List of usage examples for com.vaadin.ui Alignment TOP_RIGHT
Alignment TOP_RIGHT
To view the source code for com.vaadin.ui Alignment TOP_RIGHT.
Click Source Link
From source file:de.symeda.sormas.ui.dashboard.DashboardFilterLayout.java
License:Open Source License
private void createDateFilters() { HorizontalLayout dateFilterLayout = new HorizontalLayout(); dateFilterLayout.addStyleName(CssStyles.LAYOUT_MINIMAL); dateFilterLayout.setSpacing(true);// w w w . j av a 2 s .co m addComponent(dateFilterLayout); Date now = new Date(); // Date filters Button todayButton = new Button(I18nProperties.getCaption(Captions.dashboardToday)); initializeDateFilterButton(todayButton); todayButton.addClickListener(e -> { setDateFilter(DateHelper.getStartOfDay(now), DateHelper.getEndOfDay(now)); dashboardView.refreshDashboard(); }); Button yesterdayButton = new Button(I18nProperties.getCaption(Captions.dashboardYesterday)); initializeDateFilterButton(yesterdayButton); yesterdayButton.addClickListener(e -> { setDateFilter(DateHelper.getStartOfDay(DateHelper.subtractDays(now, 1)), DateHelper.getEndOfDay(DateHelper.subtractDays(now, 1))); dashboardView.refreshDashboard(); }); Button thisWeekButton = new Button(I18nProperties.getCaption(Captions.dashboardThisWeek)); initializeDateFilterButton(thisWeekButton); thisWeekButton.addClickListener(e -> { setDateFilter(DateHelper.getStartOfWeek(now), DateHelper.getEndOfWeek(now)); dashboardView.refreshDashboard(); }); CssStyles.style(thisWeekButton, CssStyles.BUTTON_FILTER_DARK); CssStyles.removeStyles(thisWeekButton, CssStyles.BUTTON_FILTER_LIGHT); Button lastWeekButton = new Button(I18nProperties.getCaption(Captions.dashboardLastWeek)); initializeDateFilterButton(lastWeekButton); lastWeekButton.addClickListener(e -> { setDateFilter(DateHelper.getStartOfWeek(DateHelper.subtractWeeks(now, 1)), DateHelper.getEndOfWeek(DateHelper.subtractWeeks(now, 1))); dashboardView.refreshDashboard(); }); Button thisYearButton = new Button(I18nProperties.getCaption(Captions.dashboardThisYear)); initializeDateFilterButton(thisYearButton); thisYearButton.addClickListener(e -> { setDateFilter(DateHelper.getStartOfYear(now), DateHelper.getEndOfYear(now)); dashboardView.refreshDashboard(); }); Button lastYearButton = new Button(I18nProperties.getCaption(Captions.dashboardLastYear)); initializeDateFilterButton(lastYearButton); lastYearButton.addClickListener(e -> { setDateFilter(DateHelper.getStartOfYear(DateHelper.subtractYears(now, 1)), DateHelper.getEndOfYear(DateHelper.subtractYears(now, 1))); dashboardView.refreshDashboard(); }); customButton = new PopupButton(I18nProperties.getCaption(Captions.dashboardCustom)); initializeDateFilterButton(customButton); // Custom filter HorizontalLayout customDateFilterLayout = new HorizontalLayout(); customDateFilterLayout.setSpacing(true); customDateFilterLayout.setMargin(true); // 'Apply custom filter' button Button applyButton = new Button(I18nProperties.getCaption(Captions.dashboardApplyCustomFilter)); CssStyles.style(applyButton, CssStyles.FORCE_CAPTION, ValoTheme.BUTTON_PRIMARY); // Date & Epi Week filter EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = new EpiWeekAndDateFilterComponent<>( applyButton, true, true, I18nProperties.getString(Strings.infoCaseDate)); customDateFilterLayout.addComponent(weekAndDateFilter); dashboardDataProvider .setDateFilterOption((DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter().getValue()); dashboardDataProvider.setFromDate( DateHelper.getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue())); dashboardDataProvider .setToDate(DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue())); customDateFilterLayout.addComponent(applyButton); // Apply button listener applyButton.addClickListener(e -> { DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter() .getValue(); Date fromDate = null; Date toDate = null; EpiWeek fromWeek = null; EpiWeek toWeek = null; dashboardDataProvider.setDateFilterOption(dateFilterOption); if (dateFilterOption == DateFilterOption.DATE) { fromDate = weekAndDateFilter.getDateFromFilter().getValue(); dashboardDataProvider.setFromDate(fromDate); toDate = weekAndDateFilter.getDateToFilter().getValue(); dashboardDataProvider.setToDate(toDate); } else { fromWeek = (EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue(); dashboardDataProvider.setFromDate(DateHelper.getEpiWeekStart(fromWeek)); toWeek = (EpiWeek) weekAndDateFilter.getWeekToFilter().getValue(); dashboardDataProvider.setToDate(DateHelper.getEpiWeekEnd(toWeek)); } if ((fromDate != null && toDate != null) || (fromWeek != null && toWeek != null)) { changeDateFilterButtonsStyles(customButton); dashboardView.refreshDashboard(); if (dateFilterOption == DateFilterOption.DATE) { customButton.setCaption(DateHelper.formatLocalShortDate(fromDate) + " - " + DateHelper.formatLocalShortDate(toDate)); } else { customButton.setCaption(fromWeek.toShortString() + " - " + toWeek.toShortString()); } } else { if (dateFilterOption == DateFilterOption.DATE) { new Notification(I18nProperties.getString(Strings.headingMissingDateFilter), I18nProperties.getString(Strings.messageMissingDateFilter), Type.ERROR_MESSAGE, false) .show(Page.getCurrent()); } else { new Notification(I18nProperties.getString(Strings.headingMissingEpiWeekFilter), I18nProperties.getString(Strings.messageMissingEpiWeekFilter), Type.ERROR_MESSAGE, false).show(Page.getCurrent()); } } }); customButton.setContent(customDateFilterLayout); dateFilterLayout.addComponents(todayButton, yesterdayButton, thisWeekButton, lastWeekButton, thisYearButton, lastYearButton, customButton); infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML); infoLabel.setSizeUndefined(); CssStyles.style(infoLabel, CssStyles.LABEL_XLARGE, CssStyles.LABEL_SECONDARY); addComponent(infoLabel); setComponentAlignment(infoLabel, Alignment.TOP_RIGHT); }
From source file:de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsSubComponent.java
License:Open Source License
public void addHeader(String headline, Image icon, boolean showTotalCount) { HorizontalLayout headerLayout = new HorizontalLayout(); headerLayout.setWidth(100, Unit.PERCENTAGE); headerLayout.setSpacing(true);/* ww w .j a va2s . c o m*/ headerLayout.setMargin(false); CssStyles.style(headerLayout, CssStyles.VSPACE_4); VerticalLayout labelAndTotalLayout = new VerticalLayout(); { labelAndTotalLayout.setMargin(false); labelAndTotalLayout.setSpacing(false); Label headlineLabel = new Label(headline); CssStyles.style(headlineLabel, CssStyles.H2, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE); labelAndTotalLayout.addComponent(headlineLabel); if (showTotalCount) { totalCountLabel = new Label(); CssStyles.style(totalCountLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_XXXLARGE, CssStyles.LABEL_BOLD, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE); labelAndTotalLayout.addComponent(totalCountLabel); } else { CssStyles.style(labelAndTotalLayout, CssStyles.VSPACE_4); } } headerLayout.addComponent(labelAndTotalLayout); headerLayout.setComponentAlignment(labelAndTotalLayout, Alignment.BOTTOM_LEFT); headerLayout.setHeightUndefined(); headerLayout.setExpandRatio(labelAndTotalLayout, 1); if (icon != null) { headerLayout.addComponent(icon); headerLayout.setComponentAlignment(icon, Alignment.TOP_RIGHT); } addComponent(headerLayout); setExpandRatio(headerLayout, 0); }
From source file:de.symeda.sormas.ui.dashboard.surveillance.SurveillanceOverviewLayout.java
License:Open Source License
private void addDiseaseBurdenView() { HorizontalLayout layout = new HorizontalLayout(); layout.setWidth(100, Unit.PERCENTAGE); layout.setMargin(false);/*from ww w . ja va 2 s . c om*/ layout.addComponent(diseaseTileViewLayout); layout.setExpandRatio(diseaseTileViewLayout, 1); // "Expand" and "Collapse" buttons Button showTableViewButton = new Button("", VaadinIcons.TABLE); CssStyles.style(showTableViewButton, CssStyles.BUTTON_SUBTLE); showTableViewButton.addStyleName(CssStyles.VSPACE_NONE); Button showTileViewButton = new Button("", VaadinIcons.SQUARE_SHADOW); CssStyles.style(showTileViewButton, CssStyles.BUTTON_SUBTLE); showTileViewButton.addStyleName(CssStyles.VSPACE_NONE); showTableViewButton.addClickListener(e -> { layout.removeComponent(diseaseTileViewLayout); layout.addComponent(diseaseBurdenComponent); layout.setExpandRatio(diseaseBurdenComponent, 1); layout.removeComponent(showTableViewButton); layout.addComponent(showTileViewButton); layout.setComponentAlignment(showTileViewButton, Alignment.TOP_RIGHT); }); showTileViewButton.addClickListener(e -> { layout.removeComponent(diseaseBurdenComponent); layout.addComponent(diseaseTileViewLayout); layout.setExpandRatio(diseaseTileViewLayout, 1); layout.removeComponent(showTileViewButton); layout.addComponent(showTableViewButton); layout.setComponentAlignment(showTableViewButton, Alignment.TOP_RIGHT); }); layout.addComponent(showTableViewButton); layout.setComponentAlignment(showTableViewButton, Alignment.TOP_RIGHT); diseaseBurdenView = layout; addComponent(diseaseBurdenView, BURDEN_LOC); if (UserRole.isSupervisor(UserProvider.getCurrent().getUser().getUserRoles())) showTableViewButton.click(); }
From source file:de.symeda.sormas.ui.events.EventParticipantsView.java
License:Open Source License
public HorizontalLayout createTopBar() { HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setSpacing(true);/*from w w w . j a v a 2 s . c o m*/ topLayout.setWidth("100%"); Label header = new Label(I18nProperties.getPrefixCaption(EventDto.I18N_PREFIX, EventDto.EVENT_PERSONS)); header.setSizeUndefined(); CssStyles.style(header, CssStyles.H2, CssStyles.VSPACE_NONE); topLayout.addComponent(header); // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { topLayout.setWidth(100, Unit.PERCENTAGE); MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command deleteCommand = selectedItem -> { ControllerProvider.getEventParticipantController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); topLayout.addComponent(bulkOperationsDropdown); topLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT); topLayout.setExpandRatio(bulkOperationsDropdown, 1); } if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_CREATE)) { addButton = new Button(I18nProperties.getCaption(Captions.eventParticipantAddPerson)); addButton.addStyleName(ValoTheme.BUTTON_PRIMARY); addButton.setIcon(VaadinIcons.PLUS_CIRCLE); addButton.addClickListener(e -> { ControllerProvider.getEventParticipantController().createEventParticipant(this.getEventRef(), r -> grid.reload()); }); topLayout.addComponent(addButton); topLayout.setComponentAlignment(addButton, Alignment.MIDDLE_RIGHT); } topLayout.addStyleName(CssStyles.VSPACE_3); return topLayout; }
From source file:de.symeda.sormas.ui.events.EventsView.java
License:Open Source License
public HorizontalLayout createStatusFilterBar() { HorizontalLayout statusFilterLayout = new HorizontalLayout(); statusFilterLayout.setSpacing(true); statusFilterLayout.setMargin(false); statusFilterLayout.setWidth(100, Unit.PERCENTAGE); statusFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> { criteria.eventStatus(null);/* w w w . jav a2s .co m*/ 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 (EventStatus status : EventStatus.values()) { Button statusButton = new Button(status.toString(), e -> { criteria.eventStatus(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()); } HorizontalLayout actionButtonsLayout = new HorizontalLayout(); actionButtonsLayout.setSpacing(true); { // Show archived/active cases button if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_VIEW_ARCHIVED)) { switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.eventShowArchived)); switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK); switchArchivedActiveButton.addClickListener(e -> { criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE); navigateTo(criteria); }); actionButtonsLayout.addComponent(switchArchivedActiveButton); } // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command changeCommand = selectedItem -> { ControllerProvider.getEventController() .showBulkEventDataEditComponent(grid.asMultiSelect().getSelectedItems()); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, changeCommand); Command deleteCommand = selectedItem -> { ControllerProvider.getEventController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); Command archiveCommand = selectedItem -> { ControllerProvider.getEventController() .archiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; archiveItem = bulkOperationsItem.addItem( I18nProperties.getCaption(I18nProperties.getCaption(Captions.actionArchive)), VaadinIcons.ARCHIVE, archiveCommand); Command dearchiveCommand = selectedItem -> { ControllerProvider.getEventController() .dearchiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; dearchiveItem = bulkOperationsItem.addItem( I18nProperties.getCaption(I18nProperties.getCaption(Captions.actionDearchive)), VaadinIcons.ARCHIVE, dearchiveCommand); dearchiveItem.setVisible(false); actionButtonsLayout.addComponent(bulkOperationsDropdown); } } statusFilterLayout.addComponent(actionButtonsLayout); statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT); statusFilterLayout.setExpandRatio(actionButtonsLayout, 1); return statusFilterLayout; }
From source file:de.symeda.sormas.ui.importer.ImportProgressLayout.java
License:Open Source License
public ImportProgressLayout(int totalCount, UI currentUI, Runnable cancelCallback) { this.totalCount = totalCount; this.currentUI = currentUI; setWidth(100, Unit.PERCENTAGE);//w ww . j av a 2s . c om setMargin(true); // Info text and icon/progress circle infoLayout = new HorizontalLayout(); infoLayout.setWidth(100, Unit.PERCENTAGE); infoLayout.setSpacing(true); initializeInfoComponents(); currentInfoComponent = progressCircle; infoLayout.addComponent(currentInfoComponent); infoLabel = new Label(String.format(I18nProperties.getString(Strings.infoImportProcess), totalCount)); infoLabel.setContentMode(ContentMode.HTML); infoLayout.addComponent(infoLabel); infoLayout.setExpandRatio(infoLabel, 1); addComponent(infoLayout); // Progress bar progressBar = new ProgressBar(0.0f); CssStyles.style(progressBar, CssStyles.VSPACE_TOP_3); addComponent(progressBar); progressBar.setWidth(100, Unit.PERCENTAGE); // Progress info HorizontalLayout progressInfoLayout = new HorizontalLayout(); CssStyles.style(progressInfoLayout, CssStyles.VSPACE_TOP_5); progressInfoLayout.setSpacing(true); processedImportsLabel = new Label( String.format(I18nProperties.getCaption(Captions.importProcessed), 0, totalCount)); progressInfoLayout.addComponent(processedImportsLabel); successfulImportsLabel = new Label(String.format(I18nProperties.getCaption(Captions.importImports), 0)); CssStyles.style(successfulImportsLabel, CssStyles.LABEL_POSITIVE); progressInfoLayout.addComponent(successfulImportsLabel); importErrorsLabel = new Label(String.format(I18nProperties.getCaption(Captions.importErrors), 0)); CssStyles.style(importErrorsLabel, CssStyles.LABEL_CRITICAL); progressInfoLayout.addComponent(importErrorsLabel); importDuplicatesLabel = new Label(String.format(I18nProperties.getCaption(Captions.importDuplicates), 0)); CssStyles.style(importDuplicatesLabel, CssStyles.LABEL_WARNING); progressInfoLayout.addComponent(importDuplicatesLabel); importSkipsLabel = new Label(String.format(I18nProperties.getCaption(Captions.importSkips), 0)); CssStyles.style(importSkipsLabel, CssStyles.LABEL_MINOR); progressInfoLayout.addComponent(importSkipsLabel); addComponent(progressInfoLayout); setComponentAlignment(progressInfoLayout, Alignment.TOP_RIGHT); // Cancel button closeCancelButton = new Button(I18nProperties.getCaption(Captions.actionCancel)); CssStyles.style(closeCancelButton, CssStyles.VSPACE_TOP_2); cancelListener = e -> { cancelCallback.run(); }; closeCancelButton.addClickListener(cancelListener); addComponent(closeCancelButton); setComponentAlignment(closeCancelButton, Alignment.MIDDLE_RIGHT); }
From source file:de.symeda.sormas.ui.samples.PathogenTestListEntry.java
License:Open Source License
public PathogenTestListEntry(PathogenTestDto pathogenTest) { setSpacing(true);//from ww w. j a v a 2 s . c o m setMargin(false); setWidth(100, Unit.PERCENTAGE); addStyleName(CssStyles.SORMAS_LIST_ENTRY); this.pathogenTest = pathogenTest; VerticalLayout labelLayout = new VerticalLayout(); labelLayout.setSpacing(false); labelLayout.setMargin(false); labelLayout.setWidth(100, Unit.PERCENTAGE); addComponent(labelLayout); setExpandRatio(labelLayout, 1); HorizontalLayout topLabelLayout = new HorizontalLayout(); topLabelLayout.setSpacing(false); topLabelLayout.setMargin(false); topLabelLayout.setWidth(100, Unit.PERCENTAGE); labelLayout.addComponent(topLabelLayout); Label labelTopLeft = new Label( PathogenTestType.toString(pathogenTest.getTestType(), pathogenTest.getTestTypeText())); CssStyles.style(labelTopLeft, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE); topLabelLayout.addComponent(labelTopLeft); if (pathogenTest.getTestResultVerified()) { Label labelTopRight = new Label(VaadinIcons.CHECK_CIRCLE.getHtml(), ContentMode.HTML); labelTopRight.setSizeUndefined(); labelTopRight.addStyleName(CssStyles.LABEL_LARGE); labelTopRight.setDescription(I18nProperties.getPrefixCaption(PathogenTestDto.I18N_PREFIX, PathogenTestDto.TEST_RESULT_VERIFIED)); topLabelLayout.addComponent(labelTopRight); topLabelLayout.setComponentAlignment(labelTopRight, Alignment.TOP_RIGHT); } if (!DataHelper.isNullOrEmpty(pathogenTest.getTestResultText())) { Label resultTextLabel = new Label(pathogenTest.getTestResultText()); labelLayout.addComponent(resultTextLabel); } HorizontalLayout middleLabelLayout = new HorizontalLayout(); middleLabelLayout.setSpacing(false); middleLabelLayout.setMargin(false); middleLabelLayout.setWidth(100, Unit.PERCENTAGE); labelLayout.addComponent(middleLabelLayout); Label labelLeft = new Label(DataHelper.toStringNullable( DiseaseHelper.toString(pathogenTest.getTestedDisease(), pathogenTest.getTestedDiseaseDetails()))); middleLabelLayout.addComponent(labelLeft); Label labelRight = new Label(DateHelper.formatLocalShortDateTime(pathogenTest.getTestDateTime())); labelRight.addStyleName(CssStyles.ALIGN_RIGHT); middleLabelLayout.addComponent(labelRight); middleLabelLayout.setComponentAlignment(labelRight, Alignment.TOP_RIGHT); Label labelBottom = new Label(DataHelper.toStringNullable(pathogenTest.getTestResult())); CssStyles.style(labelBottom, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE); if (pathogenTest.getTestResult() == PathogenTestResultType.POSITIVE) CssStyles.style(labelBottom, CssStyles.LABEL_CRITICAL); else CssStyles.style(labelBottom, CssStyles.LABEL_WARNING); labelLayout.addComponent(labelBottom); }
From source file:de.symeda.sormas.ui.samples.SampleGridComponent.java
License:Open Source License
public HorizontalLayout createShipmentFilterBar() { HorizontalLayout shipmentFilterLayout = new HorizontalLayout(); shipmentFilterLayout.setMargin(false); shipmentFilterLayout.setSpacing(true); shipmentFilterLayout.setWidth(100, Unit.PERCENTAGE); shipmentFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); HorizontalLayout buttonFilterLayout = new HorizontalLayout(); buttonFilterLayout.setSpacing(true); {//from w w w.j av a 2s. co m Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> processStatusChange(null)); CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER); statusAll.setCaptionAsHtml(true); buttonFilterLayout.addComponent(statusAll); statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all)); activeStatusButton = statusAll; Button notShippedButton = new Button(I18nProperties.getCaption(Captions.sampleNotShipped), e -> processStatusChange(NOT_SHIPPED)); initializeStatusButton(notShippedButton, buttonFilterLayout, NOT_SHIPPED, I18nProperties.getCaption(Captions.sampleNotShipped)); Button shippedButton = new Button(I18nProperties.getCaption(Captions.sampleShipped), e -> processStatusChange(SHIPPED)); initializeStatusButton(shippedButton, buttonFilterLayout, SHIPPED, I18nProperties.getCaption(Captions.sampleShipped)); Button receivedButton = new Button(I18nProperties.getCaption(Captions.sampleReceived), e -> processStatusChange(RECEIVED)); initializeStatusButton(receivedButton, buttonFilterLayout, RECEIVED, I18nProperties.getCaption(Captions.sampleReceived)); Button referredButton = new Button(I18nProperties.getCaption(Captions.sampleReferred), e -> processStatusChange(REFERRED)); initializeStatusButton(referredButton, buttonFilterLayout, REFERRED, I18nProperties.getCaption(Captions.sampleReferred)); } shipmentFilterLayout.addComponent(buttonFilterLayout); HorizontalLayout actionButtonsLayout = new HorizontalLayout(); actionButtonsLayout.setSpacing(true); { // Show archived/active cases button if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW_ARCHIVED)) { switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.sampleShowArchived)); switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK); switchArchivedActiveButton.addClickListener(e -> { criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE); samplesView.navigateTo(criteria); }); actionButtonsLayout.addComponent(switchArchivedActiveButton); } // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { shipmentFilterLayout.setWidth(100, Unit.PERCENTAGE); MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command deleteCommand = selectedItem -> { ControllerProvider.getSampleController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); actionButtonsLayout.addComponent(bulkOperationsDropdown); } } shipmentFilterLayout.addComponent(actionButtonsLayout); shipmentFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT); shipmentFilterLayout.setExpandRatio(actionButtonsLayout, 1); return shipmentFilterLayout; }
From source file:de.symeda.sormas.ui.samples.SampleListEntry.java
License:Open Source License
public SampleListEntry(SampleIndexDto sample) { this.sample = sample; setMargin(false);//www.ja v a2s. 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.statistics.StatisticsView.java
License:Open Source License
public void generateTable() { List<Object[]> resultData = generateStatistics(); if (resultData.isEmpty()) { resultsLayout.addComponent(emptyResultLabel); return;/*from w w w . j ava 2 s . c o m*/ } exportButton = new Button(I18nProperties.getCaption(Captions.export)); exportButton.setDescription(I18nProperties.getDescription(Descriptions.descExportButton)); exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); exportButton.setIcon(VaadinIcons.TABLE); resultsLayout.addComponent(exportButton); resultsLayout.setComponentAlignment(exportButton, Alignment.TOP_RIGHT); statisticsCaseGrid = new StatisticsCaseGrid(visualizationComponent.getRowsAttribute(), visualizationComponent.getRowsSubAttribute(), visualizationComponent.getColumnsAttribute(), visualizationComponent.getColumnsSubAttribute(), zeroValues.getValue(), resultData, caseCriteria); resultsLayout.addComponent(statisticsCaseGrid); resultsLayout.setExpandRatio(statisticsCaseGrid, 1); StreamResource streamResource = DownloadUtil.createGridExportStreamResource( statisticsCaseGrid.getContainerDataSource(), statisticsCaseGrid.getColumns(), "sormas_statistics", "sormas_statistics_" + DateHelper.formatDateForExport(new Date()) + ".csv"); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(exportButton); }