List of usage examples for com.vaadin.ui TabSheet.Tab setVisible
@Override public void setVisible(boolean visible)
From source file:com.expressui.core.view.form.EntityForm.java
License:Open Source License
private void resetTabs(boolean selectFirstTab) { if (selectFirstTab) { selectFirstToManyTab();//from w ww. ja v a2 s . com } if (!hasTabs()) return; Set<String> viewableTabNames = getFormFieldSet().getViewableTabNames(); Set<String> tabNames = getFormFieldSet().getTabNames(); for (String tabName : tabNames) { TabSheet.Tab tab = getTabByName(tabName); Set<FormField> fields = getFormFieldSet().getFormFields(tabName); if (getFormFieldSet().isTabOptional(tabName)) { boolean isTabEmpty = true; for (FormField field : fields) { if (field.getField().getValue() != null) { isTabEmpty = false; break; } } setIsRequiredEnable(tabName, !isTabEmpty); tab.setClosable(!isViewMode()); tab.setVisible(!isTabEmpty && viewableTabNames.contains(tabName)); } else { tab.setVisible(viewableTabNames.contains(tabName)); } } resetContextMenu(); if (selectFirstTab || !getTabByName(getCurrentlySelectedTabName()).isVisible()) { selectFirstTab(); } syncTabAndSaveButtonErrors(); }
From source file:com.expressui.core.view.form.TypedForm.java
License:Open Source License
private void initializeOptionalTabs(VerticalLayout layout) { final Set<String> tabNames = getFormFieldSet().getTabNames(); menu = new LayoutContextMenu(layout); for (String tabName : tabNames) { TabSheet.Tab tab = getTabByName(tabName); if (getFormFieldSet().isTabOptional(tabName)) { tab.setClosable(true);// w w w . ja v a2s . c o m menu.addAction(uiMessageSource.getMessage("typedForm.add") + " " + tabName, this, "executeContextAction").setVisible(true); menu.addAction(uiMessageSource.getMessage("typedForm.remove") + " " + tabName, this, "executeContextAction").setVisible(false); setIsRequiredEnable(tabName, false); tab.setVisible(false); } tab.setDescription(uiMessageSource.getToolTip("typedForm.tab.toolTip")); } formTabSheet.setCloseHandler(new TabSheet.CloseHandler() { @Override public void onTabClose(TabSheet tabsheet, Component tabContent) { String tabName = tabsheet.getTab(tabContent).getCaption(); String actionName = uiMessageSource.getMessage("typedForm.remove") + " " + tabName; executeContextAction(actionName); } }); }
From source file:com.expressui.core.view.form.TypedForm.java
License:Open Source License
void executeContextAction(String name) { if (name.startsWith(uiMessageSource.getMessage("typedForm.add") + " ")) { String tabName = name.substring(uiMessageSource.getMessage("typedForm.add").length() + 1); FormFieldSet.AddRemoveTabMethodDelegate addRemoveTabMethodDelegate = getFormFieldSet() .getTabAddRemoveDelegate(tabName); addRemoveTabMethodDelegate.getAddTabMethodDelegate().execute(); TabSheet.Tab tab = getTabByName(tabName); setIsRequiredEnable(tabName, true); tab.setVisible(true); formTabSheet.setSelectedTab(tab.getComponent()); } else if (name.startsWith(uiMessageSource.getMessage("typedForm.remove") + " ")) { String tabName = name.substring(uiMessageSource.getMessage("typedForm.remove").length() + 1); FormFieldSet.AddRemoveTabMethodDelegate addRemoveTabMethodDelegate = getFormFieldSet() .getTabAddRemoveDelegate(tabName); addRemoveTabMethodDelegate.getRemoveTabMethodDelegate().execute(); TabSheet.Tab tab = getTabByName(tabName); setIsRequiredEnable(tabName, false); tab.setVisible(false);/*from w w w . j av a 2s. com*/ } BeanItem beanItem = createBeanItem(getBean()); getForm().setItemDataSource(beanItem, getFormFieldSet().getPropertyIds()); resetContextMenu(); }
From source file:com.haulmont.cuba.web.gui.components.WebTabSheet.java
License:Apache License
@Override public void applyPermission(UiPermissionDescriptor permissionDescriptor) { Preconditions.checkNotNullArgument(permissionDescriptor); final String subComponentId = permissionDescriptor.getSubComponentId(); final TabSheet.Tab tab = getTab(subComponentId); if (tab != null) { UiPermissionValue permissionValue = permissionDescriptor.getPermissionValue(); if (permissionValue == UiPermissionValue.HIDE) { tab.setVisible(false); } else if (permissionValue == UiPermissionValue.READ_ONLY) { tab.setEnabled(false);//from ww w .j a va 2 s .co m } } else { LoggerFactory.getLogger(WebTabSheet.class).info(String.format("Couldn't find component %s in window %s", subComponentId, permissionDescriptor.getScreenId())); } }
From source file:com.purebred.core.view.EntityForm.java
License:Open Source License
private void resetTabs(boolean selectFirstTab) { if (selectFirstTab) { selectFirstToManyTab();/*from w w w .j ava 2s . c om*/ } if (!hasTabs()) return; Set<String> viewableTabNames = getFormFields().getViewableTabNames(); Set<String> tabNames = getFormFields().getTabNames(); for (String tabName : tabNames) { TabSheet.Tab tab = getTabByName(tabName); Set<FormField> fields = getFormFields().getFormFields(tabName); if (getFormFields().isTabOptional(tabName)) { boolean isTabEmpty = true; for (FormField field : fields) { if (field.getField().getValue() != null) { isTabEmpty = false; break; } } setIsRequiredEnable(tabName, !isTabEmpty); tab.setClosable(!isViewMode()); tab.setVisible(!isTabEmpty && viewableTabNames.contains(tabName)); } else { tab.setVisible(viewableTabNames.contains(tabName)); } } resetContextMenu(); if (selectFirstTab || !getTabByName(getCurrentlySelectedTabName()).isVisible()) { selectFirstTab(); } syncTabAndSaveButtonErrors(); }
From source file:com.purebred.core.view.FormComponent.java
License:Open Source License
private void initializeOptionalTabs(VerticalLayout layout) { final Set<String> tabNames = getFormFields().getTabNames(); menu = new LayoutContextMenu(layout); for (String tabName : tabNames) { TabSheet.Tab tab = getTabByName(tabName); if (getFormFields().isTabOptional(tabName)) { tab.setClosable(true);/*from w w w . ja v a 2 s .c om*/ menu.addAction(uiMessageSource.getMessage("formComponent.add") + " " + tabName, this, "executeContextAction").setVisible(true); menu.addAction(uiMessageSource.getMessage("formComponent.remove") + " " + tabName, this, "executeContextAction").setVisible(false); setIsRequiredEnable(tabName, false); tab.setVisible(false); } tab.setDescription(uiMessageSource.getMessage("formComponent.tab.description")); } tabSheet.setCloseHandler(new TabSheet.CloseHandler() { @Override public void onTabClose(TabSheet tabsheet, Component tabContent) { String tabName = tabsheet.getTab(tabContent).getCaption(); String actionName = uiMessageSource.getMessage("formComponent.remove") + " " + tabName; executeContextAction(actionName); } }); }
From source file:com.purebred.core.view.FormComponent.java
License:Open Source License
void executeContextAction(String name) { if (name.startsWith(uiMessageSource.getMessage("formComponent.add") + " ")) { String tabName = name.substring(4); FormFields.AddRemoveMethodDelegate addRemoveMethodDelegate = getFormFields() .getTabAddRemoveDelegate(tabName); addRemoveMethodDelegate.getAddMethodDelegate().execute(); TabSheet.Tab tab = getTabByName(tabName); setIsRequiredEnable(tabName, true); tab.setVisible(true); tabSheet.setSelectedTab(tab.getComponent()); } else if (name.startsWith(uiMessageSource.getMessage("formComponent.remove") + " ")) { String tabName = name.substring(7); FormFields.AddRemoveMethodDelegate addRemoveMethodDelegate = getFormFields() .getTabAddRemoveDelegate(tabName); addRemoveMethodDelegate.getRemoveMethodDelegate().execute(); TabSheet.Tab tab = getTabByName(tabName); setIsRequiredEnable(tabName, false); tab.setVisible(false);/*from w ww . j a va2s . c om*/ } BeanItem beanItem = createBeanItem(getEntity()); getForm().setItemDataSource(beanItem, getFormFields().getPropertyIds()); resetContextMenu(); }
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
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.getBaseTopology().contributesTo(contentType); tab.setVisible(visible); }//from w ww. ja v a 2s . c o m } }