/** * Checks if tabs are needed and hides them if not */ private void checkIfTabsNeeded() { tabs.setTabsVisible(tabs.getComponentCount() > 1); }
/** * Returns the {@link Tab} (metadata) with the given index. The {@link Tab} * object can be used for setting caption,icon, etc for the tab. * * @param index * the index of the tab * @return The tab with the given index, or null if the index is out of * bounds. */ public Tab getTab(int index) { if (index >= 0 && index < getComponentCount()) { return getTab(components.get(index)); } else { return null; } }
private void updateTabVisibility() { for (int i=0; i<tabSheet.getComponentCount(); i++) { TabSheet.Tab tab = tabSheet.getTab(i); if (tab.getComponent() instanceof SelectionAwareTable) { ContentType contentType = ((SelectionAwareTable) tab.getComponent()).getContentType(); boolean visible = m_graphContainer.getTopologyServiceClient().contributesTo(contentType); tab.setVisible(visible); } } }
private void updateTabVisibility() { for (int i=0; i<tabSheet.getComponentCount(); i++) { TabSheet.Tab tab = tabSheet.getTab(i); if (tab.getComponent() instanceof SelectionAwareTable) { ContentType contentType = ((SelectionAwareTable) tab.getComponent()).getContentType(); boolean visible = m_graphContainer.getTopologyServiceClient().contributesTo(contentType); tab.setVisible(visible); } } }
/** * This method enables or disables all tabs in a tabSheet. Therefore the * <code>ViewStatechangedEvent</code> is used. If the new view state is Edit * the method returns the last selected tab position. If the new view state * is not Edit the " <code>oldSelectedTabPosition</code>" is selected in the * given <code>tabSheet</code>. * * @param tabSheet * the tabsheet to enable or disable all tabs in * @param event * @param oldSelectedTabPosition * which tab was selected before view state was Edit * @return */ public static int enableTabs(final TabSheet tabSheet, final ViewStateChangedEvent event, final int oldSelectedTabPosition) { boolean editMode = event.getNewState().isEdit(); boolean enabled = !editMode; int newSelectedTabPosition = 0; // remember which tab was selected (before editing) if (editMode) newSelectedTabPosition = getSelectedTabPosition(tabSheet); // disable or enable for (int i = 0; i < tabSheet.getComponentCount(); i++) tabSheet.getTab(i).setEnabled(enabled); // select tab depending on selection (after editing) if (!editMode) tabSheet.setSelectedTab(tabSheet.getTab(oldSelectedTabPosition)); // return currently selected tab return editMode ? newSelectedTabPosition : getSelectedTabPosition(tabSheet); }