List of usage examples for com.vaadin.ui Label setWidth
@Override public void setWidth(float width, Unit unit)
From source file:de.kaiserpfalzEdv.vaadin.about.AboutViewImpl.java
License:Apache License
private void initializeLicense() { licenseLayout = createVerticalLayout("about.license.caption", "about.license.description", FontAwesome.FILE_TEXT);// w ww . j a v a 2 s.com Label text = new Label(licenseText, ContentMode.HTML); text.setWidth(100f, PERCENTAGE); Panel panel = new Panel(text); panel.setWidth(100f, PERCENTAGE); panel.setHeight(300f, PIXELS); licenseLayout.addComponent(panel); }
From source file:de.symeda.sormas.ui.caze.CaseController.java
License:Open Source License
public void openClassificationRulesPopup(CaseDataDto caze) { VerticalLayout classificationRulesLayout = new VerticalLayout(); classificationRulesLayout.setMargin(true); DiseaseClassificationCriteriaDto diseaseCriteria = FacadeProvider.getCaseClassificationFacade() .getByDisease(caze.getDisease()); if (diseaseCriteria != null) { Label suspectContent = new Label(); suspectContent.setContentMode(ContentMode.HTML); suspectContent.setWidth(100, Unit.PERCENTAGE); suspectContent.setValue(ClassificationHtmlRenderer.createSuspectHtmlString(diseaseCriteria)); classificationRulesLayout.addComponent(suspectContent); Label probableContent = new Label(); probableContent.setContentMode(ContentMode.HTML); probableContent.setWidth(100, Unit.PERCENTAGE); probableContent.setValue(ClassificationHtmlRenderer.createProbableHtmlString(diseaseCriteria)); classificationRulesLayout.addComponent(probableContent); Label confirmedContent = new Label(); confirmedContent.setContentMode(ContentMode.HTML); confirmedContent.setWidth(100, Unit.PERCENTAGE); confirmedContent.setValue(ClassificationHtmlRenderer.createConfirmedHtmlString(diseaseCriteria)); classificationRulesLayout.addComponent(confirmedContent); }/*from w w w . ja v a 2 s .c o m*/ Window popupWindow = VaadinUiUtil.showPopupWindow(classificationRulesLayout); popupWindow.addCloseListener(e -> { popupWindow.close(); }); popupWindow.setWidth(860, Unit.PIXELS); popupWindow.setHeight(80, Unit.PERCENTAGE); popupWindow.setCaption( I18nProperties.getString(Strings.classificationRulesFor) + " " + caze.getDisease().toString()); }
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 www .ja va 2 s. co 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.contact.ContactsView.java
License:Open Source License
public ContactsView() { super(VIEW_NAME); originalViewTitle = getViewTitleLabel().getValue(); criteria = ViewModelProviders.of(ContactsView.class).get(ContactCriteria.class); if (criteria.getArchived() == null) { criteria.archived(false);/* w w w.j av a 2 s .c o m*/ } grid = new ContactGrid(); 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.CONTACT_EXPORT)) { PopupButton exportButton = new PopupButton(I18nProperties.getCaption(Captions.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.setDescription(I18nProperties.getDescription(Descriptions.descExportButton)); basicExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); basicExportButton.setIcon(VaadinIcons.TABLE); basicExportButton.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(basicExportButton); StreamResource streamResource = new GridExportStreamResource(grid, "sormas_contacts", "sormas_contacts_" + DateHelper.formatDateForExport(new Date()) + ".csv"); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(basicExportButton); Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed)); extendedExportButton .setDescription(I18nProperties.getDescription(Descriptions.descDetailedExportButton)); extendedExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); extendedExportButton.setIcon(VaadinIcons.FILE_TEXT); extendedExportButton.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(extendedExportButton); StreamResource extendedExportStreamResource = DownloadUtil.createCsvExportStreamResource( ContactExportDto.class, (Integer start, Integer max) -> FacadeProvider.getContactFacade() .getExportList(UserProvider.getCurrent().getUuid(), grid.getCriteria(), start, max), (propertyId, type) -> { String caption = I18nProperties.getPrefixCaption(ContactExportDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption( HospitalizationDto.I18N_PREFIX, propertyId)))))); if (Date.class.isAssignableFrom(type)) { caption += " (" + DateHelper.getLocalShortDatePattern() + ")"; } return caption; }, "sormas_contacts_" + DateHelper.formatDateForExport(new Date()) + ".csv"); new FileDownloader(extendedExportStreamResource).extend(extendedExportButton); // Warning if no filters have been selected Label warningLabel = new Label(I18nProperties.getString(Strings.infoExportNoFilters)); warningLabel.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(warningLabel); warningLabel.setVisible(false); exportButton.addClickListener(e -> { warningLabel.setVisible(!criteria.hasAnyFilterActive()); }); } addComponent(gridLayout); }
From source file:de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsDiseaseElement.java
License:Open Source License
public DashboardStatisticsDiseaseElement(String caption, int count, int previousCount) { setMargin(false);/*from w ww . j av a 2s. co m*/ setSpacing(true); Label captionLabel = new Label(caption); captionLabel.setWidthUndefined(); CssStyles.style(captionLabel, CssStyles.LABEL_SECONDARY, CssStyles.LABEL_BOLD, CssStyles.LABEL_LARGE); addComponent(captionLabel); Label lineLabel = new Label(" ", ContentMode.HTML); CssStyles.style(lineLabel, CssStyles.LABEL_BOTTOM_LINE); addComponent(lineLabel); Label countLabel = new Label(Integer.toString(count)); countLabel.setWidthUndefined(); CssStyles.style(countLabel, CssStyles.LABEL_SECONDARY, CssStyles.LABEL_BOLD, CssStyles.LABEL_LARGE); addComponent(countLabel); Label growthLabel = new Label(); growthLabel.setContentMode(ContentMode.HTML); growthLabel.setWidth(15, Unit.PIXELS); CssStyles.removeStyles(growthLabel, CssStyles.LABEL_CRITICAL, CssStyles.LABEL_POSITIVE, CssStyles.LABEL_IMPORTANT); if (count > previousCount) { growthLabel.setValue(VaadinIcons.CHEVRON_UP.getHtml()); CssStyles.style(growthLabel, CssStyles.LABEL_CRITICAL); } else if (count == previousCount) { growthLabel.setValue(VaadinIcons.CHEVRON_RIGHT.getHtml()); CssStyles.style(growthLabel, CssStyles.LABEL_IMPORTANT, CssStyles.ALIGN_CENTER); } else { growthLabel.setValue(VaadinIcons.CHEVRON_DOWN.getHtml()); CssStyles.style(growthLabel, CssStyles.LABEL_POSITIVE); } CssStyles.style(growthLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_LARGE); addComponent(growthLabel); setExpandRatio(lineLabel, 1); }
From source file:de.symeda.sormas.ui.login.LoginScreen.java
License:Open Source License
private CssLayout buildLoginInformation() { CssLayout loginInformation = new CssLayout(); loginInformation.setStyleName("login-information"); VerticalLayout innerLayout = new VerticalLayout(); innerLayout.setSizeFull();//from w w w .j a v a 2 s. co m Image img = new Image(null, new ThemeResource("img/sormas-logo-big.png")); img.setHeight(240, Unit.PIXELS); innerLayout.addComponent(img); innerLayout.setComponentAlignment(img, Alignment.TOP_CENTER); innerLayout.setExpandRatio(img, 0); Label loginInfoText = new Label("<h1>SORMAS</h1>" + "<h2 style='color:white'>Surveillance, Outbreak Response Management and Analysis System</h2>" + "<h3 style='color:white; text-transform:uppercase'>● Disease Prevention<br>● Disease Detection<br>● Outbreak Response</h3>", ContentMode.HTML); loginInfoText.setWidth(100, Unit.PERCENTAGE); innerLayout.addComponent(loginInfoText); innerLayout.setExpandRatio(loginInfoText, 1); Label loginInfoCopyright = new Label(" 2019 SORMAS. All Rights Reserved."); loginInfoCopyright.setWidth(100, Unit.PERCENTAGE); innerLayout.addComponent(loginInfoCopyright); innerLayout.setExpandRatio(loginInfoCopyright, 0); innerLayout.setComponentAlignment(loginInfoCopyright, Alignment.BOTTOM_LEFT); loginInformation.addComponent(innerLayout); return loginInformation; }
From source file:de.symeda.sormas.ui.samples.SampleController.java
License:Open Source License
private void requestSampleCollectionTaskCreation(SampleDto dto, SampleEditForm form) { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);/* ww w .j av a 2 s . c om*/ ConfirmationComponent requestTaskComponent = VaadinUiUtil.buildYesNoConfirmationComponent(); Label description = new Label(I18nProperties.getString(Strings.messageCreateCollectionTask), ContentMode.HTML); description.setWidth(100, Unit.PERCENTAGE); layout.addComponent(description); layout.addComponent(requestTaskComponent); layout.setComponentAlignment(requestTaskComponent, Alignment.BOTTOM_RIGHT); layout.setSizeUndefined(); layout.setSpacing(true); Window popupWindow = VaadinUiUtil.showPopupWindow(layout); popupWindow.setSizeUndefined(); popupWindow.setCaption(I18nProperties.getString(Strings.headingCreateNewTaskQuestion)); requestTaskComponent.getConfirmButton().addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { popupWindow.close(); ControllerProvider.getTaskController().createSampleCollectionTask(TaskContext.CASE, dto.getAssociatedCase(), dto); } }); requestTaskComponent.getCancelButton().addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { popupWindow.close(); } }); }
From source file:de.symeda.sormas.ui.samples.SampleController.java
License:Open Source License
public void showChangePathogenTestResultWindow(CommitDiscardWrapperComponent<SampleEditForm> editComponent, String sampleUuid, PathogenTestResultType newResult) { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);//w w w . j av a 2s. c om ConfirmationComponent confirmationComponent = VaadinUiUtil.buildYesNoConfirmationComponent(); Label description = new Label(String .format(I18nProperties.getString(Strings.messageChangePathogenTestResult), newResult.toString())); description.setWidth(100, Unit.PERCENTAGE); layout.addComponent(description); layout.addComponent(confirmationComponent); layout.setComponentAlignment(confirmationComponent, Alignment.BOTTOM_RIGHT); layout.setSizeUndefined(); layout.setSpacing(true); Window popupWindow = VaadinUiUtil.showPopupWindow(layout); popupWindow.setSizeUndefined(); popupWindow.setCaption(I18nProperties.getString(Strings.headingChangePathogenTestResult)); confirmationComponent.getConfirmButton().addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { editComponent.commit(); SampleDto sample = FacadeProvider.getSampleFacade().getSampleByUuid(sampleUuid); sample.setPathogenTestResult(newResult); FacadeProvider.getSampleFacade().saveSample(sample); popupWindow.close(); SormasUI.refreshView(); } }); confirmationComponent.getCancelButton().addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { popupWindow.close(); } }); }
From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java
License:Open Source License
public static Window showSimplePopupWindow(String caption, String contentText) { Window window = new Window(null); window.setModal(true);/* w w w. j a v a2 s .co m*/ window.setSizeUndefined(); window.setResizable(false); window.center(); VerticalLayout popupLayout = new VerticalLayout(); popupLayout.setMargin(true); popupLayout.setSpacing(true); popupLayout.setSizeUndefined(); Label contentLabel = new Label(contentText); contentLabel.setWidth(100, Unit.PERCENTAGE); popupLayout.addComponent(contentLabel); Button okayButton = new Button(I18nProperties.getCaption(Captions.actionOkay)); okayButton.addClickListener(e -> { window.close(); }); CssStyles.style(okayButton, ValoTheme.BUTTON_PRIMARY); popupLayout.addComponent(okayButton); popupLayout.setComponentAlignment(okayButton, Alignment.BOTTOM_RIGHT); window.setCaption(caption); window.setContent(popupLayout); UI.getCurrent().addWindow(window); return window; }
From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java
License:Open Source License
public static Window showDeleteConfirmationWindow(String content, Runnable callback) { Window popupWindow = VaadinUiUtil.createPopupWindow(); VerticalLayout deleteLayout = new VerticalLayout(); deleteLayout.setMargin(true);//from w w w.ja v a2 s. co m deleteLayout.setSizeUndefined(); deleteLayout.setSpacing(true); Label description = new Label(content); description.setWidth(100, Unit.PERCENTAGE); deleteLayout.addComponent(description); ConfirmationComponent deleteConfirmationComponent = new ConfirmationComponent(false) { private static final long serialVersionUID = 1L; @Override protected void onConfirm() { popupWindow.close(); onDone(); callback.run(); } @Override protected void onCancel() { popupWindow.close(); } }; deleteConfirmationComponent.getConfirmButton().setCaption(I18nProperties.getString(Strings.yes)); deleteConfirmationComponent.getCancelButton().setCaption(I18nProperties.getString(Strings.no)); deleteLayout.addComponent(deleteConfirmationComponent); deleteLayout.setComponentAlignment(deleteConfirmationComponent, Alignment.BOTTOM_RIGHT); popupWindow.setCaption(I18nProperties.getString(Strings.headingConfirmDeletion)); popupWindow.setContent(deleteLayout); UI.getCurrent().addWindow(popupWindow); return popupWindow; }