for (Component component : tabSheet) { TabSheet.Tab tab = tabSheet.getTab(component); if ("some tab caption".equals(tab.getCaption())) { // Found it!!! } }
} else if (tabs.containsKey(tabComponent)) { Tab tab = tabs.get(tabComponent); tab.setCaption(caption); tab.setIcon(icon); return tab; } else {
public void containerItemSetChange(Container.ItemSetChangeEvent itemSetChangeEvent) { List<Wallboard> wallboardsToRemove = new ArrayList<>(); List<TabSheet.Tab> tabsToRemove = new ArrayList<>(); for (Map.Entry<Wallboard, TabSheet.Tab> entry : m_wallboardEditorMap.entrySet()) { WallboardEditor wallboardEditor = (WallboardEditor) entry.getValue().getComponent(); if (!WallboardProvider.getInstance().containsWallboard(wallboardEditor.getWallboard())) { wallboardsToRemove.add(wallboardEditor.getWallboard()); tabsToRemove.add(entry.getValue()); } } for (TabSheet.Tab tab : tabsToRemove) { m_tabSheet.removeTab(tab); } for (Wallboard wallboard : wallboardsToRemove) { m_wallboardEditorMap.remove(wallboard); } } });
overviewTab.setClosable(false);
/** * 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); }
/** * 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); }
/** * The default constructor. */ public WallboardTabSheet() { m_plusTab = new CssLayout(); m_plusTab.setCaption("+"); m_plusTab.setDescription("Add a new Ops Board configuration"); addTab(m_plusTab).setClosable(false); addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() { public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) { Component selectedTab = getSelectedTab(); if ("+".equals(selectedTab.getCaption())) { setSelectedTab((m_lastTab != null ? m_lastTab : iterator().next())); addNewTabComponent(); } else { m_lastTab = selectedTab; } } }); }
@Override public boolean addPanel(ContentPanel panel) { NavigationNode node = panel.getNavigationNode(); if (node != null) { ContentPanel cp = findTabForNode(node); if (cp != null) { setSelectedTab((Tab)cp.getData()); return false; } } Tab tab = addTab(panel.getUI(), panel.getTitle()); tab.setClosable(panel.isCloseable()); panel.setData(tab); setSelectedTab(tab); list.add(panel); return true; }
private static void switchCaption(TabSheet tabSheet, MessageSourceAccessor messageSourceAccessor) { int j=0; for (final Iterator<Component> i = tabSheet.getComponentIterator(); i.hasNext();) { final Component component = i.next(); Tab tab = tabSheet.getTab(j++); String newCaption = getTranslatedCaption(tab.getCaption(),messageSourceAccessor); if (newCaption != null) { tab.setCaption(newCaption); } } } private static void switchCaption(Label label, MessageSourceAccessor messageSourceAccessor)
/** * This method opens a {@link WallboardEditor} for a given {@link Wallboard}. * * @param wallboard the wallboard to be edited */ public void openWallboardEditor(Wallboard wallboard) { if (m_wallboardEditorMap.containsKey(wallboard)) { m_tabSheet.setSelectedTab(m_wallboardEditorMap.get(wallboard)); } else { WallboardEditor wallboardEditor = new WallboardEditor(m_dashletSelector, wallboard); TabSheet.Tab tab = m_tabSheet.addTab(wallboardEditor, wallboard.getTitle(), null); wallboardEditor.setTab(tab); tab.setClosable(true); m_wallboardEditorMap.put(wallboard, tab); m_tabSheet.setSelectedTab(tab); } }
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(); }
@Override protected Component getActionTarget(Tab tab) { return getContentTab(tab.getComponent()).getComponent(); }
@Override public void setTabClosable(String tabId, boolean closable) { getTabNN(tabId).setClosable(closable); }
@Override public void setTabDescription(String tabId, String description) { getTabNN(tabId).setDescription(description); }
@Override public void setEnabled(boolean enabled) { getVaadinTab().setEnabled(enabled); }
@Override public void setVisible(boolean visible) { getVaadinTab().setVisible(visible); }
@Override public void setVisible(boolean visible) { getVaadinTab().setVisible(visible); }
@Override public void setStyleName(String styleName) { getVaadinTab().setStyleName(styleName); }
protected Component getActionTarget(Tab tab) { return tab.getComponent(); }