Package org.onemind.swingweb.client.gwt.ui

Source Code of org.onemind.swingweb.client.gwt.ui.AbstractGWTUIHandler

/*
* 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.core.ui.AbstractUIHandler;
import org.onemind.swingweb.client.core.ui.EventInterceptor;
import org.onemind.swingweb.client.dom.DomNode;
import org.onemind.swingweb.client.gwt.GwtClient;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.UIObject;
public abstract class AbstractGWTUIHandler extends AbstractUIHandler
{

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

    protected Object updateUI(Object com, DomNode element)
    {
        if (((GwtClient) getClient()).isUseJavaNameForStyle())
        {
            String styleName = getStyleName(element);
            ((UIObject) com).setStyleName(styleName);
        };
        return com;
    };

    protected String getStyleName(DomNode element)
    {
        return element.getAttribute("class").replaceAll("\\.", "_");
    }

    public final void handleEvent(Object source, Object data)
    {
        EventInterceptor interceptor = getClient().getEventInterceptor(source);
        if (interceptor != null)
        {
            if (interceptor.interceptEvent(source, data))
            {
                postEvent(source, data);
            }
        } else
        {
            postEvent(source, data);
        }
    }

    public String getName()
    {
        String className = GWT.getTypeName(this);
        return className.substring(className.lastIndexOf('.') + 1);
    }

    protected abstract void postEvent(Object source, Object data);
}
TOP

Related Classes of org.onemind.swingweb.client.gwt.ui.AbstractGWTUIHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.