/** Colore les champs en rouge si erreur * @param validate */ @SuppressWarnings("unchecked") private void validateFields(Boolean validate){ listLayoutTraductions.forEach(e -> { AbstractField<String> tf; if (e.getComponent(0) instanceof TextField || e.getComponent(0) instanceof RichTextArea){ tf = (AbstractField<String>) e.getComponent(0); }else if (e.getComponent(0) instanceof HorizontalLayout){ tf = (AbstractField<String>) e.getComponent(1); }else{ tf = (AbstractField<String>) e.getComponent(1); } /* Ajout du style*/ if (validate){ tf.removeStyleName(StyleConstants.FIELD_ERROR_COMPLETE); }else{ tf.addStyleName(StyleConstants.FIELD_ERROR_COMPLETE); } }); }
@Override protected Field<?> onCreateField(final Object propertyId) { if (Component.Field.name.equalTo(propertyId)) { final TextField tf = new TextField(); if (isValidateForm) { tf.setNullRepresentation(""); tf.setRequired(true); tf.setRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext.getMessage(GenericI18Enum.FORM_NAME))); } return tf; } else if (Component.Field.description.equalTo(propertyId)) { return new RichTextArea(); } else if (Component.Field.userlead.equalTo(propertyId)) { return new ProjectMemberSelectionField(); } return null; }
@Override protected Field<?> onCreateField(final Object propertyId) { if (Version.Field.name.equalTo(propertyId)) { final TextField tf = new TextField(); if (isValidateForm) { tf.setNullRepresentation(""); tf.setRequired(true); tf.setRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext .getMessage(GenericI18Enum.FORM_NAME))); } 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; }
public HelpView() { final RichTextArea rtarea = new RichTextArea(); rtarea.setCaption("VFSFileExplorerPortlet"); rtarea.setValue("<h1>Configuration Example</h1>\n" + "<h2>File access</h2>\n" + "windows : file:///C:/Temp\n" + "unix: file:///home/someuser/somedir\n" + "\n" + "<h2>FTP access</h2>\n" + "ftp://hostname[: port]\n " + "plus username and password\n" + "\n" + "<h2>SFTP access</h2>\n" + "sftp://hostname[: port][ absolute-path]\n " + "plus username and password \n" + "and / or\n " + "path to keyfile like /home/user/keyfile/id_rsa "); rtarea.setReadOnly(true); addComponent(rtarea); }
private void initComponents(){ importTypeSelectField=new NativeSelect("Sequence format",theCanvas.getImportFormats()); importTypeSelectField.setNewItemsAllowed(false); importTypeSelectField.setNullSelectionAllowed(false); sequenceInputField=new RichTextArea(); sequenceInputField.setImmediate(true); sequenceInputField.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID=-6654910749910048984L; @Override public void valueChange(ValueChangeEvent event) { sequenceInputField.commit(); sequence=(String)event.getProperty().getValue(); } }); sequenceInputField.setHeight("90%"); sequenceInputField.setWidth("100%"); sequenceInputField.addStyleName("hide-richtext-toolbar"); ok=new NativeButton("Import"); }
@Override protected Component createContent() { FormLayout layout = new FormLayout(); text = new RichTextArea("Message"); text.setSizeFull(); layout.addComponent(text); layout.addComponent(getToolbar()); return layout; }
@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); 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(AppUI.getAccountId(), beanItem.getProjectid(), ProjectTypeConstants.MILESTONE, "" + beanItem.getId()); attachmentUploadField = new AttachmentUploadField(attachmentPath); } else { attachmentUploadField = new AttachmentUploadField(); } return attachmentUploadField; } return null; }
@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); return accountField; } else if (propertyId.equals("opportunityname")) { MTextField tf = new MTextField(); if (isValidateForm) { tf.withNullRepresentation("").withRequired(true) .withRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext.getMessage(GenericI18Enum.FORM_NAME))); } return tf; } else if (propertyId.equals("currencyid")) { return new CurrencyComboBoxField(); } 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 RichTextArea(); } else if (propertyId.equals("assignuser")) { return new ActiveUserComboBox(); } else if (Opportunity.Field.amount.equalTo(propertyId)) { return new DoubleField(); } else if (Opportunity.Field.probability.equalTo(propertyId)) { return new IntegerField(); } return null; }
@Override protected Field<?> onCreateField(Object propertyId) { if (propertyId.equals("firstname") || propertyId.equals("prefix")) { return firstNamePrefixField; } else if (propertyId.equals("leadsource")) { return new LeadSourceComboBox(); } else if (propertyId.equals("accountid")) { return new AccountSelectionField(); } else if (propertyId.equals("lastname")) { MTextField tf = new MTextField(); if (isValidateForm) { tf.withNullRepresentation("").withRequired(true) .withRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext.getMessage(GenericI18Enum.FORM_LASTNAME))); } return tf; } else if (propertyId.equals("description")) { return new RichTextArea(); } else if (propertyId.equals("assignuser")) { ActiveUserComboBox userBox = new ActiveUserComboBox(); userBox.select(attachForm.getBean().getAssignuser()); return userBox; } else if (propertyId.equals("primcountry") || propertyId.equals("othercountry")) { return new CountryComboBox(); } else if (propertyId.equals("birthday")) { return new DateSelectionField(); } return null; }
@Override protected Field<?> onCreateField(Object propertyId) { if (Account.Field.type.equalTo(propertyId)) { return new AccountTypeComboBox(); } else if (Account.Field.industry.equalTo(propertyId)) { return new IndustryComboBox(); } else if (Account.Field.assignuser.equalTo(propertyId)) { ActiveUserComboBox userBox = new ActiveUserComboBox(); userBox.select(attachForm.getBean().getAssignuser()); return userBox; } else if (Account.Field.description.equalTo(propertyId)) { return new RichTextArea(); } else if (Account.Field.billingcountry.equalTo(propertyId) || Account.Field.shippingcountry.equalTo(propertyId)) { return new CountryComboBox(); } else if (Account.Field.accountname.equalTo(propertyId)) { MTextField tf = new MTextField(); if (isValidateForm) { tf.withNullRepresentation("").withRequired(true) .withRequiredError(UserUIContext.getMessage(ErrorI18nEnum.ERROR_USER_IS_NOT_EXISTED, UserUIContext.getMessage(AccountI18nEnum.FORM_ACCOUNT_NAME))); } return tf; } return null; }
@Override protected Field<?> onCreateField(Object propertyId) { if ("type".equals(propertyId)) { return new CampaignTypeComboBox(); } else if ("status".equals(propertyId)) { return new CampaignStatusComboBox(); } else if ("campaignname".equals(propertyId)) { MTextField tf = new MTextField(); if (isValidateForm) { tf.withNullRepresentation("").withRequired(true) .withRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext.getMessage(GenericI18Enum.FORM_NAME))); } return tf; } else if ("description".equals(propertyId)) { return new RichTextArea(); } else if ("assignuser".equals(propertyId)) { return new ActiveUserComboBox(); } else if (propertyId.equals("currencyid")) { return new CurrencyComboBoxField(); } else if (CampaignWithBLOBs.Field.budget.equalTo(propertyId) || CampaignWithBLOBs.Field.actualcost.equalTo(propertyId) || CampaignWithBLOBs.Field.expectedcost.equalTo(propertyId) || CampaignWithBLOBs.Field.expectedrevenue.equalTo(propertyId)) { return new DoubleField(); } return null; }
@Override protected Field<?> onCreateField(Object propertyId) { if (CrmTask.Field.startdate.equalTo(propertyId)) { return new DateTimeOptionField(); } else if (CrmTask.Field.duedate.equalTo(propertyId)) { return new DateTimeOptionField(); } else if (CrmTask.Field.status.equalTo(propertyId)) { return new TaskStatusComboBox(); } else if (CrmTask.Field.priority.equalTo(propertyId)) { return new TaskPriorityComboBox(); } else if (CrmTask.Field.description.equalTo(propertyId)) { return new RichTextArea(); } else if (CrmTask.Field.contactid.equalTo(propertyId)) { return new ContactSelectionField(); } else if (CrmTask.Field.subject.equalTo(propertyId)) { TextField tf = new TextField(); if (isValidateForm) { tf.setRequired(true); tf.setRequiredError("Subject must not be null"); tf.setNullRepresentation(""); } return tf; } else if (CrmTask.Field.type.equalTo(propertyId)) { return new RelatedEditItemField(attachForm.getBean()); } else if (CrmTask.Field.typeid.equalTo(propertyId)) { return new DummyCustomField<Integer>(); } else if (CrmTask.Field.assignuser.equalTo(propertyId)) { ActiveUserComboBox userBox = new ActiveUserComboBox(); userBox.select(attachForm.getBean().getAssignuser()); return userBox; } return null; }
@Override protected Field<?> onCreateField(Object propertyId) { if (propertyId.equals("subject")) { MTextField tf = new MTextField(); if (isValidateForm) { tf.withNullRepresentation("").withRequired(true) .withRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext.getMessage(MeetingI18nEnum.FORM_SUBJECT))); } return tf; } else if (propertyId.equals("status")) { return new MeetingStatusComboBox(); } else if (propertyId.equals("startdate")) { return new DateTimeOptionField(); } else if (propertyId.equals("enddate")) { return new DateTimeOptionField(); } else if (propertyId.equals("description")) { return new RichTextArea(); } else if (propertyId.equals("type")) { return new RelatedEditItemField(attachForm.getBean()); } else if (propertyId.equals("typeid")) { return new DummyCustomField<String>(); } else if (propertyId.equals("isrecurrence")) { return null; } return null; }
@Override protected Field<?> onCreateField(Object propertyId) { if (propertyId.equals("priority")) { return new CasePriorityComboBox(); } else if (propertyId.equals("status")) { return new CaseStatusComboBox(); } else if (propertyId.equals("reason")) { return new CaseReasonComboBox(); } else if (propertyId.equals("origin")) { return new CasesOriginComboBox(); } else if (propertyId.equals("type")) { return new CaseTypeComboBox(); } else if (propertyId.equals("description")) { return new RichTextArea(); } else if (propertyId.equals("resolution")) { return new RichTextArea(); } else if (propertyId.equals("accountid")) { AccountSelectionField accountField = new AccountSelectionField(); accountField.setRequired(true); return accountField; } else if (propertyId.equals("subject")) { MTextField tf = new MTextField(); if (isValidateForm) { tf.withNullRepresentation("").withRequired(true) .withRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext.getMessage(CaseI18nEnum.FORM_SUBJECT))); } return tf; } else if (propertyId.equals("assignuser")) { ActiveUserComboBox userBox = new ActiveUserComboBox(); userBox.select(attachForm.getBean().getAssignuser()); return userBox; } return null; }
public void addComponent(Component component) { if (!(component instanceof Button)) component.setCaption(null); if (component instanceof MultiSelectComp) { component.setWidth("200px"); } else if (component instanceof AbstractTextField || component instanceof RichTextArea) { component.setWidth("100%"); } super.addComponent(component); }
@AutoGenerated private VerticalLayout buildErrorStackTraceLayout() { // common part: create layout errorStackTraceLayout = new VerticalLayout(); errorStackTraceLayout.setImmediate(false); errorStackTraceLayout.setWidth("100%"); errorStackTraceLayout.setHeight("-1px"); errorStackTraceLayout.setMargin(false, true, false, true); // stackTraceLabel stackTraceLabel = new Label(); stackTraceLabel.setImmediate(true); stackTraceLabel.setWidth("100.0%"); stackTraceLabel.setHeight("-1px"); stackTraceLabel.setValue("Stack trace:"); errorStackTraceLayout.addComponent(stackTraceLabel); // stackTraceValueLabel stackTraceValueLabel = new RichTextArea(); stackTraceValueLabel.setImmediate(true); stackTraceValueLabel.setWidth("100%"); stackTraceValueLabel.setHeight("-1px"); stackTraceValueLabel.setValue("Stack Trace Value"); errorStackTraceLayout.addComponent(stackTraceValueLabel); errorStackTraceLayout.setExpandRatio(stackTraceValueLabel, 1.0f); return errorStackTraceLayout; }
public TokenModeDemo() { setSizeFull(); setSpacing(true); setMargin(true); final Label caption = new Label("TokenMode Demo"); addComponent(caption); final CssLayout wrap = new CssLayout(); wrap.setWidth("600px"); wrap.addStyleName(ValoTheme.LAYOUT_CARD); addComponent(wrap); setExpandRatio(wrap, 1); form = new FormLayout(); form.setMargin(true); form.setSpacing(true); form.setWidth("100%"); form.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); wrap.addComponent(form); to = new AddressEditor(); to.setAddresses(buildDemoAddresses()); to.setCaption("To"); to.setWidth("100%"); form.addComponent(to); cc = new AddressEditor(); cc.setAddresses(buildDemoAddresses()); cc.setCaption("Cc"); cc.setWidth("100%"); form.addComponent(cc); TextField subject = new TextField(); subject.setWidth("100%"); form.addComponent(subject); RichTextArea body = new RichTextArea("Body"); body.setWidth("100%"); wrap.addComponent(body); }
@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()); } }); return field; } else if (propertyId.equals("id")) { if (beanItem.getId() != null) { String attachmentPath = AttachmentUtils.getProjectEntityAttachmentPath(AppUI.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; }
ProjectCommentInput(final ReloadableComponent component, final String typeVal, Integer extraTypeIdVal) { this.withMargin(new MarginInfo(true, true, false, false)).withFullWidth().withHeightUndefined(); SimpleUser currentUser = UserUIContext.getUser(); ProjectMemberBlock userBlock = new ProjectMemberBlock(currentUser.getUsername(), currentUser.getAvatarid(), currentUser.getDisplayName()); MVerticalLayout textAreaWrap = new MVerticalLayout().withFullWidth().withStyleName(WebThemes.MESSAGE_CONTAINER); this.with(userBlock, textAreaWrap).expand(textAreaWrap); type = typeVal; extraTypeId = extraTypeIdVal; commentArea = new RichTextArea(); commentArea.setWidth("100%"); commentArea.setHeight("200px"); commentArea.addStyleName("comment-attachment"); final AttachmentPanel attachments = new AttachmentPanel(); attachments.setWidth("100%"); final MButton newCommentBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_POST), clickEvent -> { CommentWithBLOBs comment = new CommentWithBLOBs(); comment.setComment(Jsoup.clean(commentArea.getValue(), Whitelist.relaxed())); comment.setCreatedtime(new GregorianCalendar().getTime()); comment.setCreateduser(UserUIContext.getUsername()); comment.setSaccountid(AppUI.getAccountId()); comment.setType(type); comment.setTypeid("" + typeId); comment.setExtratypeid(extraTypeId); final CommentService commentService = AppContextUtil.getSpringBean(CommentService.class); int commentId = commentService.saveWithSession(comment, UserUIContext.getUsername()); String attachmentPath = AttachmentUtils.getCommentAttachmentPath(typeVal, AppUI.getAccountId(), CurrentProjectVariables.getProjectId(), typeId, commentId); if (!"".equals(attachmentPath)) { attachments.saveContentsToRepo(attachmentPath); } // save success, clear comment area and load list // comments again commentArea.setValue(""); component.reload(); }).withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.SEND); textAreaWrap.with(new MCssLayout(commentArea, attachments), newCommentBtn).withAlign(newCommentBtn, Alignment.TOP_RIGHT); }
@Override protected Field<?> onCreateField(Object propertyId) { if (propertyId.equals("firstname") || propertyId.equals("prefixname")) { return firstNamePrefixField; } else if (propertyId.equals("primcountry") || propertyId.equals("othercountry")) { return new CountryComboBox(); } else if (propertyId.equals("status")) { B bean = attachForm.getBean(); if (bean.getStatus() == null) { bean.setStatus(LeadStatus.New.name()); } return new LeadStatusComboBox(); } else if (propertyId.equals("industry")) { return new IndustryComboBox(); } else if (propertyId.equals("assignuser")) { return new ActiveUserComboBox(); } else if (propertyId.equals("source")) { return new LeadSourceComboBox(); } else if (propertyId.equals("lastname")) { TextField tf = new TextField(); if (isValidateForm) { tf.setNullRepresentation(""); tf.setRequired(true); tf.setRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext.getMessage(GenericI18Enum.FORM_LASTNAME))); } return tf; } else if (propertyId.equals("description")) { return new RichTextArea(); } else if (propertyId.equals("accountname")) { TextField txtField = new TextField(); if (isValidateForm) { txtField.setRequired(true); txtField.setRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext.getMessage(LeadI18nEnum.FORM_ACCOUNT_NAME))); } return txtField; } return null; }
CrmCommentInput(ReloadableComponent component, String typeVal) { this.withMargin(new MarginInfo(true, true, false, false)).withFullWidth(); SimpleUser currentUser = UserUIContext.getUser(); UserBlock userBlock = new UserBlock(currentUser.getUsername(), currentUser.getAvatarid(), currentUser.getDisplayName()); MVerticalLayout textAreaWrap = new MVerticalLayout().withFullWidth().withStyleName(WebThemes.MESSAGE_CONTAINER); this.with(userBlock, textAreaWrap).expand(textAreaWrap); type = typeVal; commentArea = new RichTextArea(); commentArea.setWidth("100%"); commentArea.setHeight("200px"); final AttachmentPanel attachments = new AttachmentPanel(); MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLEAR), clickEvent -> commentArea.setValue("")) .withStyleName(WebThemes.BUTTON_OPTION); MButton newCommentBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_POST), clickEvent -> { CommentWithBLOBs comment = new CommentWithBLOBs(); comment.setComment(Jsoup.clean(commentArea.getValue(), Whitelist.relaxed())); comment.setCreatedtime(new GregorianCalendar().getTime()); comment.setCreateduser(UserUIContext.getUsername()); comment.setSaccountid(AppUI.getAccountId()); comment.setType(type); comment.setTypeid(typeId); CommentService commentService = AppContextUtil.getSpringBean(CommentService.class); int commentId = commentService.saveWithSession(comment, UserUIContext.getUsername()); String attachmentPath = AttachmentUtils.getCommentAttachmentPath(typeVal, AppUI.getAccountId(), null, typeId, commentId); if (!"".equals(attachmentPath)) { attachments.saveContentsToRepo(attachmentPath); } // save success, clear comment area and load list // comments again commentArea.setValue(""); component.reload(); }).withIcon(FontAwesome.SEND).withStyleName(WebThemes.BUTTON_ACTION); final MHorizontalLayout controlsLayout = new MHorizontalLayout(cancelBtn, newCommentBtn); textAreaWrap.with(commentArea, attachments, controlsLayout).withAlign(controlsLayout, Alignment.TOP_RIGHT); }