List of usage examples for com.vaadin.ui Button removeStyleName
@Override public void removeStyleName(String style)
From source file:com.adonis.ui.menu.Menu.java
/** * Highlights a view navigation button as the currently active view in the * menu. This method does not perform the actual navigation. * * @param viewName the name of the view to show as active *///from w w w . ja va2s. c om public void setActiveView(String viewName) { for (Button button : viewButtons.values()) { button.removeStyleName("selected"); } Button selected = viewButtons.get(viewName); if (selected != null) { selected.addStyleName("selected"); } menuPart.removeStyleName(VALO_MENU_VISIBLE); }
From source file:com.esofthead.mycollab.module.crm.view.CrmToolbar.java
License:Open Source License
public void gotoItem(final String crmItem) { for (final Iterator<com.vaadin.ui.Component> it = this.iterator(); it.hasNext();) { final Button btn = (Button) it.next(); if (crmItem.equals(btn.getCaption())) { btn.addStyleName("isSelected"); } else {/* w w w .ja v a 2 s .c o m*/ btn.removeStyleName("isSelected"); } } }
From source file:com.esofthead.mycollab.vaadin.ui.ToggleButtonGroup.java
License:Open Source License
public void setDefaultButton(Button button) { Iterator<Component> iterator = ToggleButtonGroup.this.iterator(); while (iterator.hasNext()) { Button currentBtn = (Button) iterator.next(); if (currentBtn.equals(button)) { selectedBtn = button;//from w w w .j a v a2s. co m selectedBtn.addStyleName(UIConstants.BTN_ACTIVE); } else { currentBtn.removeStyleName(UIConstants.BTN_ACTIVE); } } }
From source file:com.esofthead.mycollab.vaadin.web.ui.ToggleButtonGroup.java
License:Open Source License
public ButtonGroup withDefaultButton(Button button) { Iterator<Component> iterator = ToggleButtonGroup.this.iterator(); while (iterator.hasNext()) { Button currentBtn = (Button) iterator.next(); if (currentBtn.equals(button)) { selectedBtn = button;//from w ww . j ava2 s. c o m selectedBtn.addStyleName(UIConstants.BTN_ACTIVE); } else { currentBtn.removeStyleName(UIConstants.BTN_ACTIVE); } } return this; }
From source file:com.mycollab.vaadin.web.ui.ToggleButtonGroup.java
License:Open Source License
public ButtonGroup withDefaultButton(Button button) { Iterator<Component> iterator = ToggleButtonGroup.this.iterator(); while (iterator.hasNext()) { Button currentBtn = (Button) iterator.next(); if (currentBtn.equals(button)) { selectedBtn = button;//from ww w.j av a 2s .c om selectedBtn.addStyleName(WebThemes.BTN_ACTIVE); } else { currentBtn.removeStyleName(WebThemes.BTN_ACTIVE); } } return this; }
From source file:cz.zcu.pia.social.network.frontend.components.posts.ComponentPostPaginator.java
/** * Remove active style//w ww . ja v a 2 s .c om */ private void removeActiveStyle() { Button b = buttonList.get(curentPage); b.removeStyleName("paginator-active"); }
From source file:de.metas.procurement.webui.ui.view.WeeklyDetailedReportingView.java
License:Open Source License
private final void updateUI_NextWeekTrand() { final WeekProductQtyReport weekQtyReport = weekQtyReportItem == null ? null : weekQtyReportItem.getBean(); final Trend nextWeekTrend = weekQtyReport == null ? null : weekQtyReport.getNextWeekTrend(); for (Map.Entry<Trend, Button> e : trend2button.entrySet()) { final Trend trend = e.getKey(); final Button button = e.getValue(); if (Objects.equal(nextWeekTrend, trend)) { button.addStyleName(STYLE_CurrentTrend); } else {/*from w w w .j av a2 s . c om*/ button.removeStyleName(STYLE_CurrentTrend); } } }
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 . jav a 2 s . co 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.ContactsView.java
License:Open Source License
public VerticalLayout createFilterBar() { VerticalLayout filterLayout = new VerticalLayout(); filterLayout.setSpacing(false);/* w w w .j a v a 2 s . co m*/ 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.Menu.java
License:Open Source License
/** * Highlights a view navigation button as the currently active view in the * menu. This method does not perform the actual navigation. * * @param viewName/*www . jav a 2 s . c om*/ * the name of the view to show as active */ public void setActiveView(String viewName) { for (Button button : viewButtons.values()) { button.removeStyleName("selected"); } Button selected = viewButtons.get(viewName); if (selected == null && viewName.contains("/")) { // might be a sub-view viewName = viewName.substring(0, viewName.indexOf('/')); selected = viewButtons.get(viewName); } if (selected != null) { selected.addStyleName("selected"); } menuPart.removeStyleName(VALO_MENU_VISIBLE); }