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

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

/*
* 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 java.util.List;
import org.onemind.swingweb.client.core.AbstractClient;
import org.onemind.swingweb.client.dom.DomNode;
import org.onemind.swingweb.client.gwt.widget.IContainer;
import org.onemind.swingweb.client.gwt.widget.TabContainer;
import com.google.gwt.user.client.ui.*;
public class TabbedPaneUIHandler extends ContainerUIHandler implements TabListener
{

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

    protected void selectTab(SourcesTabEvents sender, int tabIndex)
    {
        // TODO Auto-generated method stub
    }

    /**
     * {@inheritDoc}
     */
    protected void registerListeners(Object com)
    {
        ((TabContainer) com).addTabListener(this);
    }

    /**
     * {@inheritDoc}
     */
    protected Object createComponentInstance(Object parent, DomNode element)
    {
        TabContainer t = new TabContainer();
        return t;
    }

    /**
     * {@inheritDoc}
     */
    protected void handleChildren(AbstractClient rootHandler, IContainer c, DomNode element)
    {
        TabContainer tabCon = (TabContainer) c;
        tabCon.clearTabs();
        List tabsList = getChildrenByTag(element, "tabs");
        if (tabsList.size() > 0)
        {
            DomNode tabsNode = (DomNode) tabsList.get(0);
            List tabs = getChildrenByTag(tabsNode, "tab");
            for (int i = 0; i < tabs.size(); i++)
            {
                DomNode tabNode = (DomNode) tabs.get(i);
                String label = tabNode.getAttribute("label");
                String selected = tabNode.getAttribute("selected");
                tabCon.addTab(label);
                if ("true".equalsIgnoreCase(selected))
                {
                    tabCon.setActiveTab(i);
                }
            }
        }
        List tabContent = getChildrenByTag(element, "tabContent");
        for (int i = 0; i < tabContent.size(); i++)
        {
            DomNode contentNode = (DomNode) tabContent.get(i);
            List colList = getChildrenByTag(contentNode, "element");
            if (colList.size() > 0)
            {
                DomNode elementNode = (DomNode) colList.get(0);
                Widget content = (Widget) getClient().handle(this, elementNode);
                tabCon.setContent(content);
            }
        }
    }

    public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex)
    {
        TabBar tb = (TabBar) sender;
        return true;
    }

    public void onTabSelected(SourcesTabEvents sender, int tabIndex)
    {
        TabBar tb = (TabBar) sender;
        handleEvent(tb.getParent(), String.valueOf(tabIndex));
    }

    public void postEvent(Object sender, Object data)
    {
        postEvent(sender, data, true);
    }
}
TOP

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

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.