WindowUIHandler.java :  » Web-Framework » swingweb » org » onemind » swingweb » client » gwt » ui » Java Open Source

Java Open Source » Web Framework » swingweb 
swingweb » org » onemind » swingweb » client » gwt » ui » WindowUIHandler.java
/*
 * Copyright (C) 2004 TiongHiang Lee
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not,  write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Email: thlee@onemindsoft.org
 */

package org.onemind.swingweb.client.gwt.ui;

import org.onemind.swingweb.client.core.AbstractClient;
import org.onemind.swingweb.client.dom.DomNode;
import org.onemind.swingweb.client.gwt.widget.*;
import com.google.gwt.user.client.ui.Widget;
public class WindowUIHandler extends ContainerUIHandler implements WindowListener
{

    public WindowUIHandler(AbstractClient client)
    {
        super(client);
    }

    /** 
     * {@inheritDoc}
     */
    protected Object updateUI(Object com, DomNode element)
    {
        MoveableWindow w = (MoveableWindow) com;
        String title = element.getAttribute("title");
        if (title != null)
        {
            w.setTitle(title);
        }
        return super.updateUI(com, element);
    }

    /** 
     * {@inheritDoc}
     */
    public void windowClosed(Widget sender)
    {
        postEvent(sender, "close", true);
    }

    /** 
     * {@inheritDoc}
     */
    public void windowMaximized(Widget sender)
    {
        postEvent(sender, "maximize", true);
    }

    /** 
     * {@inheritDoc}
     */
    public void windowMinimized(Widget sender)
    {
        postEvent(sender, "minimize", true);
    }

    protected void addWidgetToContainer(IContainer c, Widget widget, CellInfo info)
    {
        if (widget instanceof TitleBar)
        {
            //TODO: there's issue with internal frame (x, y of mouse event incorrect)
            //((MoveableWindow)c).setTitleBar((TitleBar)widget);
        } else
        {
            super.addWidgetToContainer(c, widget, info);
        }
    }

    /** 
     * {@inheritDoc}
     */
    protected void registerListeners(Object com)
    {
        ((MoveableWindow) com).addWindowListener(this);
        super.registerListeners(com);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.