com.vaadin.data.HasValue Java Examples

The following examples show how to use com.vaadin.data.HasValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BrowserCookie.java    From viritin with Apache License 2.0 6 votes vote down vote up
/**
 *
 * Binds a HasValue<V> to a cookie that lives for a month. The cookies value is updated via a
 * ValueChangeListener.
 *
 * @param <V> The value-type of the HasValue&lt;&gt;
 * @param field The HasValue&lt;V&gt; that gets bound.
 * @param name The name of the cookie
 * @param cb A BrowserCookie.Callback that gets called with the actual value of the cookie. The value is guaranteed to be not null.
 *
 * @throws IllegalArgumentException if field or name are null or if name is empty.
 */
public static <V> void bindValueToCookie(HasValue<V> field, String name, Callback cb) {
    if (Objects.isNull(name) || name.isEmpty()) {
        throw new IllegalArgumentException("Name must not be null or empty");
    }
    if (Objects.isNull(field)) {
        throw new IllegalArgumentException("Field must not be null");
    }

    detectCookieValue(name, (v) -> {
                                if (v != null) {
                                    cb.onValueDetected(v);
                                }
                            });

    field.addValueChangeListener((event) -> {
        setCookie(name, event.getValue().toString(), LocalDateTime.now().plusMonths(1l));
    });
}
 
Example #2
Source File: ResolvedInputForm.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected HasValue<?> onCreateField(final Object propertyId) {
    if (BugWithBLOBs.Field.resolution.equalTo(propertyId)) {
        if (StringUtils.isBlank(bean.getResolution()) || UserUIContext.getMessage(BugResolution.None).equals(bug.getResolution())) {
            bean.setResolution(BugResolution.Fixed.name());
        }
        return new ResolutionField();
    } else if (BugWithBLOBs.Field.assignuser.equalTo(propertyId)) {
        bug.setAssignuser(bug.getCreateduser());
        return new ProjectMemberSelectionField();
    } else if (propertyId.equals("fixedVersions")) {
        fixedVersionSelect = new VersionMultiSelectField();
        if (CollectionUtils.isEmpty(bug.getFixedVersions()) && CollectionUtils.isNotEmpty(bug.getAffectedVersions())) {
            bug.setFixedVersions(bug.getAffectedVersions());
        }
        return fixedVersionSelect;
    } else if (propertyId.equals("comment")) {
        commentArea = new RichTextArea();
        return commentArea;
    }

    return null;
}
 
Example #3
Source File: MilestoneEditFormFieldFactory.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected HasValue<?> onCreateField(Object propertyId) {
    if (Milestone.Field.assignuser.equalTo(propertyId)) {
        return new ProjectMemberSelectionField();
    } else if (propertyId.equals("status")) {
        return new ProgressStatusComboBox();
    } else if (propertyId.equals("name")) {
        return new MTextField().withRequiredIndicatorVisible(true);
    } else if (propertyId.equals("description")) {
        return new RichTextArea();
    } else if ("section-attachments".equals(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;
    } else if (Milestone.Field.startdate.equalTo(propertyId) || Milestone.Field.enddate.equalTo(propertyId)) {
        return new DateField();
    }

    return null;
}
 
Example #4
Source File: MilestonePreviewForm.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected HasValue<?> onCreateField(final Object propertyId) {
    SimpleMilestone milestone = attachForm.getBean();
    if (Milestone.Field.description.equalTo(propertyId)) {
        return new RichTextViewField();
    } else if (Milestone.Field.status.equalTo(propertyId)) {
        String milestoneStatus = UserUIContext.getMessage(MilestoneStatus.class, milestone.getStatus());
        VaadinIcons statusIcon = ProjectAssetsUtil.getPhaseIcon(milestone.getStatus());
        return new StyleViewField(statusIcon.getHtml() + " " + milestoneStatus)
                .withStyleName(WebThemes.FIELD_NOTE);
    } else if ("section-assignments".equals(propertyId)) {
        ContainerViewField containerField = new ContainerViewField();
        containerField.addComponentField(new AssignmentsComp(milestone));
        return containerField;
    } else if ("section-attachments".equals(propertyId)) {
        return new ProjectFormAttachmentDisplayField(milestone.getProjectid(), ProjectTypeConstants.MILESTONE,
                milestone.getId());
    }
    return null;
}
 
Example #5
Source File: ProjectGeneralInfoStep.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected HasValue<?> onCreateField(final Object propertyId) {
    if (Project.Field.description.equalTo(propertyId)) {
        return new RichTextArea();
    } else if (Project.Field.status.equalTo(propertyId)) {
        ProjectStatusComboBox statusField = new ProjectStatusComboBox();
        statusField.setRequiredIndicatorVisible(true);
        if (project.getStatus() == null) {
            project.setStatus(StatusI18nEnum.Open.name());
        }
        return statusField;
    } else if (Project.Field.shortname.equalTo(propertyId)) {
        return new MTextField().withRequiredIndicatorVisible(true).withWidth(WebThemes.FORM_CONTROL_WIDTH);
    } else if (Project.Field.name.equalTo(propertyId)) {
        return new MTextField().withRequiredIndicatorVisible(true).withWidth(WebThemes.FORM_CONTROL_WIDTH);
    } else if (Project.Field.memlead.equalTo(propertyId)) {
        return new ActiveUserComboBox();
    } else if (Project.Field.planstartdate.equalTo(propertyId) || Project.Field.planenddate.equalTo(propertyId)) {
        return new DateField();
    }

    return null;
}
 
Example #6
Source File: UserReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected HasValue<?> onAttachField(Object propertyId, HasValue<?> field) {
    if (propertyId.equals("website")) {
        return advancedInfoLayout.addComponent(field, UserUIContext.getMessage(UserI18nEnum.FORM_WEBSITE), 0, 0);
    } else if (propertyId.equals("company")) {
        return advancedInfoLayout.addComponent(field, UserUIContext.getMessage(UserI18nEnum.FORM_COMPANY), 0, 1);
    } else if (propertyId.equals("country")) {
        return advancedInfoLayout.addComponent(field, UserUIContext.getMessage(UserI18nEnum.FORM_COUNTRY), 0, 2);
    } else if (propertyId.equals("workphone")) {
        return contactLayout.addComponent(field, UserUIContext.getMessage(UserI18nEnum.FORM_WORK_PHONE), 0, 0);
    } else if (propertyId.equals("homephone")) {
        return contactLayout.addComponent(field, UserUIContext.getMessage(UserI18nEnum.FORM_HOME_PHONE), 0, 1);
    } else if (propertyId.equals("facebookaccount")) {
        return contactLayout.addComponent(field, "Facebook", 0, 2);
    } else if (propertyId.equals("twitteraccount")) {
        return contactLayout.addComponent(field, "Twitter", 0, 3);
    } else if (propertyId.equals("skypecontact")) {
        return contactLayout.addComponent(field, "Skype", 0, 4);
    }
    return null;
}
 
Example #7
Source File: RoleReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void previewItem(SimpleRole role) {
    this.role = role;
    this.previewForm.setFormLayoutFactory(new FormLayoutFactory());
    this.previewForm.setBeanFormFieldFactory(new AbstractBeanFieldGroupViewFieldFactory<Role>(previewForm) {
        private static final long serialVersionUID = 1L;

        @Override
        protected HasValue<?> onCreateField(Object propertyId) {
            if (Role.Field.isdefault.equalTo(propertyId)) {
                Enum localizeYesNo = LocalizationHelper.localizeYesNo(role.getIsdefault());
                return new DefaultViewField(UserUIContext.getMessage(localizeYesNo));
            }
            return null;
        }
    });
    this.previewForm.setBean(role);
}
 
Example #8
Source File: ProfileReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected HasValue<?> onAttachField(Object propertyId, HasValue<?> field) {
    if (propertyId.equals("website")) {
        return advancedInfoLayout.addComponent(field, UserUIContext.getMessage(UserI18nEnum.FORM_WEBSITE), 0, 0);
    } else if (propertyId.equals("company")) {
        return advancedInfoLayout.addComponent(field, UserUIContext.getMessage(UserI18nEnum.FORM_COMPANY), 0, 1);
    } else if (propertyId.equals("country")) {
        return advancedInfoLayout.addComponent(field, UserUIContext.getMessage(UserI18nEnum.FORM_COUNTRY), 0, 2);
    } else if (propertyId.equals("workphone")) {
        return contactLayout.addComponent(field, UserUIContext.getMessage(UserI18nEnum.FORM_WORK_PHONE), 0, 0);
    } else if (propertyId.equals("homephone")) {
        return contactLayout.addComponent(field, UserUIContext.getMessage(UserI18nEnum.FORM_HOME_PHONE), 0, 1);
    } else if (propertyId.equals("facebookaccount")) {
        return contactLayout.addComponent(field, "Facebook", 0, 2);
    } else if (propertyId.equals("twitteraccount")) {
        return contactLayout.addComponent(field, "Twitter", 0, 3);
    } else if (propertyId.equals("skypecontact")) {
        return contactLayout.addComponent(field, "Skype", 0, 4);
    }
    return null;
}
 
Example #9
Source File: BrowserCookie.java    From viritin with Apache License 2.0 6 votes vote down vote up
/**
 * Binds a HasValue&lt;String&gt; to a cookie that lives for a month. The cookies value is updated via a
 * ValueChangeListener. Its crrent value is copied into the HasValue&lt;String&gt;.
 *
 * @param field The HasValue&lt;String&gt; that gets bound.
 * @param name The name of the cookie
 *
 * @throws IllegalArgumentException if field or name are null or if name is empty.
 */
public static void bindValueToCookie(HasValue<String> field, String name) {
    if (Objects.isNull(name) || name.isEmpty()) {
        throw new IllegalArgumentException("Name must not be null or empty");
    }
    if (Objects.isNull(field)) {
        throw new IllegalArgumentException("Field must not be null");
    }

    detectCookieValue(name, (v) -> {
                                if (v != null) {
                                    field.setValue(v);
                                }
                            });

    field.addValueChangeListener((event) -> {
        setCookie(name, event.getValue(), LocalDateTime.now().plusMonths(1l));
    });
}
 
Example #10
Source File: DecisionFlowValueChangeListenerTest.java    From cia with Apache License 2.0 6 votes vote down vote up
/**
 * Selection value change test.
 */
@Test
public void selectionValueChangeTest() {
	final String pageName = "pageName";
	final String pageId = "pageId";
	final DecisionFlowValueChangeListener listener = new DecisionFlowValueChangeListener(pageName, pageId);
	final UI uiMock = Mockito.mock(UI.class);
	UI.setCurrent(uiMock);
	
	final Navigator navigatorMock = Mockito.mock(Navigator.class);
	Mockito.when(uiMock.getNavigator()).thenReturn(navigatorMock);		
			
	final ValueChangeEvent event = Mockito.mock(ValueChangeEvent.class);
	
	final HasValue hasValue = Mockito.mock(HasValue.class);
	Mockito.when(hasValue.isEmpty()).thenReturn(false);
	
	Mockito.when(event.getSource()).thenReturn(hasValue);
	
	final String value = "value";
	Mockito.when(event.getValue()).thenReturn("value");
		
	listener.valueChange(event);
	
	Mockito.verify(navigatorMock, times(1)).navigateTo(pageName + "/CHARTS/DECISION_FLOW_CHART/" + pageId + "[" +value + "]");
}
 
Example #11
Source File: ProfileReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected HasValue<?> onCreateField(final Object propertyId) {
    User user = formItem.getBean();
    if (propertyId.equals("website")) {
        return new UrlLinkViewField(user.getWebsite());
    } else if (propertyId.equals("facebookaccount")) {
        return new UrlLinkViewField(String.format("https://www.facebook.com/%s", user.getFacebookaccount()),
                user.getFacebookaccount());
    } else if (propertyId.equals("twitteraccount")) {
        return new UrlLinkViewField(String.format("https://www.twitter.com/%s", user.getTwitteraccount()),
                user.getTwitteraccount());
    } else if (propertyId.equals("skypecontact")) {
        return new UrlLinkViewField(String.format("skype:%s?chat", user.getSkypecontact()), user.getSkypecontact());
    } else if (User.Field.country.equalTo(propertyId)) {
        return new CountryViewField();
    }
    return null;
}
 
Example #12
Source File: VersionPreviewForm.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected HasValue<?> onCreateField(Object propertyId) {
    Version beanItem = attachForm.getBean();
    if (Version.Field.duedate.equalTo(propertyId)) {
        return new DateViewField();
    } else if ("section-assignments".equals(propertyId)) {
        ContainerViewField containerField = new ContainerViewField();
        containerField.addComponentField(new TicketsComp(beanItem));
        return containerField;
    } else if (Version.Field.status.equalTo(propertyId)) {
        return new I18nFormViewField(StatusI18nEnum.class).withStyleName(WebThemes.FIELD_NOTE);
    } else if (Version.Field.description.equalTo(propertyId)) {
        return new RichTextViewField();
    }
    return null;
}
 
Example #13
Source File: GridCellWrapper.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
public void addField(Component field) {
    if (field instanceof HasValue && ((HasValue)field).isRequiredIndicatorVisible() && captionComp!= null) {
        captionComp.addStyleName(WebThemes.REQUIRED_FIELD_INDICATOR);
    }
    fieldWrapper.removeAllComponents();
    field.setCaption(null);

    if (field.getWidth() != -1) {
        // continue
    } else if (field instanceof MultiSelectComp || field instanceof DateField) {
        field.setWidth(WebThemes.FORM_CONTROL_WIDTH);
    } else {
        field.setWidth("100%");
    }
    fieldWrapper.withComponent(field);
}
 
Example #14
Source File: ProjectRoleAddViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected AbstractBeanFieldGroupEditFieldFactory<ProjectRole> initBeanFormFieldFactory() {
    return new AbstractBeanFieldGroupEditFieldFactory<ProjectRole>(editForm) {
        private static final long serialVersionUID = 1L;

        @Override
        protected HasValue<?> onCreateField(Object propertyId) {
            if (propertyId.equals("description")) {
                return new TextArea();
            } else if (propertyId.equals("rolename")) {
                return new MTextField().withRequiredIndicatorVisible(true);
            }
            return null;
        }
    };
}
 
Example #15
Source File: WebTimeField.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void componentValueChanged(HasValue.ValueChangeEvent<LocalTime> e) {
    if (e.isUserOriginated()) {
        V value;

        try {
            value = constructModelValue();

            setValueToPresentation(convertToPresentation(value));
        } catch (ConversionException ce) {
            LoggerFactory.getLogger(WebDateField.class)
                    .trace("Unable to convert presentation value to model", ce);

            setValidationError(ce.getLocalizedMessage());
            return;
        }

        V oldValue = internalValue;
        internalValue = value;

        if (!fieldValueEquals(value, oldValue)) {
            ValueChangeEvent<V> event = new ValueChangeEvent<>(this, oldValue, value, true);
            publish(ValueChangeEvent.class, event);
        }
    }
}
 
Example #16
Source File: InviteUserTokenField.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
private HasValue.ValueChangeListener<SimpleTokenizable> getComboBoxValueChange(ExtTokenField extTokenField) {
    return event -> {
        SimpleTokenizable token = event.getValue();

        if (token != null) {
            extTokenField.addTokenizable(token);
            inviteEmails.add(token.getStringValue());
            event.getSource().setValue(null);
        }
    };

}
 
Example #17
Source File: UserReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void setBean(User newDataSource) {
    this.setFormLayoutFactory(new FormLayoutFactory());
    this.setBeanFormFieldFactory(new AbstractBeanFieldGroupViewFieldFactory<User>(PreviewForm.this) {
        private static final long serialVersionUID = 1L;

        @Override
        protected HasValue<?> onCreateField(Object propertyId) {
            if (propertyId.equals("email")) {
                return new EmailViewField(user.getEmail());
            } else if (propertyId.equals("roleid")) {
                if (Boolean.TRUE.equals(user.isAccountOwner())) {
                    return new DefaultViewField(UserUIContext.getMessage(RoleI18nEnum.OPT_ACCOUNT_OWNER));
                } else {
                    return new LinkViewField(user.getRoleName(), AccountLinkGenerator.generateRoleLink(user.getRoleId()));
                }
            } else if (propertyId.equals("website")) {
                return new UrlLinkViewField(user.getWebsite());
            } else if (propertyId.equals("birthday")) {
                return new DateViewField();
            } else if (propertyId.equals("timezone")) {
                return new DefaultViewField(TimezoneVal.getDisplayName(UserUIContext.getUserLocale(), user.getTimezone()));
            } else if (propertyId.equals("facebookaccount")) {
                return new UrlLinkViewField(String.format("https://www.facebook.com/%s", user.getFacebookaccount()),
                        user.getFacebookaccount());
            } else if (propertyId.equals("twitteraccount")) {
                return new UrlLinkViewField(String.format("https://www.twitter.com/%s", user.getTwitteraccount()),
                        user.getTwitteraccount());
            } else if (propertyId.equals("skypecontact")) {
                return new UrlLinkViewField(String.format("skype:%s?chat", user.getSkypecontact()), user.getSkypecontact());
            }
            return null;
        }
    });
    super.setBean(newDataSource);
}
 
Example #18
Source File: PagePreviewForm.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected HasValue<?> onAttachField(java.lang.Object propertyId, HasValue<?> field) {
    if (propertyId.equals("content")) {
        layout.addComponent((Component) field);
        return field;
    }
    return null;
}
 
Example #19
Source File: PageEditFormFieldFactory.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected HasValue<?> onCreateField(Object propertyId) {
    Page page = attachForm.getBean();
    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 = AppUI.getSiteUrl();
        String params = String.format("path=%s&createdUser=%s&sAccountId=%d", page.getPath(),
                UserUIContext.getUsername(), AppUI.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.setRequiredIndicatorVisible(true);
        return ckEditorTextField;
    } else if (propertyId.equals("status")) {
        page.setStatus(WikiI18nEnum.status_public.name());
        return new I18nValueComboBox<>(WikiI18nEnum.class, WikiI18nEnum.status_public,
                WikiI18nEnum.status_private, WikiI18nEnum.status_archieved).withWidth(WebThemes.FORM_CONTROL_WIDTH);
    } else if (propertyId.equals("subject")) {
        return new MTextField().withRequiredIndicatorVisible(true);
    }

    return null;
}
 
Example #20
Source File: BuildCriterionComponent.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
private Object constructObject(AbstractOrderedLayout valueBox) {
    int componentCount = valueBox.getComponentCount();
    if (componentCount == 1) {
        HasValue<?> component = (HasValue<?>) valueBox.getComponent(0);
        return getConvertedValue(component);
    } else if (componentCount > 1) {
        Object[] value = new Object[componentCount];
        for (int i = 0; i < componentCount; i++) {
            Array.set(value, i, getConvertedValue(((HasValue<?>) valueBox.getComponent(i))));
        }
        return value;
    } else {
        return null;
    }
}
 
Example #21
Source File: BuildCriterionComponent.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
private Object getConvertedValue(HasValue<?> component) {
    if (component instanceof Converter) {
        Converter converter = (Converter) component;
        Result result = converter.convertToModel(component.getValue(), null);
        try {
            return result.getOrThrow(SerializableFunction.identity());
        } catch (Throwable throwable) {
            throw new MyCollabException(throwable);
        }
    }
    return component.getValue();
}
 
Example #22
Source File: PageFormLayoutFactory.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected HasValue<?> onAttachField(Object propertyId, HasValue<?> field) {
    if (propertyId.equals("subject")) {
        return informationLayout.addComponent(field, UserUIContext.getMessage(PageI18nEnum.FORM_SUBJECT), 0, 0);
    } else if (propertyId.equals("content")) {
        return informationLayout.addComponent(field, UserUIContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0, 1);
    } else if (propertyId.equals("status")) {
        return informationLayout.addComponent(field, UserUIContext.getMessage(PageI18nEnum.FORM_VISIBILITY), 0, 2);
    }
    return null;
}
 
Example #23
Source File: TaskPreviewForm.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected HasValue<?> onCreateField(final Object propertyId) {
    SimpleTask beanItem = attachForm.getBean();
    if (Task.Field.assignuser.equalTo(propertyId)) {
        return new ProjectUserFormLinkField(beanItem.getProjectid(), beanItem.getAssignuser(),
                beanItem.getAssignUserAvatarId(), beanItem.getAssignUserFullName());
    } else if (Task.Field.milestoneid.equalTo(propertyId)) {
        return new ProjectItemViewField(ProjectTypeConstants.MILESTONE, beanItem.getMilestoneid(), beanItem.getMilestoneName());
    } else if ("section-attachments".equals(propertyId)) {
        return new ProjectFormAttachmentDisplayField(beanItem.getProjectid(), ProjectTypeConstants.TASK, beanItem.getId());
    } else if (SimpleTask.Field.components.equalTo(propertyId)) {
        return new ComponentsViewField();
    } else if (SimpleTask.Field.affectedVersions.equalTo(propertyId)) {
        return new VersionsViewField();
    } else if (Task.Field.priority.equalTo(propertyId)) {
        if (StringUtils.isNotBlank(beanItem.getPriority())) {
            VaadinIcons fontPriority = ProjectAssetsManager.getPriority(beanItem.getPriority());
            String priorityLbl = fontPriority.getHtml() + " " + UserUIContext.getMessage(Priority.class, beanItem.getPriority());
            StyleViewField field = new StyleViewField(priorityLbl);
            field.addStyleName("priority-" + beanItem.getPriority().toLowerCase());
            return field;
        }
    } else if (Task.Field.isestimated.equalTo(propertyId)) {
        return new BooleanViewField();
    } else if (Task.Field.description.equalTo(propertyId)) {
        return new RichTextViewField();
    } else if ("section-subTickets".equals(propertyId)) {
        return new SubTicketsComp(ProjectTicket.buildTicketByTask(beanItem));
    } else if (Task.Field.status.equalTo(propertyId)) {
        return new I18nFormViewField(StatusI18nEnum.class).withStyleName(WebThemes.FIELD_NOTE);
    }
    return null;
}
 
Example #24
Source File: AssignTaskWindow.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected HasValue<?> onCreateField(Object propertyId) {
    if (propertyId.equals("assignuser")) {
        return new ProjectMemberSelectionField();
    } else if (propertyId.equals("comment")) {
        commentArea = new RichTextArea();
        return commentArea;
    }
    return null;
}
 
Example #25
Source File: AssignTaskWindow.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected HasValue<?> onAttachField(Object propertyId, HasValue<?> field) {
    if (Task.Field.assignuser.equalTo(propertyId)) {
        return informationLayout.addComponent(field, UserUIContext.getMessage(GenericI18Enum.FORM_ASSIGNEE), 0, 0);
    } else if (propertyId.equals("comment")) {
        return informationLayout.addComponent(field, UserUIContext.getMessage(GenericI18Enum.OPT_COMMENT), 0, 1);
    }
    return null;
}
 
Example #26
Source File: VersionEditFormFieldFactory.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected HasValue<?> onCreateField(final Object propertyId) {
    if (Version.Field.name.equalTo(propertyId)) {
        return new MTextField().withRequiredIndicatorVisible(true);
    } else if (Version.Field.description.equalTo(propertyId)) {
        return new RichTextArea();
    } else if (Version.Field.duedate.equalTo(propertyId)) {
        return new DateField();
    }

    return null;
}
 
Example #27
Source File: UserBulkInviteViewImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void display() {
    removeAllComponents();
    ELabel titleLbl = ELabel.h2(UserUIContext.getMessage(UserI18nEnum.BULK_INVITE));
    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), (Button.ClickListener) clickEvent -> {
        EventBusFactory.getInstance().post(new UserEvent.GotoList(this, null));
    }).withStyleName(WebThemes.BUTTON_OPTION);
    MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), (Button.ClickListener) clickEvent -> {
        sendInviteBulkUsers();
    }).withStyleName(WebThemes.BUTTON_ACTION);

    this.with(new MHorizontalLayout(titleLbl, cancelBtn, saveBtn).withExpand(titleLbl, 1.0f).withFullWidth());

    roleComboBox = new RoleComboBox();
    roleComboBox.addValueChangeListener((HasValue.ValueChangeListener<SimpleRole>) valueChangeEvent -> {
        displayRolePermission(valueChangeEvent.getSource().getValue());
    });
    this.with(new MHorizontalLayout(ELabel.html(UserUIContext.getMessage(RoleI18nEnum.SINGLE)).withStyleName(WebThemes.META_COLOR), roleComboBox).alignAll(Alignment.TOP_LEFT));
    ResponsiveLayout mainLayout = new ResponsiveLayout().withStyleName(WebThemes.MARGIN_TOP);

    ResponsiveRow mainRow = mainLayout.addRow();
    bulkInviteUsersLayout = new GridLayout(3, 1);
    bulkInviteUsersLayout.setSpacing(true);
    ResponsiveColumn column1 = new ResponsiveColumn(12, 12, 6, 6).withComponent(bulkInviteUsersLayout);
    ResponsiveColumn column2 = new ResponsiveColumn(12, 12, 6, 6).withVisibilityRules(false, false, true, true)
            .withComponent(rolePermissionDisplayLayout);

    mainRow.addColumn(column1);
    mainRow.addColumn(column2);

    bulkInviteUsersLayout.addComponent(ELabel.h3(UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL)).withWidth("220px"), 0, 0);
    bulkInviteUsersLayout.addComponent(ELabel.h3(UserUIContext.getMessage(ShellI18nEnum.FORM_PASSWORD)), 1, 0);

    this.with(mainLayout);
    displayRolePermission(roleComboBox.getValue());

    buildInviteUserBlock();
}
 
Example #28
Source File: ComponentEditFormFieldFactory.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
    protected HasValue<?> onCreateField(final Object propertyId) {
        if (Component.Field.name.equalTo(propertyId)) {
            final MTextField tf = new MTextField().withRequiredIndicatorVisible(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;
    }
 
Example #29
Source File: ProjectMemberFormLayoutFactory.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected HasValue<?> onAttachField(Object propertyId, final HasValue<?> field) {
    if (propertyId.equals("memberFullName")) {
        return informationLayout.addComponent(field, UserUIContext.getMessage(ProjectMemberI18nEnum.FORM_USER), 0, 0, 2);
    } else if (propertyId.equals("projectroleid")) {
        return informationLayout.addComponent(field, UserUIContext.getMessage(ProjectMemberI18nEnum.FORM_ROLE), 0, 1, 2);
    } else if (ProjectMember.Field.billingrate.equalTo(propertyId)) {
        return informationLayout.addComponent(field, UserUIContext.getMessage(ProjectI18nEnum.FORM_BILLING_RATE), 0, 2);
    } else if (ProjectMember.Field.overtimebillingrate.equalTo(propertyId)) {
        return informationLayout.addComponent(field, UserUIContext.getMessage(ProjectI18nEnum.FORM_OVERTIME_BILLING_RATE), 1, 2);
    }
    return null;
}
 
Example #30
Source File: ProjectMemberReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected HasValue<?> onCreateField(final Object propertyId) {
    SimpleProjectMember projectMember = attachForm.getBean();
    if (propertyId.equals("projectroleid")) {
        return new LinkViewField(attachForm.getBean().getRoleName(), ProjectLinkGenerator.generateRolePreviewLink(
                projectMember.getProjectid(), projectMember.getProjectroleid()), null);
    } else if (propertyId.equals("username")) {
        return new UserLinkViewField(projectMember.getUsername(),
                projectMember.getMemberAvatarId(), projectMember.getMemberFullName());
    }
    return null;
}