List of usage examples for com.vaadin.ui TabSheet removeTab
public void removeTab(Tab tab)
From source file:com.foc.vaadin.gui.windows.AddTabWindow.java
License:Apache License
public AddTabWindow(final TabSheet tabSheet, final VerticalLayout addTabLayout) { super("Add New Tab"); setModal(true);//from www . j a va 2s. c om setWidth("264px"); setHeight("272px"); layout = new VerticalLayout(); buttonsLayout = new HorizontalLayout(); optionsLayout = new VerticalLayout(); seperateLayout = new VerticalLayout(); tabName = new TextField(); tabNameWrapper = new FVWrapperLayout(tabName, "Tab Name:", width); layoutHeight = new TextField(); heightWrapper = new FVWrapperLayout(layoutHeight, "Height:", width); layoutWidth = new TextField(); widthWrapper = new FVWrapperLayout(layoutWidth, "Width:", width); innerLayout = new ComboBox(); innerLayoutWrapper = new FVWrapperLayout(innerLayout, "Layout Type:", width); for (int i = 0; i < layoutTypes.length; i++) { innerLayout.addItem(layoutTypes[i]); } innerLayout.setImmediate(true); innerLayout.setNullSelectionAllowed(false); innerLayout.setValue(layoutTypes[0]); innerLayout.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String layoutType = event.getProperty().toString(); if (layoutType.equals(FXML.TAG_GRID_LAYOUT)) { layoutCols = new TextField(); colsWrapper = new FVWrapperLayout(layoutCols, "Columns:", width); layoutRows = new TextField(); rowsWrapper = new FVWrapperLayout(layoutRows, "Rows:", width); optionsLayout.addComponent(colsWrapper); optionsLayout.addComponent(rowsWrapper); setHeight("350px"); } else { if (layoutCols != null) { optionsLayout.removeComponent(colsWrapper); layoutCols = null; colsWrapper = null; } if (layoutRows != null) { optionsLayout.removeComponent(rowsWrapper); layoutRows = null; rowsWrapper = null; } setHeight("272px"); } } }); create = new Button("Create"); cancel = new Button("Cancel"); cancel.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); } }); create.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { String layoutType = innerLayout.getValue().toString(); AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute("", "name", "name", "CDATA", "null"); attributes.addAttribute("", "height", "height", "CDATA", layoutHeight.getValue().toString().isEmpty() ? "-1px" : layoutHeight.getValue().toString() + "px"); attributes.addAttribute("", "width", "width", "CDATA", layoutWidth.getValue().toString().isEmpty() ? "-1px" : layoutWidth.getValue().toString() + "px"); if (layoutType.equals(FXML.TAG_ABSOLUTE_LAYOUT)) { selectedLayout = new FVAbsoluteLayout(attributes); } else if (layoutType.equals(FXML.TAG_VERTICAL_LAYOUT)) { selectedLayout = new FVVerticalLayout(attributes); } else if (layoutType.equals(FXML.TAG_HORIZONTAL_LAYOUT)) { selectedLayout = new FVHorizontalLayout(attributes); } else { attributes.addAttribute("", "rows", "rows", "CDATA", layoutRows.getValue().toString()); attributes.addAttribute("", "cols", "cols", "CDATA", layoutCols.getValue().toString()); selectedLayout = new FVGridLayout(attributes); } tabSheet.removeTab(tabSheet.getTab(addTabLayout)); tabSheet.addTab((Component) selectedLayout, tabName.getValue().toString()); tabSheet.addTab(addTabLayout, "+"); close(); } }); optionsLayout.setSpacing(true); optionsLayout.addComponent(widthWrapper); optionsLayout.addComponent(heightWrapper); seperateLayout.setHeight("25px"); buttonsLayout.setSpacing(true); buttonsLayout.addComponent(create); buttonsLayout.addComponent(cancel); layout.setSpacing(true); layout.addComponent(tabNameWrapper); layout.addComponent(innerLayoutWrapper); layout.addComponent(optionsLayout); layout.addComponent(seperateLayout); layout.addComponent(buttonsLayout); layout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_CENTER); setContent(layout); }
From source file:com.hybridbpm.ui.component.bpm.CaseLayout.java
License:Apache License
private void close() { if (getParent() instanceof TabSheet) { TabSheet parent = (TabSheet) getParent(); parent.removeTab(parent.getTab(this)); parent.setSelectedTab(2);/*w w w. ja va 2 s .c o m*/ } }
From source file:com.hybridbpm.ui.component.bpm.TaskLayout.java
License:Apache License
private void close() { if (getParent() instanceof TabSheet) { TabSheet parent = (TabSheet) getParent(); parent.removeTab(parent.getTab(this)); parent.setSelectedTab(0);//from ww w . ja v a 2s . co m } else if (getParent() != null && getParent() instanceof VerticalLayout && getParent().getParent() instanceof AdaptiveTaskPanel) { AdaptiveTaskPanel adaptiveTaskPanel = (AdaptiveTaskPanel) getParent().getParent(); adaptiveTaskPanel.close(); } else if (getParent() != null && getParent() instanceof VerticalLayout && getParent().getParent() instanceof AdaptiveTaskEditor) { AdaptiveTaskEditor adaptiveTaskEditor = (AdaptiveTaskEditor) getParent().getParent(); adaptiveTaskEditor.close(); } }
From source file:org.apache.openaz.xacml.admin.components.PolicyWorkspace.java
License:Apache License
protected void initializeTree() { //// ww w . j ava 2s. c o m // This is where the user's Git repository is located // final Path gitPath = ((XacmlAdminUI) UI.getCurrent()).getUserGitPath(); // // Create our Git file system container // this.treeContainer = new GitRepositoryContainer(gitPath, gitPath.toFile()); // // Create our own filter to filter out File extensions and // also the Git directory. // this.treeContainer.setFilter(new FilenameFilter() { @Override public boolean accept(File dir, String name) { // // We don't want any of the hidden files // if (name.startsWith(".git") || name.equals(".DS_Store")) { return false; } // // We definitely want xml files // if (name.endsWith(".xml")) { return true; } // // We should test if its a directory, we want those // included. // Path path = Paths.get(dir.getAbsolutePath(), name); if (Files.isDirectory(path)) { return true; } logger.warn("Filtering out: " + path.toString()); return false; } }); // // Set TreeTables datasource as our git container // this.treeWorkspace.setContainerDataSource(this.treeContainer); // // Setup other properties etc. // this.treeWorkspace.setItemIconPropertyId("Icon"); this.treeWorkspace.setVisibleColumns(new Object[] { "Name", "Version", "Size", "Last Modified", "Status" }); this.treeWorkspace.setSizeFull(); this.treeWorkspace.setSelectable(true); this.treeWorkspace.setEditable(false); // // Expand the first couple of directories // for (Object id : this.treeWorkspace.getItemIds()) { this.treeWorkspace.setCollapsed(id, false); for (Object child : this.treeWorkspace.getChildren(id)) { this.treeWorkspace.setCollapsed(child, false); } } // // Respond to table selections // /* this.treeWorkspace.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { File selection = (File) self.treeWorkspace.getValue(); if (selection != null) { self.buttonImport.setEnabled(selection.isDirectory()); self.buttonExport.setEnabled(selection.isFile()); } else { } } }); */ this.treeWorkspace.addItemClickListener(new ItemClickListener() { private static final long serialVersionUID = 1L; @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick() && event.getItemId() instanceof File && ((File) event.getItemId()).isFile()) { self.openPolicyTab((File) event.getItemId(), true); } } }); // // Setup our action handlers // this.treeWorkspace.addActionHandler(new Handler() { private static final long serialVersionUID = 1L; @Override public Action[] getActions(Object target, Object sender) { if (target == null) { // // Nothing is selected, they right-clicked empty space // return new Action[] { SYNCHRONIZE_REPOSITORY, EXPORT_REPOSITORY, CREATE_SUBDOMAIN }; } if (!(target instanceof File)) { return null; } if (((File) target).isDirectory()) { // // Selected a directory // return new Action[] { CREATE_SUBDOMAIN, RENAME_SUBDOMAIN, DELETE_SUBDOMAIN, CREATE_NEWPOLICY, IMPORT_POLICY, PUSH_CHANGES }; } if (((File) target).isFile()) { // // Selected a policy file // return new Action[] { VIEW_POLICY, EDIT_POLICY, CLONE_POLICY, EXPORT_POLICY, RENAME_POLICY, DELETE_POLICY, PUSH_CHANGES }; } return null; } @Override public void handleAction(Action action, Object sender, Object target) { if (action == SYNCHRONIZE_REPOSITORY) { self.synchronizeRepository(); return; } if (action == EXPORT_REPOSITORY) { self.exportRepository(); return; } if (action == PUSH_CHANGES) { self.pushChanges((File) target); return; } if (action == CREATE_SUBDOMAIN) { self.editSubDomain((File) target, null); return; } if (action == RENAME_SUBDOMAIN) { self.editSubDomain((File) self.treeWorkspace.getParent(target), ((File) target).getName()); return; } if (action == CREATE_NEWPOLICY) { self.createPolicy((File) target); return; } if (action == RENAME_POLICY) { self.renamePolicy((File) target); return; } if (action == IMPORT_POLICY) { self.importPolicy((File) target); return; } if (action == DELETE_SUBDOMAIN) { self.deleteSubDomain((File) target); return; } if (action == CLONE_POLICY) { self.clonePolicy((File) target); return; } if (action == VIEW_POLICY) { self.openPolicyTab((File) target, true); return; } if (action == EDIT_POLICY) { self.openPolicyTab((File) target, false); return; } if (action == EXPORT_POLICY) { return; } if (action == DELETE_POLICY) { self.deletePolicy((File) target); return; } } }); // // Set the drop handler // this.treeWorkspace.setDragMode(TableDragMode.ROW); this.treeWorkspace.setDropHandler(this); // // Detect when a tab closes and remove it from the // tab sheet. // this.tabSheet.setCloseHandler(new CloseHandler() { private static final long serialVersionUID = 1L; @Override public void onTabClose(TabSheet tabsheet, Component tabContent) { logger.info("tabsheet closing: " + tabsheet.getCaption()); tabsheet.removeTab(tabsheet.getTab(tabContent)); } }); }
From source file:org.esn.esobase.view.tab.ChangePasswordTab.java
private void changePasswordAction() { sysAccountService.updateUserPassword(SpringSecurityHelper.getSysAccount(), password.getValue()); Notification n = new Notification(" ?", " ? ", Notification.Type.HUMANIZED_MESSAGE); n.setDelayMsec(2000);//w w w . j av a 2 s . c o m n.show(getUI().getPage()); TabSheet tabs = (TabSheet) this.getParent(); tabs.removeTab(tabs.getTab(this)); }
From source file:org.sensorhub.ui.GenericConfigForm.java
License:Mozilla Public License
protected Component buildTabs(final String propId, final ContainerProperty prop, final FieldGroup fieldGroup) { GridLayout layout = new GridLayout(); layout.setWidth(100.0f, Unit.PERCENTAGE); // title bar/* ww w .j av a 2 s .c om*/ HorizontalLayout titleBar = new HorizontalLayout(); titleBar.setMargin(new MarginInfo(true, false, false, false)); titleBar.setSpacing(true); String label = prop.getLabel(); if (label == null) label = DisplayUtils.getPrettyName((String) propId); Label sectionLabel = new Label(label); sectionLabel.setDescription(prop.getDescription()); sectionLabel.addStyleName(STYLE_H3); sectionLabel.addStyleName(STYLE_COLORED); titleBar.addComponent(sectionLabel); layout.addComponent(titleBar); // create one tab per item in container final MyBeanItemContainer<Object> container = prop.getValue(); final TabSheet tabs = new TabSheet(); tabs.setSizeFull(); int i = 1; for (Object itemId : container.getItemIds()) { MyBeanItem<Object> childBeanItem = (MyBeanItem<Object>) container.getItem(itemId); IModuleConfigForm subform = AdminUI.getInstance().generateForm(childBeanItem.getBean().getClass()); subform.build(null, childBeanItem); ((MarginHandler) subform).setMargin(new MarginInfo(true, false, true, false)); allForms.add(subform); Tab tab = tabs.addTab(subform, "Item #" + (i++)); tab.setClosable(true); // store item id so we can map a tab with the corresponding bean item ((AbstractComponent) subform).setData(itemId); } // draw icon on last tab to add new items tabs.addTab(new VerticalLayout(), "", UIConstants.ADD_ICON); // catch close event to delete item tabs.setCloseHandler(new CloseHandler() { private static final long serialVersionUID = 1L; @Override public void onTabClose(TabSheet tabsheet, Component tabContent) { final Tab tab = tabs.getTab(tabContent); final ConfirmDialog popup = new ConfirmDialog( "Are you sure you want to delete " + tab.getCaption() + "?</br>All settings will be lost."); popup.addCloseListener(new CloseListener() { private static final long serialVersionUID = 1L; @Override public void windowClose(CloseEvent e) { if (popup.isConfirmed()) { // retrieve id of item shown on tab AbstractComponent tabContent = (AbstractComponent) tab.getComponent(); Object itemId = tabContent.getData(); // remove from UI int deletedTabPos = tabs.getTabPosition(tab); tabs.removeTab(tab); tabs.setSelectedTab(deletedTabPos - 1); // remove from container container.removeItem(itemId); } } }); popup.setModal(true); AdminUI.getInstance().addWindow(popup); } }); // catch select event on '+' tab to add new item tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() { private static final long serialVersionUID = 1L; public void selectedTabChange(SelectedTabChangeEvent event) { Component selectedTab = event.getTabSheet().getSelectedTab(); final Tab tab = tabs.getTab(selectedTab); final int selectedTabPos = tabs.getTabPosition(tab); // case of + tab to add new item if (tab.getCaption().equals("")) { tabs.setSelectedTab(selectedTabPos - 1); try { // show popup to select among available module types String title = "Please select the desired option"; Map<String, Class<?>> typeList = GenericConfigForm.this.getPossibleTypes(propId); ObjectTypeSelectionPopup popup = new ObjectTypeSelectionPopup(title, typeList, new ObjectTypeSelectionCallback() { public void typeSelected(Class<?> objectType) { try { // add new item to container MyBeanItem<Object> childBeanItem = container.addBean( objectType.newInstance(), ((String) propId) + PROP_SEP); // generate form for new item IModuleConfigForm subform = AdminUI.getInstance() .generateForm(childBeanItem.getBean().getClass()); subform.build(null, childBeanItem); ((MarginHandler) subform) .setMargin(new MarginInfo(true, false, true, false)); allForms.add(subform); // add new tab and select it Tab newTab = tabs.addTab(subform, "Item #" + (selectedTabPos + 1), null, selectedTabPos); newTab.setClosable(true); tabs.setSelectedTab(newTab); } catch (Exception e) { Notification.show("Error", e.getMessage(), Notification.Type.ERROR_MESSAGE); } } }); popup.setModal(true); AdminUI.getInstance().addWindow(popup); } catch (Exception e) { e.printStackTrace(); } } } }); // also register commit handler fieldGroup.addCommitHandler(new CommitHandler() { private static final long serialVersionUID = 1L; @Override public void preCommit(CommitEvent commitEvent) throws CommitException { } @Override public void postCommit(CommitEvent commitEvent) throws CommitException { // make sure new items are transfered to model prop.setValue(prop.getValue()); } }); layout.addComponent(tabs); return layout; }
From source file:ru.codeinside.gses.webui.executor.ExecutorFactory.java
License:Mozilla Public License
static private void showForm(final TabSheet tabs, final String taskId) { // ? // ww w . j a va 2s . co m for (int i = tabs.getComponentCount(); i > 0; i--) { final Tab tab = tabs.getTab(i - 1); if (tab.getComponent() instanceof WithTaskId) { if (taskId.equals(((WithTaskId) tab.getComponent()).getTaskId())) { tabs.setSelectedTab(tab); return; } } } DataAccumulator accumulator = new DataAccumulator(); ExecutorService executorService = Flash.flash().getExecutorService(); final FormDescription formDescription = Functions .withEngine(new FormDescriptionBuilder(FormID.byTaskId(taskId), executorService, accumulator)); final TaskForm taskForm = new TaskForm(formDescription, new TaskForm.CloseListener() { private static final long serialVersionUID = 3726145663843346543L; @Override public void onFormClose(final TaskForm form) { final TabSheet.Tab tab = tabs.getTab(tabs.getSelectedTab()); int pos = tabs.getTabPosition(tab); tabs.removeTab(tab); int count = tabs.getComponentCount(); tabs.setSelectedTab(count == pos ? pos - 1 : pos); } }, accumulator); final Tab tab = tabs.addTab(taskForm, formDescription.task.getName()); tab.setDescription("? \"" + formDescription.processDefinition.getName() + "\""); tabs.setSelectedTab(tab); }