List of usage examples for com.vaadin.ui VerticalLayout setWidth
@Override public void setWidth(float width, Unit unit)
From source file:com.lizardtech.expresszip.vaadin.FindLayersViewComponent.java
License:Apache License
public FindLayersViewComponent() { treeTable = new ExpressZipTreeTable(); popupTable = new ExpressZipTreeTable(); configureTable(treeTable);//from w ww . j ava2 s. c o m popupSelectionListener = new Property.ValueChangeListener() { private static final long serialVersionUID = 625365970493526725L; @Override public void valueChange(ValueChangeEvent event) { // the current popup selection Set<ExpressZipLayer> popupSelection = (Set<ExpressZipLayer>) event.getProperty().getValue(); // get the tree's current selection HashSet<ExpressZipLayer> treeSelection = new HashSet<ExpressZipLayer>( (Set<ExpressZipLayer>) treeTable.getValue()); // remove all items in common with popup treeSelection.removeAll(popupTable.getItemIds()); // set the treeTable selection to the union Set<ExpressZipLayer> unionSelection = new HashSet<ExpressZipLayer>(); unionSelection.addAll(popupSelection); unionSelection.addAll(treeSelection); treeTable.setValue(unionSelection); } }; popupTable.addListener(popupSelectionListener); treeTable.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 6236114836521221107L; @Override public void valueChange(ValueChangeEvent event) { Set<ExpressZipLayer> highlightedLayers = (Set<ExpressZipLayer>) event.getProperty().getValue(); for (FindLayersViewListener listener : listeners) { listener.layerHighlightedEvent(highlightedLayers); } // reset selection of popup table popupTable.removeListener(popupSelectionListener); // intersection of treeTable's selection and popupTable items Set<ExpressZipLayer> popupSelection = new HashSet<ExpressZipLayer>(); popupSelection.addAll(highlightedLayers); popupSelection.retainAll(popupTable.getItemIds()); popupTable.setValue(popupSelection); popupTable.addListener(popupSelectionListener); } }); configureTable(popupTable); filter = new Filter(this); filterButtonListener = new FilterListeners(); axisSelectedListener = new AxisSelected(); listeners = new ArrayList<FindLayersViewListener>(); btnNext = new ExpressZipButton("Next", Style.STEP); btnBack = new ExpressZipButton("Back", Style.STEP); btnAddFilter = new ExpressZipButton("Add Filter", Style.ACTION); btnAddFilter.addStyleName("filter-flow"); hshFilterButtons = new HashMap<Button, FilterObject>(); cssLayers = new CssLayout(); basemapSelector = new ComboBox(); basemapSelector.setWidth(100.0f, UNITS_PERCENTAGE); basemapSelector.setTextInputAllowed(false); basemapSelector.setImmediate(true); basemapSelector.setNullSelectionAllowed(false); basemapSelector.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -7358667131762099215L; @Override public void valueChange(ValueChangeEvent event) { ProjectedLayer l = (ProjectedLayer) basemapSelector.getValue(); boolean enableCheckbox = false; if (l instanceof WebMapServiceLayer) { for (ExpressZipLayer local : mapModel.getLocalBaseLayers()) { if (l.toString().equals(local.getName())) { enableCheckbox = true; break; } } } includeBasemap.setEnabled(enableCheckbox); if (!enableCheckbox) { includeBasemap.setValue(false); } if (mapModel.getBaseLayerTerms(l) != null && !mapModel.getBaseLayerTermsAccepted(l)) { final Window modal = new Window("Terms of Use"); modal.setModal(true); modal.setClosable(false); modal.setResizable(false); modal.getContent().setSizeUndefined(); // trick to size around content Button bOK = new ExpressZipButton("OK", Style.ACTION, new ClickListener() { private static final long serialVersionUID = -2872178665349848542L; @Override public void buttonClick(ClickEvent event) { ProjectedLayer l = (ProjectedLayer) basemapSelector.getValue(); mapModel.setBaseLayerTermsAccepted(l); for (FindLayersViewListener listener : listeners) listener.baseMapChanged(l); ((ExpressZipWindow) getApplication().getMainWindow()).removeWindow(modal); } }); Button bCancel = new ExpressZipButton("Cancel", Style.ACTION, new ClickListener() { private static final long serialVersionUID = -3044064554876422836L; @Override public void buttonClick(ClickEvent event) { basemapSelector.select(mapModel.getBaseLayers().get(0)); ((ExpressZipWindow) getApplication().getMainWindow()).removeWindow(modal); } }); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(bOK); buttons.addComponent(bCancel); Label termsText = new Label(mapModel.getBaseLayerTerms(l)); termsText.setContentMode(Label.CONTENT_XHTML); VerticalLayout vlay = new VerticalLayout(); vlay.addComponent(termsText); vlay.addComponent(buttons); vlay.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT); vlay.setWidth(400, UNITS_PIXELS); modal.getContent().addComponent(vlay); ((ExpressZipWindow) getApplication().getMainWindow()).addWindow(modal); } else { for (FindLayersViewListener listener : listeners) listener.baseMapChanged(l); } } }); includeBasemap = new CheckBox(); includeBasemap.setDescription("Include this basemap in the exported image."); includeBasemap.setWidth(64f, UNITS_PIXELS); HorizontalLayout basemapLayout = new HorizontalLayout(); basemapLayout.setWidth(100f, UNITS_PERCENTAGE); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSizeFull(); setSizeFull(); Label step = new Label("Step 1: Select Layers"); step.addStyleName("step"); layout.addComponent(step); layout.addComponent(treeTable); layout.setSpacing(true); treeTable.setSizeFull(); layout.setExpandRatio(treeTable, 1f); layout.addComponent(new Panel(BASEMAP, basemapLayout)); basemapLayout.addComponent(basemapSelector); basemapLayout.setExpandRatio(basemapSelector, 1f); basemapLayout.addComponent(includeBasemap); layout.addComponent(cssLayers); cssLayers.addComponent(btnAddFilter); HorizontalLayout backSubmitLayout = new HorizontalLayout(); backSubmitLayout.setWidth("100%"); backSubmitLayout.addComponent(btnBack); backSubmitLayout.addComponent(btnNext); backSubmitLayout.setComponentAlignment(btnBack, Alignment.BOTTOM_LEFT); backSubmitLayout.setComponentAlignment(btnNext, Alignment.BOTTOM_RIGHT); VerticalLayout navLayout = new VerticalLayout(); navLayout.addComponent(backSubmitLayout); navLayout.setSpacing(true); ThemeResource banner = new ThemeResource("img/ProgressBar1.png"); navLayout.addComponent(new Embedded(null, banner)); layout.addComponent(navLayout); layout.setComponentAlignment(navLayout, Alignment.BOTTOM_CENTER); btnNext.addListener(this); btnNext.setEnabled(false); btnBack.setEnabled(false); // always disabled btnAddFilter.addListener(this); layout.addStyleName("findlayers"); setCompositionRoot(layout); }
From source file:de.fatalix.bookery.view.admin.AdminView.java
License:Open Source License
public HorizontalLayout createUserManagement() { userManagementLayout = new HorizontalLayout(); userManagementLayout.addStyleName("wrapping"); userManagementLayout.setSpacing(true); userManagementLayout.setMargin(true); Label label = new Label("Add new user..."); label.setSizeUndefined();/*from www . j a v a 2 s . co m*/ label.addStyleName(ValoTheme.LABEL_LARGE); VerticalLayout emptyLayout = new VerticalLayout(label); emptyLayout.addStyleName("dashed-border"); emptyLayout.setWidth(380, Unit.PIXELS); emptyLayout.setHeight(220, Unit.PIXELS); emptyLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); emptyLayout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { AppUser appUser = presenter.createNewUser(); AppUserCard appUserCard = appUserCardInstances.get(); appUserCard.loadAppUser(appUser); appUserCard.addAppUserCardListener(AdminView.this); userManagementLayout.addComponent(appUserCard, userManagementLayout.getComponentCount() - 1); } }); userManagementLayout.addComponent(emptyLayout); return userManagementLayout; }
From source file:de.fatalix.bookery.view.admin.BatchJobsLayout.java
private Layout createEmptyLayout() { Label label = new Label("Add new job..."); label.setSizeUndefined();/*from w ww . j a v a2 s .c o m*/ label.addStyleName(ValoTheme.LABEL_LARGE); VerticalLayout emptyLayout = new VerticalLayout(label); emptyLayout.addStyleName("dashed-border"); emptyLayout.setWidth(380, Unit.PIXELS); emptyLayout.setHeight(220, Unit.PIXELS); emptyLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); emptyLayout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { BatchJobConfiguration jobConfig = presenter.createBatchJob(); BatchJobCard batchJobCard = batchJobCardInstances.get(); batchJobCard.load(jobConfig); batchJobCard.addBatchJobCardListener(BatchJobsLayout.this); batchJobLayout.addComponent(batchJobCard, batchJobLayout.getComponentCount() - 1); } }); return emptyLayout; }
From source file:de.symeda.sormas.ui.caze.CaseDataView.java
License:Open Source License
@Override public void enter(ViewChangeEvent event) { super.enter(event); setHeightUndefined();/*from w ww . j a v a2s . c o m*/ CaseDataDto caze = FacadeProvider.getCaseFacade().getCaseDataByUuid(getCaseRef().getUuid()); String htmlLayout = LayoutUtil.fluidRow(LayoutUtil.fluidColumnLoc(8, 0, 12, 0, CASE_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, TASKS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SAMPLES_LOC)); VerticalLayout container = new VerticalLayout(); container.setWidth(100, Unit.PERCENTAGE); container.setMargin(true); setSubComponent(container); CustomLayout layout = new CustomLayout(); layout.addStyleName(CssStyles.ROOT_COMPONENT); layout.setTemplateContents(htmlLayout); layout.setWidth(100, Unit.PERCENTAGE); layout.setHeightUndefined(); container.addComponent(layout); CommitDiscardWrapperComponent<?> editComponent; if (getViewMode() == ViewMode.SIMPLE) { editComponent = ControllerProvider.getCaseController() .getCaseCombinedEditComponent(getCaseRef().getUuid(), ViewMode.SIMPLE); } else { editComponent = ControllerProvider.getCaseController().getCaseDataEditComponent(getCaseRef().getUuid(), ViewMode.NORMAL); } // setSubComponent(editComponent); editComponent.setMargin(false); editComponent.setWidth(100, Unit.PERCENTAGE); editComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE); editComponent.addStyleName(CssStyles.MAIN_COMPONENT); layout.addComponent(editComponent, CASE_LOC); TaskListComponent taskList = new TaskListComponent(TaskContext.CASE, getCaseRef()); taskList.addStyleName(CssStyles.SIDE_COMPONENT); layout.addComponent(taskList, TASKS_LOC); if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_VIEW) && !caze.isUnreferredPortHealthCase()) { SampleListComponent sampleList = new SampleListComponent(getCaseRef()); sampleList.addStyleName(CssStyles.SIDE_COMPONENT); layout.addComponent(sampleList, SAMPLES_LOC); } }
From source file:de.symeda.sormas.ui.caze.CasesView.java
License:Open Source License
public CasesView() { super(VIEW_NAME); originalViewTitle = getViewTitleLabel().getValue(); criteria = ViewModelProviders.of(CasesView.class).get(CaseCriteria.class); if (criteria.getArchived() == null) { criteria.archived(false);//from ww w . j a va2s .c om } grid = new CaseGrid(); grid.setCriteria(criteria); gridLayout = new VerticalLayout(); gridLayout.addComponent(createFilterBar()); gridLayout.addComponent(createStatusFilterBar()); gridLayout.addComponent(grid); gridLayout.setMargin(true); gridLayout.setSpacing(false); gridLayout.setSizeFull(); gridLayout.setExpandRatio(grid, 1); gridLayout.setStyleName("crud-main-layout"); grid.getDataProvider().addDataProviderListener(e -> updateStatusButtons()); if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_IMPORT)) { Button importButton = new Button(I18nProperties.getCaption(Captions.actionImport)); importButton.addStyleName(ValoTheme.BUTTON_PRIMARY); importButton.setIcon(VaadinIcons.UPLOAD); importButton.addClickListener(e -> { Window popupWindow = VaadinUiUtil.showPopupWindow(new CaseImportLayout()); popupWindow.setCaption(I18nProperties.getString(Strings.headingImportCases)); popupWindow.addCloseListener(c -> { grid.reload(); }); }); addHeaderComponent(importButton); } if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_EXPORT)) { PopupButton exportButton = new PopupButton(I18nProperties.getCaption(Captions.export)); exportButton.setId("export"); exportButton.setIcon(VaadinIcons.DOWNLOAD); VerticalLayout exportLayout = new VerticalLayout(); exportLayout.setSpacing(true); exportLayout.setMargin(true); exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL); exportLayout.setWidth(200, Unit.PIXELS); exportButton.setContent(exportLayout); addHeaderComponent(exportButton); Button basicExportButton = new Button(I18nProperties.getCaption(Captions.exportBasic)); basicExportButton.setId("basicExport"); basicExportButton.setDescription(I18nProperties.getString(Strings.infoBasicExport)); basicExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); basicExportButton.setIcon(VaadinIcons.TABLE); basicExportButton.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(basicExportButton); StreamResource streamResource = new GridExportStreamResource(grid, "sormas_cases", "sormas_cases_" + DateHelper.formatDateForExport(new Date()) + ".csv"); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(basicExportButton); Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed)); extendedExportButton.setId("extendedExport"); extendedExportButton.setDescription(I18nProperties.getString(Strings.infoDetailedExport)); extendedExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); extendedExportButton.setIcon(VaadinIcons.FILE_TEXT); extendedExportButton.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(extendedExportButton); StreamResource extendedExportStreamResource = DownloadUtil.createCsvExportStreamResource( CaseExportDto.class, (Integer start, Integer max) -> FacadeProvider.getCaseFacade() .getExportList(UserProvider.getCurrent().getUuid(), grid.getCriteria(), start, max), (propertyId, type) -> { String caption = I18nProperties.getPrefixCaption(CaseExportDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(EpiDataDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption( HospitalizationDto.I18N_PREFIX, propertyId)))))); if (Date.class.isAssignableFrom(type)) { caption += " (" + DateHelper.getLocalShortDatePattern() + ")"; } return caption; }, "sormas_cases_" + DateHelper.formatDateForExport(new Date()) + ".csv"); new FileDownloader(extendedExportStreamResource).extend(extendedExportButton); Button sampleExportButton = new Button(I18nProperties.getCaption(Captions.exportSamples)); sampleExportButton.setId("sampleExport"); sampleExportButton.setDescription(I18nProperties.getString(Strings.infoSampleExport)); sampleExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); sampleExportButton.setIcon(VaadinIcons.FILE_TEXT); sampleExportButton.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(sampleExportButton); StreamResource sampleExportStreamResource = DownloadUtil.createCsvExportStreamResource( SampleExportDto.class, (Integer start, Integer max) -> FacadeProvider.getSampleFacade() .getExportList(UserProvider.getCurrent().getUuid(), grid.getCriteria(), start, max), (propertyId, type) -> { String caption = I18nProperties.getPrefixCaption(SampleExportDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption( AdditionalTestDto.I18N_PREFIX, propertyId))))); if (Date.class.isAssignableFrom(type)) { caption += " (" + DateHelper.getLocalShortDatePattern() + ")"; } return caption; }, "sormas_samples_" + DateHelper.formatDateForExport(new Date()) + ".csv"); new FileDownloader(sampleExportStreamResource).extend(sampleExportButton); // Warning if no filters have been selected Label warningLabel = new Label(I18nProperties.getString(Strings.infoExportNoFilters), ContentMode.HTML); warningLabel.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(warningLabel); warningLabel.setVisible(false); exportButton.addClickListener(e -> { warningLabel.setVisible(!criteria.hasAnyFilterActive()); }); } if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_MERGE)) { Button mergeDuplicatesButton = new Button(I18nProperties.getCaption(Captions.caseMergeDuplicates)); mergeDuplicatesButton.setId("mergeDuplicates"); mergeDuplicatesButton.setIcon(VaadinIcons.COMPRESS_SQUARE); mergeDuplicatesButton .addClickListener(e -> ControllerProvider.getCaseController().navigateToMergeCasesView()); addHeaderComponent(mergeDuplicatesButton); } if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_CREATE)) { createButton = new Button(I18nProperties.getCaption(Captions.caseNewCase)); createButton.setId("create"); createButton.addStyleName(ValoTheme.BUTTON_PRIMARY); createButton.setIcon(VaadinIcons.PLUS_CIRCLE); createButton.addClickListener(e -> ControllerProvider.getCaseController().create()); addHeaderComponent(createButton); } addComponent(gridLayout); }
From source file:de.symeda.sormas.ui.caze.CasesView.java
License:Open Source License
public VerticalLayout createFilterBar() { VerticalLayout filterLayout = new VerticalLayout(); filterLayout.setSpacing(false);//w ww. j av a 2 s. c o m filterLayout.setMargin(false); filterLayout.setWidth(100, Unit.PERCENTAGE); firstFilterRowLayout = new HorizontalLayout(); firstFilterRowLayout.setMargin(false); firstFilterRowLayout.setSpacing(true); firstFilterRowLayout.setSizeUndefined(); { if (!UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) { caseOriginFilter = new ComboBox(); caseOriginFilter.setId(CaseDataDto.CASE_ORIGIN); caseOriginFilter.setWidth(140, Unit.PIXELS); caseOriginFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CASE_ORIGIN)); caseOriginFilter.addItems((Object[]) CaseOrigin.values()); caseOriginFilter.addValueChangeListener(e -> { criteria.caseOrigin(((CaseOrigin) e.getProperty().getValue())); if (UserProvider.getCurrent().hasUserRight(UserRight.PORT_HEALTH_INFO_VIEW)) { pointOfEntryFilter.setEnabled(e.getProperty().getValue() != CaseOrigin.IN_COUNTRY); portHealthCasesWithoutFacilityFilter .setEnabled(e.getProperty().getValue() != CaseOrigin.IN_COUNTRY); } navigateTo(criteria); }); firstFilterRowLayout.addComponent(caseOriginFilter); } outcomeFilter = new ComboBox(); outcomeFilter.setId(CaseDataDto.OUTCOME); outcomeFilter.setWidth(140, Unit.PIXELS); outcomeFilter .setInputPrompt(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.OUTCOME)); outcomeFilter.addItems((Object[]) CaseOutcome.values()); outcomeFilter.addValueChangeListener(e -> { criteria.outcome(((CaseOutcome) e.getProperty().getValue())); navigateTo(criteria); }); firstFilterRowLayout.addComponent(outcomeFilter); diseaseFilter = new ComboBox(); diseaseFilter.setId(CaseDataDto.DISEASE); 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())); navigateTo(criteria); }); firstFilterRowLayout.addComponent(diseaseFilter); classificationFilter = new ComboBox(); classificationFilter.setId(CaseDataDto.CASE_CLASSIFICATION); 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())); navigateTo(criteria); }); firstFilterRowLayout.addComponent(classificationFilter); searchField = new TextField(); searchField.setId("search"); searchField.setWidth(200, Unit.PIXELS); searchField.setNullRepresentation(""); searchField.setInputPrompt(I18nProperties.getString(Strings.promptCasesSearchField)); searchField.addTextChangeListener(e -> { criteria.nameUuidEpidNumberLike(e.getText()); grid.reload(); }); firstFilterRowLayout.addComponent(searchField); addShowMoreOrLessFiltersButtons(firstFilterRowLayout); resetButton = new Button(I18nProperties.getCaption(Captions.actionResetFilters)); resetButton.setId("reset"); resetButton.setVisible(false); resetButton.addClickListener(event -> { ViewModelProviders.of(CasesView.class).remove(CaseCriteria.class); navigateTo(null); }); firstFilterRowLayout.addComponent(resetButton); } filterLayout.addComponent(firstFilterRowLayout); secondFilterRowLayout = new HorizontalLayout(); secondFilterRowLayout.setMargin(false); secondFilterRowLayout.setSpacing(true); secondFilterRowLayout.setSizeUndefined(); { presentConditionFilter = new ComboBox(); presentConditionFilter.setWidth(140, Unit.PIXELS); presentConditionFilter.setInputPrompt( I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.PRESENT_CONDITION)); presentConditionFilter.addItems((Object[]) PresentCondition.values()); presentConditionFilter.addValueChangeListener(e -> { criteria.presentCondition(((PresentCondition) e.getProperty().getValue())); navigateTo(criteria); }); secondFilterRowLayout.addComponent(presentConditionFilter); UserDto user = UserProvider.getCurrent().getUser(); 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); navigateTo(criteria); }); secondFilterRowLayout.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 -> { DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue(); criteria.district(district); navigateTo(criteria); }); if (user.getRegion() != null && user.getDistrict() == 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); } secondFilterRowLayout.addComponent(districtFilter); if (!UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) { facilityFilter = new ComboBox(); facilityFilter.setWidth(140, Unit.PIXELS); facilityFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.HEALTH_FACILITY)); facilityFilter.setDescription(I18nProperties.getDescription(Descriptions.descFacilityFilter)); facilityFilter.addValueChangeListener(e -> { criteria.healthFacility(((FacilityReferenceDto) e.getProperty().getValue())); navigateTo(criteria); }); facilityFilter.setEnabled(false); secondFilterRowLayout.addComponent(facilityFilter); } if (UserProvider.getCurrent().hasUserRight(UserRight.PORT_HEALTH_INFO_VIEW)) { pointOfEntryFilter = new ComboBox(); pointOfEntryFilter.setWidth(140, Unit.PIXELS); pointOfEntryFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.POINT_OF_ENTRY)); pointOfEntryFilter .setDescription(I18nProperties.getDescription(Descriptions.descPointOfEntryFilter)); pointOfEntryFilter.addValueChangeListener(e -> { criteria.pointOfEntry(((PointOfEntryReferenceDto) e.getProperty().getValue())); navigateTo(criteria); }); secondFilterRowLayout.addComponent(pointOfEntryFilter); } districtFilter.addValueChangeListener(e -> { if (facilityFilter != null) { facilityFilter.removeAllItems(); DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue(); if (district != null) { facilityFilter.addItems( FacadeProvider.getFacilityFacade().getHealthFacilitiesByDistrict(district, true)); facilityFilter.setEnabled(true); } else { facilityFilter.setEnabled(false); } } if (pointOfEntryFilter != null) { pointOfEntryFilter.removeAllItems(); DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue(); if (district != null) { pointOfEntryFilter.addItems( FacadeProvider.getPointOfEntryFacade().getAllByDistrict(district.getUuid(), true)); pointOfEntryFilter.setEnabled( caseOriginFilter == null || caseOriginFilter.getValue() != CaseOrigin.IN_COUNTRY); } else { pointOfEntryFilter.setEnabled(false); } } }); officerFilter = new ComboBox(); officerFilter.setWidth(140, Unit.PIXELS); officerFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.SURVEILLANCE_OFFICER)); if (user.getRegion() != null) { officerFilter.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(user.getRegion(), UserRole.SURVEILLANCE_OFFICER)); } officerFilter.addValueChangeListener(e -> { criteria.surveillanceOfficer(((UserReferenceDto) e.getProperty().getValue())); navigateTo(criteria); }); secondFilterRowLayout.addComponent(officerFilter); reportedByFilter = new ComboBox(); reportedByFilter.setWidth(140, Unit.PIXELS); reportedByFilter.setInputPrompt(I18nProperties.getString(Strings.reportedBy)); reportedByFilter.addItems((Object[]) UserRole.values()); reportedByFilter.addValueChangeListener(e -> { criteria.reportingUserRole((UserRole) e.getProperty().getValue()); navigateTo(criteria); }); secondFilterRowLayout.addComponent(reportedByFilter); reportingUserFilter = new TextField(); reportingUserFilter.setWidth(200, Unit.PIXELS); reportingUserFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REPORTING_USER)); reportingUserFilter.setNullRepresentation(""); reportingUserFilter.addTextChangeListener(e -> { criteria.reportingUserLike(e.getText()); grid.reload(); }); secondFilterRowLayout.addComponent(reportingUserFilter); } filterLayout.addComponent(secondFilterRowLayout); secondFilterRowLayout.setVisible(false); thirdFilterRowLayout = new HorizontalLayout(); thirdFilterRowLayout.setMargin(false); thirdFilterRowLayout.setSpacing(true); thirdFilterRowLayout.setSizeUndefined(); CssStyles.style(thirdFilterRowLayout, CssStyles.VSPACE_3); { casesWithoutGeoCoordsFilter = new CheckBox(); CssStyles.style(casesWithoutGeoCoordsFilter, CssStyles.CHECKBOX_FILTER_INLINE); casesWithoutGeoCoordsFilter.setCaption(I18nProperties.getCaption(Captions.caseFilterWithoutGeo)); casesWithoutGeoCoordsFilter .setDescription(I18nProperties.getDescription(Descriptions.descCaseFilterWithoutGeo)); casesWithoutGeoCoordsFilter.addValueChangeListener(e -> { criteria.mustHaveNoGeoCoordinates((Boolean) e.getProperty().getValue()); navigateTo(criteria); }); thirdFilterRowLayout.addComponent(casesWithoutGeoCoordsFilter); if (UserProvider.getCurrent().hasUserRight(UserRight.PORT_HEALTH_INFO_VIEW)) { portHealthCasesWithoutFacilityFilter = new CheckBox(); CssStyles.style(portHealthCasesWithoutFacilityFilter, CssStyles.CHECKBOX_FILTER_INLINE); portHealthCasesWithoutFacilityFilter .setCaption(I18nProperties.getCaption(Captions.caseFilterPortHealthWithoutFacility)); portHealthCasesWithoutFacilityFilter.setDescription( I18nProperties.getDescription(Descriptions.descCaseFilterPortHealthWithoutFacility)); portHealthCasesWithoutFacilityFilter.addValueChangeListener(e -> { criteria.mustBePortHealthCaseWithoutFacility((Boolean) e.getProperty().getValue()); navigateTo(criteria); }); thirdFilterRowLayout.addComponent(portHealthCasesWithoutFacilityFilter); } } filterLayout.addComponent(thirdFilterRowLayout); thirdFilterRowLayout.setVisible(false); dateFilterRowLayout = new HorizontalLayout(); dateFilterRowLayout.setSpacing(true); dateFilterRowLayout.setSizeUndefined(); { Button applyButton = new Button(I18nProperties.getCaption(Captions.actionApplyDateFilter)); weekAndDateFilter = new EpiWeekAndDateFilterComponent<>(applyButton, false, false, I18nProperties.getString(Strings.infoCaseDate), NewCaseDateType.class, I18nProperties.getString(Strings.promptNewCaseDateType), NewCaseDateType.MOST_RELEVANT); weekAndDateFilter.getWeekFromFilter() .setInputPrompt(I18nProperties.getString(Strings.promptCasesEpiWeekFrom)); weekAndDateFilter.getWeekToFilter() .setInputPrompt(I18nProperties.getString(Strings.promptCasesEpiWeekTo)); weekAndDateFilter.getDateFromFilter() .setInputPrompt(I18nProperties.getString(Strings.promptCasesDateFrom)); weekAndDateFilter.getDateToFilter().setInputPrompt(I18nProperties.getString(Strings.promptDateTo)); dateFilterRowLayout.addComponent(weekAndDateFilter); dateFilterRowLayout.addComponent(applyButton); applyButton.addClickListener(e -> { DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter() .getValue(); Date fromDate, toDate; if (dateFilterOption == DateFilterOption.DATE) { fromDate = DateHelper.getStartOfDay(weekAndDateFilter.getDateFromFilter().getValue()); toDate = DateHelper.getEndOfDay(weekAndDateFilter.getDateToFilter().getValue()); } else { fromDate = DateHelper .getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue()); toDate = DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue()); } if ((fromDate != null && toDate != null) || (fromDate == null && toDate == null)) { applyButton.removeStyleName(ValoTheme.BUTTON_PRIMARY); NewCaseDateType newCaseDateType = (NewCaseDateType) weekAndDateFilter.getDateTypeSelector() .getValue(); criteria.newCaseDateBetween(fromDate, toDate, newCaseDateType != null ? newCaseDateType : NewCaseDateType.MOST_RELEVANT); navigateTo(criteria); } else { if (dateFilterOption == DateFilterOption.DATE) { Notification notification = new Notification( I18nProperties.getString(Strings.headingMissingDateFilter), I18nProperties.getString(Strings.messageMissingDateFilter), Type.WARNING_MESSAGE, false); notification.setDelayMsec(-1); notification.show(Page.getCurrent()); } else { Notification notification = new Notification( I18nProperties.getString(Strings.headingMissingEpiWeekFilter), I18nProperties.getString(Strings.messageMissingEpiWeekFilter), Type.WARNING_MESSAGE, false); notification.setDelayMsec(-1); notification.show(Page.getCurrent()); } } }); } filterLayout.addComponent(dateFilterRowLayout); dateFilterRowLayout.setVisible(false); return filterLayout; }
From source file:de.symeda.sormas.ui.contact.ContactDataView.java
License:Open Source License
@Override public void enter(ViewChangeEvent event) { super.enter(event); setHeightUndefined();//ww w . j av a 2 s .c om String htmlLayout = LayoutUtil.fluidRow(LayoutUtil.fluidColumnLoc(8, 0, 12, 0, EDIT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, CASE_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, TASKS_LOC)); VerticalLayout container = new VerticalLayout(); container.setWidth(100, Unit.PERCENTAGE); container.setMargin(true); setSubComponent(container); CustomLayout layout = new CustomLayout(); layout.addStyleName(CssStyles.ROOT_COMPONENT); layout.setTemplateContents(htmlLayout); layout.setWidth(100, Unit.PERCENTAGE); layout.setHeightUndefined(); container.addComponent(layout); CommitDiscardWrapperComponent<?> editComponent = ControllerProvider.getContactController() .getContactDataEditComponent(getContactRef().getUuid()); editComponent.setMargin(false); editComponent.setWidth(100, Unit.PERCENTAGE); editComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE); editComponent.addStyleName(CssStyles.MAIN_COMPONENT); layout.addComponent(editComponent, EDIT_LOC); ContactDto contactDto = FacadeProvider.getContactFacade().getContactByUuid(getContactRef().getUuid()); CaseDataDto caseDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(contactDto.getCaze().getUuid()); CaseInfoLayout caseInfoLayout = new CaseInfoLayout(caseDto); caseInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT); layout.addComponent(caseInfoLayout, CASE_LOC); TaskListComponent taskList = new TaskListComponent(TaskContext.CONTACT, getContactRef()); taskList.addStyleName(CssStyles.SIDE_COMPONENT); layout.addComponent(taskList, TASKS_LOC); }
From source file:de.symeda.sormas.ui.contact.ContactsView.java
License:Open Source License
public ContactsView() { super(VIEW_NAME); originalViewTitle = getViewTitleLabel().getValue(); criteria = ViewModelProviders.of(ContactsView.class).get(ContactCriteria.class); if (criteria.getArchived() == null) { criteria.archived(false);//from w w w . j a v a 2s . c om } grid = new ContactGrid(); grid.setCriteria(criteria); gridLayout = new VerticalLayout(); gridLayout.addComponent(createFilterBar()); gridLayout.addComponent(createStatusFilterBar()); gridLayout.addComponent(grid); gridLayout.setMargin(true); gridLayout.setSpacing(false); gridLayout.setSizeFull(); gridLayout.setExpandRatio(grid, 1); gridLayout.setStyleName("crud-main-layout"); grid.getDataProvider().addDataProviderListener(e -> updateStatusButtons()); if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_EXPORT)) { PopupButton exportButton = new PopupButton(I18nProperties.getCaption(Captions.export)); exportButton.setIcon(VaadinIcons.DOWNLOAD); VerticalLayout exportLayout = new VerticalLayout(); exportLayout.setSpacing(true); exportLayout.setMargin(true); exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL); exportLayout.setWidth(200, Unit.PIXELS); exportButton.setContent(exportLayout); addHeaderComponent(exportButton); Button basicExportButton = new Button(I18nProperties.getCaption(Captions.exportBasic)); basicExportButton.setDescription(I18nProperties.getDescription(Descriptions.descExportButton)); basicExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); basicExportButton.setIcon(VaadinIcons.TABLE); basicExportButton.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(basicExportButton); StreamResource streamResource = new GridExportStreamResource(grid, "sormas_contacts", "sormas_contacts_" + DateHelper.formatDateForExport(new Date()) + ".csv"); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(basicExportButton); Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed)); extendedExportButton .setDescription(I18nProperties.getDescription(Descriptions.descDetailedExportButton)); extendedExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); extendedExportButton.setIcon(VaadinIcons.FILE_TEXT); extendedExportButton.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(extendedExportButton); StreamResource extendedExportStreamResource = DownloadUtil.createCsvExportStreamResource( ContactExportDto.class, (Integer start, Integer max) -> FacadeProvider.getContactFacade() .getExportList(UserProvider.getCurrent().getUuid(), grid.getCriteria(), start, max), (propertyId, type) -> { String caption = I18nProperties.getPrefixCaption(ContactExportDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, propertyId, I18nProperties.getPrefixCaption( HospitalizationDto.I18N_PREFIX, propertyId)))))); if (Date.class.isAssignableFrom(type)) { caption += " (" + DateHelper.getLocalShortDatePattern() + ")"; } return caption; }, "sormas_contacts_" + DateHelper.formatDateForExport(new Date()) + ".csv"); new FileDownloader(extendedExportStreamResource).extend(extendedExportButton); // Warning if no filters have been selected Label warningLabel = new Label(I18nProperties.getString(Strings.infoExportNoFilters)); warningLabel.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(warningLabel); warningLabel.setVisible(false); exportButton.addClickListener(e -> { warningLabel.setVisible(!criteria.hasAnyFilterActive()); }); } addComponent(gridLayout); }
From source file:de.symeda.sormas.ui.contact.ContactsView.java
License:Open Source License
public VerticalLayout createFilterBar() { VerticalLayout filterLayout = new VerticalLayout(); filterLayout.setSpacing(false);/*from w w w. ja v a 2s . com*/ filterLayout.setMargin(false); filterLayout.setWidth(100, Unit.PERCENTAGE); firstFilterRowLayout = new HorizontalLayout(); firstFilterRowLayout.setMargin(false); firstFilterRowLayout.setSpacing(true); firstFilterRowLayout.setSizeUndefined(); { classificationFilter = new ComboBox(); classificationFilter.setWidth(140, Unit.PIXELS); classificationFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.CONTACT_CLASSIFICATION)); classificationFilter.addItems((Object[]) ContactClassification.values()); classificationFilter.addValueChangeListener(e -> { criteria.contactClassification((ContactClassification) e.getProperty().getValue()); navigateTo(criteria); }); firstFilterRowLayout.addComponent(classificationFilter); diseaseFilter = new ComboBox(); diseaseFilter.setWidth(140, Unit.PIXELS); diseaseFilter.setInputPrompt( I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.CASE_DISEASE)); diseaseFilter.addItems( FacadeProvider.getDiseaseConfigurationFacade().getAllActivePrimaryDiseases().toArray()); diseaseFilter.addValueChangeListener(e -> { criteria.caseDisease(((Disease) e.getProperty().getValue())); navigateTo(criteria); }); firstFilterRowLayout.addComponent(diseaseFilter); followUpStatusFilter = new ComboBox(); followUpStatusFilter.setWidth(140, Unit.PIXELS); followUpStatusFilter.setInputPrompt( I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.FOLLOW_UP_STATUS)); followUpStatusFilter.addItems((Object[]) FollowUpStatus.values()); followUpStatusFilter.addValueChangeListener(e -> { criteria.followUpStatus(((FollowUpStatus) e.getProperty().getValue())); navigateTo(criteria); }); firstFilterRowLayout.addComponent(followUpStatusFilter); searchField = new TextField(); searchField.setWidth(200, Unit.PIXELS); searchField.setNullRepresentation(""); searchField.setInputPrompt(I18nProperties.getString(Strings.promptContactsSearchField)); searchField.addTextChangeListener(e -> { criteria.nameUuidCaseLike(e.getText()); grid.reload(); }); firstFilterRowLayout.addComponent(searchField); addShowMoreOrLessFiltersButtons(firstFilterRowLayout); resetButton = new Button(I18nProperties.getCaption(Captions.actionResetFilters)); resetButton.setVisible(false); resetButton.addClickListener(event -> { ViewModelProviders.of(ContactsView.class).remove(ContactCriteria.class); navigateTo(null); }); firstFilterRowLayout.addComponent(resetButton); } filterLayout.addComponent(firstFilterRowLayout); secondFilterRowLayout = new HorizontalLayout(); secondFilterRowLayout.setMargin(false); secondFilterRowLayout.setSpacing(true); secondFilterRowLayout.setSizeUndefined(); { UserDto user = UserProvider.getCurrent().getUser(); regionFilter = new ComboBox(); if (user.getRegion() == null) { regionFilter.setWidth(140, Unit.PIXELS); regionFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.CASE_REGION_UUID)); regionFilter.addItems(FacadeProvider.getRegionFacade().getAllAsReference()); regionFilter.addValueChangeListener(e -> { RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue(); criteria.caseRegion(region); navigateTo(criteria); }); secondFilterRowLayout.addComponent(regionFilter); } districtFilter = new ComboBox(); districtFilter.setWidth(140, Unit.PIXELS); districtFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.CASE_DISTRICT_UUID)); districtFilter.setDescription(I18nProperties.getDescription(Descriptions.descDistrictFilter)); districtFilter.addValueChangeListener(e -> { DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue(); criteria.caseDistrict(district); navigateTo(criteria); }); if (user.getRegion() != null && user.getDistrict() == 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); } secondFilterRowLayout.addComponent(districtFilter); facilityFilter = new ComboBox(); facilityFilter.setWidth(140, Unit.PIXELS); facilityFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.CASE_HEALTH_FACILITY_UUID)); facilityFilter.setDescription(I18nProperties.getDescription(Descriptions.descFacilityFilter)); facilityFilter.addValueChangeListener(e -> { FacilityReferenceDto facility = (FacilityReferenceDto) e.getProperty().getValue(); criteria.caseFacility(facility); navigateTo(criteria); }); facilityFilter.setEnabled(false); secondFilterRowLayout.addComponent(facilityFilter); districtFilter.addValueChangeListener(e -> { facilityFilter.removeAllItems(); DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue(); if (district != null) { facilityFilter.addItems( FacadeProvider.getFacilityFacade().getHealthFacilitiesByDistrict(district, true)); facilityFilter.setEnabled(true); } else { facilityFilter.setEnabled(false); } }); officerFilter = new ComboBox(); officerFilter.setWidth(140, Unit.PIXELS); officerFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.CONTACT_OFFICER_UUID)); if (user.getRegion() != null) { officerFilter.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(user.getRegion(), UserRole.CONTACT_OFFICER)); } officerFilter.addValueChangeListener(e -> { UserReferenceDto officer = (UserReferenceDto) e.getProperty().getValue(); criteria.contactOfficer(officer); navigateTo(criteria); }); secondFilterRowLayout.addComponent(officerFilter); reportedByFilter = new ComboBox(); reportedByFilter.setWidth(140, Unit.PIXELS); reportedByFilter.setInputPrompt(I18nProperties.getString(Strings.reportedBy)); reportedByFilter.addItems((Object[]) UserRole.values()); reportedByFilter.addValueChangeListener(e -> { criteria.reportingUserRole((UserRole) e.getProperty().getValue()); navigateTo(criteria); }); secondFilterRowLayout.addComponent(reportedByFilter); } filterLayout.addComponent(secondFilterRowLayout); secondFilterRowLayout.setVisible(false); dateFilterRowLayout = new HorizontalLayout(); dateFilterRowLayout.setSpacing(true); dateFilterRowLayout.setSizeUndefined(); { Button applyButton = new Button(I18nProperties.getCaption(Captions.actionApplyDateFilter)); weekAndDateFilter = new EpiWeekAndDateFilterComponent<>(applyButton, false, false, null, ContactDateType.class, I18nProperties.getString(Strings.promptContactDateType), ContactDateType.REPORT_DATE); weekAndDateFilter.getWeekFromFilter() .setInputPrompt(I18nProperties.getString(Strings.promptContactEpiWeekFrom)); weekAndDateFilter.getWeekToFilter() .setInputPrompt(I18nProperties.getString(Strings.promptContactEpiWeekTo)); weekAndDateFilter.getDateFromFilter() .setInputPrompt(I18nProperties.getString(Strings.promptContactDateFrom)); weekAndDateFilter.getDateToFilter() .setInputPrompt(I18nProperties.getString(Strings.promptContactDateTo)); dateFilterRowLayout.addComponent(weekAndDateFilter); dateFilterRowLayout.addComponent(applyButton); applyButton.addClickListener(e -> { DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter() .getValue(); Date fromDate, toDate; if (dateFilterOption == DateFilterOption.DATE) { fromDate = DateHelper.getStartOfDay(weekAndDateFilter.getDateFromFilter().getValue()); toDate = DateHelper.getEndOfDay(weekAndDateFilter.getDateToFilter().getValue()); } else { fromDate = DateHelper .getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue()); toDate = DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue()); } if ((fromDate != null && toDate != null) || (fromDate == null && toDate == null)) { applyButton.removeStyleName(ValoTheme.BUTTON_PRIMARY); ContactDateType contactDateType = (ContactDateType) weekAndDateFilter.getDateTypeSelector() .getValue(); if (contactDateType == ContactDateType.LAST_CONTACT_DATE) { criteria.lastContactDateBetween(fromDate, toDate); criteria.reportDateBetween(null, null); } else { criteria.reportDateBetween(fromDate, toDate); criteria.lastContactDateBetween(null, null); } navigateTo(criteria); } else { if (dateFilterOption == DateFilterOption.DATE) { Notification notification = new Notification( I18nProperties.getString(Strings.headingMissingDateFilter), I18nProperties.getString(Strings.messageMissingDateFilter), Type.WARNING_MESSAGE, false); notification.setDelayMsec(-1); notification.show(Page.getCurrent()); } else { Notification notification = new Notification( I18nProperties.getString(Strings.headingMissingEpiWeekFilter), I18nProperties.getString(Strings.messageMissingEpiWeekFilter), Type.WARNING_MESSAGE, false); notification.setDelayMsec(-1); notification.show(Page.getCurrent()); } } }); } filterLayout.addComponent(dateFilterRowLayout); dateFilterRowLayout.setVisible(false); return filterLayout; }
From source file:de.symeda.sormas.ui.dashboard.contacts.ContactsDashboardView.java
License:Open Source License
protected VerticalLayout createEpiCurveLayout() { if (epiCurveComponent == null) { throw new UnsupportedOperationException( "EpiCurveComponent needs to be initialized before calling createEpiCurveLayout"); }//from w w w . j a va 2 s. co m VerticalLayout layout = new VerticalLayout(); layout.setMargin(false); layout.setSpacing(false); layout.setWidth(100, Unit.PERCENTAGE); layout.setHeight(400, Unit.PIXELS); epiCurveComponent.setSizeFull(); layout.addComponent(epiCurveComponent); layout.setExpandRatio(epiCurveComponent, 1); epiCurveComponent.setExpandListener(expanded -> { if (expanded) { dashboardLayout.removeComponent(statisticsComponent); epiCurveAndMapLayout.removeComponent(mapLayout); ContactsDashboardView.this.setHeight(100, Unit.PERCENTAGE); epiCurveAndMapLayout.setHeight(100, Unit.PERCENTAGE); epiCurveLayout.setSizeFull(); } else { dashboardLayout.addComponent(statisticsComponent, 1); epiCurveAndMapLayout.addComponent(mapLayout, 1); epiCurveLayout.setHeight(400, Unit.PIXELS); ContactsDashboardView.this.setHeightUndefined(); epiCurveAndMapLayout.setHeightUndefined(); } }); return layout; }