List of usage examples for com.vaadin.ui HorizontalLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:de.symeda.sormas.ui.samples.SampleGridComponent.java
License:Open Source License
public HorizontalLayout createFilterBar() { HorizontalLayout filterLayout = new HorizontalLayout(); filterLayout.setMargin(false); filterLayout.setSpacing(true);//from ww w. j ava 2 s .c om filterLayout.setSizeUndefined(); UserDto user = UserProvider.getCurrent().getUser(); testResultFilter = new ComboBox(); testResultFilter.setWidth(140, Unit.PIXELS); testResultFilter.setInputPrompt( I18nProperties.getPrefixCaption(PathogenTestDto.I18N_PREFIX, PathogenTestDto.TEST_RESULT)); testResultFilter.addItems((Object[]) PathogenTestResultType.values()); testResultFilter.addValueChangeListener(e -> { criteria.pathogenTestResult(((PathogenTestResultType) e.getProperty().getValue())); samplesView.navigateTo(criteria); }); filterLayout.addComponent(testResultFilter); specimenConditionFilter = new ComboBox(); specimenConditionFilter.setWidth(140, Unit.PIXELS); specimenConditionFilter.setInputPrompt( I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, SampleDto.SPECIMEN_CONDITION)); specimenConditionFilter.addItems((Object[]) SpecimenCondition.values()); specimenConditionFilter.addValueChangeListener(e -> { criteria.specimenCondition(((SpecimenCondition) e.getProperty().getValue())); samplesView.navigateTo(criteria); }); filterLayout.addComponent(specimenConditionFilter); classificationFilter = new ComboBox(); classificationFilter.setWidth(140, Unit.PIXELS); classificationFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CASE_CLASSIFICATION)); classificationFilter.addItems((Object[]) CaseClassification.values()); classificationFilter.addValueChangeListener(e -> { criteria.caseClassification(((CaseClassification) e.getProperty().getValue())); samplesView.navigateTo(criteria); }); filterLayout.addComponent(classificationFilter); diseaseFilter = new ComboBox(); diseaseFilter.setWidth(140, Unit.PIXELS); diseaseFilter.setInputPrompt(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE)); diseaseFilter .addItems(FacadeProvider.getDiseaseConfigurationFacade().getAllActivePrimaryDiseases().toArray()); diseaseFilter.addValueChangeListener(e -> { criteria.disease(((Disease) e.getProperty().getValue())); samplesView.navigateTo(criteria); }); filterLayout.addComponent(diseaseFilter); regionFilter = new ComboBox(); if (user.getRegion() == null) { regionFilter.setWidth(140, Unit.PIXELS); regionFilter .setInputPrompt(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REGION)); regionFilter.addItems(FacadeProvider.getRegionFacade().getAllAsReference()); regionFilter.addValueChangeListener(e -> { RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue(); criteria.region(region); samplesView.navigateTo(criteria); }); filterLayout.addComponent(regionFilter); } districtFilter = new ComboBox(); districtFilter.setWidth(140, Unit.PIXELS); districtFilter .setInputPrompt(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISTRICT)); districtFilter.setDescription(I18nProperties.getDescription(Descriptions.descDistrictFilter)); districtFilter.addValueChangeListener(e -> { criteria.district(((DistrictReferenceDto) e.getProperty().getValue())); samplesView.navigateTo(criteria); }); if (user.getRegion() != null) { districtFilter.addItems(FacadeProvider.getDistrictFacade().getAllByRegion(user.getRegion().getUuid())); districtFilter.setEnabled(true); } else { regionFilter.addValueChangeListener(e -> { RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue(); districtFilter.removeAllItems(); if (region != null) { districtFilter.addItems(FacadeProvider.getDistrictFacade().getAllByRegion(region.getUuid())); districtFilter.setEnabled(true); } else { districtFilter.setEnabled(false); } }); districtFilter.setEnabled(false); } filterLayout.addComponent(districtFilter); labFilter = new ComboBox(); labFilter.setWidth(140, Unit.PIXELS); labFilter.setInputPrompt(I18nProperties.getPrefixCaption(SampleIndexDto.I18N_PREFIX, SampleIndexDto.LAB)); labFilter.addItems(FacadeProvider.getFacilityFacade().getAllLaboratories(true)); labFilter.addValueChangeListener(e -> { criteria.laboratory(((FacilityReferenceDto) e.getProperty().getValue())); samplesView.navigateTo(criteria); }); filterLayout.addComponent(labFilter); searchField = new TextField(); searchField.setWidth(200, Unit.PIXELS); searchField.setNullRepresentation(""); searchField.setInputPrompt(I18nProperties.getString(Strings.promptSamplesSearchField)); searchField.addTextChangeListener(e -> { criteria.caseCodeIdLike(e.getText()); grid.reload(); }); filterLayout.addComponent(searchField); resetButton = new Button(I18nProperties.getCaption(Captions.actionResetFilters)); resetButton.setVisible(false); resetButton.addClickListener(event -> { ViewModelProviders.of(SamplesView.class).remove(SampleCriteria.class); samplesView.navigateTo(null); }); filterLayout.addComponent(resetButton); return filterLayout; }
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); {/* ww w.j a va2 s . c o 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.SampleListComponent.java
License:Open Source License
public SampleListComponent(CaseReferenceDto caseRef) { setWidth(100, Unit.PERCENTAGE);/*from ww w. j a va 2 s. co m*/ setMargin(false); setSpacing(false); HorizontalLayout componentHeader = new HorizontalLayout(); componentHeader.setMargin(false); componentHeader.setSpacing(false); componentHeader.setWidth(100, Unit.PERCENTAGE); addComponent(componentHeader); list = new SampleList(caseRef); addComponent(list); list.reload(); Label tasksHeader = new Label(I18nProperties.getString(Strings.entitySamples)); tasksHeader.addStyleName(CssStyles.H3); componentHeader.addComponent(tasksHeader); if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_CREATE)) { createButton = new Button(I18nProperties.getCaption(Captions.sampleNewSample)); createButton.addStyleName(ValoTheme.BUTTON_PRIMARY); createButton.setIcon(VaadinIcons.PLUS_CIRCLE); createButton .addClickListener(e -> ControllerProvider.getSampleController().create(caseRef, this::reload)); componentHeader.addComponent(createButton); componentHeader.setComponentAlignment(createButton, Alignment.MIDDLE_RIGHT); } }
From source file:de.symeda.sormas.ui.samples.SampleListEntry.java
License:Open Source License
public SampleListEntry(SampleIndexDto sample) { this.sample = sample; setMargin(false);/*from ww w . j a va2 s .c o 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.DatabaseExportView.java
License:Open Source License
public DatabaseExportView() { super(VIEW_NAME); databaseTableToggles = new HashMap<>(); databaseExportLayout = new VerticalLayout(); databaseExportLayout.setSpacing(false); databaseExportLayout.setMargin(false); HorizontalLayout headerLayout = new HorizontalLayout(); headerLayout.setSpacing(true);//from w ww.ja va2 s . com headerLayout.setMargin(false); Label infoLabel = new Label(I18nProperties.getString(Strings.infoDatabaseExportTables)); headerLayout.addComponent(infoLabel); headerLayout.setComponentAlignment(infoLabel, Alignment.MIDDLE_LEFT); headerLayout.addComponent(createSelectionButtonsLayout()); databaseExportLayout.addComponent(headerLayout); databaseExportLayout.addComponent(createDatabaseTablesLayout()); Button exportButton = new Button(I18nProperties.getCaption(Captions.export), VaadinIcons.DOWNLOAD); CssStyles.style(exportButton, ValoTheme.BUTTON_PRIMARY); StreamResource streamResource = DownloadUtil.createDatabaseExportStreamResource(this, "sormas_export_" + DateHelper.formatDateForExport(new Date()) + ".zip", "application/zip"); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(exportButton); databaseExportLayout.addComponent(exportButton); databaseExportLayout.setMargin(true); databaseExportLayout.setSpacing(true); addComponent(databaseExportLayout); }
From source file:de.symeda.sormas.ui.statistics.DatabaseExportView.java
License:Open Source License
private HorizontalLayout createSelectionButtonsLayout() { HorizontalLayout selectionButtonsLayout = new HorizontalLayout(); selectionButtonsLayout.setMargin(false); selectionButtonsLayout.setSpacing(true); Button selectAll = new Button(I18nProperties.getCaption(Captions.actionSelectAll)); CssStyles.style(selectAll, ValoTheme.BUTTON_LINK); selectAll.addClickListener(e -> { for (CheckBox checkBox : databaseTableToggles.keySet()) { checkBox.setValue(true);/* w ww.j av a2 s . c o m*/ } }); selectionButtonsLayout.addComponent(selectAll); Button selectAllSormasData = new Button(I18nProperties.getCaption(Captions.exportSelectSormasData)); CssStyles.style(selectAllSormasData, ValoTheme.BUTTON_LINK); selectAllSormasData.addClickListener(e -> { for (CheckBox checkBox : databaseTableToggles.keySet()) { if (databaseTableToggles.get(checkBox).getDatabaseTableType() == DatabaseTableType.SORMAS) { checkBox.setValue(true); } else { checkBox.setValue(false); } } }); selectionButtonsLayout.addComponent(selectAllSormasData); Button deselectAll = new Button(I18nProperties.getCaption(Captions.actionDeselectAll)); CssStyles.style(deselectAll, ValoTheme.BUTTON_LINK); deselectAll.addClickListener(e -> { for (CheckBox checkBox : databaseTableToggles.keySet()) { checkBox.setValue(false); } }); selectionButtonsLayout.addComponent(deselectAll); return selectionButtonsLayout; }
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);/*from w ww . ja v a2 s . c o m*/ sormasDataLayout.setSpacing(false); 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.StatisticsView.java
License:Open Source License
public void generateMap() { List<Object[]> resultData = generateStatistics(); if (resultData.isEmpty()) { resultsLayout.addComponent(emptyResultLabel); return;/*from w ww . ja v a2 s . com*/ } HorizontalLayout mapLayout = new HorizontalLayout(); mapLayout.setSpacing(true); mapLayout.setMargin(false); mapLayout.setWidth(100, Unit.PERCENTAGE); mapLayout.setHeightUndefined(); LeafletMap map = new LeafletMap(); map.setTileLayerOpacity(0.5f); map.setWidth(100, Unit.PERCENTAGE); map.setHeight(580, Unit.PIXELS); map.setZoom(6); GeoLatLon mapCenter = FacadeProvider.getGeoShapeProvider().getCenterOfAllRegions(); map.setCenter(mapCenter.getLon(), mapCenter.getLat()); List<RegionReferenceDto> regions = FacadeProvider.getRegionFacade().getAllAsReference(); List<LeafletPolygon> outlinePolygones = new ArrayList<LeafletPolygon>(); // draw outlines of all regions for (RegionReferenceDto region : regions) { GeoLatLon[][] regionShape = FacadeProvider.getGeoShapeProvider().getRegionShape(region); if (regionShape == null) { continue; } for (int part = 0; part < regionShape.length; part++) { GeoLatLon[] regionShapePart = regionShape[part]; LeafletPolygon polygon = new LeafletPolygon(); polygon.setCaption(region.getCaption()); // fillOpacity is used, so we can still hover the region polygon.setOptions("{\"weight\": 1, \"color\": '#888', \"fillOpacity\": 0.02}"); polygon.setLatLons(regionShapePart); outlinePolygones.add(polygon); } } map.addPolygonGroup("outlines", outlinePolygones); resultData.sort((a, b) -> { return Long.compare(((Number) a[0]).longValue(), ((Number) b[0]).longValue()); }); BigDecimal valuesLowerQuartile = new BigDecimal( resultData.size() > 0 ? ((Number) resultData.get((int) (resultData.size() * 0.25))[0]).longValue() : null); BigDecimal valuesMedian = new BigDecimal( resultData.size() > 0 ? ((Number) resultData.get((int) (resultData.size() * 0.5))[0]).longValue() : null); BigDecimal valuesUpperQuartile = new BigDecimal( resultData.size() > 0 ? ((Number) resultData.get((int) (resultData.size() * 0.75))[0]).longValue() : null); List<LeafletPolygon> resultPolygons = new ArrayList<LeafletPolygon>(); // Draw relevant district fills for (Object[] resultRow : resultData) { ReferenceDto regionOrDistrict = (ReferenceDto) resultRow[1]; String shapeUuid = regionOrDistrict.getUuid(); BigDecimal regionOrDistrictValue = new BigDecimal(((Number) resultRow[0]).longValue()); GeoLatLon[][] shape; switch (visualizationComponent.getVisualizationMapType()) { case REGIONS: shape = FacadeProvider.getGeoShapeProvider().getRegionShape(new RegionReferenceDto(shapeUuid)); break; case DISTRICTS: shape = FacadeProvider.getGeoShapeProvider().getDistrictShape(new DistrictReferenceDto(shapeUuid)); break; default: throw new IllegalArgumentException(visualizationComponent.getVisualizationMapType().toString()); } if (shape == null) { continue; } for (int part = 0; part < shape.length; part++) { GeoLatLon[] shapePart = shape[part]; String fillColor; if (regionOrDistrictValue.compareTo(BigDecimal.ZERO) == 0) { fillColor = "#000"; } else if (regionOrDistrictValue.compareTo(valuesLowerQuartile) < 0) { fillColor = "#FEDD6C"; } else if (regionOrDistrictValue.compareTo(valuesMedian) < 0) { fillColor = "#FDBF44"; } else if (regionOrDistrictValue.compareTo(valuesUpperQuartile) < 0) { fillColor = "#F47B20"; } else { fillColor = "#ED1B24"; } LeafletPolygon polygon = new LeafletPolygon(); polygon.setCaption(regionOrDistrict.getCaption() + "<br>" + regionOrDistrictValue); // fillOpacity is used, so we can still hover the region polygon.setOptions("{\"stroke\": false, \"color\": '" + fillColor + "', \"fillOpacity\": 0.8}"); polygon.setLatLons(shapePart); resultPolygons.add(polygon); } } map.addPolygonGroup("results", resultPolygons); mapLayout.addComponent(map); mapLayout.setExpandRatio(map, 1); AbstractOrderedLayout regionLegend = DashboardMapComponent.buildRegionLegend(true, CaseMeasure.CASE_COUNT, false, valuesLowerQuartile, valuesMedian, valuesUpperQuartile); Label legendHeader = new Label(I18nProperties.getCaption(Captions.dashboardMapKey)); CssStyles.style(legendHeader, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE); regionLegend.addComponent(legendHeader, 0); mapLayout.addComponent(regionLegend); mapLayout.setExpandRatio(regionLegend, 0); resultsLayout.addComponent(mapLayout); resultsLayout.setExpandRatio(mapLayout, 1); }
From source file:de.symeda.sormas.ui.task.TaskGridComponent.java
License:Open Source License
public HorizontalLayout createFilterBar() { HorizontalLayout filterLayout = new HorizontalLayout(); filterLayout.setMargin(false); filterLayout.setSpacing(true);//from w w w.ja v a2s . c o m filterLayout.setSizeUndefined(); statusFilter = new ComboBox(); statusFilter.setWidth(200, Unit.PIXELS); statusFilter.setInputPrompt(I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.TASK_STATUS)); statusFilter.addItems((Object[]) TaskStatus.values()); statusFilter.addValueChangeListener(e -> { criteria.taskStatus((TaskStatus) e.getProperty().getValue()); tasksView.navigateTo(criteria); }); filterLayout.addComponent(statusFilter); resetButton = new Button(I18nProperties.getCaption(Captions.actionResetFilters)); resetButton.setVisible(false); resetButton.addClickListener(event -> { ViewModelProviders.of(TasksView.class).remove(TaskCriteria.class); tasksView.navigateTo(null); }); filterLayout.addComponent(resetButton); return filterLayout; }
From source file:de.symeda.sormas.ui.task.TaskGridComponent.java
License:Open Source License
public HorizontalLayout createAssigneeFilterBar() { HorizontalLayout assigneeFilterLayout = new HorizontalLayout(); assigneeFilterLayout.setMargin(false); assigneeFilterLayout.setSpacing(true); assigneeFilterLayout.setWidth(100, Unit.PERCENTAGE); assigneeFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); HorizontalLayout buttonFilterLayout = new HorizontalLayout(); buttonFilterLayout.setSpacing(true); {//w w w .j a v a 2s. c o m Button allTasks = new Button(I18nProperties.getCaption(Captions.all), e -> processAssigneeFilterChange(null)); CssStyles.style(allTasks, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER); allTasks.setCaptionAsHtml(true); buttonFilterLayout.addComponent(allTasks); statusButtons.put(allTasks, I18nProperties.getCaption(Captions.all)); Button officerTasks = new Button(I18nProperties.getCaption(Captions.taskOfficerTasks), e -> processAssigneeFilterChange(OFFICER_TASKS)); initializeStatusButton(officerTasks, buttonFilterLayout, OFFICER_TASKS, I18nProperties.getCaption(Captions.taskOfficerTasks)); Button myTasks = new Button(I18nProperties.getCaption(Captions.taskMyTasks), e -> processAssigneeFilterChange(MY_TASKS)); initializeStatusButton(myTasks, buttonFilterLayout, MY_TASKS, I18nProperties.getCaption(Captions.taskMyTasks)); // Default filter for lab users (that don't have any other role) is "My tasks" if ((UserProvider.getCurrent().hasUserRole(UserRole.LAB_USER) || UserProvider.getCurrent().hasUserRole(UserRole.EXTERNAL_LAB_USER)) && UserProvider.getCurrent().getUserRoles().size() == 1) { activeStatusButton = myTasks; } else { activeStatusButton = allTasks; } } assigneeFilterLayout.addComponent(buttonFilterLayout); HorizontalLayout actionButtonsLayout = new HorizontalLayout(); actionButtonsLayout.setSpacing(true); { // Show archived/active cases button if (UserProvider.getCurrent().hasUserRight(UserRight.TASK_VIEW_ARCHIVED)) { switchArchivedActiveButton = new Button( I18nProperties.getCaption(I18nProperties.getCaption(Captions.taskShowArchived))); switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK); switchArchivedActiveButton.addClickListener(e -> { criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE); tasksView.navigateTo(criteria); }); actionButtonsLayout.addComponent(switchArchivedActiveButton); } // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { assigneeFilterLayout.setWidth(100, Unit.PERCENTAGE); MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command deleteCommand = selectedItem -> { ControllerProvider.getTaskController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); actionButtonsLayout.addComponent(bulkOperationsDropdown); } } assigneeFilterLayout.addComponent(actionButtonsLayout); assigneeFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT); assigneeFilterLayout.setExpandRatio(actionButtonsLayout, 1); return assigneeFilterLayout; }