com.vaadin.ui.IconGenerator Java Examples

The following examples show how to use com.vaadin.ui.IconGenerator. 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: WebFoldersPane.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void setupIconGenerator() {
    WebConfig webConfig = beanLocator.get(Configuration.class)
            .getConfig(WebConfig.class);

    IconGenerator<AbstractSearchFolder> iconGenerator = !webConfig.getShowFolderIcons()
            ? NULL_ITEM_ICON_GENERATOR
            : iconProvider == null
                ? DEFAULT_ICON_GENERATOR
                : ICON_GENERATOR;

    component.setIconGenerator(iconGenerator);
}
 
Example #2
Source File: MilestoneEditFormFieldFactory.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
ProgressStatusComboBox() {
    super(MilestoneStatus.class, InProgress, Future, Closed);
    this.setWidth(WebThemes.FORM_CONTROL_WIDTH);
    this.setItemIconGenerator((IconGenerator<MilestoneStatus>) it -> {
        switch (it) {
            case InProgress:
                return VaadinIcons.SPINNER;
            case Future:
                return VaadinIcons.CLOCK;
            default:
                return VaadinIcons.MINUS_CIRCLE;
        }
    });
    this.setValue(InProgress);
}
 
Example #3
Source File: MilestoneComboBox.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public MilestoneComboBox() {
    this.setWidth(WebThemes.FORM_CONTROL_WIDTH);
    MilestoneSearchCriteria criteria = new MilestoneSearchCriteria();
    SimpleProject project = CurrentProjectVariables.getProject();
    if (project != null) {
        criteria.setProjectIds(new SetSearchField<>(project.getId()));
        MilestoneService milestoneService = AppContextUtil.getSpringBean(MilestoneService.class);
        milestones = (List<SimpleMilestone>) milestoneService.findPageableListByCriteria(new BasicSearchRequest<>(criteria));
        milestones.sort(new MilestoneComparator());

        this.setItems(milestones);
        this.setItemCaptionGenerator((ItemCaptionGenerator<SimpleMilestone>) milestone -> StringUtils.trim(milestone.getName(), 25, true));
        this.setItemIconGenerator((IconGenerator<SimpleMilestone>) milestone -> ProjectAssetsUtil.getPhaseIcon(milestone.getStatus()));
    }
}
 
Example #4
Source File: BugSeverityComboBox.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public BugSeverityComboBox() {
    super(BugSeverity.class, OptionI18nEnum.bug_severities);
    setWidth(WebThemes.FORM_CONTROL_WIDTH);
    setItemIconGenerator((IconGenerator<BugSeverity>) severity -> VaadinIcons.STAR);
    setStyleGenerator((StyleGenerator<BugSeverity>) severity -> {
        if (severity != null) {
            return "bug-severity-" + severity.toString().toLowerCase();
        } else {
            return null;
        }
    });
    setValue(Major);
}
 
Example #5
Source File: ProjectMemberListSelect.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public ProjectMemberListSelect(boolean activeMembers, List<Integer> projectIds) {
    ProjectMemberSearchCriteria criteria = new ProjectMemberSearchCriteria();
    criteria.setProjectIds(new SetSearchField<>(projectIds));

    if (activeMembers) {
        criteria.setStatuses(new SetSearchField<>(ProjectMemberStatusConstants.ACTIVE));
    }

    ProjectMemberService projectMemberService = AppContextUtil.getSpringBean(ProjectMemberService.class);
    List<SimpleProjectMember> members = (List<SimpleProjectMember>) projectMemberService.findPageableListByCriteria(new BasicSearchRequest<>(criteria));
    this.setItems(members);
    this.setItemCaptionGenerator((ItemCaptionGenerator<SimpleProjectMember>) SimpleProjectMember::getDisplayName);
    setItemIconGenerator((IconGenerator<SimpleProjectMember>) member -> UserAvatarControlFactory.createAvatarResource(member.getMemberAvatarId(), 16));
    this.setRows(4);
}
 
Example #6
Source File: PriorityComboBox.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public PriorityComboBox() {
    super(Priority.class, Urgent, High, Medium, Low, None);
    this.setWidth(WebThemes.FORM_CONTROL_WIDTH);
    this.setItemIconGenerator((IconGenerator<Priority>) item -> {
        if (item == Urgent || item == High || item == Medium) {
            return VaadinIcons.ARROW_UP;
        } else {
            return VaadinIcons.ARROW_DOWN;
        }
    });
    this.setStyleGenerator((StyleGenerator<Priority>) itemId -> String.format("priority-%s", itemId.name().toLowerCase()));
    this.setValue(Medium);
}
 
Example #7
Source File: ActiveUserComboBox.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public ActiveUserComboBox() {
    this.setWidth(WebThemes.FORM_CONTROL_WIDTH);
    UserSearchCriteria criteria = new UserSearchCriteria();
    criteria.setSaccountid(new NumberSearchField(AppUI.getAccountId()));
    criteria.setRegisterStatuses(new SetSearchField<>(RegisterStatusConstants.ACTIVE));

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    users = (List<SimpleUser>) userService.findPageableListByCriteria(new BasicSearchRequest<>(criteria));
    setItems(users);
    setItemCaptionGenerator((ItemCaptionGenerator<SimpleUser>) user -> StringUtils.trim(user.getDisplayName(), 30, true));
    setItemIconGenerator((IconGenerator<SimpleUser>) user -> UserAvatarControlFactory.createAvatarResource(user.getAvatarid(), 16));
}
 
Example #8
Source File: ActiveUserListSelect.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public ActiveUserListSelect() {

        UserSearchCriteria criteria = new UserSearchCriteria();
        criteria.setSaccountid(new NumberSearchField(AppUI.getAccountId()));
        criteria.setRegisterStatuses(new SetSearchField<>(RegisterStatusConstants.ACTIVE));

        UserService userService = AppContextUtil.getSpringBean(UserService.class);
        List<SimpleUser> users = (List<SimpleUser>) userService.findPageableListByCriteria(new BasicSearchRequest<>(criteria));

        this.setItems(users);
        this.setItemCaptionGenerator((ItemCaptionGenerator<SimpleUser>) user -> user.getDisplayName());
        this.setItemIconGenerator((IconGenerator<SimpleUser>) user -> UserAvatarControlFactory.createAvatarResource(user.getAvatarid(), 16));

        this.setRows(4);
    }
 
Example #9
Source File: ComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 4 votes vote down vote up
@Override
public void setItemIconGenerator(final IconGenerator<T> itemIconGenerator) {
    super.setItemIconGenerator(itemIconGenerator);
}
 
Example #10
Source File: CubaSearchSelectPickerField.java    From cuba with Apache License 2.0 4 votes vote down vote up
public IconGenerator<T> getItemIconGenerator() {
    return getFieldInternal().getItemIconGenerator();
}
 
Example #11
Source File: CubaSearchSelectPickerField.java    From cuba with Apache License 2.0 4 votes vote down vote up
public void setItemIconGenerator(IconGenerator<T> itemIconGenerator) {
    getFieldInternal().setItemIconGenerator(itemIconGenerator);
}
 
Example #12
Source File: CubaComboBoxPickerField.java    From cuba with Apache License 2.0 4 votes vote down vote up
public IconGenerator<T> getItemIconGenerator() {
    return getFieldInternal().getItemIconGenerator();
}
 
Example #13
Source File: CubaComboBoxPickerField.java    From cuba with Apache License 2.0 4 votes vote down vote up
public void setItemIconGenerator(IconGenerator<T> itemIconGenerator) {
    getFieldInternal().setItemIconGenerator(itemIconGenerator);
}
 
Example #14
Source File: ComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 4 votes vote down vote up
@Override
public void setItemIconGenerator(final IconGenerator<T> itemIconGenerator) {
    super.setItemIconGenerator(itemIconGenerator);
}
 
Example #15
Source File: TicketComponentFactoryImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private void loadAssociateTicketTypePerProject() {
    typeSelection.clear();
    List<String> ticketTypes = new ArrayList<>();

    if (UserUIContext.isAdmin()) {
        if (isIncludeMilestone) {
            ticketTypes.add(UserUIContext.getMessage(MilestoneI18nEnum.SINGLE));
        }
        ticketTypes.add(UserUIContext.getMessage(TaskI18nEnum.SINGLE));
        ticketTypes.add(UserUIContext.getMessage(BugI18nEnum.SINGLE));

    } else {
        ProjectMemberService projectMemberService = AppContextUtil.getSpringBean(ProjectMemberService.class);
        SimpleProjectMember member = projectMemberService.findMemberByUsername(UserUIContext.getUsername(), selectedProject.getId(), AppUI.getAccountId());

        if (member != null) {
            if (isIncludeMilestone && (member.canWrite(ProjectRolePermissionCollections.MILESTONES))) {
                ticketTypes.add(UserUIContext.getMessage(MilestoneI18nEnum.SINGLE));
            }

            if (member.canWrite(ProjectRolePermissionCollections.TASKS)) {
                ticketTypes.add(UserUIContext.getMessage(TaskI18nEnum.SINGLE));
            }

            if (member.canWrite(ProjectRolePermissionCollections.BUGS)) {
                ticketTypes.add(UserUIContext.getMessage(BugI18nEnum.SINGLE));
            }
        }
    }


    if (ticketTypes.size() > 0) {
        typeSelection.setItems(ticketTypes);
        typeSelection.setValue(ticketTypes.get(0));
        typeSelection.setItemIconGenerator((IconGenerator<String>) item -> {
            if (item.equals(UserUIContext.getMessage(TaskI18nEnum.SINGLE))) {
                return ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK);
            } else if (item.equals(UserUIContext.getMessage(BugI18nEnum.SINGLE))) {
                return ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG);
            } else if (item.equals(UserUIContext.getMessage(MilestoneI18nEnum.SINGLE))) {
                return ProjectAssetsManager.getAsset(ProjectTypeConstants.MILESTONE);
            } else {
                throw new IllegalArgumentException();
            }
        });
    }
}
 
Example #16
Source File: ProjectMemberSelectionBox.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private void loadUserList() {
    this.setItems(members);
    this.setItemCaptionGenerator((ItemCaptionGenerator<SimpleProjectMember>) member -> StringUtils.trim(member.getDisplayName(), 25, true));
    this.setItemIconGenerator((IconGenerator<SimpleProjectMember>) member -> UserAvatarControlFactory.createAvatarResource(member.getMemberAvatarId(), 16));
}