List of usage examples for com.vaadin.ui VerticalLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:de.symeda.sormas.ui.samples.SampleListEntry.java
License:Open Source License
public SampleListEntry(SampleIndexDto sample) { this.sample = sample; setMargin(false);//from w w w . j a v a 2 s . co m setSpacing(true); setWidth(100, Unit.PERCENTAGE); addStyleName(CssStyles.SORMAS_LIST_ENTRY); VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setWidth(100, Unit.PERCENTAGE); mainLayout.setMargin(false); mainLayout.setSpacing(false); addComponent(mainLayout); setExpandRatio(mainLayout, 1); HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setWidth(100, Unit.PERCENTAGE); topLayout.setMargin(false); topLayout.setSpacing(false); mainLayout.addComponent(topLayout); VerticalLayout topLeftLayout = new VerticalLayout(); { topLeftLayout.setMargin(false); topLeftLayout.setSpacing(false); Label materialLabel = new Label(DataHelper.toStringNullable(sample.getSampleMaterial())); CssStyles.style(materialLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE); topLeftLayout.addComponent(materialLabel); Label dateTimeLabel = new Label( I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, SampleDto.SAMPLE_DATE_TIME) + ": " + DateHelper.formatLocalShortDate(sample.getSampleDateTime())); topLeftLayout.addComponent(dateTimeLabel); Label labLabel = new Label(DataHelper.toStringNullable(sample.getLab())); topLeftLayout.addComponent(labLabel); } topLayout.addComponent(topLeftLayout); VerticalLayout topRightLayout = new VerticalLayout(); { topRightLayout.addStyleName(CssStyles.ALIGN_RIGHT); topRightLayout.setMargin(false); topRightLayout.setSpacing(false); Label resultLabel = new Label(); CssStyles.style(resultLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE); if (sample.getPathogenTestResult() != null) { resultLabel.setValue(DataHelper.toStringNullable(sample.getPathogenTestResult())); if (sample.getPathogenTestResult() == PathogenTestResultType.POSITIVE) { resultLabel.addStyleName(CssStyles.LABEL_CRITICAL); } else if (sample.getPathogenTestResult() == PathogenTestResultType.INDETERMINATE) { resultLabel.addStyleName(CssStyles.LABEL_WARNING); } } else if (sample.getSpecimenCondition() == SpecimenCondition.NOT_ADEQUATE) { resultLabel.setValue(DataHelper.toStringNullable(sample.getSpecimenCondition())); resultLabel.addStyleName(CssStyles.LABEL_WARNING); } topRightLayout.addComponent(resultLabel); Label referredLabel = new Label(); CssStyles.style(referredLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE); if (sample.isReferred()) { referredLabel.setValue(I18nProperties.getCaption(Captions.sampleReferredShort)); referredLabel.addStyleName(CssStyles.LABEL_NOT); } else if (sample.isReceived()) { referredLabel.setValue(I18nProperties.getCaption(Captions.sampleReceived) + " " + DateHelper.formatLocalShortDate(sample.getReceivedDate())); } else if (sample.isShipped()) { referredLabel.setValue(I18nProperties.getCaption(Captions.sampleShipped) + " " + DateHelper.formatLocalShortDate(sample.getShipmentDate())); } else { referredLabel.setValue(I18nProperties.getCaption(Captions.sampleNotShippedLong)); } topRightLayout.addComponent(referredLabel); } topLayout.addComponent(topRightLayout); topLayout.setComponentAlignment(topRightLayout, Alignment.TOP_RIGHT); if (UserProvider.getCurrent().hasUserRight(UserRight.ADDITIONAL_TEST_VIEW)) { Label labelAdditionalTests = new Label(I18nProperties.getString(Strings.entityAdditionalTests) + " " + sample.getAdditionalTestingStatus().toString().toLowerCase()); mainLayout.addComponent(labelAdditionalTests); } }
From source file:de.symeda.sormas.ui.samples.SamplesView.java
License:Open Source License
public SamplesView() { super(VIEW_NAME); sampleListComponent = new SampleGridComponent(getViewTitleLabel(), this); setSizeFull();// w w w .j a va 2 s . c o m addComponent(sampleListComponent); if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_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.getString(Strings.infoBasicExport)); basicExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); basicExportButton.setIcon(VaadinIcons.TABLE); basicExportButton.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(basicExportButton); StreamResource streamResource = new GridExportStreamResource(sampleListComponent.getGrid(), "sormas_samples", "sormas_samples_" + DateHelper.formatDateForExport(new Date()) + ".csv", SampleGrid.EDIT_BTN_ID); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(basicExportButton); Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed)); 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( SampleExportDto.class, (Integer start, Integer max) -> FacadeProvider.getSampleFacade().getExportList( UserProvider.getCurrent().getUuid(), sampleListComponent.getGrid().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(extendedExportStreamResource).extend(extendedExportButton); } }
From source file:de.symeda.sormas.ui.statistics.DatabaseExportView.java
License:Open Source License
private HorizontalLayout createDatabaseTablesLayout() { HorizontalLayout databaseTablesLayout = new HorizontalLayout(); databaseTablesLayout.setMargin(false); databaseTablesLayout.setSpacing(true); VerticalLayout sormasDataLayout = new VerticalLayout(); sormasDataLayout.setMargin(false); sormasDataLayout.setSpacing(false);//from w ww . ja v a2 s .c o m Label sormasDataHeadline = new Label(I18nProperties.getCaption(Captions.exportSormasData)); CssStyles.style(sormasDataHeadline, CssStyles.H4); sormasDataLayout.addComponent(sormasDataHeadline); VerticalLayout infrastructureDataLayout = new VerticalLayout(); infrastructureDataLayout.setMargin(false); infrastructureDataLayout.setSpacing(false); Label infrastructureDataHeadline = new Label(I18nProperties.getCaption(Captions.exportInfrastructureData)); CssStyles.style(infrastructureDataHeadline, CssStyles.H4); infrastructureDataLayout.addComponent(infrastructureDataHeadline); for (DatabaseTable databaseTable : DatabaseTable.values()) { CheckBox checkBox = new CheckBox(databaseTable.toString()); int indent = getIndent(databaseTable); if (indent == 1) { CssStyles.style(checkBox, CssStyles.INDENT_LEFT_1); } else if (indent == 2) { CssStyles.style(checkBox, CssStyles.INDENT_LEFT_2); } else if (indent == 3) { CssStyles.style(checkBox, CssStyles.INDENT_LEFT_3); } if (databaseTable.getDatabaseTableType() == DatabaseTableType.SORMAS) { sormasDataLayout.addComponent(checkBox); } else { infrastructureDataLayout.addComponent(checkBox); } databaseTableToggles.put(checkBox, databaseTable); } databaseTablesLayout.addComponent(sormasDataLayout); databaseTablesLayout.addComponent(infrastructureDataLayout); return databaseTablesLayout; }
From source file:de.symeda.sormas.ui.statistics.StatisticsFilterValuesElement.java
License:Open Source License
private VerticalLayout createUtilityButtonsLayout() { VerticalLayout utilityButtonsLayout = new VerticalLayout(); utilityButtonsLayout.setMargin(false); utilityButtonsLayout.setSpacing(false); utilityButtonsLayout.setSizeUndefined(); Button addAllButton = new Button(I18nProperties.getCaption(Captions.all), VaadinIcons.PLUS_CIRCLE); CssStyles.style(addAllButton, ValoTheme.BUTTON_LINK); addAllButton.addClickListener(e -> { for (TokenizableValue tokenizable : getFilterValues()) { tokenField.addTokenizable(tokenizable); }//from w w w . j av a 2 s . c o m }); Button removeAllButton = new Button(I18nProperties.getCaption(Captions.actionClear), VaadinIcons.CLOSE_CIRCLE); CssStyles.style(removeAllButton, ValoTheme.BUTTON_LINK); removeAllButton.addClickListener(e -> { for (Tokenizable tokenizable : tokenField.getValue()) { tokenField.removeTokenizable(tokenizable); } }); utilityButtonsLayout.addComponent(addAllButton); utilityButtonsLayout.addComponent(removeAllButton); return utilityButtonsLayout; }
From source file:de.symeda.sormas.ui.statistics.StatisticsView.java
License:Open Source License
public StatisticsView() { super(VIEW_NAME); setWidth(100, Unit.PERCENTAGE);// ww w .j a v a2 s .c o m emptyResultLabel = new Label(I18nProperties.getString(Strings.infoNoCasesFoundStatistics)); // Main layout VerticalLayout statisticsLayout = new VerticalLayout(); statisticsLayout.setMargin(true); statisticsLayout.setSpacing(true); statisticsLayout.setWidth(100, Unit.PERCENTAGE); // Filters layout addFiltersLayout(statisticsLayout); // Visualization layout Label visualizationTitle = new Label(I18nProperties.getString(Strings.headingVisualization)); visualizationTitle.setWidthUndefined(); CssStyles.style(visualizationTitle, CssStyles.STATISTICS_TITLE); statisticsLayout.addComponent(visualizationTitle); visualizationComponent = new StatisticsVisualizationComponent(); CssStyles.style(visualizationComponent, CssStyles.STATISTICS_TITLE_BOX); statisticsLayout.addComponent(visualizationComponent); // Options layout addOptionsLayout(statisticsLayout); // Generate button addGenerateButton(statisticsLayout); // Results layout addResultsLayout(statisticsLayout); // Disclaimer Label disclaimer = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + I18nProperties.getString(Strings.infoStatisticsDisclaimer), ContentMode.HTML); statisticsLayout.addComponent(disclaimer); addComponent(statisticsLayout); }
From source file:de.symeda.sormas.ui.task.TaskListEntry.java
License:Open Source License
public TaskListEntry(TaskIndexDto task) { this.task = task; setMargin(false);//from w w w .ja va 2 s . c o m setSpacing(true); setWidth(100, Unit.PERCENTAGE); addStyleName(CssStyles.SORMAS_LIST_ENTRY); HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setMargin(false); topLayout.setSpacing(false); topLayout.setWidth(100, Unit.PERCENTAGE); addComponent(topLayout); setExpandRatio(topLayout, 1); // TOP LEFT VerticalLayout topLeftLayout = new VerticalLayout(); topLeftLayout.setMargin(false); topLeftLayout.setSpacing(false); Label taskTypeLabel = new Label(DataHelper.toStringNullable(task.getTaskType())); CssStyles.style(taskTypeLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE); topLeftLayout.addComponent(taskTypeLabel); Label suggestedStartLabel = new Label( I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.SUGGESTED_START) + ": " + DateHelper.formatLocalShortDate(task.getSuggestedStart())); topLeftLayout.addComponent(suggestedStartLabel); Label dueDateLabel = new Label(I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.DUE_DATE) + ": " + DateHelper.formatLocalShortDate(task.getDueDate())); topLeftLayout.addComponent(dueDateLabel); topLayout.addComponent(topLeftLayout); // TOP RIGHT VerticalLayout topRightLayout = new VerticalLayout(); topRightLayout.addStyleName(CssStyles.ALIGN_RIGHT); topRightLayout.setMargin(false); topRightLayout.setSpacing(false); Label statusLabel = new Label(DataHelper.toStringNullable(task.getTaskStatus())); CssStyles.style(statusLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE); topRightLayout.addComponent(statusLabel); Label priorityLabel = new Label( DataHelper.toStringNullable(I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.PRIORITY) + ": " + task.getPriority())); if (TaskPriority.HIGH == task.getPriority()) { priorityLabel.addStyleName(CssStyles.LABEL_IMPORTANT); } else if (TaskPriority.NORMAL == task.getPriority()) { priorityLabel.addStyleName(CssStyles.LABEL_NEUTRAL); } topRightLayout.addComponent(priorityLabel); Label userLabel = new Label(I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.ASSIGNEE_USER) + ": " + task.getAssigneeUser().getCaption()); topRightLayout.addComponent(userLabel); topLayout.addComponent(topRightLayout); topLayout.setComponentAlignment(topRightLayout, Alignment.TOP_RIGHT); String statusStyle; switch (task.getTaskStatus()) { case DONE: statusStyle = CssStyles.LABEL_DONE; break; case NOT_EXECUTABLE: statusStyle = CssStyles.LABEL_NOT; break; case REMOVED: statusStyle = CssStyles.LABEL_DISCARDED; break; default: statusStyle = null; } if (statusStyle != null) { taskTypeLabel.addStyleName(statusStyle); suggestedStartLabel.addStyleName(statusStyle); dueDateLabel.addStyleName(statusStyle); statusLabel.addStyleName(statusStyle); priorityLabel.addStyleName(statusStyle); userLabel.addStyleName(statusStyle); } }
From source file:de.symeda.sormas.ui.therapy.TherapyView.java
License:Open Source License
public TherapyView() { super(VIEW_NAME); prescriptionCriteria = ViewModelProviders.of(TherapyView.class).get(PrescriptionCriteria.class); treatmentCriteria = ViewModelProviders.of(TherapyView.class).get(TreatmentCriteria.class); VerticalLayout container = new VerticalLayout(); container.setSpacing(false);/*from ww w .j a v a 2 s. c om*/ container.setWidth(100, Unit.PERCENTAGE); container.setMargin(true); container.addComponent(createPrescriptionsHeader()); prescriptionGrid = new PrescriptionGrid(this); prescriptionGrid.setCriteria(prescriptionCriteria); prescriptionGrid.setHeightMode(HeightMode.ROW); CssStyles.style(prescriptionGrid, CssStyles.VSPACE_2); container.addComponent(prescriptionGrid); container.addComponent(createTreatmentsHeader()); treatmentGrid = new TreatmentGrid(); treatmentGrid.setCriteria(treatmentCriteria); container.addComponent(treatmentGrid); container.setExpandRatio(treatmentGrid, 1); setSubComponent(container); }
From source file:de.symeda.sormas.ui.therapy.TherapyView.java
License:Open Source License
private VerticalLayout createPrescriptionsHeader() { VerticalLayout prescriptionsHeader = new VerticalLayout(); prescriptionsHeader.setMargin(false); prescriptionsHeader.setSpacing(false); prescriptionsHeader.setWidth(100, Unit.PERCENTAGE); HorizontalLayout headlineRow = new HorizontalLayout(); headlineRow.setMargin(false);//from w w w .j a va 2s . c o m headlineRow.setSpacing(true); headlineRow.setWidth(100, Unit.PERCENTAGE); { Label prescriptionsLabel = new Label(I18nProperties.getString(Strings.entityPrescriptions)); CssStyles.style(prescriptionsLabel, CssStyles.H3); headlineRow.addComponent(prescriptionsLabel); headlineRow.setExpandRatio(prescriptionsLabel, 1); // Bulk operations if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command deleteCommand = selectedItem -> { ControllerProvider.getTherapyController() .deleteAllSelectedPrescriptions(prescriptionGrid.getSelectedRows(), new Runnable() { public void run() { reloadPrescriptionGrid(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); headlineRow.addComponent(bulkOperationsDropdown); headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT); } Button newPrescriptionButton = new Button( I18nProperties.getCaption(Captions.prescriptionNewPrescription)); CssStyles.style(newPrescriptionButton, ValoTheme.BUTTON_PRIMARY); newPrescriptionButton.addClickListener(e -> { ControllerProvider.getTherapyController().openPrescriptionCreateForm( prescriptionCriteria.getTherapy(), this::reloadPrescriptionGrid); }); headlineRow.addComponent(newPrescriptionButton); headlineRow.setComponentAlignment(newPrescriptionButton, Alignment.MIDDLE_RIGHT); } prescriptionsHeader.addComponent(headlineRow); HorizontalLayout filterRow = new HorizontalLayout(); filterRow.setMargin(false); filterRow.setSpacing(true); { prescriptionTypeFilter = new ComboBox(); prescriptionTypeFilter.setWidth(140, Unit.PIXELS); prescriptionTypeFilter.setInputPrompt(I18nProperties.getPrefixCaption(PrescriptionDto.I18N_PREFIX, PrescriptionDto.PRESCRIPTION_TYPE)); prescriptionTypeFilter.addItems((Object[]) TreatmentType.values()); prescriptionTypeFilter.addValueChangeListener(e -> { prescriptionCriteria.prescriptionType(((TreatmentType) e.getProperty().getValue())); navigateTo(prescriptionCriteria); }); filterRow.addComponent(prescriptionTypeFilter); prescriptionTextFilter = new TextField(); prescriptionTextFilter.setWidth(300, Unit.PIXELS); prescriptionTextFilter.setNullRepresentation(""); prescriptionTextFilter.setInputPrompt(I18nProperties.getString(Strings.promptPrescriptionTextFilter)); prescriptionTextFilter.addTextChangeListener(e -> { prescriptionCriteria.textFilter(e.getText()); reloadPrescriptionGrid(); }); filterRow.addComponent(prescriptionTextFilter); } prescriptionsHeader.addComponent(filterRow); return prescriptionsHeader; }
From source file:de.symeda.sormas.ui.therapy.TherapyView.java
License:Open Source License
private VerticalLayout createTreatmentsHeader() { VerticalLayout treatmentsHeader = new VerticalLayout(); treatmentsHeader.setMargin(false); treatmentsHeader.setSpacing(false);//from w ww .j av a 2s. com treatmentsHeader.setWidth(100, Unit.PERCENTAGE); HorizontalLayout headlineRow = new HorizontalLayout(); headlineRow.setMargin(false); headlineRow.setSpacing(true); headlineRow.setWidth(100, Unit.PERCENTAGE); { Label treatmentsLabel = new Label(I18nProperties.getString(Strings.headingTreatments)); CssStyles.style(treatmentsLabel, CssStyles.H3); headlineRow.addComponent(treatmentsLabel); headlineRow.setExpandRatio(treatmentsLabel, 1); // Bulk operations if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command deleteCommand = selectedItem -> { ControllerProvider.getTherapyController() .deleteAllSelectedTreatments(treatmentGrid.getSelectedRows(), new Runnable() { public void run() { reloadTreatmentGrid(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); headlineRow.addComponent(bulkOperationsDropdown); headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT); } Button newTreatmentButton = new Button(I18nProperties.getCaption(Captions.treatmentNewTreatment)); newTreatmentButton.addClickListener(e -> { ControllerProvider.getTherapyController().openTreatmentCreateForm(treatmentCriteria.getTherapy(), this::reloadTreatmentGrid); }); headlineRow.addComponent(newTreatmentButton); headlineRow.setComponentAlignment(newTreatmentButton, Alignment.MIDDLE_RIGHT); } treatmentsHeader.addComponent(headlineRow); HorizontalLayout filterRow = new HorizontalLayout(); filterRow.setMargin(false); filterRow.setSpacing(true); { treatmentTypeFilter = new ComboBox(); treatmentTypeFilter.setWidth(140, Unit.PIXELS); treatmentTypeFilter.setInputPrompt( I18nProperties.getPrefixCaption(TreatmentDto.I18N_PREFIX, TreatmentDto.TREATMENT_TYPE)); treatmentTypeFilter.addItems((Object[]) TreatmentType.values()); treatmentTypeFilter.addValueChangeListener(e -> { treatmentCriteria.treatmentType(((TreatmentType) e.getProperty().getValue())); navigateTo(treatmentCriteria); }); filterRow.addComponent(treatmentTypeFilter); treatmentTextFilter = new TextField(); treatmentTextFilter.setWidth(300, Unit.PIXELS); treatmentTextFilter.setNullRepresentation(""); treatmentTextFilter.setInputPrompt(I18nProperties.getString(Strings.promptTreatmentTextFilter)); treatmentTextFilter.addTextChangeListener(e -> { treatmentCriteria.textFilter(e.getText()); reloadTreatmentGrid(); }); filterRow.addComponent(treatmentTextFilter); } treatmentsHeader.addComponent(filterRow); return treatmentsHeader; }
From source file:de.symeda.sormas.ui.user.UserController.java
License:Open Source License
public void makeNewPassword(String userUuid) { String newPassword = FacadeProvider.getUserFacade().resetPassword(userUuid); VerticalLayout layout = new VerticalLayout(); layout.addComponent(new Label(I18nProperties.getString(Strings.messageCopyPassword))); Label passwordLabel = new Label(newPassword); passwordLabel.addStyleName(CssStyles.H2); layout.addComponent(passwordLabel);/*from w ww .ja v a 2s . c o m*/ Window popupWindow = VaadinUiUtil.showPopupWindow(layout); popupWindow.setCaption(I18nProperties.getString(Strings.headingNewPassword)); layout.setMargin(true); }