List of usage examples for com.vaadin.ui Button setIcon
@Override public void setIcon(Resource icon)
From source file:de.kaiserpfalzEdv.vaadin.ui.defaultviews.editor.impl.BaseEditorViewImpl.java
License:Apache License
private Button initializeButton(final String buttonKey, int tabIndex) { Button result = new Button(presenter.translate("button." + buttonKey + ".caption")); result.setDescription(presenter.translate("button." + buttonKey + ".description")); result.setIcon(FontAwesome.valueOf(presenter.translate("button." + buttonKey + ".icon"))); result.setWidth(100f, PERCENTAGE);// w ww . ja v a 2 s.c o m result.setTabIndex(tabIndex); return result; }
From source file:de.kaiserpfalzEdv.vaadin.ui.menu.impl.MenuImpl.java
License:Apache License
private void createViewButton(final String name, String i18nKey, int index) { Resource icon = FontAwesome.valueOf(translate(i18nKey + ".icon")); Button button = new Button(translate(i18nKey + ".caption"), event -> { LOG.trace("Menu click: {}", name); bus.post(new NavigateToEvent(this, name)); });//from ww w . j av a 2 s .c o m button.setDescription(translate(i18nKey + ".description")); button.setPrimaryStyleName(ValoTheme.MENU_ITEM); button.setIcon(icon); viewButtons.put(index, button); LOG.debug("Created menu entry: {}", i18nKey); }
From source file:de.mendelson.comm.as2.webclient2.AS2WebUI.java
private HorizontalLayout createButtonBar() { HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSizeFull();// w w w. j a v a 2 s . com Button buttonRefresh = new Button("Refresh"); buttonRefresh.setIcon(new ThemeResource("images/refresh16x16.gif")); buttonRefresh.setEnabled(true); buttonRefresh.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { AS2WebUI.this.refreshOverviewTableData(); } }); buttonLayout.addComponent(buttonRefresh); this.buttonDetails = new Button("Message details"); this.buttonDetails.setIcon(new ThemeResource("images/messagedetails16x16.gif")); this.buttonDetails.setEnabled(false); this.buttonDetails.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { AS2WebUI.this.displayMessageDetailsOfSelectedRow(); } }); buttonLayout.addComponent(this.buttonDetails); this.labelUsername.setWidth(null); buttonLayout.addComponent(this.labelUsername); buttonLayout.setComponentAlignment(this.labelUsername, Alignment.MIDDLE_RIGHT); buttonLayout.setExpandRatio(buttonRefresh, 0.0f); buttonLayout.setExpandRatio(this.buttonDetails, 0.0f); buttonLayout.setExpandRatio(this.labelUsername, 1.0f); return (buttonLayout); }
From source file:de.metas.procurement.webui.ui.view.DailyReportingView.java
License:Open Source License
public DailyReportingView() { super();/*from w w w . j av a 2s .c om*/ addStyleName(STYLE); // // Top { final NavigationBar navigationBar = getNavigationBar(); navigationBar.setCaption(i18n.get("DailyReportingView.caption")); final NavigationButton logoutButton = new NavigationButton(i18n.get("Logout.caption")); logoutButton.setTargetView(this); logoutButton.addClickListener(new NavigationButtonClickListener() { @Override public void buttonClick(final NavigationButtonClickEvent event) { onLogout(); } }); navigationBar.setRightComponent(logoutButton); } // // Content { final VerticalLayout content = new VerticalLayout(); // Date { datePanel = new DateNavigation(); datePanel.addDateChangedListener(new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent evt) { onDayChanged(datePanel.getDate()); } }); final VerticalComponentGroup datePanelGroup = new VerticalComponentGroup(); datePanelGroup.addComponent(datePanel); content.addComponent(datePanelGroup); } // Product buttons productButtons = new BeansVerticalComponentGroup<ProductQtyReport>() { @Override protected Component createItemComponent(final BeanItem<ProductQtyReport> item) { final ProductItemButton itemComp = new ProductItemButton(); itemComp.setItem(item); return itemComp; }; }; content.addComponent(productButtons); setContent(content); } // // Toolbar (bottom) { final Button weekViewButton = new Button(i18n.get("DailyReportingView.weekViewButton")); weekViewButton.setStyleName("no-decoration"); weekViewButton.setIcon(FontAwesome.CALENDAR); weekViewButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onWeekView(); } }); final Button addProductButton = new Button(i18n.get("DailyReportingView.addProductButton")); addProductButton.setStyleName("no-decoration"); addProductButton.setIcon(FontAwesome.PLUS); addProductButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onProductAdd(); } }); final Button rfqButton = new Button(i18n.get("DailyReportingView.rfqButton")); rfqButton.setStyleName("no-decoration"); rfqButton.setIcon(FontAwesome.MONEY); rfqButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onRfQ(); } }); final ISendService sendService = MFProcurementUI.getCurrentMFSession().getSendService(); final Button sendButton = new Button(i18n.get("DailyReportingView.sendButton")); sendButton.setStyleName("no-decoration"); sendButton.setIcon(FontAwesome.CHECK); final TextOverlay sendButtonOverlay = TextOverlay.extend(sendButton); sendButtonOverlay.setPropertyDataSource(sendService.getNotSentCounterProperty()); sendButtonOverlay.setConverter(TextOverlay.CONVERTER_PositiveCounterOrNull); sendButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onSend(); } }); final Button infoButton = new Button(i18n.getWithDefault("InfoMessageView.caption.short", "Info")); infoButton.setStyleName("no-decoration"); infoButton.setIcon(FontAwesome.INFO); infoButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onInfo(); } }); final Toolbar toolbar = new Toolbar(); toolbar.addComponents(weekViewButton, addProductButton, sendButton, infoButton, rfqButton); setToolbar(toolbar); } // // Initialize final Date today = DateUtils.getToday(); final Date date = DateUtils.addDays(today, +1); // tomorrow (FRESH-196) datePanel.setDate(date); }
From source file:de.metas.procurement.webui.ui.view.WeeklyDetailedReportingView.java
License:Open Source License
private final Button createTrendButton(final Trend trend) { final Button button = new Button(); button.setStyleName("no-decoration"); Trend.applyStyleName(button, trend); button.setIcon(trend.getIcon()); button.addClickListener(new ClickListener() { @Override// www .jav a 2 s .co m public void buttonClick(final ClickEvent event) { onNextWeekTrendButtonPressed(trend); } }); trend2button.put(trend, button); return button; }
From source file:de.metas.ui.web.vaadin.components.navigator.MFViewDisplay.java
License:Open Source License
public MFViewDisplay(final UI ui) { super();//from w w w .java2s.c o m final VerticalLayout content = new VerticalLayout(); content.addStyleName(STYLE); // // Lane: title { final Button icon = new Button(); icon.setPrimaryStyleName(STYLE + "-title-icon"); icon.setIcon(FontAwesome.BARS); icon.addClickListener(event -> toggleMenuPanel()); titleLabel = new Label(); titleLabel.setPrimaryStyleName(STYLE + "-title-text"); final HorizontalLayout panel = new HorizontalLayout(icon, titleLabel); panel.addStyleName(STYLE + "-title-lane"); content.addComponent(panel); } // // Lane: menu { menuPanel = new MenuPanel(); menuPanel.setHiddenByStyle(false); content.addComponent(menuPanel); } viewContainer = new ViewContainer(); content.addComponent(viewContainer); setCompositionRoot(content); ui.setContent(this); }
From source file:de.metas.ui.web.vaadin.window.view.WindowViewImpl.java
License:Open Source License
@Override public void setActions(final ActionsList actions) { if (Objects.equals(this._actions, actions)) { return;// w w w .jav a 2s .c om } this._actions = ActionsList.copyOf(actions); // // Toolbar actions actionsPanel.removeAllComponents(); for (final Action action : _actions) { if (!action.isToolbarAction()) { continue; } final String actionId = action.getActionId(); final Button btn = new Button(); btn.setCaption(action.getCaption()); btn.setIcon(Theme.getVaadinResource(action.getIcon())); btn.addClickListener(event -> getWindowViewListener().onActionClicked(actionId)); actionsPanel.addComponent(btn); } }
From source file:de.steinwedel.messagebox.MessageBox.java
License:Apache License
/** * Adds a button./*w w w . java 2 s . c o m*/ * * @param buttonType A {@link ButtonType} * @param runOnClick The Runnable, that is executed on clicking the button * @param options Some optional {@link ButtonOption}s * @return The {@link MessageBox} instance */ public MessageBox withButton(ButtonType buttonType, Runnable runOnClick, ButtonOption... options) { Button button = new Button(BUTTON_DEFAULT_CAPTION_FACTORY.translate(buttonType, DIALOG_DEFAULT_LOCALE)); buttons.put(buttonType, button); button.setData(runOnClick); if (buttonType != null) { button.addStyleName(buttonType.name().toLowerCase() + "Icon"); } button.addStyleName("messageBoxIcon"); if (BUTTON_DEFAULT_ICONS_VISIBLE) { button.setIcon(BUTTON_DEFAULT_ICON_FACTORY.getIcon(buttonType)); } return withButton(button, options); }
From source file:de.symeda.sormas.ui.caze.CaseContactsView.java
License:Open Source License
public HorizontalLayout createStatusFilterBar() { HorizontalLayout statusFilterLayout = new HorizontalLayout(); statusFilterLayout.setSpacing(true); statusFilterLayout.setWidth("100%"); statusFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> { criteria.contactStatus(null);//from w ww. j a va 2 s. c om navigateTo(criteria); }); CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER); statusAll.setCaptionAsHtml(true); statusFilterLayout.addComponent(statusAll); statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all)); activeStatusButton = statusAll; for (ContactStatus status : ContactStatus.values()) { Button statusButton = new Button(status.toString(), e -> { criteria.contactStatus(status); navigateTo(criteria); }); statusButton.setData(status); CssStyles.style(statusButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT); statusButton.setCaptionAsHtml(true); statusFilterLayout.addComponent(statusButton); statusButtons.put(statusButton, status.toString()); } statusFilterLayout .setExpandRatio(statusFilterLayout.getComponent(statusFilterLayout.getComponentCount() - 1), 1); // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { statusFilterLayout.setWidth(100, Unit.PERCENTAGE); MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command changeCommand = selectedItem -> { ControllerProvider.getContactController().showBulkContactDataEditComponent( grid.asMultiSelect().getSelectedItems(), getCaseRef().getUuid()); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, changeCommand); Command cancelFollowUpCommand = selectedItem -> { ControllerProvider.getContactController() .cancelFollowUpOfAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp), VaadinIcons.CLOSE, cancelFollowUpCommand); Command lostToFollowUpCommand = selectedItem -> { ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp( grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp), VaadinIcons.UNLINK, lostToFollowUpCommand); Command deleteCommand = selectedItem -> { ControllerProvider.getContactController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); statusFilterLayout.addComponent(bulkOperationsDropdown); statusFilterLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT); statusFilterLayout.setExpandRatio(bulkOperationsDropdown, 1); } if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_EXPORT)) { Button exportButton = new Button(I18nProperties.getCaption(Captions.export)); exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); exportButton.setIcon(VaadinIcons.DOWNLOAD); StreamResource streamResource = new GridExportStreamResource(grid, "sormas_contacts", "sormas_contacts_" + DateHelper.formatDateForExport(new Date()) + ".csv"); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(exportButton); statusFilterLayout.addComponent(exportButton); statusFilterLayout.setComponentAlignment(exportButton, Alignment.MIDDLE_RIGHT); if (!UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { statusFilterLayout.setExpandRatio(exportButton, 1); } } if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_CREATE)) { newButton = new Button( I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, Captions.contactNewContact)); newButton.addStyleName(ValoTheme.BUTTON_PRIMARY); newButton.setIcon(VaadinIcons.PLUS_CIRCLE); newButton.addClickListener(e -> ControllerProvider.getContactController().create(this.getCaseRef())); statusFilterLayout.addComponent(newButton); statusFilterLayout.setComponentAlignment(newButton, Alignment.MIDDLE_RIGHT); } statusFilterLayout.addStyleName("top-bar"); activeStatusButton = statusAll; return statusFilterLayout; }
From source file:de.symeda.sormas.ui.caze.CasesView.java
License:Open Source License
public CasesView() { super(VIEW_NAME); originalViewTitle = getViewTitleLabel().getValue(); criteria = ViewModelProviders.of(CasesView.class).get(CaseCriteria.class); if (criteria.getArchived() == null) { criteria.archived(false);//from w w w .jav a 2s .c o m } grid = new CaseGrid(); grid.setCriteria(criteria); gridLayout = new VerticalLayout(); gridLayout.addComponent(createFilterBar()); gridLayout.addComponent(createStatusFilterBar()); gridLayout.addComponent(grid); gridLayout.setMargin(true); gridLayout.setSpacing(false); gridLayout.setSizeFull(); gridLayout.setExpandRatio(grid, 1); gridLayout.setStyleName("crud-main-layout"); grid.getDataProvider().addDataProviderListener(e -> updateStatusButtons()); if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_IMPORT)) { Button importButton = new Button(I18nProperties.getCaption(Captions.actionImport)); importButton.addStyleName(ValoTheme.BUTTON_PRIMARY); importButton.setIcon(VaadinIcons.UPLOAD); importButton.addClickListener(e -> { Window popupWindow = VaadinUiUtil.showPopupWindow(new CaseImportLayout()); popupWindow.setCaption(I18nProperties.getString(Strings.headingImportCases)); popupWindow.addCloseListener(c -> { grid.reload(); }); }); addHeaderComponent(importButton); } if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_EXPORT)) { PopupButton exportButton = new PopupButton(I18nProperties.getCaption(Captions.export)); exportButton.setId("export"); exportButton.setIcon(VaadinIcons.DOWNLOAD); VerticalLayout exportLayout = new VerticalLayout(); exportLayout.setSpacing(true); exportLayout.setMargin(true); exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL); exportLayout.setWidth(200, Unit.PIXELS); exportButton.setContent(exportLayout); addHeaderComponent(exportButton); Button basicExportButton = new Button(I18nProperties.getCaption(Captions.exportBasic)); basicExportButton.setId("basicExport"); basicExportButton.setDescription(I18nProperties.getString(Strings.infoBasicExport)); basicExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); basicExportButton.setIcon(VaadinIcons.TABLE); basicExportButton.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(basicExportButton); StreamResource streamResource = new GridExportStreamResource(grid, "sormas_cases", "sormas_cases_" + DateHelper.formatDateForExport(new Date()) + ".csv"); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(basicExportButton); Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed)); extendedExportButton.setId("extendedExport"); extendedExportButton.setDescription(I18nProperties.getString(Strings.infoDetailedExport)); extendedExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); extendedExportButton.setIcon(VaadinIcons.FILE_TEXT); extendedExportButton.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(extendedExportButton); StreamResource extendedExportStreamResource = DownloadUtil.createCsvExportStreamResource( CaseExportDto.class, (Integer start, Integer max) -> FacadeProvider.getCaseFacade() .getExportList(UserProvider.getCurrent().getUuid(), grid.getCriteria(), start, max), (propertyId, type) -> { String caption = I18nProperties.getPrefixCaption(CaseExportDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(EpiDataDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption( HospitalizationDto.I18N_PREFIX, propertyId)))))); if (Date.class.isAssignableFrom(type)) { caption += " (" + DateHelper.getLocalShortDatePattern() + ")"; } return caption; }, "sormas_cases_" + DateHelper.formatDateForExport(new Date()) + ".csv"); new FileDownloader(extendedExportStreamResource).extend(extendedExportButton); Button sampleExportButton = new Button(I18nProperties.getCaption(Captions.exportSamples)); sampleExportButton.setId("sampleExport"); sampleExportButton.setDescription(I18nProperties.getString(Strings.infoSampleExport)); sampleExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); sampleExportButton.setIcon(VaadinIcons.FILE_TEXT); sampleExportButton.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(sampleExportButton); StreamResource sampleExportStreamResource = DownloadUtil.createCsvExportStreamResource( SampleExportDto.class, (Integer start, Integer max) -> FacadeProvider.getSampleFacade() .getExportList(UserProvider.getCurrent().getUuid(), grid.getCriteria(), start, max), (propertyId, type) -> { String caption = I18nProperties.getPrefixCaption(SampleExportDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption( AdditionalTestDto.I18N_PREFIX, propertyId))))); if (Date.class.isAssignableFrom(type)) { caption += " (" + DateHelper.getLocalShortDatePattern() + ")"; } return caption; }, "sormas_samples_" + DateHelper.formatDateForExport(new Date()) + ".csv"); new FileDownloader(sampleExportStreamResource).extend(sampleExportButton); // Warning if no filters have been selected Label warningLabel = new Label(I18nProperties.getString(Strings.infoExportNoFilters), ContentMode.HTML); warningLabel.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(warningLabel); warningLabel.setVisible(false); exportButton.addClickListener(e -> { warningLabel.setVisible(!criteria.hasAnyFilterActive()); }); } if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_MERGE)) { Button mergeDuplicatesButton = new Button(I18nProperties.getCaption(Captions.caseMergeDuplicates)); mergeDuplicatesButton.setId("mergeDuplicates"); mergeDuplicatesButton.setIcon(VaadinIcons.COMPRESS_SQUARE); mergeDuplicatesButton .addClickListener(e -> ControllerProvider.getCaseController().navigateToMergeCasesView()); addHeaderComponent(mergeDuplicatesButton); } if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_CREATE)) { createButton = new Button(I18nProperties.getCaption(Captions.caseNewCase)); createButton.setId("create"); createButton.addStyleName(ValoTheme.BUTTON_PRIMARY); createButton.setIcon(VaadinIcons.PLUS_CIRCLE); createButton.addClickListener(e -> ControllerProvider.getCaseController().create()); addHeaderComponent(createButton); } addComponent(gridLayout); }