/** * @deprecated will be removed in GWT 2.0 along with the listener classes */ @Deprecated public static void add(TabBar source, TabListener listener) { WrappedTabListener t = new WrappedTabListener(listener); source.addBeforeSelectionHandler(t); source.addSelectionHandler(t); }
/** * Adds a new tab with the specified text. * * @param html the new tab's html */ public void addTab(SafeHtml html) { addTab(html.asString(), true); }
/** * Adds a new tab with the specified widget. * * @param widget the new tab's widget */ public void addTab(Widget widget) { insertTab(widget, getTabCount()); }
/** * Programmatically selects the specified tab. Use index -1 to specify that no * tab should be selected. * * @param index the index of the tab to be selected * @param fireEvents true to fire events, false not to * @return <code>true</code> if successful, <code>false</code> if the change * is denied by the {@link BeforeSelectionHandler}. */ public boolean selectTab(int index, boolean fireEvents) { checkTabIndex(index); if (fireEvents) { BeforeSelectionEvent<?> event = BeforeSelectionEvent.fire(this, index); if (event != null && event.isCanceled()) { return false; } } // Check for -1. setSelectionStyle(selectedTab, false); if (index == -1) { selectedTab = null; return true; } selectedTab = panel.getWidget(index + 1); setSelectionStyle(selectedTab, true); if (fireEvents) { SelectionEvent.fire(this, index); } return true; }
public void insertTabProtected(Widget widget, int beforeIndex) { super.insertTab(widget, beforeIndex); }
/** * Programmatically selects the specified tab and fires events. Use index -1 * to specify that no tab should be selected. * * @param index the index of the tab to be selected * @return <code>true</code> if successful, <code>false</code> if the change * is denied by the {@link BeforeSelectionHandler}. */ public boolean selectTab(int index) { return selectTab(index, true); }
/** * Inserts a new tab at the specified index. * * @param widget widget to be used in the new tab * @param beforeIndex the index before which this tab will be inserted */ protected void insertTabWidget(Widget widget, int beforeIndex) { checkInsertBeforeTabIndex(beforeIndex); ClickDelegatePanel delWidget = new ClickDelegatePanel(widget); delWidget.setStyleName(STYLENAME_DEFAULT); // Add a11y role "tab" SimplePanel focusablePanel = delWidget.getFocusablePanel(); Roles.getTabRole().set(focusablePanel.getElement()); panel.insert(delWidget, beforeIndex + 1); setStyleName(DOM.getParent(delWidget.getElement()), STYLENAME_DEFAULT + "-wrapper", true); }
/** * Inserts a new tab at the specified index. * * @param text the new tab's text * @param asHTML <code>true</code> to treat the specified text as HTML * @param beforeIndex the index before which this tab will be inserted */ public void insertTab(@IsSafeHtml String text, boolean asHTML, int beforeIndex) { checkInsertBeforeTabIndex(beforeIndex); Label item; if (asHTML) { item = new HTML(text); } else { item = new Label(text); } item.setWordWrap(false); insertTabWidget(item, beforeIndex); }
public void removeTabProtected(int index) { super.removeTab(index); }
@Override public HandlerRegistration addBeforeSelectionHandler(BeforeSelectionHandler<Integer> handler) { return addHandler(handler, BeforeSelectionEvent.getType()); }
public void addSelectionHandler(SelectionHandler<Integer> handler) { tabBar.addSelectionHandler(handler); }
public WSTabPanel() { layoutPanel = new DockPanel(); layoutPanel.setSize("98%", "100%"); tabBar = new TabBar(); deckPanel = new DeckPanel(); deckPanel.setWidth("100%"); deckPanel.addStyleName("gwt-TabPanelBottom"); layoutPanel.add(tabBar, DockPanel.NORTH); layoutPanel.add(deckPanel, DockPanel.CENTER); tabBar.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> integerSelectionEvent) { deckPanel.showWidget(integerSelectionEvent.getSelectedItem()); } }); initWidget(layoutPanel); }
ClickDelegatePanel(Widget child) { focusablePanel = new SimplePanel(FocusPanel.impl.createFocusable()); focusablePanel.setWidget(child); SimplePanel wrapperWidget = createTabTextWrapper(); if (wrapperWidget == null) { initWidget(focusablePanel); } else { wrapperWidget.setWidget(focusablePanel); initWidget(wrapperWidget); } sinkEvents(Event.ONCLICK | Event.ONKEYDOWN); }
/** * Removes the tab at the specified index. * * @param index the index of the tab to be removed */ public void removeTab(int index) { checkTabIndex(index); // (index + 1) to account for 'first' placeholder widget. Widget toRemove = panel.getWidget(index + 1); if (toRemove == selectedTab) { selectedTab = null; } panel.remove(toRemove); }
/** * Inserts a new tab at the specified index. * * @param text the new tab's text * @param beforeIndex the index before which this tab will be inserted */ @SuppressIsSafeHtmlCastCheck public void insertTab(String text, int beforeIndex) { insertTab(text, false, beforeIndex); }
/** * Selects the tab corresponding to the widget for the tab. To be clear the * widget for the tab is not the widget INSIDE of the tab; it is the widget * used to represent the tab itself. * * @param tabWidget The widget for the tab to be selected * @return true if the tab corresponding to the widget for the tab could * located and selected, false otherwise */ private boolean selectTabByTabWidget(Widget tabWidget) { int numTabs = panel.getWidgetCount() - 1; for (int i = 1; i < numTabs; ++i) { if (panel.getWidget(i) == tabWidget) { return selectTab(i - 1); } } return false; }
/** * Inserts a new tab at the specified index. * * @param widget widget to be used in the new tab * @param beforeIndex the index before which this tab will be inserted */ protected void insertTabWidget(Widget widget, int beforeIndex) { checkInsertBeforeTabIndex(beforeIndex); ClickDelegatePanel delWidget = new ClickDelegatePanel(widget); delWidget.setStyleName(STYLENAME_DEFAULT); // Add a11y role "tab" SimplePanel focusablePanel = delWidget.getFocusablePanel(); Roles.getTabRole().set(focusablePanel.getElement()); panel.insert(delWidget, beforeIndex + 1); setStyleName(DOM.getParent(delWidget.getElement()), STYLENAME_DEFAULT + "-wrapper", true); }
/** * Inserts a new tab at the specified index. * * @param text the new tab's text * @param asHTML <code>true</code> to treat the specified text as HTML * @param beforeIndex the index before which this tab will be inserted */ public void insertTab(String text, boolean asHTML, int beforeIndex) { checkInsertBeforeTabIndex(beforeIndex); Label item; if (asHTML) { item = new HTML(text); } else { item = new Label(text); } item.setWordWrap(false); insertTabWidget(item, beforeIndex); }
/** * Programmatically selects the specified tab. Use index -1 to specify that no * tab should be selected. * * @param index the index of the tab to be selected * @param fireEvents true to fire events, false not to * @return <code>true</code> if successful, <code>false</code> if the change * is denied by the {@link BeforeSelectionHandler}. */ public boolean selectTab(int index, boolean fireEvents) { checkTabIndex(index); if (fireEvents) { BeforeSelectionEvent<?> event = BeforeSelectionEvent.fire(this, index); if (event != null && event.isCanceled()) { return false; } } // Check for -1. setSelectionStyle(selectedTab, false); if (index == -1) { selectedTab = null; return true; } selectedTab = panel.getWidget(index + 1); setSelectionStyle(selectedTab, true); if (fireEvents) { SelectionEvent.fire(this, index); } return true; }
public void removeTabProtected(int index) { super.removeTab(index); }