List of usage examples for com.vaadin.ui Button setIcon
@Override public void setIcon(Resource icon)
From source file:org.eclipse.skalli.view.component.PeopleSearchWindow.java
License:Open Source License
private void createContents() { setModal(true);//from w w w .j a va 2 s .com setCaption("Search people..."); setWidth("310px"); //$NON-NLS-1$ setHeight("400px"); //$NON-NLS-1$ root = new VerticalLayout(); root.setMargin(true); root.setSpacing(true); HorizontalLayout search = new HorizontalLayout(); search.setSpacing(true); searchField = new TextField("Search for:"); searchField.setWidth("20em"); //$NON-NLS-1$ searchField.setImmediate(true); searchField.addListener(new ValueChangeListener() { @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { search((String) searchField.getValue()); list.focus(); } }); search.addComponent(searchField); search.setComponentAlignment(searchField, Alignment.BOTTOM_LEFT); search.setExpandRatio(searchField, 1.0f); Button searchButton = new NativeButton("", new Button.ClickListener() { //$NON-NLS-1$ @Override public void buttonClick(ClickEvent event) { search((String) searchField.getValue()); } }); searchButton.setDescription("Search"); searchButton.setStyleName(STYLE_USER_DOSEARCH); search.addComponent(searchButton); search.setComponentAlignment(searchButton, Alignment.BOTTOM_LEFT); search.setExpandRatio(searchButton, 0); root.addComponent(search); list = new ListSelect("Search results:", dataSource); list.setSizeFull(); list.setMultiSelect(true); list.setImmediate(true); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); Button addButton = new Button("Add"); addButton.setIcon(ICON_BUTTON_ADD_SELECTED); addButton.setDescription("Adds the selected person to the list."); addButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Set<User> values = (Set<User>) list.getValue(); if (selectHandler != null && values != null) { selectHandler.onPeopleSelected(values); list.removeAllItems(); searchField.setValue(""); //$NON-NLS-1$ searchField.focus(); } } }); buttons.addComponent(addButton); Button addAndCloseButton = new Button("Add & Close"); addAndCloseButton.setIcon(ICON_BUTTON_ADD_SELECTED); addAndCloseButton.setDescription("Adds the selected person to the list and closes the dialog."); addAndCloseButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Set<User> values = (Set<User>) list.getValue(); if (selectHandler != null && values != null) { selectHandler.onPeopleSelected(values); close(); } } }); buttons.addComponent(addAndCloseButton); root.addComponent(list); root.addComponent(buttons); root.setSizeFull(); root.setExpandRatio(list, 1); // root.setStyleName(STYLE_LAYOUT); setContent(root); searchField.focus(); }
From source file:org.eclipse.skalli.view.component.RadioSelect.java
License:Open Source License
private void renderEntries() { int row = 0;//from w w w .ja va 2s .c om radios = new ArrayList<Button>(entries.size()); for (Entry entry : entries) { Button b = new Button(); b.setIcon(row == selected ? SELECTED : UNSELECTED); b.setStyleName(Button.STYLE_LINK); b.addListener((Button.ClickListener) this); entriesGrid.addComponent(b, 0, row); radios.add(b); StringBuilder sb = new StringBuilder(); sb.append("<span style=\"font-weight:bold\">"); //$NON-NLS-1$ sb.append(StringEscapeUtils.escapeHtml(entry.getCaption())); sb.append("</span><br>"); //$NON-NLS-1$ sb.append("<span style=\"white-space:normal\">"); //$NON-NLS-1$ sb.append(HtmlUtils.clean(entry.getDescription())); sb.append("</span>"); //$NON-NLS-1$ CssLayout css = new CssLayout() { private static final long serialVersionUID = 7370808823922141846L; @Override protected String getCss(Component c) { return "margin-bottom:10px;margin-left:3px"; //$NON-NLS-1$ } }; css.setSizeFull(); Label comment = new Label(sb.toString(), Label.CONTENT_XHTML); css.addComponent(comment); entriesGrid.addComponent(css, 1, row); entriesGrid.setColumnExpandRatio(1, 1.0f); ++row; } }
From source file:org.eclipse.skalli.view.component.RadioSelect.java
License:Open Source License
@Override public void buttonClick(ClickEvent event) { radios.get(selected).setIcon(UNSELECTED); Button b = event.getButton(); if (UNSELECTED.equals(b.getIcon())) { for (int i = 0; i < radios.size(); ++i) { if (b.equals(radios.get(i))) { selected = i;//from w w w . j a v a 2s. c o m } } b.setIcon(SELECTED); } }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ReviewComponent.java
License:Open Source License
@SuppressWarnings({ "serial", "deprecation" }) private void paintReviewButton(HorizontalLayout hl, final ProjectRating rating) { Button btn = new Button(); if (util.getLoggedInUser() != null) { btn.addListener(new Button.ClickListener() { @Override// w w w .j av a2 s . c o m public void buttonClick(ClickEvent event) { reviewPopup = createReviewWindow(rating); getWindow().addWindow(reviewPopup); } }); btn.setDescription(getDescription(rating)); } else { btn.setEnabled(false); btn.setDescription("Login to rate this project."); } btn.setStyleName(Button.STYLE_LINK); btn.setIcon(getIcon(rating)); hl.addComponent(btn); }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ReviewComponent.java
License:Open Source License
@SuppressWarnings("serial") private Window createReviewWindow(final ProjectRating rating) { final Window subwindow = new Window("Rate and Review"); subwindow.setModal(true);/* w w w. j av a 2 s. co m*/ subwindow.setWidth("420px"); //$NON-NLS-1$ subwindow.setHeight("320px"); //$NON-NLS-1$ VerticalLayout vl = (VerticalLayout) subwindow.getContent(); vl.setSpacing(true); vl.setSizeFull(); HorizontalLayout hl = new HorizontalLayout(); hl.setSizeUndefined(); Embedded icon = new Embedded(null, getIcon(rating)); Label iconLabel = new Label("<b>" + HSPACE + getReviewComment(rating) + "</b>", Label.CONTENT_XHTML); //$NON-NLS-1$ //$NON-NLS-2$ String captionTextField = getReviewCommentQuestion(rating); hl.addComponent(icon); hl.addComponent(iconLabel); hl.setComponentAlignment(iconLabel, Alignment.MIDDLE_LEFT); vl.addComponent(hl); final TextField editor = new TextField(captionTextField); editor.setRows(3); editor.setColumns(30); editor.setImmediate(true); vl.addComponent(editor); final User user = util.getLoggedInUser(); final ArrayList<String> userSelects = new ArrayList<String>(2); userSelects.add("I want to vote as " + user.getDisplayName()); if (extension.getAllowAnonymous()) { userSelects.add("I want to vote as Anonymous!"); } final OptionGroup userSelect = new OptionGroup(null, userSelects); userSelect.setNullSelectionAllowed(false); userSelect.select(userSelects.get(0)); vl.addComponent(userSelect); CssLayout css = new CssLayout() { @Override protected String getCss(Component c) { return "margin-left:5px;margin-right:5px;margin-top:10px"; //$NON-NLS-1$ } }; Button okButton = new Button("OK"); okButton.setIcon(ICON_BUTTON_OK); okButton.setDescription("Commit changes"); okButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { String comment = (String) editor.getValue(); if (StringUtils.isBlank(comment)) { comment = "No Comment"; } ((Window) subwindow.getParent()).removeWindow(subwindow); String userName = "Anonymous"; if (userSelects.get(0).equals(userSelect.getValue())) { userName = user.getDisplayName(); } ReviewEntry review = new ReviewEntry(rating, comment, userName, System.currentTimeMillis()); extension.addReview(review); util.persist(project); reviews = extension.getReviews(); size = reviews.size(); currentPage = 0; lastPage = size / currentPageLength; paintReviewList(); } }); css.addComponent(okButton); Button cancelButton = new Button("Cancel"); cancelButton.setIcon(ICON_BUTTON_CANCEL); cancelButton.setDescription("Discard changes"); cancelButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { ((Window) subwindow.getParent()).removeWindow(subwindow); } }); css.addComponent(cancelButton); vl.addComponent(css); vl.setComponentAlignment(css, Alignment.MIDDLE_CENTER); return subwindow; }
From source file:org.eclipse.skalli.view.internal.window.NewProjectPanel.java
License:Open Source License
/** * Renders the OK/Cancel button bar./* w ww . j a va 2 s. co m*/ */ private void renderButtons(VerticalLayout content) { CssLayout buttons = new CssLayout(); buttons.addStyleName(STYLE_TEMPLATE_SELECT_BUTTONS); Button okButton = new Button("Create Project"); okButton.setIcon(ICON_BUTTON_OK); okButton.addListener(new OKButtonListener()); buttons.addComponent(okButton); Button cancelButton = new Button("Cancel"); cancelButton.setIcon(ICON_BUTTON_CANCEL); cancelButton.addListener(new CancelButtonListener()); buttons.addComponent(cancelButton); content.addComponent(buttons); content.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER); }
From source file:org.eclipse.skalli.view.internal.window.ProjectEditPanel.java
License:Open Source License
/** * Renders a OK/Cancel/Validate/Expand All/Collapse All button bar. *///w w w .j a v a 2 s . c om @SuppressWarnings("serial") private Button renderButtons(VerticalLayout layout, boolean header) { CssLayout buttons = new CssLayout(); buttons.addStyleName(STYLE_EDIT_PROJECT_BUTTONS); String prefix = header ? HEADER : FOOTER; Button okButton = new Button("OK"); okButton.setIcon(ICON_BUTTON_OK); okButton.setDescription("Save the modified project"); okButton.addStyleName(prefix + BUTTON_OK); okButton.addListener(new OKButtonListener()); buttons.addComponent(okButton); Button cancelButton = new Button("Cancel"); cancelButton.setIcon(ICON_BUTTON_CANCEL); cancelButton.setDescription("Discard all changes to the project"); cancelButton.addStyleName(prefix + BUTTON_CANCEL); cancelButton.addListener(new CancelButtonListener()); buttons.addComponent(cancelButton); Button checkButton = new Button("Check"); checkButton.setIcon(ICON_BUTTON_VALIDATE); checkButton.setDescription("Checks the modified project for issues without saving it"); checkButton.addStyleName(prefix + BUTTON_VALIDATE); checkButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { validateModifiedProject(); } }); buttons.addComponent(checkButton); Button expandAllButton = new Button("Expand All"); expandAllButton.setIcon(ICON_BUTTON_EXPAND_ALL); expandAllButton.setDescription("Expand all panels"); expandAllButton.addStyleName(prefix + BUTTON_EXPAND_ALL); expandAllButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { expandAllPanels(); } }); buttons.addComponent(expandAllButton); Button collapseAllButton = new Button("Collapse All"); collapseAllButton.setIcon(ICON_BUTTON_COLLAPSE_ALL); collapseAllButton.setDescription("Collapse all panels"); collapseAllButton.addStyleName(prefix + BUTTON_COLLAPSE_ALL); collapseAllButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { collapseAllPanels(); } }); buttons.addComponent(collapseAllButton); layout.addComponent(buttons); layout.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER); return checkButton; }
From source file:org.escidoc.browser.elabsmodul.views.helpers.LabsLayoutHelper.java
License:Open Source License
public static HorizontalLayout createButtonLayout() { final HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSpacing(true);/*w w w .jav a 2 s . com*/ final Button saveButton = new Button("Save"); saveButton.setIcon(ELabsViewContants.ICON_16_OK); final Label blank = new Label(""); blank.setWidth(LABEL_WIDTH); horizontalLayout.addComponent(blank, 0); horizontalLayout.addComponent(saveButton, 1); return horizontalLayout; }
From source file:org.escidoc.browser.layout.NavigationSimpleLayout.java
License:Open Source License
private CssLayout newHeaderButton(final TreeDataSource ds) { CssLayout cssLayout = new CssLayout(); cssLayout.setWidth("97%"); cssLayout.setMargin(false);/*from ww w . j av a 2 s .c o m*/ ThemeResource plusIcon = new ThemeResource("images/assets/plus.png"); final Button createGroupButton = new Button(); createGroupButton.setStyleName(BaseTheme.BUTTON_LINK); createGroupButton.addStyleName("floatright paddingtop3"); createGroupButton.setWidth("20px"); createGroupButton.setIcon(plusIcon); createGroupButton.addListener(new ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) { showCreateGroupView(); } private void showCreateGroupView() { router.getMainWindow().addWindow( new CreateGroupView(repositories.group(), router.getMainWindow(), ds).modalWindow()); } }); cssLayout.addComponent(createGroupButton); return cssLayout; }
From source file:org.escidoc.browser.ui.GroupRolesView.java
License:Open Source License
private Button buildAddGrantButton(final NativeSelect resourceSelect, final NativeSelect roleNameSelect) { Button assignGrantButton = new Button(); assignGrantButton.setIcon(new ThemeResource("images/assets/plus.png")); assignGrantButton.addListener(new Button.ClickListener() { @Override/* w w w .java 2s . c om*/ public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { try { if (getSelectedRole() == null) { router.getMainWindow().showNotification("Role can not be empty", "", Window.Notification.TYPE_WARNING_MESSAGE); return; } Grant grant = assignGrantInServer(); updateView(); showSuccessMessage(grant); } catch (EscidocClientException e) { router.getMainWindow().showNotification("Error Message", "Something wrong happens. Cause: " + e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } private void showSuccessMessage(Grant grant) { router.getMainWindow().showNotification("", "Sucessfully assign" + grant.getXLinkTitle() + " to " + groupId, Notification.TYPE_TRAY_NOTIFICATION); } private Grant assignGrantInServer() throws EscidocClientException { return repositories.group().assign(groupId).withRole(getSelectedRole()) .onResources(getSelectedResources()).execute(); } private RoleModel getSelectedRole() { final Object value = roleNameSelect.getValue(); if (value instanceof RoleModel) { return (RoleModel) value; } return null; } private Set<ResourceModel> getSelectedResources() { final Object value = resourceSelect.getValue(); if (value instanceof ResourceModel) { return Collections.singleton((ResourceModel) value); } return Collections.emptySet(); } private void updateView() throws EscidocClientException { listRolesForUser(rolesLayout); } }); return assignGrantButton; }