List of usage examples for com.vaadin.ui TabSheet getSelectedTab
public Component getSelectedTab()
From source file:org.lunifera.runtime.web.vaadin.databinding.component.internal.TabSheetSelectedTabProperty.java
License:Open Source License
@Override protected Object doGetValue(Object source) { TabSheet component = (TabSheet) source; return component.getSelectedTab(); }
From source file:org.opennms.features.jmxconfiggenerator.webui.ui.UIHelper.java
License:Open Source License
private static int getSelectedTabPosition(final TabSheet tabSheet) { if (tabSheet == null) return 0; if (tabSheet.getSelectedTab() == null) return 0; if (tabSheet.getTab(tabSheet.getSelectedTab()) == null) return 0; return tabSheet.getTabPosition(tabSheet.getTab(tabSheet.getSelectedTab())); }
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
/** * Gets a {@link TabSheet} view for all widgets in this manager. * //www.j a va 2s . c o m * @return TabSheet */ private Component getTabSheet(WidgetManager manager, WidgetContext widgetContext) { // Use an absolute layout for the bottom panel AbsoluteLayout bottomLayout = new AbsoluteLayout(); bottomLayout.setSizeFull(); tabSheet = new TabSheet(); tabSheet.setSizeFull(); for (IViewContribution viewContrib : manager.getWidgets()) { // Create a new view instance final Component view = viewContrib.getView(m_applicationContext, widgetContext); try { m_graphContainer.getSelectionManager().addSelectionListener((SelectionListener) view); } catch (ClassCastException e) { } try { ((SelectionNotifier) view).addSelectionListener(m_graphContainer.getSelectionManager()); } catch (ClassCastException e) { } // Icon can be null tabSheet.addTab(view, viewContrib.getTitle(), viewContrib.getIcon()); // If the component supports the HasExtraComponents interface, then add the extra // components to the tab bar try { Component[] extras = ((HasExtraComponents) view).getExtraComponents(); if (extras != null && extras.length > 0) { // For any extra controls, add a horizontal layout that will float // on top of the right side of the tab panel final HorizontalLayout extraControls = new HorizontalLayout(); extraControls.setHeight(32, Unit.PIXELS); extraControls.setSpacing(true); // Add the extra controls to the layout for (Component component : extras) { extraControls.addComponent(component); extraControls.setComponentAlignment(component, Alignment.MIDDLE_RIGHT); } // Add a TabSheet.SelectedTabChangeListener to show or hide the extra controls tabSheet.addSelectedTabChangeListener(new SelectedTabChangeListener() { private static final long serialVersionUID = 6370347645872323830L; @Override public void selectedTabChange(SelectedTabChangeEvent event) { final TabSheet source = (TabSheet) event.getSource(); if (source == tabSheet) { // Bizarrely enough, getSelectedTab() returns the contained // Component, not the Tab itself. // // If the first tab was selected... if (source.getSelectedTab() == view) { extraControls.setVisible(true); } else { extraControls.setVisible(false); } } } }); // Place the extra controls on the absolute layout bottomLayout.addComponent(extraControls, "top:0px;right:5px;z-index:100"); } } catch (ClassCastException e) { } view.setSizeFull(); } // Add the tabsheet to the layout bottomLayout.addComponent(tabSheet, "top: 0; left: 0; bottom: 0; right: 0;"); return bottomLayout; }
From source file:org.opennms.features.vaadin.datacollection.DataCollectionGroupPanel.java
License:Open Source License
@Override public void selectedTabChange(SelectedTabChangeEvent event) { TabSheet tabsheet = event.getTabSheet(); Tab tab = tabsheet.getTab(tabsheet.getSelectedTab()); if (tab != null) { Notification.show("Selected tab: " + tab.getCaption()); }/*from ww w . jav a 2 s .c o m*/ }
From source file:org.opennms.features.vaadin.nodemaps.internal.NodeMapsApplication.java
License:Open Source License
/** * Gets a {@link TabSheet} view for all widgets in this manager. * /*from w w w.j av a2 s . c o m*/ * @return TabSheet */ private Component getTabSheet() { // Use an absolute layout for the bottom panel AbsoluteLayout bottomLayout = new AbsoluteLayout(); bottomLayout.setSizeFull(); final TabSheet tabSheet = new TabSheet(); tabSheet.setSizeFull(); for (final SelectionAwareTable view : new SelectionAwareTable[] { m_alarmTable, m_nodeTable }) { // Icon can be null tabSheet.addTab(view, (view == m_alarmTable ? "Alarms" : "Nodes"), null); // If the component supports the HasExtraComponents interface, then add the extra // components to the tab bar try { final Component[] extras = ((HasExtraComponents) view).getExtraComponents(); if (extras != null && extras.length > 0) { // For any extra controls, add a horizontal layout that will float // on top of the right side of the tab panel final HorizontalLayout extraControls = new HorizontalLayout(); extraControls.setHeight(32, Unit.PIXELS); extraControls.setSpacing(true); // Add the extra controls to the layout for (final Component component : extras) { extraControls.addComponent(component); extraControls.setComponentAlignment(component, Alignment.MIDDLE_RIGHT); } // Add a TabSheet.SelectedTabChangeListener to show or hide the extra controls tabSheet.addSelectedTabChangeListener(new SelectedTabChangeListener() { @Override public void selectedTabChange(final SelectedTabChangeEvent event) { final TabSheet source = (TabSheet) event.getSource(); if (source == tabSheet) { // Bizarrely enough, getSelectedTab() returns the contained // Component, not the Tab itself. // // If the first tab was selected... if (source.getSelectedTab() == view) { extraControls.setVisible(true); } else { extraControls.setVisible(false); } } } }); // Place the extra controls on the absolute layout bottomLayout.addComponent(extraControls, "top:0px;right:5px;z-index:100"); } } catch (ClassCastException e) { } view.setSizeFull(); } // Add the tabsheet to the layout bottomLayout.addComponent(tabSheet, "top: 0; left: 0; bottom: 0; right: 0;"); return bottomLayout; }
From source file:org.vaadin.addon.twitter.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { Responsive.makeResponsive(this); CssLayout info = new CssLayout(); info.setStyleName("tw-docs"); info.addComponent(markdown.get(0));/* w w w . ja v a 2s . co m*/ TabSheet tabSheet = new TabSheet(); tabSheet.setStyleName("tw-demo-tab"); tabSheet.addStyleName(ValoTheme.TABSHEET_CENTERED_TABS); tabSheet.setSizeFull(); tabSheet.addTab(new TimelineDemo()).setCaption("Timeline"); tabSheet.addTab(new TweetDemo()).setCaption("Single Tweet"); tabSheet.addTab(new ButtonDemo(TweetButton.Type.Follow)).setCaption("Follow Button"); tabSheet.addTab(new ButtonDemo(TweetButton.Type.Share)).setCaption("Share Button"); tabSheet.addTab(new ButtonDemo(TweetButton.Type.Hashtag)).setCaption("Hashtag Button"); tabSheet.addTab(new ButtonDemo(TweetButton.Type.Mention)).setCaption("Mention Button"); tabSheet.addSelectedTabChangeListener(event -> { Component old = info.getComponent(0); Component newComp = markdown.get(tabSheet.getTabPosition(tabSheet.getTab(tabSheet.getSelectedTab()))); info.replaceComponent(old, newComp); }); final MHorizontalLayout layout = new MHorizontalLayout(info, tabSheet).withExpand(info, 4) .withExpand(tabSheet, 6).withFullWidth().withFullHeight().withMargin(false).withSpacing(true); setContent(new MPanel(layout).withFullWidth().withFullHeight().withStyleName(ValoTheme.PANEL_WELL, "root-container")); }
From source file:ro.zg.netcell.vaadin.action.UserActionListHandler.java
License:Apache License
@Override public void handle(final ActionContext actionContext) throws Exception { ComponentContainer displayArea = actionContext.getTargetContainer(); displayArea.removeAllComponents();/*ww w. java2 s . c o m*/ UserActionList ual = (UserActionList) actionContext.getUserAction(); final OpenGroupsApplication app = actionContext.getApp(); final Entity entity = actionContext.getEntity(); final TabSheet actionsTabSheet = new TabSheet(); actionsTabSheet.addStyleName(Reindeer.TABSHEET_MINIMAL); // actionsTabSheet.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); actionsTabSheet.addStyleName(OpenGroupsStyles.USER_ACTIONS_TABSHEET); // final CssLayout contentArea = new CssLayout(); // contentArea.setWidth("100%"); // contentArea.setStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); // displayArea.addComponent(contentArea); /* add listener */ actionsTabSheet.addListener(new SelectedTabChangeListener() { @Override public void selectedTabChange(SelectedTabChangeEvent event) { TabSheet tabSheet = event.getTabSheet(); AbstractComponentContainer selectedTabContent = (AbstractComponentContainer) tabSheet .getSelectedTab(); UserAction ua = (UserAction) selectedTabContent.getData(); if (entity != null) { Deque<String> desiredActionsQueue = entity.getState().getDesiredActionTabsQueue(); /* * if a desired action exists, it will be set afterwards, otherwise allow the first action from the * list to be selected by default */ if (desiredActionsQueue.size() != 0) { String nextAction = desiredActionsQueue.peek(); if (nextAction.equals(ua.getActionName())) { /* remove action from the queue */ desiredActionsQueue.remove(); } else { /* * if this action does not match with the next desired action, do nothing */ return; } } else { entity.getState().resetPageInfo(); } } if (ua instanceof UserActionList) { // selectedTabContent.removeStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); // contentArea.setWidth("100%"); // contentArea.setMargin(false); // selectedTabContent.setMargin(false); ua.executeHandler(entity, app, selectedTabContent, false, actionContext); } else { // selectedTabContent.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); // contentArea.setWidth("99.5%"); // contentArea.setMargin(true); // selectedTabContent.setMargin(true); // selectedTabContent.setWidth("100%"); if (entity != null) { entity.getState().setCurrentTabAction(ua); entity.getState().setCurrentTabActionContainer(selectedTabContent); entity.getState().setCurrentActionsPath(ua.getFullActionPath()); // entity.getState().getDesiredActionTabsQueue().clear(); // entity.getState().resetPageInfoForCurrentAction(); actionContext.getWindow().setFragmentToEntity(entity); } ua.executeHandler(entity, app, selectedTabContent, false, actionContext); } } }); /* add the tabsheet to the target component */ // List<String> currentUserTypes = getCurrentUserTypes(entity, app); Map<String, ComponentContainer> actionPathContainers = new HashMap<String, ComponentContainer>(); List<UserAction> actionsList = new ArrayList<UserAction>(ual.getActions().values()); for (UserAction cua : actionsList) { /* display only the actions that the user is allowed to see */ // if (!cua.allowRead(currentUserTypes)) { if (!cua.isVisible(actionContext)) { continue; } CssLayout tabContent = new CssLayout(); if (cua instanceof UserActionList) { // tabContent.setMargin(false); // contentArea.setMargin(false); // tabContent.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); // tabContent.setWidth("100%"); } else { // tabContent.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); tabContent.setMargin(true); // contentArea.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); // contentArea.setMargin(true); } tabContent.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE); actionPathContainers.put(cua.getActionName(), tabContent); tabContent.setData(cua); actionsTabSheet.addTab(tabContent, cua.getDisplayName(), null); } displayArea.addComponent(actionsTabSheet); if (entity != null) { Deque<String> desiredActionsQueue = entity.getState().getDesiredActionTabsQueue(); if (desiredActionsQueue.size() != 0) { // System.out.println("desired actions: " + // entity.getState().getDesiredActionsPath()); // System.out.println("full url: "+app.getFullUrl()); /* select the tab specified by the next desired action */ actionsTabSheet.setSelectedTab(actionPathContainers.get(desiredActionsQueue.peek())); } } }
From source file:ru.codeinside.adm.ui.AdminApp.java
License:Mozilla Public License
private Component createEmployeeWidget() { final TabSheet tabSheet = new TabSheet(); tabSheet.addStyleName(Reindeer.TABSHEET_MINIMAL); tabSheet.setSizeFull();//from w ww . j ava 2s . com tabSheet.addTab(new EmployeeWidget(false, table), "?"); tabSheet.addTab(new EmployeeWidget(true, table), ""); tabSheet.addListener(new TabSheet.SelectedTabChangeListener() { @Override public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) { EmployeeWidget currentTab = (EmployeeWidget) tabSheet.getSelectedTab(); currentTab.refreshList(); } }); return 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) { // ? //from ww w . j av a 2 s . c o 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); }