Package org.gwtoolbox.sample.widget.client.layout

Source Code of org.gwtoolbox.sample.widget.client.layout.TabLayoutSample

package org.gwtoolbox.sample.widget.client.layout;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ResizeComposite;
import com.google.gwt.user.client.ui.Widget;
import org.gwtoolbox.ioc.core.client.annotation.Component;
import org.gwtoolbox.ioc.core.client.annotation.Order;
import org.gwtoolbox.sample.widget.client.SamplePanel;
import org.gwtoolbox.widget.client.button.version2.Button;
import org.gwtoolbox.widget.client.menu.Menu;
import org.gwtoolbox.widget.client.menu.MenuBuilder;
import org.gwtoolbox.widget.client.panel.layout.tab.TabLayout;
import org.gwtoolbox.widget.client.panel.layout.tab.TabSpec;

/**
* @author Uri Boness
*/
@Component
@Order(40)
@LayoutSample
public class TabLayoutSample extends ResizeComposite implements SamplePanel {

    private TabLayout tabs;

    public TabLayoutSample() {
        tabs = new TabLayout();
        initWidget(tabs);
    }

    public String getName() {
        return "Tabs";
    }

    public Widget getContentWidget() {
        return this;
    }

    public void reset() {
        tabs.clear();
        tabs.setShowDefaultContextMenu(true);
        tabs.setHideTabBarWithSingleTab(false);
        TabSpec tab1 = new TabSpec("tab1", "Tab 1", null, new HTML("This tab has a custom context menu!!!"), false);
        tab1.setMenuBuilder(new MenuBuilder() {
            public void build(Menu menu) {
                menu.addItem("Custom Action", new Command() {
                    public void execute() {
                        Window.alert("Custom Action was clicked");
                    }
                });
            }
        });
        tabs.addTab(tab1);
        tabs.addTab("Tab 2", new HTML("Tab 2 Content"));
        tabs.addTab("Tab 3", new HTML("Tab 3 Content"));
        final TabSpec tab4 = new TabSpec("tab4", "Tab 4", null, new HTML("Tab 4 Content"), true);
        tabs.addTab(tab4);
        Button button = new Button("Add Tab 4");
        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                tabs.addTab(tab4, 3);
            }
        });
        FlowPanel content5 = new FlowPanel();
        content5.add(button);

        button = new Button("Highlight 3");
        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                tabs.setTabHightlighted("Tab 3", true);
            }
        });
        content5.add(button);

        button = new Button("Rename 6", new ClickHandler() {
            public void onClick(ClickEvent event) {
                tabs.renameTab("tab6", "Tab 6 *");
            }
        });
        content5.add(button);

        tabs.addTab("Tab 5", content5);
        TabSpec tab6 = new TabSpec("tab6", "Tab 6", null, new HTML("Tab 6 Content"), true);
        tabs.addTab(tab6);

    }

}
TOP

Related Classes of org.gwtoolbox.sample.widget.client.layout.TabLayoutSample

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.