List of usage examples for com.vaadin.ui HorizontalLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:de.symeda.sormas.ui.caze.CaseContactsView.java
License:Open Source License
public HorizontalLayout createFilterBar() { HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setSpacing(true); topLayout.setSizeUndefined();//from www . j ava 2 s . c o m classificationFilter = new ComboBox(); classificationFilter.setWidth(240, Unit.PIXELS); classificationFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.CONTACT_CLASSIFICATION)); classificationFilter.addValueChangeListener(e -> { criteria.contactClassification((ContactClassification) e.getProperty().getValue()); navigateTo(criteria); }); topLayout.addComponent(classificationFilter); districtFilter = new ComboBox(); districtFilter.setWidth(240, Unit.PIXELS); districtFilter.setInputPrompt( I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.CASE_DISTRICT_UUID)); districtFilter.addValueChangeListener(e -> { criteria.caseDistrict((DistrictReferenceDto) e.getProperty().getValue()); navigateTo(criteria); }); topLayout.addComponent(districtFilter); officerFilter = new ComboBox(); officerFilter.setWidth(240, Unit.PIXELS); officerFilter.setInputPrompt( I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.CONTACT_OFFICER_UUID)); officerFilter.addValueChangeListener(e -> { criteria.contactOfficer((UserReferenceDto) e.getProperty().getValue()); navigateTo(criteria); }); topLayout.addComponent(officerFilter); resetButton = new Button(I18nProperties.getCaption(Captions.actionResetFilters)); resetButton.setVisible(false); resetButton.addClickListener(event -> { ViewModelProviders.of(CaseContactsView.class).remove(ContactCriteria.class); navigateTo(null); }); topLayout.addComponent(resetButton); return topLayout; }
From source file:de.symeda.sormas.ui.caze.CaseContactsView.java
License:Open Source License
public HorizontalLayout createStatusFilterBar() { HorizontalLayout statusFilterLayout = new HorizontalLayout(); statusFilterLayout.setSpacing(true); statusFilterLayout.setWidth("100%"); statusFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> { criteria.contactStatus(null);//w ww .j a v a2 s . c o 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 (ContactStatus status : ContactStatus.values()) { Button statusButton = new Button(status.toString(), e -> { criteria.contactStatus(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()); } statusFilterLayout .setExpandRatio(statusFilterLayout.getComponent(statusFilterLayout.getComponentCount() - 1), 1); // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { statusFilterLayout.setWidth(100, Unit.PERCENTAGE); MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command changeCommand = selectedItem -> { ControllerProvider.getContactController().showBulkContactDataEditComponent( grid.asMultiSelect().getSelectedItems(), getCaseRef().getUuid()); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, changeCommand); Command cancelFollowUpCommand = selectedItem -> { ControllerProvider.getContactController() .cancelFollowUpOfAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp), VaadinIcons.CLOSE, cancelFollowUpCommand); Command lostToFollowUpCommand = selectedItem -> { ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp( grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp), VaadinIcons.UNLINK, lostToFollowUpCommand); Command deleteCommand = selectedItem -> { ControllerProvider.getContactController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); statusFilterLayout.addComponent(bulkOperationsDropdown); statusFilterLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT); statusFilterLayout.setExpandRatio(bulkOperationsDropdown, 1); } if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_EXPORT)) { Button exportButton = new Button(I18nProperties.getCaption(Captions.export)); exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); exportButton.setIcon(VaadinIcons.DOWNLOAD); StreamResource streamResource = new GridExportStreamResource(grid, "sormas_contacts", "sormas_contacts_" + DateHelper.formatDateForExport(new Date()) + ".csv"); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(exportButton); statusFilterLayout.addComponent(exportButton); statusFilterLayout.setComponentAlignment(exportButton, Alignment.MIDDLE_RIGHT); if (!UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { statusFilterLayout.setExpandRatio(exportButton, 1); } } if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_CREATE)) { newButton = new Button( I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, Captions.contactNewContact)); newButton.addStyleName(ValoTheme.BUTTON_PRIMARY); newButton.setIcon(VaadinIcons.PLUS_CIRCLE); newButton.addClickListener(e -> ControllerProvider.getContactController().create(this.getCaseRef())); statusFilterLayout.addComponent(newButton); statusFilterLayout.setComponentAlignment(newButton, Alignment.MIDDLE_RIGHT); } statusFilterLayout.addStyleName("top-bar"); activeStatusButton = statusAll; return statusFilterLayout; }
From source file:de.symeda.sormas.ui.caze.CaseInfoLayout.java
License:Open Source License
private void updateCaseInfo() { this.removeAllComponents(); PersonDto personDto = FacadeProvider.getPersonFacade().getPersonByUuid(caseDto.getPerson().getUuid()); VerticalLayout leftColumnLayout = new VerticalLayout(); leftColumnLayout.setMargin(false);//from w ww . j a v a 2s . c o m leftColumnLayout.setSpacing(true); { addDescLabel(leftColumnLayout, DataHelper.getShortUuid(caseDto.getUuid()), I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.UUID)) .setDescription(caseDto.getUuid()); addDescLabel(leftColumnLayout, caseDto.getEpidNumber(), I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.EPID_NUMBER)) .setDescription(caseDto.getEpidNumber()); if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) { addDescLabel(leftColumnLayout, caseDto.getPerson(), I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.PERSON)); HorizontalLayout ageSexLayout = new HorizontalLayout(); ageSexLayout.setMargin(false); ageSexLayout.setSpacing(true); addDescLabel(ageSexLayout, ApproximateAgeHelper.formatApproximateAge(personDto.getApproximateAge(), personDto.getApproximateAgeType()), I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.APPROXIMATE_AGE)); addDescLabel(ageSexLayout, personDto.getSex(), I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.SEX)); leftColumnLayout.addComponent(ageSexLayout); } if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_MANAGEMENT_ACCESS)) { addDescLabel(leftColumnLayout, caseDto.getClinicianName(), I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CLINICIAN_NAME)); } } this.addComponent(leftColumnLayout); VerticalLayout rightColumnLayout = new VerticalLayout(); rightColumnLayout.setMargin(false); rightColumnLayout.setSpacing(true); { addDescLabel(rightColumnLayout, caseDto.getDisease() != Disease.OTHER ? caseDto.getDisease().toShortString() : DataHelper.toStringNullable(caseDto.getDiseaseDetails()), I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE)); if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) { addDescLabel(rightColumnLayout, caseDto.getCaseClassification(), I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CASE_CLASSIFICATION)); addDescLabel(rightColumnLayout, DateHelper.formatLocalShortDate(caseDto.getSymptoms().getOnsetDate()), I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE)); } } this.addComponent(rightColumnLayout); }
From source file:de.symeda.sormas.ui.caze.CasesView.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.investigationStatus(null); navigateTo(criteria);//from w ww . j a va 2 s.c o m }); 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 (InvestigationStatus status : InvestigationStatus.values()) { Button statusButton = new Button(status.toString(), e -> { criteria.investigationStatus(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.CASE_VIEW_ARCHIVED)) { switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.caseShowArchived)); 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.getCaseController() .showBulkCaseDataEditComponent(grid.asMultiSelect().getSelectedItems()); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, changeCommand); Command deleteCommand = selectedItem -> { ControllerProvider.getCaseController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); Command archiveCommand = selectedItem -> { ControllerProvider.getCaseController() .archiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; archiveItem = bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.actionArchive), VaadinIcons.ARCHIVE, archiveCommand); Command dearchiveCommand = selectedItem -> { ControllerProvider.getCaseController() .dearchiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; dearchiveItem = bulkOperationsItem.addItem(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.configuration.outbreak.OutbreakRegionConfigurationForm.java
License:Open Source License
private HorizontalLayout createHeader() { HorizontalLayout headerLayout = new HorizontalLayout(); headerLayout.setWidth(100, Unit.PERCENTAGE); headerLayout.setSpacing(true); CssStyles.style(headerLayout, CssStyles.VSPACE_2); // Headline and info text Label infoTextLabel = new Label(I18nProperties.getString(Strings.headingDefineOutbreakDistricts)); infoTextLabel.setWidthUndefined();/*from w w w . j a v a 2s. c om*/ CssStyles.style(infoTextLabel, CssStyles.VSPACE_TOP_4); headerLayout.addComponent(infoTextLabel); // Number of affected districts and options to toggle outbreak mode for all districts HorizontalLayout allDistrictsLayout = new HorizontalLayout(); allDistrictsLayout.setWidthUndefined(); allDistrictsLayout.setSpacing(true); { Label allDistrictsLabel = new Label(I18nProperties.getString(Strings.headingSetOutbreakStatus)); allDistrictsLabel.setWidthUndefined(); CssStyles.style(allDistrictsLabel, CssStyles.VSPACE_TOP_4); allDistrictsLayout.addComponent(allDistrictsLabel); OptionGroup outbreakToggle = new OptionGroup(); CssStyles.style(outbreakToggle, ValoTheme.OPTIONGROUP_HORIZONTAL, CssStyles.OPTIONGROUP_HORIZONTAL_SWITCH_CRITICAL); outbreakToggle.addItem(OUTBREAK); outbreakToggle.addItem(NORMAL); if (affectedDistricts.isEmpty()) { outbreakToggle.setValue(NORMAL); } else if (affectedDistricts.size() == totalDistricts) { outbreakToggle.setValue(OUTBREAK); } outbreakToggle.addValueChangeListener(e -> { for (OptionGroup districtOutbreakToggle : outbreakToggles) { districtOutbreakToggle.setValue(e.getProperty().getValue()); } }); outbreakToggle.setWidthUndefined(); allDistrictsLayout.addComponent(outbreakToggle); affectedDistrictsNumberLabel = new Label(); affectedDistrictsNumberLabel.setWidthUndefined(); allDistrictsLayout.addComponent(affectedDistrictsNumberLabel); } headerLayout.addComponent(allDistrictsLayout); headerLayout.setComponentAlignment(allDistrictsLayout, Alignment.TOP_RIGHT); headerLayout.setExpandRatio(infoTextLabel, 1); return headerLayout; }
From source file:de.symeda.sormas.ui.contact.ContactsView.java
License:Open Source License
public HorizontalLayout createStatusFilterBar() { HorizontalLayout statusFilterLayout = new HorizontalLayout(); statusFilterLayout.setMargin(false); statusFilterLayout.setSpacing(true); statusFilterLayout.setWidth(100, Unit.PERCENTAGE); statusFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> { criteria.contactStatus(null);//from w w w . j a v a2s. c om 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 (ContactStatus status : ContactStatus.values()) { Button statusButton = new Button(status.toString(), e -> { criteria.contactStatus(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.CONTACT_VIEW_ARCHIVED)) { switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.contactShowArchived)); 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)) { statusFilterLayout.setWidth(100, Unit.PERCENTAGE); MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command changeCommand = selectedItem -> { ControllerProvider.getContactController() .showBulkContactDataEditComponent(grid.asMultiSelect().getSelectedItems(), null); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, changeCommand); Command cancelFollowUpCommand = selectedItem -> { ControllerProvider.getContactController().cancelFollowUpOfAllSelectedItems( grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp), VaadinIcons.CLOSE, cancelFollowUpCommand); Command lostToFollowUpCommand = selectedItem -> { ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp( grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp), VaadinIcons.UNLINK, lostToFollowUpCommand); Command deleteCommand = selectedItem -> { ControllerProvider.getContactController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); 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.contact.ContactVisitsView.java
License:Open Source License
public HorizontalLayout createTopBar() { HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setSpacing(true); topLayout.setWidth(100, Unit.PERCENTAGE); // statusButtons = new HashMap<>(); ////from w w w . ja v a 2s .c o m // Button contactButton = new Button(I18nProperties.getCaption(Captions.contactRelated), e -> { // grid.reload(getContactRef()); // processStatusChangeVisuals(e.getButton()); // }); // CssStyles.style(contactButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER); // contactButton.setCaptionAsHtml(true); // topLayout.addComponent(contactButton); // statusButtons.put(contactButton, I18nProperties.getCaption(Captions.contactRelated)); // // Button personButton = new Button(I18nProperties.getCaption(Captions.contactPersonVisits), e -> { // ContactDto contact = FacadeProvider.getContactFacade().getContactByUuid(getContactRef().getUuid()); // grid.reload(contact.getPerson()); // processStatusChangeVisuals(e.getButton()); // }); // CssStyles.style(personButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT); // personButton.setCaptionAsHtml(true); // topLayout.addComponent(personButton); // statusButtons.put(personButton, I18nProperties.getCaption(Captions.contactPersonVisits)); // topLayout.setExpandRatio(topLayout.getComponent(topLayout.getComponentCount()-1), 1); // 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.getVisitController() .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.VISIT_CREATE)) { newButton = new Button(I18nProperties.getCaption(Captions.visitNewVisit)); newButton.addStyleName(ValoTheme.BUTTON_PRIMARY); newButton.setIcon(VaadinIcons.PLUS_CIRCLE); newButton.addClickListener(e -> { ControllerProvider.getVisitController().createVisit(this.getContactRef(), r -> grid.reload()); }); topLayout.addComponent(newButton); topLayout.setComponentAlignment(newButton, Alignment.MIDDLE_RIGHT); } topLayout.addStyleName(CssStyles.VSPACE_3); // activeStatusButton = contactButton; return topLayout; }
From source file:de.symeda.sormas.ui.dashboard.contacts.ContactsDashboardView.java
License:Open Source License
protected HorizontalLayout createEpiCurveAndMapLayout() { HorizontalLayout layout = new HorizontalLayout(); layout.addStyleName(DashboardCssStyles.CURVE_AND_MAP_LAYOUT); layout.setWidth(100, Unit.PERCENTAGE); layout.setMargin(false);//from w ww . jav a2s.co m layout.setSpacing(false); // Epi curve layout epiCurveLayout = createEpiCurveLayout(); layout.addComponent(epiCurveLayout); // Map layout mapLayout = createMapLayout(); layout.addComponent(mapLayout); return layout; }
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); addComponent(dateFilterLayout);/*from w w w . ja v a2s. c o m*/ 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.diagram.AbstractEpiCurveComponent.java
License:Open Source License
private HorizontalLayout createHeader() { HorizontalLayout epiCurveHeaderLayout = new HorizontalLayout(); epiCurveHeaderLayout.setWidth(100, Unit.PERCENTAGE); epiCurveHeaderLayout.setSpacing(true); CssStyles.style(epiCurveHeaderLayout, CssStyles.VSPACE_4); epiCurveLabel = new Label(I18nProperties.getString(Strings.headingEpiCurve)); epiCurveLabel.setSizeUndefined();/* w w w .j a v a2 s .c o m*/ CssStyles.style(epiCurveLabel, CssStyles.H2, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE); epiCurveHeaderLayout.addComponent(epiCurveLabel); epiCurveHeaderLayout.setComponentAlignment(epiCurveLabel, Alignment.BOTTOM_LEFT); epiCurveHeaderLayout.setExpandRatio(epiCurveLabel, 1); // "Expand" and "Collapse" buttons Button expandEpiCurveButton = new Button("", VaadinIcons.EXPAND); CssStyles.style(expandEpiCurveButton, CssStyles.BUTTON_SUBTLE); expandEpiCurveButton.addStyleName(CssStyles.VSPACE_NONE); Button collapseEpiCurveButton = new Button("", VaadinIcons.COMPRESS); CssStyles.style(collapseEpiCurveButton, CssStyles.BUTTON_SUBTLE); collapseEpiCurveButton.addStyleName(CssStyles.VSPACE_NONE); expandEpiCurveButton.addClickListener(e -> { externalExpandListener.accept(true); epiCurveHeaderLayout.removeComponent(expandEpiCurveButton); epiCurveHeaderLayout.addComponent(collapseEpiCurveButton); epiCurveHeaderLayout.setComponentAlignment(collapseEpiCurveButton, Alignment.MIDDLE_RIGHT); }); collapseEpiCurveButton.addClickListener(e -> { externalExpandListener.accept(false); epiCurveHeaderLayout.removeComponent(collapseEpiCurveButton); epiCurveHeaderLayout.addComponent(expandEpiCurveButton); epiCurveHeaderLayout.setComponentAlignment(expandEpiCurveButton, Alignment.MIDDLE_RIGHT); }); epiCurveHeaderLayout.addComponent(expandEpiCurveButton); epiCurveHeaderLayout.setComponentAlignment(expandEpiCurveButton, Alignment.MIDDLE_RIGHT); return epiCurveHeaderLayout; }