Example usage for com.vaadin.ui VerticalLayout setSpacing

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

Introduction

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

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:de.symeda.sormas.ui.task.TaskListEntry.java

License:Open Source License

public TaskListEntry(TaskIndexDto task) {

    this.task = task;

    setMargin(false);//from   w ww .ja v a  2 s.c om
    setSpacing(true);
    setWidth(100, Unit.PERCENTAGE);
    addStyleName(CssStyles.SORMAS_LIST_ENTRY);

    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setMargin(false);
    topLayout.setSpacing(false);
    topLayout.setWidth(100, Unit.PERCENTAGE);
    addComponent(topLayout);
    setExpandRatio(topLayout, 1);

    // TOP LEFT
    VerticalLayout topLeftLayout = new VerticalLayout();

    topLeftLayout.setMargin(false);
    topLeftLayout.setSpacing(false);

    Label taskTypeLabel = new Label(DataHelper.toStringNullable(task.getTaskType()));
    CssStyles.style(taskTypeLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
    topLeftLayout.addComponent(taskTypeLabel);

    Label suggestedStartLabel = new Label(
            I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.SUGGESTED_START) + ": "
                    + DateHelper.formatLocalShortDate(task.getSuggestedStart()));
    topLeftLayout.addComponent(suggestedStartLabel);

    Label dueDateLabel = new Label(I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.DUE_DATE) + ": "
            + DateHelper.formatLocalShortDate(task.getDueDate()));
    topLeftLayout.addComponent(dueDateLabel);

    topLayout.addComponent(topLeftLayout);

    // TOP RIGHT
    VerticalLayout topRightLayout = new VerticalLayout();

    topRightLayout.addStyleName(CssStyles.ALIGN_RIGHT);
    topRightLayout.setMargin(false);
    topRightLayout.setSpacing(false);

    Label statusLabel = new Label(DataHelper.toStringNullable(task.getTaskStatus()));
    CssStyles.style(statusLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
    topRightLayout.addComponent(statusLabel);

    Label priorityLabel = new Label(
            DataHelper.toStringNullable(I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.PRIORITY)
                    + ": " + task.getPriority()));
    if (TaskPriority.HIGH == task.getPriority()) {
        priorityLabel.addStyleName(CssStyles.LABEL_IMPORTANT);
    } else if (TaskPriority.NORMAL == task.getPriority()) {
        priorityLabel.addStyleName(CssStyles.LABEL_NEUTRAL);
    }
    topRightLayout.addComponent(priorityLabel);

    Label userLabel = new Label(I18nProperties.getPrefixCaption(TaskDto.I18N_PREFIX, TaskDto.ASSIGNEE_USER)
            + ": " + task.getAssigneeUser().getCaption());
    topRightLayout.addComponent(userLabel);

    topLayout.addComponent(topRightLayout);
    topLayout.setComponentAlignment(topRightLayout, Alignment.TOP_RIGHT);

    String statusStyle;
    switch (task.getTaskStatus()) {
    case DONE:
        statusStyle = CssStyles.LABEL_DONE;
        break;
    case NOT_EXECUTABLE:
        statusStyle = CssStyles.LABEL_NOT;
        break;
    case REMOVED:
        statusStyle = CssStyles.LABEL_DISCARDED;
        break;
    default:
        statusStyle = null;
    }

    if (statusStyle != null) {
        taskTypeLabel.addStyleName(statusStyle);
        suggestedStartLabel.addStyleName(statusStyle);
        dueDateLabel.addStyleName(statusStyle);
        statusLabel.addStyleName(statusStyle);
        priorityLabel.addStyleName(statusStyle);
        userLabel.addStyleName(statusStyle);
    }
}

From source file:de.symeda.sormas.ui.therapy.TherapyView.java

License:Open Source License

public TherapyView() {
    super(VIEW_NAME);

    prescriptionCriteria = ViewModelProviders.of(TherapyView.class).get(PrescriptionCriteria.class);
    treatmentCriteria = ViewModelProviders.of(TherapyView.class).get(TreatmentCriteria.class);

    VerticalLayout container = new VerticalLayout();
    container.setSpacing(false);
    container.setWidth(100, Unit.PERCENTAGE);
    container.setMargin(true);/*  ww  w  .java  2s .  c  om*/

    container.addComponent(createPrescriptionsHeader());

    prescriptionGrid = new PrescriptionGrid(this);
    prescriptionGrid.setCriteria(prescriptionCriteria);
    prescriptionGrid.setHeightMode(HeightMode.ROW);
    CssStyles.style(prescriptionGrid, CssStyles.VSPACE_2);
    container.addComponent(prescriptionGrid);

    container.addComponent(createTreatmentsHeader());

    treatmentGrid = new TreatmentGrid();
    treatmentGrid.setCriteria(treatmentCriteria);
    container.addComponent(treatmentGrid);
    container.setExpandRatio(treatmentGrid, 1);

    setSubComponent(container);
}

From source file:de.symeda.sormas.ui.therapy.TherapyView.java

License:Open Source License

private VerticalLayout createPrescriptionsHeader() {
    VerticalLayout prescriptionsHeader = new VerticalLayout();
    prescriptionsHeader.setMargin(false);
    prescriptionsHeader.setSpacing(false);
    prescriptionsHeader.setWidth(100, Unit.PERCENTAGE);

    HorizontalLayout headlineRow = new HorizontalLayout();
    headlineRow.setMargin(false);/*from   ww  w. ja  va 2  s.  c o m*/
    headlineRow.setSpacing(true);
    headlineRow.setWidth(100, Unit.PERCENTAGE);
    {
        Label prescriptionsLabel = new Label(I18nProperties.getString(Strings.entityPrescriptions));
        CssStyles.style(prescriptionsLabel, CssStyles.H3);
        headlineRow.addComponent(prescriptionsLabel);
        headlineRow.setExpandRatio(prescriptionsLabel, 1);

        // Bulk operations
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            MenuBar bulkOperationsDropdown = new MenuBar();
            MenuItem bulkOperationsItem = bulkOperationsDropdown
                    .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

            Command deleteCommand = selectedItem -> {
                ControllerProvider.getTherapyController()
                        .deleteAllSelectedPrescriptions(prescriptionGrid.getSelectedRows(), new Runnable() {
                            public void run() {
                                reloadPrescriptionGrid();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                    deleteCommand);

            headlineRow.addComponent(bulkOperationsDropdown);
            headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT);
        }

        Button newPrescriptionButton = new Button(
                I18nProperties.getCaption(Captions.prescriptionNewPrescription));
        CssStyles.style(newPrescriptionButton, ValoTheme.BUTTON_PRIMARY);
        newPrescriptionButton.addClickListener(e -> {
            ControllerProvider.getTherapyController().openPrescriptionCreateForm(
                    prescriptionCriteria.getTherapy(), this::reloadPrescriptionGrid);
        });
        headlineRow.addComponent(newPrescriptionButton);

        headlineRow.setComponentAlignment(newPrescriptionButton, Alignment.MIDDLE_RIGHT);
    }
    prescriptionsHeader.addComponent(headlineRow);

    HorizontalLayout filterRow = new HorizontalLayout();
    filterRow.setMargin(false);
    filterRow.setSpacing(true);
    {
        prescriptionTypeFilter = new ComboBox();
        prescriptionTypeFilter.setWidth(140, Unit.PIXELS);
        prescriptionTypeFilter.setInputPrompt(I18nProperties.getPrefixCaption(PrescriptionDto.I18N_PREFIX,
                PrescriptionDto.PRESCRIPTION_TYPE));
        prescriptionTypeFilter.addItems((Object[]) TreatmentType.values());
        prescriptionTypeFilter.addValueChangeListener(e -> {
            prescriptionCriteria.prescriptionType(((TreatmentType) e.getProperty().getValue()));
            navigateTo(prescriptionCriteria);
        });
        filterRow.addComponent(prescriptionTypeFilter);

        prescriptionTextFilter = new TextField();
        prescriptionTextFilter.setWidth(300, Unit.PIXELS);
        prescriptionTextFilter.setNullRepresentation("");
        prescriptionTextFilter.setInputPrompt(I18nProperties.getString(Strings.promptPrescriptionTextFilter));
        prescriptionTextFilter.addTextChangeListener(e -> {
            prescriptionCriteria.textFilter(e.getText());
            reloadPrescriptionGrid();
        });
        filterRow.addComponent(prescriptionTextFilter);
    }
    prescriptionsHeader.addComponent(filterRow);

    return prescriptionsHeader;
}

From source file:de.symeda.sormas.ui.therapy.TherapyView.java

License:Open Source License

private VerticalLayout createTreatmentsHeader() {
    VerticalLayout treatmentsHeader = new VerticalLayout();
    treatmentsHeader.setMargin(false);//from  ww  w .j a  v a  2  s . co  m
    treatmentsHeader.setSpacing(false);
    treatmentsHeader.setWidth(100, Unit.PERCENTAGE);

    HorizontalLayout headlineRow = new HorizontalLayout();
    headlineRow.setMargin(false);
    headlineRow.setSpacing(true);
    headlineRow.setWidth(100, Unit.PERCENTAGE);
    {
        Label treatmentsLabel = new Label(I18nProperties.getString(Strings.headingTreatments));
        CssStyles.style(treatmentsLabel, CssStyles.H3);
        headlineRow.addComponent(treatmentsLabel);
        headlineRow.setExpandRatio(treatmentsLabel, 1);

        // Bulk operations
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            MenuBar bulkOperationsDropdown = new MenuBar();
            MenuItem bulkOperationsItem = bulkOperationsDropdown
                    .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

            Command deleteCommand = selectedItem -> {
                ControllerProvider.getTherapyController()
                        .deleteAllSelectedTreatments(treatmentGrid.getSelectedRows(), new Runnable() {
                            public void run() {
                                reloadTreatmentGrid();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                    deleteCommand);

            headlineRow.addComponent(bulkOperationsDropdown);
            headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT);
        }

        Button newTreatmentButton = new Button(I18nProperties.getCaption(Captions.treatmentNewTreatment));
        newTreatmentButton.addClickListener(e -> {
            ControllerProvider.getTherapyController().openTreatmentCreateForm(treatmentCriteria.getTherapy(),
                    this::reloadTreatmentGrid);
        });
        headlineRow.addComponent(newTreatmentButton);

        headlineRow.setComponentAlignment(newTreatmentButton, Alignment.MIDDLE_RIGHT);
    }
    treatmentsHeader.addComponent(headlineRow);

    HorizontalLayout filterRow = new HorizontalLayout();
    filterRow.setMargin(false);
    filterRow.setSpacing(true);
    {
        treatmentTypeFilter = new ComboBox();
        treatmentTypeFilter.setWidth(140, Unit.PIXELS);
        treatmentTypeFilter.setInputPrompt(
                I18nProperties.getPrefixCaption(TreatmentDto.I18N_PREFIX, TreatmentDto.TREATMENT_TYPE));
        treatmentTypeFilter.addItems((Object[]) TreatmentType.values());
        treatmentTypeFilter.addValueChangeListener(e -> {
            treatmentCriteria.treatmentType(((TreatmentType) e.getProperty().getValue()));
            navigateTo(treatmentCriteria);
        });
        filterRow.addComponent(treatmentTypeFilter);

        treatmentTextFilter = new TextField();
        treatmentTextFilter.setWidth(300, Unit.PIXELS);
        treatmentTextFilter.setNullRepresentation("");
        treatmentTextFilter.setInputPrompt(I18nProperties.getString(Strings.promptTreatmentTextFilter));
        treatmentTextFilter.addTextChangeListener(e -> {
            treatmentCriteria.textFilter(e.getText());
            reloadTreatmentGrid();
        });
        filterRow.addComponent(treatmentTextFilter);
    }
    treatmentsHeader.addComponent(filterRow);

    return treatmentsHeader;
}

From source file:de.symeda.sormas.ui.utils.AbstractSubNavigationView.java

License:Open Source License

protected Optional<VerticalLayout> createInfoLayout() {
    VerticalLayout infoLayout = new VerticalLayout();
    infoLayout.setMargin(false);//from   w w w  .  j a  va2s.  c  o  m
    infoLayout.setSpacing(false);
    infoLayout.setSizeUndefined();
    CssStyles.stylePrimary(infoLayout, CssStyles.CALLOUT);
    infoLabel = new Label("");
    infoLabelSub = new Label("");
    CssStyles.style(infoLabelSub, ValoTheme.LABEL_SMALL);
    infoLayout.addComponent(infoLabel);
    infoLayout.addComponent(infoLabelSub);

    return Optional.of(infoLayout);
}

From source file:de.symeda.sormas.ui.utils.AbstractView.java

License:Open Source License

protected AbstractView(String viewName) {
    this.viewName = viewName;

    setSizeFull();//w w w .  j  a  v a  2 s. c om
    setMargin(false);
    setSpacing(false);

    viewHeader = new HorizontalLayout();
    viewHeader.setWidth(100, Unit.PERCENTAGE);
    viewHeader.setHeightUndefined();
    viewHeader.setMargin(new MarginInfo(false, true));
    viewHeader.setSpacing(true);
    CssStyles.style(viewHeader, "view-header");

    VerticalLayout viewTitleLayout = new VerticalLayout();
    {
        viewTitleLayout.setSizeUndefined();
        viewTitleLayout.setSpacing(false);
        viewTitleLayout.setMargin(false);

        // note: splitting title and subtitle into labels does not work with the css
        String viewTitle = I18nProperties.getPrefixCaption("View", viewName.replaceAll("/", "."));
        String viewSubTitle = I18nProperties.getPrefixCaption("View", viewName.replaceAll("/", ".") + ".sub",
                "");
        viewTitleLabel = new Label(viewTitle);
        viewTitleLabel.setSizeUndefined();
        CssStyles.style(viewTitleLabel, CssStyles.H1, CssStyles.VSPACE_NONE);
        viewTitleLayout.addComponent(viewTitleLabel);
        Label viewSubTitleLabel = new Label(viewSubTitle);
        viewSubTitleLabel.setSizeUndefined();
        CssStyles.style(viewSubTitleLabel, CssStyles.H4, CssStyles.VSPACE_TOP_NONE);
        viewTitleLayout.addComponent(viewSubTitleLabel);
    }
    viewHeader.addComponent(viewTitleLayout);
    viewHeader.setExpandRatio(viewTitleLayout, 1);

    addComponent(viewHeader);
    setExpandRatio(viewHeader, 0);
}

From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java

License:Open Source License

public static Window showSimplePopupWindow(String caption, String contentText) {
    Window window = new Window(null);
    window.setModal(true);//from   ww  w.  j av  a  2s  . com
    window.setSizeUndefined();
    window.setResizable(false);
    window.center();

    VerticalLayout popupLayout = new VerticalLayout();
    popupLayout.setMargin(true);
    popupLayout.setSpacing(true);
    popupLayout.setSizeUndefined();
    Label contentLabel = new Label(contentText);
    contentLabel.setWidth(100, Unit.PERCENTAGE);
    popupLayout.addComponent(contentLabel);
    Button okayButton = new Button(I18nProperties.getCaption(Captions.actionOkay));
    okayButton.addClickListener(e -> {
        window.close();
    });
    CssStyles.style(okayButton, ValoTheme.BUTTON_PRIMARY);
    popupLayout.addComponent(okayButton);
    popupLayout.setComponentAlignment(okayButton, Alignment.BOTTOM_RIGHT);

    window.setCaption(caption);
    window.setContent(popupLayout);

    UI.getCurrent().addWindow(window);

    return window;
}

From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java

License:Open Source License

public static Window showConfirmationPopup(String caption, Component content, String confirmCaption,
        String cancelCaption, Integer width, Consumer<Boolean> resultConsumer) {
    Window popupWindow = VaadinUiUtil.createPopupWindow();
    if (width != null) {
        popupWindow.setWidth(width, Unit.PIXELS);
    } else {//from w  w  w  .j  a v a 2 s .  c  om
        popupWindow.setWidthUndefined();
    }
    popupWindow.setCaption(caption);

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    content.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(content);

    ConfirmationComponent confirmationComponent = new ConfirmationComponent(false) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onConfirm() {
            popupWindow.close();
            resultConsumer.accept(true);
        }

        @Override
        protected void onCancel() {
            popupWindow.close();
            resultConsumer.accept(false);
        }
    };
    confirmationComponent.getConfirmButton().setCaption(confirmCaption);
    confirmationComponent.getCancelButton().setCaption(cancelCaption);

    popupWindow.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            confirmationComponent.getCancelButton().click();
        }
    });

    layout.addComponent(confirmationComponent);
    layout.setComponentAlignment(confirmationComponent, Alignment.BOTTOM_RIGHT);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setSpacing(true);
    popupWindow.setContent(layout);

    UI.getCurrent().addWindow(popupWindow);
    return popupWindow;
}

From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java

License:Open Source License

public static Window showDeleteConfirmationWindow(String content, Runnable callback) {
    Window popupWindow = VaadinUiUtil.createPopupWindow();

    VerticalLayout deleteLayout = new VerticalLayout();
    deleteLayout.setMargin(true);//from w w w. j a v  a  2 s . co  m
    deleteLayout.setSizeUndefined();
    deleteLayout.setSpacing(true);

    Label description = new Label(content);
    description.setWidth(100, Unit.PERCENTAGE);
    deleteLayout.addComponent(description);

    ConfirmationComponent deleteConfirmationComponent = new ConfirmationComponent(false) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onConfirm() {
            popupWindow.close();
            onDone();
            callback.run();
        }

        @Override
        protected void onCancel() {
            popupWindow.close();
        }
    };
    deleteConfirmationComponent.getConfirmButton().setCaption(I18nProperties.getString(Strings.yes));
    deleteConfirmationComponent.getCancelButton().setCaption(I18nProperties.getString(Strings.no));
    deleteLayout.addComponent(deleteConfirmationComponent);
    deleteLayout.setComponentAlignment(deleteConfirmationComponent, Alignment.BOTTOM_RIGHT);

    popupWindow.setCaption(I18nProperties.getString(Strings.headingConfirmDeletion));
    popupWindow.setContent(deleteLayout);
    UI.getCurrent().addWindow(popupWindow);

    return popupWindow;
}

From source file:de.unioninvestment.eai.portal.portlet.crud.CrudUI.java

License:Apache License

private ComponentContainer initializeHelpPage() {

    DatasourceInfos datasourceInfos = new DatasourceInfos();
    DatasourceInfoView datasourceInfoView = new DatasourceInfoView(datasourceInfos.getContainer());
    this.datasourceInfo = new DatasourceInfoPresenter(datasourceInfoView, datasourceInfos);

    VerticalLayout help = new VerticalLayout();
    help.setSpacing(true);
    help.addComponent(new Link(Context.getMessage("portlet.crud.page.help.message"),
            new ExternalResource(settings.getHelpUrl())));
    help.addComponent(new Label(
            Context.getMessage("portlet.crud.page.help.buildNumberLabel", settings.getBuildNumber())));
    help.addComponent(this.datasourceInfo.getView());

    return help;/* w ww.ja va 2  s.c  om*/
}