Example usage for com.google.gwt.user.client.ui TabLayoutPanel selectTab

List of usage examples for com.google.gwt.user.client.ui TabLayoutPanel selectTab

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui TabLayoutPanel selectTab.

Prototype

public void selectTab(Widget child) 

Source Link

Document

Programmatically selects the specified tab and fires events.

Usage

From source file:com.github.tdesjardins.ol3.demo.client.GwtOLPlayground.java

License:Apache License

@Override
public void onModuleLoad() {

    Map<String, Integer> exampleIndexMap = new HashMap<>();

    // choose your example
    TabLayoutPanel tabs = new TabLayoutPanel(27, Style.Unit.PX);

    int index = 0;

    for (OLExampleType example : OLExampleType.values()) {
        tabs.add(new LazyExampleWidget(example), example.name().replace("Example", ""));
        exampleIndexMap.put(example.name(), index);
        index++;//from  ww  w .j  a  va  2  s.  com
    }
    RootLayoutPanel.get().add(tabs);

    String token = History.getToken();

    if (token != null && exampleIndexMap.containsKey(token)) {
        tabs.selectTab(exampleIndexMap.get(token));
    }
}

From source file:com.google.gwt.gwtai.demo.client.GwtAI.java

License:Apache License

/**
 * This is the entry point method./* w ww  .j  a v  a2 s . co  m*/
 */
public void onModuleLoad() {
    TabLayoutPanel tabPanel = new TabLayoutPanel(30, Unit.PX);
    tabPanel.setWidth("600px");

    tabPanel.add(new CounterAppletTab(), "Counter");
    tabPanel.add(new StopWatchAppletTab(), "Stop Watch");
    tabPanel.add(new TrayIconAppletTab(), "Tray Icon");
    tabPanel.add(createCallbackApplet(), "CallbackApplet");

    tabPanel.selectTab(0);

    RootLayoutPanel.get().add(tabPanel);
}

From source file:com.google.gwt.sample.showcase.client.content.panels.CwTabLayoutPanel.java

License:Apache License

/**
 * Initialize this example.//w w  w .j  av a 2  s .c om
 */
@ShowcaseSource
@Override
public Widget onInitialize() {
    // Create a tab panel
    TabLayoutPanel tabPanel = new TabLayoutPanel(2.5, Unit.EM);
    tabPanel.setAnimationDuration(1000);
    tabPanel.getElement().getStyle().setMarginBottom(10.0, Unit.PX);

    // Add a home tab
    String[] tabTitles = constants.cwTabPanelTabs();
    HTML homeText = new HTML(constants.cwTabPanelTab0());
    tabPanel.add(homeText, tabTitles[0]);

    // Add a tab with an image
    SimplePanel imageContainer = new SimplePanel();
    imageContainer.setWidget(new Image(Showcase.images.gwtLogo()));
    tabPanel.add(imageContainer, tabTitles[1]);

    // Add a tab
    HTML moreInfo = new HTML(constants.cwTabPanelTab2());
    tabPanel.add(moreInfo, tabTitles[2]);

    // Return the content
    tabPanel.selectTab(0);
    tabPanel.ensureDebugId("cwTabPanel");

    return tabPanel;
}

From source file:com.rhizospherejs.gwt.showcase.client.ShowcaseEntryPoint.java

License:Open Source License

@Override
public void onModuleLoad() {
    // Injects styles shared by all tabs.
    Resources.INSTANCE.tabsCss().ensureInjected();

    // Create the main tab layout.
    final TabLayoutPanel tabs = new TabLayoutPanel(2, Unit.EM);
    tabs.setStyleName(Resources.INSTANCE.tabsCss().rhizosphereTabs(), true);
    tabs.add(new IntroTab(), "Introduction");
    tabs.add(OrgChartTab.get(), "Org Chart demo");
    tabs.add(BooksTab.get(), "Google Books demo");
    tabs.add(GoogleVisualizationTab.get(), "Google Visualization API demo");

    DockLayoutPanel dock = new DockLayoutPanel(Unit.EM);
    dock.addNorth(new HeaderBar(), 5);
    dock.add(tabs);//from  w w  w.  j ava  2  s .  c  o m

    // History management.
    tabs.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            String tabid = "";
            switch (event.getSelectedItem()) {
            case 0:
                tabid = "intro";
                break;
            case 1:
                tabid = "orgchart";
                break;
            case 2:
                tabid = "books";
                break;
            case 3:
                tabid = "gviz";
                break;
            default:
            }
            if (tabid.length() > 0) {
                History.newItem(tabid);
            }
        }
    });

    History.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String historyToken = event.getValue();
            tabs.selectTab(tabNumberFromToken(historyToken));
        }
    });

    tabs.selectTab(tabNumberFromToken(History.getToken()));
    RootLayoutPanel.get().add(dock);
}

From source file:fr.drop.client.content.about.CwTabLayoutPanel.java

License:Apache License

/**
 * Initialize this example.//from   w w w. j  av  a 2 s.  com
 */
@DropSource
@Override
public Widget onInitialize() {
    // Create a tab panel
    TabLayoutPanel tabPanel = new TabLayoutPanel(2.5, Unit.EM);
    tabPanel.setAnimationDuration(1000);
    tabPanel.getElement().getStyle().setMarginBottom(10.0, Unit.PX);

    // Add a home tab
    String[] tabTitles = constants.cwTabPanelTabs();
    HTML homeText = new HTML(constants.cwTabPanelTab0());
    tabPanel.add(homeText, tabTitles[0]);

    // Add a tab with an image
    SimplePanel imageContainer = new SimplePanel();
    imageContainer.setWidget(new Image(Drop.images.gwtLogo()));
    tabPanel.add(imageContainer, tabTitles[1]);

    // Add a tab
    HTML moreInfo = new HTML(constants.cwTabPanelTab2());
    tabPanel.add(moreInfo, tabTitles[2]);

    // Return the content
    tabPanel.selectTab(0);
    tabPanel.ensureDebugId("cwTabPanel");

    return tabPanel;
}

From source file:org.glom.web.client.ui.details.Notebook.java

License:Open Source License

/**
 * Create a new Notebook widget based on the specified LayoutItemNotebook DTO.
 * //  ww w.  j  av a2s .  c  o  m
 * @param layoutItemNotebook
 */
public Notebook(final LayoutItemNotebook layoutItemNotebook) {
    // The height of the TabLayoutPanel needs to be set to make the child widgets visible. The height of the tab bar
    // also needs to be explicitly set. To work around these constraints, we're setting the tab height based on the
    // tab text and decorations as set in the CSS. The height of the TabLayoutPanel will be set to be the height of
    // the tab panel plus the height of the decorated tab content panel plus the height of the tallest child widget.

    final int tabBarHeight = getDecoratedTabBarHeight();
    final int emptyTabContentHeight = getDecoratedEmptyTabContentHeight();

    final TabLayoutPanel tabPanel = new TabLayoutPanel(tabBarHeight, Unit.PX);

    int maxChildHeight = 0;
    for (final LayoutItem layoutItem : layoutItemNotebook.getItems()) {
        if (!(layoutItem instanceof LayoutGroup)) {
            // Ignore non-LayoutGroup items. This is what Glom 1.18 does.
            continue;
        }

        // child groups of Notebooks shouldn't show their titles
        final Widget child = createChildWidget(layoutItem, false);

        // update the maximum value of the child height if required
        final int childHeight = Utils.getWidgetHeight(child);
        if (childHeight > maxChildHeight) {
            maxChildHeight = childHeight;
        }

        // Use the name if the title is empty. This avoids having tabs with empty labels.
        tabPanel.add(child,
                StringUtils.isEmpty(layoutItem.getTitle()) ? layoutItem.getName() : layoutItem.getTitle());
    }

    // Set the first tab as the default tab.
    tabPanel.selectTab(0);

    // Add a CSS class name for the first tab.
    if (tabPanel.getWidgetCount() > 0) {
        final Element element = tabPanel.getElement().getFirstChildElement().getNextSiblingElement()
                .getFirstChildElement().getFirstChildElement();
        element.addClassName("firstTab");
    }

    // Use the max child height plus the height of the tab bar and the height of an empty content panel.
    tabPanel.setHeight((tabBarHeight + emptyTabContentHeight + maxChildHeight) + "px");

    initWidget(tabPanel);
}

From source file:org.jboss.as.console.client.shared.subsys.messaging.MessagingView.java

License:Open Source License

@Override
public Widget createWidget() {

    TabLayoutPanel tabLayoutpanel = new TabLayoutPanel(40, Style.Unit.PX);
    tabLayoutpanel.addStyleName("default-tabpanel");

    providerEditor = new MessagingProviderEditor(presenter);
    jmsEditor = new JMSEditor(presenter);

    tabLayoutpanel.add(providerEditor.asWidget(), Console.CONSTANTS.subsys_messaging_jms_provider());
    tabLayoutpanel.add(jmsEditor.asWidget(), Console.CONSTANTS.subsys_messaging_jms_destinations());

    tabLayoutpanel.selectTab(0);

    return tabLayoutpanel;
}

From source file:org.jbpm.formbuilder.client.edition.EditionViewImpl.java

License:Apache License

@Override
public void selectTab() {
    Widget parent = getParent();/*from  w  ww  . jav a 2 s.c o  m*/
    while (!(parent instanceof TabLayoutPanel)) {
        parent = parent.getParent();
    }
    TabLayoutPanel tab = (TabLayoutPanel) parent;
    tab.selectTab(this);
}