Example usage for com.vaadin.ui TextArea getValue

List of usage examples for com.vaadin.ui TextArea getValue

Introduction

In this page you can find the example usage for com.vaadin.ui TextArea getValue.

Prototype

@Override
    public String getValue() 

Source Link

Usage

From source file:com.mycollab.module.project.view.kanban.AddNewColumnWindow.java

License:Open Source License

public AddNewColumnWindow(final IKanbanView kanbanView, final String type, final String fieldGroup) {
    super(UserUIContext.getMessage(TaskI18nEnum.ACTION_NEW_COLUMN));
    this.withModal(true).withResizable(false).withWidth("800px").withCenter();
    MVerticalLayout layout = new MVerticalLayout().withMargin(new MarginInfo(false, false, true, false));
    GridFormLayoutHelper gridFormLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4);
    this.setContent(layout);

    final TextField stageField = new TextField();
    final CheckBox defaultProject = new CheckBox();
    defaultProject.setVisible(UserUIContext.canBeYes(RolePermissionCollections.GLOBAL_PROJECT_SETTINGS));
    final ColorPicker colorPicker = new ColorPicker("", new com.vaadin.shared.ui.colorpicker.Color(
            DEFAULT_COLOR.getRed(), DEFAULT_COLOR.getGreen(), DEFAULT_COLOR.getBlue()));
    final TextArea description = new TextArea();

    gridFormLayoutHelper.addComponent(stageField, UserUIContext.getMessage(GenericI18Enum.FORM_NAME), 0, 0);
    gridFormLayoutHelper.addComponent(defaultProject,
            UserUIContext.getMessage(TaskI18nEnum.FORM_COLUMN_DEFAULT_FOR_NEW_PROJECT), 0, 1);
    gridFormLayoutHelper.addComponent(colorPicker, UserUIContext.getMessage(TaskI18nEnum.FORM_COLUMN_COLOR), 0,
            2);/*from w  ww  .j  av  a  2 s  .co m*/
    gridFormLayoutHelper.addComponent(description, UserUIContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0,
            3);

    MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> {
        OptionVal optionVal = new OptionVal();
        optionVal.setCreatedtime(new GregorianCalendar().getTime());
        optionVal.setCreateduser(UserUIContext.getUsername());
        optionVal.setDescription(description.getValue());
        com.vaadin.shared.ui.colorpicker.Color color = colorPicker.getColor();
        String cssColor = color.getCSS();
        if (cssColor.startsWith("#")) {
            cssColor = cssColor.substring(1);
        }
        optionVal.setColor(cssColor);
        if (defaultProject.getValue()) {
            optionVal.setIsdefault(true);
        } else {
            optionVal.setIsdefault(false);
            optionVal.setExtraid(CurrentProjectVariables.getProjectId());
        }
        optionVal.setSaccountid(MyCollabUI.getAccountId());
        optionVal.setType(type);
        optionVal.setTypeval(stageField.getValue());
        optionVal.setFieldgroup(fieldGroup);
        OptionValService optionService = AppContextUtil.getSpringBean(OptionValService.class);
        int optionValId = optionService.saveWithSession(optionVal, UserUIContext.getUsername());

        if (optionVal.getIsdefault()) {
            optionVal.setId(null);
            optionVal.setIsdefault(false);
            optionVal.setRefoption(optionValId);
            optionVal.setExtraid(CurrentProjectVariables.getProjectId());
            optionService.saveWithSession(optionVal, UserUIContext.getUsername());
        }
        kanbanView.addColumn(optionVal);
        close();
    }).withIcon(FontAwesome.SAVE).withStyleName(WebThemes.BUTTON_ACTION);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);

    MHorizontalLayout controls = new MHorizontalLayout().with(cancelBtn, saveBtn)
            .withMargin(new MarginInfo(false, true, false, false));
    layout.with(gridFormLayoutHelper.getLayout(), controls).withAlign(controls, Alignment.BOTTOM_RIGHT);
}

From source file:com.openhris.employee.EmployeePersonalInformation.java

private Window updatePersonalInformationConfirmation(final PersonalInformation pi) {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);//from   w  w w  . j a  v  a 2 s .c  o  m
    vlayout.setMargin(true);

    final Window window = new Window("UPDATE WINDOW", vlayout);
    window.setWidth("350px");

    final TextArea remarks = new TextArea("Remarks");
    remarks.setWidth("100%");
    remarks.setRows(3);
    window.addComponent(remarks);

    Button removeBtn = new Button("UPDATE EMPLOYEE?");
    removeBtn.setWidth("100%");
    removeBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (remarks.getValue() == null || remarks.getValue().toString().trim().isEmpty()) {
                getWindow().showNotification("Add remarks!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            boolean result = piService.updatePersonalInformation(pi, remarks.getValue().toString().trim());
            if (result) {
                getWindow().showNotification("Information Updated", Window.Notification.TYPE_TRAY_NOTIFICATION);
                (window.getParent()).removeWindow(window);
            } else {
                getWindow().showNotification("SQL Error", Window.Notification.TYPE_ERROR_MESSAGE);
            }
        }

    });
    window.addComponent(removeBtn);

    return window;
}

From source file:com.peergreen.example.webconsole.extensions.CssContributionExtension.java

License:Open Source License

@PostConstruct
public void init() {
    String css = ".custom_button_style {\n" + "   color : red !important;\n"
            + "   border : 1px green dashed !important;\n" + "}";
    final TextArea textArea = new TextArea("Css : ", css);
    textArea.setWidth("500px");
    addComponent(textArea);/*from ww w  .  j  ava2s .  com*/
    Button button = new Button("Change my style !");
    button.setWidth("500px");
    button.addStyleName("custom_button_style");
    button.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            String newCss = textArea.getValue();
            cssInjectorService.inject(newCss);
        }
    });
    addComponent(button);
    setExpandRatio(button, 1.5f);
}

From source file:com.save.client.RemoveAccountWindow.java

VerticalLayout getVLayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);/*from   w  ww . j a va 2 s  .c  om*/
    vlayout.setMargin(true);
    vlayout.setSizeFull();

    final TextArea remarks = new TextArea("Remarks: ");
    remarks.setRows(2);
    remarks.setWidth("100%");
    vlayout.addComponent(remarks);

    Button removeBtn = new Button("REMOVE ACCOUNT?");
    removeBtn.setWidth("100%");
    removeBtn.addClickListener((Button.ClickEvent event) -> {
        if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
            Notification.show("Add Remarks!", Notification.Type.ERROR_MESSAGE);
            return;
        }

        boolean result = clientService.removeAccount(getClientId(), remarks.getValue().trim().toLowerCase());
        if (result) {
            close();
        }
    });
    vlayout.addComponent(removeBtn);

    return vlayout;
}

From source file:com.save.employee.RemoveAccountWindow.java

VerticalLayout getVLayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);//from   ww  w .  j  av  a2  s  .co  m
    vlayout.setMargin(true);
    vlayout.setSizeFull();

    final TextArea remarks = new TextArea("Remarks: ");
    remarks.setRows(2);
    remarks.setWidth("100%");
    vlayout.addComponent(remarks);

    Button removeBtn = new Button("REMOVE ACCOUNT?");
    removeBtn.setWidth("100%");
    removeBtn.addClickListener((Button.ClickEvent event) -> {
        if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
            Notification.show("Add Remarks!", Notification.Type.ERROR_MESSAGE);
            return;
        }

        boolean result = employeeService.removeAccount(getEmployeeId(),
                remarks.getValue().trim().toLowerCase());
        if (result) {
            close();
        }
    });
    vlayout.addComponent(removeBtn);

    return vlayout;
}

From source file:com.skysql.manager.ui.MonitorsSettings.java

License:Open Source License

/**
 * Monitor form./*from  w w  w . ja  v  a  2 s . co  m*/
 *
 * @param monitor the monitor
 * @param title the title
 * @param description the description
 * @param button the button
 */
public void monitorForm(final MonitorRecord monitor, String title, String description, String button) {
    final TextField monitorName = new TextField("Monitor Name");
    final TextField monitorDescription = new TextField("Description");
    final TextField monitorUnit = new TextField("Measurement Unit");
    final TextArea monitorSQL = new TextArea("SQL Statement");
    final CheckBox monitorDelta = new CheckBox("Is Delta");
    final CheckBox monitorAverage = new CheckBox("Is Average");
    final NativeSelect validationTarget = new NativeSelect("Validate SQL on");
    final NativeSelect monitorInterval = new NativeSelect("Sampling interval");
    final NativeSelect monitorChartType = new NativeSelect("Default display");

    secondaryDialog = new ModalWindow(title, null);
    UI.getCurrent().addWindow(secondaryDialog);
    secondaryDialog.addCloseListener(this);

    final VerticalLayout formContainer = new VerticalLayout();
    formContainer.setMargin(new MarginInfo(true, true, false, true));
    formContainer.setSpacing(false);

    final Form form = new Form();
    formContainer.addComponent(form);
    form.setImmediate(false);
    form.setFooter(null);
    form.setDescription(description);

    String value;

    if ((value = monitor.getName()) != null) {
        monitorName.setValue(value);
    }
    form.addField("monitorName", monitorName);
    form.getField("monitorName").setRequired(true);
    form.getField("monitorName").setRequiredError("Monitor Name is missing");
    monitorName.focus();
    monitorName.setImmediate(true);
    monitorName.addValidator(new MonitorNameValidator(monitor.getName()));

    if ((value = monitor.getDescription()) != null) {
        monitorDescription.setValue(value);
    }
    monitorDescription.setWidth("24em");
    form.addField("monitorDescription", monitorDescription);

    if ((value = monitor.getUnit()) != null) {
        monitorUnit.setValue(value);
    }
    form.addField("monitorUnit", monitorUnit);

    if ((value = monitor.getSql()) != null) {
        monitorSQL.setValue(value);
    }
    monitorSQL.setWidth("24em");
    monitorSQL.addValidator(new SQLValidator());
    form.addField("monitorSQL", monitorSQL);

    final String noValidation = "None - Skip Validation";
    validationTarget.setImmediate(true);
    validationTarget.setNullSelectionAllowed(false);
    validationTarget.addItem(noValidation);
    validationTarget.select(noValidation);
    OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class);
    ArrayList<NodeInfo> nodes = overviewPanel.getNodes();

    if (nodes == null || nodes.isEmpty()) {
        SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class);
        String systemID = systemInfo.getCurrentID();
        String systemType = systemInfo.getCurrentSystem().getSystemType();
        if (systemID.equals(SystemInfo.SYSTEM_ROOT)) {
            ClusterComponent clusterComponent = VaadinSession.getCurrent().getAttribute(ClusterComponent.class);
            systemID = clusterComponent.getID();
            systemType = clusterComponent.getSystemType();
        }
        nodes = new ArrayList<NodeInfo>();
        for (String nodeID : systemInfo.getSystemRecord(systemID).getNodes()) {
            NodeInfo nodeInfo = new NodeInfo(systemID, systemType, nodeID);
            nodes.add(nodeInfo);
        }

    }

    for (NodeInfo node : nodes) {
        validationTarget.addItem(node.getID());
        validationTarget.setItemCaption(node.getID(), node.getName());
    }
    validationTarget.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void valueChange(ValueChangeEvent event) {
            nodeID = (String) event.getProperty().getValue();
            validateSQL = nodeID.equals(noValidation) ? false : true;
        }

    });
    form.addField("validationTarget", validationTarget);

    monitorDelta.setValue(monitor.isDelta());
    form.addField("monitorDelta", monitorDelta);

    monitorAverage.setValue(monitor.isAverage());
    form.addField("monitorAverage", monitorAverage);

    SettingsValues intervalValues = new SettingsValues(SettingsValues.SETTINGS_MONITOR_INTERVAL);
    String[] intervals = intervalValues.getValues();
    for (String interval : intervals) {
        monitorInterval.addItem(Integer.parseInt(interval));
    }

    Collection<?> validIntervals = monitorInterval.getItemIds();
    if (validIntervals.contains(monitor.getInterval())) {
        monitorInterval.select(monitor.getInterval());
    } else {
        SystemInfo systemInfo = getSession().getAttribute(SystemInfo.class);
        String defaultInterval = systemInfo.getSystemRecord(systemID).getProperties()
                .get(SystemInfo.PROPERTY_DEFAULTMONITORINTERVAL);
        if (defaultInterval != null && validIntervals.contains(Integer.parseInt(defaultInterval))) {
            monitorInterval.select(Integer.parseInt(defaultInterval));
        } else if (!validIntervals.isEmpty()) {
            monitorInterval.select(validIntervals.toArray()[0]);
        } else {
            new ErrorDialog(null, "No set of permissible monitor intervals found");
        }

        monitorInterval.setNullSelectionAllowed(false);
        form.addField("monitorInterval", monitorInterval);
    }

    for (UserChart.ChartType type : UserChart.ChartType.values()) {
        monitorChartType.addItem(type.name());
    }
    monitorChartType
            .select(monitor.getChartType() == null ? UserChart.ChartType.values()[0] : monitor.getChartType());
    monitorChartType.setNullSelectionAllowed(false);
    form.addField("monitorChartType", monitorChartType);

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Cancel");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            form.discard();
            secondaryDialog.close();
        }
    });

    Button okButton = new Button(button);
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            try {
                form.setComponentError(null);
                form.commit();
                monitor.setName(monitorName.getValue());
                monitor.setDescription(monitorDescription.getValue());
                monitor.setUnit(monitorUnit.getValue());
                monitor.setSql(monitorSQL.getValue());
                monitor.setDelta(monitorDelta.getValue());
                monitor.setAverage(monitorAverage.getValue());
                monitor.setInterval((Integer) monitorInterval.getValue());
                monitor.setChartType((String) monitorChartType.getValue());
                String ID;
                if ((ID = monitor.getID()) == null) {
                    if (Monitors.setMonitor(monitor)) {
                        ID = monitor.getID();
                        select.addItem(ID);
                        select.select(ID);
                        Monitors.reloadMonitors();
                        monitorsAll = Monitors.getMonitorsList(systemType);
                    }
                } else {
                    Monitors.setMonitor(monitor);
                    ChartProperties chartProperties = getSession().getAttribute(ChartProperties.class);
                    chartProperties.setDirty(true);
                    settingsDialog.setRefresh(true);
                }

                if (ID != null) {
                    select.setItemCaption(ID, monitor.getName());
                    displayMonitorRecord(ID);
                    secondaryDialog.close();
                }

            } catch (EmptyValueException e) {
                return;
            } catch (InvalidValueException e) {
                return;
            } catch (Exception e) {
                ManagerUI.error(e.getMessage());
                return;
            }
        }
    });
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) secondaryDialog.getContent();
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(formContainer);
    windowLayout.addComponent(buttonsBar);

}

From source file:com.trivago.mail.pigeon.web.components.templates.ModalAddTemplate.java

License:Apache License

public ModalAddTemplate(final TemplateList tl, final Long templateId) {
    setResizable(true);// w  w  w .ja v  a2  s  . co  m
    setWidth("972px");
    setHeight("700px");
    Panel rootPanel = new Panel("Add new Template");
    TabSheet tSheet = new TabSheet();
    HorizontalLayout hLayout = new HorizontalLayout();

    final TextField title = new TextField("Template description");
    final TextField subject = new TextField("Newsletter Subject");

    final TextArea textContent = new TextArea("Text Version");
    textContent.setRows(40);
    textContent.setColumns(100);

    final CKEditorTextField htmlContent = new CKEditorTextField();
    htmlContent.setWidth("100%");
    htmlContent.setHeight("650px");

    // Load the content, if we receive a template id
    if (templateId != null) {
        MailTemplate mt = new MailTemplate(templateId);
        title.setValue(mt.getTitle());
        subject.setValue(mt.getSubject());
        textContent.setValue(mt.getText());
        htmlContent.setValue(mt.getHtml());
    }

    Button saveButton = new Button("Save");
    Button cancel = new Button("Cancel");

    saveButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            boolean hasError = false;
            if (title.getValue().equals("")) {
                title.setComponentError(new UserError("Name must not be empty"));
                hasError = true;
            } else {
                title.setComponentError(null);
            }

            if (subject.getValue().equals("")) {
                subject.setComponentError(new UserError("Subject must not be empty"));
                hasError = true;
            } else {
                subject.setComponentError(null);
            }

            if (htmlContent.getValue().equals("")) {
                htmlContent.setComponentError(new UserError("Please provide some HTML content"));
                hasError = true;
            } else {
                htmlContent.setComponentError(null);
            }

            if (textContent.getValue().equals("")) {
                textContent.setComponentError(new UserError("Please provide some text content"));
                hasError = true;
            } else {
                textContent.setComponentError(null);
            }

            if (!hasError) {
                if (templateId == null) {
                    long templateId = Util.generateId();
                    try {
                        MailTemplate mt = new MailTemplate(templateId, title.getValue().toString(),
                                textContent.getValue().toString(), htmlContent.getValue().toString(),
                                subject.getValue().toString());
                        event.getButton().getWindow().setVisible(false);
                        event.getButton().getWindow().getParent()
                                .removeComponent(event.getButton().getWindow());
                        event.getButton().getWindow().getParent().showNotification("Saved successfully",
                                Notification.TYPE_HUMANIZED_MESSAGE);
                        tl.getBeanContainer().addItem(mt.getId(), mt);
                    } catch (RuntimeException e) {
                        // Should never happen ... hopefully :D
                    }
                } else {
                    MailTemplate mt = new MailTemplate(templateId);

                    mt.setHtml(htmlContent.getValue().toString());
                    mt.setSubject(subject.getValue().toString());
                    mt.setText(textContent.getValue().toString());
                    mt.setTitle(title.getValue().toString());

                    event.getButton().getWindow().setVisible(false);
                    event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow());
                    event.getButton().getWindow().getParent().showNotification("Saved successfully",
                            Notification.TYPE_HUMANIZED_MESSAGE);

                    final int beanIndex = tl.getBeanContainer().indexOfId(mt.getId());
                    tl.getBeanContainer().removeItem(mt.getId());
                    tl.getBeanContainer().addItemAt(beanIndex, mt.getId(), mt);
                }
                TemplateSelectBox.reloadSelect();
            }
        }
    });

    hLayout.addComponent(saveButton);
    hLayout.addComponent(cancel);
    hLayout.setSpacing(true);

    VerticalLayout metaDataLayout = new VerticalLayout();

    Panel textFieldPanel = new Panel("Meta Data");
    VerticalLayout metaLayout = new VerticalLayout();
    metaLayout.addComponent(title);
    metaLayout.addComponent(subject);
    textFieldPanel.addComponent(metaLayout);

    Panel helpPanel = new Panel("Template Documentation");
    assembleHelpComponents(helpPanel);

    metaDataLayout.addComponent(textFieldPanel);
    metaDataLayout.addComponent(helpPanel);

    tSheet.addTab(metaDataLayout).setCaption("Meta Data");

    VerticalLayout textLayout = new VerticalLayout();
    textLayout.addComponent(textContent);
    tSheet.addTab(textLayout).setCaption("Text Content");

    VerticalLayout htmlLayout = new VerticalLayout();
    htmlLayout.addComponent(htmlContent);
    tSheet.addTab(htmlLayout).setCaption("HTML Content");

    rootPanel.addComponent(tSheet);
    rootPanel.addComponent(hLayout);
    addComponent(rootPanel);
}

From source file:de.fzi.fhemapi.view.vaadin.ui.HWindow.java

License:Apache License

private void openConfig() {
    VerticalLayout layout = new VerticalLayout();

    final TextArea area = new TextArea(null, server.getConfigManager().getConfigFile());
    //      area.setHeight("100%");
    area.setRows(100);// w  ww . j av  a 2s  . c  om
    area.setWidth("100%");

    layout.addComponent(area);

    Button saveButton = new Button("Speichern");
    saveButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            server.setFHEMCfg(((String) area.getValue()));
            getWindow().showNotification(server.rereadConfiguration().toString(),
                    Notification.TYPE_TRAY_NOTIFICATION);
            server.getConfigManager().update();
        }
    });
    layout.addComponent(saveButton);
    layout.setComponentAlignment(saveButton, Alignment.TOP_CENTER);
    mainSplitPanel.setSecondComponent(layout);
}

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);/*w w w.  j ava 2  s .co  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:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java

private Component buildSupportTab(User user) {
    VerticalLayout root = new VerticalLayout();
    root.setCaption(Language.get(Word.SUPPORT));
    root.setIcon(VaadinIcons.HEADSET);/*from   w ww  .j  a  va2  s  . c o m*/
    root.setWidth("100%");
    root.setHeight("100%");
    root.setSpacing(true);
    root.setMargin(true);

    TextArea textAreaMessage = new TextArea(Language.get(Word.MESSAGE));
    textAreaMessage.setWidth("100%");
    textAreaMessage.setHeight("100%");

    Button buttonSend = new Button(Language.get(Word.SEND), VaadinIcons.ENVELOPE);
    buttonSend.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonSend.addClickListener(ce -> {
        try {
            if (emailsSend.containsKey(user)) {
                Map<LocalDate, Integer> times = emailsSend.get(user);
                if (times.containsKey(LocalDate.now())) {
                    if (times.get(LocalDate.now()) > 3) {
                        if (times.get(LocalDate.now()) > 15) {
                            UserUtils.banUser(user);
                            VaadinUtils.errorNotification("BANNED DUE TO TOO MUCH EMAILS");
                        } else {
                            VaadinUtils.errorNotification("TOO MUCH EMAILS");
                        }
                        return;
                    } else {
                        times.put(LocalDate.now(), times.get(LocalDate.now()) + 1);
                    }
                } else {
                    times.put(LocalDate.now(), 1);
                }
            } else {
                HashMap<LocalDate, Integer> times = new HashMap<>();
                times.put(LocalDate.now(), 1);
                emailsSend.put(user, times);
            }
            Mail.send(Props.get("supportmail"), "SUPPORT", user.toString() + "\n" + textAreaMessage.getValue());
            VaadinUtils.middleInfoNotification(Language.get(Word.SUCCESSFULLY_SEND));
            textAreaMessage.clear();
        } catch (EmailException ex) {
            VaadinUtils.errorNotification(Language.get(Word.SEND_FAILED));
            Log.error("Could not send Supportmail: ", ex);
        }
    });

    root.addComponents(textAreaMessage, buttonSend);
    root.setExpandRatio(textAreaMessage, 5);
    root.setComponentAlignment(buttonSend, Alignment.MIDDLE_LEFT);

    return root;
}