Example usage for com.vaadin.ui TextArea TextArea

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

Introduction

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

Prototype

public TextArea() 

Source Link

Document

Constructs an empty TextArea.

Usage

From source file:com.mycollab.mobile.module.project.ui.ProjectCommentInputView.java

License:Open Source License

public ProjectCommentInputView(String typeVal, String typeIdVal, Integer extraTypeIdVal) {
    this.setCaption(UserUIContext.getMessage(GenericI18Enum.ACTION_ADD_COMMENT));
    resourceService = AppContextUtil.getSpringBean(ResourceService.class);
    MVerticalLayout content = new MVerticalLayout().withFullWidth().withStyleName("comment-input");
    this.setContent(content);

    type = typeVal;//from   w w w . j  a v a2  s. co  m
    typeId = typeIdVal;
    extraTypeId = extraTypeIdVal;

    prepareUploadField();

    commentInput = new TextArea();
    commentInput.setWidth("100%");
    commentInput.setInputPrompt("---");

    MButton postBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> {
        final CommentWithBLOBs comment = new CommentWithBLOBs();
        comment.setComment(commentInput.getValue());
        comment.setCreatedtime(new GregorianCalendar().getTime());
        comment.setCreateduser(UserUIContext.getUsername());
        comment.setSaccountid(MyCollabUI.getAccountId());
        comment.setType(type);
        comment.setTypeid("" + typeId);
        comment.setExtratypeid(extraTypeId);

        final CommentService commentService = AppContextUtil.getSpringBean(CommentService.class);
        int commentId = commentService.saveWithSession(comment, UserUIContext.getUsername());

        String attachmentPath = AttachmentUtils.getCommentAttachmentPath(type, MyCollabUI.getAccountId(),
                CurrentProjectVariables.getProjectId(), typeId, commentId);
        if (!"".equals(attachmentPath)) {
            saveContentsToRepo(attachmentPath);
        }

        getNavigationManager().navigateBack();
    });
    this.setRightComponent(postBtn);
    content.with(commentInput, ELabel.hr(), uploadField, statusWrapper);
}

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 w w  .  j  a  va2 s  .c o 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.mycollab.module.project.view.settings.ProjectMemberInviteViewImpl.java

License:Open Source License

private void initContent() {
    this.removeAllComponents();

    roleComboBox = new ProjectRoleComboBox();
    roleComboBox.addValueChangeListener(valueChangeEvent -> {
        Integer roleId = (Integer) roleComboBox.getValue();
        displayRolePermission(roleId);/*  w  ww  .  j av a2  s .  c  o m*/
    });

    AddViewLayout userAddLayout = new AddViewLayout(
            UserUIContext.getMessage(ProjectMemberI18nEnum.FORM_INVITE_MEMBERS), FontAwesome.USER);
    userAddLayout.addHeaderRight(createButtonControls());

    GridFormLayoutHelper informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 3);

    inviteUserTokenField = new InviteUserTokenField();
    informationLayout.addComponent(
            new MVerticalLayout(inviteUserTokenField,
                    new ELabel(UserUIContext.getMessage(ProjectMemberI18nEnum.USER_TOKEN_INVITE_HINT))
                            .withStyleName(UIConstants.META_INFO)).withMargin(false),
            UserUIContext.getMessage(ProjectMemberI18nEnum.FORM_INVITEES_EMAIL), 0, 0);
    informationLayout.addComponent(roleComboBox, UserUIContext.getMessage(ProjectMemberI18nEnum.FORM_ROLE), 0,
            1);

    messageArea = new TextArea();
    messageArea.setValue(UserUIContext.getMessage(ProjectMemberI18nEnum.MSG_DEFAULT_INVITATION_COMMENT));
    informationLayout.addComponent(messageArea, UserUIContext.getMessage(ProjectMemberI18nEnum.FORM_MESSAGE), 0,
            2);

    userAddLayout.addBody(informationLayout.getLayout());
    userAddLayout.addBottom(createBottomPanel());
    this.addComponent(userAddLayout);
}

From source file:com.mycollab.module.project.view.settings.ProjectRoleAddViewImpl.java

License:Open Source License

@Override
protected AbstractBeanFieldGroupEditFieldFactory<ProjectRole> initBeanFormFieldFactory() {
    return new AbstractBeanFieldGroupEditFieldFactory<ProjectRole>(editForm) {
        private static final long serialVersionUID = 1L;

        @Override/*from  w w  w.  j  av  a 2 s.  c o m*/
        protected Field<?> onCreateField(Object propertyId) {
            if (propertyId.equals("description")) {
                final TextArea textArea = new TextArea();
                textArea.setNullRepresentation("");
                return textArea;
            } else if (propertyId.equals("rolename")) {
                final TextField tf = new TextField();
                if (isValidateForm) {
                    tf.setNullRepresentation("");
                    tf.setRequired(true);
                    tf.setRequiredError("Please enter a projectRole name");
                }
                return tf;
            }
            return null;
        }
    };
}

From source file:com.ocs.dynamo.domain.model.impl.ModelBasedFieldFactory.java

License:Apache License

/**
 * Creates a field/*from ww w  .j av  a  2  s  .c om*/
 * 
 * @param propertyId
 *            the name of the property that can be edited by this field
 * @param fieldEntityModel
 *            the custom entity model for the field
 * @return
 */
public Field<?> createField(String propertyId, EntityModel<?> fieldEntityModel) {

    // in case of a read-only field, return <code>null</code> so Vaadin will
    // render a label instead
    AttributeModel attributeModel = model.getAttributeModel(propertyId);
    if (attributeModel.isReadOnly()
            && (!attributeModel.isUrl() && !AttributeType.DETAIL.equals(attributeModel.getAttributeType()))
            && !search) {
        return null;
    }

    Field<?> field = null;

    if (AttributeTextFieldMode.TEXTAREA.equals(attributeModel.getTextFieldMode()) && !search) {
        // text area field
        field = new TextArea();
    } else if (attributeModel.isWeek()) {
        // special case - week field in a table
        TextField tf = new TextField();
        tf.setConverter(new WeekCodeConverter());
        field = tf;
    } else if (search && attributeModel.getType().equals(Boolean.class)) {
        // in a search screen, we need to offer the true, false, and
        // undefined options
        field = constructSearchBooleanComboBox(attributeModel);
    } else if (AbstractEntity.class.isAssignableFrom(attributeModel.getType())) {
        // lookup or combo field for an entity
        field = constructSelectField(attributeModel, fieldEntityModel, null);
    } else if (AttributeType.ELEMENT_COLLECTION.equals(attributeModel.getAttributeType())) {
        // use a "collection table" for an element collection
        FormOptions fo = new FormOptions();
        fo.setShowRemoveButton(true);
        if (String.class.equals(attributeModel.getMemberType())) {
            CollectionTable<String> table = new CollectionTable<>(false, fo, String.class);
            table.setMinLength(attributeModel.getMinLength());
            table.setMaxLength(attributeModel.getMaxLength());
            field = table;
        } else if (Integer.class.equals(attributeModel.getMemberType())) {
            CollectionTable<Integer> table = new CollectionTable<>(false, fo, Integer.class);
            field = table;
        } else {
            // other types not supported for now
            throw new OCSRuntimeException();
        }
    } else if (Collection.class.isAssignableFrom(attributeModel.getType())) {
        // render a multiple select component for a collection
        field = constructCollectionSelect(attributeModel.getNestedEntityModel(), attributeModel, null, true,
                search);
    } else if (AttributeDateType.TIME.equals(attributeModel.getDateType())) {
        TimeField tf = new TimeField();
        tf.setResolution(Resolution.MINUTE);
        tf.setLocale(VaadinSession.getCurrent() == null ? DynamoConstants.DEFAULT_LOCALE
                : VaadinSession.getCurrent().getLocale());
        field = tf;
    } else if (attributeModel.isUrl()) {
        // URL field (offers clickable link in readonly mode)
        TextField tf = (TextField) createField(attributeModel.getType(), Field.class);
        tf.addValidator(new URLValidator(messageService.getMessage("ocs.no.valid.url")));
        tf.setNullRepresentation(null);
        tf.setSizeFull();

        // wrap text field in URL field
        field = new URLField(tf, attributeModel, false);
        field.setSizeFull();
    } else {
        // just a regular field
        field = createField(attributeModel.getType(), Field.class);
    }
    field.setCaption(attributeModel.getDisplayName());

    postProcessField(field, attributeModel);

    // add a field validator based on JSR-303 bean validation
    if (validate) {
        field.addValidator(new BeanValidator(model.getEntityClass(), (String) propertyId));
        // disable the field if it cannot be edited
        if (!attributeModel.isUrl()) {
            field.setEnabled(!attributeModel.isReadOnly());
        }

        if (attributeModel.isNumerical()) {
            field.addStyleName(DynamoConstants.CSS_NUMERICAL);
        }
    }
    return field;
}

From source file:com.squadd.UI.GroupChatLayout.java

public GroupChatLayout(Group group) {
    name = new Panel();
    Label label = new Label("Group Chat");
    label.setSizeUndefined();//  w w w . j  a  v  a2s.c  o m
    HorizontalLayout hor = new HorizontalLayout();
    hor.setWidth(0.67 * Display.width + "px");
    hor.addComponent(label);
    hor.setComponentAlignment(label, Alignment.TOP_CENTER);
    name.setWidth(0.68 * Display.width + "px");
    name.setContent(hor);
    name.setStyleName("backColorGrey");
    message = new TextArea();
    msg = new ArrayList();
    send = new Button("send");
    content = new VerticalLayout();

    dateComparator = new Comparator<GroupChat>() {
        @Override
        public int compare(GroupChat o1, GroupChat o2) {
            return -o1.getDate().compareTo(o2.getDate());
        }
    };
    configureLayout(group);
    configureActions(group);
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentComplaintsPanel.java

private void openComplaintWindow(Complaint complaint) {

    WebBrowser webBrowser = Page.getCurrent().getWebBrowser();

    Window window = new Window("Registro de Queja");
    window.setModal(true);/*from  w w  w .  j a  va  2  s.co m*/
    if (webBrowser.getScreenWidth() < 1024) {
        window.setSizeFull();
    } else {
        window.setHeight(90.0f, Unit.PERCENTAGE);
        window.setWidth(90.0f, Unit.PERCENTAGE);
    }

    //        TextField nameField = new TextField();
    //        nameField.setInputPrompt("Introduzca el ttulo de la queja");
    //        nameField.setWidth("100%");
    TextArea notesArea = new TextArea();
    notesArea.setInputPrompt("Introduzca el contenido de la queja");
    notesArea.setSizeFull();
    //        CheckBox doneField = new CheckBox("Atendido");

    HorizontalLayout horizontal = new HorizontalLayout();
    horizontal.setSpacing(true);
    horizontal.addComponent(createDeleteButton(window));
    horizontal.addComponent(createOkButton(window));

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setMargin(true);
    layout.addComponent(complaintType);
    layout.addComponent(notesArea);
    //        layout.addComponent(doneField);
    layout.addComponent(horizontal);
    layout.setComponentAlignment(horizontal, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(complaintType, 1);
    layout.setExpandRatio(notesArea, 8);
    //        layout.setExpandRatio(doneField, 1);
    layout.setExpandRatio(horizontal, 1);

    BeanItem beanItem = new BeanItem<>(complaint);
    fieldGroup = new BeanFieldGroup<>(Complaint.class);
    fieldGroup.setItemDataSource(beanItem);
    fieldGroup.bind(complaintType, "complaintType");
    fieldGroup.bind(notesArea, "notes");
    //        fieldGroup.bind(doneField, "done");

    window.setContent(layout);
    getUI().addWindow(window);

    //        Window windowComplaint = new Window(complaintView);
    //        WidgetActions actions = new WidgetActions(){
    //
    //            @Override
    //            public void saveAction() {
    //                refreshBind();
    //                windowComplaint.close();
    //            }
    //
    //            @Override
    //            public void deleteAction() {
    //                appointment.getComplaints().remove(complaint);
    //                refreshBind();
    //                windowComplaint.close();
    //            }
    //            
    //        };
    //        complaintView.bind(complaint);
    //        complaintView.setActions(actions);
    //        getUI().addWindow(windowComplaint);
}

From source file:com.thingtrack.vaadin.desktop.MyVaadinUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();//from w ww.  j  a  v  a 2  s .  c  o  m
    mainLayout.setMargin(true);
    setContent(mainLayout);

    mainLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    textArea = new TextArea();
    textArea.setInputPrompt("Send message");
    mainLayout.addComponent(textArea);

    Button button = new Button("Send");
    button.setImmediate(true);
    button.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            if (publisher == null) {
                publisher = new Publisher();
                publisher.start();
            }

            String message = textArea.getValue();

            try {
                publisher.send(message);
            } catch (MqttException e) {
                Notification.show(e.getMessage(), Type.ERROR_MESSAGE);
            }
        }
    });

    mainLayout.addComponent(button);
}

From source file:com.vaushell.treetasker.application.content.layout.EditTaskLayout.java

License:Open Source License

private VerticalLayout getDescriptionLayout() {
    if (descriptionLayout == null) {
        descriptionLayout = new VerticalLayout();
        descriptionLayout.setMargin(true);
        descriptionLayout.setHeight("100%");

        vTAtaskDescriptionValue = new TextArea();
        vTAtaskDescriptionValue.setValue(taskNode.getTask().getDescription());
        vTAtaskDescriptionValue.setReadOnly(true);
        vTAtaskDescriptionValue.setRows(20);
        vTAtaskDescriptionValue.setWidth("100%");
        vTAtaskDescriptionValue.setNullRepresentation("Ajouter une description...");

        descriptionLayout.addComponent(vTAtaskDescriptionValue);
    }//from   w w  w.  j av a 2s .  com
    return descriptionLayout;
}

From source file:de.fatalix.timeline.web.root.block.TimelineConfigLayout.java

private Layout createLeftSide() {
    headline = new TextField();
    headline.setInputPrompt("Your timeline headline...");
    headline.setColumns(15);//  w w  w  . j a  v a 2s. c  o  m
    headline.setNullSettingAllowed(true);
    headline.addStyleName("timeline");
    text = new TextArea();
    text.setInputPrompt("Your timeline description...");
    text.setColumns(30);
    text.setRows(10);
    text.setNullSettingAllowed(true);
    startDate = new DateField(null, new Date());
    startDate.setDateFormat("dd-MM-yyyy");
    startDate.setResolution(Resolution.DAY);

    Button createEventBtn = new Button("Add Event", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            TimelineEvent newEvent = new TimelineEvent();
            newEvent.setTimeline(data);
            newEvent.setStartDate(new Date());
            data.getEvents().add(newEvent);
            addTimelineEvent(newEvent);
        }
    });
    return new VerticalLayout(headline, text, startDate, createEventBtn);
}