List of usage examples for com.vaadin.v7.ui TextArea setRows
public void setRows(int rows)
From source file:de.symeda.sormas.ui.task.TaskEditForm.java
License:Open Source License
@Override protected void addFields() { addField(TaskDto.CAZE, ComboBox.class); addField(TaskDto.EVENT, ComboBox.class); addField(TaskDto.CONTACT, ComboBox.class); DateTimeField startDate = addDateField(TaskDto.SUGGESTED_START, DateTimeField.class, -1); DateTimeField dueDate = addDateField(TaskDto.DUE_DATE, DateTimeField.class, -1); dueDate.setImmediate(true);/*from w w w . j a v a 2s . co m*/ addField(TaskDto.PRIORITY, ComboBox.class); OptionGroup taskStatus = addField(TaskDto.TASK_STATUS, OptionGroup.class); OptionGroup taskContext = addField(TaskDto.TASK_CONTEXT, OptionGroup.class); taskContext.setImmediate(true); taskContext.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { updateByTaskContext(); } }); ComboBox taskTypeField = addField(TaskDto.TASK_TYPE, ComboBox.class); taskTypeField.setItemCaptionMode(ItemCaptionMode.ID_TOSTRING); taskTypeField.setImmediate(true); taskTypeField.addValueChangeListener(e -> { TaskType taskType = (TaskType) e.getProperty().getValue(); if (taskType != null) { setRequired(taskType.isCreatorCommentRequired(), TaskDto.CREATOR_COMMENT); } }); ComboBox assigneeUser = addField(TaskDto.ASSIGNEE_USER, ComboBox.class); assigneeUser.addValueChangeListener(e -> updateByCreatingAndAssignee()); assigneeUser.setImmediate(true); TextArea creatorComment = addField(TaskDto.CREATOR_COMMENT, TextArea.class); creatorComment.setRows(2); creatorComment.setImmediate(true); addField(TaskDto.ASSIGNEE_REPLY, TextArea.class).setRows(2); setRequired(true, TaskDto.TASK_CONTEXT, TaskDto.TASK_TYPE, TaskDto.ASSIGNEE_USER, TaskDto.DUE_DATE); setReadOnly(true, TaskDto.TASK_CONTEXT, TaskDto.CAZE, TaskDto.CONTACT, TaskDto.EVENT); addValueChangeListener(e -> { TaskDto taskDto = getValue(); if (taskDto.getTaskType() == TaskType.CASE_INVESTIGATION && taskDto.getCaze() != null) { taskStatus.addValidator(new TaskStatusValidator(taskDto.getCaze().getUuid(), I18nProperties.getValidationError(Validations.investigationStatusUnclassifiedCase))); } DistrictReferenceDto district = null; RegionReferenceDto region = null; if (taskDto.getCaze() != null) { CaseDataDto caseDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(taskDto.getCaze().getUuid()); district = caseDto.getDistrict(); region = caseDto.getRegion(); } else if (taskDto.getContact() != null) { ContactDto contactDto = FacadeProvider.getContactFacade() .getContactByUuid(taskDto.getContact().getUuid()); CaseDataDto caseDto = FacadeProvider.getCaseFacade() .getCaseDataByUuid(contactDto.getCaze().getUuid()); district = caseDto.getDistrict(); region = caseDto.getRegion(); } else if (taskDto.getEvent() != null) { EventDto eventDto = FacadeProvider.getEventFacade().getEventByUuid(taskDto.getEvent().getUuid()); district = eventDto.getEventLocation().getDistrict(); region = eventDto.getEventLocation().getRegion(); } else { UserDto userDto = UserProvider.getCurrent().getUser(); district = userDto.getDistrict(); region = userDto.getRegion(); } List<UserReferenceDto> users = new ArrayList<>(); if (district != null) { users = FacadeProvider.getUserFacade().getUserRefsByDistrict(district, true); } else if (region != null) { users = FacadeProvider.getUserFacade().getUsersByRegionAndRoles(region); } else { // fallback - just show all users users = FacadeProvider.getUserFacade().getAllAfterAsReference(null); } // Validation startDate.addValidator(new DateComparisonValidator(startDate, dueDate, true, false, I18nProperties .getValidationError(Validations.beforeDate, startDate.getCaption(), dueDate.getCaption()))); dueDate.addValidator(new DateComparisonValidator(dueDate, startDate, false, false, I18nProperties .getValidationError(Validations.afterDate, dueDate.getCaption(), startDate.getCaption()))); TaskController taskController = ControllerProvider.getTaskController(); for (UserReferenceDto user : users) { assigneeUser.addItem(user); assigneeUser.setItemCaption(user, taskController.getUserCaptionWithPendingTaskCount(user)); } }); }