Example usage for com.vaadin.ui HorizontalLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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

public ClippingView(Clipping clipping) {
    User user = UserUtils.getCurrent();/*from   ww w.j ava 2s  .c om*/

    clippingArticlesLayout = new VerticalLayout();
    clippingArticlesLayout.setSpacing(true);
    clippingArticlesLayout.setMargin(false);
    clippingArticlesLayout.setSizeFull();

    HorizontalLayout clippingOptionsLayout = new HorizontalLayout();
    clippingOptionsLayout.setSpacing(true);
    clippingOptionsLayout.setMargin(false);
    clippingOptionsLayout.setWidth("100%");

    ComboBox<SortOptions> comboBoxSortOptions = new ComboBox<>(Language.get(Word.SORT_BY));
    Language.setCustom(Word.SORT_BY, s -> {
        comboBoxSortOptions.setCaption(s);
        comboBoxSortOptions.getDataProvider().refreshAll();
    });
    comboBoxSortOptions.setItems(EnumSet.allOf(SortOptions.class));
    comboBoxSortOptions.setItemCaptionGenerator(s -> s.getName());
    comboBoxSortOptions.setItemIconGenerator(s -> s.getIcon());
    comboBoxSortOptions.setValue(SortOptions.BYPROFILE);
    comboBoxSortOptions.setTextInputAllowed(false);
    comboBoxSortOptions.setEmptySelectionAllowed(false);
    comboBoxSortOptions.addStyleName("comboboxsort");
    comboBoxSortOptions.addValueChangeListener(e -> {
        switch (e.getValue()) {
        case BYDATE:
            createClippingViewByDate(clipping);
            break;
        case BYPROFILE:
            createClippingViewByProfile(clipping);
            break;
        case BYSOURCE:
            createClippingViewBySource(clipping);
            break;
        }
    });

    Button buttonRegenerateClipping = new Button(VaadinIcons.REFRESH);
    buttonRegenerateClipping.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonRegenerateClipping.addClickListener(ce -> {
        user.setLastClipping(ClippingUtils.generateClipping(user, false));
        ClippingGorillaUI.getCurrent().setMainContent(ClippingView.getCurrent());
    });

    clippingOptionsLayout.addComponents(comboBoxSortOptions, buttonRegenerateClipping);
    clippingOptionsLayout.setExpandRatio(comboBoxSortOptions, 5);
    clippingOptionsLayout.setComponentAlignment(buttonRegenerateClipping, Alignment.BOTTOM_CENTER);

    addComponents(clippingOptionsLayout, clippingArticlesLayout);

    createClippingViewByProfile(clipping);
    if (clipping.getArticles().keySet().isEmpty() && clipping.getArticlesFromGroup().keySet().isEmpty()) {
        Label labelNoProfile = new Label();
        Language.setCustom(Word.NO_PROFILE_PRESENT, s -> labelNoProfile.setValue(s));
        labelNoProfile.addStyleName(ValoTheme.LABEL_H2);
        clippingArticlesLayout.addComponent(labelNoProfile);
    }
}

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

public Component createClippingRow(Article a) {
    Image imageNewsImage = new Image();
    String url = a.getUrlToImage();
    if (url == null || url.isEmpty()) {
        url = a.getSourceAsSource().getLogo().toExternalForm();
    }/*from w  ww . ja v a2s.  c  o m*/
    imageNewsImage.setSource(new ExternalResource(url));
    imageNewsImage.addStyleName("articleimage");

    VerticalLayout layoutNewsImage = new VerticalLayout(imageNewsImage);
    layoutNewsImage.setMargin(false);
    layoutNewsImage.setSpacing(false);
    layoutNewsImage.setWidth("200px");
    layoutNewsImage.setHeight("150px");
    layoutNewsImage.setComponentAlignment(imageNewsImage, Alignment.MIDDLE_CENTER);

    Label labelHeadLine = new Label(a.getTitle(), ContentMode.HTML);
    labelHeadLine.addStyleName(ValoTheme.LABEL_H2);
    labelHeadLine.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    labelHeadLine.setWidth("100%");

    Label labelDescription = new Label(a.getDescription(), ContentMode.HTML);
    labelDescription.setWidth("100%");

    Image imageSource = new Image();
    Source s = a.getSourceAsSource();
    URL logo = null;
    if (s != null) {
        logo = s.getLogo();
    } else {
        Log.error("Source is null: " + a.getSource());
        return new Label("INTERNAL ERROR");
    }
    if (logo != null) {
        imageSource.setSource(new ExternalResource(logo));
    } else {
        Log.error("Sourcelogo is null: " + s.getName());
    }
    imageSource.setHeight("30px");
    Label labelSource = new Label(a.getSourceAsSource().getName());
    labelSource.addStyleName(ValoTheme.LABEL_SMALL);

    LocalDateTime time = a.getPublishedAtAsLocalDateTime();
    DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG);
    formatter.withZone(ZoneId.of("Europe/Berlin"));
    Label labelDate = new Label(time.format(formatter));
    labelDate.addStyleName(ValoTheme.LABEL_SMALL);

    Label labelAuthor = new Label();
    labelAuthor.addStyleName(ValoTheme.LABEL_SMALL);
    labelAuthor.setWidth("100%");
    if (a.getAuthor() != null && !a.getAuthor().isEmpty()) {
        labelAuthor.setValue(a.getAuthor());
    }

    Button openWebsite = new Button(VaadinIcons.EXTERNAL_LINK);
    openWebsite.addClickListener(e -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false));

    HorizontalLayout layoutArticleOptions = new HorizontalLayout();
    layoutArticleOptions.setWidth("100%");
    layoutArticleOptions.addComponents(imageSource, labelSource, labelDate, labelAuthor, openWebsite);
    layoutArticleOptions.setComponentAlignment(imageSource, Alignment.MIDDLE_CENTER);
    layoutArticleOptions.setComponentAlignment(labelSource, Alignment.MIDDLE_CENTER);
    layoutArticleOptions.setComponentAlignment(labelDate, Alignment.MIDDLE_CENTER);
    layoutArticleOptions.setComponentAlignment(labelAuthor, Alignment.MIDDLE_LEFT);
    layoutArticleOptions.setComponentAlignment(openWebsite, Alignment.MIDDLE_CENTER);
    layoutArticleOptions.setExpandRatio(labelAuthor, 5);

    VerticalLayout layoutNewsText = new VerticalLayout(labelHeadLine, labelDescription, layoutArticleOptions);
    layoutNewsText.setMargin(false);
    layoutNewsText.setWidth("100%");

    HorizontalLayout layoutClipping = new HorizontalLayout();
    layoutClipping.setWidth("100%");
    layoutClipping.setMargin(true);
    layoutClipping.addComponents(layoutNewsImage, layoutNewsText);
    layoutClipping.setComponentAlignment(layoutNewsImage, Alignment.MIDDLE_CENTER);
    layoutClipping.setExpandRatio(layoutNewsText, 5);
    layoutClipping.addStyleName(ValoTheme.LAYOUT_CARD);
    layoutClipping.addStyleName("tags");
    return layoutClipping;
}

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

private void refreshProfiles(Group g, Layout layoutProfiles) {
    layoutProfiles.removeAllComponents();
    GroupUtils.getAllInterestProfiles(g, UserUtils.getCurrent()).forEach((p, enabled) -> {
        HorizontalLayout layoutProfile = new HorizontalLayout();
        layoutProfile.setWidth("100%");

        CheckBox checkBoxEnabled = new CheckBox();
        checkBoxEnabled.setValue(enabled);
        checkBoxEnabled.addValueChangeListener(v -> {
            GroupInterestProfileUtils.changeEnabled(p, UserUtils.getCurrent(), v.getValue());
            refreshAll(g);/*from  w  w w . j  a  v  a 2 s . c om*/
        });

        long subscribers = p.getEnabledUsers().values().stream().filter(v -> v).count();
        Label labelProfileInfo = new Label();
        Language.setCustom(Word.SUBSCRIBERS, s -> {
            String info = p.getName() + " (" + subscribers + " ";
            info += subscribers == 1 ? Language.get(Word.SUBSCRIBER) + ")"
                    : Language.get(Word.SUBSCRIBERS) + ")";
            labelProfileInfo.setValue(info);
        });

        boolean isAdmin = g.getUsers().getOrDefault(UserUtils.getCurrent(), false);

        Button buttonOpen = new Button(VaadinIcons.EXTERNAL_LINK);
        buttonOpen.addClickListener(ce -> {
            UI.getCurrent().addWindow(GroupProfileWindow.show(p, isAdmin, () -> {
            }));
        });

        if (isAdmin) {
            Button buttonRemove = new Button(VaadinIcons.MINUS);
            buttonRemove.addStyleName(ValoTheme.BUTTON_DANGER);
            buttonRemove.addClickListener(ce -> {
                ConfirmationDialog.show(
                        Language.get(Word.REALLY_DELETE_PROFILE).replace("[PROFILE]", p.getName()), () -> {
                            GroupInterestProfileUtils.delete(p);
                            refreshAll(g);
                        });
            });

            layoutProfile.addComponents(checkBoxEnabled, labelProfileInfo, buttonOpen, buttonRemove);
        } else {
            layoutProfile.addComponents(checkBoxEnabled, labelProfileInfo, buttonOpen);
        }

        layoutProfile.setExpandRatio(labelProfileInfo, 5);
        layoutProfile.setComponentAlignment(checkBoxEnabled, Alignment.MIDDLE_CENTER);
        layoutProfile.setComponentAlignment(labelProfileInfo, Alignment.MIDDLE_LEFT);

        layoutProfiles.addComponent(layoutProfile);
    });
}

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

public void refreshMembers(Group g, Layout layoutMembers) {
    layoutMembers.removeAllComponents();
    Map<User, Boolean> allMembers = GroupUtils.getAllMembers(g);
    boolean isAdmin = GroupUtils.isAdmin(g, UserUtils.getCurrent());
    if (!isAdmin) {
        if (allMembers.size() < 2) {
            buttonLeave.setVisible(false);
        } else {//from w ww .ja  v  a 2s  .c  o m
            buttonLeave.setVisible(true);
        }
    } else {
        if (allMembers.entrySet().stream().map(e -> e.getValue()).filter(b -> b == true).count() > 1) {
            buttonLeave.setVisible(true);
        } else {
            buttonLeave.setVisible(false);
        }
    }
    allMembers.forEach((u, admin) -> {
        HorizontalLayout layoutMember = new HorizontalLayout();
        layoutMember.setWidth("100%");

        VaadinIcons iconRole = admin ? VaadinIcons.KEY : VaadinIcons.USER;
        Label labelMemberName = new Label(iconRole.getHtml() + " " + u.getUsername(), ContentMode.HTML);
        //labelMemberName.setWidth("50%");

        layoutMember.addComponents(labelMemberName);
        layoutMember.setComponentAlignment(labelMemberName, Alignment.MIDDLE_LEFT);
        layoutMember.setExpandRatio(labelMemberName, 5);
        if (isAdmin) {
            if (g.getUsers().size() > 1) {
                Button buttonChangeRole = new Button(admin ? VaadinIcons.ARROW_DOWN : VaadinIcons.ARROW_UP);
                buttonChangeRole.addClickListener(ce -> {
                    if (g.getUsers().get(u)) {//Downgrade
                        long amountAdmins = g.getUsers().entrySet().stream().filter(e -> e.getValue()).count();
                        if (amountAdmins > 1) {
                            if (UserUtils.getCurrent() == u) {
                                ConfirmationDialog.show(Language.get(Word.REALLY_DEADMIN_YOURSELF), () -> {
                                    GroupUtils.makeNormalMember(g, u);
                                    refreshAll(g);
                                });
                            } else {
                                GroupUtils.makeNormalMember(g, u);
                                refreshAll(g);
                            }
                        } else {
                            VaadinUtils.errorNotification(Language.get(Word.NOT_ENOUGH_ADMINS_IN_GROUP));
                            buttonLeave.setVisible(false);
                        }
                    } else {//Upgrade
                        GroupUtils.makeAdmin(g, u);
                        refreshAll(g);
                    }
                });
                layoutMember.addComponent(buttonChangeRole);

                if (g.getUsers().values().stream().filter(v -> v).count() > 1 || !GroupUtils.isAdmin(g, u)) {
                    Button buttonRemoveUser = new Button(VaadinIcons.MINUS);
                    buttonRemoveUser.addStyleName(ValoTheme.BUTTON_DANGER);
                    buttonRemoveUser.addClickListener(ce -> {
                        ConfirmationDialog.show(
                                Language.get(Word.REALLY_REMOVE_USER_FROM_GROUP)
                                        .replace("[USER]", u.getUsername()).replace("[GROUP]", g.getName()),
                                () -> {
                                    GroupUtils.removeUser(g, u);
                                    refreshAll(g);
                                });
                    });
                    layoutMember.addComponents(buttonRemoveUser);
                }
            }
        }
        layoutMembers.addComponent(layoutMember);
    });
}

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

private Component buildUserTab(User user) {
    HorizontalLayout root = new HorizontalLayout();
    root.setCaption(Language.get(Word.PROFILE));
    root.setIcon(VaadinIcons.USER);//w  w w.j  a  va  2 s  .  c om
    root.setWidth("100%");
    root.setSpacing(true);
    root.setMargin(true);

    FormLayout details = new FormLayout();
    details.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    root.addComponent(details);

    firstNameField = new TextField(Language.get(Word.FIRST_NAME));
    firstNameField.setValue(user.getFirstName());
    firstNameField.setMaxLength(20);
    firstNameField.addValueChangeListener(event -> {
        String firstNameError = UserUtils.checkName(event.getValue());
        if (!firstNameError.isEmpty()) {
            firstNameField.setComponentError(new UserError(firstNameError,
                    AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(firstNameError);
            saveButton.setEnabled(setError(firstNameField, true));
        } else {
            firstNameField.setComponentError(null);
            boolean enabled = setError(firstNameField, false);
            saveButton.setEnabled(enabled);
        }
    });
    setError(firstNameField, false);

    lastNameField = new TextField(Language.get(Word.LAST_NAME));
    lastNameField.setValue(user.getLastName());
    lastNameField.setMaxLength(20);
    lastNameField.addValueChangeListener(event -> {
        String lastNameError = UserUtils.checkName(event.getValue());
        if (!lastNameError.isEmpty()) {
            lastNameField.setComponentError(new UserError(lastNameError, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(lastNameError);
            saveButton.setEnabled(setError(lastNameField, true));
        } else {
            lastNameField.setComponentError(null);
            saveButton.setEnabled(setError(lastNameField, false));
        }
    });
    setError(lastNameField, false);

    usernameField = new TextField(Language.get(Word.USERNAME));
    usernameField.setValue(user.getUsername());
    usernameField.setMaxLength(20);
    usernameField.addValueChangeListener(event -> {
        if (!event.getValue().equals(user.getUsername())) {
            String userNameError = UserUtils.checkUsername(event.getValue());
            if (!userNameError.isEmpty()) {
                usernameField.setComponentError(new UserError(userNameError,
                        AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
                VaadinUtils.infoNotification(userNameError);
                saveButton.setEnabled(setError(usernameField, true));
            } else {
                usernameField.setComponentError(null);
                saveButton.setEnabled(setError(usernameField, false));
            }
        } else {
            usernameField.setComponentError(null);
            saveButton.setEnabled(setError(usernameField, false));
        }
    });
    setError(usernameField, false);

    emailField = new TextField(Language.get(Word.EMAIL));
    emailField.setValue(user.getEmail());
    emailField.setMaxLength(256);
    emailField.addValueChangeListener(event -> {
        if (!event.getValue().equals(user.getEmail())) {
            String email1Error = UserUtils.checkEmail(event.getValue().toLowerCase());
            if (!email1Error.isEmpty()) {
                emailField.setComponentError(new UserError(email1Error, AbstractErrorMessage.ContentMode.HTML,
                        ErrorMessage.ErrorLevel.INFORMATION));
                VaadinUtils.infoNotification(email1Error);
                saveButton.setEnabled(setError(emailField, true));
            } else {
                emailField.setComponentError(null);
                saveButton.setEnabled(setError(emailField, false));
            }
        } else {
            emailField.setComponentError(null);
            saveButton.setEnabled(setError(emailField, false));
        }
    });
    setError(emailField, false);

    oldPasswordField = new PasswordField(Language.get(Word.OLD_PASSWORD));
    oldPasswordField.setValue("");
    oldPasswordField.setMaxLength(51);
    oldPasswordField.addValueChangeListener(event -> {
        if (!event.getValue().isEmpty()) {
            String password1Error = UserUtils.checkPassword(event.getValue());
            if (!password1Error.isEmpty()) {
                oldPasswordField.setComponentError(new UserError(password1Error,
                        AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
                VaadinUtils.infoNotification(password1Error);
                saveButton.setEnabled(setError(oldPasswordField, true));
            } else {
                oldPasswordField.setComponentError(null);
                saveButton.setEnabled(setError(oldPasswordField, false));
            }
        } else {
            oldPasswordField.setComponentError(null);
            saveButton.setEnabled(setError(oldPasswordField, false));
        }
    });
    setError(oldPasswordField, false);

    ProgressBar strength = new ProgressBar();

    password1Field = new PasswordField(Language.get(Word.PASSWORD));
    password1Field.setValue("");
    password1Field.setMaxLength(51);
    password1Field.addValueChangeListener(event -> {
        if (!event.getValue().isEmpty()) {
            String password1Error = UserUtils.checkPassword(event.getValue());
            strength.setValue(UserUtils.calculatePasswordStrength(event.getValue()));
            if (!password1Error.isEmpty()) {
                password1Field.setComponentError(new UserError(password1Error,
                        AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
                VaadinUtils.infoNotification(password1Error);
                saveButton.setEnabled(setError(password1Field, true));
            } else {
                password1Field.setComponentError(null);
                saveButton.setEnabled(setError(password1Field, false));
            }
        } else {
            password1Field.setComponentError(null);
            saveButton.setEnabled(setError(password1Field, false));
        }
    });
    setError(password1Field, false);

    strength.setWidth("184px");
    strength.setHeight("1px");

    password2Field = new PasswordField(Language.get(Word.PASSWORD_AGAIN));
    password2Field.setValue("");
    password2Field.setMaxLength(51);
    password2Field.addValueChangeListener(event -> {
        if (!event.getValue().isEmpty()) {
            String password2Error = UserUtils.checkPassword(event.getValue())
                    + UserUtils.checkSecondPassword(password1Field.getValue(), event.getValue());
            if (!password2Error.isEmpty()) {
                password2Field.setComponentError(new UserError(password2Error,
                        AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
                VaadinUtils.infoNotification(password2Error);
                saveButton.setEnabled(setError(password2Field, true));
            } else {
                password2Field.setComponentError(null);
                saveButton.setEnabled(setError(password2Field, false));
            }
        } else {
            password2Field.setComponentError(null);
            saveButton.setEnabled(setError(password2Field, false));
        }
    });
    setError(password2Field, false);

    details.addComponents(firstNameField, lastNameField, usernameField, emailField, oldPasswordField,
            password1Field, strength, password2Field);

    return root;
}

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

private Component buildClippingsTab(User user) {
    HorizontalLayout root = new HorizontalLayout();
    root.setCaption(Language.get(Word.CLIPPINGS));
    root.setIcon(VaadinIcons.NEWSPAPER);
    root.setWidth("100%");
    root.setSpacing(true);/*from  w  w  w.jav a 2s.c o m*/
    root.setMargin(true);

    FormLayout formLayoutClippingDetails = new FormLayout();
    formLayoutClippingDetails.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    root.addComponent(formLayoutClippingDetails);

    CheckBox checkBoxReceiveEmails = new CheckBox();
    checkBoxReceiveEmails.setValue(UserUtils.getEmailNewsletter(user));
    checkBoxReceiveEmails.addValueChangeListener(v -> UserUtils.setEmailNewsletter(user, v.getValue()));
    HorizontalLayout layoutCheckBoxReceiveEmails = new HorizontalLayout(checkBoxReceiveEmails);
    layoutCheckBoxReceiveEmails.setCaption(Language.get(Word.EMAIL_SUBSCRIPTION));
    layoutCheckBoxReceiveEmails.setMargin(false);
    layoutCheckBoxReceiveEmails.setSpacing(false);

    HorizontalLayout layoutAddNewClippingTime = new HorizontalLayout();
    layoutAddNewClippingTime.setMargin(false);
    layoutAddNewClippingTime.setCaption(Language.get(Word.ADD_CLIPPING_TIME));
    layoutAddNewClippingTime.setWidth("100%");

    InlineDateTimeField dateFieldNewClippingTime = new InlineDateTimeField();
    LocalDateTime value = LocalDateTime.now(ZoneId.of("Europe/Berlin"));
    dateFieldNewClippingTime.setValue(value);
    dateFieldNewClippingTime.setLocale(VaadinSession.getCurrent().getLocale());
    dateFieldNewClippingTime.setResolution(DateTimeResolution.MINUTE);
    dateFieldNewClippingTime.addStyleName("time-only");

    Button buttonAddClippingTime = new Button();
    buttonAddClippingTime.setIcon(VaadinIcons.PLUS);
    buttonAddClippingTime.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonAddClippingTime.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    buttonAddClippingTime.addClickListener(e -> {
        LocalTime generalTime = dateFieldNewClippingTime.getValue().toLocalTime();
        layoutClippingTimes.addComponent(getTimeRow(user, generalTime));
        UserUtils.addClippingSendTime(user, generalTime);
    });
    layoutAddNewClippingTime.addComponents(dateFieldNewClippingTime, buttonAddClippingTime);
    layoutAddNewClippingTime.setComponentAlignment(dateFieldNewClippingTime, Alignment.MIDDLE_LEFT);
    layoutAddNewClippingTime.setComponentAlignment(buttonAddClippingTime, Alignment.MIDDLE_CENTER);
    layoutAddNewClippingTime.setExpandRatio(dateFieldNewClippingTime, 5);

    layoutClippingTimes = new VerticalLayout();
    layoutClippingTimes.setMargin(new MarginInfo(true, false, false, true));
    layoutClippingTimes.setCaption(Language.get(Word.CLIPPING_TIMES));
    layoutClippingTimes.setWidth("100%");
    layoutClippingTimes.addStyleName("times");

    Set<LocalTime> userTimes = user.getClippingTime();
    userTimes.forEach(t -> layoutClippingTimes.addComponent(getTimeRow(user, t)));

    formLayoutClippingDetails.addComponents(layoutCheckBoxReceiveEmails, layoutAddNewClippingTime,
            layoutClippingTimes);

    return root;
}

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

private Component getTimeRow(User user, LocalTime time) {
    HorizontalLayout layoutTimeRow = new HorizontalLayout();
    layoutTimeRow.setWidth("100%");

    DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
    Label labelTime = new Label(time.format(formatter));

    Button buttonDelete = new Button(VaadinIcons.TRASH);
    buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonDelete.setWidth("80px");
    buttonDelete.addClickListener(e -> {
        if (layoutClippingTimes.getComponentCount() > 1) {
            layoutClippingTimes.removeComponent(layoutTimeRow);
            UserUtils.removeClippingSendTime(user, time);
        } else {//w  w w  .  j  a  v a  2 s  .  c o  m
            VaadinUtils.errorNotification(Language.get(Word.AT_LREAST_ONE_TIME));
        }
    });

    layoutTimeRow.addComponents(labelTime, buttonDelete);
    layoutTimeRow.setComponentAlignment(labelTime, Alignment.MIDDLE_LEFT);
    layoutTimeRow.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER);
    layoutTimeRow.setExpandRatio(labelTime, 5);

    return layoutTimeRow;
}

From source file:ed.cracken.pos.ui.purchases.PurchaserView.java

public HorizontalLayout createFooter() {
    total = new Label("<h2><strong>Total:</strong></h2>");
    total.setContentMode(ContentMode.HTML);
    totalValue = new Label("<h2><strong>" + DataFormatHelper.formatNumber(BigDecimal.ZERO) + "</strong></h2>");
    totalValue.setContentMode(ContentMode.HTML);

    quantity = new Label("<h2><strong>Cantidad:</strong></h2>");
    quantity.setContentMode(ContentMode.HTML);
    quantityValue = new Label(
            "<h2><strong>" + DataFormatHelper.formatNumber(BigDecimal.ZERO) + "</strong></h2>");
    quantityValue.setContentMode(ContentMode.HTML);

    saveTrx = new Button("Guardar", FontAwesome.CHECK_CIRCLE_O);
    saveTrx.addStyleName(ValoTheme.BUTTON_PRIMARY);
    saveTrx.setHeight("60px");
    saveTrx.addClickListener((Button.ClickEvent event) -> {
        UI.getCurrent().addWindow(paymentView);
    });//from   w  w w .  j av a2  s . c  om
    cancelTrx = new Button("Cancelar", FontAwesome.CLOSE);
    cancelTrx.addStyleName(ValoTheme.BUTTON_DANGER);
    cancelTrx.setHeight("60px");
    HorizontalLayout bottom = new HorizontalLayout();
    HorizontalLayout labelsArea = new HorizontalLayout();
    HorizontalLayout buttonsArea = new HorizontalLayout();

    labelsArea.setSpacing(true);
    labelsArea.addComponent(total);
    labelsArea.addComponent(totalValue);
    labelsArea.addComponent(quantity);
    labelsArea.addComponent(quantityValue);

    labelsArea.setComponentAlignment(total, Alignment.MIDDLE_LEFT);
    labelsArea.setComponentAlignment(totalValue, Alignment.MIDDLE_LEFT);
    labelsArea.setComponentAlignment(quantity, Alignment.MIDDLE_RIGHT);
    labelsArea.setComponentAlignment(quantityValue, Alignment.MIDDLE_RIGHT);

    buttonsArea.setSpacing(true);
    buttonsArea.addComponent(saveTrx);
    buttonsArea.addComponent(cancelTrx);
    bottom.setSpacing(true);
    bottom.addComponent(buttonsArea);
    bottom.addComponent(labelsArea);
    bottom.setComponentAlignment(buttonsArea, Alignment.MIDDLE_LEFT);
    bottom.setComponentAlignment(labelsArea, Alignment.MIDDLE_RIGHT);
    bottom.setWidth("100%");

    return bottom;
}

From source file:edu.cornell.qatarmed.planrnaseq.AnnotateRNAseqSQL.java

private void initLayout() {

    /* Root of the user interface component tree is set */
    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    setContent(splitPanel);//from   ww  w  .j  a va  2s . c om

    /* Build the component tree */
    VerticalLayout leftLayout = new VerticalLayout();
    VerticalSplitPanel rightSplitPanel = new VerticalSplitPanel();
    //  VerticalSplitPanel leftSplitPanel = new VerticalSplitPanel();

    splitPanel.addComponent(leftLayout);
    splitPanel.addComponent(rightSplitPanel);

    VerticalLayout rightTopLayout = new VerticalLayout();
    // rightTopLayout.addComponent(rightTopForm);
    rightTopTabsheet.setSizeFull();
    rightTopLayout.addComponent(rightTopTabsheet);
    rightTopTabsheet.addTab(rightTopForm, "Study Details");
    rightTopTabsheet.addTab(rightTopAnnotationForm, "Annotate");
    rightTopLayout.setSizeFull();

    rightSplitPanel.addComponent(rightTopLayout);

    HorizontalSplitPanel rightBottomLayout = new HorizontalSplitPanel();
    // HorizontalLayout rightBottomLayout = new HorizontalLayout();
    VerticalLayout rightBottomLeftLayout = new VerticalLayout();
    VerticalLayout rightBottomRightLayout = new VerticalLayout();
    rightBottomLayout.addComponent(rightBottomLeftLayout);
    rightBottomLayout.addComponent(rightBottomRightLayout);
    //  rightBottomLayout.setExpandRatio(rightBottomLeftLayout, 1);
    //  rightBottomLayout.setExpandRatio(rightBottomRightLayout, 3);
    rightBottomLayout.setSplitPosition(30f, Unit.PERCENTAGE);

    rightBottomLayout.setSizeFull();
    rightBottomTabsheet.setSizeFull();

    rightSplitPanel.addComponent(rightBottomLayout);

    splitPanel.setSplitPosition(50f, Unit.PERCENTAGE);
    //   rightSplitPanel.setWidth("20%");

    /*
     //make form asking parameters and add it to leftLaayout
     VerticalLayout formLayout = new VerticalLayout();
     // TextField studyName = new TextField("RNAseq Study Name");
     formLayout.addComponent(studyName);
     List replist = new ArrayList();
     ComboBox numReplicates = new ComboBox("Replicates", replist);
     formLayout.addComponent(numReplicates);
     leftLayout.addComponent(formLayout);
     */
    HorizontalLayout leftTopLayout = new HorizontalLayout();
    leftLayout.addComponent(leftTopLayout);
    leftTopLayout.addComponent(searchField);
    leftTopLayout.addComponent(searchButton);
    leftTopLayout.setWidth("100%");
    searchField.setWidth("100%");

    leftTopLayout.setExpandRatio(searchField, 1);
    leftLayout.addComponent(bioprojectSummaryTable);
    // leftLayout.setExpandRatio(searchField, 0);
    leftLayout.setExpandRatio(bioprojectSummaryTable, 1);
    bioprojectSummaryTable.setSizeFull();
    /* Set the contents in the left of the split panel to use all the space */
    leftLayout.setSizeFull();

    /*        VerticalLayout resultLayout = new VerticalLayout();
     rightLayout.addComponent(resultLayout);
     VerticalLayout chartLayout = new VerticalLayout();
     rightLayout.addComponent(chartLayout);
            
     chartLayout.setVisible(false);
     */
    rightBottomLeftLayout.addComponent(tree);

    rightBottomRightLayout.addComponent(rightBottomTabsheet);
    rightBottomTabsheet.addTab(myform, "Selected Biosample");
    myform.setSizeFull();
    VerticalLayout rbTabBiosampleSummaryLayout = new VerticalLayout(); // Right bottom Biosample Summary
    rightBottomTabsheet.addTab(rbTabBiosampleSummaryLayout, "All Biosamples");
    rbTabBiosampleSummaryLayout.addComponent(biosampleSummaryTable);
    rbTabBiosampleSummaryLayout.setSizeFull();

    initDataAndSubcomponent();
    rightTopLayout.setSizeFull();
    rightBottomRightLayout.setSizeFull();

}

From source file:edu.cornell.qatarmed.planrnaseq.AnnotateView.java

public void initLayout() {

    /* Root of the user interface component tree is set */
    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    addComponent(splitPanel);/*www .  jav a2s  . c o m*/
    //    panel = new Panel();
    //  panel.setContent(splitPanel);
    splitPanel.setSizeFull();
    //setCompositionRoot(splitPanel);

    //   panel.setContent(splitPanel);

    /* Build the component tree */
    VerticalLayout leftLayout = new VerticalLayout();
    VerticalSplitPanel rightSplitPanel = new VerticalSplitPanel();
    //  VerticalSplitPanel leftSplitPanel = new VerticalSplitPanel();

    splitPanel.addComponent(leftLayout);
    splitPanel.addComponent(rightSplitPanel);

    VerticalLayout rightTopLayout = new VerticalLayout();
    // rightTopLayout.addComponent(rightTopForm);
    rightTopTabsheet.setSizeFull();
    rightTopLayout.addComponent(rightTopTabsheet);
    rightTopTabsheet.addTab(rightTopForm, "Study Details");
    rightTopTabsheet.addTab(rightTopAnnotationForm, "Annotate");
    rightTopLayout.setSizeFull();

    rightSplitPanel.addComponent(rightTopLayout);

    HorizontalSplitPanel rightBottomLayout = new HorizontalSplitPanel();
    // HorizontalLayout rightBottomLayout = new HorizontalLayout();
    VerticalLayout rightBottomLeftLayout = new VerticalLayout();
    VerticalLayout rightBottomRightLayout = new VerticalLayout();
    rightBottomLayout.addComponent(rightBottomLeftLayout);
    rightBottomLayout.addComponent(rightBottomRightLayout);
    //  rightBottomLayout.setExpandRatio(rightBottomLeftLayout, 1);
    //  rightBottomLayout.setExpandRatio(rightBottomRightLayout, 3);
    rightBottomLayout.setSplitPosition(30f, Unit.PERCENTAGE);

    rightBottomLayout.setSizeFull();
    rightBottomTabsheet.setSizeFull();

    rightSplitPanel.addComponent(rightBottomLayout);

    splitPanel.setSplitPosition(50f, Unit.PERCENTAGE);
    //   rightSplitPanel.setWidth("20%");

    /*
     //make form asking parameters and add it to leftLaayout
     VerticalLayout formLayout = new VerticalLayout();
     // TextField studyName = new TextField("RNAseq Study Name");
     formLayout.addComponent(studyName);
     List replist = new ArrayList();
     ComboBox numReplicates = new ComboBox("Replicates", replist);
     formLayout.addComponent(numReplicates);
     leftLayout.addComponent(formLayout);
     */
    HorizontalLayout leftTopLayout = new HorizontalLayout();
    leftLayout.addComponent(leftTopLayout);
    leftTopLayout.addComponent(searchField);
    leftTopLayout.addComponent(searchButton);
    leftTopLayout.setWidth("100%");
    searchField.setWidth("100%");

    leftTopLayout.setExpandRatio(searchField, 1);
    leftLayout.addComponent(bioprojectSummaryTable);
    // leftLayout.setExpandRatio(searchField, 0);
    leftLayout.setExpandRatio(bioprojectSummaryTable, 1);
    bioprojectSummaryTable.setSizeFull();
    /* Set the contents in the left of the split panel to use all the space */
    leftLayout.setSizeFull();

    /*        VerticalLayout resultLayout = new VerticalLayout();
     rightLayout.addComponent(resultLayout);
     VerticalLayout chartLayout = new VerticalLayout();
     rightLayout.addComponent(chartLayout);
            
     chartLayout.setVisible(false);
     */
    rightBottomLeftLayout.addComponent(tree);

    rightBottomRightLayout.addComponent(rightBottomTabsheet);
    rightBottomTabsheet.addTab(myform, "Selected Biosample");
    myform.setSizeFull();
    VerticalLayout rbTabBiosampleSummaryLayout = new VerticalLayout(); // Right bottom Biosample Summary
    rightBottomTabsheet.addTab(rbTabBiosampleSummaryLayout, "All Biosamples");
    rbTabBiosampleSummaryLayout.addComponent(biosampleSummaryTable);
    rbTabBiosampleSummaryLayout.setSizeFull();

    initDataAndSubcomponent();
    rightTopLayout.setSizeFull();
    rightBottomRightLayout.setSizeFull();

}