Example usage for com.vaadin.ui VerticalLayout setExpandRatio

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

Introduction

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

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

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  ww .j ava2  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.unioninvestment.eai.portal.portlet.crud.export.ExportDialog.java

License:Apache License

@SuppressWarnings("serial")
private void init() {
    setCaption(Context.getMessage("portlet.crud.dialog.export.title"));
    setModal(true);/*w  w w.  ja v a2  s  . c o m*/
    setResizable(false);
    setWidth("400px");
    addCloseListener(new CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            handleWindowCloseEvent();
        }
    });

    indicator = new ProgressBar(0.0f);
    indicator.setWidth("100%");
    UI.getCurrent().setPollInterval(1000);

    if (automaticDownload) {
        VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        layout.addComponent(indicator);

        setContent(layout);
    } else {
        HorizontalLayout layout = new HorizontalLayout();
        layout.setWidth("100%");
        layout.setMargin(true);
        layout.setSpacing(true);

        downloadLink = new Link();
        downloadLink.setStyleName(LiferayTheme.BUTTON_LINK);
        downloadLink.setCaption(Context.getMessage("portlet.crud.dialog.export.download"));
        downloadLink.setEnabled(false);

        layout.addComponents(indicator, downloadLink);
        layout.setComponentAlignment(indicator, Alignment.MIDDLE_CENTER);
        layout.setComponentAlignment(downloadLink, Alignment.MIDDLE_CENTER);
        layout.setExpandRatio(indicator, 1f);

        setContent(layout);
    }

}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultTextAreaView.java

License:Apache License

@Override
public void showEditor(String xhtml) {

    final RichTextArea richTextArea = new RichTextArea();
    richTextArea.setNullRepresentation("");
    richTextArea.setWidth("100%");
    richTextArea.setValue(xhtml);//from  w  w w. ja  v a 2 s  . c  om

    Button saveButton = new Button("Speichern", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String changedContent = (String) richTextArea.getValue();
            presenter.contentChanged(changedContent);
        }
    });

    Button cancelButton = new Button("Abbrechen", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            presenter.cancelEditing();
        }
    });

    CssLayout buttons = new CssLayout(saveButton, cancelButton);
    buttons.setStyleName("actions");
    VerticalLayout layout = new VerticalLayout(richTextArea, buttons);
    layout.setSpacing(true);
    if (getHeight() >= 0f) {
        richTextArea.setHeight("100%");
        layout.setExpandRatio(richTextArea, 1f);
    }
    setCompositionRoot(layout);
}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.ui.Popup.java

License:Apache License

private void init() {
    this.setModal(true);
    this.setHeight(325, Unit.PIXELS);
    this.setWidth(500, Unit.PIXELS);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//w  w w  . j  ava2 s  .c  o  m
    layout.setSpacing(true);
    layout.setMargin(true);
    setContent(layout);

    Panel panel = new Panel();
    panel.setHeight(100, Unit.PERCENTAGE);
    panel.addStyleName(Runo.PANEL_LIGHT);
    layout.addComponent(panel);
    layout.setExpandRatio(panel, 1);

    messageLabel = new Label();
    panel.setContent(messageLabel);

    Button close = new Button("Beenden", new Button.ClickListener() {
        private static final long serialVersionUID = -8385641161488292715L;

        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(Popup.this);
        }
    });

    layout.addComponent(close);
    layout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);
}

From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java

public Component getSources(InterestProfile profile) {
    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setWidth("100%");
    VerticalLayout sourcesLayout = new VerticalLayout();
    sourcesLayout.setWidth("100%");
    Panel sourcesPanel = new Panel(sourcesLayout);

    List<CheckBox> checkBoxes = new ArrayList<>();
    HashMap<String, GridLayout> sourceLayouts = new HashMap<>();
    profile.getSources().entrySet().stream()
            .sorted((e1, e2) -> e1.getKey().getName().compareToIgnoreCase(e2.getKey().getName())).forEach(e -> {
                Source source = e.getKey();
                boolean enabled = e.getValue();
                GridLayout sourceLayout = new GridLayout(5, 1);
                sourceLayout.setSizeFull();

                CheckBox sourceSelected = new CheckBox();
                sourceSelected.setValue(enabled);
                sourceSelected.addStyleName(ValoTheme.CHECKBOX_LARGE);
                sourceSelected.addValueChangeListener(v -> profile.getSources().replace(source, v.getValue()));
                checkBoxes.add(sourceSelected);

                Image sourceLogo = new Image();
                sourceLogo.addStyleName("logosmall");
                sourceLogo.setSource(new ExternalResource(source.getLogo()));
                sourceLogo.addClickListener(c -> {
                    sourceSelected.setValue(!sourceSelected.getValue());
                    profile.getSources().replace(source, sourceSelected.getValue());
                });/*w w  w.j  av a 2 s . com*/
                VerticalLayout layoutLogo = new VerticalLayout(sourceLogo);
                layoutLogo.setWidth("150px");
                layoutLogo.setHeight("50px");
                layoutLogo.setMargin(false);
                layoutLogo.setSpacing(false);
                layoutLogo.setComponentAlignment(sourceLogo, Alignment.MIDDLE_LEFT);

                Label labelHeadLine = new Label(
                        source.getCategory().getIcon().getHtml() + "  " + source.getName(), ContentMode.HTML);
                labelHeadLine.addStyleName(ValoTheme.LABEL_H3);

                Label labelDescription = new Label(source.getDescription(), ContentMode.HTML);
                labelDescription.setWidth("300px");
                PopupView popup = new PopupView(null, labelDescription);

                Button buttonDescription = new Button(VaadinIcons.INFO_CIRCLE_O);
                buttonDescription.addClickListener(ce -> {
                    popup.setPopupVisible(true);
                });

                sourceLayout.addComponents(sourceSelected, layoutLogo, labelHeadLine, popup, buttonDescription);
                sourceLayout.setComponentAlignment(sourceSelected, Alignment.MIDDLE_CENTER);
                sourceLayout.setComponentAlignment(layoutLogo, Alignment.MIDDLE_CENTER);
                sourceLayout.setColumnExpandRatio(2, 5);
                sourceLayout.setSpacing(true);

                sourceLayouts.put(source.getName().toLowerCase().replaceAll(" ", "").replaceAll("-", "")
                        .replaceAll("_", ""), sourceLayout);
                sourcesLayout.addComponent(sourceLayout);
            });

    sourcesPanel.setContent(sourcesLayout);
    sourcesPanel.setHeight("100%");
    sourcesPanel.setCaption(Language.get(Word.SOURCES));
    Language.setCustom(Word.SOURCES, s -> sourcesPanel.setCaption(s));
    windowLayout.addComponent(sourcesPanel);
    windowLayout.setExpandRatio(sourcesPanel, 1);
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);

    CheckBox checkBoxSelectAll = new CheckBox();
    Language.setCustom(Word.SELECT_ALL, s -> checkBoxSelectAll.setCaption(s));
    checkBoxSelectAll.setWidth("100%");
    checkBoxSelectAll.addValueChangeListener(e -> {
        profile.getSources().replaceAll((c, enabled) -> checkBoxSelectAll.getValue());
        checkBoxes.forEach(c -> c.setValue(checkBoxSelectAll.getValue()));
    });

    TextField textFieldSearch = new TextField();
    Language.setCustom(Word.SEARCH, s -> textFieldSearch.setPlaceholder(s));
    textFieldSearch.setWidth("100%");
    textFieldSearch.setMaxLength(255);
    textFieldSearch.setPlaceholder(Language.get(Word.SEARCH));
    textFieldSearch.addValueChangeListener(searchValue -> {
        sourceLayouts.forEach((sourceName, sourceLayout) -> {
            if (!sourceName.contains(searchValue.getValue().toLowerCase().replaceAll(" ", "")
                    .replaceAll("-", "").replaceAll("_", ""))) {
                sourcesLayout.removeComponent(sourceLayout);
            } else {
                sourcesLayout.addComponent(sourceLayout);
            }
        });
    });

    Label placeholder = new Label();
    placeholder.setWidth("100%");

    GridLayout footer = new GridLayout(3, 1);
    footer.setSpacing(true);
    footer.setMargin(new MarginInfo(true, false, false, false));
    footer.addStyleName("menubar");
    footer.setWidth("100%");
    footer.addComponents(checkBoxSelectAll, textFieldSearch, placeholder);
    footer.setComponentAlignment(checkBoxSelectAll, Alignment.MIDDLE_LEFT);
    footer.setComponentAlignment(textFieldSearch, Alignment.MIDDLE_CENTER);

    windowLayout.addComponent(footer);
    windowLayout.setHeight("350px");
    return windowLayout;
}

From source file:dhbw.clippinggorilla.userinterface.windows.ConfirmationDialog.java

public ConfirmationDialog(String confirmationText, Runnable onOk, Runnable onCancel) {
    addCloseListener(ce -> onCancel.run());
    setCaption(Language.get(Word.CONFIRMATION));

    VerticalLayout root = new VerticalLayout();
    root.setSpacing(false);/*from ww  w  .  jav a2 s . c  o m*/
    root.setMargin(false);
    root.setSizeFull();

    Label text = new Label(confirmationText);
    text.setStyleName(ValoTheme.LABEL_H3);
    text.setWidth("100%");
    VerticalLayout layoutText = new VerticalLayout(text);
    layoutText.setSizeFull();
    layoutText.addStyleName("tags");
    layoutText.setSpacing(false);

    root.addComponent(layoutText);

    Label ignoreMe = new Label();

    Button ok = new Button(Language.get(Word.OK));
    ok.addClickListener(c -> {
        close();
        onOk.run();
    });
    ok.addStyleName(ValoTheme.BUTTON_DANGER);

    Button cancel = new Button(Language.get(Word.CANCEL));
    cancel.addClickListener(c -> {
        close();
        onCancel.run();
    });
    cancel.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    GridLayout footer = new GridLayout(3, 1);
    footer.setSpacing(true);
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.addStyleName("menubar");
    footer.addComponents(ignoreMe, ok, cancel);
    footer.setColumnExpandRatio(0, 5);
    footer.setComponentAlignment(ok, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER);
    root.setExpandRatio(layoutText, 5);
    root.addComponent(footer);

    setContent(root);
    setModal(true);
    center();
    setDraggable(false);
    setResizable(false);
    setWidth("350px");
    setHeight("200px");
    UI.getCurrent().addWindow(this);

}

From source file:dhbw.clippinggorilla.userinterface.windows.GroupProfileWindow.java

public Component getSources(GroupInterestProfile profile, boolean isAdmin) {
    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setWidth("100%");
    VerticalLayout sourcesLayout = new VerticalLayout();
    sourcesLayout.setWidth("100%");
    Panel sourcesPanel = new Panel(sourcesLayout);

    List<CheckBox> checkBoxes = new ArrayList<>();
    HashMap<String, GridLayout> sourceLayouts = new HashMap<>();
    profile.getSources().entrySet().stream()
            .sorted((e1, e2) -> e1.getKey().getName().compareToIgnoreCase(e2.getKey().getName())).forEach(e -> {
                Source source = e.getKey();
                boolean enabled = e.getValue();
                GridLayout sourceLayout = new GridLayout(5, 1);
                sourceLayout.setSizeFull();

                CheckBox sourceSelected = new CheckBox();
                sourceSelected.setValue(enabled);
                sourceSelected.addStyleName(ValoTheme.CHECKBOX_LARGE);
                sourceSelected.addValueChangeListener(v -> profile.getSources().replace(source, v.getValue()));
                sourceSelected.setEnabled(isAdmin);
                checkBoxes.add(sourceSelected);

                Image sourceLogo = new Image();
                sourceLogo.addStyleName("logosmall");
                sourceLogo.setSource(new ExternalResource(source.getLogo()));
                if (isAdmin) {
                    sourceLogo.addClickListener(c -> {
                        sourceSelected.setValue(!sourceSelected.getValue());
                        profile.getSources().replace(source, sourceSelected.getValue());
                    });//from   w  w w.ja  v  a  2s.  c  om
                }
                VerticalLayout layoutLogo = new VerticalLayout(sourceLogo);
                layoutLogo.setWidth("150px");
                layoutLogo.setHeight("50px");
                layoutLogo.setMargin(false);
                layoutLogo.setSpacing(false);
                layoutLogo.setComponentAlignment(sourceLogo, Alignment.MIDDLE_LEFT);

                Label labelHeadLine = new Label(
                        source.getCategory().getIcon().getHtml() + "  " + source.getName(), ContentMode.HTML);
                labelHeadLine.addStyleName(ValoTheme.LABEL_H3);

                Label labelDescription = new Label(source.getDescription(), ContentMode.HTML);
                labelDescription.setWidth("300px");
                PopupView popup = new PopupView(null, labelDescription);

                Button buttonDescription = new Button(VaadinIcons.INFO_CIRCLE_O);
                buttonDescription.addClickListener(ce -> {
                    popup.setPopupVisible(true);
                });

                sourceLayout.addComponents(sourceSelected, layoutLogo, labelHeadLine, popup, buttonDescription);
                sourceLayout.setComponentAlignment(sourceSelected, Alignment.MIDDLE_CENTER);
                sourceLayout.setComponentAlignment(layoutLogo, Alignment.MIDDLE_CENTER);
                sourceLayout.setColumnExpandRatio(2, 5);
                sourceLayout.setSpacing(true);

                sourceLayouts.put(source.getName().toLowerCase().replaceAll(" ", "").replaceAll("-", "")
                        .replaceAll("_", ""), sourceLayout);
                sourcesLayout.addComponent(sourceLayout);
            });

    sourcesPanel.setContent(sourcesLayout);
    sourcesPanel.setHeight("100%");
    sourcesPanel.setCaption(Language.get(Word.SOURCES));
    Language.setCustom(Word.SOURCES, s -> sourcesPanel.setCaption(s));
    windowLayout.addComponent(sourcesPanel);
    windowLayout.setExpandRatio(sourcesPanel, 1);
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);

    CheckBox checkBoxSelectAll = new CheckBox();
    Language.setCustom(Word.SELECT_ALL, s -> checkBoxSelectAll.setCaption(s));
    checkBoxSelectAll.setWidth("100%");
    checkBoxSelectAll.addValueChangeListener(e -> {
        profile.getSources().replaceAll((c, enabled) -> checkBoxSelectAll.getValue());
        checkBoxes.forEach(c -> c.setValue(checkBoxSelectAll.getValue()));
    });
    checkBoxSelectAll.setEnabled(isAdmin);

    TextField textFieldSearch = new TextField();
    Language.setCustom(Word.SEARCH, s -> textFieldSearch.setPlaceholder(s));
    textFieldSearch.setWidth("100%");
    textFieldSearch.setMaxLength(255);
    textFieldSearch.setPlaceholder(Language.get(Word.SEARCH));
    textFieldSearch.addValueChangeListener(searchValue -> {
        sourceLayouts.forEach((sourceName, sourceLayout) -> {
            if (!sourceName.contains(searchValue.getValue().toLowerCase().replaceAll(" ", "")
                    .replaceAll("-", "").replaceAll("_", ""))) {
                sourcesLayout.removeComponent(sourceLayout);
            } else {
                sourcesLayout.addComponent(sourceLayout);
            }
        });
    });

    Label placeholder = new Label();
    placeholder.setWidth("100%");

    GridLayout footer = new GridLayout(3, 1);
    footer.setSpacing(true);
    footer.setMargin(new MarginInfo(true, false, false, false));
    footer.addStyleName("menubar");
    footer.setWidth("100%");
    footer.addComponents(checkBoxSelectAll, textFieldSearch, placeholder);
    footer.setComponentAlignment(checkBoxSelectAll, Alignment.MIDDLE_LEFT);
    footer.setComponentAlignment(textFieldSearch, Alignment.MIDDLE_CENTER);

    windowLayout.addComponent(footer);
    windowLayout.setHeight("350px");
    return windowLayout;
}

From source file:dhbw.clippinggorilla.userinterface.windows.ManageSourcesWindow.java

public Component getSourcesList() {
    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setSizeFull();// w  w  w .  j  av a 2 s  . co  m
    sourcesLayout = new VerticalLayout();
    sourcesLayout.setWidth("100%");
    Panel sourcesPanel = new Panel(sourcesLayout);

    refreshSources();

    sourcesPanel.setContent(sourcesLayout);
    sourcesPanel.setHeight("100%");
    windowLayout.addComponent(sourcesPanel);
    windowLayout.setExpandRatio(sourcesPanel, 1);
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);

    TextField textFieldSearch = new TextField();
    textFieldSearch.setPlaceholder(Language.get(Word.SEARCH));
    textFieldSearch.addValueChangeListener(searchValue -> {
        sourceLayouts.forEach((sourceName, sourceLayout) -> {
            if (!sourceName.contains(searchValue.getValue().toLowerCase().replaceAll(" ", "")
                    .replaceAll("-", "").replaceAll("_", ""))) {
                sourcesLayout.removeComponent(sourceLayout);
            } else {
                sourcesLayout.addComponent(sourceLayout);
            }
        });
    });

    Button buttonAddSource = new Button(Language.get(Word.ADD_SOURCE), VaadinIcons.PLUS);
    buttonAddSource.addClickListener(ce -> UI.getCurrent().addWindow(NewSourceWindow.create()));

    Button buttonSave = new Button();
    Language.set(Word.SAVE, buttonSave);
    buttonSave.setIcon(VaadinIcons.CHECK);
    buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonSave.addClickListener(ce -> {
        close();
    });
    buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

    Label placeholder = new Label();

    GridLayout footer = new GridLayout(4, 1);
    footer.setSpacing(true);
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.addStyleName("menubar");
    footer.setWidth(100.0f, Unit.PERCENTAGE);
    footer.addComponents(textFieldSearch, placeholder, buttonAddSource, buttonSave);
    footer.setComponentAlignment(textFieldSearch, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(buttonAddSource, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER);
    footer.setColumnExpandRatio(1, 5);

    windowLayout.addComponent(footer);
    return windowLayout;
}

From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java

public Component getThirdStage(Source s) {
    Label header = new Label(Language.get(Word.CRAWLER));
    header.addStyleName(ValoTheme.LABEL_H1);

    Crawler crawler;/* w w w  . j a va 2  s. com*/
    if (s.getCrawler() != null) {
        crawler = s.getCrawler();
    } else {
        crawler = new Crawler(s);
        s.setCrawler(crawler);
    }

    GridLayout mainGrid = new GridLayout(2, 2);
    mainGrid.setSizeFull();
    mainGrid.setSpacing(true);

    FormLayout layoutForms = new FormLayout();

    //Exclude or Include
    RadioButtonGroup<Boolean> radios = new RadioButtonGroup<>();
    radios.setItems(true, false);
    radios.setItemCaptionGenerator(b -> b ? Language.get(Word.INCLUDE_TAGS) : Language.get(Word.EXCLUDE_TAGS));
    radios.setItemIconGenerator(b -> b ? VaadinIcons.CHECK : VaadinIcons.CLOSE);
    radios.setSelectedItem(true);
    radios.addValueChangeListener(event -> include = event.getValue());

    //By Class
    CssLayout addByClassGroup = new CssLayout();
    addByClassGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    TextField textFieldAddByClass = new TextField();
    textFieldAddByClass.setWidth("465px");
    Button buttonAddByClass = new Button(VaadinIcons.PLUS);
    buttonAddByClass.addClickListener(e -> {
        crawler.addByClass(textFieldAddByClass.getValue(), include);
        refreshList(mainGrid, crawler);
        textFieldAddByClass.clear();
    });
    addByClassGroup.addComponents(textFieldAddByClass, buttonAddByClass);
    addByClassGroup.setCaption(Language.get(Word.BYCLASS));

    //ByTag
    CssLayout addByTagGroup = new CssLayout();
    addByTagGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    TextField textFieldAddByTag = new TextField();
    Button buttonAddByTag = new Button(VaadinIcons.PLUS);
    textFieldAddByTag.setWidth("465px");
    buttonAddByTag.addClickListener(e -> {
        crawler.addByTag(textFieldAddByTag.getValue(), include);
        refreshList(mainGrid, crawler);
        textFieldAddByTag.clear();
    });
    addByTagGroup.addComponents(textFieldAddByTag, buttonAddByTag);
    addByTagGroup.setCaption(Language.get(Word.BYTAG));

    //ByID
    CssLayout addByIDGroup = new CssLayout();
    addByIDGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    TextField textFieldAddByID = new TextField();
    textFieldAddByID.setWidth("465px");
    Button buttonAddByID = new Button(VaadinIcons.PLUS);
    buttonAddByID.addClickListener(e -> {
        crawler.addByID(textFieldAddByID.getValue(), include);
        refreshList(mainGrid, crawler);
        textFieldAddByID.clear();
    });
    addByIDGroup.addComponents(textFieldAddByID, buttonAddByID);
    addByIDGroup.setCaption(Language.get(Word.BYID));

    //ByAttribute
    CssLayout addByAttributeGroup = new CssLayout();
    addByAttributeGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    TextField textFieldAddByAttributeKey = new TextField();
    textFieldAddByAttributeKey.setWidth("233px");
    TextField textFieldAddByAttributeValue = new TextField();
    textFieldAddByAttributeValue.setWidth("232px");
    Button buttonAddByAttribute = new Button(VaadinIcons.PLUS);
    buttonAddByAttribute.addClickListener(e -> {
        crawler.addByAttribute(textFieldAddByAttributeKey.getValue(), textFieldAddByAttributeValue.getValue(),
                include);
        refreshList(mainGrid, crawler);
        textFieldAddByAttributeKey.clear();
        textFieldAddByAttributeValue.clear();
    });
    addByAttributeGroup.addComponents(textFieldAddByAttributeKey, textFieldAddByAttributeValue,
            buttonAddByAttribute);
    addByAttributeGroup.setCaption(Language.get(Word.BYATTRIBUTEVALUE));

    layoutForms.addComponents(radios, addByClassGroup, addByTagGroup, addByIDGroup, addByAttributeGroup);
    mainGrid.addComponent(layoutForms);

    Label labelResult = new Label();
    Panel panelResult = new Panel(labelResult);
    labelResult.setWidth("100%");
    panelResult.setWidth("100%");
    panelResult.setHeight("175px");
    mainGrid.addComponent(panelResult, 0, 1, 1, 1);

    Button buttonTestURL = new Button();
    buttonTestURL.setIcon(VaadinIcons.EXTERNAL_LINK);
    buttonTestURL.setCaption(Language.get(Word.OPEN_LINK));

    Button buttonTest = new Button(Language.get(Word.TEST), VaadinIcons.CLIPBOARD_CHECK);
    buttonTest.addClickListener(ce -> {
        Article a = CrawlerUtils.executeRandom(crawler);
        labelResult.setValue(a.getBody());
        if (reg != null) {
            reg.remove();
        }
        reg = buttonTestURL
                .addClickListener(cev -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false));
    });

    refreshList(mainGrid, crawler);

    Runnable cancel = () -> close();
    Runnable next = () -> validateThirdStage(s);

    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.addComponents(header, mainGrid, getFooter(cancel, next, buttonTest, buttonTestURL));
    windowLayout.setComponentAlignment(header, Alignment.MIDDLE_CENTER);
    windowLayout.setExpandRatio(mainGrid, 5);
    windowLayout.setWidth("1250px");
    return windowLayout;
}

From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java

public PreferencesWindow(User user) {
    //setHeight("480px");
    //setWidth("720px");

    VerticalLayout windowContent = new VerticalLayout();
    windowContent.setWidth("100%");
    windowContent.setHeight("100%");
    windowContent.setMargin(new MarginInfo(true, false, false, false));

    TabSheet preferencesCategories = new TabSheet();
    preferencesCategories.setWidth("100%");
    preferencesCategories.setHeight("100%");
    preferencesCategories.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
    preferencesCategories.addStyleName(ValoTheme.TABSHEET_ICONS_ON_TOP);
    preferencesCategories.addStyleName(ValoTheme.TABSHEET_CENTERED_TABS);
    windowContent.addComponent(preferencesCategories);
    windowContent.setExpandRatio(preferencesCategories, 1f);

    preferencesCategories.addComponent(buildUserTab(user));
    preferencesCategories.addComponent(buildClippingsTab(user));
    preferencesCategories.addComponent(buildSupportTab(user));
    preferencesCategories.setSelectedTab(0);

    windowContent.addComponent(buildFooter(user));

    setContent(windowContent);/*from   w  w  w .  jav a  2  s.  com*/
    setModal(true);
    addCloseShortcut(KeyCode.ENTER, null);
    setResizable(false);
    setClosable(false);
    setHeight("480px");
    setWidth("720px");
}