List of usage examples for com.vaadin.ui TextField TextField
public TextField()
TextField
with no caption. From source file:com.esofthead.mycollab.module.crm.view.opportunity.OpportunityEditFormFieldFactory.java
License:Open Source License
@Override protected Field<?> onCreateField(Object propertyId) { if (propertyId.equals("campaignid")) { return new CampaignSelectionField(); } else if (propertyId.equals("accountid")) { AccountSelectionField accountField = new AccountSelectionField(); accountField.setRequired(true);//ww w. ja v a2 s. c o m return accountField; } else if (propertyId.equals("opportunityname")) { TextField tf = new TextField(); if (isValidateForm) { tf.setNullRepresentation(""); tf.setRequired(true); tf.setRequiredError("Name must not be null"); } return tf; } else if (propertyId.equals("currencyid")) { CurrencyComboBoxField currencyBox = new CurrencyComboBoxField(); return currencyBox; } else if (propertyId.equals("salesstage")) { return new OpportunitySalesStageComboBox(); } else if (propertyId.equals("opportunitytype")) { return new OpportunityTypeComboBox(); } else if (propertyId.equals("source")) { return new LeadSourceComboBox(); } else if (propertyId.equals("description")) { return new RichTextEditField(); } else if (propertyId.equals("assignuser")) { ActiveUserComboBox userBox = new ActiveUserComboBox(); return userBox; } return null; }
From source file:com.esofthead.mycollab.module.project.view.assignments.gantt.GanttTreeTable.java
License:Open Source License
public GanttTreeTable(final GanttExt gantt) { super();// w w w .j a va 2 s.c o m this.gantt = gantt; this.setWidth("800px"); this.setBuffered(true); beanContainer = gantt.getBeanContainer(); this.setContainerDataSource(beanContainer); this.setVisibleColumns("ganttIndex", "name", "startDate", "endDate", "duration", "percentageComplete", "predecessors", "assignUser"); this.setColumnHeader("ganttIndex", ""); this.setColumnWidth("ganttIndex", 25); this.setColumnHeader("name", "Task"); this.setColumnExpandRatio("name", 1.0f); this.setHierarchyColumn("name"); this.setColumnHeader("startDate", "Start"); this.setColumnWidth("startDate", 90); this.setColumnHeader("endDate", "End"); this.setColumnWidth("endDate", 90); this.setColumnHeader("duration", "Duration"); this.setColumnWidth("duration", 65); this.setColumnHeader("predecessors", "Predecessors"); this.setColumnWidth("predecessors", 100); this.setColumnHeader("percentageComplete", "% Complete"); this.setColumnWidth("percentageComplete", 75); this.setColumnHeader("assignUser", "Assignee"); this.setColumnWidth("assignUser", 80); this.setColumnCollapsingAllowed(true); this.setColumnCollapsed("assignUser", true); this.setEditable(true); this.setNullSelectionAllowed(false); this.addGeneratedColumn("ganttIndex", new ColumnGenerator() { @Override public Object generateCell(Table table, Object itemId, Object columnId) { GanttItemWrapper item = (GanttItemWrapper) itemId; return new ELabel("" + item.getGanttIndex()).withStyleName(ValoTheme.LABEL_SMALL); } }); this.setTableFieldFactory(new TableFieldFactory() { @Override public Field<?> createField(Container container, Object itemId, final Object propertyId, Component uiContext) { Field field = null; final GanttItemWrapper ganttItem = (GanttItemWrapper) itemId; if ("name".equals(propertyId)) { field = new AssignmentNameCellField(ganttItem.getType()); } else if ("percentageComplete".equals(propertyId)) { field = new TextField(); ((TextField) field).setNullRepresentation("0"); ((TextField) field).setImmediate(true); field.addStyleName(ValoTheme.TEXTFIELD_SMALL); if (ganttItem.hasSubTasks() || ganttItem.isMilestone()) { field.setEnabled(false); ((TextField) 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"); } } else if ("startDate".equals(propertyId) || "endDate".equals(propertyId)) { field = new DateField(); field.addStyleName(ValoTheme.DATEFIELD_SMALL); ((DateField) field).setConverter(new LocalDateConverter()); ((DateField) field).setImmediate(true); if (ganttItem.hasSubTasks()) { field.setEnabled(false); ((DateField) 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"); } } else if ("assignUser".equals(propertyId)) { field = new ProjectMemberSelectionField(); } else if ("predecessors".equals(propertyId)) { field = new DefaultViewField(""); ((DefaultViewField) field).setConverter(new PredecessorConverter()); return field; } else if ("duration".equals(propertyId)) { field = new TextField(); ((TextField) field).setConverter(new HumanTimeConverter()); field.addStyleName(ValoTheme.TEXTFIELD_SMALL); if (ganttItem.hasSubTasks()) { field.setEnabled(false); ((TextField) 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"); } } if (field != null) { field.setBuffered(true); field.setWidth("100%"); if (ganttItem.isMilestone()) { if (!CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) { field.setEnabled(false); ((AbstractComponent) field).setDescription( AppContext.getMessage(GenericI18Enum.NOTIFICATION_NO_PERMISSION_DO_TASK)); } } else if (ganttItem.isTask()) { if (!CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { field.setEnabled(false); ((AbstractComponent) field).setDescription( AppContext.getMessage(GenericI18Enum.NOTIFICATION_NO_PERMISSION_DO_TASK)); } } else if (ganttItem.isBug()) { if (!CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) { field.setEnabled(false); ((AbstractComponent) field).setDescription( AppContext.getMessage(GenericI18Enum.NOTIFICATION_NO_PERMISSION_DO_TASK)); } } else { throw new MyCollabException( "Do not support gantt item type " + ganttItem.getTask().getType()); } if (field instanceof FieldEvents.BlurNotifier) { ((FieldEvents.BlurNotifier) field).addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent event) { Object o = event.getSource(); if (o instanceof Field) { Field f = (Field) o; if (f.isModified()) { f.commit(); EventBusFactory.getInstance().post(new GanttEvent.AddGanttItemUpdateToQueue( GanttTreeTable.this, ganttItem)); GanttTreeTable.this.refreshRowCache(); } } } }); } } return field; } }); this.addExpandListener(new Tree.ExpandListener() { @Override public void nodeExpand(Tree.ExpandEvent expandEvent) { GanttItemWrapper item = (GanttItemWrapper) expandEvent.getItemId(); List<GanttItemWrapper> subTasks = item.subTasks(); insertSubSteps(item, subTasks); } }); this.addCollapseListener(new Tree.CollapseListener() { @Override public void nodeCollapse(Tree.CollapseEvent collapseEvent) { GanttItemWrapper item = (GanttItemWrapper) collapseEvent.getItemId(); List<GanttItemWrapper> subTasks = item.subTasks(); removeSubSteps(item, subTasks); } }); this.setCellStyleGenerator(new CellStyleGenerator() { @Override public String getStyle(Table source, Object itemId, Object propertyId) { GanttItemWrapper item = (GanttItemWrapper) itemId; if (item.isMilestone()) { return "root"; } else if (item.isTask()) { return ""; } return ""; } }); final GanttContextMenu contextMenu = new GanttContextMenu(); contextMenu.setAsContextMenuOf(this); contextMenu.setOpenAutomatically(false); ContextMenu.ContextMenuOpenedListener.TableListener tableListener = new ContextMenu.ContextMenuOpenedListener.TableListener() { public void onContextMenuOpenFromRow(ContextMenu.ContextMenuOpenedOnTableRowEvent event) { GanttItemWrapper item = (GanttItemWrapper) event.getItemId(); contextMenu.displayContextMenu(item); contextMenu.open(GanttTreeTable.this); } public void onContextMenuOpenFromHeader(ContextMenu.ContextMenuOpenedOnTableHeaderEvent event) { } public void onContextMenuOpenFromFooter(ContextMenu.ContextMenuOpenedOnTableFooterEvent event) { } }; contextMenu.addContextMenuTableListener(tableListener); gantt.setVerticalScrollDelegateTarget(this); this.setPageLength(currentPageLength); }
From source file:com.esofthead.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 BugPriorityComboBox(); } else if (propertyId.equals("assignuser")) { ProjectMemberSelectionField field = new ProjectMemberSelectionField(); field.addValueChangeListener(new Property.ValueChangeListener() { @Override/*from ww w . j a v a 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 (propertyId.equals("id")) { attachmentUploadField = new ProjectFormAttachmentUploadField(); if (beanItem.getId() != null) { attachmentUploadField.getAttachments(beanItem.getProjectid(), ProjectTypeConstants.BUG, beanItem.getId()); } 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("summary")) { final TextField tf = new TextField(); if (isValidateForm) { tf.setNullRepresentation(""); tf.setRequired(true); tf.setRequiredError("Summary must be not null"); } return tf; } else if (propertyId.equals("milestoneid")) { final MilestoneComboBox milestoneBox = new MilestoneComboBox(); milestoneBox.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(Property.ValueChangeEvent event) { String milestoneName = milestoneBox.getItemCaption(milestoneBox.getValue()); beanItem.setMilestoneName(milestoneName); } }); return milestoneBox; } else if (propertyId.equals("estimatetime") || (propertyId.equals("estimateremaintime"))) { 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.esofthead.mycollab.module.project.view.bug.BugRelatedField.java
License:Open Source License
public void displayRelatedBugs(final SimpleBug bug) { this.bug = bug; VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setWidth("100%"); mainLayout.setMargin(true);/*from w ww . ja va 2 s. co m*/ mainLayout.setSpacing(true); HorizontalLayout layoutAdd = new HorizontalLayout(); layoutAdd.setSpacing(true); Label lbBug = new Label("Bug:"); lbBug.setWidth("70px"); layoutAdd.addComponent(lbBug); layoutAdd.setComponentAlignment(lbBug, Alignment.MIDDLE_LEFT); itemField = new TextField(); itemField.setWidth("300px"); itemField.setNullRepresentation(""); itemField.setReadOnly(true); itemField.setEnabled(true); layoutAdd.addComponent(itemField); layoutAdd.setComponentAlignment(itemField, Alignment.MIDDLE_LEFT); browseBtn = new Button("", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { callItemSelectionWindow(); } }); browseBtn.setIcon(MyCollabResource.newResource(WebResourceIds._16_browseItem)); browseBtn.setStyleName("link"); layoutAdd.addComponent(browseBtn); layoutAdd.setComponentAlignment(browseBtn, Alignment.MIDDLE_LEFT); clearBtn = new Button("", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { setItemFieldValue(""); } }); clearBtn.setIcon(MyCollabResource.newResource("icons/16/clearItem.png")); clearBtn.setStyleName("link"); layoutAdd.addComponent(clearBtn); layoutAdd.setComponentAlignment(clearBtn, Alignment.MIDDLE_LEFT); Label lbIs = new Label("is"); layoutAdd.addComponent(lbIs); layoutAdd.setComponentAlignment(lbIs, Alignment.MIDDLE_LEFT); comboRelation = new BugRelationComboBox(); comboRelation.setWidth("200px"); layoutAdd.addComponent(comboRelation); layoutAdd.setComponentAlignment(comboRelation, Alignment.MIDDLE_LEFT); btnRelate = new Button("Relate"); btnRelate.setStyleName(UIConstants.THEME_GREEN_LINK); btnRelate.setIcon(MyCollabResource.newResource(WebResourceIds._16_addRecord)); ProjectMemberService memberService = ApplicationContextUtil.getSpringBean(ProjectMemberService.class); SimpleProjectMember member = memberService.findMemberByUsername(AppContext.getUsername(), CurrentProjectVariables.getProjectId(), AppContext.getAccountId()); if (member != null) { btnRelate.setEnabled((member.getIsadmin() || (AppContext.getUsername().equals(bug.getAssignuser())) || (AppContext.getUsername().equals(bug.getLogby()))) && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)); } btnRelate.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { if (!itemField.getValue().toString().trim().equals("") && relatedBean != null && !relatedBean.getSummary().equals(bug.getSummary())) { SimpleRelatedBug relatedBug = new SimpleRelatedBug(); relatedBug.setBugid(bug.getId()); relatedBug.setRelatedid(relatedBean.getId()); relatedBug.setRelatetype((String) comboRelation.getValue()); relatedBug.setComment(txtComment.getValue().toString()); relatedBugService.saveWithSession(relatedBug, AppContext.getUsername()); SimpleRelatedBug oppositeRelation = new SimpleRelatedBug(); oppositeRelation.setBugid(relatedBean.getId()); oppositeRelation.setRelatedid(bug.getId()); oppositeRelation.setComment(txtComment.getValue().toString()); if (comboRelation.getValue().toString().equals(BugRelationConstants.PARENT)) { oppositeRelation.setRelatetype(BugRelationConstants.CHILD); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.CHILD)) { oppositeRelation.setRelatetype(BugRelationConstants.PARENT); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.RELATED)) { oppositeRelation.setRelatetype(BugRelationConstants.RELATED); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.BEFORE)) { oppositeRelation.setRelatetype(BugRelationConstants.AFTER); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.AFTER)) { oppositeRelation.setRelatetype(BugRelationConstants.BEFORE); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.DUPLICATED)) { oppositeRelation.setRelatetype(BugRelationConstants.DUPLICATED); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bug.setStatus(BugStatus.Resolved.name()); bug.setResolution(BugResolution.Duplicate.name()); bugService.updateWithSession(bug, AppContext.getUsername()); } relatedBugService.saveWithSession(oppositeRelation, AppContext.getUsername()); setCriteria(); setItemFieldValue(""); txtComment.setValue(""); relatedBean = null; } } }); layoutAdd.addComponent(btnRelate); layoutAdd.setComponentAlignment(btnRelate, Alignment.MIDDLE_LEFT); Label lbInstruction = new Label("<strong>Relate to an existing ticket</strong>", ContentMode.HTML); mainLayout.addComponent(lbInstruction); mainLayout.addComponent(layoutAdd); HorizontalLayout layoutComment = new HorizontalLayout(); layoutComment.setSpacing(true); Label lbComment = new Label("Comment:"); lbComment.setWidth("70px"); layoutComment.addComponent(lbComment); layoutComment.setComponentAlignment(lbComment, Alignment.TOP_LEFT); txtComment = new RichTextArea(); txtComment.setHeight("130px"); txtComment.setWidth("565px"); layoutComment.addComponent(txtComment); layoutComment.setComponentAlignment(txtComment, Alignment.MIDDLE_LEFT); mainLayout.addComponent(layoutComment); tableItem = new DefaultPagedBeanTable<RelatedBugService, BugRelatedSearchCriteria, SimpleRelatedBug>( ApplicationContextUtil.getSpringBean(RelatedBugService.class), SimpleRelatedBug.class, Arrays.asList( new TableViewField(BugI18nEnum.RELATED_BUG_NAME, "bugName", UIConstants.TABLE_EX_LABEL_WIDTH), new TableViewField(BugI18nEnum.RELATED_BUG_TYPE, "relatetype", UIConstants.TABLE_S_LABEL_WIDTH), new TableViewField(BugI18nEnum.RELATED_BUG_COMMENT, "comment", UIConstants.TABLE_EX_LABEL_WIDTH), new TableViewField(null, "id", UIConstants.TABLE_CONTROL_WIDTH))); tableItem.addGeneratedColumn("bugName", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleRelatedBug relatedItem = tableItem.getBeanByIndex(itemId); String bugname = "[%s-%s] %s"; bugname = String.format(bugname, CurrentProjectVariables.getProject().getShortname(), relatedItem.getRelatedid(), relatedItem.getBugName()); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); final SimpleBug bug = bugService.findById(relatedItem.getRelatedid(), AppContext.getAccountId()); LabelLink b = new LabelLink(bugname, ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName())); if (StringUtils.isNotBlank(bug.getPriority())) { String iconPriority = ProjectResources.getIconResourceLink12ByBugPriority(bug.getPriority()); b.setIconLink(iconPriority); } if (BugStatus.Verified.name().equals(bug.getStatus())) { b.addStyleName(UIConstants.LINK_COMPLETED); } else if (bug.getDuedate() != null && (bug.getDuedate().before(new GregorianCalendar().getTime()))) { b.addStyleName(UIConstants.LINK_OVERDUE); } b.setWidth("100%"); return b; } }); tableItem.addGeneratedColumn("id", new ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { final SimpleRelatedBug relatedItem = tableItem.getBeanByIndex(itemId); Button deleteBtn = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { BugRelatedSearchCriteria relateBugIdCriteria = new BugRelatedSearchCriteria(); relateBugIdCriteria.setBugId(new NumberSearchField(relatedItem.getBugid())); relateBugIdCriteria.setRelatedId(new NumberSearchField(relatedItem.getRelatedid())); relatedBugService.removeByCriteria(relateBugIdCriteria, AppContext.getAccountId()); BugRelatedSearchCriteria relateIdCriteria = new BugRelatedSearchCriteria(); relateIdCriteria.setBugId(new NumberSearchField(relatedItem.getRelatedid())); relateIdCriteria.setRelatedId(new NumberSearchField(relatedItem.getBugid())); relatedBugService.removeByCriteria(relateIdCriteria, AppContext.getAccountId()); BugRelatedField.this.setCriteria(); } }); deleteBtn.setStyleName("link"); deleteBtn.setIcon(MyCollabResource.newResource("icons/16/delete.png")); relatedItem.setExtraData(deleteBtn); ProjectMemberService memberService = ApplicationContextUtil .getSpringBean(ProjectMemberService.class); SimpleProjectMember member = memberService.findMemberByUsername(AppContext.getUsername(), CurrentProjectVariables.getProjectId(), AppContext.getAccountId()); if (member != null) { deleteBtn.setEnabled( member.getIsadmin() || (AppContext.getUsername().equals(bug.getAssignuser())) || (AppContext.getUsername().equals(bug.getLogby()))); } return deleteBtn; } }); mainLayout.addComponent(tableItem); setCriteria(); this.setCompositionRoot(mainLayout); }
From source file:com.esofthead.mycollab.module.project.view.bug.BugSimpleSearchPanel.java
License:Open Source License
private void addTextFieldSearch() { textValueField = new TextField(); textValueField.setWidth("300px"); layoutSearchPane.addComponent(textValueField, 0, 0); layoutSearchPane.setComponentAlignment(textValueField, Alignment.MIDDLE_CENTER); }
From source file:com.esofthead.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();/*www .j ava 2 s . co m*/ this.addComponent(titleLinkLbl); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) { this.addStyleName("editable-field"); Button instantEditBtn = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent 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(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.kanban.AddNewColumnWindow.java
License:Open Source License
public AddNewColumnWindow(final IKanbanView kanbanView, final String type, final String fieldGroup) { super(AppContext.getMessage(TaskI18nEnum.ACTION_NEW_COLUMN)); this.setWidth("800px"); this.setModal(true); this.setResizable(false); this.center(); 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.setEnabled(AppContext.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, AppContext.getMessage(GenericI18Enum.FORM_NAME), 0, 0); gridFormLayoutHelper.addComponent(defaultProject, AppContext.getMessage(TaskI18nEnum.FORM_COLUMN_DEFAULT_FOR_NEW_PROJECT), 0, 1); gridFormLayoutHelper.addComponent(colorPicker, AppContext.getMessage(TaskI18nEnum.FORM_COLUMN_COLOR), 0, 2); gridFormLayoutHelper.addComponent(description, AppContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0, 3);//from w w w .j av a 2s .c o m Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { OptionVal optionVal = new OptionVal(); optionVal.setCreatedtime(new GregorianCalendar().getTime()); optionVal.setCreateduser(AppContext.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(AppContext.getAccountId()); optionVal.setType(type); optionVal.setTypeval(stageField.getValue()); optionVal.setFieldgroup(fieldGroup); OptionValService optionService = AppContextUtil.getSpringBean(OptionValService.class); int optionValId = optionService.saveWithSession(optionVal, AppContext.getUsername()); if (optionVal.getIsdefault()) { optionVal.setId(null); optionVal.setIsdefault(false); optionVal.setRefoption(optionValId); optionVal.setExtraid(CurrentProjectVariables.getProjectId()); optionService.saveWithSession(optionVal, AppContext.getUsername()); } kanbanView.addColumn(optionVal); close(); } }); saveBtn.setIcon(FontAwesome.SAVE); saveBtn.setStyleName(UIConstants.BUTTON_ACTION); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { close(); } }); cancelBtn.setStyleName(UIConstants.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.esofthead.mycollab.module.project.view.milestone.MilestoneEditFormFieldFactory.java
License:Open Source License
@Override protected Field<?> onCreateField(Object propertyId) { if (propertyId.equals("owner")) { final ProjectMemberSelectionField userbox = new ProjectMemberSelectionField(); userbox.setRequired(true);/*from ww w . ja v a 2 s. c o m*/ userbox.setRequiredError("Please select an assignee"); return userbox; } else if (propertyId.equals("status")) { if (attachForm.getBean().getStatus() == null) { attachForm.getBean().setStatus(MilestoneStatus.InProgress.toString()); } return new ProgressStatusComboBox(); } else if (propertyId.equals("name")) { final TextField tf = new TextField(); if (isValidateForm) { tf.setNullRepresentation(""); tf.setRequired(true); tf.setRequiredError("Please enter name"); } return tf; } else if (propertyId.equals("description")) { final RichTextArea descArea = new RichTextArea(); descArea.setNullRepresentation(""); return descArea; } else if (propertyId.equals("numOpenTasks")) { final ContainerHorizontalViewField taskComp = new ContainerHorizontalViewField(); final int numOpenTask = (attachForm.getBean() instanceof SimpleMilestone) ? ((SimpleMilestone) attachForm.getBean()).getNumOpenTasks() : 0; final int numTasks = (attachForm.getBean() instanceof SimpleMilestone) ? ((SimpleMilestone) attachForm.getBean()).getNumTasks() : 0; final ProgressBarIndicator progressTask = new ProgressBarIndicator(numTasks, numOpenTask); progressTask.setWidth("100%"); taskComp.addComponentField(progressTask); return taskComp; } else if (propertyId.equals("numOpenBugs")) { final ContainerHorizontalViewField bugComp = new ContainerHorizontalViewField(); final int numOpenBugs = (attachForm.getBean() instanceof SimpleMilestone) ? ((SimpleMilestone) attachForm.getBean()).getNumOpenBugs() : 0; final int numBugs = (attachForm.getBean() instanceof SimpleMilestone) ? ((SimpleMilestone) attachForm.getBean()).getNumBugs() : 0; final ProgressBarIndicator progressBug = new ProgressBarIndicator(numBugs, numOpenBugs); progressBug.setWidth("100%"); bugComp.addComponentField(progressBug); return bugComp; } return null; }
From source file:com.esofthead.mycollab.module.project.view.milestone.ToggleGenericTaskSummaryField.java
License:Open Source License
ToggleGenericTaskSummaryField(final ProjectGenericTask genericTask) { this.genericTask = genericTask; this.setWidth("100%"); titleLinkLbl = new ELabel(buildGenericTaskLink(), ContentMode.HTML).withWidthUndefined(); titleLinkLbl.addStyleName(ValoTheme.LABEL_NO_MARGIN); titleLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP); this.addComponent(titleLinkLbl); if ((genericTask.isTask() && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) || (genericTask.isBug() && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) || (genericTask.isRisk()//w w w . j a va2 s . c o 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.esofthead.mycollab.module.project.view.milestone.ToggleMilestoneSummaryField.java
License:Open Source License
ToggleMilestoneSummaryField(final SimpleMilestone milestone, int maxLength) { this.milestone = milestone; this.maxLength = maxLength; this.setWidth("100%"); titleLinkLbl = new ELabel(buildMilestoneLink(), ContentMode.HTML).withStyleName(ValoTheme.LABEL_H3) .withWidthUndefined();//from w ww . j a v a 2s . c om titleLinkLbl.addStyleName(ValoTheme.LABEL_NO_MARGIN); titleLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP); this.addComponent(titleLinkLbl); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) { this.addStyleName("editable-field"); Button instantEditBtn = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent 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(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); } }