Example usage for com.google.gwt.user.client.ui TabBar getSelectedTab

List of usage examples for com.google.gwt.user.client.ui TabBar getSelectedTab

Introduction

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

Prototype

public int getSelectedTab() 

Source Link

Document

Gets the tab that is currently selected.

Usage

From source file:net.s17fabu.vip.gwt.showcase.client.Showcase.java

License:Apache License

/**
 * Create the options that appear next to the title.
 *//*www.  ja va2 s .c  om*/
private void setupOptionsPanel(ShowcaseConstants constants) {
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    if (LocaleInfo.getCurrentLocale().isRTL()) {
        vPanel.getElement().setAttribute("align", "left");
    } else {
        vPanel.getElement().setAttribute("align", "right");
    }
    app.setOptionsWidget(vPanel);

    // Add the option to change the locale
    final ListBox localeBox = new ListBox();
    String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
    if (currentLocale.equals("default")) {
        currentLocale = "en_US";
    }
    String[] localeNames = LocaleInfo.getAvailableLocaleNames();
    for (String localeName : localeNames) {
        if (!localeName.equals("default")) {
            String nativeName = LocaleInfo.getLocaleNativeDisplayName(localeName);
            localeBox.addItem(nativeName, localeName);
            if (localeName.equals(currentLocale)) {
                localeBox.setSelectedIndex(localeBox.getItemCount() - 1);
            }
        }
    }
    localeBox.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            String localeName = localeBox.getValue(localeBox.getSelectedIndex());
            Window.open(getHostPageLocation() + "?locale=" + localeName, "_self", "");
        }
    });
    HorizontalPanel localeWrapper = new HorizontalPanel();
    localeWrapper.add(images.locale().createImage());
    localeWrapper.add(new Label(constants.chooseLocale()));
    localeWrapper.add(localeBox);
    vPanel.add(localeWrapper);

    // Add the option to change the style
    final HorizontalPanel styleWrapper = new HorizontalPanel();
    vPanel.add(styleWrapper);
    for (int i = 0; i < ShowcaseConstants.STYLE_THEMES.length; i++) {
        final ThemeButton button = new ThemeButton(ShowcaseConstants.STYLE_THEMES[i]);
        styleWrapper.add(button);
        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                // Update the current theme
                CUR_THEME = button.getTheme();

                // Reload the current tab, loading the new theme if necessary
                TabBar bar = ((TabBar) app.getContentTitle());
                bar.selectTab(bar.getSelectedTab());

                // Load the new style sheets
                updateStyleSheets();
            }
        });
    }
}