Package org.gwtoolbox.widget.client.panel.tab

Examples of org.gwtoolbox.widget.client.panel.tab.SimpleTabPanel


@PanelSample
public class SimpleTabPanelSamplePane extends LayoutComposite implements SamplePanel {

    public SimpleTabPanelSamplePane() {

        final SimpleTabPanel panel = new SimpleTabPanel(true);

        panel.addTab(new TabSpec("tab1", "Tab 1", null, new Label("Tab 1 content"), true));

        ScrollPanel content2 = new ScrollPanel(createContent(createVeryLongText(), "#CCFFCC"));
        content2.setSize("100%", "100%");
        panel.addTab("Tab 2", content2);

        SimpleHorizontalSplitPanel hsp = new SimpleHorizontalSplitPanel();
        hsp.setLeftWidget(new Label("Left"));
        hsp.setRightWidget(new Label("Right"));
        hsp.setSplitPosition("25%");
        hsp.setSize("100%", "100%");
        panel.addTab("Tab 3", hsp);

        TabSpec tab4 = new TabSpec("tab4", "Tab 4", null, new Label("Confent for Tab 4"), false).setMenuBuilder(new MenuBuilder() {
            public void build(Menu menu) {
                CheckMenuItem item = new CheckMenuItem("Disable", !panel.isTabEnabled("tab4"));
                item.addListener(new MenuItemSelectionListener() {
                    public void selectionChanged(SelectionMenuItem item) {
                        panel.setTabEnabled("tab4", !item.isSelected());
                    }
                });
                menu.addItem(item);
            }
        });
        panel.addTab(tab4);
//        panel.addTab("Tab 4", new Label("Content 4"));
        panel.addTab("Tab 5", new Label("Content 5"));
        panel.addTab("Tab 6", new Label("Content 6"));
        panel.setSelectedTab("Tab 3");

        panel.setWidth("100%");
//        panel.setHeight("500px");
        panel.setHeight("100%");
        DOM.setStyleAttribute(panel.getElement(), "borderBottom", "1px solid blue");

        HorizontalPanel hp = new HorizontalPanel();

        SimpleButton button = new SimpleButton("Remove Tab 1", new ClickHandler() {
            public void onClick(ClickEvent event) {
                panel.removeTab("Tab 1");
            }
        });
        hp.add(button);

        addGap(hp, "10px");

        button = new SimpleButton("Clear Tabs", new ClickHandler() {
            public void onClick(ClickEvent event) {
                panel.clear();
            }
        });
        hp.add(button);

        addGap(hp, "10px");

        button = new SimpleButton("Add Tab...", new ClickHandler() {
            public void onClick(ClickEvent event) {
                String tabName = Window.prompt("Enter the tab name", "");
                if (tabName != null) {
                    TabSpec tabSpec = new TabSpec(tabName, tabName, null, new Label("This is the content of '" + tabName + "'"), true);
                    panel.addTab(tabSpec);
                }
            }
        });
        hp.add(button);

        addGap(hp, "10px");

        button = new SimpleButton("Add Tab (Auto)", new ClickHandler() {
            public void onClick(ClickEvent event) {
                String tabName = "Tab " + (panel.getTabCount() + 1);
                GWT.log(tabName, null);
                panel.addTab(tabName, new Label("This is the content of '" + tabName + "'"));
                if (panel.getTabCount() % 2 == 0) {
                    panel.setTabEnabled(tabName, false);
                }
            }
        });
        hp.add(button);

        addGap(hp, "10px");

        button = new SimpleButton("Enable Tab 4", new ClickHandler() {
            public void onClick(ClickEvent event) {
                panel.setTabEnabled("tab4", true);
            }
        });
        hp.add(button);

        DOM.setStyleAttribute(panel.getElement(), "border", "1px solid blue");

//        FixedVerticalPanel main = new FixedVerticalPanel();
//        main.addGap("20px");
//        main.addWidget(panel, new VerticalLayoutData("350px").setOverflow("hidden"));
//        main.addGap("5px");
View Full Code Here

TOP

Related Classes of org.gwtoolbox.widget.client.panel.tab.SimpleTabPanel

Copyright © 2018 www.massapicom. 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.