Example usage for com.vaadin.ui VerticalLayout setMargin

List of usage examples for com.vaadin.ui VerticalLayout setMargin

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setMargin.

Prototype

@Override
    public void setMargin(boolean enabled) 

Source Link

Usage

From source file:de.fzi.fhemapi.view.vaadin.ui.DeviceDetailsPanel.java

License:Apache License

@AutoGenerated
private VerticalLayout buildMainLayout() {
    // common part: create layout
    VerticalLayout layout = new VerticalLayout();
    layout.setImmediate(false);// w  w  w . j a v  a 2  s  .  co  m
    layout.setWidth("100.0%");
    layout.setHeight("-1");
    layout.setMargin(false);

    HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setImmediate(false);
    titleLayout.setWidth("-1");
    titleLayout.setHeight("50");
    titleLayout.setMargin(false);
    layout.addComponent(titleLayout);
    layout.setComponentAlignment(titleLayout, Alignment.TOP_CENTER);

    // deviceTitle
    deviceTitle = new TextField();
    deviceTitle.setImmediate(true);
    deviceTitle.setWidth("100%");
    deviceTitle.setHeight("-1px");
    deviceTitle.setValue(device.getName());
    deviceTitle.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (((String) event.getProperty().getValue()).length() > 1) {
                device.rename((String) event.getProperty().getValue());
                parent.reloadTree();
            }
        }
    });
    titleLayout.addComponent(deviceTitle);
    titleLayout.setComponentAlignment(deviceTitle, Alignment.TOP_CENTER);

    ComboBox combobox = new ComboBox();
    String[] classes = DeviceFactory.getAvailableDevicetypes();
    for (String name : classes) {
        combobox.addItem(name);
    }
    combobox.select(device.getClass().getSimpleName());
    combobox.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            setDeviceType((String) event.getProperty().getValue());
        }
    });
    combobox.setImmediate(true);

    deviceTypeHoriLayout = UIHelper.buildAttributePanel("Device Type", combobox);
    layout.addComponent(deviceTypeHoriLayout);
    layout.setComponentAlignment(deviceTypeHoriLayout, Alignment.TOP_CENTER);
    layout.setExpandRatio(deviceTypeHoriLayout, 1);

    ioDevHoriLayout = buildAttributePanel("IO Device", device.getType());
    layout.addComponent(ioDevHoriLayout);
    layout.setComponentAlignment(ioDevHoriLayout, Alignment.TOP_CENTER);
    layout.setExpandRatio(ioDevHoriLayout, 1);

    addDeviceDetails(DevicePanelManager.getDeviceDetails(device, this), layout);

    return layout;
}

From source file:de.lmu.ifi.dbs.knowing.vaadin.MainApplication.java

License:Apache License

private Window getAboutDialog() {
    if (aboutWindow == null) {
        aboutWindow = new Window("About...");
        aboutWindow.setModal(true);/*from  w  ww .  j av a2 s .  com*/
        aboutWindow.setWidth("400px");

        VerticalLayout layout = (VerticalLayout) aboutWindow.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName("grey");

        CssLayout titleLayout = new CssLayout();
        H2 title = new H2("Knowing Vaadin Application");
        titleLayout.addComponent(title);
        SmallText description = new SmallText("<br>Copyright (c) Nepomuk Seiler, LMU Database <br>"
                + "Licensed under Apache Software Foundation 2.0 license (ASF).<br><br>"
                + "This software contains modules licenced under<br>"
                + " the Apache Software Foundation 2.0 license (ASF) and EPL<br><br>"
                + "Many thanks to Kai Tdter, Chris Brind, Neil Bartlett and<br>"
                + " Petter Holmstrm for their OSGi and Vaadin<br>"
                + " related work, blogs, and bundles.<br><br>"
                + "The icons are from the Silk icon set by Mark James<br>"
                + "<a href=\"http://www.famfamfam.com/lab/icons/silk/\">http://www.famfamfam.com/lab/icons/silk/</a>");
        description.setSizeUndefined();
        description.setContentMode(Label.CONTENT_XHTML);

        titleLayout.addComponent(description);
        aboutWindow.addComponent(titleLayout);

        @SuppressWarnings("serial")
        Button close = new Button("Close", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                (aboutWindow.getParent()).removeWindow(aboutWindow);
            }

        });
        layout.addComponent(close);
        layout.setComponentAlignment(close, Alignment.TOP_RIGHT);
    }
    return aboutWindow;
}

From source file:de.symeda.sormas.ui.AboutView.java

License:Open Source License

public AboutView() {
    CustomLayout aboutContent = new CustomLayout("aboutview");
    aboutContent.setStyleName("about-content");

    // Info section
    VerticalLayout infoLayout = new VerticalLayout();
    infoLayout.setSpacing(false);/*  w  w w  . j a v  a 2s  .  c  o  m*/
    infoLayout.setMargin(false);
    aboutContent.addComponent(infoLayout, "info");

    Label versionLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " "
            + I18nProperties.getCaption(Captions.aboutSormasVersion) + ": " + InfoProvider.get().getVersion(),
            ContentMode.HTML);
    infoLayout.addComponent(versionLabel);

    Link whatsNewLink = new Link(I18nProperties.getCaption(Captions.aboutWhatsNew),
            new ExternalResource(
                    "https://github.com/hzi-braunschweig/SORMAS-Project/releases/tag/releases%2Fversion-"
                            + InfoProvider.get().getBaseVersion()));
    whatsNewLink.setTargetName("_blank");
    infoLayout.addComponent(whatsNewLink);

    Link sormasWebsiteLink = new Link(I18nProperties.getCaption(Captions.aboutSormasWebsite),
            new ExternalResource("https://sormasorg.helmholtz-hzi.de/"));
    sormasWebsiteLink.setTargetName("_blank");
    infoLayout.addComponent(sormasWebsiteLink);

    Link sormasGithubLink = new Link("SORMAS Github",
            new ExternalResource("https://github.com/hzi-braunschweig/SORMAS-Project"));
    sormasGithubLink.setTargetName("_blank");
    infoLayout.addComponent(sormasGithubLink);

    Link changelogLink = new Link(I18nProperties.getCaption(Captions.aboutChangelog),
            new ExternalResource("https://github.com/hzi-braunschweig/SORMAS-Project/releases"));
    changelogLink.setTargetName("_blank");
    infoLayout.addComponent(changelogLink);

    // Documents section
    VerticalLayout documentsLayout = new VerticalLayout();
    documentsLayout.setSpacing(false);
    documentsLayout.setMargin(false);
    aboutContent.addComponent(documentsLayout, "documents");

    Button classificationDocumentButton = new Button(
            I18nProperties.getCaption(Captions.aboutCaseClassificationRules));
    CssStyles.style(classificationDocumentButton, ValoTheme.BUTTON_LINK, CssStyles.BUTTON_COMPACT);
    documentsLayout.addComponent(classificationDocumentButton);

    try {
        String serverUrl = new URL(((VaadinServletRequest) VaadinService.getCurrentRequest())
                .getHttpServletRequest().getRequestURL().toString()).getAuthority();
        StreamResource classificationResource = DownloadUtil.createStringStreamResource(
                ClassificationHtmlRenderer.createHtmlForDownload(serverUrl,
                        FacadeProvider.getDiseaseConfigurationFacade().getAllActivePrimaryDiseases()),
                "classification_rules.html", "text/html");
        new FileDownloader(classificationResource).extend(classificationDocumentButton);
    } catch (MalformedURLException e) {

    }

    Button dataDictionaryButton = new Button(I18nProperties.getCaption(Captions.aboutDataDictionary));
    CssStyles.style(dataDictionaryButton, ValoTheme.BUTTON_LINK, CssStyles.BUTTON_COMPACT);
    documentsLayout.addComponent(dataDictionaryButton);
    FileDownloader dataDictionaryDownloader = new FileDownloader(
            new ClassResource("/doc/SORMAS_Data_Dictionary.xlsx"));
    dataDictionaryDownloader.extend(dataDictionaryButton);

    Link technicalManualLink = new Link(I18nProperties.getCaption(Captions.aboutTechnicalManual),
            new ExternalResource(
                    "https://github.com/hzi-braunschweig/SORMAS-Project/files/2585973/SORMAS_Technical_Manual_Webversion_20180911.pdf"));
    technicalManualLink.setTargetName("_blank");
    documentsLayout.addComponent(technicalManualLink);

    setSizeFull();
    setStyleName("about-view");
    addComponent(aboutContent);
    setComponentAlignment(aboutContent, Alignment.MIDDLE_CENTER);
}

From source file:de.symeda.sormas.ui.caze.CaseController.java

License:Open Source License

public void openClassificationRulesPopup(CaseDataDto caze) {
    VerticalLayout classificationRulesLayout = new VerticalLayout();
    classificationRulesLayout.setMargin(true);

    DiseaseClassificationCriteriaDto diseaseCriteria = FacadeProvider.getCaseClassificationFacade()
            .getByDisease(caze.getDisease());
    if (diseaseCriteria != null) {
        Label suspectContent = new Label();
        suspectContent.setContentMode(ContentMode.HTML);
        suspectContent.setWidth(100, Unit.PERCENTAGE);
        suspectContent.setValue(ClassificationHtmlRenderer.createSuspectHtmlString(diseaseCriteria));
        classificationRulesLayout.addComponent(suspectContent);

        Label probableContent = new Label();
        probableContent.setContentMode(ContentMode.HTML);
        probableContent.setWidth(100, Unit.PERCENTAGE);
        probableContent.setValue(ClassificationHtmlRenderer.createProbableHtmlString(diseaseCriteria));
        classificationRulesLayout.addComponent(probableContent);

        Label confirmedContent = new Label();
        confirmedContent.setContentMode(ContentMode.HTML);
        confirmedContent.setWidth(100, Unit.PERCENTAGE);
        confirmedContent.setValue(ClassificationHtmlRenderer.createConfirmedHtmlString(diseaseCriteria));
        classificationRulesLayout.addComponent(confirmedContent);
    }//from w ww  . j a  va  2s  .c om

    Window popupWindow = VaadinUiUtil.showPopupWindow(classificationRulesLayout);
    popupWindow.addCloseListener(e -> {
        popupWindow.close();
    });
    popupWindow.setWidth(860, Unit.PIXELS);
    popupWindow.setHeight(80, Unit.PERCENTAGE);
    popupWindow.setCaption(
            I18nProperties.getString(Strings.classificationRulesFor) + " " + caze.getDisease().toString());
}

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 ww w.  j ava  2  s .  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.CaseInfoLayout.java

License:Open Source License

private void updateCaseInfo() {
    this.removeAllComponents();

    PersonDto personDto = FacadeProvider.getPersonFacade().getPersonByUuid(caseDto.getPerson().getUuid());

    VerticalLayout leftColumnLayout = new VerticalLayout();
    leftColumnLayout.setMargin(false);
    leftColumnLayout.setSpacing(true);//ww w.j  av  a 2 s  .c o m
    {
        addDescLabel(leftColumnLayout, DataHelper.getShortUuid(caseDto.getUuid()),
                I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.UUID))
                        .setDescription(caseDto.getUuid());

        addDescLabel(leftColumnLayout, caseDto.getEpidNumber(),
                I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.EPID_NUMBER))
                        .setDescription(caseDto.getEpidNumber());

        if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) {
            addDescLabel(leftColumnLayout, caseDto.getPerson(),
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.PERSON));

            HorizontalLayout ageSexLayout = new HorizontalLayout();
            ageSexLayout.setMargin(false);
            ageSexLayout.setSpacing(true);
            addDescLabel(ageSexLayout,
                    ApproximateAgeHelper.formatApproximateAge(personDto.getApproximateAge(),
                            personDto.getApproximateAgeType()),
                    I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.APPROXIMATE_AGE));
            addDescLabel(ageSexLayout, personDto.getSex(),
                    I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.SEX));
            leftColumnLayout.addComponent(ageSexLayout);
        }

        if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_MANAGEMENT_ACCESS)) {
            addDescLabel(leftColumnLayout, caseDto.getClinicianName(),
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CLINICIAN_NAME));
        }
    }
    this.addComponent(leftColumnLayout);

    VerticalLayout rightColumnLayout = new VerticalLayout();
    rightColumnLayout.setMargin(false);
    rightColumnLayout.setSpacing(true);
    {
        addDescLabel(rightColumnLayout,
                caseDto.getDisease() != Disease.OTHER ? caseDto.getDisease().toShortString()
                        : DataHelper.toStringNullable(caseDto.getDiseaseDetails()),
                I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE));

        if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) {
            addDescLabel(rightColumnLayout, caseDto.getCaseClassification(),
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CASE_CLASSIFICATION));
            addDescLabel(rightColumnLayout,
                    DateHelper.formatLocalShortDate(caseDto.getSymptoms().getOnsetDate()),
                    I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE));
        }
    }
    this.addComponent(rightColumnLayout);
}

From source file:de.symeda.sormas.ui.caze.CasesView.java

License:Open Source License

public 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 v a2s. c  o m
    }

    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 w w .j  ava 2s.  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.configuration.outbreak.OutbreakRegionConfigurationForm.java

License:Open Source License

private HorizontalLayout createAffectedDistrictsComponent() {
    HorizontalLayout affectedDistrictsComponent = new HorizontalLayout();
    affectedDistrictsComponent.setWidth(100, Unit.PERCENTAGE);
    affectedDistrictsComponent.setMargin(false);
    CssStyles.style(affectedDistrictsComponent, CssStyles.VSPACE_3);

    // Create two columns to display the districts
    VerticalLayout leftColumn = new VerticalLayout();
    leftColumn.setMargin(false);
    VerticalLayout middleColumn = new VerticalLayout();
    middleColumn.setMargin(false);//from  ww  w . j a  v  a2  s  . co  m
    VerticalLayout rightColumn = new VerticalLayout();
    rightColumn.setMargin(false);

    affectedDistrictsComponent.addComponent(leftColumn);
    // Add spacer label
    affectedDistrictsComponent.addComponent(new Label());
    affectedDistrictsComponent.addComponent(middleColumn);
    // Add spacer label
    affectedDistrictsComponent.addComponent(new Label());
    affectedDistrictsComponent.addComponent(rightColumn);

    affectedDistrictsComponent.setExpandRatio(leftColumn, 1);
    affectedDistrictsComponent.setExpandRatio(middleColumn, 1);
    affectedDistrictsComponent.setExpandRatio(rightColumn, 1);

    List<DistrictReferenceDto> districts = FacadeProvider.getDistrictFacade().getAllByRegion(region.getUuid());
    int index = 1;
    for (DistrictReferenceDto district : districts) {
        OptionGroup outbreakToggle = createOutbreakToggle(district);
        outbreakToggle.setWidth(100, Unit.PERCENTAGE);
        outbreakToggles[index - 1] = outbreakToggle;

        // Split districts evenly to all three columns
        if ((districts.size() % 3 == 0 && index <= districts.size() / 3)
                || (districts.size() % 3 != 0 && index <= (districts.size() / 3) + 1)) {
            leftColumn.addComponent(outbreakToggle);
        } else if ((districts.size() % 3 == 0 && index <= districts.size() / 1.5f)
                || ((districts.size() % 3 == 1 || districts.size() % 3 == 2)
                        && index <= (districts.size() / 1.5f) + 1)) {
            middleColumn.addComponent(outbreakToggle);
        } else {
            rightColumn.addComponent(outbreakToggle);
        }

        index++;
    }

    return affectedDistrictsComponent;
}

From source file:de.symeda.sormas.ui.contact.ContactDataView.java

License:Open Source License

@Override
public void enter(ViewChangeEvent event) {
    super.enter(event);
    setHeightUndefined();// w w  w  . j a  v a 2 s. c o  m

    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);
}