Example usage for com.vaadin.ui RichTextArea setWidth

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

Introduction

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

Prototype

public void setWidth(float width, Unit unit);

Source Link

Document

Sets the width of the object.

Usage

From source file:com.esofthead.mycollab.vaadin.ui.FeedbackWindow.java

License:Open Source License

private void initUI() {
    GridLayout mainLayout = new GridLayout(2, 5);
    mainLayout.setMargin(true);/*w  ww  .j a  v  a2s  . co m*/
    mainLayout.setSpacing(true);

    emailNameTextField = new TextField();
    emailNameTextField.setWidth("500px");
    Label emailName = new Label("Your name: ");

    mainLayout.addComponent(emailName, 0, 0);
    mainLayout.addComponent(emailNameTextField, 1, 0);

    emailTextField = new TextField();
    emailTextField.setWidth("500px");
    emailTextField.setRequired(true);
    Label emailLbl = new Label("Your email: ");

    mainLayout.addComponent(emailLbl, 0, 1);
    mainLayout.addComponent(emailTextField, 1, 1);

    subjectTextField = new TextField();
    subjectTextField.setWidth("500px");
    subjectTextField.setRequired(true);
    Label subjectLbl = new Label("Subject: ");

    mainLayout.addComponent(subjectLbl, 0, 2);
    mainLayout.addComponent(subjectTextField, 1, 2);

    final RichTextArea contentArea = new RichTextArea();
    contentArea.setImmediate(true);
    contentArea.setWidth(500, Sizeable.Unit.PIXELS);
    contentArea.setHeight(200, Sizeable.Unit.PIXELS);
    Label contentLbl = new Label("Your feedback: ");

    mainLayout.addComponent(contentLbl, 0, 3);
    mainLayout.addComponent(contentArea, 1, 3);

    initDefaultData();

    HorizontalLayout controlsLayout = new HorizontalLayout();
    controlsLayout.setWidth("100%");

    final AttachmentPanel attachments = new AttachmentPanel();
    attachments.setWidth("350px");

    MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments);
    uploadExt.addComponent(attachments);

    // Panel attachedFilepanel = new Panel();
    VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setHeight("80px");
    contentLayout.setStyleName("noneBorder-panel");
    contentLayout.setSizeUndefined();

    contentLayout.addComponent(uploadExt);

    // attachedFilepanel.setContent(contentLayout);

    controlsLayout.addComponent(contentLayout);
    controlsLayout.setComponentAlignment(contentLayout, Alignment.BOTTOM_LEFT);
    controlsLayout.setExpandRatio(contentLayout, 1.0f);

    controlsLayout.setSpacing(true);

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    FeedbackWindow.this.close();
                }
            });

    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    controlsLayout.addComponent(cancelBtn);
    controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT);

    Button sendBtn = new Button("Send", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            String email = emailTextField.getValue().toString().trim();
            String subject = subjectTextField.getValue().toString().trim();
            if (!StringUtils.isValidEmail(email)) {
                NotificationUtil.showWarningNotification("The email is not valid, please check it again!");
                return;
            }
            if (!email.equals("") && !subject.equals("")) {
                ExtMailService systemMailService = ApplicationContextUtil.getSpringBean(ExtMailService.class);
                List<File> listFile = attachments.getListFile();
                List<EmailAttachementSource> emailAttachmentSource = null;

                if (CollectionUtils.isNotEmpty(listFile)) {
                    emailAttachmentSource = new ArrayList<EmailAttachementSource>();
                    for (File file : listFile) {
                        emailAttachmentSource.add(new FileEmailAttachmentSource(file));
                    }
                }

                String nameEmailFrom = emailNameTextField.getValue().toString().trim();
                nameEmailFrom = nameEmailFrom.equals("") ? email : nameEmailFrom;
                String toEmail = SiteConfiguration.getSendErrorEmail();

                FeedbackWindow.this.close();

                systemMailService.sendHTMLMail(email, nameEmailFrom,
                        Arrays.asList(new MailRecipientField(toEmail, toEmail)), null, null, subject,
                        contentArea.getValue().toString(), emailAttachmentSource);

            } else {
                NotificationUtil.showWarningNotification(
                        "The email field and subject field must be not empty! Please fulfil them before pressing enter button.");
            }
        }
    });
    sendBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    controlsLayout.addComponent(sendBtn);
    controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT);
    mainLayout.addComponent(controlsLayout, 0, 4, 1, 4);

    this.setContent(mainLayout);
}

From source file:org.hip.vif.admin.admin.ui.SendMailView.java

License:Open Source License

/** @param inGroups {@link GroupContainer}
 * @param inTask {@link SendMailTask} */
public SendMailView(final GroupContainer inGroups, final SendMailTask inTask) {
    final IMessages lMessages = Activator.getMessages();
    final VerticalLayout lLayout = initLayout(lMessages, "admin.send.mail.title.page"); //$NON-NLS-1$

    lLayout.addComponent(new Label(lMessages.getMessage("admin.send.remark"), ContentMode.HTML)); //$NON-NLS-1$
    lLayout.addComponent(RiplaViewHelper.createSpacer());

    final LabelValueTable lTable = new LabelValueTable();
    final ListSelect lGroups = new ListSelect();
    lGroups.setContainerDataSource(inGroups);
    lGroups.setRows(Math.min(SELECT_SIZE, inGroups.size()));
    lGroups.setStyleName(VIF_STYLE);//w ww  . j  av  a2s  .c om
    lGroups.setMultiSelect(true);
    lGroups.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    lGroups.setItemCaptionPropertyId(GroupContainer.PROPERTY_CAPTION);
    lGroups.focus();
    lTable.addRowEmphasized(lMessages.getMessage("admin.send.mail.label.select"), lGroups); //$NON-NLS-1$

    final TextField lSubject = new TextField();
    lSubject.setWidth(WIDTH, Unit.PIXELS);
    lSubject.setStyleName(VIF_STYLE);
    lTable.addRowEmphasized(lMessages.getMessage("admin.send.mail.label.subject"), lSubject); //$NON-NLS-1$

    final RichTextArea lBody = new RichTextArea();
    lBody.setStyleName("vif-editor " + VIF_STYLE); //$NON-NLS-1$
    lBody.setWidth(WIDTH, Unit.PIXELS);
    lTable.addRowEmphasized(lMessages.getMessage("admin.send.mail.label.body"), lBody); //$NON-NLS-1$
    lLayout.addComponent(lTable);

    send = new Button(lMessages.getMessage("admin.send.mail.button.send")); //$NON-NLS-1$
    // send.setClickShortcut(KeyCode.ENTER);
    send.addClickListener(new Button.ClickListener() {
        @Override
        @SuppressWarnings("unchecked")
        public void buttonClick(final ClickEvent inEvent) {
            if (!isValid(lGroups, lSubject, lBody)) {
                Notification.show(lMessages.getMessage("admin.send.mail.msg.not.valid"), //$NON-NLS-1$
                        Type.WARNING_MESSAGE);
                return;
            }
            if (!inTask.processGroups((Collection<GroupWrapper>) lGroups.getValue(),
                    lSubject.getValue().toString(), lBody.getValue())) {
                Notification.show(lMessages.getMessage("admin.send.mail.msg.errmsg"), Type.WARNING_MESSAGE); //$NON-NLS-1$
            }
        }
    });
    lLayout.addComponent(send);
}

From source file:org.hip.vif.web.util.VIFViewHelper.java

License:Open Source License

/** Helper method to create a text field.
 *
 * @param inContent String the field's content
 * @param inWidth int the field width (in pixels)
 * @param inHeight int the field width (in pixels)
 * @param inValidator {@link Validator} the field's validator or <code>null</code>, if no validation is applied
 * @return {@link RichTextArea} */
public static RichTextArea createTextArea(final String inContent, final int inWidth, final int inHeight,
        final Validator inValidator) {
    final RichTextArea out = new RichTextArea();
    out.setValue(inContent);/* www.jav a 2s . co  m*/
    if (inValidator != null) {
        out.addValidator(inValidator);
    }
    out.setWidth(inWidth, Unit.PIXELS);
    out.setHeight(inHeight, Unit.PIXELS);
    out.setStyleName("vif-editor"); //$NON-NLS-1$
    return out;
}

From source file:org.ripla.web.demo.widgets.views.InputWidgetsView.java

License:Open Source License

public InputWidgetsView() {
    super();/*from  w w w  .  ja  va 2s.c om*/

    final IMessages lMessages = Activator.getMessages();
    final VerticalLayout lLayout = initLayout(lMessages, "widgets.title.page.input"); //$NON-NLS-1$

    final HorizontalLayout lColumns = new HorizontalLayout();
    lColumns.setSpacing(true);
    lLayout.addComponent(lColumns);

    final VerticalLayout lCol1 = new VerticalLayout();
    lCol1.setSizeUndefined();
    lColumns.addComponent(lCol1);
    final VerticalLayout lCol2 = new VerticalLayout();
    lCol2.setSizeUndefined();
    lColumns.addComponent(lCol2);
    final VerticalLayout lCol3 = new VerticalLayout();
    lCol3.setSizeUndefined();
    lColumns.addComponent(lCol3);
    lColumns.setExpandRatio(lCol3, 1);

    // classic input fields
    lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.input.normal"))); //$NON-NLS-1$
    final TextField lTextField = new TextField();
    lTextField.setColumns(WIDTH_FIELD);
    lCol1.addComponent(lTextField);

    lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.input.prompt"))); //$NON-NLS-1$
    final TextField lTextField2 = new TextField();
    lTextField2.setInputPrompt(lMessages.getMessage("widgets.input.input.prompt")); //$NON-NLS-1$
    lTextField2.setColumns(WIDTH_FIELD);
    lCol1.addComponent(lTextField2);

    lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.input.password"))); //$NON-NLS-1$
    final PasswordField lPassword = new PasswordField();
    lPassword.setColumns(WIDTH_FIELD);
    lCol1.addComponent(lPassword);

    lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.date"))); //$NON-NLS-1$
    final PopupDateField lDate1 = new PopupDateField(lMessages.getMessage("widgets.input.popup.date")); //$NON-NLS-1$
    lDate1.setResolution(Resolution.DAY);
    lDate1.setDateFormat("dd. MMMM yyyy"); //$NON-NLS-1$
    lDate1.setWidth(160, Unit.PIXELS);
    lDate1.setValue(new java.util.Date());
    lCol1.addComponent(lDate1);

    // text areas
    lCol2.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.text.area"))); //$NON-NLS-1$
    final TextArea lArea = new TextArea();
    lArea.setColumns(WIDTH_AREA);
    lArea.setRows(7);
    lCol2.addComponent(lArea);

    lCol2.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.rich.text"))); //$NON-NLS-1$
    final RichTextArea lRichText = new RichTextArea();
    lRichText.setWidth(WIDTH_AREA, Unit.EM);
    lRichText.setHeight(15, Unit.EM);
    lCol2.addComponent(lRichText);

    // text input with filter
    final CountryContainer lCountries = new CountryContainer();
    lCol3.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.input.filter"))); //$NON-NLS-1$
    final TextField lFilter = new TextField();
    lFilter.setTextChangeEventMode(TextChangeEventMode.LAZY);
    lFilter.setTextChangeTimeout(200);
    lFilter.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(final TextChangeEvent inEvent) {
            lCountries.removeAllContainerFilters();
            lCountries.addContainerFilter(
                    new SimpleStringFilter(CountryContainer.PROPERTY_NAME, inEvent.getText(), true, true));
        }
    });
    lFilter.setWidth(FILTER_WIDTH, Unit.PIXELS);

    final Table lTable = new Table(null, lCountries);
    lTable.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
    lTable.setWidth(FILTER_WIDTH, Unit.PIXELS);
    lTable.setPageLength(18);

    lCol3.addComponent(lFilter);
    lCol3.addComponent(lTable);
}