Example usage for com.vaadin.ui VerticalLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(float width, Unit unit) 

Source Link

Usage

From source file:de.symeda.sormas.ui.statistics.StatisticsView.java

License:Open Source License

public StatisticsView() {
    super(VIEW_NAME);
    setWidth(100, Unit.PERCENTAGE);/*w  ww  .j ava  2s  . c om*/

    emptyResultLabel = new Label(I18nProperties.getString(Strings.infoNoCasesFoundStatistics));

    // Main layout
    VerticalLayout statisticsLayout = new VerticalLayout();
    statisticsLayout.setMargin(true);
    statisticsLayout.setSpacing(true);
    statisticsLayout.setWidth(100, Unit.PERCENTAGE);

    // Filters layout
    addFiltersLayout(statisticsLayout);

    // Visualization layout
    Label visualizationTitle = new Label(I18nProperties.getString(Strings.headingVisualization));
    visualizationTitle.setWidthUndefined();
    CssStyles.style(visualizationTitle, CssStyles.STATISTICS_TITLE);
    statisticsLayout.addComponent(visualizationTitle);

    visualizationComponent = new StatisticsVisualizationComponent();
    CssStyles.style(visualizationComponent, CssStyles.STATISTICS_TITLE_BOX);
    statisticsLayout.addComponent(visualizationComponent);

    // Options layout
    addOptionsLayout(statisticsLayout);

    // Generate button
    addGenerateButton(statisticsLayout);

    // Results layout
    addResultsLayout(statisticsLayout);

    // Disclaimer
    Label disclaimer = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " "
            + I18nProperties.getString(Strings.infoStatisticsDisclaimer), ContentMode.HTML);
    statisticsLayout.addComponent(disclaimer);

    addComponent(statisticsLayout);
}

From source file:de.symeda.sormas.ui.statistics.StatisticsView.java

License:Open Source License

private void addFiltersLayout(VerticalLayout statisticsLayout) {
    Label filtersLayoutTitle = new Label(I18nProperties.getString(Strings.headingFilters));
    filtersLayoutTitle.setWidthUndefined();
    CssStyles.style(filtersLayoutTitle, CssStyles.STATISTICS_TITLE);
    statisticsLayout.addComponent(filtersLayoutTitle);

    VerticalLayout filtersSectionLayout = new VerticalLayout();
    CssStyles.style(filtersSectionLayout, CssStyles.STATISTICS_TITLE_BOX);
    filtersSectionLayout.setSpacing(true);
    filtersSectionLayout.setWidth(100, Unit.PERCENTAGE);
    Label filtersInfoText = new Label(I18nProperties.getString(Strings.infoStatisticsFilter), ContentMode.HTML);
    filtersSectionLayout.addComponent(filtersInfoText);

    filtersLayout = new VerticalLayout();
    filtersLayout.setSpacing(true);//w w w .  jav a 2  s .c  o  m
    filtersLayout.setMargin(false);
    filtersSectionLayout.addComponent(filtersLayout);

    // Filters footer
    HorizontalLayout filtersSectionFooter = new HorizontalLayout();
    {
        filtersSectionFooter.setSpacing(true);

        Button addFilterButton = new Button(I18nProperties.getCaption(Captions.statisticsAddFilter),
                VaadinIcons.PLUS);
        CssStyles.style(addFilterButton, ValoTheme.BUTTON_PRIMARY);
        addFilterButton.addClickListener(e -> {
            filtersLayout.addComponent(createFilterComponentLayout());
        });
        filtersSectionFooter.addComponent(addFilterButton);

        Button resetFiltersButton = new Button(I18nProperties.getCaption(Captions.statisticsResetFilters));
        resetFiltersButton.addClickListener(e -> {
            filtersLayout.removeAllComponents();
            filterComponents.clear();
        });
        filtersSectionFooter.addComponent(resetFiltersButton);
    }
    filtersSectionLayout.addComponent(filtersSectionFooter);

    statisticsLayout.addComponent(filtersSectionLayout);
}

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);//from  w  w  w .  j a  v  a  2 s  . com
    container.setWidth(100, Unit.PERCENTAGE);
    container.setMargin(true);

    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   w  w  w  . j  a  v  a 2s .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);//w w w  .j a  va 2  s . com
    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.AbstractEditForm.java

License:Open Source License

@SuppressWarnings("rawtypes")
public static CommitDiscardWrapperComponent<VerticalLayout> buildCommitDiscardWrapper(
        AbstractEditForm... wrappedForms) {
    VerticalLayout formsLayout = new VerticalLayout();
    if (wrappedForms.length > 0) { // not perfect, but necessary to make this work in grid views like CaseDataView
        formsLayout.setWidth(wrappedForms[0].getWidth(), wrappedForms[0].getWidthUnits());
    }//from w  w  w  . j  ava 2 s .co  m
    FieldGroup[] fieldGroups = new FieldGroup[wrappedForms.length];
    for (int i = 0; i < wrappedForms.length; i++) {
        formsLayout.addComponent(wrappedForms[i]);
        wrappedForms[i].setWidth(100, Unit.PERCENTAGE);
        fieldGroups[i] = wrappedForms[i].getFieldGroup();
    }
    return new CommitDiscardWrapperComponent<>(formsLayout, fieldGroups);
}

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 av  a2s  .  c o  m*/
        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.uni_tuebingen.qbic.qbicmainportlet.MultiscaleComponent.java

License:Open Source License

void buildEmptyComments() {

    // add comments
    VerticalLayout addComment = new VerticalLayout();
    addComment.setMargin(true);/*from   w  w w . j  av a  2s. c  o  m*/
    addComment.setWidth(100, Unit.PERCENTAGE);
    final TextArea comments = new TextArea();
    comments.setInputPrompt("Write your comment here...");
    comments.setWidth(100, Unit.PERCENTAGE);
    comments.setRows(2);
    Button commentsOk = new Button("Add Comment");
    commentsOk.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    commentsOk.addClickListener(new ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = -5369241494545155677L;

        public void buttonClick(ClickEvent event) {
            if ("".equals(comments.getValue()))
                return;

            String newComment = comments.getValue();
            // reset comments
            comments.setValue("");
            // use some date format
            Date dNow = new Date();
            SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

            Note note = new Note();
            note.setComment(newComment);
            note.setUsername(controller.getUser());
            note.setTime(ft.format(dNow));

            // show it now
            // pastcomments.getContainerDataSource().addItem(note);
            notes.add(note);

            // TODO write back
            Label commentsLabel = new Label(translateComments(notes), ContentMode.HTML);
            commentsPanel.setContent(commentsLabel);

            // write back to openbis
            if (!controller.addNote(note)) {
                Notification.show("Could not add comment to sample. How did you do that?");
            }

        }

    });

    HorizontalLayout inputPrompt = new HorizontalLayout();
    inputPrompt.addComponent(comments);
    inputPrompt.addComponent(commentsOk);

    inputPrompt.setWidth(50, Unit.PERCENTAGE);
    inputPrompt.setComponentAlignment(commentsOk, Alignment.TOP_RIGHT);
    inputPrompt.setExpandRatio(comments, 1.0f);

    // addComment.addComponent(comments);
    // addComment.addComponent(commentsOk);

    addComment.addComponent(commentsPanel);
    addComment.addComponent(inputPrompt);

    // addComment.setComponentAlignment(comments, Alignment.TOP_CENTER);
    // addComment.setComponentAlignment(commentsOk, Alignment.MIDDLE_CENTER);

    addComment.setComponentAlignment(commentsPanel, Alignment.TOP_CENTER);
    addComment.setComponentAlignment(inputPrompt, Alignment.MIDDLE_CENTER);

    mainlayout.addComponent(addComment);

    // mainlayout.addComponent(pastcomments);
    Label commentsLabel = new Label("No comments added so far.", ContentMode.HTML);
    commentsPanel.setContent(commentsLabel);

    // mainlayout.addComponent(commentsPanel);
    // mainlayout.setComponentAlignment(commentsPanel,
    // Alignment.TOP_CENTER);
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjectView.java

License:Open Source License

VerticalLayout initTable() {
    this.table = this.buildFilterTable();
    this.tableClickChangeTreeView();
    VerticalLayout tableSection = new VerticalLayout();
    VerticalLayout tableSectionContent = new VerticalLayout();

    tableSection.setCaption("Exp. Steps");
    // tableSectionContent.setCaption("Registered Experiments");
    // tableSectionContent.setIcon(FontAwesome.FLASK);
    tableSectionContent.addComponent(this.table);

    tableSectionContent.setMargin(new MarginInfo(true, false, false, true));
    tableSection.setMargin(new MarginInfo(true, false, false, true));
    this.table.setWidth("100%");
    tableSection.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.8f, Unit.PIXELS);
    tableSectionContent.setWidth("100%");

    tableSection.addComponent(tableSectionContent);

    this.export = new Button("Export as TSV");
    buttonLayoutSection = new VerticalLayout();
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setHeight(null);/* ww  w.ja v  a 2 s.  c  o  m*/
    buttonLayout.setWidth("100%");
    buttonLayout.addComponent(this.export);
    buttonLayout.setMargin(new MarginInfo(false, false, true, false));
    buttonLayoutSection.addComponent(buttonLayout);
    buttonLayoutSection.setSpacing(true);
    buttonLayoutSection.setMargin(new MarginInfo(false, false, true, true));

    tableSection.addComponent(buttonLayoutSection);

    return tableSection;
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjectView.java

License:Open Source License

/**
 * //from  w w  w.  j  a  v a2  s  . c  o m
 * @return
 */
VerticalLayout initGraph() {
    VerticalLayout graphSection = new VerticalLayout();
    graphSectionContent = new VerticalLayout();
    graphSection.setCaption("Project Graph");

    graphSectionContent.setMargin(new MarginInfo(true, false, true, true));
    graphSection.setMargin(new MarginInfo(true, false, true, true));
    graphSection.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.8f, Unit.PIXELS);
    graphSectionContent.setWidth("100%");
    /*
     * final Button loadGraph = new Button("[+]"); loadGraph.setStyleName(ValoTheme.BUTTON_LINK);
     * loadGraph.addClickListener(new ClickListener() {
     * 
     * @Override public void buttonClick(ClickEvent event) { if
     * (graphSectionContent.getComponentCount() == 0 || !(graphSectionContent.getComponent(0)
     * instanceof Image)) { ProgressBar progress = new ProgressBar();
     * progress.setIndeterminate(true); Label info = new Label(
     * "Computing the project graph can take several seconds on big projects. Please be patient.");
     * info.setStyleName(ValoTheme.LABEL_SUCCESS); graphSectionContent.addComponent(info);
     * graphSectionContent.addComponent(progress); Worker worker = new Worker(getCurrent());
     * worker.start(); UI.getCurrent().setPollInterval(500); loadGraph.setEnabled(false); }
     * 
     * 
     * }
     * 
     * public void processed() { UI.getCurrent().setPollInterval(-1); loadGraph.setVisible(false); }
     * 
     * class Worker extends Thread { private ProjectView projectView;
     * 
     * public Worker(ProjectView current) { projectView = current; }
     * 
     * @Override public void run() { projectView.updateContentGraph(); synchronized
     * (UI.getCurrent()) { processed(); }
     * 
     * } } });
     */
    graphSection.addComponent(graphSectionContent);
    return graphSection;
}