List of usage examples for com.vaadin.ui MenuBar setCaption
@Override public void setCaption(String caption)
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; }/* w w w . jav a 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.Dragging.java
License:Apache License
public Dragging() { setMargin(true);/* w w w . j a va 2 s. c o m*/ setSpacing(true); Label h1 = new Label("Dragging Components"); h1.addStyleName("h1"); addComponent(h1); MenuBar options = new MenuBar(); options.setCaption("Drop Hints"); addComponent(options); // Use these styles to hide irrelevant drag hints // Can be used either on a parent or directly on the DnDWrapper MenuItem opt = options.addItem("Vertical", new MenuBar.Command() { @Override public void menuSelected(MenuItem selectedItem) { if (selectedItem.isChecked()) { sample.removeStyleName("no-vertical-drag-hints"); } else { sample.addStyleName("no-vertical-drag-hints"); } } }); opt.setCheckable(true); opt.setChecked(true); opt = options.addItem("Horizontal", new MenuBar.Command() { @Override public void menuSelected(MenuItem selectedItem) { if (selectedItem.isChecked()) { sample.removeStyleName("no-horizontal-drag-hints"); } else { sample.addStyleName("no-horizontal-drag-hints"); } } }); opt.setCheckable(true); opt.setChecked(true); opt = options.addItem("Box", new MenuBar.Command() { @Override public void menuSelected(MenuItem selectedItem) { if (selectedItem.isChecked()) { sample.removeStyleName("no-box-drag-hints"); } else { sample.addStyleName("no-box-drag-hints"); } } }); opt.setCheckable(true); opt.setChecked(true); sample = new SortableLayout(); sample.setSizeUndefined(); sample.setHeight("100px"); for (final Component component : createComponents()) { sample.addComponent(component); } addComponent(sample); }
From source file:com.cavisson.gui.dashboard.components.controls.MenuBars.java
License:Apache License
public void init() { Label h1 = new Label("Menu Bars"); h1.addStyleName("h1"); addComponent(h1);/*from www.j ava 2 s . co m*/ MenuBar menuBar = getMenuBar(); menuBar.setCaption("Normal style"); addComponent(menuBar); menuBar = getMenuBar(); menuBar.setCaption("Small style"); menuBar.addStyleName("small"); addComponent(menuBar); menuBar = getMenuBar(); menuBar.setCaption("Borderless style"); menuBar.addStyleName("borderless"); addComponent(menuBar); menuBar = getMenuBar(); menuBar.setCaption("Small borderless style"); menuBar.addStyleName("borderless"); menuBar.addStyleName("small"); addComponent(menuBar); Label h2 = new Label("Drop Down Button"); h2.addStyleName("h2"); addComponent(h2); HorizontalLayout wrap = new HorizontalLayout(); wrap.addStyleName("wrapping"); wrap.setSpacing(true); addComponent(wrap); wrap.addComponent(getMenuButton("Normal", false)); MenuBar split = getMenuButton("Small", false); split.addStyleName("small"); wrap.addComponent(split); split = getMenuButton("Borderless", false); split.addStyleName("borderless"); wrap.addComponent(split); split = getMenuButton("Themed", false); split.addStyleName("color1"); wrap.addComponent(split); split = getMenuButton("Small", false); split.addStyleName("color1"); split.addStyleName("small"); wrap.addComponent(split); h2 = new Label("Split Button"); h2.addStyleName("h2"); addComponent(h2); wrap = new HorizontalLayout(); wrap.addStyleName("wrapping"); wrap.setSpacing(true); addComponent(wrap); wrap.addComponent(getMenuButton("Normal", true)); split = getMenuButton("Small", true); split.addStyleName("small"); wrap.addComponent(split); split = getMenuButton("Borderless", true); split.addStyleName("borderless"); wrap.addComponent(split); split = getMenuButton("Themed", true); split.addStyleName("color1"); wrap.addComponent(split); split = getMenuButton("Small", true); split.addStyleName("color1"); split.addStyleName("small"); wrap.addComponent(split); }
From source file:com.etest.valo.MenuBars.java
License:Apache License
public MenuBars() { setMargin(true);// w w w . ja va 2 s . c om setSpacing(true); Label h1 = new Label("Menu Bars"); h1.addStyleName("h1"); addComponent(h1); MenuBar menuBar = getMenuBar(); menuBar.setCaption("Normal style"); addComponent(menuBar); menuBar = getMenuBar(); menuBar.setCaption("Small style"); menuBar.addStyleName("small"); addComponent(menuBar); menuBar = getMenuBar(); menuBar.setCaption("Borderless style"); menuBar.addStyleName("borderless"); addComponent(menuBar); menuBar = getMenuBar(); menuBar.setCaption("Small borderless style"); menuBar.addStyleName("borderless"); menuBar.addStyleName("small"); addComponent(menuBar); Label h2 = new Label("Drop Down Button"); h2.addStyleName("h2"); addComponent(h2); HorizontalLayout wrap = new HorizontalLayout(); wrap.addStyleName("wrapping"); wrap.setSpacing(true); addComponent(wrap); wrap.addComponent(getMenuButton("Normal", false)); MenuBar split = getMenuButton("Small", false); split.addStyleName("small"); wrap.addComponent(split); split = getMenuButton("Borderless", false); split.addStyleName("borderless"); wrap.addComponent(split); split = getMenuButton("Themed", false); split.addStyleName("color1"); wrap.addComponent(split); split = getMenuButton("Small", false); split.addStyleName("color1"); split.addStyleName("small"); wrap.addComponent(split); h2 = new Label("Split Button"); h2.addStyleName("h2"); addComponent(h2); wrap = new HorizontalLayout(); wrap.addStyleName("wrapping"); wrap.setSpacing(true); addComponent(wrap); wrap.addComponent(getMenuButton("Normal", true)); split = getMenuButton("Small", true); split.addStyleName("small"); wrap.addComponent(split); split = getMenuButton("Borderless", true); split.addStyleName("borderless"); wrap.addComponent(split); split = getMenuButton("Themed", true); split.addStyleName("color1"); wrap.addComponent(split); split = getMenuButton("Small", true); split.addStyleName("color1"); split.addStyleName("small"); wrap.addComponent(split); }
From source file:de.symeda.sormas.ui.statistics.StatisticsFilterComponent.java
License:Open Source License
private HorizontalLayout createFilterAttributeElement() { HorizontalLayout filterAttributeLayout = new HorizontalLayout(); filterAttributeLayout.setSpacing(true); filterAttributeLayout.setWidth(100, Unit.PERCENTAGE); MenuBar filterAttributeDropdown = new MenuBar(); filterAttributeDropdown.setCaption(I18nProperties.getCaption(Captions.statisticsAttribute)); MenuItem filterAttributeItem = filterAttributeDropdown .addItem(I18nProperties.getCaption(Captions.statisticsAttributeSelect), null); MenuBar filterSubAttributeDropdown = new MenuBar(); filterSubAttributeDropdown.setCaption(I18nProperties.getCaption(Captions.statisticsAttributeSpecification)); MenuItem filterSubAttributeItem = filterSubAttributeDropdown.addItem(SPECIFY_YOUR_SELECTION, null); // Add attribute groups for (StatisticsCaseAttributeGroup attributeGroup : StatisticsCaseAttributeGroup.values()) { MenuItem attributeGroupItem = filterAttributeItem.addItem(attributeGroup.toString(), null); attributeGroupItem.setEnabled(false); // Add attributes belonging to the current group for (StatisticsCaseAttribute attribute : attributeGroup.getAttributes()) { Command attributeCommand = selectedItem -> { selectedAttribute = attribute; selectedSubAttribute = null; filterAttributeItem.setText(attribute.toString()); // Add style to keep chosen item selected and remove it from all other items for (MenuItem menuItem : filterAttributeItem.getChildren()) { menuItem.setStyleName(null); }/* w w w . j a va2 s . c om*/ selectedItem.setStyleName("selected-filter"); // Reset the sub attribute dropdown filterSubAttributeItem.removeChildren(); filterSubAttributeItem.setText(SPECIFY_YOUR_SELECTION); if (attribute.getSubAttributes().length > 0) { for (StatisticsCaseSubAttribute subAttribute : attribute.getSubAttributes()) { if (subAttribute.isUsedForFilters()) { Command subAttributeCommand = selectedSubItem -> { selectedSubAttribute = subAttribute; filterSubAttributeItem.setText(subAttribute.toString()); // Add style to keep chosen item selected and remove it from all other items for (MenuItem menuItem : filterSubAttributeItem.getChildren()) { menuItem.setStyleName(null); } selectedSubItem.setStyleName("selected-filter"); updateFilterElement(); }; filterSubAttributeItem.addItem(subAttribute.toString(), subAttributeCommand); } } // Only add the sub attribute dropdown if there are any sub attributes that are relevant for the filters section if (filterSubAttributeItem.getChildren() != null && filterSubAttributeItem.getChildren().size() > 0) { filterAttributeLayout.addComponent(filterSubAttributeDropdown); filterAttributeLayout.setExpandRatio(filterSubAttributeDropdown, 1); } else { filterAttributeLayout.removeComponent(filterSubAttributeDropdown); } } else { filterAttributeLayout.removeComponent(filterSubAttributeDropdown); } updateFilterElement(); }; filterAttributeItem.addItem(attribute.toString(), attributeCommand); } } filterAttributeLayout.addComponent(filterAttributeDropdown); filterAttributeLayout.setExpandRatio(filterAttributeDropdown, 0); return filterAttributeLayout; }