List of usage examples for com.vaadin.ui TabSheet getTab
public Tab getTab(int index)
From source file:com.jain.addon.i18N.handlers.I18NTabSheetHandler.java
License:Apache License
private void initialize(final Component component) { if (component instanceof TabSheet) { TabSheet sheet = (TabSheet) component; for (Component c : sheet) { Tab tab = sheet.getTab(c); tabMap.put(tab, tab.getCaption()); }//from w w w. j a v a 2 s .com } else if (component.getParent() instanceof TabSheet) { TabSheet sheet = (TabSheet) component.getParent(); Tab tab = sheet.getTab(component); tabMap.put(tab, tab.getCaption()); } }
From source file:com.ocs.dynamo.ui.composite.layout.LazyTabLayout.java
License:Apache License
/** * Constructs the lazy tab sheet by setting up empty dummy tabs * @param tabs/*from ww w . j a va2s . co m*/ */ private void setupLazySheet(final TabSheet tabs) { // build up placeholder tabs that only contain an empty layout for (String caption : getTabCaptions()) { tabs.addTab(new DefaultVerticalLayout(false, false), caption); } // load the first tab ((Layout) tabs.getTab(0).getComponent()).addComponent(initTab(0)); replacedTabs.add(tabs.getTab(0).getCaption()); // respond to a tab change by actually loading the sheet tabs.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() { @Override public void selectedTabChange(SelectedTabChangeEvent event) { Component selectedTab = event.getTabSheet().getSelectedTab(); Tab tab = event.getTabSheet().getTab(selectedTab); // lazily load a tab if (!replacedTabs.contains(tab.getCaption())) { replacedTabs.add(tab.getCaption()); // look up the tab in the copies int index = 0; for (int i = 0; i < tabs.getComponentCount(); i++) { Tab t = tabs.getTab(i); if (t.getCaption().equals(tab.getCaption())) { index = i; break; } } // paste the real tab into the placeholder Component realTab = initTab(index); ((Layout) selectedTab).addComponent(realTab); } else { // reload the tab if needed Layout layout = (Layout) selectedTab; Component next = layout.iterator().next(); if (next instanceof Reloadable) { ((Reloadable) next).reload(); } } } }); }
From source file:com.oodrive.nuage.webui.VvrManagerUi.java
License:Apache License
/** * Initialize VVRs representation./*from w w w . j a va 2 s .c o m*/ * * @param jmxHandler */ private final void initVvrManagerUi(final JmxHandler jmxHandler) { // Create Model for vvrManager vvrManagerModel = jmxHandler.createVvrManagerModel(); // Vvr representation vvrsTabsheet = new TabSheet(); vvrManagerLayout.addComponent(vvrsTabsheet); // Sheet 0 create new VVR final VerticalLayout lastLayout = new VerticalLayout(); lastLayout.setWidth("100%"); lastLayout.setHeight(lastLayoutHeight); vvrsTabsheet.addTab(lastLayout, "+"); // Add a sheet for each vvr final Set<UUID> vvrUuidList = vvrManagerModel.getVvrs(); for (final UUID vvrUuid : vvrUuidList) { addVvr(vvrUuid); } // Window to create a new vvr (display on the last tabsheet) final VvrCreateWindow createWindow = new VvrCreateWindow(new PostProcessing() { @Override public void execute() { // After creation select the first tab vvrsTabsheet.setSelectedTab(0); } }); vvrsTabsheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() { @Override public void selectedTabChange(final SelectedTabChangeEvent event) { final TabSheet tabsheet = event.getTabSheet(); final String caption = tabsheet.getTab(tabsheet.getSelectedTab()).getCaption(); if (caption.equals("+")) { createWindow.add(vvrManagerModel); } else { // Remove window if another tab is selected createWindow.remove(); } } }); // If no other tab, display creation window (+ tab can not be selected) if (vvrUuidList.isEmpty()) { createWindow.add(vvrManagerModel); } }
From source file:com.peergreen.webconsole.vaadin.tabs.CloseTabListener.java
License:Open Source License
@Override public void onTabClose(TabSheet tabsheet, Component tabContent) { notifierService/*from w w w. ja va 2 s .c o m*/ .addNotification("Warning ! You have closed " + tabsheet.getTab(tabContent).getCaption() + " tab"); tabsheet.removeComponent(tabContent); }
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 ww w . j a va2s . com*/ 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.trivago.mail.pigeon.web.components.mail.ActionButtonColumnGenerator.java
License:Apache License
@Override public Object generateCell(final Table source, final Object itemId, final Object columnId) { HorizontalLayout hl = new HorizontalLayout(); Button showNlConentButton = new Button(); showNlConentButton.setDescription("View"); showNlConentButton.setImmediate(true); showNlConentButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png")); showNlConentButton.addListener(new Button.ClickListener() { @Override//from www. ja va2 s . c o m public void buttonClick(Button.ClickEvent event) { Mail m = new Mail((Long) itemId); Window nlConentView = new Window("Newsletter Contents of ID " + itemId); // Create an empty tab sheet. TabSheet tabsheet = new TabSheet(); Panel pText = new Panel("Text Content"); Panel pHtml = new Panel("Text Content"); RichTextArea textArea = new RichTextArea(); textArea.setValue(m.getText()); textArea.setReadOnly(true); RichTextArea richTextArea = new RichTextArea(); richTextArea.setValue(m.getHtml()); richTextArea.setReadOnly(true); pText.addComponent(textArea); pHtml.addComponent(richTextArea); richTextArea.setHeight("50%"); richTextArea.setWidth("100%"); textArea.setHeight("50%"); textArea.setWidth("100%"); nlConentView.setResizable(true); nlConentView.setWidth("800px"); nlConentView.setHeight("600px"); tabsheet.addTab(pText); tabsheet.getTab(pText).setCaption("Text Version"); tabsheet.addTab(pHtml); tabsheet.getTab(pHtml).setCaption("Html Version"); nlConentView.addComponent(tabsheet); source.getWindow().addWindow(nlConentView); nlConentView.setVisible(true); } }); final Button showOpenendMails = new Button(); showOpenendMails.setDescription("Show recipients of this mailling"); showOpenendMails.setIcon(new ThemeResource("../runo/icons/16/users.png")); showOpenendMails.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Mail m = new Mail((Long) itemId); ModalRecipientListByMail modalRecipientListByMail = new ModalRecipientListByMail(m); source.getWindow().addWindow(modalRecipientListByMail); modalRecipientListByMail.setVisible(true); } }); hl.addComponent(showNlConentButton); hl.addComponent(showOpenendMails); return hl; }
From source file:edu.vcu.csbc.vahmpexplorer.main.VaHMPExplorer.java
@Override public void selectedTabChange(SelectedTabChangeEvent event) { TabSheet tabSheet = event.getTabSheet(); Tab tab = tabSheet.getTab(tabSheet.getSelectedTab()); if (tab != null) { // getMainWindow().showNotification("Selected " + tab.getCaption() + " tab"); }// w w w.java 2s. co m }
From source file:io.subutai.plugin.accumulo.ui.AccumuloComponent.java
public AccumuloComponent(ExecutorService executorService, Accumulo accumulo, Hadoop hadoop, Zookeeper zookeeper, Tracker tracker, EnvironmentManager environmentManager) throws NamingException { setSizeFull();// w w w . j av a 2 s .c om VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSpacing(true); verticalLayout.setSizeFull(); TabSheet sheet = new TabSheet(); sheet.setSizeFull(); final Manager manager = new Manager(executorService, accumulo, hadoop, zookeeper, tracker, environmentManager); Wizard wizard = new Wizard(executorService, accumulo, hadoop, zookeeper, tracker, environmentManager); sheet.addTab(wizard.getContent(), "Install"); sheet.getTab(0).setId("AccumuloInstallTab"); sheet.addTab(manager.getContent(), "Manage"); sheet.getTab(1).setId("AccumuloManageTab"); sheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() { @Override public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) { TabSheet tabsheet = event.getTabSheet(); String caption = tabsheet.getTab(event.getTabSheet().getSelectedTab()).getCaption(); if (caption.equals("Manage")) { manager.refreshClustersInfo(); } } }); verticalLayout.addComponent(sheet); setCompositionRoot(verticalLayout); manager.refreshClustersInfo(); }
From source file:nz.co.senanque.vaadinsupport.I18n.I18nCaptionHelper.java
License:Apache License
private static void switchCaption(TabSheet tabSheet, MessageSourceAccessor messageSourceAccessor) { int j = 0;// w w w. j a va 2 s .co m 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); } } }
From source file:org.apache.openaz.xacml.admin.components.PolicyWorkspace.java
License:Apache License
protected void initializeTree() { ///* w ww.j av a2s .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)); } }); }