List of usage examples for com.vaadin.ui TextField TextField
public TextField()
TextField
with no caption. From source file:com.mycollab.module.crm.view.opportunity.OpportunitySimpleSearchPanel.java
License:Open Source License
private void addTextFieldSearch() { textValueField = new TextField(); textValueField.addShortcutListener(//from w w w. j a v a 2s . c o m new ShortcutListener("OpportunitySearchField", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object o, Object o1) { doSearch(); } }); searchPanel.addComponent(textValueField, 0, 0); searchPanel.setComponentAlignment(textValueField, Alignment.MIDDLE_CENTER); }
From source file:com.mycollab.module.project.view.bug.BugEditFormFieldFactory.java
License:Open Source License
@Override protected Field<?> onCreateField(final Object propertyId) { final SimpleBug beanItem = attachForm.getBean(); if (propertyId.equals("environment")) { return new RichTextArea(); } else if (propertyId.equals("description")) { return new RichTextArea(); } else if (propertyId.equals("priority")) { return new PriorityComboBox(); } else if (propertyId.equals("assignuser")) { ProjectMemberSelectionField field = new ProjectMemberSelectionField(); field.addValueChangeListener(valueChangeEvent -> { Property property = valueChangeEvent.getProperty(); SimpleProjectMember member = (SimpleProjectMember) property.getValue(); if (member != null) { subscribersComp.addFollower(member.getUsername()); }/*w ww . j av a 2 s . co m*/ }); return field; } else if (propertyId.equals("id")) { if (beanItem.getId() != null) { String attachmentPath = AttachmentUtils.getProjectEntityAttachmentPath(MyCollabUI.getAccountId(), beanItem.getProjectid(), ProjectTypeConstants.BUG, "" + beanItem.getId()); attachmentUploadField = new AttachmentUploadField(attachmentPath); } else { attachmentUploadField = new AttachmentUploadField(); } return attachmentUploadField; } else if (propertyId.equals("severity")) { return new BugSeverityComboBox(); } else if (propertyId.equals("components")) { componentSelect = new ComponentMultiSelectField(); return componentSelect; } else if (propertyId.equals("affectedVersions")) { affectedVersionSelect = new VersionMultiSelectField(); return affectedVersionSelect; } else if (propertyId.equals("fixedVersions")) { fixedVersionSelect = new VersionMultiSelectField(); return fixedVersionSelect; } else if (propertyId.equals("name")) { final TextField tf = new TextField(); if (isValidateForm) { tf.setNullRepresentation(""); tf.setRequired(true); tf.setRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext.getMessage(BugI18nEnum.FORM_SUMMARY))); } return tf; } else if (propertyId.equals("milestoneid")) { final MilestoneComboBox milestoneBox = new MilestoneComboBox(); milestoneBox.addValueChangeListener(valueChangeEvent -> { String milestoneName = milestoneBox.getItemCaption(milestoneBox.getValue()); beanItem.setMilestoneName(milestoneName); }); return milestoneBox; } else if (BugWithBLOBs.Field.originalestimate.equalTo(propertyId) || (BugWithBLOBs.Field.remainestimate.equalTo(propertyId))) { return new DoubleField(); } else if (propertyId.equals("selected")) { return subscribersComp; } else if (BugWithBLOBs.Field.startdate.equalTo(propertyId) || BugWithBLOBs.Field.enddate.equalTo(propertyId) || BugWithBLOBs.Field.duedate.equalTo(propertyId)) { return new DateTimeOptionField(true); } return null; }
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 .j a va2 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 www. j a va2 s . com 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); } }
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);//w w w.j ava 2s.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.milestone.MilestoneEditFormFieldFactory.java
License:Open Source License
@Override protected Field<?> onCreateField(Object propertyId) { if (Milestone.Field.assignuser.equalTo(propertyId)) { ProjectMemberSelectionField memberSelectionField = new ProjectMemberSelectionField(); memberSelectionField.setRequired(true); memberSelectionField.setRequiredError("Please select an assignee"); return memberSelectionField; } else if (propertyId.equals("status")) { return new ProgressStatusComboBox(); } else if (propertyId.equals("name")) { final TextField tf = new TextField(); if (isValidateForm) { tf.setNullRepresentation(""); tf.setRequired(true);// ww w . jav a 2 s .c o m tf.setRequiredError("Please enter name"); } return tf; } else if (propertyId.equals("description")) { RichTextArea descArea = new RichTextArea(); descArea.setNullRepresentation(""); return descArea; } else if (Milestone.Field.saccountid.equalTo(propertyId)) { Milestone beanItem = attachForm.getBean(); if (beanItem.getId() != null) { String attachmentPath = AttachmentUtils.getProjectEntityAttachmentPath(MyCollabUI.getAccountId(), beanItem.getProjectid(), ProjectTypeConstants.MILESTONE, "" + beanItem.getId()); attachmentUploadField = new AttachmentUploadField(attachmentPath); } else { attachmentUploadField = new AttachmentUploadField(); } return attachmentUploadField; } return null; }
From source file:com.mycollab.module.project.view.milestone.ToggleGenericTaskSummaryField.java
License:Open Source License
ToggleGenericTaskSummaryField(final ProjectGenericTask genericTask) { this.genericTask = genericTask; this.setWidth("100%"); titleLinkLbl = ELabel.html(buildGenericTaskLink()) .withStyleName(ValoTheme.LABEL_NO_MARGIN, UIConstants.LABEL_WORD_WRAP).withWidthUndefined(); this.addComponent(titleLinkLbl); if ((genericTask.isTask() && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) || (genericTask.isBug() && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) || (genericTask.isRisk()//from w w w.j av a 2 s . co m && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.RISKS))) { this.addStyleName("editable-field"); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); Button instantEditBtn = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (isRead) { removeComponent(titleLinkLbl); removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(genericTask.getName()); editField.setWidth("100%"); editField.focus(); addComponent(editField); 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.mycollab.module.project.view.milestone.ToggleMilestoneSummaryField.java
License:Open Source License
ToggleMilestoneSummaryField(final SimpleMilestone milestone, int maxLength, boolean toggleStatusSupport, boolean isDeleteSupport) { this.milestone = milestone; this.maxLength = maxLength; this.setWidth("100%"); this.addStyleName("editable-field"); if (toggleStatusSupport && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) { toggleStatusSelect = new CssCheckBox(); toggleStatusSelect.setSimpleMode(true); toggleStatusSelect.setValue(milestone.isCompleted()); this.addComponent(toggleStatusSelect); this.addComponent(ELabel.EMPTY_SPACE()); displayTooltip();/*from ww w . j a va 2s .c o m*/ toggleStatusSelect.addValueChangeListener(valueChangeEvent -> { if (milestone.isCompleted()) { milestone.setStatus(MilestoneStatus.InProgress.name()); titleLinkLbl.removeStyleName(WebThemes.LINK_COMPLETED); } else { milestone.setStatus(MilestoneStatus.Closed.name()); titleLinkLbl.addStyleName(WebThemes.LINK_COMPLETED); } displayTooltip(); MilestoneService milestoneService = AppContextUtil.getSpringBean(MilestoneService.class); milestoneService.updateSelectiveWithSession(milestone, UserUIContext.getUsername()); ProjectTicketSearchCriteria searchCriteria = new ProjectTicketSearchCriteria(); searchCriteria.setProjectIds(new SetSearchField<>(CurrentProjectVariables.getProjectId())); searchCriteria.setTypes(new SetSearchField<>(ProjectTypeConstants.BUG, ProjectTypeConstants.RISK, ProjectTypeConstants.TASK)); searchCriteria.setMilestoneId(NumberSearchField.equal(milestone.getId())); searchCriteria.setIsOpenned(new SearchField()); ProjectTicketService genericTaskService = AppContextUtil.getSpringBean(ProjectTicketService.class); int openAssignmentsCount = genericTaskService.getTotalCount(searchCriteria); if (openAssignmentsCount > 0) { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.OPT_QUESTION, MyCollabUI.getSiteName()), UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_CLOSE_SUB_ASSIGNMENTS), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { genericTaskService.closeSubAssignmentOfMilestone(milestone.getId()); } }); } }); } titleLinkLbl = ELabel.h3(buildMilestoneLink()).withStyleName(UIConstants.LABEL_WORD_WRAP) .withWidthUndefined(); this.addComponent(titleLinkLbl); buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true)) .withStyleName("toggle"); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) { MButton instantEditBtn = new MButton("", clickEvent -> { if (isRead) { ToggleMilestoneSummaryField.this.removeComponent(titleLinkLbl); ToggleMilestoneSummaryField.this.removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(milestone.getName()); editField.setWidth("100%"); editField.focus(); ToggleMilestoneSummaryField.this.addComponent(editField); ToggleMilestoneSummaryField.this.removeStyleName("editable-field"); editField.addValueChangeListener(valueChangeEvent -> updateFieldValue(editField)); editField.addBlurListener(blurEvent -> updateFieldValue(editField)); isRead = !isRead; } }).withDescription(UserUIContext.getMessage(MilestoneI18nEnum.OPT_EDIT_PHASE_NAME)) .withIcon(FontAwesome.EDIT).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); buttonControls.with(instantEditBtn); } if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MILESTONES)) { MButton removeBtn = new MButton("", clickEvent -> { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { AppContextUtil.getSpringBean(MilestoneService.class).removeWithSession(milestone, UserUIContext.getUsername(), MyCollabUI.getAccountId()); BlockRowRender rowRenderer = UIUtils.getRoot(ToggleMilestoneSummaryField.this, BlockRowRender.class); if (rowRenderer != null) { rowRenderer.selfRemoved(); } EventBusFactory.getInstance() .post(new MilestoneEvent.MilestoneDeleted(this, milestone.getId())); } }); }).withIcon(FontAwesome.TRASH).withStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); buttonControls.with(removeBtn); } if (buttonControls.getComponentCount() > 0) { this.addComponent(buttonControls); } }
From source file:com.mycollab.module.project.view.milestone.ToggleTicketSummaryField.java
License:Open Source License
public ToggleTicketSummaryField(final ProjectTicket ticket) { this.ticket = ticket; this.setWidth("100%"); titleLinkLbl = ELabel.html(buildTicketLink()) .withStyleName(ValoTheme.LABEL_NO_MARGIN, UIConstants.LABEL_WORD_WRAP).withWidthUndefined(); if (ticket.isClosed()) { titleLinkLbl.addStyleName(WebUIConstants.LINK_COMPLETED); } else if (ticket.isOverdue()) { titleLinkLbl.addStyleName(WebUIConstants.LINK_OVERDUE); }/* w ww . j a v a2 s. c o m*/ this.addComponent(titleLinkLbl); if (CurrentProjectVariables.canWriteTicket(ticket)) { this.addStyleName("editable-field"); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); MButton instantEditBtn = new MButton("", clickEvent -> { if (isRead) { removeComponent(titleLinkLbl); removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(ticket.getName()); editField.setWidth("100%"); editField.focus(); addComponent(editField); 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(UserUIContext.getMessage(GenericI18Enum.ACTION_CLICK_TO_EDIT)); buttonControls.with(instantEditBtn); this.addComponent(buttonControls); } }
From source file:com.mycollab.module.project.view.page.PageEditFormFieldFactory.java
License:Open Source License
@Override protected Field<?> onCreateField(Object propertyId) { Page page = attachForm.getBean();/*from w ww. j a v a 2 s. c o m*/ 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 = MyCollabUI.getSiteUrl(); String params = String.format("path=%s&createdUser=%s&sAccountId=%d", page.getPath(), UserUIContext.getUsername(), MyCollabUI.getAccountId()); if (appUrl.endsWith("/")) { config.setFilebrowserUploadUrl(String.format("%spage/upload?%s", appUrl, params)); } else { config.setFilebrowserUploadUrl(String.format("%s/page/upload?%s", appUrl, params)); } 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(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext.getMessage(PageI18nEnum.FORM_SUBJECT))); return subjectField; } return null; }