List of usage examples for com.vaadin.ui TabSheet addSelectedTabChangeListener
public Registration addSelectedTabChangeListener(SelectedTabChangeListener listener)
From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java
License:Apache License
Panel windows() { Panel p = new Panel("Dialogs"); VerticalLayout content = new VerticalLayout() { final Window win = new Window("Window Caption"); String prevHeight = "300px"; boolean footerVisible = true; boolean autoHeight = false; boolean tabsVisible = false; boolean toolbarVisible = false; boolean footerToolbar = false; boolean toolbarLayout = false; String toolbarStyle = null; VerticalLayout windowContent() { VerticalLayout root = new VerticalLayout(); if (toolbarVisible) { MenuBar menuBar = MenuBars.getToolBar(); menuBar.setSizeUndefined(); menuBar.setStyleName(toolbarStyle); Component toolbar = menuBar; if (toolbarLayout) { menuBar.setWidth(null); HorizontalLayout toolbarLayout = new HorizontalLayout(); toolbarLayout.setWidth("100%"); toolbarLayout.setSpacing(true); Label label = new Label("Tools"); label.setSizeUndefined(); toolbarLayout.addComponents(label, menuBar); toolbarLayout.setExpandRatio(menuBar, 1); toolbarLayout.setComponentAlignment(menuBar, Alignment.TOP_RIGHT); toolbar = toolbarLayout; }// ww w. java 2 s .co m toolbar.addStyleName("v-window-top-toolbar"); root.addComponent(toolbar); } Component content = null; if (tabsVisible) { TabSheet tabs = new TabSheet(); tabs.setSizeFull(); VerticalLayout l = new VerticalLayout(); l.addComponent(new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML)); l.setMargin(true); tabs.addTab(l, "Selected"); tabs.addTab(new Label(" ", ContentMode.HTML), "Another"); tabs.addTab(new Label(" ", ContentMode.HTML), "One more"); tabs.addStyleName("padded-tabbar"); tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() { @Override public void selectedTabChange(final SelectedTabChangeEvent event) { try { Thread.sleep(600); } catch (InterruptedException e) { e.printStackTrace(); } } }); content = tabs; } else if (!autoHeight) { Panel p = new Panel(); p.setSizeFull(); p.addStyleName("borderless"); if (!toolbarVisible || !toolbarLayout) { p.addStyleName("scroll-divider"); } VerticalLayout l = new VerticalLayout(); l.addComponent(new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML)); l.setMargin(true); p.setContent(l); content = p; } else { content = new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML); root.setMargin(true); } root.addComponent(content); if (footerVisible) { HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName("v-window-bottom-toolbar"); Label footerText = new Label("Footer text"); footerText.setSizeUndefined(); Button ok = new Button("OK"); ok.addStyleName("primary"); Button cancel = new Button("Cancel"); footer.addComponents(footerText, ok, cancel); footer.setExpandRatio(footerText, 1); if (footerToolbar) { MenuBar menuBar = MenuBars.getToolBar(); menuBar.setStyleName(toolbarStyle); menuBar.setWidth(null); footer.removeAllComponents(); footer.addComponent(menuBar); } root.addComponent(footer); } if (!autoHeight) { root.setSizeFull(); root.setExpandRatio(content, 1); } return root; } { setSpacing(true); setMargin(true); win.setWidth("380px"); win.setHeight(prevHeight); win.setClosable(false); win.setResizable(false); win.setContent(windowContent()); win.setCloseShortcut(KeyCode.ESCAPE, null); Command optionsCommand = new Command() { @Override public void menuSelected(final MenuItem selectedItem) { if (selectedItem.getText().equals("Footer")) { footerVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Auto Height")) { autoHeight = selectedItem.isChecked(); if (!autoHeight) { win.setHeight(prevHeight); } else { prevHeight = win.getHeight() + win.getHeightUnits().toString(); win.setHeight(null); } } if (selectedItem.getText().equals("Tabs")) { tabsVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Top")) { toolbarVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Footer")) { footerToolbar = selectedItem.isChecked(); } if (selectedItem.getText().equals("Top layout")) { toolbarLayout = selectedItem.isChecked(); } if (selectedItem.getText().equals("Borderless")) { toolbarStyle = selectedItem.isChecked() ? "borderless" : null; } win.setContent(windowContent()); } }; MenuBar options = new MenuBar(); options.setCaption("Content"); options.addItem("Auto Height", optionsCommand).setCheckable(true); options.addItem("Tabs", optionsCommand).setCheckable(true); MenuItem option = options.addItem("Footer", optionsCommand); option.setCheckable(true); option.setChecked(true); options.addStyleName("small"); addComponent(options); options = new MenuBar(); options.setCaption("Toolbars"); options.addItem("Footer", optionsCommand).setCheckable(true); options.addItem("Top", optionsCommand).setCheckable(true); options.addItem("Top layout", optionsCommand).setCheckable(true); options.addItem("Borderless", optionsCommand).setCheckable(true); options.addStyleName("small"); addComponent(options); Command optionsCommand2 = new Command() { @Override public void menuSelected(final MenuItem selectedItem) { if (selectedItem.getText().equals("Caption")) { win.setCaption(selectedItem.isChecked() ? "Window Caption" : null); } else if (selectedItem.getText().equals("Closable")) { win.setClosable(selectedItem.isChecked()); } else if (selectedItem.getText().equals("Resizable")) { win.setResizable(selectedItem.isChecked()); } else if (selectedItem.getText().equals("Modal")) { win.setModal(selectedItem.isChecked()); } } }; options = new MenuBar(); options.setCaption("Options"); MenuItem caption = options.addItem("Caption", optionsCommand2); caption.setCheckable(true); caption.setChecked(true); options.addItem("Closable", optionsCommand2).setCheckable(true); options.addItem("Resizable", optionsCommand2).setCheckable(true); options.addItem("Modal", optionsCommand2).setCheckable(true); options.addStyleName("small"); addComponent(options); final Button show = new Button("Open Window", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { getUI().addWindow(win); win.center(); win.focus(); event.getButton().setEnabled(false); } }); show.addStyleName("primary"); addComponent(show); final CheckBox hidden = new CheckBox("Hidden"); hidden.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { win.setVisible(!hidden.getValue()); } }); addComponent(hidden); win.addCloseListener(new CloseListener() { @Override public void windowClose(final CloseEvent e) { show.setEnabled(true); } }); } }; p.setContent(content); return p; }
From source file:com.cavisson.gui.dashboard.components.controls.Tabsheets.java
License:Apache License
static TabSheet getTabSheet(boolean caption, String style, boolean closable, boolean scrolling, boolean icon, boolean disable) { TestIcon testIcon = new TestIcon(60); TabSheet ts = new TabSheet(); ts.addStyleName(style);//from ww w . j a va 2s .com StringGenerator sg = new StringGenerator(); for (int i = 1; i <= (scrolling ? 10 : 3); i++) { String tabcaption = caption ? sg.nextString(true) + " " + sg.nextString(false) : null; VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); content.addComponent(new Label("Content for tab " + i)); if (i == 2) { content.addComponent(new Label( "Excepteur sint obcaecat cupiditat non proident culpa. Magna pars studiorum, prodita quaerimus.")); } Tab t = ts.addTab(content, tabcaption); t.setClosable(closable); t.setEnabled(!disable); // First tab is always enabled if (i == 1) { t.setEnabled(true); } if (icon) { t.setIcon(testIcon.get(false)); } } ts.addSelectedTabChangeListener(new SelectedTabChangeListener() { @Override public void selectedTabChange(SelectedTabChangeEvent event) { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }); return ts; }
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 va 2 s .com*/ */ 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.peergreen.webconsole.scope.system.internal.bundle.BundleView.java
License:Open Source License
@PostConstruct public void createView() { setMargin(true);// w w w. ja v a 2 s . c o m setSpacing(true); /* Page.Styles styles = Page.getCurrent().getStyles(); styles.add(".no-padding {padding: 0em 0em 0em 0em !important; }"); */ HorizontalLayout header = new HorizontalLayout(); // header.setWidth("100%"); header.setSpacing(true); header.setMargin(true); Label title = new Label("OSGi Bundles"); title.addStyleName("h1"); // title.setSizeUndefined(); header.addComponent(title); header.setComponentAlignment(title, Alignment.MIDDLE_LEFT); final TextField filter = new TextField(); filter.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(final FieldEvents.TextChangeEvent event) { data.removeAllContainerFilters(); String trimmed = event.getText().trim(); Container.Filter or = new Or(new SimpleStringFilter(BUNDLE_ID_COLUMN, trimmed, true, false), new SimpleStringFilter(BUNDLE_NAME_COLUMN, trimmed, true, false), new SimpleStringFilter(BUNDLE_SYMBOLICNAME_COLUMN, trimmed, true, false), new SimpleStringFilter(VERSION_COLUMN, trimmed, true, false), new SimpleStringFilter(PRETTY_STATE_COLUMN, trimmed, true, false)); data.addContainerFilter(or); } }); filter.setInputPrompt("Filter"); filter.addShortcutListener(new ShortcutListener("Clear", ShortcutAction.KeyCode.ESCAPE, null) { @Override public void handleAction(Object sender, Object target) { filter.setValue(""); data.removeAllContainerFilters(); } }); header.addComponent(filter); header.setExpandRatio(filter, 1); header.setComponentAlignment(filter, Alignment.MIDDLE_LEFT); // Store the header in the vertical layout (this) addComponent(header); addComponent(tabSheet); table = new Table(); table.setContainerDataSource(data); table.setSizeFull(); table.setSortContainerPropertyId(BUNDLE_ID_COLUMN); table.setSortAscending(true); table.setImmediate(true); table.setColumnHeader(BUNDLE_ID_COLUMN, "Bundle ID"); table.setColumnHeader(PRETTY_NAME_COLUMN, "Bundle Name"); table.setColumnHeader(VERSION_COLUMN, "Version"); table.setColumnHeader(PRETTY_STATE_COLUMN, "State"); table.setColumnHeader("actions", "Actions"); table.setColumnWidth(BUNDLE_ID_COLUMN, 100); table.setColumnAlignment(BUNDLE_ID_COLUMN, Table.Align.CENTER); table.setColumnAlignment(PRETTY_STATE_COLUMN, Table.Align.CENTER); table.setColumnAlignment(VERSION_COLUMN, Table.Align.CENTER); table.addGeneratedColumn("actions", new Table.ColumnGenerator() { @Override public Object generateCell(final Table source, final Object itemId, final Object columnId) { HorizontalLayout layout = new HorizontalLayout(); BeanItem<BundleItem> item = (BeanItem<BundleItem>) source.getContainerDataSource().getItem(itemId); Bundle bundle = item.getBean().getBundle(); if (BundleHelper.isState(bundle, Bundle.INSTALLED) || BundleHelper.isState(bundle, Bundle.RESOLVED)) { Button changeState = new Button(); changeState.addClickListener(new StartBundleClickListener(bundle, notifierService)); //changeState.addStyleName("no-padding"); changeState.setCaption("Start"); //changeState.setIcon(new ClassResource(BundleViewer.class, "/images/go-next.png")); if (!securityManager.isUserInRole("admin")) { changeState.setDisableOnClick(true); } layout.addComponent(changeState); } if (BundleHelper.isState(bundle, Bundle.ACTIVE)) { Button changeState = new Button(); changeState.addClickListener(new StopBundleClickListener(bundle, notifierService)); //changeState.addStyleName("no-padding"); changeState.setCaption("Stop"); if (!securityManager.isUserInRole("admin")) { changeState.setDisableOnClick(true); } //changeState.setIcon(new ClassResource(BundleViewer.class, "/images/media-record.png")); layout.addComponent(changeState); } // Update Button update = new Button(); update.addClickListener(new UpdateBundleClickListener(bundle, notifierService)); //update.addStyleName("no-padding"); update.setCaption("Update"); if (!securityManager.isUserInRole("admin")) { update.setDisableOnClick(true); } //update.setIcon(new ClassResource(BundleViewer.class, "/images/view-refresh.png")); layout.addComponent(update); // Trash Button trash = new Button(); trash.addClickListener(new UninstallBundleClickListener(bundle, notifierService)); //trash.addStyleName("no-padding"); trash.setCaption("Delete"); if (!securityManager.isUserInRole("admin")) { trash.setDisableOnClick(true); } //trash.setIcon(new ClassResource(BundleViewer.class, "/images/user-trash-full.png")); layout.addComponent(trash); return layout; } }); table.setVisibleColumns(BUNDLE_ID_COLUMN, PRETTY_NAME_COLUMN, VERSION_COLUMN, PRETTY_STATE_COLUMN, "actions"); table.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(final ItemClickEvent event) { if (event.isDoubleClick()) { BeanItem<BundleItem> item = (BeanItem<BundleItem>) table.getContainerDataSource() .getItem(event.getItemId()); Bundle bundle = item.getBean().getBundle(); showBundle(bundle); } } }); createBundleTracker(); tabSheet.setSizeFull(); selectedTabListener = new SelectedTabListener(uiContext.getViewNavigator()); selectedTabListener.addLocation(table, uiContext.getViewNavigator().getLocation(this.getClass().getName())); tabSheet.addSelectedTabChangeListener(selectedTabListener); tabSheet.addTab(table, "Bundles", new ClassResource(BundleView.class, "/images/22x22/user-home.png")); setExpandRatio(tabSheet, 1.5f); tabSheet.setCloseHandler(new TabSheet.CloseHandler() { @Override public void onTabClose(TabSheet tabsheet, Component tabContent) { for (Map.Entry<Long, Component> tab : openTabs.entrySet()) { if (tabContent.equals(tab.getValue())) { openTabs.remove(tab.getKey()); } } tabsheet.removeComponent(tabContent); selectedTabListener.removeLocation(tabContent); } }); }
From source file:facs.components.BookAdmin.java
License:Open Source License
public BookAdmin(User user) { Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss"); System.out.println(ft.format(dNow) + " INFO Calendar Admin accessed! - User: " + LiferayAndVaadinUtils.getUser().getScreenName()); Label infoLabel = new Label( DBManager.getDatabaseInstance().getUserNameByUserID(LiferayAndVaadinUtils.getUser().getScreenName()) + " " + LiferayAndVaadinUtils.getUser().getScreenName()); infoLabel.addStyleName("h4"); String buttonRefreshTitle = "Refresh"; Button refresh = new Button(buttonRefreshTitle); refresh.setIcon(FontAwesome.REFRESH); refresh.setSizeFull();/*from w w w.j a v a2 s. c o m*/ refresh.setDescription("Click here to reload the data from the database!"); refresh.addStyleName(ValoTheme.BUTTON_FRIENDLY); String buttonUpdateTitle = "Update"; Button updateUser = new Button(buttonUpdateTitle); updateUser.setIcon(FontAwesome.WRENCH); updateUser.setSizeFull(); updateUser.setDescription("Click here to update your user role and group!"); userDevice = new ListSelect("Select a device"); userDevice.addItems(DBManager.getDatabaseInstance().getDeviceNames()); userDevice.setRows(6); userDevice.setNullSelectionAllowed(false); userDevice.setSizeFull(); userDevice.setImmediate(true); /* * userDevice.addValueChangeListener(e -> Notification.show("Device:", * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION)); */ userGroup = new ListSelect("Select a user group"); userGroup.addItems(DBManager.getDatabaseInstance().getUserGroups()); userGroup.setRows(6); userGroup.setNullSelectionAllowed(false); userGroup.setSizeFull(); userGroup.setImmediate(true); /* * userGroup.addValueChangeListener(e -> Notification.show("User Group:", * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION)); */ userRole = new ListSelect("Select a user role"); userRole.addItems(DBManager.getDatabaseInstance().getUserRoles()); userRole.setRows(6); userRole.setNullSelectionAllowed(false); userRole.setSizeFull(); userRole.setImmediate(true); /* * userRole.addValueChangeListener(e -> Notification.show("User Role:", * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION)); */ refresh.addClickListener(new ClickListener() { private static final long serialVersionUID = -3610721151565496269L; @Override public void buttonClick(ClickEvent event) { refreshDataSources(); } }); updateUser.addClickListener(new ClickListener() { private static final long serialVersionUID = -3610721151565496909L; @Override public void buttonClick(ClickEvent event) { try { if (userDevice.getValue().equals(null) || userRole.getValue().equals(null) || userGroup.getValue().equals(null)) { showErrorNotification("Something's missing!", "Please make sure that you selected a Device, a Role and a Group! Each list has to have one highligthed option.'."); // System.out.println("Device: "+userDevice.getValue()+" Group: "+userGroup.getValue()+" Role: "+userRole.getValue()); } else { DBManager.getDatabaseInstance().getShitDone( DBManager.getDatabaseInstance().getUserRoleIDbyDesc(userRole.getValue().toString()), DBManager.getDatabaseInstance() .getUserIDbyLDAPID(LiferayAndVaadinUtils.getUser().getScreenName()), DBManager.getDatabaseInstance() .getDeviceIDByName(userDevice.getValue().toString())); DBManager.getDatabaseInstance().getShitDoneAgain( DBManager.getDatabaseInstance() .getUserGroupIDByName(userGroup.getValue().toString()), LiferayAndVaadinUtils.getUser().getScreenName()); } } catch (Exception e) { showErrorNotification("Something's missing!", "Please make sure that you selected a Device, a Role and a Group! Each list has to have one highligthed option.'."); } refreshDataSources(); } }); // only admins are allowed to see the admin panel ;) if (!DBManager.getDatabaseInstance() .getUserAdminPanelAccessByLDAPId(LiferayAndVaadinUtils.getUser().getScreenName()).equals("1")) { VerticalLayout errorLayout = new VerticalLayout(); infoLabel.setValue("ACCESS DENIED"); errorLayout.addComponent(infoLabel); showErrorNotification("Access Denied!", "Sorry, you're not allowed to see anything here, at least your username told us so. Do you need assistance? Please contact 'info@qbic.uni-tuebingen.de'."); setCompositionRoot(errorLayout); return; } this.setCaption("Admin"); final TabSheet bookAdmin = new TabSheet(); bookAdmin.addStyleName(ValoTheme.TABSHEET_FRAMED); bookAdmin.addStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS); ArrayList<String> deviceNames = new ArrayList<String>(); deviceNames = DBManager.getDatabaseInstance().getDeviceNames(); bookAdmin.addTab(awaitingRequestsGrid()); for (int i = 0; i < deviceNames.size(); i++) { bookAdmin.addTab(newDeviceGrid(deviceNames.get(i))); } bookAdmin.addTab(deletedBookingsGrid()); bookAdmin.addSelectedTabChangeListener(new SelectedTabChangeListener() { /** * */ private static final long serialVersionUID = 8987818794404251063L; @Override public void selectedTabChange(SelectedTabChangeEvent event) { userDevice.select(bookAdmin.getSelectedTab().getCaption()); userRole.select(DBManager.getDatabaseInstance() .getUserGroupDescriptionByLDAPId(LiferayAndVaadinUtils.getUser().getScreenName(), DBManager .getDatabaseInstance().getDeviceIDByName(bookAdmin.getSelectedTab().getCaption()))); userGroup.select(DBManager.getDatabaseInstance() .getUserRoleNameByLDAPId(LiferayAndVaadinUtils.getUser().getScreenName())); } }); gridLayout.setWidth("100%"); // add components to the grid layout // gridLayout.addComponent(infoLabel, 0, 0, 3, 0); gridLayout.addComponent(bookAdmin, 0, 1, 5, 1); gridLayout.addComponent(refresh, 0, 2); gridLayout.addComponent(userDevice, 0, 4, 1, 4); gridLayout.addComponent(userRole, 2, 4, 3, 4); gridLayout.addComponent(userGroup, 4, 4, 5, 4); gridLayout.addComponent(updateUser, 0, 5, 5, 5); gridLayout.setSizeFull(); gridLayout.setSpacing(true); setCompositionRoot(gridLayout); /* * JavaScript to update the Grid try { JDBCConnectionPool connectionPool = new * SimpleJDBCConnectionPool("com.mysql.jdbc.Driver", * "jdbc:mysql://localhost:8889/facs_facility", "facs", "facs"); QueryDelegate qd = new * FreeformQuery("select * from facs_facility", connectionPool, "id"); final SQLContainer c = * new SQLContainer(qd); bookAdmin.setContainerDataSource(c); } * * JavaScript.getCurrent().execute("setInterval(function(){refreshTable();},5000);"); * JavaScript.getCurrent().addFunction("refreshTable", new JavaScriptFunction() { * * @Override public void call(JsonArray arguments) { // TODO Auto-generated method stub * * } }); */ }
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();//from w w w .java 2 s . c o m 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:org.eclipse.hawkbit.ui.rollout.rollout.AddUpdateRolloutWindowLayout.java
License:Open Source License
private TabSheet createGroupDefinitionTabs() { final TabSheet tabSheet = new TabSheet(); tabSheet.setId(UIComponentIdProvider.ROLLOUT_GROUPS); tabSheet.setWidth(850, Unit.PIXELS); tabSheet.setHeight(300, Unit.PIXELS); tabSheet.setStyleName(SPUIStyleDefinitions.ROLLOUT_GROUPS); final TabSheet.Tab simpleTab = tabSheet.addTab(createSimpleGroupDefinitionTab(), i18n.getMessage("caption.rollout.tabs.simple")); simpleTab.setId(UIComponentIdProvider.ROLLOUT_SIMPLE_TAB); final TabSheet.Tab advancedTab = tabSheet.addTab(defineGroupsLayout, i18n.getMessage("caption.rollout.tabs.advanced")); advancedTab.setId(UIComponentIdProvider.ROLLOUT_ADVANCED_TAB); tabSheet.addSelectedTabChangeListener(event -> validateGroups()); return tabSheet; }
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 ww.ja v a 2 s. com*/ * @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.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/*from w ww . j a v a 2 s . co m*/ 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: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));/*from w w w.jav a2 s . c o 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")); }