Search in sources :

Example 56 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class EventsFilterForm method applyDistrictDependency.

@Override
protected void applyDistrictDependency(DistrictReferenceDto district, String communityFieldId) {
    final ComboBox communityField = getField(communityFieldId);
    if (district != null) {
        FieldHelper.updateItems(communityField, FacadeProvider.getCommunityFacade().getAllActiveByDistrict(district.getUuid()));
        communityField.setEnabled(true);
    } else {
        communityField.setEnabled(false);
    }
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox)

Example 57 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class EventsFilterForm method addFields.

@Override
protected void addFields() {
    addField(FieldConfiguration.pixelSized(EventCriteria.EVENT_STATUS, 140));
    addField(FieldConfiguration.pixelSized(EventCriteria.RISK_LEVEL, 140));
    List<SpecificRisk> specificRisks = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.SPECIFIC_EVENT_RISK, null);
    if (!specificRisks.isEmpty()) {
        ComboBox specificRiskField = addField(FieldConfiguration.pixelSized(EventCriteria.SPECIFIC_RISK, 140), ComboBox.class);
        FieldHelper.updateItems(specificRiskField, specificRisks);
    }
    addField(FieldConfiguration.pixelSized(EventIndexDto.DISEASE, 140));
    addField(FieldConfiguration.pixelSized(EventIndexDto.DISEASE_VARIANT, 140), ComboBox.class);
    addField(FieldConfiguration.withCaptionAndPixelSized(EventCriteria.REPORTING_USER_ROLE, I18nProperties.getString(Strings.reportedBy), 140));
    TextField searchField = addField(FieldConfiguration.withCaptionAndPixelSized(EventCriteria.FREE_TEXT, I18nProperties.getString(Strings.promptEventsSearchField), 200));
    searchField.setNullRepresentation("");
    TextField searchFieldEventParticipants = addField(FieldConfiguration.withCaptionAndPixelSized(EventCriteria.FREE_TEXT_EVENT_PARTICIPANTS, I18nProperties.getString(Strings.promptEventsSearchFieldEventParticipants), 200));
    searchFieldEventParticipants.setNullRepresentation("");
    TextField searchFieldEventGroups = addField(FieldConfiguration.withCaptionAndPixelSized(EventCriteria.FREE_TEXT_EVENT_GROUPS, I18nProperties.getString(Strings.promptEventsSearchFieldEventGroups), 200));
    searchFieldEventGroups.setNullRepresentation("");
}
Also used : SpecificRisk(de.symeda.sormas.api.event.SpecificRisk) ComboBox(com.vaadin.v7.ui.ComboBox) TextField(com.vaadin.v7.ui.TextField)

Example 58 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class HospitalizationForm method addFields.

@SuppressWarnings("deprecation")
@Override
protected void addFields() {
    if (caze == null || viewMode == null) {
        return;
    }
    Label hospitalizationHeadingLabel = new Label(I18nProperties.getString(Strings.headingHospitalization));
    hospitalizationHeadingLabel.addStyleName(H3);
    getContent().addComponent(hospitalizationHeadingLabel, HOSPITALIZATION_HEADING_LOC);
    Label previousHospitalizationsHeadingLabel = new Label(I18nProperties.getString(Strings.headingPreviousHospitalizations));
    previousHospitalizationsHeadingLabel.addStyleName(H3);
    getContent().addComponent(previousHospitalizationsHeadingLabel, PREVIOUS_HOSPITALIZATIONS_HEADING_LOC);
    TextField facilityField = addCustomField(HEALTH_FACILITY, FacilityReferenceDto.class, TextField.class);
    FacilityReferenceDto healthFacility = caze.getHealthFacility();
    final boolean noneFacility = healthFacility == null || healthFacility.getUuid().equalsIgnoreCase(FacilityDto.NONE_FACILITY_UUID);
    facilityField.setValue(noneFacility || !FacilityType.HOSPITAL.equals(caze.getFacilityType()) ? null : healthFacility.toString());
    facilityField.setReadOnly(true);
    final NullableOptionGroup admittedToHealthFacilityField = addField(HospitalizationDto.ADMITTED_TO_HEALTH_FACILITY, NullableOptionGroup.class);
    final DateField admissionDateField = addField(HospitalizationDto.ADMISSION_DATE, DateField.class);
    final DateField dischargeDateField = addDateField(HospitalizationDto.DISCHARGE_DATE, DateField.class, 7);
    intensiveCareUnit = addField(HospitalizationDto.INTENSIVE_CARE_UNIT, NullableOptionGroup.class);
    intensiveCareUnitStart = addField(HospitalizationDto.INTENSIVE_CARE_UNIT_START, DateField.class);
    intensiveCareUnitStart.setVisible(false);
    intensiveCareUnitEnd = addField(HospitalizationDto.INTENSIVE_CARE_UNIT_END, DateField.class);
    intensiveCareUnitEnd.setVisible(false);
    FieldHelper.setVisibleWhen(intensiveCareUnit, Arrays.asList(intensiveCareUnitStart, intensiveCareUnitEnd), Arrays.asList(YesNoUnknown.YES), true);
    final Field isolationDateField = addField(HospitalizationDto.ISOLATION_DATE);
    final TextArea descriptionField = addField(HospitalizationDto.DESCRIPTION, TextArea.class);
    descriptionField.setRows(4);
    final NullableOptionGroup isolatedField = addField(HospitalizationDto.ISOLATED, NullableOptionGroup.class);
    final NullableOptionGroup leftAgainstAdviceField = addField(HospitalizationDto.LEFT_AGAINST_ADVICE, NullableOptionGroup.class);
    final ComboBox hospitalizationReason = addField(HospitalizationDto.HOSPITALIZATION_REASON);
    final TextField otherHospitalizationReason = addField(HospitalizationDto.OTHER_HOSPITALIZATION_REASON, TextField.class);
    NullableOptionGroup hospitalizedPreviouslyField = addField(HospitalizationDto.HOSPITALIZED_PREVIOUSLY, NullableOptionGroup.class);
    CssStyles.style(hospitalizedPreviouslyField, CssStyles.ERROR_COLOR_PRIMARY);
    PreviousHospitalizationsField previousHospitalizationsField = addField(HospitalizationDto.PREVIOUS_HOSPITALIZATIONS, PreviousHospitalizationsField.class);
    FieldHelper.setEnabledWhen(admittedToHealthFacilityField, Arrays.asList(YesNoUnknown.YES, YesNoUnknown.NO, YesNoUnknown.UNKNOWN), Arrays.asList(facilityField, admissionDateField, dischargeDateField, intensiveCareUnit, intensiveCareUnitStart, intensiveCareUnitEnd, isolationDateField, descriptionField, isolatedField, leftAgainstAdviceField, hospitalizationReason, otherHospitalizationReason), false);
    initializeVisibilitiesAndAllowedVisibilities();
    initializeAccessAndAllowedAccesses();
    if (isVisibleAllowed(HospitalizationDto.ISOLATION_DATE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), HospitalizationDto.ISOLATION_DATE, HospitalizationDto.ISOLATED, Arrays.asList(YesNoUnknown.YES), true);
    }
    if (isVisibleAllowed(HospitalizationDto.PREVIOUS_HOSPITALIZATIONS)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), HospitalizationDto.PREVIOUS_HOSPITALIZATIONS, HospitalizationDto.HOSPITALIZED_PREVIOUSLY, Arrays.asList(YesNoUnknown.YES), true);
    }
    FieldHelper.setVisibleWhen(getFieldGroup(), HospitalizationDto.OTHER_HOSPITALIZATION_REASON, HospitalizationDto.HOSPITALIZATION_REASON, Collections.singletonList(HospitalizationReasonType.OTHER), true);
    // Validations
    // Add a visual-only validator to check if symptomonsetdate<admissiondate, as saving should be possible either way
    admissionDateField.addValueChangeListener(event -> {
        if (caze.getSymptoms().getOnsetDate() != null && DateTimeComparator.getDateOnlyInstance().compare(admissionDateField.getValue(), caze.getSymptoms().getOnsetDate()) < 0) {
            admissionDateField.setComponentError(new ErrorMessage() {

                @Override
                public ErrorLevel getErrorLevel() {
                    return ErrorLevel.INFO;
                }

                @Override
                public String getFormattedHtmlMessage() {
                    return I18nProperties.getValidationError(Validations.afterDateSoft, admissionDateField.getCaption(), I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE));
                }
            });
        } else {
            // remove all invalidity-indicators and re-evaluate field
            admissionDateField.setComponentError(null);
            admissionDateField.markAsDirty();
        }
        // re-evaluate validity of dischargeDate (necessary because discharge has to be after admission)
        dischargeDateField.markAsDirty();
    });
    admissionDateField.addValidator(new DateComparisonValidator(admissionDateField, dischargeDateField, true, false, I18nProperties.getValidationError(Validations.beforeDate, admissionDateField.getCaption(), dischargeDateField.getCaption())));
    dischargeDateField.addValidator(new DateComparisonValidator(dischargeDateField, admissionDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, dischargeDateField.getCaption(), admissionDateField.getCaption())));
    // re-evaluate admission date for consistent validation of all fields
    dischargeDateField.addValueChangeListener(event -> admissionDateField.markAsDirty());
    intensiveCareUnitStart.addValidator(new DateComparisonValidator(intensiveCareUnitStart, admissionDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, intensiveCareUnitStart.getCaption(), admissionDateField.getCaption())));
    intensiveCareUnitStart.addValidator(new DateComparisonValidator(intensiveCareUnitStart, intensiveCareUnitEnd, true, false, I18nProperties.getValidationError(Validations.beforeDate, intensiveCareUnitStart.getCaption(), intensiveCareUnitEnd.getCaption())));
    intensiveCareUnitEnd.addValidator(new DateComparisonValidator(intensiveCareUnitEnd, intensiveCareUnitStart, false, false, I18nProperties.getValidationError(Validations.afterDate, intensiveCareUnitEnd.getCaption(), intensiveCareUnitStart.getCaption())));
    intensiveCareUnitEnd.addValidator(new DateComparisonValidator(intensiveCareUnitEnd, dischargeDateField, true, false, I18nProperties.getValidationError(Validations.beforeDate, intensiveCareUnitEnd.getCaption(), dischargeDateField.getCaption())));
    intensiveCareUnitStart.addValueChangeListener(event -> intensiveCareUnitEnd.markAsDirty());
    intensiveCareUnitEnd.addValueChangeListener(event -> intensiveCareUnitStart.markAsDirty());
    hospitalizedPreviouslyField.addValueChangeListener(e -> updatePrevHospHint(hospitalizedPreviouslyField, previousHospitalizationsField));
    previousHospitalizationsField.addValueChangeListener(e -> updatePrevHospHint(hospitalizedPreviouslyField, previousHospitalizationsField));
}
Also used : NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) TextArea(com.vaadin.v7.ui.TextArea) ComboBox(com.vaadin.v7.ui.ComboBox) Label(com.vaadin.ui.Label) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) DateField(com.vaadin.v7.ui.DateField) Field(com.vaadin.v7.ui.Field) TextField(com.vaadin.v7.ui.TextField) TextField(com.vaadin.v7.ui.TextField) ErrorLevel(com.vaadin.shared.ui.ErrorLevel) DateField(com.vaadin.v7.ui.DateField) ErrorMessage(com.vaadin.server.ErrorMessage)

Example 59 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project charts by vaadin.

the class ChartsDemoUI method init.

@Override
protected void init(VaadinRequest request) {
    initGATracker();
    tabSheet = new TabSheet();
    tabSheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() {

        @Override
        public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) {
            com.vaadin.ui.JavaScript.eval("setTimeout(function(){prettyPrint();},300);");
        }
    });
    tabSheet.setSizeFull();
    tabSheet.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
    Link homepage = new Link("Home Page", new ExternalResource("https://vaadin.com/components/vaadin-charts"));
    Link javadoc = new Link("JavaDoc", new ExternalResource("https://vaadin.com/api/com.vaadin/vaadin-charts/" + getVersion() + "/"));
    Link manual = new Link("Manual", new ExternalResource("https://vaadin.com/docs/v8/charts/charts-overview.html"));
    Link pricing = new Link("Pricing", new ExternalResource("https://vaadin.com/pricing"));
    Label version = new Label("Version " + getVersion());
    version.addStyleName("version");
    HorizontalLayout links = new HorizontalLayout(homepage, pricing, javadoc, manual);
    links.setSpacing(true);
    links.addStyleName("links");
    final HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
    horizontalSplitPanel.setSecondComponent(tabSheet);
    horizontalSplitPanel.setSplitPosition(300, Unit.PIXELS);
    horizontalSplitPanel.addStyleName("main-layout");
    ChartOptions.get().setTheme(new ValoLightTheme());
    themeSelector = new ComboBox("Charts Theme:");
    themeSelector.addStyleName("theme-selector");
    themeSelector.addStyleName(ValoTheme.COMBOBOX_SMALL);
    themeSelector.setTextInputAllowed(false);
    com.vaadin.addon.charts.model.style.Theme defaultTheme = new ValoLightTheme();
    Map<com.vaadin.addon.charts.model.style.Theme, String> mapThemes = new HashMap<>();
    com.vaadin.addon.charts.model.style.Theme[] themes = new com.vaadin.addon.charts.model.style.Theme[] { defaultTheme, new ValoDarkTheme(), new VaadinTheme(), new HighChartsDefaultTheme(), new GridTheme(), new GrayTheme(), new SkiesTheme() };
    mapThemes.put(themes[0], "Valo Light");
    mapThemes.put(themes[1], "Valo Dark");
    mapThemes.put(themes[2], "Vaadin");
    mapThemes.put(themes[3], "HighCharts");
    mapThemes.put(themes[4], "Grid");
    mapThemes.put(themes[5], "Gray");
    mapThemes.put(themes[6], "Skies");
    themeSelector.setEmptySelectionAllowed(false);
    themeSelector.setItems(themes);
    themeSelector.setSelectedItem(defaultTheme);
    themeSelector.setItemCaptionGenerator(mapThemes::get);
    themeSelector.addSelectionListener(e -> {
        ChartOptions.get().setTheme(e.getValue());
    });
    final HierarchicalContainer container = getContainer();
    VerticalLayout content = new VerticalLayout();
    content.setSpacing(true);
    content.setMargin(false);
    Label logo = new Label("Vaadin Charts for Vaadin 8");
    logo.setWidth("100%");
    logo.addStyleName("h3");
    logo.addStyleName("logo");
    TextField filterField = new TextField();
    filterField.setPlaceholder("Filter examples");
    filterField.setIcon(FontAwesome.SEARCH);
    filterField.addStyleName("filter");
    filterField.setWidth("100%");
    filterField.addValueChangeListener(e -> {
        container.removeAllContainerFilters();
        String text = e.getValue();
        if (text != null && !text.isEmpty()) {
            expandForFiltering();
            container.addContainerFilter("searchName", text, true, false);
        } else {
            restoreExpandedStates();
        }
    });
    tree = new Tree();
    tree.setImmediate(true);
    tree.setContainerDataSource(container);
    tree.setItemCaptionPropertyId("displayName");
    tree.setNullSelectionAllowed(false);
    tree.setWidth("100%");
    tree.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            Object value = event.getProperty().getValue();
            if (value instanceof Class) {
                updateTabSheet((Class) value);
            } else {
                tree.expandItemsRecursively(value);
            }
        }
    });
    Button trial = new Button("Start Free Trial");
    trial.addStyleName(ValoTheme.BUTTON_PRIMARY);
    trial.addStyleName(ValoTheme.BUTTON_TINY);
    trial.addClickListener(e -> {
        getUI().getPage().open("https://vaadin.com/trial", "_blank");
    });
    content.addComponents(logo, links, trial, filterField, tree, version);
    content.setComponentAlignment(trial, Alignment.MIDDLE_CENTER);
    horizontalSplitPanel.setFirstComponent(content);
    selectItem();
    Page.getCurrent().addUriFragmentChangedListener(new Page.UriFragmentChangedListener() {

        @Override
        public void uriFragmentChanged(Page.UriFragmentChangedEvent event) {
            selectItem();
        }
    });
    setContent(new CssLayout() {

        {
            setSizeFull();
            addComponent(horizontalSplitPanel);
            addComponent(themeSelector);
        }
    });
    if (tracker != null) {
        tracker.trackPageview("/charts");
    }
}
Also used : SkiesTheme(com.vaadin.addon.charts.themes.SkiesTheme) HighChartsDefaultTheme(com.vaadin.addon.charts.themes.HighChartsDefaultTheme) ValoLightTheme(com.vaadin.addon.charts.themes.ValoLightTheme) HashMap(java.util.HashMap) Label(com.vaadin.ui.Label) VaadinTheme(com.vaadin.addon.charts.themes.VaadinTheme) Page(com.vaadin.server.Page) GrayTheme(com.vaadin.addon.charts.themes.GrayTheme) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ValoDarkTheme(com.vaadin.addon.charts.themes.ValoDarkTheme) CssLayout(com.vaadin.ui.CssLayout) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField) Tree(com.vaadin.v7.ui.Tree) Property(com.vaadin.v7.data.Property) ComboBox(com.vaadin.ui.ComboBox) GridTheme(com.vaadin.addon.charts.themes.GridTheme) ExternalResource(com.vaadin.server.ExternalResource) TabSheet(com.vaadin.ui.TabSheet) HorizontalSplitPanel(com.vaadin.ui.HorizontalSplitPanel) ValoLightTheme(com.vaadin.addon.charts.themes.ValoLightTheme) ValoDarkTheme(com.vaadin.addon.charts.themes.ValoDarkTheme) ValoTheme(com.vaadin.ui.themes.ValoTheme) Theme(com.vaadin.annotations.Theme) GrayTheme(com.vaadin.addon.charts.themes.GrayTheme) VaadinTheme(com.vaadin.addon.charts.themes.VaadinTheme) GridTheme(com.vaadin.addon.charts.themes.GridTheme) HighChartsDefaultTheme(com.vaadin.addon.charts.themes.HighChartsDefaultTheme) SkiesTheme(com.vaadin.addon.charts.themes.SkiesTheme) HierarchicalContainer(com.vaadin.v7.data.util.HierarchicalContainer) Link(com.vaadin.ui.Link)

Example 60 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project CodenameOne by codenameone.

the class UIFragmentSample method testUIFragment.

private void testUIFragment() {
    Form f = new Form("Test Fragments", BoxLayout.y());
    TextArea ta = new TextArea();
    ta.setMaxSize(5000);
    String[] examples = new String[] { "<borderAbs><$button1 constraint='center'/><xng constraint='south'><$button2/><$button3/><$button4/></xng></borderAbs>", "{centerAbs:$button1, south:{xng:[$button2, $button3, $button4]}}", "{cs:$button1, south:{xng:[$button2, $button3, $button4]}}", "{ca:$button1, south:{xng:[$button2, $button3, $button4]}}", "{centerScale:$button1, south:{xng:[$button2, $button3, $button4]}}", "{ctb:$button1, south:{xng:[$button2, $button3, $button4]}}", "{centerTotalBelow:$button1, south:{xng:[$button2, $button3, $button4]}}", "{s:$button1, c:{xng:[$button2, $button3, $button4]}}", "{s:$button1, c:{x:[$button2, $button3, $button4]}}", "{s:$button1, c:{y:[$button2, $button3, $button4]}}", "{s:$button1, c:{yBottomLast:[$button2, $button3, $button4]}}", "{s:$button1, c:{ybl:[$button2, $button3, $button4]}}" };
    ComboBox cb = new ComboBox(examples);
    cb.addActionListener(e -> {
        ta.setText(examples[cb.getSelectedIndex()]);
    });
    ta.setText("<borderAbs><$button1 constraint='center'/><xng constraint='south'><$button2/><$button3/><$button4/></xng></borderAbs>");
    Button b = new Button("Compile");
    b.addActionListener(e -> {
        Form f2 = new Form("Result", new BorderLayout());
        f2.setToolbar(new Toolbar());
        f2.setTitle("Result");
        f2.setBackCommand("Back", null, evt -> {
            f.showBack();
        });
        f2.getToolbar().addCommandToLeftBar("Back", null, evt -> {
            f.showBack();
        });
        Button b1 = new Button("Button 1");
        Button b2 = new Button("Button 2");
        Button b3 = new Button("Button 3");
        Button b4 = new Button("Button 4");
        $(b1, b2, b3, b4).selectAllStyles().setBorder(RoundRectBorder.create().cornerRadius(2)).setBgColor(0x003399).setBgTransparency(0xff);
        UIFragment frag;
        if (ta.getText().charAt(0) == '<') {
            frag = UIFragment.parseXML(ta.getText());
        } else {
            System.out.println("Parsing " + ta.getText());
            frag = UIFragment.parseJSON(ta.getText());
        }
        f2.add(BorderLayout.CENTER, frag.set("button1", b1).set("button2", b2).set("button3", b3).set("button4", b4).getView());
        f2.show();
    });
    ta.setRows(5);
    f.addAll(cb, ta, b);
    f.show();
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout) Form(com.codename1.ui.Form) TextArea(com.codename1.ui.TextArea) Button(com.codename1.ui.Button) ComboBox(com.codename1.ui.ComboBox) UIFragment(com.codename1.ui.UIFragment) Toolbar(com.codename1.ui.Toolbar)

Aggregations

ComboBox (com.vaadin.v7.ui.ComboBox)113 TextField (com.vaadin.v7.ui.TextField)43 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)31 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)28 Label (com.vaadin.ui.Label)24 Disease (de.symeda.sormas.api.Disease)24 TextArea (com.vaadin.v7.ui.TextArea)19 UserDto (de.symeda.sormas.api.user.UserDto)19 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)19 DateField (com.vaadin.v7.ui.DateField)18 List (java.util.List)18 CheckBox (com.vaadin.v7.ui.CheckBox)17 FacadeProvider (de.symeda.sormas.api.FacadeProvider)17 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)17 DateComparisonValidator (de.symeda.sormas.ui.utils.DateComparisonValidator)17 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)16 AbstractEditForm (de.symeda.sormas.ui.utils.AbstractEditForm)16 Field (com.vaadin.v7.ui.Field)15 FieldVisibilityCheckers (de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers)15 Captions (de.symeda.sormas.api.i18n.Captions)14