List of usage examples for com.vaadin.ui Button addClickListener
public Registration addClickListener(ClickListener listener)
From source file:de.symeda.sormas.ui.statistics.StatisticsView.java
License:Open Source License
private HorizontalLayout createFilterComponentLayout() { HorizontalLayout filterComponentLayout = new HorizontalLayout(); filterComponentLayout.setSpacing(true); filterComponentLayout.setWidth(100, Unit.PERCENTAGE); StatisticsFilterComponent filterComponent = new StatisticsFilterComponent(); Button removeFilterButton = new Button(VaadinIcons.CLOSE); removeFilterButton.setDescription(I18nProperties.getCaption(Captions.statisticsRemoveFilter)); CssStyles.style(removeFilterButton, CssStyles.FORCE_CAPTION); removeFilterButton.addClickListener(e -> { filterComponents.remove(filterComponent); filtersLayout.removeComponent(filterComponentLayout); });/*from w w w .jav a 2s . c o m*/ filterComponentLayout.addComponent(removeFilterButton); filterComponents.add(filterComponent); filterComponentLayout.addComponent(filterComponent); filterComponentLayout.setExpandRatio(filterComponent, 1); return filterComponentLayout; }
From source file:de.symeda.sormas.ui.statistics.StatisticsView.java
License:Open Source License
private void addGenerateButton(VerticalLayout statisticsLayout) { Button generateButton = new Button(I18nProperties.getCaption(Captions.actionGenerate)); CssStyles.style(generateButton, ValoTheme.BUTTON_PRIMARY); generateButton.addClickListener(e -> { // Check whether there is any invalid empty filter or grouping data Notification errorNotification = null; for (StatisticsFilterComponent filterComponent : filterComponents) { if (filterComponent.getSelectedAttribute() != StatisticsCaseAttribute.REGION_DISTRICT && (filterComponent.getSelectedAttribute() == null || filterComponent.getSelectedAttribute().getSubAttributes().length > 0 && filterComponent.getSelectedSubAttribute() == null)) { errorNotification = new Notification( I18nProperties.getString(Strings.messageSpecifyFilterAttributes), Type.WARNING_MESSAGE); break; }/*from w ww. ja va2s. co m*/ } if (errorNotification == null && visualizationComponent.getRowsAttribute() != null && visualizationComponent.getRowsAttribute().getSubAttributes().length > 0 && visualizationComponent.getRowsSubAttribute() == null) { errorNotification = new Notification(I18nProperties.getString(Strings.messageSpecifyRowAttribute), Type.WARNING_MESSAGE); } else if (errorNotification == null && visualizationComponent.getColumnsAttribute() != null && visualizationComponent.getColumnsAttribute().getSubAttributes().length > 0 && visualizationComponent.getColumnsSubAttribute() == null) { errorNotification = new Notification( I18nProperties.getString(Strings.messageSpecifyColumnAttribute), Type.WARNING_MESSAGE); } if (errorNotification != null) { errorNotification.setDelayMsec(-1); errorNotification.show(Page.getCurrent()); } else { resultsLayout.removeAllComponents(); switch (visualizationComponent.getVisualizationType()) { case TABLE: generateTable(); break; case MAP: generateMap(); break; default: generateChart(); break; } } }); statisticsLayout.addComponent(generateButton); }
From source file:de.symeda.sormas.ui.symptoms.SymptomsForm.java
License:Open Source License
@Override protected void addFields() { if (disease == null || symptomsContext == null) { // workaround to stop initialization until disease is set return;//from w ww.j a v a2 s . com } // Add fields DateField onsetDateField = addField(SymptomsDto.ONSET_DATE, DateField.class); ComboBox onsetSymptom = addField(SymptomsDto.ONSET_SYMPTOM, ComboBox.class); if (symptomsContext == SymptomsContext.CASE) { onsetDateField.addValidator(new DateComparisonValidator(onsetDateField, caze.getHospitalization().getAdmissionDate(), true, false, I18nProperties.getValidationError(Validations.beforeDateSoft, onsetDateField.getCaption(), I18nProperties.getPrefixCaption(HospitalizationDto.I18N_PREFIX, HospitalizationDto.ADMISSION_DATE)))); onsetDateField.setInvalidCommitted(true); } ComboBox temperature = addField(SymptomsDto.TEMPERATURE, ComboBox.class); for (Float temperatureValue : SymptomsHelper.getTemperatureValues()) { temperature.addItem(temperatureValue); temperature.setItemCaption(temperatureValue, SymptomsHelper.getTemperatureString(temperatureValue)); } if (symptomsContext == SymptomsContext.CASE) { temperature.setCaption(I18nProperties.getCaption(Captions.symptomsMaxTemperature)); } addField(SymptomsDto.TEMPERATURE_SOURCE); ComboBox bloodPressureSystolic = addField(SymptomsDto.BLOOD_PRESSURE_SYSTOLIC, ComboBox.class); bloodPressureSystolic.addItems(SymptomsHelper.getBloodPressureValues()); ComboBox bloodPressureDiastolic = addField(SymptomsDto.BLOOD_PRESSURE_DIASTOLIC, ComboBox.class); bloodPressureDiastolic.addItems(SymptomsHelper.getBloodPressureValues()); ComboBox heartRate = addField(SymptomsDto.HEART_RATE, ComboBox.class); heartRate.addItems(SymptomsHelper.getHeartRateValues()); ComboBox respiratoryRate = addField(SymptomsDto.RESPIRATORY_RATE, ComboBox.class); respiratoryRate.addItems(SymptomsHelper.getRespiratoryRateValues()); ComboBox weight = addField(SymptomsDto.WEIGHT, ComboBox.class); for (Integer weightValue : SymptomsHelper.getWeightValues()) { weight.addItem(weightValue); weight.setItemCaption(weightValue, SymptomsHelper.getDecimalString(weightValue)); } ComboBox height = addField(SymptomsDto.HEIGHT, ComboBox.class); height.addItems(SymptomsHelper.getHeightValues()); ComboBox midUpperArmCircumference = addField(SymptomsDto.MID_UPPER_ARM_CIRCUMFERENCE, ComboBox.class); for (Integer circumferenceValue : SymptomsHelper.getMidUpperArmCircumferenceValues()) { midUpperArmCircumference.addItem(circumferenceValue); midUpperArmCircumference.setItemCaption(circumferenceValue, SymptomsHelper.getDecimalString(circumferenceValue)); } ComboBox glasgowComaScale = addField(SymptomsDto.GLASGOW_COMA_SCALE, ComboBox.class); glasgowComaScale.addItems(SymptomsHelper.getGlasgowComaScaleValues()); addFields(SymptomsDto.FEVER, SymptomsDto.VOMITING, SymptomsDto.DIARRHEA, SymptomsDto.BLOOD_IN_STOOL, SymptomsDto.NAUSEA, SymptomsDto.ABDOMINAL_PAIN, SymptomsDto.HEADACHE, SymptomsDto.MUSCLE_PAIN, SymptomsDto.FATIGUE_WEAKNESS, SymptomsDto.SKIN_RASH, SymptomsDto.NECK_STIFFNESS, SymptomsDto.SORE_THROAT, SymptomsDto.COUGH, SymptomsDto.RUNNY_NOSE, SymptomsDto.DIFFICULTY_BREATHING, SymptomsDto.CHEST_PAIN, SymptomsDto.CONJUNCTIVITIS, SymptomsDto.EYE_PAIN_LIGHT_SENSITIVE, SymptomsDto.KOPLIKS_SPOTS, SymptomsDto.THROBOCYTOPENIA, SymptomsDto.OTITIS_MEDIA, SymptomsDto.HEARINGLOSS, SymptomsDto.DEHYDRATION, SymptomsDto.ANOREXIA_APPETITE_LOSS, SymptomsDto.REFUSAL_FEEDOR_DRINK, SymptomsDto.JOINT_PAIN, SymptomsDto.HICCUPS, SymptomsDto.BACKACHE, SymptomsDto.EYES_BLEEDING, SymptomsDto.JAUNDICE, SymptomsDto.DARK_URINE, SymptomsDto.STOMACH_BLEEDING, SymptomsDto.RAPID_BREATHING, SymptomsDto.SWOLLEN_GLANDS, SymptomsDto.SYMPTOMS_COMMENTS, SymptomsDto.UNEXPLAINED_BLEEDING, SymptomsDto.GUMS_BLEEDING, SymptomsDto.INJECTION_SITE_BLEEDING, SymptomsDto.NOSE_BLEEDING, SymptomsDto.BLOODY_BLACK_STOOL, SymptomsDto.RED_BLOOD_VOMIT, SymptomsDto.DIGESTED_BLOOD_VOMIT, SymptomsDto.COUGHING_BLOOD, SymptomsDto.BLEEDING_VAGINA, SymptomsDto.SKIN_BRUISING, SymptomsDto.BLOOD_URINE, SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS, SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS_TEXT, SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS, SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT, SymptomsDto.LESIONS, SymptomsDto.LESIONS_THAT_ITCH, SymptomsDto.LESIONS_SAME_STATE, SymptomsDto.LESIONS_SAME_SIZE, SymptomsDto.LESIONS_DEEP_PROFOUND, SymptomsDto.LESIONS_FACE, SymptomsDto.LESIONS_LEGS, SymptomsDto.LESIONS_SOLES_FEET, SymptomsDto.LESIONS_PALMS_HANDS, SymptomsDto.LESIONS_THORAX, SymptomsDto.LESIONS_ARMS, SymptomsDto.LESIONS_GENITALS, SymptomsDto.LESIONS_ALL_OVER_BODY, SymptomsDto.LYMPHADENOPATHY_AXILLARY, SymptomsDto.LYMPHADENOPATHY_CERVICAL, SymptomsDto.LYMPHADENOPATHY_INGUINAL, SymptomsDto.CHILLS_SWEATS, SymptomsDto.BEDRIDDEN, SymptomsDto.ORAL_ULCERS, SymptomsDto.PAINFUL_LYMPHADENITIS, SymptomsDto.BLACKENING_DEATH_OF_TISSUE, SymptomsDto.BUBOES_GROIN_ARMPIT_NECK, SymptomsDto.BULGING_FONTANELLE, SymptomsDto.PHARYNGEAL_ERYTHEMA, SymptomsDto.PHARYNGEAL_EXUDATE, SymptomsDto.OEDEMA_FACE_NECK, SymptomsDto.OEDEMA_LOWER_EXTREMITY, SymptomsDto.LOSS_SKIN_TURGOR, SymptomsDto.PALPABLE_LIVER, SymptomsDto.PALPABLE_SPLEEN, SymptomsDto.MALAISE, SymptomsDto.SUNKEN_EYES_FONTANELLE, SymptomsDto.SIDE_PAIN, SymptomsDto.FLUID_IN_LUNG_CAVITY, SymptomsDto.TREMOR, SymptomsDto.BILATERAL_CATARACTS, SymptomsDto.UNILATERAL_CATARACTS, SymptomsDto.CONGENITAL_GLAUCOMA, SymptomsDto.CONGENITAL_HEART_DISEASE, SymptomsDto.PIGMENTARY_RETINOPATHY, SymptomsDto.RADIOLUCENT_BONE_DISEASE, SymptomsDto.SPLENOMEGALY, SymptomsDto.MICROCEPHALY, SymptomsDto.MENINGOENCEPHALITIS, SymptomsDto.PURPURIC_RASH, SymptomsDto.DEVELOPMENTAL_DELAY, SymptomsDto.CONGENITAL_HEART_DISEASE_TYPE, SymptomsDto.CONGENITAL_HEART_DISEASE_DETAILS, SymptomsDto.JAUNDICE_WITHIN_24_HOURS_OF_BIRTH, SymptomsDto.PATIENT_ILL_LOCATION); addField(SymptomsDto.LESIONS_ONSET_DATE, DateField.class); // complications addFields(SymptomsDto.ALTERED_CONSCIOUSNESS, SymptomsDto.CONFUSED_DISORIENTED, SymptomsDto.HEMORRHAGIC_SYNDROME, SymptomsDto.HYPERGLYCEMIA, SymptomsDto.HYPOGLYCEMIA, SymptomsDto.MENINGEAL_SIGNS, SymptomsDto.SEIZURES, SymptomsDto.SEPSIS, SymptomsDto.SHOCK); monkeypoxImageFieldIds = Arrays.asList(SymptomsDto.LESIONS_RESEMBLE_IMG1, SymptomsDto.LESIONS_RESEMBLE_IMG2, SymptomsDto.LESIONS_RESEMBLE_IMG3, SymptomsDto.LESIONS_RESEMBLE_IMG4); for (String propertyId : monkeypoxImageFieldIds) { @SuppressWarnings("rawtypes") Field monkeypoxImageField = addField(propertyId); CssStyles.style(monkeypoxImageField, CssStyles.VSPACE_NONE); } // Set initial visibilities initializeVisibilitiesAndAllowedVisibilities(disease, viewMode); if (symptomsContext != SymptomsContext.CLINICAL_VISIT) { setVisible(false, SymptomsDto.BLOOD_PRESSURE_SYSTOLIC, SymptomsDto.BLOOD_PRESSURE_DIASTOLIC, SymptomsDto.HEART_RATE, SymptomsDto.RESPIRATORY_RATE, SymptomsDto.WEIGHT, SymptomsDto.HEIGHT, SymptomsDto.MID_UPPER_ARM_CIRCUMFERENCE, SymptomsDto.GLASGOW_COMA_SCALE); } else { setVisible(false, SymptomsDto.ONSET_SYMPTOM, SymptomsDto.ONSET_DATE); } // Initialize lists conditionalBleedingSymptomFieldIds = Arrays.asList(SymptomsDto.GUMS_BLEEDING, SymptomsDto.INJECTION_SITE_BLEEDING, SymptomsDto.NOSE_BLEEDING, SymptomsDto.BLOODY_BLACK_STOOL, SymptomsDto.RED_BLOOD_VOMIT, SymptomsDto.DIGESTED_BLOOD_VOMIT, SymptomsDto.EYES_BLEEDING, SymptomsDto.COUGHING_BLOOD, SymptomsDto.BLEEDING_VAGINA, SymptomsDto.SKIN_BRUISING, SymptomsDto.STOMACH_BLEEDING, SymptomsDto.BLOOD_URINE, SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS); lesionsFieldIds = Arrays.asList(SymptomsDto.LESIONS_SAME_STATE, SymptomsDto.LESIONS_SAME_SIZE, SymptomsDto.LESIONS_DEEP_PROFOUND, SymptomsDto.LESIONS_THAT_ITCH); lesionsLocationFieldIds = Arrays.asList(SymptomsDto.LESIONS_FACE, SymptomsDto.LESIONS_LEGS, SymptomsDto.LESIONS_SOLES_FEET, SymptomsDto.LESIONS_PALMS_HANDS, SymptomsDto.LESIONS_THORAX, SymptomsDto.LESIONS_ARMS, SymptomsDto.LESIONS_GENITALS, SymptomsDto.LESIONS_ALL_OVER_BODY); unconditionalSymptomFieldIds = Arrays.asList(SymptomsDto.FEVER, SymptomsDto.VOMITING, SymptomsDto.DIARRHEA, SymptomsDto.BLOOD_IN_STOOL, SymptomsDto.NAUSEA, SymptomsDto.ABDOMINAL_PAIN, SymptomsDto.HEADACHE, SymptomsDto.MUSCLE_PAIN, SymptomsDto.FATIGUE_WEAKNESS, SymptomsDto.SKIN_RASH, SymptomsDto.NECK_STIFFNESS, SymptomsDto.SORE_THROAT, SymptomsDto.COUGH, SymptomsDto.RUNNY_NOSE, SymptomsDto.DIFFICULTY_BREATHING, SymptomsDto.CHEST_PAIN, SymptomsDto.CONJUNCTIVITIS, SymptomsDto.EYE_PAIN_LIGHT_SENSITIVE, SymptomsDto.KOPLIKS_SPOTS, SymptomsDto.THROBOCYTOPENIA, SymptomsDto.OTITIS_MEDIA, SymptomsDto.HEARINGLOSS, SymptomsDto.DEHYDRATION, SymptomsDto.ANOREXIA_APPETITE_LOSS, SymptomsDto.REFUSAL_FEEDOR_DRINK, SymptomsDto.JOINT_PAIN, SymptomsDto.HICCUPS, SymptomsDto.BACKACHE, SymptomsDto.JAUNDICE, SymptomsDto.DARK_URINE, SymptomsDto.RAPID_BREATHING, SymptomsDto.SWOLLEN_GLANDS, SymptomsDto.UNEXPLAINED_BLEEDING, SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS, SymptomsDto.LESIONS, SymptomsDto.LYMPHADENOPATHY_AXILLARY, SymptomsDto.LYMPHADENOPATHY_CERVICAL, SymptomsDto.LYMPHADENOPATHY_INGUINAL, SymptomsDto.CHILLS_SWEATS, SymptomsDto.BEDRIDDEN, SymptomsDto.ORAL_ULCERS, SymptomsDto.PAINFUL_LYMPHADENITIS, SymptomsDto.BLACKENING_DEATH_OF_TISSUE, SymptomsDto.BUBOES_GROIN_ARMPIT_NECK, SymptomsDto.BULGING_FONTANELLE, SymptomsDto.PHARYNGEAL_ERYTHEMA, SymptomsDto.PHARYNGEAL_EXUDATE, SymptomsDto.OEDEMA_FACE_NECK, SymptomsDto.OEDEMA_LOWER_EXTREMITY, SymptomsDto.LOSS_SKIN_TURGOR, SymptomsDto.PALPABLE_LIVER, SymptomsDto.PALPABLE_SPLEEN, SymptomsDto.MALAISE, SymptomsDto.SUNKEN_EYES_FONTANELLE, SymptomsDto.SIDE_PAIN, SymptomsDto.FLUID_IN_LUNG_CAVITY, SymptomsDto.TREMOR, SymptomsDto.BILATERAL_CATARACTS, SymptomsDto.UNILATERAL_CATARACTS, SymptomsDto.CONGENITAL_GLAUCOMA, SymptomsDto.CONGENITAL_HEART_DISEASE, SymptomsDto.RADIOLUCENT_BONE_DISEASE, SymptomsDto.SPLENOMEGALY, SymptomsDto.MICROCEPHALY, SymptomsDto.MENINGOENCEPHALITIS, SymptomsDto.DEVELOPMENTAL_DELAY, SymptomsDto.PURPURIC_RASH, SymptomsDto.PIGMENTARY_RETINOPATHY, // complications SymptomsDto.ALTERED_CONSCIOUSNESS, SymptomsDto.CONFUSED_DISORIENTED, SymptomsDto.HEMORRHAGIC_SYNDROME, SymptomsDto.HYPERGLYCEMIA, SymptomsDto.HYPOGLYCEMIA, SymptomsDto.MENINGEAL_SIGNS, SymptomsDto.SEIZURES, SymptomsDto.SEPSIS, SymptomsDto.SHOCK); // Set visibilities FieldHelper.setVisibleWhen(getFieldGroup(), conditionalBleedingSymptomFieldIds, SymptomsDto.UNEXPLAINED_BLEEDING, Arrays.asList(SymptomState.YES), true, SymptomsDto.class, disease); FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS_TEXT, SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS, Arrays.asList(SymptomState.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT, SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS, Arrays.asList(SymptomState.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), lesionsFieldIds, SymptomsDto.LESIONS, Arrays.asList(SymptomState.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), lesionsLocationFieldIds, SymptomsDto.LESIONS, Arrays.asList(SymptomState.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.LESIONS_ONSET_DATE, SymptomsDto.LESIONS, Arrays.asList(SymptomState.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.CONGENITAL_HEART_DISEASE_TYPE, SymptomsDto.CONGENITAL_HEART_DISEASE, Arrays.asList(SymptomState.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.CONGENITAL_HEART_DISEASE_DETAILS, SymptomsDto.CONGENITAL_HEART_DISEASE_TYPE, Arrays.asList(CongenitalHeartDiseaseType.OTHER), true); if (isVisibleAllowed(getFieldGroup().getField(SymptomsDto.JAUNDICE_WITHIN_24_HOURS_OF_BIRTH))) { FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.JAUNDICE_WITHIN_24_HOURS_OF_BIRTH, SymptomsDto.JAUNDICE, Arrays.asList(SymptomState.YES), true); } FieldHelper.addSoftRequiredStyle(getField(SymptomsDto.LESIONS_ONSET_DATE)); boolean isInfant = person != null && person.getApproximateAge() != null && ((person.getApproximateAge() <= 12 && person.getApproximateAgeType() == ApproximateAgeType.MONTHS) || person.getApproximateAge() <= 1); if (!isInfant) { getFieldGroup().getField(SymptomsDto.BULGING_FONTANELLE).setVisible(false); } // Handle visibility of lesions locations caption Label lesionsLocationsCaption = new Label(I18nProperties.getCaption(Captions.symptomsLesionsLocations)); CssStyles.style(lesionsLocationsCaption, CssStyles.VSPACE_3); getContent().addComponent(lesionsLocationsCaption, LESIONS_LOCATIONS_LOC); getContent().getComponent(LESIONS_LOCATIONS_LOC) .setVisible(getFieldGroup().getField(SymptomsDto.LESIONS).getValue() == SymptomState.YES); getFieldGroup().getField(SymptomsDto.LESIONS).addValueChangeListener(e -> { getContent().getComponent(LESIONS_LOCATIONS_LOC) .setVisible(e.getProperty().getValue() == SymptomState.YES); }); // Symptoms hint text Label symptomsHint = new Label( I18nProperties.getString(symptomsContext == SymptomsContext.CASE ? Strings.messageSymptomsHint : Strings.messageSymptomsVisitHint), ContentMode.HTML); getContent().addComponent(symptomsHint, SYMPTOMS_HINT_LOC); if (disease == Disease.MONKEYPOX) { setUpMonkeypoxVisibilities(); } if (symptomsContext != SymptomsContext.CASE) { getFieldGroup().getField(SymptomsDto.PATIENT_ILL_LOCATION).setVisible(false); } FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS), Arrays.asList(SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS_TEXT), Arrays.asList(SymptomState.YES), disease); FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS), Arrays.asList(SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT), Arrays.asList(SymptomState.YES), disease); FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(SymptomsDto.LESIONS), lesionsFieldIds, Arrays.asList(SymptomState.YES), disease); FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(SymptomsDto.LESIONS), monkeypoxImageFieldIds, Arrays.asList(SymptomState.YES), disease); addListenerForOnsetFields(onsetSymptom, onsetDateField); Button clearAllButton = new Button(I18nProperties.getCaption(Captions.actionClearAll)); clearAllButton.addStyleName(ValoTheme.BUTTON_LINK); clearAllButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object symptomId : unconditionalSymptomFieldIds) { getFieldGroup().getField(symptomId).setValue(null); } for (Object symptomId : conditionalBleedingSymptomFieldIds) { getFieldGroup().getField(symptomId).setValue(null); } for (Object symptomId : lesionsFieldIds) { getFieldGroup().getField(symptomId).setValue(null); } for (Object symptomId : lesionsLocationFieldIds) { getFieldGroup().getField(symptomId).setValue(null); } for (Object symptomId : monkeypoxImageFieldIds) { getFieldGroup().getField(symptomId).setValue(null); } } }); Button setEmptyToNoButton = new Button(I18nProperties.getCaption(Captions.symptomsSetClearedToNo)); setEmptyToNoButton.addStyleName(ValoTheme.BUTTON_LINK); setEmptyToNoButton.addClickListener(new ClickListener() { @SuppressWarnings("unchecked") @Override public void buttonClick(ClickEvent event) { for (Object symptomId : unconditionalSymptomFieldIds) { Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId); if (symptom.isVisible() && symptom.getValue() == null) { symptom.setValue(SymptomState.NO); } } for (Object symptomId : conditionalBleedingSymptomFieldIds) { Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId); if (symptom.isVisible() && symptom.getValue() == null) { symptom.setValue(SymptomState.NO); } } for (Object symptomId : lesionsFieldIds) { Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId); if (symptom.isVisible() && symptom.getValue() == null) { symptom.setValue(SymptomState.NO); } } for (Object symptomId : monkeypoxImageFieldIds) { Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId); if (symptom.isVisible() && symptom.getValue() == null) { symptom.setValue(SymptomState.NO); } } } }); // Complications heading - not displayed for Rubella (dirty, should be made generic) Label complicationsHeading = new Label(I18nProperties.getString(Strings.headingComplications)); CssStyles.style(complicationsHeading, CssStyles.H3); if (disease != Disease.CONGENITAL_RUBELLA) { getContent().addComponent(complicationsHeading, COMPLICATIONS_HEADING); } HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.addComponent(clearAllButton); buttonsLayout.addComponent(setEmptyToNoButton); buttonsLayout.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT); getContent().addComponent(buttonsLayout, BUTTONS_LOC); }
From source file:de.symeda.sormas.ui.task.TasksView.java
License:Open Source License
public TasksView() { super(VIEW_NAME); if (!ViewModelProviders.of(TasksView.class).has(TaskCriteria.class)) { // init default filter TaskCriteria taskCriteria = new TaskCriteria(); taskCriteria.taskStatus(TaskStatus.PENDING); ViewModelProviders.of(TasksView.class).get(TaskCriteria.class, taskCriteria); }/*w ww .ja v a 2 s . c om*/ taskListComponent = new TaskGridComponent(getViewTitleLabel(), this); addComponent(taskListComponent); if (UserProvider.getCurrent().hasUserRight(UserRight.TASK_CREATE)) { Button createButton = new Button(I18nProperties.getCaption(Captions.taskNewTask)); createButton.addStyleName(ValoTheme.BUTTON_PRIMARY); createButton.setIcon(VaadinIcons.PLUS_CIRCLE); createButton.addClickListener(e -> ControllerProvider.getTaskController().create(TaskContext.GENERAL, null, taskListComponent.getGrid()::reload)); addHeaderComponent(createButton); } }
From source file:de.symeda.sormas.ui.therapy.TherapyView.java
License:Open Source License
private VerticalLayout createPrescriptionsHeader() { VerticalLayout prescriptionsHeader = new VerticalLayout(); prescriptionsHeader.setMargin(false); prescriptionsHeader.setSpacing(false); prescriptionsHeader.setWidth(100, Unit.PERCENTAGE); HorizontalLayout headlineRow = new HorizontalLayout(); headlineRow.setMargin(false);/*from w w w . j a v a 2 s . co m*/ headlineRow.setSpacing(true); headlineRow.setWidth(100, Unit.PERCENTAGE); { Label prescriptionsLabel = new Label(I18nProperties.getString(Strings.entityPrescriptions)); CssStyles.style(prescriptionsLabel, CssStyles.H3); headlineRow.addComponent(prescriptionsLabel); headlineRow.setExpandRatio(prescriptionsLabel, 1); // Bulk operations if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command deleteCommand = selectedItem -> { ControllerProvider.getTherapyController() .deleteAllSelectedPrescriptions(prescriptionGrid.getSelectedRows(), new Runnable() { public void run() { reloadPrescriptionGrid(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); headlineRow.addComponent(bulkOperationsDropdown); headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT); } Button newPrescriptionButton = new Button( I18nProperties.getCaption(Captions.prescriptionNewPrescription)); CssStyles.style(newPrescriptionButton, ValoTheme.BUTTON_PRIMARY); newPrescriptionButton.addClickListener(e -> { ControllerProvider.getTherapyController().openPrescriptionCreateForm( prescriptionCriteria.getTherapy(), this::reloadPrescriptionGrid); }); headlineRow.addComponent(newPrescriptionButton); headlineRow.setComponentAlignment(newPrescriptionButton, Alignment.MIDDLE_RIGHT); } prescriptionsHeader.addComponent(headlineRow); HorizontalLayout filterRow = new HorizontalLayout(); filterRow.setMargin(false); filterRow.setSpacing(true); { prescriptionTypeFilter = new ComboBox(); prescriptionTypeFilter.setWidth(140, Unit.PIXELS); prescriptionTypeFilter.setInputPrompt(I18nProperties.getPrefixCaption(PrescriptionDto.I18N_PREFIX, PrescriptionDto.PRESCRIPTION_TYPE)); prescriptionTypeFilter.addItems((Object[]) TreatmentType.values()); prescriptionTypeFilter.addValueChangeListener(e -> { prescriptionCriteria.prescriptionType(((TreatmentType) e.getProperty().getValue())); navigateTo(prescriptionCriteria); }); filterRow.addComponent(prescriptionTypeFilter); prescriptionTextFilter = new TextField(); prescriptionTextFilter.setWidth(300, Unit.PIXELS); prescriptionTextFilter.setNullRepresentation(""); prescriptionTextFilter.setInputPrompt(I18nProperties.getString(Strings.promptPrescriptionTextFilter)); prescriptionTextFilter.addTextChangeListener(e -> { prescriptionCriteria.textFilter(e.getText()); reloadPrescriptionGrid(); }); filterRow.addComponent(prescriptionTextFilter); } prescriptionsHeader.addComponent(filterRow); return prescriptionsHeader; }
From source file:de.symeda.sormas.ui.therapy.TherapyView.java
License:Open Source License
private VerticalLayout createTreatmentsHeader() { VerticalLayout treatmentsHeader = new VerticalLayout(); treatmentsHeader.setMargin(false);/*from w w w . jav a 2s .c om*/ treatmentsHeader.setSpacing(false); treatmentsHeader.setWidth(100, Unit.PERCENTAGE); HorizontalLayout headlineRow = new HorizontalLayout(); headlineRow.setMargin(false); headlineRow.setSpacing(true); headlineRow.setWidth(100, Unit.PERCENTAGE); { Label treatmentsLabel = new Label(I18nProperties.getString(Strings.headingTreatments)); CssStyles.style(treatmentsLabel, CssStyles.H3); headlineRow.addComponent(treatmentsLabel); headlineRow.setExpandRatio(treatmentsLabel, 1); // Bulk operations if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command deleteCommand = selectedItem -> { ControllerProvider.getTherapyController() .deleteAllSelectedTreatments(treatmentGrid.getSelectedRows(), new Runnable() { public void run() { reloadTreatmentGrid(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); headlineRow.addComponent(bulkOperationsDropdown); headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT); } Button newTreatmentButton = new Button(I18nProperties.getCaption(Captions.treatmentNewTreatment)); newTreatmentButton.addClickListener(e -> { ControllerProvider.getTherapyController().openTreatmentCreateForm(treatmentCriteria.getTherapy(), this::reloadTreatmentGrid); }); headlineRow.addComponent(newTreatmentButton); headlineRow.setComponentAlignment(newTreatmentButton, Alignment.MIDDLE_RIGHT); } treatmentsHeader.addComponent(headlineRow); HorizontalLayout filterRow = new HorizontalLayout(); filterRow.setMargin(false); filterRow.setSpacing(true); { treatmentTypeFilter = new ComboBox(); treatmentTypeFilter.setWidth(140, Unit.PIXELS); treatmentTypeFilter.setInputPrompt( I18nProperties.getPrefixCaption(TreatmentDto.I18N_PREFIX, TreatmentDto.TREATMENT_TYPE)); treatmentTypeFilter.addItems((Object[]) TreatmentType.values()); treatmentTypeFilter.addValueChangeListener(e -> { treatmentCriteria.treatmentType(((TreatmentType) e.getProperty().getValue())); navigateTo(treatmentCriteria); }); filterRow.addComponent(treatmentTypeFilter); treatmentTextFilter = new TextField(); treatmentTextFilter.setWidth(300, Unit.PIXELS); treatmentTextFilter.setNullRepresentation(""); treatmentTextFilter.setInputPrompt(I18nProperties.getString(Strings.promptTreatmentTextFilter)); treatmentTextFilter.addTextChangeListener(e -> { treatmentCriteria.textFilter(e.getText()); reloadTreatmentGrid(); }); filterRow.addComponent(treatmentTextFilter); } treatmentsHeader.addComponent(filterRow); return treatmentsHeader; }
From source file:de.symeda.sormas.ui.user.UserController.java
License:Open Source License
public Button createResetPasswordButton(String userUuid, CommitDiscardWrapperComponent<UserEditForm> editView) { Button resetPasswordButton = new Button(null, VaadinIcons.UNLOCK); resetPasswordButton.setCaption(I18nProperties.getCaption(Captions.userResetPassword)); resetPasswordButton.addStyleName(ValoTheme.BUTTON_LINK); resetPasswordButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override/*w ww. jav a2s . c o m*/ public void buttonClick(ClickEvent event) { ConfirmationComponent resetPasswordComponent = getResetPasswordConfirmationComponent(userUuid, editView); Window popupWindow = VaadinUiUtil.showPopupWindow(resetPasswordComponent); resetPasswordComponent.addDoneListener(new DoneListener() { public void onDone() { popupWindow.close(); } }); resetPasswordComponent.getCancelButton().addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { popupWindow.close(); } }); popupWindow.setCaption(I18nProperties.getString(Strings.headingUpdatePassword)); } }); return resetPasswordButton; }
From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java
License:Open Source License
public static Window showSimplePopupWindow(String caption, String contentText) { Window window = new Window(null); window.setModal(true);/*from w w w . ja v a 2 s. c o m*/ window.setSizeUndefined(); window.setResizable(false); window.center(); VerticalLayout popupLayout = new VerticalLayout(); popupLayout.setMargin(true); popupLayout.setSpacing(true); popupLayout.setSizeUndefined(); Label contentLabel = new Label(contentText); contentLabel.setWidth(100, Unit.PERCENTAGE); popupLayout.addComponent(contentLabel); Button okayButton = new Button(I18nProperties.getCaption(Captions.actionOkay)); okayButton.addClickListener(e -> { window.close(); }); CssStyles.style(okayButton, ValoTheme.BUTTON_PRIMARY); popupLayout.addComponent(okayButton); popupLayout.setComponentAlignment(okayButton, Alignment.BOTTOM_RIGHT); window.setCaption(caption); window.setContent(popupLayout); UI.getCurrent().addWindow(window); return window; }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultCompoundSearchView.java
License:Apache License
@Override public void initialize(TableColumns fields) { this.fields = fields; searchBox = new SearchBox(this); searchBox.setWidth("100%"); searchBox.setOptionHandler(new SearchOptionsHandler(fields)); searchBox.focus();/* w w w . ja v a2s . com*/ searchBox.setInputPrompt(getMessage("portlet.crud.compoundsearch.inputPrompt")); Button resetButton = new Button(getMessage("portlet.crud.compoundsearch.reset")); resetButton.setStyleName(LiferayTheme.BUTTON_LINK); resetButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { presenter.reset(); } }); PopupView infoButton = new PopupView(new Content() { @Override public String getMinimizedValueAsHTML() { return "?"; } @Override public Component getPopupComponent() { return createSearchInfo(); } }); infoButton.setHideOnMouseOut(false); searchBar = new HorizontalLayout(searchBox, resetButton, infoButton); searchBar.setWidth("100%"); searchBar.addStyleName("compsearchbar"); searchBar.setExpandRatio(searchBox, 1); searchBar.setSpacing(true); searchBar.setComponentAlignment(resetButton, Alignment.MIDDLE_CENTER); searchBar.setComponentAlignment(infoButton, Alignment.MIDDLE_CENTER); addComponent(searchBar); }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultFormView.java
License:Apache License
@SuppressWarnings("serial") private void createFooterAndPopulateActions(FormActions actions) { CssLayout buttons = new CssLayout(); buttons.setStyleName("actions"); boolean allHidden = true; for (final FormAction action : actions) { final Button button = new Button(action.getTitle()); button.setDisableOnClick(true);//from w w w . j a v a 2 s. c o m button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { presenter.executeAction(action); } finally { button.setEnabled(true); } } }); if (action.getActionHandler() instanceof SearchFormAction) { if (searchAction == null) { searchAction = action; // button.setClickShortcut(KeyCode.ENTER); } } if (action.isHidden()) { button.setVisible(false); } else { allHidden = false; } buttons.addComponent(button); } if (!allHidden) { rootLayout.addComponent(buttons); } }