List of usage examples for com.vaadin.ui TextField TextField
public TextField()
TextField
with no caption. From source file:com.esofthead.mycollab.module.project.view.page.PageEditFormFieldFactory.java
License:Open Source License
@Override protected Field<?> onCreateField(Object propertyId) { Page page = attachForm.getBean();/* w ww . ja v a 2s . c om*/ if (propertyId.equals("content")) { CKEditorConfig config = new CKEditorConfig(); config.useCompactTags(); config.setResizeDir(CKEditorConfig.RESIZE_DIR.HORIZONTAL); config.disableSpellChecker(); config.disableResizeEditor(); config.disableElementsPath(); config.setToolbarCanCollapse(true); config.setWidth("100%"); String appUrl = AppContext.getSiteUrl(); String params = String.format("path=%s&createdUser=%s&sAccountId=%d", page.getPath(), AppContext.getUsername(), AppContext.getAccountId()); if (appUrl.endsWith("/")) { config.setFilebrowserUploadUrl(appUrl + "page/upload?" + params); } else { config.setFilebrowserUploadUrl(appUrl + "/page/upload?" + params); } final CKEditorTextField ckEditorTextField = new CKEditorTextField(config); ckEditorTextField.setHeight("450px"); ckEditorTextField.setRequired(true); ckEditorTextField.setRequiredError("Content must be not null"); return ckEditorTextField; } else if (propertyId.equals("status")) { page.setStatus(WikiI18nEnum.status_public.name()); return new I18nValueComboBox(false, WikiI18nEnum.status_public, WikiI18nEnum.status_private, WikiI18nEnum.status_archieved); } else if (propertyId.equals("subject")) { TextField subjectField = new TextField(); subjectField.setRequired(true); subjectField.setRequiredError("Subject must be not null"); return subjectField; } return null; }
From source file:com.esofthead.mycollab.module.project.view.ProjectAddBaseTemplateWindow.java
License:Open Source License
public ProjectAddBaseTemplateWindow() { super(AppContext.getMessage(ProjectI18nEnum.OPT_CREATE_PROJECT_FROM_TEMPLATE)); this.setModal(true); this.setClosable(true); this.setResizable(false); this.setWidth("550px"); MVerticalLayout content = new MVerticalLayout(); GridFormLayoutHelper gridFormLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(1, 3); final TemplateProjectComboBox templateProjectComboBox = new TemplateProjectComboBox(); Button helpBtn = new Button(""); helpBtn.setIcon(FontAwesome.QUESTION_CIRCLE); helpBtn.addStyleName(UIConstants.BUTTON_ACTION); helpBtn.setDescription(AppContext.getMessage(ProjectI18nEnum.OPT_MARK_TEMPLATE_HELP)); gridFormLayoutHelper/*from w ww.j a va2 s . c o m*/ .addComponent( new MHorizontalLayout().withFullWidth().with(templateProjectComboBox, helpBtn) .expand(templateProjectComboBox), AppContext.getMessage(ProjectI18nEnum.FORM_TEMPLATE), 0, 0); final TextField prjNameField = new TextField(); gridFormLayoutHelper.addComponent(prjNameField, AppContext.getMessage(GenericI18Enum.FORM_NAME), 0, 1); final TextField prjKeyField = new TextField(); gridFormLayoutHelper.addComponent(prjKeyField, AppContext.getMessage(ProjectI18nEnum.FORM_SHORT_NAME), 0, 2); MHorizontalLayout buttonControls = new MHorizontalLayout(); content.with(gridFormLayoutHelper.getLayout(), buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT); Button okBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_OK), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { SimpleProject templatePrj = (SimpleProject) templateProjectComboBox.getValue(); if (templatePrj == null) { NotificationUtil.showErrorNotification( AppContext.getMessage(ProjectI18nEnum.ERROR_MUST_CHOOSE_TEMPLATE_PROJECT)); return; } String newPrjName = prjNameField.getValue(); if (newPrjName.length() == 0) { NotificationUtil.showErrorNotification("Project name must be not null"); return; } String newPrjKey = prjKeyField.getValue(); if (newPrjKey.length() > 3 || newPrjKey.length() == 0) { NotificationUtil .showErrorNotification("Project key must be not null and less than 3 characters"); return; } ProjectTemplateService projectTemplateService = AppContextUtil .getSpringBean(ProjectTemplateService.class); if (projectTemplateService != null) { Integer newProjectId = projectTemplateService.cloneProject(templatePrj.getId(), newPrjName, newPrjKey, AppContext.getAccountId(), AppContext.getUsername()); EventBusFactory.getInstance().post(new ProjectEvent.GotoMyProject(this, new PageActionChain(new ProjectScreenData.Goto(newProjectId)))); close(); } } }); okBtn.setIcon(FontAwesome.SAVE); okBtn.addStyleName(UIConstants.BUTTON_ACTION); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { close(); } }); cancelBtn.addStyleName(UIConstants.BUTTON_OPTION); buttonControls.with(cancelBtn, okBtn); this.setContent(content); }
From source file:com.esofthead.mycollab.module.project.view.settings.component.ComponentEditFormFieldFactory.java
License:Open Source License
@Override protected Field<?> onCreateField(final Object propertyId) { if (Component.Field.componentname.equalTo(propertyId)) { final TextField tf = new TextField(); if (isValidateForm) { tf.setNullRepresentation(""); tf.setRequired(true);// ww w . j av a2 s .c o m tf.setRequiredError(AppContext.getMessage(ComponentI18nEnum.FORM_COMPONENT_ERROR)); } return tf; } else if (Component.Field.description.equalTo(propertyId)) { return new RichTextArea(); } else if (Component.Field.userlead.equalTo(propertyId)) { return new ProjectMemberSelectionField(); } return null; }
From source file:com.esofthead.mycollab.module.project.view.settings.component.VersionEditFormFieldFactory.java
License:Open Source License
@Override protected Field<?> onCreateField(final Object propertyId) { if (Version.Field.versionname.equalTo(propertyId)) { final TextField tf = new TextField(); if (isValidateForm) { tf.setNullRepresentation(""); tf.setRequired(true);/*w w w . j ava2 s . c o m*/ tf.setRequiredError(AppContext.getMessage(VersionI18nEnum.FORM_VERSION_ERROR_MSG)); } return tf; } else if (Version.Field.description.equalTo(propertyId)) { return new RichTextArea(); } else if (Version.Field.duedate.equalTo(propertyId)) { final PopupDateFieldExt dateField = new PopupDateFieldExt(); dateField.setResolution(Resolution.DAY); return dateField; } return null; }
From source file:com.esofthead.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 ww . j a v 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("isadmin")) { } 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.esofthead.mycollab.module.project.view.task.components.ToggleTaskSummaryField.java
License:Open Source License
public ToggleTaskSummaryField(final SimpleTask task, int maxLength) { this.setWidth("100%"); this.maxLength = maxLength; this.task = task; titleLinkLbl = new Label(buildTaskLink(), ContentMode.HTML); titleLinkLbl.setWidthUndefined();/*from ww w . j ava2s . c o m*/ titleLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP); this.addComponent(titleLinkLbl); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { this.addStyleName("editable-field"); Button instantEditBtn = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (isRead) { ToggleTaskSummaryField.this.removeComponent(titleLinkLbl); ToggleTaskSummaryField.this.removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(task.getTaskname()); editField.setWidth("100%"); editField.focus(); ToggleTaskSummaryField.this.addComponent(editField); ToggleTaskSummaryField.this.removeStyleName("editable-field"); editField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { updateFieldValue(editField); } }); editField.addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent event) { updateFieldValue(editField); } }); isRead = !isRead; } } }); instantEditBtn.setDescription("Edit task name"); instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ONLY); instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setIcon(FontAwesome.EDIT); buttonControls.with(instantEditBtn); this.addComponent(buttonControls); } }
From source file:com.esofthead.mycollab.module.project.view.task.TaskEditFormFieldFactory.java
License:Open Source License
@Override protected Field<?> onCreateField(final Object propertyId) { if (Task.Field.assignuser.equalTo(propertyId)) { ProjectMemberSelectionField field = new ProjectMemberSelectionField(); field.addValueChangeListener(new Property.ValueChangeListener() { @Override/* w ww . j ava 2s . c o m*/ public void valueChange(Property.ValueChangeEvent valueChangeEvent) { Property property = valueChangeEvent.getProperty(); SimpleProjectMember member = (SimpleProjectMember) property.getValue(); if (member != null) { subscribersComp.addFollower(member.getUsername()); } } }); return field; } else if (Task.Field.milestoneid.equalTo(propertyId)) { return new MilestoneComboBox(); } else if (Task.Field.notes.equalTo(propertyId)) { final RichTextArea richTextArea = new RichTextArea(); richTextArea.setNullRepresentation(""); return richTextArea; } else if (Task.Field.taskname.equalTo(propertyId)) { final TextField tf = new TextField(); tf.setNullRepresentation(""); tf.setRequired(true); tf.setRequiredError(AppContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, "Name")); return tf; } else if (Task.Field.status.equalTo(propertyId)) { return new TaskStatusComboBox(); } else if (Task.Field.percentagecomplete.equalTo(propertyId)) { return new TaskSliderField(); } else if (Task.Field.priority.equalTo(propertyId)) { return new TaskPriorityComboBox(); } else if (Task.Field.duration.equalTo(propertyId)) { final TextField field = new TextField(); field.setConverter(new HumanTimeConverter()); final SimpleTask beanItem = attachForm.getBean(); if (beanItem.getNumSubTasks() != null && beanItem.getNumSubTasks() > 0) { field.setEnabled(false); field.setDescription("Because this row has sub-tasks, this cell " + "is a summary value and can not be edited directly. You can edit cells " + "beneath this row to change its value"); } //calculate the end date if the start date is set field.addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent event) { HumanTime humanTime = HumanTime.eval(field.getValue()); Integer duration = Integer.valueOf(humanTime.getDelta() + ""); DateTimeOptionField startDateField = (DateTimeOptionField) fieldGroup .getField(Task.Field.startdate.name()); Date startDateVal = startDateField.getValue(); if (duration > 0 && startDateVal != null) { int durationIndays = duration / (int) DateTimeUtils.MILLISECONDS_IN_A_DAY; if (durationIndays > 0) { LocalDate startDateJoda = new LocalDate(startDateVal); LocalDate endDateJoda = BusinessDayTimeUtils.plusDays(startDateJoda, durationIndays); DateTimeOptionField endDateField = (DateTimeOptionField) fieldGroup .getField(Task.Field.enddate.name()); endDateField.setValue(endDateJoda.toDate()); } } } }); return field; } else if (Task.Field.originalestimate.equalTo(propertyId) || Task.Field.remainestimate.equalTo(propertyId)) { return new DoubleField(); } else if (Task.Field.startdate.equalTo(propertyId)) { final DateTimeOptionField startDateField = new DateTimeOptionField(true); startDateField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { calculateDurationBaseOnStartAndEndDates(); } }); return startDateField; } else if (Task.Field.enddate.equalTo(propertyId)) { DateTimeOptionField endDateField = new DateTimeOptionField(true); endDateField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { calculateDurationBaseOnStartAndEndDates(); } }); return endDateField; } else if (Task.Field.id.equalTo(propertyId)) { attachmentUploadField = new AttachmentUploadField(); Task beanItem = attachForm.getBean(); if (beanItem.getId() != null) { String attachmentPath = AttachmentUtils.getProjectEntityAttachmentPath(AppContext.getAccountId(), beanItem.getProjectid(), ProjectTypeConstants.TASK, "" + beanItem.getId()); attachmentUploadField.getAttachments(attachmentPath); } return attachmentUploadField; } else if (Task.Field.deadline.equalTo(propertyId)) { return new DateTimeOptionField(true); } else if (propertyId.equals("selected")) { return subscribersComp; } return null; }
From source file:com.esofthead.mycollab.module.project.view.task.TaskGroupDisplayViewImpl.java
License:Open Source License
private VerticalLayout createSearchPanel() { MVerticalLayout basicSearchBody = new MVerticalLayout() .withMargin(new MarginInfo(true, false, true, false)); basicSearchBody.addStyleName(UIConstants.BORDER_BOX_2); nameField = new TextField(); nameField.setWidth(UIConstants.DEFAULT_CONTROL_WIDTH); basicSearchBody.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER); MHorizontalLayout control = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false)); final Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH)); searchBtn.setIcon(FontAwesome.SEARCH); searchBtn.setStyleName(UIConstants.THEME_GREEN_LINK); searchBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override/*from ww w . j a va 2 s.c o m*/ public void buttonClick(final ClickEvent event) { TaskSearchCriteria searchCriteria = new TaskSearchCriteria(); searchCriteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId())); searchCriteria.setTaskName(new StringSearchField(nameField.getValue().trim())); TaskFilterParameter taskFilter = new TaskFilterParameter(searchCriteria, "Task Search"); moveToTaskSearch(taskFilter); } }); control.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_CENTER); final Button advancedSearchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { TaskSearchCriteria searchCriteria = new TaskSearchCriteria(); searchCriteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId())); searchCriteria.setTaskName(new StringSearchField(nameField.getValue().trim())); TaskFilterParameter taskFilter = new TaskFilterParameter(searchCriteria, "Task Search"); taskFilter.setAdvanceSearch(true); moveToTaskSearch(taskFilter); } }); advancedSearchBtn.setStyleName(UIConstants.THEME_BLUE_LINK); control.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER); basicSearchBody.with(control).withAlign(control, Alignment.MIDDLE_CENTER); return basicSearchBody; }
From source file:com.esofthead.mycollab.shell.view.SetupNewInstanceView.java
License:Open Source License
public SetupNewInstanceView() { this.setDefaultComponentAlignment(Alignment.TOP_CENTER); MVerticalLayout content = new MVerticalLayout().withWidth("600px"); this.with(content); content.with(ELabel.h2("Last step, you are almost there!").withWidthUndefined()); content.with(ELabel.h3("All fields are required *").withStyleName("overdue").withWidthUndefined()); content.with(/*from www. j a v a 2 s.c o m*/ new ELabel(AppContext.getMessage(ShellI18nEnum.OPT_SUPPORTED_LANGUAGES_INTRO), ContentMode.HTML) .withStyleName(UIConstants.META_COLOR)); GridFormLayoutHelper formLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(2, 8, "200px"); formLayoutHelper.getLayout().setWidth("600px"); final TextField adminField = formLayoutHelper.addComponent(new TextField(), "Admin email", 0, 0); final PasswordField passwordField = formLayoutHelper.addComponent(new PasswordField(), "Admin password", 0, 1); final PasswordField retypePasswordField = formLayoutHelper.addComponent(new PasswordField(), "Retype Admin password", 0, 2); final DateFormatField dateFormatField = formLayoutHelper.addComponent( new DateFormatField(SimpleBillingAccount.DEFAULT_DATE_FORMAT), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_YYMMDD_FORMAT), AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 3); final DateFormatField shortDateFormatField = formLayoutHelper.addComponent( new DateFormatField(SimpleBillingAccount.DEFAULT_SHORT_DATE_FORMAT), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_MMDD_FORMAT), AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 4); final DateFormatField longDateFormatField = formLayoutHelper.addComponent( new DateFormatField(SimpleBillingAccount.DEFAULT_LONG_DATE_FORMAT), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_HUMAN_DATE_FORMAT), AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 5); final TimeZoneSelectionField timeZoneSelectionField = formLayoutHelper.addComponent( new TimeZoneSelectionField(false), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_TIMEZONE), 0, 6); timeZoneSelectionField.setValue(TimeZone.getDefault().getID()); final LanguageSelectionField languageBox = formLayoutHelper.addComponent(new LanguageSelectionField(), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_LANGUAGE), 0, 7); languageBox.setValue(Locale.US.toLanguageTag()); content.with(formLayoutHelper.getLayout()); Button installBtn = new Button("Setup", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { String adminName = adminField.getValue(); String password = passwordField.getValue(); String retypePassword = retypePasswordField.getValue(); if (!StringUtils.isValidEmail(adminName)) { NotificationUtil.showErrorNotification("Invalid email value"); return; } if (!password.equals(retypePassword)) { NotificationUtil.showErrorNotification("Password is not match"); return; } String dateFormat = dateFormatField.getValue(); String shortDateFormat = shortDateFormatField.getValue(); String longDateFormat = longDateFormatField.getValue(); if (!isValidDayPattern(dateFormat) || !isValidDayPattern(shortDateFormat) || !isValidDayPattern(longDateFormat)) { NotificationUtil.showErrorNotification("Invalid date format"); return; } String language = languageBox.getValue(); String timezoneDbId = timeZoneSelectionField.getValue(); BillingAccountMapper billingAccountMapper = AppContextUtil .getSpringBean(BillingAccountMapper.class); BillingAccountExample ex = new BillingAccountExample(); ex.createCriteria().andIdEqualTo(AppContext.getAccountId()); List<BillingAccount> billingAccounts = billingAccountMapper.selectByExample(ex); BillingAccount billingAccount = billingAccounts.get(0); billingAccount.setDefaultlanguagetag(language); billingAccount.setDefaultyymmddformat(dateFormat); billingAccount.setDefaultmmddformat(shortDateFormat); billingAccount.setDefaulthumandateformat(longDateFormat); billingAccount.setDefaulttimezone(timezoneDbId); billingAccountMapper.updateByPrimaryKey(billingAccount); BillingAccountService billingAccountService = AppContextUtil .getSpringBean(BillingAccountService.class); billingAccountService.createDefaultAccountData(adminName, password, timezoneDbId, language, true, true, AppContext.getAccountId()); ((DesktopApplication) UI.getCurrent()).doLogin(adminName, password, false); } }); installBtn.addStyleName(UIConstants.BUTTON_ACTION); content.with(installBtn).withAlign(installBtn, Alignment.TOP_RIGHT); }
From source file:com.esofthead.mycollab.vaadin.ui.BuildCriterionComponent.java
License:Open Source License
private void buildSaveFilterBox() { filterBox.removeAllComponents();/*from w w w . j a v a2 s. c o m*/ final TextField queryTextField = new TextField(); queryTextField.setWidth("125px"); filterBox.addComponent(queryTextField); Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { String queryText = queryTextField.getValue(); saveSearchCriteria(queryText); } }); saveBtn.setStyleName(UIConstants.THEME_GREEN_LINK); saveBtn.setIcon(FontAwesome.SAVE); filterBox.addComponent(saveBtn); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { buildFilterBox(null); } }); cancelBtn.addStyleName(UIConstants.THEME_GRAY_LINK); filterBox.addComponent(cancelBtn); }