List of usage examples for com.vaadin.ui TabSheet getComponentCount
@Override public int getComponentCount()
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 w ww . ja va 2s . c o 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:de.catma.ui.tabbedview.TabbedView.java
License:Open Source License
public void onTabClose(TabSheet tabsheet, Component tabContent) { tabsheet.removeComponent(tabContent); ((ClosableTab) tabContent).close();/*from ww w . jav a 2 s . co m*/ if (tabsheet.getComponentCount() == 0) { //setVisible(false) doesn't work here because of out of sync errors tabSheet.hideTabs(true); tabSheet.setHeight("0px"); addComponent(noOpenTabsLabel, 0); noOpenTabsLabel.setVisible(true); setMargin(true); } }
From source file:de.catma.ui.visualizer.VisualizationManagerView.java
License:Open Source License
/** * Additional handling for charts because when closing a non active chart, * the active chart becomes empty. In addition to the standard behaviour this * method removes and reinserts all remaining {@link DistributionChartView}s. * //from ww w .j a v a2s .c o m * @see de.catma.ui.tabbedview.TabbedView#onTabClose(com.vaadin.ui.TabSheet, com.vaadin.ui.Component) */ @Override public void onTabClose(TabSheet tabsheet, Component tabContent) { Iterator<Component> compIter = tabsheet.getComponentIterator(); HashSet<Component> contents = new HashSet<Component>(); while (compIter.hasNext()) { contents.add(compIter.next()); } boolean hasLeft = (tabsheet.getComponentCount() > 1); super.onTabClose(tabsheet, tabContent); if (hasLeft) { tabsheet.removeAllComponents(); contents.remove(tabContent); for (Component c : contents) { addClosableTab((ClosableTab) c, c.toString()); } } }
From source file:org.opennms.features.jmxconfiggenerator.webui.ui.UIHelper.java
License:Open Source License
/** * 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>. * /*from www. j a v a 2 s . co m*/ * @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); }
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 2 s .com 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); }
From source file:v7cr.ReviewList.java
License:Open Source License
public void itemClick(ItemClickEvent event) { TabSheet tabs = (TabSheet) getParent(); Object iid = event.getItemId(); if (iid instanceof ObjectId) { // find existing tab int count = tabs.getComponentCount(); for (int i = 0; i < count; i++) { Component x = tabs.getTab(i).getComponent(); if (x instanceof ReviewTab && ((ReviewTab) x).reviewId.equals(iid)) { tabs.setSelectedTab(x);//w w w. j a v a 2 s .c om return; } } Tab t = tabs.addTab(new ReviewTab((ObjectId) iid)); t.setClosable(true); tabs.setSelectedTab(t.getComponent()); } }