Example usage for com.google.gwt.user.client.ui TabPanel addBeforeSelectionHandler

List of usage examples for com.google.gwt.user.client.ui TabPanel addBeforeSelectionHandler

Introduction

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

Prototype

public HandlerRegistration addBeforeSelectionHandler(BeforeSelectionHandler<Integer> handler) 

Source Link

Usage

From source file:cc.alcina.framework.gwt.client.widget.LazyPanel.java

License:Apache License

/**
 * Adds a tab listener to ensure that any {@link LazyPanel} instances are
 * loaded when a tab panel selects the lazy panel's tab.
 * //w  w  w  . java  2  s  .c o m
 * @param panel
 *            to add listener to
 */
public static void addBeforeSelectionHandler(final TabPanel panel) {
    panel.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
        public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            Integer tabIndex = event.getItem();
            Widget widget = panel.getWidget(tabIndex);
            if (widget instanceof LazyPanel) {
                ((LazyPanel) widget).ensureWidget();
            }
        }
    });
}

From source file:org.drools.guvnor.client.asseteditor.drools.WorkingSetEditor.java

License:Apache License

private void refreshWidgets() {
    WorkingSetConfigData wsData = (WorkingSetConfigData) workingSet.getContent();

    TabPanel tPanel = new TabPanel();
    //tPanel.setWidth(800);
    ScrollPanel pnl = new ScrollPanel();
    //        pnl.setAutoWidth(true);
    //pnl.setClosable(false);
    pnl.setTitle("WS Definition"); //TODO {bauna} i18n
    //        pnl.setAutoHeight(true);
    pnl.add(buildDoubleList(wsData));/*  w  w w.jav  a  2 s .c o m*/
    tPanel.add(pnl, "WS Definition");

    pnl = new ScrollPanel();
    //        pnl.setAutoWidth(true);
    //pnl.setClosable(false);
    //pnl.setTitle("WS Constraints"); //TODO {bauna} i18n
    //        pnl.setAutoHeight(true);
    this.factsConstraintsgEditorPanel = new FactsConstraintsEditorPanel(this);
    pnl.add(this.factsConstraintsgEditorPanel);
    tPanel.add(pnl, "WS Constraints");

    pnl = new ScrollPanel();
    //        pnl.setAutoWidth(true);
    //pnl.setClosable(false);
    pnl.setTitle("WS Custom Forms"); //TODO {bauna} i18n
    //        pnl.setAutoHeight(true);
    this.customFormsEditorPanel = new CustomFormsEditorPanel(this);
    pnl.add(this.customFormsEditorPanel);
    tPanel.add(pnl, "WS Custom Forms");
    tPanel.addBeforeSelectionHandler(new BeforeSelectionHandler<java.lang.Integer>() {

        public void onBeforeSelection(BeforeSelectionEvent<java.lang.Integer> arg0) {
            factsConstraintsgEditorPanel.fillSelectedFacts();
            customFormsEditorPanel.fillSelectedFacts();
        }

    });

    tPanel.selectTab(0);
    initWidget(tPanel);
}

From source file:org.drools.guvnor.client.ruleeditor.WorkingSetEditor.java

License:Apache License

private void refreshWidgets() {
    WorkingSetConfigData wsData = (WorkingSetConfigData) workingSet.content;

    TabPanel tPanel = new TabPanel();
    //tPanel.setWidth(800);
    ScrollPanel pnl = new ScrollPanel();
    //        pnl.setAutoWidth(true);
    //pnl.setClosable(false);
    pnl.setTitle("WS Definition"); //TODO {bauna} i18n
    //        pnl.setAutoHeight(true);
    pnl.add(buildDoubleList(wsData));/*www.j  a  va2  s  .  c  om*/
    tPanel.add(pnl, "WS Definition");

    pnl = new ScrollPanel();
    //        pnl.setAutoWidth(true);
    //pnl.setClosable(false);
    //pnl.setTitle("WS Constraints"); //TODO {bauna} i18n
    //        pnl.setAutoHeight(true);
    this.factsConstraintsgEditorPanel = new FactsConstraintsEditorPanel(this);
    pnl.add(this.factsConstraintsgEditorPanel);
    tPanel.add(pnl, "WS Constraints");

    pnl = new ScrollPanel();
    //        pnl.setAutoWidth(true);
    //pnl.setClosable(false);
    pnl.setTitle("WS Custom Forms"); //TODO {bauna} i18n
    //        pnl.setAutoHeight(true);
    this.customFormsEditorPanel = new CustomFormsEditorPanel(this);
    pnl.add(this.customFormsEditorPanel);
    tPanel.add(pnl, "WS Custom Forms");
    tPanel.addBeforeSelectionHandler(new BeforeSelectionHandler<java.lang.Integer>() {

        public void onBeforeSelection(BeforeSelectionEvent<java.lang.Integer> arg0) {
            factsConstraintsgEditorPanel.fillSelectedFacts();
            customFormsEditorPanel.fillSelectedFacts();
        }

    });

    tPanel.selectTab(0);
    initWidget(tPanel);
}

From source file:org.opendatakit.aggregate.client.AggregateUI.java

License:Apache License

void setSubMenuSelectionHandler(final TabPanel menuTab, final Tabs menu, final SubTabs[] subMenus) {
    // add the mainNav selection handler for this menu...
    mainNav.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override//ww w  . ja  v a2s. c o m
        public void onSelection(SelectionEvent<Integer> event) {
            if (userInfo == null) {
                GWT.log("getSubMenuSelectionHandler: No userInfo - not setting selection");
                return;
            }

            int selected = event.getSelectedItem();
            String tabHash = menu.getHashString();

            Tabs tab = tabPosition.get(selected);

            if (tab == null) {
                return;
            }

            if (tabHash.equals(tab.getHashString())) {

                if (!authorizedForTab(tab)) {
                    return;
                }

                // and select the appropriate subtab...
                AggregateTabBase tabObj = tabMap.get(menu);
                if (tabObj != null) {
                    tabObj.selectTab(tabObj.findSubTabIndexFromHash(hash));
                }
            }
        }
    });

    menuTab.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {

        @Override
        public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            // allow the currently-selected SubTab to refuse the tab selection.
            // refusal should only occur after user confirmation.
            if (!getTimer().canLeaveCurrentSubTab()) {
                event.cancel();
            }
        }

    });

    menuTab.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            if (userInfo == null) {
                GWT.log("getSubMenuSelectionHandler: No userInfo - not setting subMenu selection");
                return;
            }
            int selected = event.getSelectedItem();
            clearError();
            hash.clear();
            hash.set(UrlHash.MAIN_MENU, menu.getHashString());
            hash.set(UrlHash.SUB_MENU, subMenus[selected].getHashString());
            getTimer().setCurrentSubTab(subMenus[selected]);
            hash.put();
            changeHelpPanel(subMenus[selected]);
        }
    });
}

From source file:org.switchyard.console.client.ui.service.ServiceEditor.java

License:Apache License

/**
 * @return this editor as a Widget.//from  w w w  . j  a v a  2s  .co m
 */
public Widget asWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.add(new ContentGroupLabel(Singleton.MESSAGES.label_serviceDetails()));
    panel.add(new ContentDescription(Singleton.MESSAGES.description_serviceDetails()));
    panel.add(createImplementationDetailsPanel());

    TabPanel tabs = new TabPanel();
    tabs.setStyleName("default-tabpanel"); //$NON-NLS-1$
    tabs.getElement().setAttribute("style", "margin-top:15px;"); //$NON-NLS-1$ //$NON-NLS-2$
    tabs.add(createGatewayDetailsPanel(), Singleton.MESSAGES.label_gateways());
    tabs.add(createThrottlingDetailsPanel(), Singleton.MESSAGES.label_throttling());
    tabs.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
        @Override
        public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            _toolstrip.doCancel();
        }
    });

    panel.add(tabs);
    tabs.selectTab(0);

    return panel;
}

From source file:org.xwiki.gwt.wysiwyg.client.WysiwygEditor.java

License:Open Source License

/**
 * Build the editor tab panel. This panel contains two tabs, one for the WYSIWYG editor and one for the source
 * editor./*from  w  w w .j  a  va2  s. c  o m*/
 * 
 * @return the newly created tab panel
 */
private TabPanel createTabPanel() {
    PlainTextEditor plainTextEditor = new PlainTextEditor(config.getHook());

    TabPanel tabs = new TabPanel();
    tabs.add(getRichTextEditor(), Strings.INSTANCE.wysiwyg());
    tabs.add(plainTextEditor, Strings.INSTANCE.source());
    tabs.setStyleName("xRichTextEditorTabPanel");
    tabs.setAnimationEnabled(false);
    tabs.selectTab(config.getSelectedTabIndex());

    // Enable the appropriate text area based on the type of input (source or HTML).
    boolean richTextAreaEnabled = config.isInputConverted();
    plainTextEditor.getTextArea().setEnabled(!richTextAreaEnabled);
    getRichTextEditor().getTextArea().setEnabled(richTextAreaEnabled);

    saveRegistration(tabs.addBeforeSelectionHandler(switcher));
    saveRegistration(tabs.addSelectionHandler(new SelectionHandler<Integer>() {
        public void onSelection(SelectionEvent<Integer> event) {
            // Cache the active text area.
            config.setSelectedTabIndex(event.getSelectedItem());
        }
    }));
    saveRegistration(tabs.addSelectionHandler(switcher));

    return tabs;
}