List of usage examples for com.vaadin.ui VerticalLayout setWidth
@Override public void setWidth(float width, Unit unit)
From source file:de.symeda.sormas.ui.dashboard.contacts.ContactsDashboardView.java
License:Open Source License
protected VerticalLayout createMapLayout() { if (mapComponent == null) { throw new UnsupportedOperationException( "MapComponent needs to be initialized before calling createMapLayout"); }/*from w ww .j a va2 s . c o m*/ VerticalLayout layout = new VerticalLayout(); layout.setMargin(false); layout.setSpacing(false); layout.setWidth(100, Unit.PERCENTAGE); layout.setHeight(555, Unit.PIXELS); mapComponent.setSizeFull(); layout.addComponent(mapComponent); layout.setExpandRatio(mapComponent, 1); mapComponent.setExpandListener(expanded -> { if (expanded) { dashboardLayout.removeComponent(statisticsComponent); epiCurveAndMapLayout.removeComponent(epiCurveLayout); ContactsDashboardView.this.setHeight(100, Unit.PERCENTAGE); epiCurveAndMapLayout.setHeight(100, Unit.PERCENTAGE); mapLayout.setSizeFull(); } else { dashboardLayout.addComponent(statisticsComponent, 1); epiCurveAndMapLayout.addComponent(epiCurveLayout, 0); mapLayout.setHeight(400, Unit.PIXELS); ContactsDashboardView.this.setHeightUndefined(); epiCurveAndMapLayout.setHeightUndefined(); } }); return layout; }
From source file:de.symeda.sormas.ui.dashboard.surveillance.DiseaseTileComponent.java
License:Open Source License
void addTopLayout(Disease disease, Long casesCount, boolean isOutbreak) { HorizontalLayout layout = new HorizontalLayout(); layout.setMargin(false);//from www. j ava 2 s .c om layout.setSpacing(false); CssStyles.style(layout, CssStyles.getDiseaseColor(disease)); layout.setHeight(75, Unit.PIXELS); layout.setWidth(100, Unit.PERCENTAGE); VerticalLayout nameAndOutbreakLayout = new VerticalLayout(); nameAndOutbreakLayout.setMargin(false); nameAndOutbreakLayout.setSpacing(false); nameAndOutbreakLayout.setHeight(100, Unit.PERCENTAGE); nameAndOutbreakLayout.setWidth(100, Unit.PERCENTAGE); HorizontalLayout nameLayout = new HorizontalLayout(); nameLayout.setMargin(false); nameLayout.setSpacing(false); nameLayout.setWidth(100, Unit.PERCENTAGE); nameLayout.setHeight(100, Unit.PERCENTAGE); Label nameLabel = new Label(disease.toShortString()); CssStyles.style(nameLabel, CssStyles.LABEL_WHITE, nameLabel.getValue().length() > 12 ? CssStyles.LABEL_LARGE : CssStyles.LABEL_XLARGE, CssStyles.LABEL_BOLD, CssStyles.ALIGN_CENTER, CssStyles.LABEL_UPPERCASE); nameLayout.addComponent(nameLabel); nameLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_CENTER); nameAndOutbreakLayout.addComponent(nameLayout); nameAndOutbreakLayout.setExpandRatio(nameLayout, 1); if (isOutbreak) { HorizontalLayout outbreakLayout = new HorizontalLayout(); outbreakLayout.setMargin(false); outbreakLayout.setSpacing(false); CssStyles.style(outbreakLayout, CssStyles.BACKGROUND_CRITICAL); outbreakLayout.setWidth(100, Unit.PERCENTAGE); outbreakLayout.setHeight(30, Unit.PIXELS); Label outbreakLabel = new Label(I18nProperties.getCaption(Captions.dashboardOutbreak)); CssStyles.style(outbreakLabel, CssStyles.LABEL_WHITE, CssStyles.ALIGN_CENTER, CssStyles.LABEL_UPPERCASE); outbreakLayout.addComponent(outbreakLabel); outbreakLayout.setComponentAlignment(outbreakLabel, Alignment.MIDDLE_CENTER); nameAndOutbreakLayout.addComponent(outbreakLayout); } layout.addComponent(nameAndOutbreakLayout); layout.setExpandRatio(nameAndOutbreakLayout, 1); HorizontalLayout countLayout = new HorizontalLayout(); countLayout.setMargin(false); countLayout.setSpacing(false); CssStyles.style(countLayout, CssStyles.getDiseaseColor(disease), CssStyles.BACKGROUND_DARKER); countLayout.setHeight(100, Unit.PERCENTAGE); countLayout.setWidth(100, Unit.PERCENTAGE); Label countLabel = new Label(casesCount.toString()); CssStyles.style(countLabel, CssStyles.LABEL_WHITE, CssStyles.LABEL_BOLD, CssStyles.LABEL_XXXLARGE, CssStyles.ALIGN_CENTER); countLayout.addComponent(countLabel); countLayout.setComponentAlignment(countLabel, Alignment.MIDDLE_CENTER); layout.addComponent(countLayout); layout.setExpandRatio(countLayout, 0.65f); addComponent(layout); }
From source file:de.symeda.sormas.ui.dashboard.surveillance.DiseaseTileComponent.java
License:Open Source License
void addStatsLayout(Long fatalities, Long events, String community) { VerticalLayout layout = new VerticalLayout(); layout.setWidth(100, Unit.PERCENTAGE); layout.setMargin(false);/*from w w w .j a v a2s.c om*/ layout.setSpacing(false); CssStyles.style(layout, CssStyles.BACKGROUND_HIGHLIGHT); HorizontalLayout statsItem = createStatsItem("Last report", community.length() == 0 ? "None" : community, false); CssStyles.style(statsItem, CssStyles.VSPACE_TOP_4); layout.addComponent(statsItem); layout.addComponent(createStatsItem(I18nProperties.getCaption(Captions.dashboardFatalities), fatalities.toString(), fatalities > 0)); statsItem = createStatsItem(I18nProperties.getCaption(Captions.DiseaseBurden_eventCount), events.toString(), false); CssStyles.style(statsItem, CssStyles.VSPACE_4); layout.addComponent(statsItem); addComponent(layout); }
From source file:de.symeda.sormas.ui.events.EventDataView.java
License:Open Source License
@Override public void enter(ViewChangeEvent event) { super.enter(event); setHeightUndefined();//from ww w.j a v a 2 s . c om String htmlLayout = LayoutUtil.fluidRow(LayoutUtil.fluidColumnLoc(8, 0, 12, 0, EVENT_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.getEventController() .getEventDataEditComponent(getEventRef().getUuid()); editComponent.setMargin(false); editComponent.setWidth(100, Unit.PERCENTAGE); editComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE); editComponent.addStyleName(CssStyles.MAIN_COMPONENT); layout.addComponent(editComponent, EVENT_LOC); TaskListComponent taskList = new TaskListComponent(TaskContext.EVENT, getEventRef()); taskList.addStyleName(CssStyles.SIDE_COMPONENT); layout.addComponent(taskList, TASKS_LOC); }
From source file:de.symeda.sormas.ui.importer.ImportPersonSelectField.java
License:Open Source License
@Override protected Component initContent() { if (importedCase == null || importedPerson == null) { return null; }//from w ww. ja v a 2s . com VerticalLayout layout = new VerticalLayout(); layout.setSizeUndefined(); layout.setWidth(100, Unit.PERCENTAGE); // Info label Label infoLabel = new Label(I18nProperties.getString(Strings.infoImportSimilarity)); CssStyles.style(infoLabel, CssStyles.VSPACE_3); layout.addComponent(infoLabel); // Imported case info VerticalLayout outerCaseInfoLayout = new VerticalLayout(); outerCaseInfoLayout.setWidth(100, Unit.PERCENTAGE); CssStyles.style(outerCaseInfoLayout, CssStyles.BACKGROUND_ROUNDED_CORNERS, CssStyles.BACKGROUND_SUB_CRITERIA, CssStyles.VSPACE_3, "v-scrollable"); Label importedCaseLabel = new Label(I18nProperties.getString(Strings.headingImportedCaseInfo)); CssStyles.style(importedCaseLabel, CssStyles.LABEL_BOLD, CssStyles.VSPACE_4); outerCaseInfoLayout.addComponent(importedCaseLabel); HorizontalLayout caseInfoLayout = new HorizontalLayout(); caseInfoLayout.setSpacing(true); caseInfoLayout.setSizeUndefined(); { Label diseaseField = new Label(); diseaseField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE)); diseaseField .setValue(DiseaseHelper.toString(importedCase.getDisease(), importedCase.getDiseaseDetails())); diseaseField.setWidthUndefined(); caseInfoLayout.addComponent(diseaseField); Label caseDateField = new Label(); if (importedCase.getSymptoms().getOnsetDate() != null) { caseDateField.setCaption( I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE)); caseDateField.setValue(DateHelper.formatLocalShortDate(importedCase.getSymptoms().getOnsetDate())); } else { caseDateField.setCaption( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REPORT_DATE)); caseDateField.setValue(DateHelper.formatLocalShortDate(importedCase.getReportDate())); } caseDateField.setWidthUndefined(); caseInfoLayout.addComponent(caseDateField); Label regionField = new Label(); regionField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REGION)); regionField.setValue(importedCase.getRegion().toString()); regionField.setWidthUndefined(); caseInfoLayout.addComponent(regionField); Label districtField = new Label(); districtField .setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISTRICT)); districtField.setValue(importedCase.getDistrict().toString()); districtField.setWidthUndefined(); caseInfoLayout.addComponent(districtField); Label communityField = new Label(); communityField .setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.COMMUNITY)); communityField .setValue(importedCase.getCommunity() != null ? importedCase.getCommunity().toString() : ""); communityField.setWidthUndefined(); caseInfoLayout.addComponent(communityField); Label facilityField = new Label(); facilityField.setCaption( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.HEALTH_FACILITY)); facilityField.setValue(FacilityHelper.buildFacilityString(null, importedCase.getHealthFacility() != null ? importedCase.getHealthFacility().toString() : "", importedCase.getHealthFacilityDetails())); facilityField.setWidthUndefined(); caseInfoLayout.addComponent(facilityField); } outerCaseInfoLayout.addComponent(caseInfoLayout); layout.addComponent(outerCaseInfoLayout); // Imported person info VerticalLayout outerPersonInfoLayout = new VerticalLayout(); outerPersonInfoLayout.setWidth(100, Unit.PERCENTAGE); CssStyles.style(outerPersonInfoLayout, CssStyles.BACKGROUND_ROUNDED_CORNERS, CssStyles.BACKGROUND_SUB_CRITERIA, CssStyles.VSPACE_3, "v-scrollable"); Label importedPersonLabel = new Label(I18nProperties.getString(Strings.headingImportedPersonInfo)); CssStyles.style(importedPersonLabel, CssStyles.LABEL_BOLD, CssStyles.VSPACE_4); outerPersonInfoLayout.addComponent(importedPersonLabel); HorizontalLayout personInfoLayout = new HorizontalLayout(); personInfoLayout.setSpacing(true); personInfoLayout.setSizeUndefined(); { Label firstNameField = new Label(); firstNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.FIRST_NAME)); firstNameField.setValue(importedPerson.getFirstName()); firstNameField.setWidthUndefined(); personInfoLayout.addComponent(firstNameField); Label lastNameField = new Label(); lastNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.LAST_NAME)); lastNameField.setValue(importedPerson.getLastName()); lastNameField.setWidthUndefined(); personInfoLayout.addComponent(lastNameField); Label nicknameField = new Label(); nicknameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.NICKNAME)); nicknameField.setValue(importedPerson.getNickname()); nicknameField.setWidthUndefined(); personInfoLayout.addComponent(nicknameField); Label ageField = new Label(); ageField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.APPROXIMATE_AGE)); ageField.setValue(ApproximateAgeHelper.formatApproximateAge(importedPerson.getApproximateAge(), importedPerson.getApproximateAgeType())); ageField.setWidthUndefined(); personInfoLayout.addComponent(ageField); Label sexField = new Label(); sexField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.SEX)); sexField.setValue(importedPerson.getSex() != null ? importedPerson.getSex().toString() : ""); sexField.setWidthUndefined(); personInfoLayout.addComponent(sexField); Label presentConditionField = new Label(); presentConditionField.setCaption( I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.PRESENT_CONDITION)); presentConditionField.setValue( importedPerson.getPresentCondition() != null ? importedPerson.getPresentCondition().toString() : null); presentConditionField.setWidthUndefined(); personInfoLayout.addComponent(presentConditionField); Label regionField = new Label(); regionField.setCaption(I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, LocationDto.REGION)); regionField.setValue(importedPerson.getAddress().getRegion() != null ? importedPerson.getAddress().getRegion().toString() : ""); regionField.setWidthUndefined(); personInfoLayout.addComponent(regionField); Label districtField = new Label(); districtField .setCaption(I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, LocationDto.DISTRICT)); districtField.setValue(importedPerson.getAddress().getDistrict() != null ? importedPerson.getAddress().getDistrict().toString() : ""); districtField.setWidthUndefined(); personInfoLayout.addComponent(districtField); Label communityField = new Label(); communityField .setCaption(I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, LocationDto.COMMUNITY)); communityField.setValue(importedPerson.getAddress().getCommunity() != null ? importedPerson.getAddress().getCommunity().toString() : ""); communityField.setWidthUndefined(); personInfoLayout.addComponent(communityField); Label cityField = new Label(); cityField.setCaption(I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, LocationDto.CITY)); cityField.setValue(importedPerson.getAddress().getCity()); cityField.setWidthUndefined(); personInfoLayout.addComponent(cityField); } outerPersonInfoLayout.addComponent(personInfoLayout); layout.addComponent(outerPersonInfoLayout); // Person selection/creation selectPerson = new OptionGroup(null); selectPerson.addItem(SELECT_PERSON); selectPerson.setItemCaption(SELECT_PERSON, I18nProperties.getCaption(Captions.personSelect)); CssStyles.style(selectPerson, CssStyles.VSPACE_NONE); selectPerson.addValueChangeListener(e -> { if (e.getProperty().getValue() != null) { createNewPerson.setValue(null); personGrid.setEnabled(true); mergeCheckBox.setEnabled(true); if (selectionChangeCallback != null) { selectionChangeCallback.accept(personGrid.getSelectedRow() != null); } } }); layout.addComponent(selectPerson); mergeCheckBox = new CheckBox(); mergeCheckBox.setCaption(I18nProperties.getCaption(Captions.caseImportMergeCase)); CssStyles.style(mergeCheckBox, CssStyles.VSPACE_3); layout.addComponent(mergeCheckBox); initPersonGrid(); // Deselect "create new" when person is selected personGrid.addSelectionListener(e -> { if (e.getSelected().size() > 0) { createNewPerson.setValue(null); } }); CssStyles.style(personGrid, CssStyles.VSPACE_3); layout.addComponent(personGrid); personGrid.addSelectionListener(e -> { if (selectionChangeCallback != null) { selectionChangeCallback.accept(!e.getSelected().isEmpty()); } }); createNewPerson = new OptionGroup(null); createNewPerson.addItem(CREATE_PERSON); createNewPerson.setItemCaption(CREATE_PERSON, I18nProperties.getCaption(Captions.personCreateNew)); // Deselect grid when "create new" is selected createNewPerson.addValueChangeListener(e -> { if (e.getProperty().getValue() != null) { selectPerson.setValue(null); personGrid.select(null); personGrid.setEnabled(false); mergeCheckBox.setEnabled(false); if (selectionChangeCallback != null) { selectionChangeCallback.accept(true); } } }); layout.addComponent(createNewPerson); // Set field values based on internal value setInternalValue(super.getInternalValue()); return layout; }
From source file:de.symeda.sormas.ui.person.PersonSelectField.java
License:Open Source License
@Override protected Component initContent() { VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true);/* w w w.ja v a2 s .c om*/ layout.setSizeUndefined(); layout.setWidth(100, Unit.PERCENTAGE); HorizontalLayout nameLayout = new HorizontalLayout(); nameLayout.setSpacing(true); nameLayout.setWidth(100, Unit.PERCENTAGE); firstNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.FIRST_NAME)); firstNameField.setWidth(100, Unit.PERCENTAGE); firstNameField.setRequired(true); nameLayout.addComponent(firstNameField); lastNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.LAST_NAME)); lastNameField.setWidth(100, Unit.PERCENTAGE); lastNameField.setRequired(true); nameLayout.addComponent(lastNameField); CssStyles.style(searchMatchesButton, CssStyles.FORCE_CAPTION, ValoTheme.BUTTON_PRIMARY); searchMatchesButton.addClickListener(e -> { personGrid.reload(firstNameField.getValue(), lastNameField.getValue()); selectBestMatch(); }); nameLayout.addComponent(searchMatchesButton); layout.addComponent(nameLayout); selectPerson = new OptionGroup(null); selectPerson.addItem(SELECT_PERSON); selectPerson.setItemCaption(SELECT_PERSON, I18nProperties.getCaption(Captions.personSelect)); CssStyles.style(selectPerson, CssStyles.VSPACE_NONE); selectPerson.addValueChangeListener(e -> { if (e.getProperty().getValue() != null) { createNewPerson.setValue(null); personGrid.setEnabled(true); if (selectionChangeCallback != null) { selectionChangeCallback.accept(personGrid.getSelectedRow() != null); } } }); layout.addComponent(selectPerson); initPersonGrid(); // unselect "create new" when person is selected personGrid.addSelectionListener(e -> { if (e.getSelected().size() > 0) { createNewPerson.setValue(null); } }); layout.addComponent(personGrid); personGrid.addSelectionListener(e -> { if (selectionChangeCallback != null) { selectionChangeCallback.accept(!e.getSelected().isEmpty()); } }); createNewPerson = new OptionGroup(null); createNewPerson.addItem(CREATE_PERSON); createNewPerson.setItemCaption(CREATE_PERSON, I18nProperties.getCaption(Captions.personCreateNew)); // unselect grid when "create new" is selected createNewPerson.addValueChangeListener(e -> { if (e.getProperty().getValue() != null) { selectPerson.setValue(null); personGrid.select(null); personGrid.setEnabled(false); if (selectionChangeCallback != null) { selectionChangeCallback.accept(true); } } }); layout.addComponent(createNewPerson); // set field values based on internal value setInternalValue(super.getInternalValue()); return layout; }
From source file:de.symeda.sormas.ui.samples.PathogenTestListEntry.java
License:Open Source License
public PathogenTestListEntry(PathogenTestDto pathogenTest) { setSpacing(true);/* ww w . ja va2 s .c om*/ setMargin(false); setWidth(100, Unit.PERCENTAGE); addStyleName(CssStyles.SORMAS_LIST_ENTRY); this.pathogenTest = pathogenTest; VerticalLayout labelLayout = new VerticalLayout(); labelLayout.setSpacing(false); labelLayout.setMargin(false); labelLayout.setWidth(100, Unit.PERCENTAGE); addComponent(labelLayout); setExpandRatio(labelLayout, 1); HorizontalLayout topLabelLayout = new HorizontalLayout(); topLabelLayout.setSpacing(false); topLabelLayout.setMargin(false); topLabelLayout.setWidth(100, Unit.PERCENTAGE); labelLayout.addComponent(topLabelLayout); Label labelTopLeft = new Label( PathogenTestType.toString(pathogenTest.getTestType(), pathogenTest.getTestTypeText())); CssStyles.style(labelTopLeft, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE); topLabelLayout.addComponent(labelTopLeft); if (pathogenTest.getTestResultVerified()) { Label labelTopRight = new Label(VaadinIcons.CHECK_CIRCLE.getHtml(), ContentMode.HTML); labelTopRight.setSizeUndefined(); labelTopRight.addStyleName(CssStyles.LABEL_LARGE); labelTopRight.setDescription(I18nProperties.getPrefixCaption(PathogenTestDto.I18N_PREFIX, PathogenTestDto.TEST_RESULT_VERIFIED)); topLabelLayout.addComponent(labelTopRight); topLabelLayout.setComponentAlignment(labelTopRight, Alignment.TOP_RIGHT); } if (!DataHelper.isNullOrEmpty(pathogenTest.getTestResultText())) { Label resultTextLabel = new Label(pathogenTest.getTestResultText()); labelLayout.addComponent(resultTextLabel); } HorizontalLayout middleLabelLayout = new HorizontalLayout(); middleLabelLayout.setSpacing(false); middleLabelLayout.setMargin(false); middleLabelLayout.setWidth(100, Unit.PERCENTAGE); labelLayout.addComponent(middleLabelLayout); Label labelLeft = new Label(DataHelper.toStringNullable( DiseaseHelper.toString(pathogenTest.getTestedDisease(), pathogenTest.getTestedDiseaseDetails()))); middleLabelLayout.addComponent(labelLeft); Label labelRight = new Label(DateHelper.formatLocalShortDateTime(pathogenTest.getTestDateTime())); labelRight.addStyleName(CssStyles.ALIGN_RIGHT); middleLabelLayout.addComponent(labelRight); middleLabelLayout.setComponentAlignment(labelRight, Alignment.TOP_RIGHT); Label labelBottom = new Label(DataHelper.toStringNullable(pathogenTest.getTestResult())); CssStyles.style(labelBottom, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE); if (pathogenTest.getTestResult() == PathogenTestResultType.POSITIVE) CssStyles.style(labelBottom, CssStyles.LABEL_CRITICAL); else CssStyles.style(labelBottom, CssStyles.LABEL_WARNING); labelLayout.addComponent(labelBottom); }
From source file:de.symeda.sormas.ui.samples.SampleDataView.java
License:Open Source License
@Override public void enter(ViewChangeEvent event) { super.enter(event); setHeightUndefined();//from w w w . j a v a2 s . co 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, PATHOGEN_TESTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, ADDITIONAL_TESTS_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); SampleDto sampleDto = FacadeProvider.getSampleFacade().getSampleByUuid(getSampleRef().getUuid()); CommitDiscardWrapperComponent<SampleEditForm> editComponent = ControllerProvider.getSampleController() .getSampleEditComponent(getSampleRef().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); BiConsumer<PathogenTestResultType, Boolean> pathogenTestChangedCallback = new BiConsumer<PathogenTestResultType, Boolean>() { @Override public void accept(PathogenTestResultType pathogenTestResult, Boolean verified) { if (verified) { SampleDto componentSample = editComponent.getWrappedComponent().getValue(); if (pathogenTestResult != componentSample.getPathogenTestResult()) { ControllerProvider.getSampleController().showChangePathogenTestResultWindow(editComponent, componentSample.getUuid(), pathogenTestResult); } } editComponent.getWrappedComponent().makePathogenTestResultRequired(); } }; CaseDataDto caseDto = FacadeProvider.getCaseFacade() .getCaseDataByUuid(sampleDto.getAssociatedCase().getUuid()); CaseInfoLayout caseInfoLayout = new CaseInfoLayout(caseDto); caseInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT); layout.addComponent(caseInfoLayout, CASE_LOC); PathogenTestListComponent pathogenTestList = new PathogenTestListComponent(getSampleRef(), pathogenTestChangedCallback); pathogenTestList.addStyleName(CssStyles.SIDE_COMPONENT); layout.addComponent(pathogenTestList, PATHOGEN_TESTS_LOC); if (UserProvider.getCurrent().hasUserRight(UserRight.ADDITIONAL_TEST_VIEW)) { AdditionalTestListComponent additionalTestList = new AdditionalTestListComponent( getSampleRef().getUuid()); additionalTestList.addStyleName(CssStyles.SIDE_COMPONENT); layout.addComponent(additionalTestList, ADDITIONAL_TESTS_LOC); } }
From source file:de.symeda.sormas.ui.samples.SampleListEntry.java
License:Open Source License
public SampleListEntry(SampleIndexDto sample) { this.sample = sample; setMargin(false);//from w w w. ja v a2 s.c o m setSpacing(true); setWidth(100, Unit.PERCENTAGE); addStyleName(CssStyles.SORMAS_LIST_ENTRY); VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setWidth(100, Unit.PERCENTAGE); mainLayout.setMargin(false); mainLayout.setSpacing(false); addComponent(mainLayout); setExpandRatio(mainLayout, 1); HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setWidth(100, Unit.PERCENTAGE); topLayout.setMargin(false); topLayout.setSpacing(false); mainLayout.addComponent(topLayout); VerticalLayout topLeftLayout = new VerticalLayout(); { topLeftLayout.setMargin(false); topLeftLayout.setSpacing(false); Label materialLabel = new Label(DataHelper.toStringNullable(sample.getSampleMaterial())); CssStyles.style(materialLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE); topLeftLayout.addComponent(materialLabel); Label dateTimeLabel = new Label( I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, SampleDto.SAMPLE_DATE_TIME) + ": " + DateHelper.formatLocalShortDate(sample.getSampleDateTime())); topLeftLayout.addComponent(dateTimeLabel); Label labLabel = new Label(DataHelper.toStringNullable(sample.getLab())); topLeftLayout.addComponent(labLabel); } topLayout.addComponent(topLeftLayout); VerticalLayout topRightLayout = new VerticalLayout(); { topRightLayout.addStyleName(CssStyles.ALIGN_RIGHT); topRightLayout.setMargin(false); topRightLayout.setSpacing(false); Label resultLabel = new Label(); CssStyles.style(resultLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE); if (sample.getPathogenTestResult() != null) { resultLabel.setValue(DataHelper.toStringNullable(sample.getPathogenTestResult())); if (sample.getPathogenTestResult() == PathogenTestResultType.POSITIVE) { resultLabel.addStyleName(CssStyles.LABEL_CRITICAL); } else if (sample.getPathogenTestResult() == PathogenTestResultType.INDETERMINATE) { resultLabel.addStyleName(CssStyles.LABEL_WARNING); } } else if (sample.getSpecimenCondition() == SpecimenCondition.NOT_ADEQUATE) { resultLabel.setValue(DataHelper.toStringNullable(sample.getSpecimenCondition())); resultLabel.addStyleName(CssStyles.LABEL_WARNING); } topRightLayout.addComponent(resultLabel); Label referredLabel = new Label(); CssStyles.style(referredLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE); if (sample.isReferred()) { referredLabel.setValue(I18nProperties.getCaption(Captions.sampleReferredShort)); referredLabel.addStyleName(CssStyles.LABEL_NOT); } else if (sample.isReceived()) { referredLabel.setValue(I18nProperties.getCaption(Captions.sampleReceived) + " " + DateHelper.formatLocalShortDate(sample.getReceivedDate())); } else if (sample.isShipped()) { referredLabel.setValue(I18nProperties.getCaption(Captions.sampleShipped) + " " + DateHelper.formatLocalShortDate(sample.getShipmentDate())); } else { referredLabel.setValue(I18nProperties.getCaption(Captions.sampleNotShippedLong)); } topRightLayout.addComponent(referredLabel); } topLayout.addComponent(topRightLayout); topLayout.setComponentAlignment(topRightLayout, Alignment.TOP_RIGHT); if (UserProvider.getCurrent().hasUserRight(UserRight.ADDITIONAL_TEST_VIEW)) { Label labelAdditionalTests = new Label(I18nProperties.getString(Strings.entityAdditionalTests) + " " + sample.getAdditionalTestingStatus().toString().toLowerCase()); mainLayout.addComponent(labelAdditionalTests); } }
From source file:de.symeda.sormas.ui.samples.SamplesView.java
License:Open Source License
public SamplesView() { super(VIEW_NAME); sampleListComponent = new SampleGridComponent(getViewTitleLabel(), this); setSizeFull();//from w w w .j a v a2s .c o m addComponent(sampleListComponent); if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_EXPORT)) { PopupButton exportButton = new PopupButton(I18nProperties.getCaption(Captions.export)); exportButton.setIcon(VaadinIcons.DOWNLOAD); VerticalLayout exportLayout = new VerticalLayout(); exportLayout.setSpacing(true); exportLayout.setMargin(true); exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL); exportLayout.setWidth(200, Unit.PIXELS); exportButton.setContent(exportLayout); addHeaderComponent(exportButton); Button basicExportButton = new Button(I18nProperties.getCaption(Captions.exportBasic)); basicExportButton.setDescription(I18nProperties.getString(Strings.infoBasicExport)); basicExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); basicExportButton.setIcon(VaadinIcons.TABLE); basicExportButton.setWidth(100, Unit.PERCENTAGE); exportLayout.addComponent(basicExportButton); StreamResource streamResource = new GridExportStreamResource(sampleListComponent.getGrid(), "sormas_samples", "sormas_samples_" + DateHelper.formatDateForExport(new Date()) + ".csv", SampleGrid.EDIT_BTN_ID); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(basicExportButton); Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed)); 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( SampleExportDto.class, (Integer start, Integer max) -> FacadeProvider.getSampleFacade().getExportList( UserProvider.getCurrent().getUuid(), sampleListComponent.getGrid().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(extendedExportStreamResource).extend(extendedExportButton); } }