private void checkInsertBeforeTabIndex(int beforeIndex) { if ((beforeIndex < 0) || (beforeIndex > getTabCount())) { throw new IndexOutOfBoundsException(); } }
private void checkTabIndex(int index) { if ((index < -1) || (index >= getTabCount())) { throw new IndexOutOfBoundsException(); } }
/** * Adds a new tab with the specified widget. * * @param widget the new tab's widget */ public void addTab(Widget widget) { insertTab(widget, getTabCount()); }
/** * Adds a new tab with the specified text. * * @param text the new tab's text */ public void addTab(String text) { insertTab(text, getTabCount()); }
/** * Gets the given tab. * * This method is final because the Tab interface will expand. Therefore * it is highly likely that subclasses which implemented this method would end up * breaking. * * @param index the tab's index * @return the tab wrapper */ public final Tab getTab(int index) { if (index >= getTabCount()) { return null; } ClickDelegatePanel p = (ClickDelegatePanel) panel.getWidget(index + 1); return p; }
/** * Check if a tab is enabled or disabled. If disabled, the user cannot select * the tab. * * @param index the index of the tab * @return true if the tab is enabled, false if disabled */ public boolean isTabEnabled(int index) { assert (index >= 0) && (index < getTabCount()) : "Tab index out of bounds"; ClickDelegatePanel delPanel = (ClickDelegatePanel) panel.getWidget(index + 1); return delPanel.isEnabled(); }
/** * Adds a new tab with the specified text. * * @param text the new tab's text * @param asHTML <code>true</code> to treat the specified text as html */ public void addTab(@IsSafeHtml String text, boolean asHTML) { insertTab(text, asHTML, getTabCount()); }
/** * Sets a tab's text contents. * * @param index the index of the tab whose text is to be set * @param text the object's new text */ public void setTabText(int index, String text) { assert (index >= 0) && (index < getTabCount()) : "Tab index out of bounds"; ClickDelegatePanel delPanel = (ClickDelegatePanel) panel.getWidget(index + 1); SimplePanel focusablePanel = delPanel.getFocusablePanel(); // It is not safe to check if the current widget is an instanceof Label and // reuse it here because HTML is an instanceof Label. Leaving an HTML would // throw off the results of getTabHTML(int). focusablePanel.setWidget(new Label(text, false)); }
/** * Sets a tab's contents via HTML. * * Use care when setting an object's HTML; it is an easy way to expose * script-based security problems. Consider using * {@link #setTabText(int, String)} or {@link #setTabHTML(int, SafeHtml)} * whenever possible. * * @param index the index of the tab whose HTML is to be set * @param html the tab new HTML */ public void setTabHTML(int index, @IsSafeHtml String html) { assert (index >= 0) && (index < getTabCount()) : "Tab index out of bounds"; ClickDelegatePanel delPanel = (ClickDelegatePanel) panel.getWidget(index + 1); SimplePanel focusablePanel = delPanel.getFocusablePanel(); focusablePanel.setWidget(new HTML(html, false)); }
/** * Enable or disable a tab. When disabled, users cannot select the tab. * * @param index the index of the tab to enable or disable * @param enabled true to enable, false to disable */ public void setTabEnabled(int index, boolean enabled) { assert (index >= 0) && (index < getTabCount()) : "Tab index out of bounds"; // Style the wrapper ClickDelegatePanel delPanel = (ClickDelegatePanel) panel.getWidget(index + 1); delPanel.setEnabled(enabled); setStyleName(delPanel.getElement(), "gwt-TabBarItem-disabled", !enabled); setStyleName(delPanel.getElement().getParentElement(), "gwt-TabBarItem-wrapper-disabled", !enabled); }
/** * Gets the specified tab's HTML. * * @param index the index of the tab whose HTML is to be retrieved * @return the tab's HTML */ public String getTabHTML(int index) { if (index >= getTabCount()) { return null; } ClickDelegatePanel delPanel = (ClickDelegatePanel) panel.getWidget(index + 1); SimplePanel focusablePanel = delPanel.getFocusablePanel(); Widget widget = focusablePanel.getWidget(); if (widget instanceof HTML) { return ((HTML) widget).getHTML(); } else if (widget instanceof Label) { return ((Label) widget).getText(); } else { // This will be a focusable panel holding a user-supplied widget. return focusablePanel.getElement().getParentElement().getInnerHTML(); } }
/** * <b>Affected Elements:</b> * <ul> * <li>-tab# = The element containing the contents of the tab.</li> * <li>-tab-wrapper# = The cell containing the tab at the index.</li> * </ul> * * @see UIObject#onEnsureDebugId(String) */ @Override protected void onEnsureDebugId(String baseID) { super.onEnsureDebugId(baseID); int numTabs = getTabCount(); for (int i = 0; i < numTabs; i++) { ClickDelegatePanel delPanel = (ClickDelegatePanel) panel.getWidget(i + 1); SimplePanel focusablePanel = delPanel.getFocusablePanel(); ensureDebugId(focusablePanel.getContainerElement(), baseID, "tab" + i); ensureDebugId(DOM.getParent(delPanel.getElement()), baseID, "tab-wrapper" + i); } }
private void checkInsertBeforeTabIndex(int beforeIndex) { if ((beforeIndex < 0) || (beforeIndex > getTabCount())) { throw new IndexOutOfBoundsException(); } }
private void checkTabIndex(int index) { if ((index < -1) || (index >= getTabCount())) { throw new IndexOutOfBoundsException(); } }
private void checkTabIndex(int index) { if ((index < -1) || (index >= getTabCount())) { throw new IndexOutOfBoundsException(); } }
/** * Adds a new tab with the specified text. * * @param text the new tab's text * @param asHTML <code>true</code> to treat the specified text as html */ public void addTab(String text, boolean asHTML) { insertTab(text, asHTML, getTabCount()); }
/** * Adds a new tab with the specified text. * * @param text the new tab's text * @param asHTML <code>true</code> to treat the specified text as html */ public void addTab(String text, boolean asHTML) { insertTab(text, asHTML, getTabCount()); }
/** * Adds a new tab with the specified widget. * * @param widget the new tab's widget */ public void addTab(Widget widget) { insertTab(widget, getTabCount()); }
/** * Check if a tab is enabled or disabled. If disabled, the user cannot select * the tab. * * @param index the index of the tab * @return true if the tab is enabled, false if disabled */ public boolean isTabEnabled(int index) { assert (index >= 0) && (index < getTabCount()) : "Tab index out of bounds"; ClickDelegatePanel delPanel = (ClickDelegatePanel) panel.getWidget(index + 1); return delPanel.isEnabled(); }
/** * Check if a tab is enabled or disabled. If disabled, the user cannot select * the tab. * * @param index the index of the tab * @return true if the tab is enabled, false if disabled */ public boolean isTabEnabled(int index) { assert (index >= 0) && (index < getTabCount()) : "Tab index out of bounds"; ClickDelegatePanel delPanel = (ClickDelegatePanel) panel.getWidget(index + 1); return delPanel.isEnabled(); }