List of usage examples for com.vaadin.ui Button setDescription
public void setDescription(String description)
From source file:com.trivago.mail.pigeon.web.components.recipients.ActionButtonColumnGenerator.java
License:Apache License
@Override public Object generateCell(final Table source, final Object itemId, final Object columnId) { HorizontalLayout hl = new HorizontalLayout(); Button deleteButton = new Button(); deleteButton.setImmediate(true);/*from w ww . j a v a2s . co m*/ deleteButton.setIcon(new ThemeResource("../runo/icons/16/trash.png")); deleteButton.setDescription("Delete recipient"); deleteButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Transaction tx = ConnectionFactory.getDatabase().beginTx(); try { Recipient s = new Recipient((Long) itemId); ConnectionFactory.getUserIndex().remove(s.getDataNode()); for (Relationship r : s.getDataNode().getRelationships()) { r.delete(); } s.getDataNode().delete(); source.removeItem(itemId); source.getWindow().showNotification("Successfully deleted."); tx.success(); } catch (Exception e) { log.error("Error while deleting entry", e); source.getWindow().showNotification("Error while deleting entry: " + e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); tx.failure(); } finally { tx.finish(); } } }); hl.addComponent(deleteButton); return hl; }
From source file:com.trivago.mail.pigeon.web.components.sender.ActionButtonColumnGenerator.java
License:Apache License
@Override public Object generateCell(final Table source, final Object itemId, final Object columnId) { HorizontalLayout hl = new HorizontalLayout(); Button deleteButton = new Button(); deleteButton.setImmediate(true);//from w w w . j a v a2s . c o m deleteButton.setIcon(new ThemeResource("../runo/icons/16/trash.png")); deleteButton.setDescription("Delete sender"); deleteButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Transaction tx = ConnectionFactory.getDatabase().beginTx(); try { Sender s = new Sender((Long) itemId); ConnectionFactory.getSenderIndex().remove(s.getDataNode()); for (Relationship r : s.getDataNode().getRelationships()) { r.delete(); } s.getDataNode().delete(); source.removeItem(itemId); source.getWindow().showNotification("Successfully deleted."); tx.success(); } catch (Exception e) { source.getWindow().showNotification("Error while deleting entry: " + e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); log.error(e); tx.failure(); } finally { tx.finish(); } } }); hl.addComponent(deleteButton); return hl; }
From source file:com.trivago.mail.pigeon.web.components.templates.ActionButtonColumnGenerator.java
License:Apache License
@Override public Object generateCell(final Table source, final Object itemId, final Object columnId) { HorizontalLayout hl = new HorizontalLayout(); Button deleteButton = new Button(); deleteButton.setImmediate(true);/*from ww w .j a v a 2s . c om*/ deleteButton.setIcon(new ThemeResource("../runo/icons/16/trash.png")); deleteButton.setDescription("Delete template"); deleteButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Transaction tx = ConnectionFactory.getDatabase().beginTx(); try { MailTemplate mt = new MailTemplate((Long) itemId); ConnectionFactory.getNewsletterIndex().remove(mt.getDataNode()); for (Relationship r : mt.getDataNode().getRelationships()) { r.delete(); } mt.getDataNode().delete(); source.removeItem(itemId); source.getWindow().showNotification("Successfully deleted."); tx.success(); } catch (Exception e) { source.getWindow().showNotification("Error while deleting entry: " + e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); log.error(e); tx.failure(); } finally { tx.finish(); } } }); Button editButton = new Button(); editButton.setImmediate(true); editButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png")); editButton.setDescription("Edit template"); editButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Window modalNewWindow = new ModalAddTemplate( (TemplateList) source.getParent().getParent().getParent(), (Long) itemId); event.getButton().getWindow().addWindow(modalNewWindow); modalNewWindow.setVisible(true); } }); hl.addComponent(editButton); hl.addComponent(deleteButton); return hl; }
From source file:com.vphakala.Toolbar.java
public Toolbar(String windowName, Button read, Button create, Button update, Button delete) { setSpacing(true);/* ww w.j av a 2 s.co m*/ create.setIcon(FontAwesome.USER_PLUS); create.setDescription("Create a new " + windowName + "."); read.setIcon(FontAwesome.USER); read.setDescription("Read the " + windowName + ". Insert NAME."); update.setIcon(FontAwesome.SAVE); update.setDescription("Store the " + windowName + " data."); delete.setIcon(FontAwesome.TRASH); delete.setDescription("Remove the " + windowName); addComponents(read, create, update, delete); }
From source file:de.kaiserpfalzEdv.infopir.ui.register.editor.RegisterEditorViewImpl.java
License:Apache License
private Button createButton(final String i18nBase, final int tabIndex) { Button result = new Button(i18n.get(i18nBase + ".caption"), FontAwesome.valueOf(i18n.get(i18nBase + ".icon"))); result.setSizeFull();//ww w . j a v a2s .c om result.setDescription(i18n.get(i18nBase + ".description")); result.setTabIndex(tabIndex); buttonLayout.addComponent(result); return result; }
From source file:de.kaiserpfalzEdv.vaadin.LoginScreen.java
License:Apache License
private Component buildLoginForm() { FormLayout loginForm = new FormLayout(); loginForm.addStyleName("login-form"); loginForm.setSizeUndefined();//w w w . jav a2 s. c om loginForm.setMargin(false); loginForm.addComponent(username = new TextField(translate("login.name.caption"))); username.setDescription(translate("login.name.description")); username.setWidth(15, Unit.EM); loginForm.addComponent(password = new PasswordField(translate("login.password.caption"))); password.setWidth(15, Unit.EM); password.setDescription(translate("login.password.description")); CssLayout buttons = new CssLayout(); buttons.setStyleName("buttons"); loginForm.addComponent(buttons); login = new Button(translate("login.login-button.caption")); buttons.addComponent(login); login.setDescription(translate("login.login-button.description")); login.setDisableOnClick(true); login.addClickListener(event -> { try { login(); } finally { login.setEnabled(true); } }); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addStyleName(ValoTheme.BUTTON_FRIENDLY); Button forgotPassword; buttons.addComponent(forgotPassword = new Button(translate("login.password-forgotten.caption"))); forgotPassword.setDescription(translate("login.password-forgotten.description")); forgotPassword.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { NotificationPayload notification = new NotificationPayload("login.password-forgotten.text"); bus.post(new NotificationEvent(this, notification)); } }); forgotPassword.addStyleName(ValoTheme.BUTTON_LINK); return loginForm; }
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);/*from w w w. ja v a2s . co 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 w w w .j a va2 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.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.j ava2 s .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); }
From source file:de.symeda.sormas.ui.configuration.infrastructure.CommunitiesView.java
License:Open Source License
public CommunitiesView() { super(VIEW_NAME); criteria = ViewModelProviders.of(CommunitiesView.class).get(CommunityCriteria.class); grid = new CommunitiesGrid(); grid.setCriteria(criteria);/*from w ww. j a va 2 s . co m*/ gridLayout = new VerticalLayout(); gridLayout.addComponent(createFilterBar()); gridLayout.addComponent(grid); gridLayout.setMargin(true); gridLayout.setSpacing(false); gridLayout.setExpandRatio(grid, 1); gridLayout.setSizeFull(); gridLayout.setStyleName("crud-main-layout"); if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_EXPORT)) { Button exportButton = new Button(I18nProperties.getCaption(Captions.export)); exportButton.setDescription(I18nProperties.getDescription(Descriptions.descExportButton)); exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); exportButton.setIcon(VaadinIcons.TABLE); addHeaderComponent(exportButton); StreamResource streamResource = new GridExportStreamResource(grid, "sormas_communities", "sormas_communities_" + DateHelper.formatDateForExport(new Date()) + ".csv", CommunitiesGrid.EDIT_BTN_ID); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(exportButton); } if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_CREATE)) { createButton = new Button(I18nProperties.getCaption(Captions.actionNewEntry)); createButton.addStyleName(ValoTheme.BUTTON_PRIMARY); createButton.setIcon(VaadinIcons.PLUS_CIRCLE); createButton.addClickListener(e -> ControllerProvider.getInfrastructureController().createCommunity()); addHeaderComponent(createButton); } addComponent(gridLayout); }