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.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  ww w . jav a 2 s.  c o  m
    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);
    layout.setSpacing(false);/*from w  w  w.  j  a  v  a  2 s  .c om*/
    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 w ww  .j a va 2  s  .c o  m*/

    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.login.LoginScreen.java

License:Open Source License

private void buildUI() {
    addStyleName("login-screen");

    // login form, centered in the available part of the screen
    VerticalLayout loginFormLayout = new VerticalLayout();
    loginFormLayout.addStyleName("login-form");
    loginFormLayout.setMargin(false);
    Component loginForm = buildLoginForm();
    loginFormLayout.addComponent(loginForm);
    loginFormLayout.addComponent(buildLoginDetailsLayout());

    // layout to center login form when there is sufficient screen space
    // - see the theme for how this is made responsive for various screen
    // sizes//w  ww  . ja v  a  2  s.c  om
    CssLayout loginLayout = new CssLayout();
    loginLayout.setStyleName("login-form-container");
    loginLayout.addComponent(loginFormLayout);

    // information text about logging in
    CssLayout loginInformation = buildLoginInformation();

    // custom html layout
    CssLayout loginSidebarLayout = buildLoginSidebarLayout();

    addComponent(loginInformation);
    addComponent(loginLayout);
    addComponent(loginSidebarLayout);
}

From source file:de.symeda.sormas.ui.reports.WeeklyReportOfficersGrid.java

License:Open Source License

@Override
public void itemClick(ItemClickEvent event) {
    if (event.getPropertyId().equals(VIEW_DETAILS_BTN_ID)) {
        WeeklyReportOfficerSummaryDto summaryDto = (WeeklyReportOfficerSummaryDto) event.getItemId();
        if (summaryDto.getInformants() > 0) {
            VerticalLayout layout = new VerticalLayout();
            layout.setSizeUndefined();//  w  ww . j  av  a2  s .c o m
            layout.setMargin(true);
            Window window = VaadinUiUtil.showPopupWindow(layout);

            WeeklyReportInformantsGrid grid = new WeeklyReportInformantsGrid(summaryDto.getOfficer(),
                    new EpiWeek(year, week));
            grid.setWidth(960, Unit.PIXELS);
            grid.setHeightMode(HeightMode.ROW);
            grid.setHeightUndefined();
            layout.addComponent(grid);
            window.setCaption(String.format(I18nProperties.getCaption(Captions.weeklyReportsInDistrict),
                    summaryDto.getDistrict().toString()) + " - " + I18nProperties.getString(Strings.epiWeek)
                    + " " + week + "/" + year);
        }
    }
}

From source file:de.symeda.sormas.ui.reports.WeeklyReportRegionsGrid.java

License:Open Source License

@Override
public void itemClick(ItemClickEvent event) {
    if (event.getPropertyId().equals(VIEW_DETAILS_BTN_ID)) {
        WeeklyReportRegionSummaryDto summaryDto = (WeeklyReportRegionSummaryDto) event.getItemId();
        VerticalLayout layout = new VerticalLayout();
        layout.setSizeUndefined();/*from   w w  w . ja  v a  2 s  .  com*/
        layout.setMargin(true);
        Window window = VaadinUiUtil.showPopupWindow(layout);

        WeeklyReportOfficersGrid grid = new WeeklyReportOfficersGrid();
        grid.reload(summaryDto.getRegion(), year, week);
        grid.setWidth(1600, Unit.PIXELS);
        grid.setHeightMode(HeightMode.ROW);
        grid.setHeightUndefined();
        layout.addComponent(grid);
        window.setCaption(String.format(I18nProperties.getCaption(Captions.weeklyReportsInDistrict),
                summaryDto.getRegion().toString()) + " - " + I18nProperties.getString(Strings.epiWeek) + " "
                + week + "/" + year);
    }
}

From source file:de.symeda.sormas.ui.samples.PathogenTestListEntry.java

License:Open Source License

public PathogenTestListEntry(PathogenTestDto pathogenTest) {
    setSpacing(true);/*from  w w w.j ava  2  s  .  c  o  m*/
    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.SampleController.java

License:Open Source License

private void requestSampleCollectionTaskCreation(SampleDto dto, SampleEditForm form) {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);

    ConfirmationComponent requestTaskComponent = VaadinUiUtil.buildYesNoConfirmationComponent();

    Label description = new Label(I18nProperties.getString(Strings.messageCreateCollectionTask),
            ContentMode.HTML);//from w ww.ja  va  2s. com
    description.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(description);
    layout.addComponent(requestTaskComponent);
    layout.setComponentAlignment(requestTaskComponent, Alignment.BOTTOM_RIGHT);
    layout.setSizeUndefined();
    layout.setSpacing(true);

    Window popupWindow = VaadinUiUtil.showPopupWindow(layout);
    popupWindow.setSizeUndefined();
    popupWindow.setCaption(I18nProperties.getString(Strings.headingCreateNewTaskQuestion));
    requestTaskComponent.getConfirmButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            popupWindow.close();
            ControllerProvider.getTaskController().createSampleCollectionTask(TaskContext.CASE,
                    dto.getAssociatedCase(), dto);
        }
    });
    requestTaskComponent.getCancelButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            popupWindow.close();
        }
    });
}

From source file:de.symeda.sormas.ui.samples.SampleController.java

License:Open Source License

public void showChangePathogenTestResultWindow(CommitDiscardWrapperComponent<SampleEditForm> editComponent,
        String sampleUuid, PathogenTestResultType newResult) {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);

    ConfirmationComponent confirmationComponent = VaadinUiUtil.buildYesNoConfirmationComponent();

    Label description = new Label(String
            .format(I18nProperties.getString(Strings.messageChangePathogenTestResult), newResult.toString()));
    description.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(description);/*from  www .j  a  v a 2  s. co  m*/
    layout.addComponent(confirmationComponent);
    layout.setComponentAlignment(confirmationComponent, Alignment.BOTTOM_RIGHT);
    layout.setSizeUndefined();
    layout.setSpacing(true);

    Window popupWindow = VaadinUiUtil.showPopupWindow(layout);
    popupWindow.setSizeUndefined();
    popupWindow.setCaption(I18nProperties.getString(Strings.headingChangePathogenTestResult));
    confirmationComponent.getConfirmButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            editComponent.commit();
            SampleDto sample = FacadeProvider.getSampleFacade().getSampleByUuid(sampleUuid);
            sample.setPathogenTestResult(newResult);
            FacadeProvider.getSampleFacade().saveSample(sample);
            popupWindow.close();
            SormasUI.refreshView();
        }
    });
    confirmationComponent.getCancelButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            popupWindow.close();
        }
    });
}

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