if (newSelectedTab.isEnabled()) { setSelected(newSelectedComponent);
/** * Called when a selected tab is removed to specify the new tab to select. * Can be overridden to provide another algorithm that calculates the new * selection. * * Current implementation will choose the first enabled tab to the right of * the removed tab if it's not the last one, otherwise will choose the * closer enabled tab to the left. * * @since 7.4 * @param removedTabIndex * the index of the selected tab which was just remove. * @return the index of the tab to be selected or -1 if there are no more * enabled tabs to select. */ protected int selectedTabIndexAfterTabRemove(int removedTabIndex) { for (int i = removedTabIndex; i < components.size(); i++) { Tab tab = getTab(i); if (tab.isEnabled()) { return i; } } for (int i = removedTabIndex - 1; i >= 0; i--) { Tab tab = getTab(i); if (tab.isEnabled()) { return i; } } return -1; }
/** * Tests if component enabled and visible and its container enabled. * * @param child component * @return component enabled state */ public static boolean isComponentEnabled(Component child) { if (child.getParent() instanceof TabSheet) { TabSheet tabSheet = (TabSheet) child.getParent(); TabSheet.Tab tab = tabSheet.getTab(child); if (!tab.isEnabled()) { return false; } } return child.isEnabled() && (child.getParent() == null || isComponentEnabled(child.getParent())) && isComponentVisible(child); }
public void moveTab(Component c, int position) { Tab oldTab = getTab(c); String tabId = tabIds.inverse().get(oldTab); String tabCubaId = getCubaId(oldTab); // do not detach close handler // call super super.removeComponent(oldTab.getComponent()); Tab newTab = addTab(c, position); newTab.setCaption(oldTab.getCaption()); newTab.setDescription(oldTab.getDescription()); newTab.setClosable(oldTab.isClosable()); newTab.setEnabled(oldTab.isEnabled()); newTab.setVisible(oldTab.isVisible()); newTab.setIcon(oldTab.getIcon()); newTab.setStyleName(oldTab.getStyleName()); setCubaId(newTab, tabCubaId); if (tabId != null) { tabIds.remove(tabId); tabIds.put(tabId, newTab); } }
@Override public boolean isEnabled() { return tabbarTab.isEnabled(); }
private void disableCompositesTabIfNecessary(Mbean newModel) { boolean alreadyDisabled = !getTab(compositesLayout).isEnabled(); boolean shouldDisable = newModel == null || newModel.getCompAttrib().isEmpty(); boolean disabled = shouldDisable || alreadyDisabled; //so we do not overwrite enable/disable while already disabled due to another component //disable composites tab, if there are no composites getTab(compositesLayout).setEnabled(!disabled); getTab(compositesLayout).setDescription(disabled ? "no composites available" : null); }
@Override public boolean isEnabled() { return getVaadinTab().isEnabled(); }
@Override public boolean isEnabled() { return getVaadinTab().isEnabled(); }
DesignAttributeHandler.writeAttribute("caption", attr, tab.getCaption(), def.getCaption(), String.class, designContext); DesignAttributeHandler.writeAttribute("enabled", attr, tab.isEnabled(), def.isEnabled(), Boolean.class, designContext); DesignAttributeHandler.writeAttribute("icon", attr, tab.getIcon(), def.getIcon(), Resource.class, designContext);
/** * Copies properties from one Tab to another. * * @param from * The tab whose data to copy. * @param to * The tab to which copy the data. */ private static void copyTabMetadata(Tab from, Tab to) { to.setCaption(from.getCaption()); to.setIcon(from.getIcon(), from.getIconAlternateText()); to.setDescription(from.getDescription()); to.setVisible(from.isVisible()); to.setEnabled(from.isEnabled()); to.setClosable(from.isClosable()); to.setStyleName(from.getStyleName()); to.setComponentError(from.getComponentError()); }