List of usage examples for com.vaadin.ui Button setDescription
public void setDescription(String description)
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
Layout getWindowPreviews() { Layout grid = getPreviewLayout("Windows"); Button win = new Button("Open normal sub-window", new Button.ClickListener() { @Override/*from w w w.j a v a 2s . co m*/ public void buttonClick(ClickEvent event) { getApplication().getMainWindow().addWindow(new Window("Normal window")); } }); grid.addComponent(win); win.setDescription("new Window()"); win = new Button("Open opaque sub-window", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Window w = new Window("Window.addStyleName(\"opaque\")"); w.addStyleName("opaque"); getApplication().getMainWindow().addWindow(w); } }); grid.addComponent(win); win.setDescription("Window.addStyleName(\"opaque\")"); return grid; }
From source file:my.vaadin.app.MyUI.java
@Override protected void init(VaadinRequest vaadinRequest) { final VerticalLayout layout = new VerticalLayout(); filterText.setPlaceholder("filter by name..."); filterText.addValueChangeListener(e -> updateList()); filterText.setValueChangeMode(ValueChangeMode.LAZY); Button clearFilterTextBtn = new Button(FontAwesome.TIMES); clearFilterTextBtn.setDescription("Clear the current filter"); clearFilterTextBtn.addClickListener(e -> filterText.clear()); CssLayout filtering = new CssLayout(); filtering.addComponents(filterText, clearFilterTextBtn); filtering.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); Button addCustomerBtn = new Button("Add new customer"); addCustomerBtn.addClickListener(e -> { grid.asSingleSelect().clear();//from ww w .j a v a2s . c o m form.setCustomer(new Customer()); }); HorizontalLayout toolbar = new HorizontalLayout(filtering, addCustomerBtn); grid.setColumns("firstName", "lastName", "email"); HorizontalLayout main = new HorizontalLayout(grid, form); main.setSizeFull(); grid.setSizeFull(); main.setExpandRatio(grid, 1); layout.addComponents(toolbar, main); // fetch list of Customers from service and assign it to Grid updateList(); setContent(layout); form.setVisible(false); grid.asSingleSelect().addValueChangeListener(event -> { if (event.getValue() == null) { form.setVisible(false); } else { form.setCustomer(event.getValue()); } }); }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.tester.ExecutionScreen.java
License:Apache License
public ExecutionScreen() { testCaseTree = new TreeTable("available.tests"); testCaseTree.setAnimationsEnabled(true); testCaseTree.addContainerProperty("general.name", String.class, ""); testCaseTree.addGeneratedColumn("general.status", (Table source, Object itemId, Object columnId) -> { if ("general.status".equals(columnId) && itemId instanceof String) { String id = (String) itemId; String message;//from w w w . ja va 2s .co m HorizontalLayout icons = new HorizontalLayout(); Button label = new Button(); Button label2 = new Button(); icons.addComponent(label2); icons.addComponent(label); label.addStyleName(ValoTheme.BUTTON_BORDERLESS + " labelButton"); label2.addStyleName(ValoTheme.BUTTON_BORDERLESS + " labelButton"); Map<String, Integer> summary = new HashMap<>(); boolean locked = false; if (id.startsWith("tce")) { TestCaseExecutionServer tce = new TestCaseExecutionServer(Integer.parseInt(id.substring(3))); summary = getSummary(tce, -1); locked = isLocked(tce); } else if (id.startsWith("es")) { ExecutionStepServer es = new ExecutionStepServer(extractExecutionStepPK(id)); summary = getSummary(es.getTestCaseExecution(), Integer.parseInt(id.substring(id.lastIndexOf("-") + 1))); locked = es.getLocked(); } if (locked) { label2.setIcon(VaadinIcons.LOCK); label2.setDescription(TRANSLATOR.translate("message.locked")); } if (!summary.isEmpty()) { if (summary.containsKey("result.fail")) { //At least one failure means the test case is failing message = "result.fail"; } else if (summary.containsKey("result.blocked")) { //It is blocked message = "result.blocked"; } else if (summary.containsKey("result.pending") && !summary.containsKey("result.pass")) { //Still not done message = "result.pending"; } else if (summary.containsKey("result.pending") && summary.containsKey("result.pass")) { //In progress message = "result.progress"; } else { //All is pass message = "result.pass"; } label.setCaption(TRANSLATOR.translate(message)); label.setDescription(TRANSLATOR.translate(message)); //Completed. Now check result switch (message) { case "result.pass": label.setIcon(VaadinIcons.CHECK); break; case "result.fail": label.setIcon(VaadinIcons.CLOSE); break; case "result.blocked": label.setIcon(VaadinIcons.PAUSE); break; case "result.pending": label.setIcon(VaadinIcons.CLOCK); break; case "result.progress": label.setIcon(VaadinIcons.AUTOMATION); break; default: label.setIcon(VaadinIcons.CLOCK); break; } return icons; } } return new Label(); }); testCaseTree.addContainerProperty("general.summary", String.class, ""); testCaseTree.addContainerProperty("general.assignment.date", String.class, ""); testCaseTree.setVisibleColumns( new Object[] { "general.name", "general.status", "general.summary", "general.assignment.date" }); testCaseTree.addActionHandler(new Action.Handler() { @Override public Action[] getActions(Object target, Object sender) { List<Action> actions = new ArrayList<>(); if (target instanceof String) { String t = (String) target; int tcID = -1; TestCaseExecutionServer tce = null; if (t.startsWith("es")) { tce = new TestCaseExecutionServer( new ExecutionStepServer(extractExecutionStepPK(t)).getTestCaseExecution().getId()); tcID = Integer.parseInt(t.substring(t.lastIndexOf("-") + 1)); } else if (t.startsWith("tce")) { tce = new TestCaseExecutionServer(Integer.parseInt(t.substring(3))); } if (!isLocked(tce, tcID) && ExecutionScreen.this instanceof TesterScreenProvider) { actions.add(new Action(TRANSLATOR.translate("general.execute"), VMUI.EXECUTION_ICON)); } else if (isLocked(tce, tcID) && ExecutionScreen.this instanceof QualityScreenProvider) { actions.add(new Action(TRANSLATOR.translate("general.review"), VaadinIcons.EYE)); } actions.add(new Action(TRANSLATOR.translate("general.export"), VaadinIcons.DOWNLOAD)); } return actions.toArray(new Action[actions.size()]); } @Override public void handleAction(Action action, Object sender, Object target) { List<TestCaseExecutionServer> executions = new ArrayList<>(); int tcID = -1; if (((String) target).startsWith("tce")) { executions.add(new TestCaseExecutionServer(Integer.parseInt(((String) target).substring(3)))); } else if (((String) target).startsWith("es")) { executions.add(new TestCaseExecutionServer( new ExecutionStepServer(extractExecutionStepPK((String) target)).getTestCaseExecution() .getId())); tcID = Integer.parseInt(((String) target).substring(((String) target).lastIndexOf("-") + 1)); } //Parse the information to get the exact Execution Step if (action.getCaption().equals(TRANSLATOR.translate("general.export"))) { viewExecutionScreen(executions, tcID); } else { showExecutionScreen(executions, tcID); } } }); }
From source file:org.apache.ace.webui.vaadin.AddArtifactWindow.java
License:Apache License
/** * Create a new button that delete an OBREntry on-click. * //from www. j a v a2 s. c om * @param entry * The entry * @return The button */ private Button createDeleteOBREntryButton(final OBREntry entry) { Button button = new Button("x"); button.setStyleName(Reindeer.BUTTON_SMALL); button.setDescription("Delete " + entry.getName()); button.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { event.getButton().setEnabled(false); try { int code = OBRUtil.deleteOBREntry(getConnectionFactory(), entry, m_obrUrl); if (code == HttpServletResponse.SC_OK) { m_artifactsTable.removeItem(entry.getUri()); } else { showErrorNotification("Failed to delete resource", "The OBR returned an unexpected response code: " + code); } } catch (IOException e) { showErrorNotification("Failed to delete resource", "Reason: " + e.getMessage()); } } }); return button; }
From source file:org.apache.ace.webui.vaadin.component.BaseObjectPanel.java
License:Apache License
/** * Creates a remove-item button for the given repository object. * /*from ww w . ja va2 s . c om*/ * @param object * the object to create a remove-item button, cannot be <code>null</code>; * @param displayName * the display name for the description of the button, cannot be <code>null</code>. * @return a remove-item button, never <code>null</code>. */ protected final Button createRemoveItemButton(RepositoryObject object, String displayName) { Button result = new Button(); result.setIcon(createIconResource("trash")); result.setData(object.getDefinition()); result.setStyleName("small tiny"); result.setDescription("Delete " + displayName); result.setDisableOnClick(true); result.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { try { handleItemRemoveObject(event.getButton().getData()); } catch (Exception e) { // ACE-246: notify user when the removal failed! getWindow().showNotification("Failed to remove item!", "<br/>Reason: " + e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); return result; }
From source file:org.apache.ace.webui.vaadin.component.BaseObjectPanel.java
License:Apache License
/** * Creates a remove-link button for the given repository object. * //from ww w . j a v a 2s .c o m * @param object * the object to create a remove-link button, cannot be <code>null</code>; * @param displayName * the display name for the description of the button, cannot be <code>null</code>. * @return a remove-link button, never <code>null</code>. */ protected final Button createRemoveLinkButton(RepositoryObject object, String displayName) { Button result = new Button(); result.setIcon(createIconResource("unlink")); result.setStyleName("small tiny"); result.setData(object.getDefinition()); result.setDescription("Unlink " + displayName); // Only enable this button when actually selected... result.setEnabled(false); result.setDisableOnClick(true); result.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { handleItemRemoveLink(event.getButton().getData()); } }); return result; }
From source file:org.apache.ace.webui.vaadin.ManageResourceProcessorWindow.java
License:Apache License
private Button createRemoveButton(final ArtifactObject rp) { Button button = new Button("x"); button.setStyleName(Reindeer.BUTTON_SMALL); button.setDescription("Remove " + rp.getAttribute(Constants.BUNDLE_SYMBOLICNAME)); button.addListener(new ClickListener() { @Override// w w w . ja v a2 s . co m public void buttonClick(ClickEvent event) { event.getButton().setEnabled(false); try { getArtifactRepository().remove(rp); m_artifactsTable.removeItem(rp.getDefinition()); } catch (Exception e) { getParent().showNotification("Failed to delete resource", "Reason: <br/>" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); return button; }
From source file:org.apache.ace.webui.vaadin.ShortcutHelper.java
License:Apache License
public static void addShortcut(WebBrowser browser, Button button, String description, int key, int... modifiers) { if (!browser.isTouchDevice()) { button.setClickShortcut(key, modifiers); button.setDescription(String.format("%s (%s)", description, formatShortcut(key, modifiers))); }//from w w w . j a v a 2s . c om }
From source file:org.asi.ui.custom.demo.CustomWindowDemo.java
private void init() { // Initialize our new UI component final LookUp win = new LookUp("Abhiram"); final LookUp win1 = new LookUp(); Button x = new Button("First Window"); Button y = new Button("Second Window"); setSizeFull();//from w w w. ja va2 s . co m addComponent(x); x.setDescription("Added minimize to tray"); setComponentAlignment(x, Alignment.MIDDLE_CENTER); x.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (win.getParent() == null) { win.setClosable(false); win.setMinimizeToTray(true); UI.getCurrent().addWindow(win); } else { LookUp win3 = new LookUp("Abhi" + (i++)); win3.setMinimizeToTray(true); UI.getCurrent().addWindow(win3); } } }); y.setDescription("Not Added minimize to tray"); addComponent(y); setComponentAlignment(y, Alignment.MIDDLE_CENTER); y.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (win1.getParent() == null) { UI.getCurrent().addWindow(win1); } } }); }
From source file:org.asi.ui.customcomponentdemo.demo.CustomMenuBarDemo.java
private void init() { Button menu = new Button("Main Menu"); addComponent(menu);/*from w w w.j ava2s. c o m*/ menu.setDescription("Go to Main Menu"); setComponentAlignment(menu, Alignment.MIDDLE_CENTER); menu.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { getUI().getNavigator().navigateTo(Custom.NAME); } }); // Initialize our new UI component final CustomMenuBar barmenu = new CustomMenuBar(); // A top-level menu item that opens a submenu final CustomMenuItem drinks = barmenu.addItem("Beverages", null, null); drinks.setCloseable(true); drinks.setItemClickable(true); final VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); layout.addComponent(barmenu); CustomMenuBar.Command mycommand = new CustomMenuBar.Command() { private static final long serialVersionUID = 4483012525105015694L; @Override public void menuSelected(CustomMenuBar.CustomMenuItem selectedItem) { Notification.show("select--" + selectedItem.getId() + "--" + selectedItem.getMenuItem().getCaption() + "--" + selectedItem.getMenuItem().getId()); } }; barmenu.addItemClickListener(new CustomMenuBar.ItemClickListener() { @Override public void itemClick(CustomMenuBar.ItemClickEvent event) { Notification.show("item--" + event.getMenuItem().getId() + "--" + event.getMenuItem().getMenuItem().getCaption() + "--" + event.getMenuItem().getMenuItem().getId()); } }); barmenu.addItemCloseClickListener(new CustomMenuBar.ItemCloseClickListener() { @Override public void itemCloseClick(CustomMenuBar.ItemCloseClickEvent event) { Notification.show("close--" + event.getMenuItem().getId() + "--" + event.getMenuItem().getMenuItem().getCaption() + "--" + event.getMenuItem().getMenuItem().getId()); if (event.getMenuItem().getParent() != null) { event.getMenuItem().getParent().removeChild(event.getMenuItem()); } else { barmenu.removeItem(event.getMenuItem()); } } }); // Submenu item with a sub-submenu CustomMenuItem hots = drinks.addItem(new MenuItemDTO("Hot"), null, null); hots.setCloseable(false); hots.setItemClickable(true); hots.addItem("Tea", null, mycommand); hots.addItem(new MenuItemDTO("Coffee"), null, mycommand); // Another submenu item with a sub-submenu CustomMenuItem colds = drinks.addItem(new MenuItemDTO("Cold"), null, null); colds.addItem(new MenuItemDTO("Milk"), null, mycommand); colds.addItem(new MenuItemDTO("Weissbier"), null, mycommand); // A sub-menu item after a separator drinks.addSeparator(); drinks.addItem(new MenuItemDTO("Quit Drinking"), null, null); // Another top-level item CustomMenuItem snacks = barmenu.addItem(new MenuItemDTO("Snacks"), null, null); snacks.addItem(new MenuItemDTO("Weisswurst"), null, mycommand); snacks.addItem(new MenuItemDTO("Bratwurst"), null, mycommand); snacks.addItem(new MenuItemDTO("Currywurst"), null, mycommand); // Yet another top-level item CustomMenuItem servs = barmenu.addItem(new MenuItemDTO("Services"), null, null); CustomMenuItem servs1 = servs.addItem(new MenuItemDTO("Car Service"), null, mycommand); servs1.setCloseable(true); servs1.setItemClickable(true); addComponent(layout); }