Example usage for com.vaadin.ui TextField setValue

List of usage examples for com.vaadin.ui TextField setValue

Introduction

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

Prototype

@Override
public void setValue(String value) 

Source Link

Document

Sets the value of this text field.

Usage

From source file:com.jiangyifen.ec2.ui.mgr.outlinemanage.EditOutline.java

@Override
public void valueChange(ValueChangeEvent event) {
    Property source = event.getProperty();
    if (source == sipType) {
        TextField hostField = (TextField) form.getField("host");
        if (hostField != null) {
            if (SipConfigType.gateway_outline.equals(sipType.getValue())) {
                hostField.setValue("dynamic");
            } else {
                hostField.setValue("");
            }//w  ww.  j  a  va 2 s . c  o m
        }
    } else {
        this.center();
        String typeValue = (String) settingType.getValue();
        if ("advanced".equals(typeValue)) {
            this.setHeight("700px");
            this.setWidth("380px");
            // ?
            advancedEditOutline();
        } else {
            this.setWidth("360px");
            this.setHeight("565px");
            // ??
            typicalEditOutline();
        }
    }
}

From source file:com.jorambarrez.PropertyPanel.java

License:Apache License

public void showNodeProperties(Node node) {
    currentNode = node;//  www  . j  ava 2 s  .co m

    title.setValue(node.getText());
    title.setContentMode(Label.CONTENT_DEFAULT);

    // Demo
    propertyLayout.removeAllComponents();
    Label assigneeLabel = new Label("Assignee");
    assigneeLabel.addStyleName(STYLE_BOLD);
    propertyLayout.addComponent(assigneeLabel);
    TextField assigneeTextField = new TextField();
    assigneeTextField.setValue(node.getProperty("Assignee"));
    propertyLayout.addComponent(assigneeTextField);

    Label deadlineLabel = new Label("Deadline");
    deadlineLabel.addStyleName(STYLE_BOLD);
    propertyLayout.addComponent(deadlineLabel);
    DateField deadlineField = new DateField();
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
    try {
        deadlineField.setValue(dateFormat.parseObject(node.getProperty("Deadline")));
        propertyLayout.addComponent(deadlineField);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.klwork.explorer.ui.business.social.SaveToNotePopupWindow.java

License:Apache License

public VerticalLayout initMainLayout(final SocialUserWeibo userWeibo) {
    return new VerticalLayout() {
        {//from w  ww .  ja v a  2 s.c o  m
            setSizeFull();
            setSpacing(true);
            setMargin(new MarginInfo(true, true, false, true));

            Label descriptionField = new Label();
            descriptionField.addStyleName("wb_text");
            descriptionField.setContentMode(ContentMode.HTML);
            descriptionField.setValue("");
            addComponent(descriptionField);
            // ?
            weiboContentTA = new TextArea("");
            weiboContentTA.setWidth("100%");
            weiboContentTA.setColumns(25);
            weiboContentTA.focus();
            addComponent(weiboContentTA);
            scheduleEventFieldGroup.bind(weiboContentTA, "content");

            if (hasOrginWeibo) {// 
                weiboContentTA.setValue("//@" + userWeibo.getUserScreenName() + ": " + userWeibo.getText());
            } else {
                weiboContentTA.setValue(userWeibo.getText());
                //+ mainPage.textTranslate(userWeibo.getText()));
            }

            //,
            addComponent(new VerticalLayout() {
                {
                    setSpacing(true);

                    TextField titleField = CommonFieldHandler.createTextField("");
                    scheduleEventFieldGroup.bind(titleField, "title");

                    //???
                    if (userWeibo.getText() != null && userWeibo.getText().length() > 10) {
                        titleField.setValue(userWeibo.getText().substring(0, 10));
                    }
                    addComponent(titleField);
                    // setSizeFull();
                    // setMargin(true);
                    SocialUserAccount noteAccount = socialUserAccountService
                            .findSocialUserByType(socialUserAccount.getOwnUser(), DictDef.dictInt("evernote"));
                    if (noteAccount != null) {
                        noteEntity.setUserAccountId(noteAccount.getId());
                    }

                    Map<String, String> map = socialEvernoteService.queryNotebook(noteAccount);
                    ComboBox noteMap = CommonFieldHandler.createComBox("", map, "");
                    addComponent(noteMap);
                    setComponentAlignment(noteMap, Alignment.MIDDLE_LEFT);
                }
            });

            // 
            HorizontalLayout buttonLayout = new HorizontalLayout() {
                {
                    setSpacing(true);
                    setSizeFull();
                    // setMargin(true);
                    Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                    addComponent(okButton);
                    setComponentAlignment(okButton, Alignment.TOP_RIGHT);

                    okButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            BinderHandler.commit(scheduleEventFieldGroup);
                            //?
                            int ret = socialEvernoteService.saveWeiboToNotes(noteEntity);
                            if (ret == 1) {
                                Notification.show("??", Notification.Type.HUMANIZED_MESSAGE);
                            } else {
                                Notification.show("??!", Notification.Type.HUMANIZED_MESSAGE);
                            }
                            close();
                        }
                    });
                    setExpandRatio(okButton, 1.0f);

                    Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
                    addComponent(cancleButton);
                    setComponentAlignment(cancleButton, Alignment.TOP_RIGHT);

                    cancleButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            close();
                        }
                    });
                }
            };
            addComponent(buttonLayout);
            setExpandRatio(buttonLayout, 1f);

        }
    };
}

From source file:com.klwork.explorer.ui.form.LongFormPropertyRenderer.java

License:Apache License

@Override
public Field getPropertyField(FormProperty formProperty) {
    final TextField textField = new TextField(getPropertyLabel(formProperty));
    textField.setRequired(formProperty.isRequired());
    textField.setEnabled(formProperty.isWritable());
    textField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));

    if (formProperty.getValue() != null) {
        textField.setValue(formProperty.getValue());
    }//from www .  ja  va2  s .  com

    // Add validation of numeric value
    textField.addValidator(new LongValidator("Value must be a long"));
    textField.setImmediate(true);

    return textField;
}

From source file:com.klwork.explorer.ui.form.StringFormPropertyRenderer.java

License:Apache License

@Override
public Field getPropertyField(FormProperty formProperty) {
    TextField textField = new TextField(getPropertyLabel(formProperty));
    textField.setRequired(formProperty.isRequired());
    textField.setEnabled(formProperty.isWritable());
    textField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));

    if (formProperty.getValue() != null) {
        textField.setValue(formProperty.getValue());
    }// www .  j  av  a  2  s  .c o  m

    return textField;
}

From source file:com.liferay.mail.vaadin.FolderTree.java

License:Open Source License

public void handleAccountAction(AccountAction action) {
    final Long accountId = action.getAccountId();
    if (accountId == null) {
        return;//w  ww  .  j  a va2 s.co  m
    }

    if (Lang.get("create-folder").equals(action.getCaption())) {
        String title = Lang.get("create-folder");
        String message = Lang.get("please-enter-a-folder-name");
        final ConfirmDialog confirm = new ConfirmDialog(Lang.get("confirm"), title, message);
        final TextField newNameField = new TextField();
        newNameField.setNullRepresentation("");
        newNameField.setValue("new folder");
        confirm.addExtraComponent(newNameField);

        confirm.addConfirmButtonListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {
                String newName = (String) newNameField.getValue();
                if (newName != null && !"".equals(newName)) {
                    confirm.closeDialog();

                    addFolder(accountId, newName);

                    synchronizeAccount(accountId, Controller.get());
                    refresh();
                } else {
                    Controller.get().showError(Lang.get("please-enter-a-folder-name"));
                }
            }
        });

        Controller.get().getApplication().getMainWindow().addWindow(confirm);
    }
}

From source file:com.liferay.mail.vaadin.FolderTree.java

License:Open Source License

public void handleFolderAction(FolderAction action) {
    final Folder folder = action.getFolder();
    if (folder == null) {
        return;/*from  ww  w.  j  a va2 s.c  o m*/
    }

    if (Lang.get("rename-folder").equals(action.getCaption())) {
        String title = Lang.get("rename-folder");
        String message = Lang.get("please-enter-a-new-folder-name");
        final ConfirmDialog confirm = new ConfirmDialog(Lang.get("confirm"), title, message);
        final TextField newNameField = new TextField();
        newNameField.setNullRepresentation("");
        newNameField.setValue(folder.getDisplayName());
        confirm.addExtraComponent(newNameField);

        confirm.addConfirmButtonListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {
                String newName = (String) newNameField.getValue();
                if (newName != null && !"".equals(newName)) {
                    confirm.closeDialog();

                    renameFolder(folder.getFolderId(), newName);

                    synchronizeAccount(folder.getAccountId(), Controller.get());
                    refresh();
                } else {
                    Controller.get().showError(Lang.get("please-enter-a-new-folder-name"));
                }
            }
        });

        Controller.get().getApplication().getMainWindow().addWindow(confirm);
    } else if (Lang.get("delete-folder").equals(action.getCaption())) {
        final ConfirmDialog confirm = new ConfirmDialog(Lang.get("confirm"), Lang.get("delete-folder"),
                Lang.get("are-you-sure-you-want-to-delete-this-folder"));

        confirm.addConfirmButtonListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {
                confirm.closeDialog();

                deleteFolder(folder.getFolderId());

                synchronizeAccount(folder.getAccountId(), Controller.get());
                refresh();
            }
        });

        Controller.get().getApplication().getMainWindow().addWindow(confirm);
    }
}

From source file:com.lizardtech.expresszip.vaadin.ExportOptionsViewComponent.java

License:Apache License

private void constrainTileDimension(TextField f, int constraint) {
    int v = -1;//from w  w w .j  a v  a 2  s.c  o m
    if (f.getValue() != null) {
        try {
            v = Integer.parseInt((String) f.getValue());
        } catch (NumberFormatException e) {
        }
    }
    if (f.getValue() == null || v > constraint || v < 1)
        f.setValue(Integer.toString(constraint));
}

From source file:com.mycollab.module.project.view.bug.components.ToggleBugSummaryField.java

License:Open Source License

public ToggleBugSummaryField(final BugWithBLOBs bug, int trimCharacters) {
    this.bug = bug;
    this.maxLength = trimCharacters;
    titleLinkLbl = new Label(buildBugLink(), ContentMode.HTML);
    titleLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP);
    titleLinkLbl.setWidthUndefined();/* w w  w.  ja  v  a2 s  .c om*/
    this.addComponent(titleLinkLbl);
    buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false);
    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) {
        this.addStyleName("editable-field");
        MButton instantEditBtn = new MButton("", clickEvent -> {
            if (isRead) {
                ToggleBugSummaryField.this.removeComponent(titleLinkLbl);
                ToggleBugSummaryField.this.removeComponent(buttonControls);
                final TextField editField = new TextField();
                editField.setValue(bug.getSummary());
                editField.setWidth("100%");
                editField.focus();
                ToggleBugSummaryField.this.addComponent(editField);
                ToggleBugSummaryField.this.removeStyleName("editable-field");
                editField.addValueChangeListener(valueChangeEvent -> updateFieldValue(editField));
                editField.addBlurListener(blurEvent -> updateFieldValue(editField));
                isRead = !isRead;
            }
        }).withIcon(FontAwesome.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ONLY,
                ValoTheme.BUTTON_ICON_ALIGN_TOP);
        instantEditBtn.setDescription("Edit task name");
        buttonControls.with(instantEditBtn);
        this.addComponent(buttonControls);
    }
}

From source file:com.mycollab.module.project.view.bug.ToggleBugSummaryField.java

License:Open Source License

public ToggleBugSummaryField(final BugWithBLOBs bug, int trimCharacters) {
    this.bug = bug;
    this.maxLength = trimCharacters;
    titleLinkLbl = ELabel.html(buildBugLink()).withStyleName(UIConstants.LABEL_WORD_WRAP).withWidthUndefined();
    this.addComponent(titleLinkLbl);
    buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false);
    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) {
        this.addStyleName("editable-field");
        MButton instantEditBtn = new MButton("", clickEvent -> {
            if (isRead) {
                ToggleBugSummaryField.this.removeComponent(titleLinkLbl);
                ToggleBugSummaryField.this.removeComponent(buttonControls);
                final TextField editField = new TextField();
                editField.setValue(bug.getName());
                editField.setWidth("100%");
                editField.focus();/*from   w  w w .  ja v a 2 s  .  c om*/
                ToggleBugSummaryField.this.addComponent(editField);
                ToggleBugSummaryField.this.removeStyleName("editable-field");
                editField.addValueChangeListener(valueChangeEvent -> updateFieldValue(editField));
                editField.addBlurListener(blurEvent -> updateFieldValue(editField));
                isRead = !isRead;
            }
        }).withDescription(UserUIContext.getMessage(BugI18nEnum.OPT_EDIT_BUG_NAME)).withIcon(FontAwesome.EDIT)
                .withStyleName(ValoTheme.BUTTON_ICON_ONLY, ValoTheme.BUTTON_ICON_ALIGN_TOP);
        buttonControls.with(instantEditBtn);
        this.addComponent(buttonControls);
    }
}