Example usage for com.vaadin.ui GridLayout setSpacing

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

Introduction

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

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * Helper method. Puts a blank in front of a component. Useful for buttons.
 * //from ww  w .  ja  v a  2 s .co  m
 * @param comp
 *            The component to display.
 * @return The component in an grid layout. A blank in front and afterwards is inserted.
 */
public static synchronized GridLayout create(final Component comp) {
    final GridLayout hor = new GridLayout(3, 1);
    hor.setHeight(Constants.DEFAULT_HEIGHT);
    hor.addComponent(new Label(" "), 0, 0);
    hor.addComponent(comp, 1, 0);
    hor.setComponentAlignment(comp, Alignment.MIDDLE_RIGHT);
    hor.addComponent(new Label(" "), 2, 0);
    hor.setSpacing(false);
    return hor;
}

From source file:de.gedoplan.webclients.vaadin.views.CustomerForm.java

protected void buildLayout() {
    GridLayout gridLayout = new GridLayout(4, 4);
    gridLayout.setSpacing(true);
    gridLayout.setMargin(true);/*from w  w w .j av a 2s.  c  o  m*/
    gridLayout.setWidth(100, Unit.PERCENTAGE);
    gridLayout.addComponent(id, 0, 0);
    gridLayout.addComponent(name, 1, 0, 2, 0);
    gridLayout.addComponent(kontakt, 3, 0);
    gridLayout.addComponent(strasse, 0, 1);
    gridLayout.addComponent(plz, 1, 1);
    gridLayout.addComponent(stadt, 2, 1, 3, 1);
    gridLayout.addComponent(region, 0, 2);
    gridLayout.addComponent(land, 1, 2);
    gridLayout.addComponent(telefon, 2, 2);
    gridLayout.addComponent(fax, 3, 2);
    gridLayout.addComponent(speichern, 1, 3);
    gridLayout.addComponent(abbrechen, 2, 3);
    gridLayout.setComponentAlignment(speichern, Alignment.MIDDLE_CENTER);
    gridLayout.setComponentAlignment(abbrechen, Alignment.MIDDLE_CENTER);
    speichern.setWidth(200, Unit.PIXELS);
    abbrechen.setWidth(200, Unit.PIXELS);
    setSpacing(true);
    setWidth(100, Unit.PERCENTAGE);
    addComponent(gridLayout);
}

From source file:de.kaiserpfalzEdv.vaadin.about.AboutViewImpl.java

License:Apache License

private GridLayout createGridLayout(final int cols, final int rows) {
    GridLayout result = new GridLayout(cols, rows);

    result.setSizeFull();/*from w  w w  . j av  a  2  s . co  m*/
    result.setSpacing(true);
    result.setResponsive(true);

    return result;
}

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

License:Apache License

private GridLayout layoutAsGrid(int columns, int fieldCount) {
    int rows = calculateRowCount(columns, fieldCount);

    GridLayout grid = new GridLayout(columns, rows);
    grid.setMargin(new MarginInfo(true, false, true, false));
    grid.setSpacing(true);
    grid.setWidth("100%");
    return grid;//from   w  w  w.  ja v a2  s. c om
}

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

public DocumentsView() {
    for (int i = 1; i < 12; i++) {
        setWidth("55%");
        GridLayout layout = new GridLayout(3, 1);
        layout.setMargin(true);/*w  w w  .  j  a  v  a  2 s  . c  om*/
        layout.setSpacing(true);
        try {
            List<Path> files = FileUtils.listFiles("docs/week" + i);
            layout.setRows(files.size() > 0 ? files.size() : 1);
            files.stream().sorted(Comparator.naturalOrder()).forEach(f -> {
                generateLine(f, layout);
            });
        } catch (IOException ex) {
            Logger.getLogger(DocumentsView.class.getName()).log(Level.SEVERE, null, ex);
        }
        addTab(layout, Language.get(Word.WEEK) + " " + i);
    }
    Language.setCustom(Word.WEEK, t -> t + " 1", v -> getTab(0).setCaption(v));
    Language.setCustom(Word.WEEK, t -> t + " 2", v -> getTab(1).setCaption(v));
    Language.setCustom(Word.WEEK, t -> t + " 3", v -> getTab(2).setCaption(v));
    Language.setCustom(Word.WEEK, t -> t + " 4", v -> getTab(3).setCaption(v));
    Language.setCustom(Word.WEEK, t -> t + " 5", v -> getTab(4).setCaption(v));
    Language.setCustom(Word.WEEK, t -> t + " 6", v -> getTab(5).setCaption(v));
    Language.setCustom(Word.WEEK, t -> t + " 7", v -> getTab(6).setCaption(v));
    Language.setCustom(Word.WEEK, t -> t + " 8", v -> getTab(7).setCaption(v));
    Language.setCustom(Word.WEEK, t -> t + " 9", v -> getTab(8).setCaption(v));
    Language.setCustom(Word.WEEK, t -> t + " 10", v -> getTab(9).setCaption(v));
    Language.setCustom(Word.WEEK, t -> t + " 11", v -> getTab(10).setCaption(v));
    SESSIONS.put(VaadinSession.getCurrent(), this);
}

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

public VerticalLayout createTab(Group g) {
    User u = UserUtils.getCurrent();//from  ww w . j  av a 2s  .  c om
    VerticalLayout groupSettingsLayout = new VerticalLayout();
    groupSettingsLayouts.put(g, groupSettingsLayout);
    GridLayout tabContent;
    TextField textFieldName = new TextField();
    if (GroupUtils.isAdmin(g, u)) {
        tabContent = new GridLayout(3, 2);
        Language.set(Word.NAME, textFieldName);
        textFieldName.setWidth("100%");
        textFieldName.setValue(g.getName());
        textFieldName.setMaxLength(255);
        tabContent.addComponent(textFieldName);
        tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT);
    } else {
        tabContent = new GridLayout(3, 1);
    }

    buttonLeave = new Button();
    Language.set(Word.LEAVE, buttonLeave);
    buttonLeave.setIcon(VaadinIcons.MINUS);
    buttonLeave.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonLeave.addClickListener(ce -> {
        ConfirmationDialog.show(Language.get(Word.REALLY_LEAVE_GROUP).replace("[GROUP]", g.getName()), () -> {
            long amountAdmins = g.getUsers().entrySet().stream().filter(e -> e.getValue()).count();
            if (amountAdmins > 1 || !GroupUtils.isAdmin(g, u)) {
                GroupUtils.removeUser(g, u);
                refreshAll(g);
            } else {
                VaadinUtils.errorNotification(Language.get(Word.NOT_ENOUGH_ADMINS_IN_GROUP));
            }
        });
    });

    buttonDelete = new Button();
    Language.set(Word.DELETE, buttonDelete);
    buttonDelete.setIcon(VaadinIcons.TRASH);
    buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonDelete.addClickListener(ce -> {
        ConfirmationDialog.show(Language.get(Word.REALLY_DELETE_GROUP).replace("[GROUP]", g.getName()), () -> {
            GroupUtils.removeGroup(g);
            refreshAll(g);
        });
    });

    Button buttonSave = new Button();
    Language.set(Word.SAVE, buttonSave);
    buttonSave.setIcon(VaadinIcons.CHECK);
    buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonSave.addClickListener(ce -> {
        if (GroupUtils.isAdmin(g, u)) {
            GroupUtils.changeName(g, textFieldName.getValue());
            accordion.getTab(groupSettingsLayout).setCaption(textFieldName.getValue());
        }
        VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED));
    });
    buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

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

    GridLayout footer = new GridLayout(4, 1);
    footer.setSpacing(true);
    footer.setMargin(new MarginInfo(false, true));
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.addStyleName("menubar");
    if (GroupUtils.isAdmin(g, u)) {
        footer.addComponents(placeholder, buttonDelete, buttonLeave, buttonSave);
        footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER);
    } else {
        footer.addComponents(placeholder, placeholder3, buttonLeave, buttonSave);
    }
    footer.setColumnExpandRatio(0, 5);
    footer.setComponentAlignment(buttonLeave, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER);

    if (GroupUtils.isAdmin(g, u)) {
        tabContent.addComponent(getProfiles(g), 0, 1, 1, 1);
        tabContent.addComponent(getMembers(g), 2, 1);
    } else {
        tabContent.addComponent(getProfiles(g), 0, 0, 1, 0);
        tabContent.addComponent(getMembers(g), 2, 0);
    }
    tabContent.setWidth("100%");
    tabContent.setSpacing(true);
    tabContent.setMargin(true);
    tabContent.addStyleName("profiles");
    groupSettingsLayout.addComponents(tabContent, footer);
    groupSettingsLayout.setMargin(false);
    groupSettingsLayout.setSpacing(false);
    groupSettingsLayout.setWidth("100%");
    return groupSettingsLayout;
}

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

public VerticalLayout createTab(InterestProfile profile) {
    VerticalLayout profileSettingsLayout = new VerticalLayout();
    GridLayout tabContent = new GridLayout(3, 3);

    TextField textFieldName = new TextField();
    Language.set(Word.NAME, textFieldName);
    textFieldName.setWidth("100%");
    textFieldName.setValue(profile.getName());
    textFieldName.setMaxLength(255);/* w w w .j a  v a 2 s  .co m*/
    CheckBox checkBoxEnabled = new CheckBox();
    checkBoxEnabled.setValue(profile.isEnabled());
    Language.setCustom(Word.ENABLED, s -> checkBoxEnabled.setCaption(s));

    Button buttonDelete = new Button();
    Language.set(Word.DELETE, buttonDelete);
    buttonDelete.setIcon(VaadinIcons.TRASH);
    buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonDelete.addClickListener(ce -> {
        InterestProfileUtils.delete(profile);
        accordion.removeTab(accordion.getTab(profileSettingsLayout));
    });

    Button buttonSave = new Button();
    Language.set(Word.SAVE, buttonSave);
    buttonSave.setIcon(VaadinIcons.CHECK);
    buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonSave.addClickListener(ce -> {
        InterestProfileUtils.changeName(profile, textFieldName.getValue());
        accordion.getTab(profileSettingsLayout).setCaption(textFieldName.getValue());
        InterestProfileUtils.changeEnabled(profile, checkBoxEnabled.getValue());
        InterestProfileUtils.changeSources(profile, profile.getSources());
        InterestProfileUtils.changeCategories(profile, profile.getCategories());
        InterestProfileUtils.changeAllTags(profile, profile.getTags());
        VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED));
    });
    buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

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

    Label labelHelp = new Label(Language.get(Word.HELP_TEXT), ContentMode.HTML);
    Language.setCustom(Word.HELP_TEXT, s -> labelHelp.setValue(s));
    labelHelp.setWidth("500px");
    PopupView popupHelp = new PopupView(null, labelHelp);

    Button buttonHelp = new Button(Language.get(Word.HELP), VaadinIcons.QUESTION);
    buttonHelp.addClickListener(ce -> {
        popupHelp.setPopupVisible(true);
    });

    GridLayout footer = new GridLayout(5, 1);
    footer.setSpacing(true);
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.addStyleName("menubar");
    footer.addComponents(buttonHelp, popupHelp, placeholder, buttonDelete, buttonSave);
    footer.setColumnExpandRatio(2, 5);
    footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER);

    tabContent.addComponents(textFieldName, checkBoxEnabled, placeholder2);
    tabContent.addComponent(getSources(profile), 0, 1, 1, 1);
    tabContent.addComponent(getCategories(profile), 2, 1);
    tabContent.addComponent(getTags(profile), 0, 2, 2, 2);
    tabContent.setWidth("100%");
    tabContent.setSpacing(true);
    tabContent.setMargin(true);
    tabContent.addStyleName("profiles");
    tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT);
    tabContent.setComponentAlignment(checkBoxEnabled, Alignment.MIDDLE_CENTER);
    profileSettingsLayout.addComponents(tabContent, footer);
    profileSettingsLayout.setMargin(false);
    profileSettingsLayout.setSpacing(false);
    profileSettingsLayout.setWidth("100%");
    return profileSettingsLayout;
}

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());
                });//from w  w  w  . ja  v  a  2 s.c o  m
                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.views.InterestProfileView.java

public Component getCategories(InterestProfile profile) {
    Map<Category, Boolean> categories = profile.getCategories();
    VerticalLayout categoriesLayout = new VerticalLayout();
    categoriesLayout.setWidth("100%");
    Panel categoriesPanel = new Panel(categoriesLayout);

    categories.entrySet().stream().sorted((e1, e2) -> e1.getKey().getName().compareTo(e2.getKey().getName()))
            .forEach(e -> {//  ww  w.  j a  va 2s .c o m
                Category category = e.getKey();
                boolean enabled = e.getValue();
                GridLayout categoryLayout = new GridLayout(3, 1);
                categoryLayout.setWidth("100%");

                CheckBox categorySelected = new CheckBox();
                categorySelected.setValue(enabled);
                categorySelected.addStyleName(ValoTheme.CHECKBOX_LARGE);
                categorySelected.addValueChangeListener(v -> categories.replace(category, v.getValue()));

                Label categoryIcon = new Label(category.getIcon().getHtml(), ContentMode.HTML);
                categoryIcon.addStyleName(ValoTheme.LABEL_H3);
                categoryIcon.addStyleName(ValoTheme.LABEL_NO_MARGIN);

                Label categoryName = new Label(category.getName(), ContentMode.HTML);
                Language.setCustom(null, s -> categoryName.setValue(category.getName()));
                categoryName.addStyleName(ValoTheme.LABEL_H3);
                categoryName.addStyleName(ValoTheme.LABEL_NO_MARGIN);

                categoryLayout.addComponents(categorySelected, categoryIcon, categoryName);
                categoryLayout.setComponentAlignment(categorySelected, Alignment.MIDDLE_CENTER);
                categoryLayout.setComponentAlignment(categoryIcon, Alignment.MIDDLE_LEFT);
                categoryLayout.setComponentAlignment(categoryName, Alignment.MIDDLE_LEFT);
                categoryLayout.setColumnExpandRatio(2, 5);
                categoryLayout.setSpacing(true);

                categoriesLayout.addComponent(categoryLayout);
            });

    categoriesPanel.setContent(categoriesLayout);
    categoriesPanel.setHeight("100%");
    categoriesPanel.setCaption(Language.get(Word.CATEGORIES));
    Language.setCustom(Word.CATEGORIES, s -> categoriesPanel.setCaption(s));

    return categoriesPanel;
}

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

private void addRow(InterestProfile profile, boolean included, String value) {
    GridLayout tagLayout = new GridLayout(2, 1);
    tagLayout.setWidth("100%");

    Label labelTagName = new Label(value, ContentMode.HTML);
    labelTagName.setWidth("100%");
    labelTagName.addStyleName(ValoTheme.LABEL_H3);
    labelTagName.addStyleName(ValoTheme.LABEL_NO_MARGIN);

    Button buttonDeleteTag = new Button(VaadinIcons.TRASH);
    buttonDeleteTag.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonDeleteTag.addClickListener(ev -> {
        profile.getTags().remove(value);
        if (included) {
            includedTagsLayouts.get(profile).removeComponent(tagLayout);
        } else {/*from www.  jav a  2s  .  c om*/
            excludedTagsLayouts.get(profile).removeComponent(tagLayout);
        }
    });

    tagLayout.addComponents(labelTagName, buttonDeleteTag);
    tagLayout.setComponentAlignment(labelTagName, Alignment.MIDDLE_LEFT);
    tagLayout.setComponentAlignment(buttonDeleteTag, Alignment.MIDDLE_RIGHT);
    tagLayout.setWidth("100%");
    tagLayout.setColumnExpandRatio(0, 5);
    tagLayout.setSpacing(true);
    tagLayout.setMargin(false);

    if (included) {
        includedTagsLayouts.get(profile).addComponent(tagLayout, 2);
    } else {
        excludedTagsLayouts.get(profile).addComponent(tagLayout, 2);
    }
}