Example usage for com.vaadin.server FontAwesome COG

List of usage examples for com.vaadin.server FontAwesome COG

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome COG.

Prototype

FontAwesome COG

To view the source code for com.vaadin.server FontAwesome COG.

Click Source Link

Usage

From source file:com.esofthead.mycollab.module.project.view.bug.BugListViewImpl.java

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final MHorizontalLayout layout = new MHorizontalLayout().withWidth("100%");

    final Label lbEmpty = new Label("");
    layout.with(lbEmpty).expand(lbEmpty);

    MHorizontalLayout buttonControls = new MHorizontalLayout();
    layout.addComponent(buttonControls);

    Button customizeViewBtn = new Button("", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override//from w w w . j  a  v  a2s  .c o m
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().addWindow(new BugListCustomizeWindow(BugListView.VIEW_DEF_ID, tableItem));

        }
    });
    customizeViewBtn.setIcon(FontAwesome.COG);
    customizeViewBtn.setDescription("Layout Options");
    customizeViewBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    buttonControls.addComponent(customizeViewBtn);

    PopupButton exportButtonControl = new PopupButton();
    exportButtonControl.addStyleName(UIConstants.THEME_GRAY_LINK);
    exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK);
    exportButtonControl.setDescription(AppContext.getMessage(FileI18nEnum.EXPORT_FILE));

    VerticalLayout popupButtonsControl = new VerticalLayout();
    exportButtonControl.setContent(popupButtonsControl);

    Button exportPdfBtn = new Button(AppContext.getMessage(FileI18nEnum.PDF));

    StreamWrapperFileDownloader fileDownloader = new StreamWrapperFileDownloader(new StreamResourceFactory() {

        @Override
        public StreamResource getStreamResource() {
            String title = "Bugs of Project " + ((CurrentProjectVariables.getProject() != null
                    && CurrentProjectVariables.getProject().getName() != null)
                            ? CurrentProjectVariables.getProject().getName()
                            : "");
            BugSearchCriteria searchCriteria = new BugSearchCriteria();
            searchCriteria.setProjectId(
                    new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProject().getId()));

            return new StreamResource(new SimpleGridExportItemsStreamResource.AllItems<>(title,
                    new RpParameterBuilder(tableItem.getDisplayColumns()), ReportExportType.PDF,
                    ApplicationContextUtil.getSpringBean(BugService.class), searchCriteria, SimpleBug.class),
                    "export.pdf");
        }

    });
    fileDownloader.extend(exportPdfBtn);
    exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O);
    exportPdfBtn.setStyleName("link");
    popupButtonsControl.addComponent(exportPdfBtn);

    Button exportExcelBtn = new Button(AppContext.getMessage(FileI18nEnum.EXCEL));
    StreamWrapperFileDownloader excelDownloader = new StreamWrapperFileDownloader(new StreamResourceFactory() {

        @Override
        public StreamResource getStreamResource() {
            String title = "Bugs of Project " + ((CurrentProjectVariables.getProject() != null
                    && CurrentProjectVariables.getProject().getName() != null)
                            ? CurrentProjectVariables.getProject().getName()
                            : "");
            BugSearchCriteria searchCriteria = new BugSearchCriteria();
            searchCriteria.setProjectId(
                    new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProject().getId()));

            return new StreamResource(new SimpleGridExportItemsStreamResource.AllItems<>(title,
                    new RpParameterBuilder(tableItem.getDisplayColumns()), ReportExportType.EXCEL,
                    ApplicationContextUtil.getSpringBean(BugService.class), searchCriteria, SimpleBug.class),
                    "export.xlsx");
        }
    });
    excelDownloader.extend(exportExcelBtn);
    exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O);
    exportExcelBtn.setStyleName("link");
    popupButtonsControl.addComponent(exportExcelBtn);

    Button exportCsvBtn = new Button(AppContext.getMessage(FileI18nEnum.CSV));

    StreamWrapperFileDownloader csvFileDownloader = new StreamWrapperFileDownloader(
            new StreamResourceFactory() {

                @Override
                public StreamResource getStreamResource() {
                    String title = "Bugs of Project " + ((CurrentProjectVariables.getProject() != null
                            && CurrentProjectVariables.getProject().getName() != null)
                                    ? CurrentProjectVariables.getProject().getName()
                                    : "");
                    BugSearchCriteria searchCriteria = new BugSearchCriteria();
                    searchCriteria.setProjectId(new NumberSearchField(SearchField.AND,
                            CurrentProjectVariables.getProject().getId()));

                    return new StreamResource(new SimpleGridExportItemsStreamResource.AllItems<>(title,
                            new RpParameterBuilder(tableItem.getDisplayColumns()), ReportExportType.CSV,
                            ApplicationContextUtil.getSpringBean(BugService.class), searchCriteria,
                            SimpleBug.class), "export.csv");
                }
            });
    csvFileDownloader.extend(exportCsvBtn);

    exportCsvBtn.setIcon(FontAwesome.FILE_TEXT_O);
    exportCsvBtn.setStyleName("link");
    popupButtonsControl.addComponent(exportCsvBtn);

    buttonControls.addComponent(exportButtonControl);
    return layout;
}

From source file:com.esofthead.mycollab.module.project.view.bug.BugTableDisplay.java

License:Open Source License

public BugTableDisplay(String viewId, TableViewField requiredColumn, List<TableViewField> displayColumns) {
    super(ApplicationContextUtil.getSpringBean(BugService.class), SimpleBug.class, viewId, requiredColumn,
            displayColumns);/*from  ww w  .j av  a  2s. c om*/

    this.addGeneratedColumn("id", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(final Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            final Button bugSettingBtn = new Button(null, FontAwesome.COG);
            bugSettingBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);

            final ContextMenu contextMenu = new ContextMenu();
            contextMenu.setAsContextMenuOf(bugSettingBtn);

            contextMenu.addItemClickListener(new ContextMenuItemClickListener() {

                @Override
                public void contextMenuItemClicked(ContextMenuItemClickEvent event) {
                    if (((ContextMenuItem) event.getSource()).getData() == null) {
                        return;
                    }

                    String category = ((MenuItemData) ((ContextMenuItem) event.getSource()).getData())
                            .getAction();
                    String value = ((MenuItemData) ((ContextMenuItem) event.getSource()).getData()).getKey();
                    if ("status".equals(category)) {
                        if (AppContext.getMessage(BugStatus.Verified).equals(value)) {
                            UI.getCurrent().addWindow(new ApproveInputWindow(BugTableDisplay.this, bug));
                        } else if (AppContext.getMessage(BugStatus.InProgress).equals(value)) {
                            bug.setStatus(BugStatus.InProgress.name());
                            BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
                            bugService.updateWithSession(bug, AppContext.getUsername());
                        } else if (AppContext.getMessage(BugStatus.Open).equals(value)) {
                            UI.getCurrent().addWindow(new ReOpenWindow(BugTableDisplay.this, bug));
                        } else if (AppContext.getMessage(BugStatus.Resolved).equals(value)) {
                            UI.getCurrent().addWindow(new ResolvedInputWindow(BugTableDisplay.this, bug));
                        }
                    } else if ("severity".equals(category)) {
                        bug.setSeverity(value);
                        BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
                        bugService.updateWithSession(bug, AppContext.getUsername());
                        refresh();
                    } else if ("priority".equals(category)) {
                        bug.setPriority(value);
                        BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
                        bugService.updateWithSession(bug, AppContext.getUsername());
                        refresh();
                    } else if ("action".equals(category)) {
                        if ("edit".equals(value)) {
                            EventBusFactory.getInstance()
                                    .post(new BugEvent.GotoEdit(BugTableDisplay.this, bug));
                        } else if ("delete".equals(value)) {
                            ConfirmDialogExt.show(UI.getCurrent(),
                                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                            SiteConfiguration.getSiteName()),
                                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                                    AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                                    AppContext.getMessage(GenericI18Enum.BUTTON_NO),
                                    new ConfirmDialog.Listener() {
                                        private static final long serialVersionUID = 1L;

                                        @Override
                                        public void onClose(ConfirmDialog dialog) {
                                            if (dialog.isConfirmed()) {
                                                BugService bugService = ApplicationContextUtil
                                                        .getSpringBean(BugService.class);
                                                bugService.removeWithSession(bug.getId(),
                                                        AppContext.getUsername(), AppContext.getAccountId());
                                                refresh();
                                            }
                                        }
                                    });

                        }
                    }

                }
            });

            bugSettingBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS));

            bugSettingBtn.addClickListener(new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    displayContextMenuItem(contextMenu, bug, event.getClientX(), event.getClientY());
                }
            });
            return bugSettingBtn;
        }
    });

    this.addGeneratedColumn("assignuserFullName", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new ProjectUserLink(bug.getAssignuser(), bug.getAssignUserAvatarId(),
                    bug.getAssignuserFullName());
        }
    });

    this.addGeneratedColumn("loguserFullName", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new ProjectUserLink(bug.getLogby(), bug.getLoguserAvatarId(), bug.getLoguserFullName());
        }
    });

    this.addGeneratedColumn("summary", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {

            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);

            String bugname = "[%s-%s] %s";
            bugname = String.format(bugname, CurrentProjectVariables.getProject().getShortname(),
                    bug.getBugkey(), bug.getSummary());
            LabelLink b = new LabelLink(bugname,
                    ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName()));

            if (StringUtils.isNotBlank(bug.getPriority())) {
                b.setIconLink(ProjectResources.getIconResourceLink12ByBugPriority(bug.getPriority()));
            }

            b.setDescription(ProjectTooltipGenerator.generateToolTipBug(AppContext.getUserLocale(), bug,
                    AppContext.getSiteUrl(), AppContext.getTimezone()));

            if (bug.isCompleted()) {
                b.addStyleName(UIConstants.LINK_COMPLETED);
            } else if (bug.isOverdue()) {
                b.addStyleName(UIConstants.LINK_OVERDUE);
            }
            return b;

        }
    });

    this.addGeneratedColumn("severity", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);

            Resource iconPriority = new ExternalResource(
                    ProjectResources.getIconResourceLink12ByBugSeverity(bug.getPriority()));

            Embedded iconEmbedded = new Embedded(null, iconPriority);
            Label lbPriority = new Label(AppContext.getMessage(BugSeverity.class, bug.getSeverity()));
            HorizontalLayout containerField = new HorizontalLayout();
            containerField.setSpacing(true);
            containerField.addComponent(iconEmbedded);
            containerField.addComponent(lbPriority);
            containerField.setExpandRatio(lbPriority, 1.0f);
            return containerField;

        }
    });

    this.addGeneratedColumn("duedate", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(bug.getDuedate()));

        }
    });

    this.addGeneratedColumn("createdtime", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDateTime(bug.getCreatedtime()));

        }
    });

    this.addGeneratedColumn("resolution", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.getMessage(BugResolution.class, bug.getResolution()));
        }
    });
    this.setWidth("100%");
}

From source file:com.esofthead.mycollab.module.project.view.milestone.MilestoneListViewImpl.java

License:Open Source License

private ComponentContainer constructMilestoneBox(final SimpleMilestone milestone) {
    final CssLayout layout = new CssLayout();
    layout.addStyleName(UIConstants.MILESTONE_BOX);
    layout.setWidth("100%");

    final LabelLink milestoneLink = new LabelLink(milestone.getName(),
            ProjectLinkBuilder.generateMilestonePreviewFullLink(milestone.getProjectid(), milestone.getId()));
    milestoneLink.setStyleName("link");
    milestoneLink.addStyleName("bold");
    milestoneLink.addStyleName(UIConstants.WORD_WRAP);
    milestoneLink.addStyleName("milestone-name");
    milestoneLink.setWidth("100%");

    MHorizontalLayout milestoneHeader = new MHorizontalLayout().withWidth("100%").with(milestoneLink)
            .expand(milestoneLink);// w  w w .j a  v  a2  s  .  c  o  m

    PopupButton taskSettingPopupBtn = new PopupButton();
    taskSettingPopupBtn.setWidth("20px");
    MVerticalLayout filterBtnLayout = new MVerticalLayout().withWidth("100px");

    Button editButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    EventBusFactory.getInstance()
                            .post(new MilestoneEvent.GotoEdit(MilestoneListViewImpl.this, milestone));
                }
            });
    editButton.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES));
    editButton.setStyleName("link");
    filterBtnLayout.addComponent(editButton);

    Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    ConfirmDialogExt.show(UI.getCurrent(),
                            AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                    SiteConfiguration.getSiteName()),
                            AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                            AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                            AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                                private static final long serialVersionUID = 1L;

                                @Override
                                public void onClose(ConfirmDialog dialog) {
                                    if (dialog.isConfirmed()) {
                                        MilestoneService projectTaskService = ApplicationContextUtil
                                                .getSpringBean(MilestoneService.class);
                                        projectTaskService.removeWithSession(milestone.getId(),
                                                AppContext.getUsername(), AppContext.getAccountId());
                                        milestones.remove(milestone);
                                        displayMilestones(milestones);
                                    }
                                }
                            });
                }
            });
    deleteBtn.setStyleName("link");
    deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MILESTONES));
    filterBtnLayout.addComponent(deleteBtn);

    taskSettingPopupBtn.setIcon(FontAwesome.COG);
    taskSettingPopupBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
    taskSettingPopupBtn.setContent(filterBtnLayout);

    milestoneHeader.addComponent(taskSettingPopupBtn);
    layout.addComponent(milestoneHeader);

    MHorizontalLayout spacing = new MHorizontalLayout().withHeight("8px").withWidth("100%");
    layout.addComponent(spacing);

    final GridFormLayoutHelper layoutHelper = new GridFormLayoutHelper(1, 5, "100%", "80px");
    layoutHelper.addComponent(
            new Label(AppContext.formatDate(milestone.getStartdate(),
                    AppContext.getMessage(GenericI18Enum.FORM_EMPTY))),
            AppContext.getMessage(MilestoneI18nEnum.FORM_START_DATE_FIELD), 0, 0, Alignment.MIDDLE_LEFT);
    layoutHelper.addComponent(
            new Label(AppContext.formatDate(milestone.getEnddate(),
                    AppContext.getMessage(GenericI18Enum.FORM_EMPTY))),
            AppContext.getMessage(MilestoneI18nEnum.FORM_END_DATE_FIELD), 0, 1, Alignment.MIDDLE_LEFT);

    CssLayout linkWrapper = new CssLayout();
    linkWrapper.setWidth("100%");
    linkWrapper.addComponent(new ProjectUserLink(milestone.getOwner(), milestone.getOwnerAvatarId(),
            milestone.getOwnerFullName(), false, true));
    layoutHelper.addComponent(linkWrapper, AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE), 0, 2,
            Alignment.MIDDLE_LEFT);

    final ProgressBarIndicator progressTask = new ProgressBarIndicator(milestone.getNumTasks(),
            milestone.getNumOpenTasks());
    progressTask.setWidth("100%");

    layoutHelper.addComponent(progressTask, AppContext.getMessage(MilestoneI18nEnum.FORM_TASK_FIELD), 0, 3,
            Alignment.MIDDLE_LEFT);

    final ProgressBarIndicator progressBug = new ProgressBarIndicator(milestone.getNumBugs(),
            milestone.getNumOpenBugs());
    progressBug.setWidth("100%");

    layoutHelper.addComponent(progressBug, AppContext.getMessage(MilestoneI18nEnum.FORM_BUG_FIELD), 0, 4,
            Alignment.MIDDLE_LEFT);
    final GridLayout milestoneInfoLayout = layoutHelper.getLayout();
    milestoneInfoLayout.setWidth("100%");
    milestoneInfoLayout.setMargin(false);
    milestoneInfoLayout.setSpacing(true);
    layout.addComponent(milestoneInfoLayout);

    return layout;
}

From source file:com.esofthead.mycollab.module.project.view.user.ProjectInfoComponent.java

License:Open Source License

public ProjectInfoComponent(final SimpleProject project) {
    this.withMargin(true).withStyleName("project-info").withFullWidth();
    Component projectIcon = ProjectAssetsUtil.buildProjectLogo(project.getShortname(), project.getId(),
            project.getAvatarid(), 64);// www  . j  a  v  a 2  s . c o  m
    this.with(projectIcon).withAlign(projectIcon, Alignment.TOP_LEFT);
    ELabel headerLbl = ELabel.h2(project.getName());
    headerLbl.setDescription(ProjectTooltipGenerator.generateToolTipProject(AppContext.getUserLocale(),
            AppContext.getDateFormat(), project, AppContext.getSiteUrl(), AppContext.getUserTimeZone()));
    headerLbl.addStyleName(UIConstants.TEXT_ELLIPSIS);
    MVerticalLayout headerLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, false, true));

    MHorizontalLayout footer = new MHorizontalLayout();
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    footer.addStyleName(UIConstants.META_INFO);
    footer.addStyleName(UIConstants.FLEX_DISPLAY);

    ELabel createdTimeLbl = new ELabel(
            FontAwesome.CLOCK_O.getHtml() + " " + AppContext.formatPrettyTime(project.getCreatedtime()),
            ContentMode.HTML).withDescription(AppContext.getMessage(GenericI18Enum.FORM_CREATED_TIME))
                    .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
    footer.addComponents(createdTimeLbl);

    billableHoursLbl = new ELabel(
            FontAwesome.MONEY.getHtml() + " " + NumberUtils.roundDouble(2, project.getTotalBillableHours()),
            ContentMode.HTML).withDescription(AppContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS))
                    .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
    footer.addComponents(billableHoursLbl);

    nonBillableHoursLbl = new ELabel(FontAwesome.GIFT.getHtml() + " " + project.getTotalNonBillableHours(),
            ContentMode.HTML)
                    .withDescription(AppContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS))
                    .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
    footer.addComponents(nonBillableHoursLbl);

    if (project.getLead() != null) {
        Div leadAvatar = new DivLessFormatter()
                .appendChild(
                        new Img("", StorageFactory.getInstance().getAvatarPath(project.getLeadAvatarId(), 16)),
                        DivLessFormatter.EMPTY_SPACE(),
                        new A(ProjectLinkBuilder.generateProjectMemberFullLink(project.getId(),
                                project.getLead()))
                                        .appendText(StringUtils.trim(project.getLeadFullName(), 30, true)))
                .setTitle(project.getLeadFullName());
        ELabel leadLbl = new ELabel("Lead: " + leadAvatar.write(), ContentMode.HTML).withWidthUndefined();
        footer.addComponents(leadLbl);
    }
    if (project.getHomepage() != null) {
        ELabel homepageLbl = new ELabel(FontAwesome.WECHAT.getHtml() + " "
                + new A(project.getHomepage()).appendText(project.getHomepage()).setTarget("_blank").write(),
                ContentMode.HTML).withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
        homepageLbl.setDescription(AppContext.getMessage(ProjectI18nEnum.FORM_HOME_PAGE));
    }

    if (project.getNumActiveMembers() > 0) {
        ELabel activeMembersLbl = new ELabel(FontAwesome.USERS.getHtml() + " " + project.getNumActiveMembers(),
                ContentMode.HTML).withDescription("Active members").withStyleName(ValoTheme.LABEL_SMALL)
                        .withWidthUndefined();
        footer.addComponents(activeMembersLbl);
    }

    if (project.getAccountid() != null && !SiteConfiguration.isCommunityEdition()) {
        Div clientDiv = new Div();
        if (project.getClientAvatarId() == null) {
            clientDiv.appendText(FontAwesome.INSTITUTION.getHtml() + " ");
        } else {
            Img clientImg = new Img("", StorageFactory.getInstance()
                    .getEntityLogoPath(AppContext.getAccountId(), project.getClientAvatarId(), 16));
            clientDiv.appendChild(clientImg).appendChild(DivLessFormatter.EMPTY_SPACE());
        }
        clientDiv.appendChild(new A(ProjectLinkBuilder.generateClientPreviewFullLink(project.getAccountid()))
                .appendText(project.getClientName()));
        ELabel accountBtn = new ELabel(clientDiv.write(), ContentMode.HTML)
                .withStyleName(UIConstants.BUTTON_BLOCK).withWidthUndefined();
        footer.addComponents(accountBtn);
    }

    if (!SiteConfiguration.isCommunityEdition()) {
        Button tagBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TAG),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoTagListView(this, null));
                    }
                });
        tagBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
        tagBtn.addStyleName(UIConstants.BUTTON_ACTION);
        tagBtn.setDescription("Tag management");
        tagBtn.setIcon(FontAwesome.TAGS);
        footer.addComponents(tagBtn);

        Button favoriteBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_FAVORITES),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoFavoriteView(this, null));
                    }
                });
        favoriteBtn.setCaptionAsHtml(true);
        favoriteBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
        favoriteBtn.addStyleName(UIConstants.BUTTON_ACTION);
        favoriteBtn.setIcon(FontAwesome.STAR);
        favoriteBtn.setDescription("Your favorite list");
        footer.addComponents(favoriteBtn);

        Button eventBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_CALENDAR),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoCalendarView(this));
                    }
                });
        eventBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
        eventBtn.addStyleName(UIConstants.BUTTON_ACTION);
        eventBtn.setIcon(FontAwesome.CALENDAR);
        eventBtn.setDescription("Calendar");
        footer.addComponents(eventBtn);

        Button ganttChartBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_GANTT_CHART),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoGanttChart(this, null));
                    }
                });
        ganttChartBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
        ganttChartBtn.addStyleName(UIConstants.BUTTON_ACTION);
        ganttChartBtn.setIcon(FontAwesome.BAR_CHART_O);
        ganttChartBtn.setDescription("Gantt chart");
        footer.addComponents(ganttChartBtn);
    }

    headerLayout.with(headerLbl, footer);

    MHorizontalLayout topPanel = new MHorizontalLayout().withMargin(false);
    this.with(headerLayout, topPanel).expand(headerLayout).withAlign(topPanel, Alignment.TOP_RIGHT);

    if (project.isProjectArchived()) {
        Button activeProjectBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECT),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        ProjectService projectService = AppContextUtil.getSpringBean(ProjectService.class);
                        project.setProjectstatus(OptionI18nEnum.StatusI18nEnum.Open.name());
                        projectService.updateSelectiveWithSession(project, AppContext.getUsername());

                        PageActionChain chain = new PageActionChain(
                                new ProjectScreenData.Goto(CurrentProjectVariables.getProjectId()));
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoMyProject(this, chain));

                    }
                });
        activeProjectBtn.setStyleName(UIConstants.BUTTON_ACTION);
        topPanel.with(activeProjectBtn).withAlign(activeProjectBtn, Alignment.MIDDLE_RIGHT);
    } else {
        SearchTextField searchField = new SearchTextField() {
            public void doSearch(String value) {
                ProjectView prjView = UIUtils.getRoot(this, ProjectView.class);
                if (prjView != null) {
                    prjView.displaySearchResult(value);
                }
            }

            @Override
            public void emptySearch() {

            }
        };

        final PopupButton controlsBtn = new PopupButton();
        controlsBtn.addStyleName(UIConstants.BOX);
        controlsBtn.setIcon(FontAwesome.ELLIPSIS_H);

        OptionPopupContent popupButtonsControl = new OptionPopupContent();

        Button createPhaseBtn = new Button(AppContext.getMessage(MilestoneI18nEnum.NEW),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance()
                                .post(new MilestoneEvent.GotoAdd(ProjectInfoComponent.this, null));
                    }
                });
        createPhaseBtn
                .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES));
        createPhaseBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.MILESTONE));
        popupButtonsControl.addOption(createPhaseBtn);

        Button createTaskBtn = new Button(AppContext.getMessage(TaskI18nEnum.NEW), new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                controlsBtn.setPopupVisible(false);
                EventBusFactory.getInstance().post(new TaskEvent.GotoAdd(ProjectInfoComponent.this, null));
            }
        });
        createTaskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
        createTaskBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK));
        popupButtonsControl.addOption(createTaskBtn);

        Button createBugBtn = new Button(AppContext.getMessage(BugI18nEnum.NEW), new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                controlsBtn.setPopupVisible(false);
                EventBusFactory.getInstance().post(new BugEvent.GotoAdd(this, null));
            }
        });
        createBugBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS));
        createBugBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG));
        popupButtonsControl.addOption(createBugBtn);

        Button createComponentBtn = new Button(AppContext.getMessage(ComponentI18nEnum.NEW),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance().post(new BugComponentEvent.GotoAdd(this, null));
                    }
                });
        createComponentBtn
                .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.COMPONENTS));
        createComponentBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG_COMPONENT));
        popupButtonsControl.addOption(createComponentBtn);

        Button createVersionBtn = new Button(AppContext.getMessage(VersionI18nEnum.NEW),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance().post(new BugVersionEvent.GotoAdd(this, null));
                    }
                });
        createVersionBtn
                .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.VERSIONS));
        createVersionBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG_VERSION));
        popupButtonsControl.addOption(createVersionBtn);

        if (!SiteConfiguration.isCommunityEdition()) {
            Button createRiskBtn = new Button(AppContext.getMessage(RiskI18nEnum.NEW),
                    new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            controlsBtn.setPopupVisible(false);
                            EventBusFactory.getInstance().post(new RiskEvent.GotoAdd(this, null));
                        }
                    });
            createRiskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.RISKS));
            createRiskBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.RISK));
            popupButtonsControl.addOption(createRiskBtn);
        }

        popupButtonsControl.addSeparator();
        Button inviteMemberBtn = new Button(AppContext.getMessage(ProjectMemberI18nEnum.BUTTON_NEW_INVITEES),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance()
                                .post(new ProjectMemberEvent.GotoInviteMembers(this, null));
                    }
                });
        inviteMemberBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS));
        inviteMemberBtn.setIcon(FontAwesome.SEND);
        popupButtonsControl.addOption(inviteMemberBtn);

        Button settingBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_SETTINGS),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance().post(new ProjectNotificationEvent.GotoList(this, null));
                    }
                });
        settingBtn.setIcon(FontAwesome.COG);
        popupButtonsControl.addOption(settingBtn);

        popupButtonsControl.addSeparator();

        final Button markProjectTemplateBtn = new Button();
        markProjectTemplateBtn.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
                Boolean isTemplate = !MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE);
                project.setIstemplate(isTemplate);
                ProjectService prjService = AppContextUtil.getSpringBean(ProjectService.class);
                prjService.updateWithSession(project, AppContext.getUsername());
                if (project.getIstemplate()) {
                    markProjectTemplateBtn
                            .setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE));
                } else {
                    markProjectTemplateBtn
                            .setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE));
                }
            }
        });
        markProjectTemplateBtn.setIcon(FontAwesome.STICKY_NOTE);
        Boolean isTemplate = MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE);
        if (isTemplate) {
            markProjectTemplateBtn.setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE));
        } else {
            markProjectTemplateBtn.setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE));
        }
        markProjectTemplateBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.CREATE_NEW_PROJECT));
        popupButtonsControl.addOption(markProjectTemplateBtn);

        Button editProjectBtn = new Button(AppContext.getMessage(ProjectI18nEnum.EDIT),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance()
                                .post(new ProjectEvent.GotoEdit(ProjectInfoComponent.this, project));
                    }
                });
        editProjectBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROJECT));
        editProjectBtn.setIcon(FontAwesome.EDIT);
        popupButtonsControl.addOption(editProjectBtn);

        Button archiveProjectBtn = new Button(
                AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECT),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        ConfirmDialogExt.show(UI.getCurrent(),
                                AppContext.getMessage(GenericI18Enum.WINDOW_WARNING_TITLE,
                                        AppContext.getSiteName()),
                                AppContext.getMessage(
                                        ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_ARCHIVE_MESSAGE),
                                AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                                AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                                    private static final long serialVersionUID = 1L;

                                    @Override
                                    public void onClose(ConfirmDialog dialog) {
                                        if (dialog.isConfirmed()) {
                                            ProjectService projectService = AppContextUtil
                                                    .getSpringBean(ProjectService.class);
                                            project.setProjectstatus(
                                                    OptionI18nEnum.StatusI18nEnum.Archived.name());
                                            projectService.updateSelectiveWithSession(project,
                                                    AppContext.getUsername());

                                            PageActionChain chain = new PageActionChain(
                                                    new ProjectScreenData.Goto(
                                                            CurrentProjectVariables.getProjectId()));
                                            EventBusFactory.getInstance()
                                                    .post(new ProjectEvent.GotoMyProject(this, chain));
                                        }
                                    }
                                });
                    }
                });
        archiveProjectBtn
                .setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT));
        archiveProjectBtn.setIcon(FontAwesome.ARCHIVE);
        popupButtonsControl.addOption(archiveProjectBtn);

        if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) {
            popupButtonsControl.addSeparator();
            Button deleteProjectBtn = new Button(
                    AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_DELETE_PROJECT),
                    new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            controlsBtn.setPopupVisible(false);
                            ConfirmDialogExt.show(UI.getCurrent(),
                                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                            AppContext.getSiteName()),
                                    AppContext.getMessage(
                                            ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_DELETE_MESSAGE),
                                    AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                                    AppContext.getMessage(GenericI18Enum.BUTTON_NO),
                                    new ConfirmDialog.Listener() {
                                        private static final long serialVersionUID = 1L;

                                        @Override
                                        public void onClose(ConfirmDialog dialog) {
                                            if (dialog.isConfirmed()) {
                                                ProjectService projectService = AppContextUtil
                                                        .getSpringBean(ProjectService.class);
                                                projectService.removeWithSession(
                                                        CurrentProjectVariables.getProject(),
                                                        AppContext.getUsername(), AppContext.getAccountId());
                                                EventBusFactory.getInstance()
                                                        .post(new ShellEvent.GotoProjectModule(this, null));
                                            }
                                        }
                                    });
                        }
                    });
            deleteProjectBtn
                    .setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT));
            deleteProjectBtn.setIcon(FontAwesome.TRASH_O);
            popupButtonsControl.addDangerOption(deleteProjectBtn);
        }

        controlsBtn.setContent(popupButtonsControl);
        controlsBtn.setWidthUndefined();

        topPanel.with(searchField, controlsBtn).withAlign(searchField, Alignment.TOP_RIGHT)
                .withAlign(controlsBtn, Alignment.TOP_RIGHT);
    }
}

From source file:com.hybridbpm.ui.component.bpm.designer.ElementModelLayout.java

License:Apache License

public void setStyleSelected(boolean selected) {
    button.addStyleName("element-" + (selected ? "selected" : "unselected"));
    if (taskModel.getTaskType().equals(TaskModel.TASK_TYPE.AUTOMATIC)) {
        button.setIcon(FontAwesome.COG);
    } else if (taskModel.getTaskType().equals(TaskModel.TASK_TYPE.HUMAN)) {
        button.setIcon(FontAwesome.USER);
    }/*from  w  ww  .  j av  a 2 s .  c  om*/
}

From source file:com.hybridbpm.ui.component.chart.ChartEditor.java

License:Apache License

public ChartEditor(Module module) {
    super();// w w w .  j a v  a  2s. com
    this.module = HybridbpmUI.getDevelopmentAPI().getModuleById(module.getId());

    if (this.module.getDesign() != null && !this.module.getDesign().isEmpty()) {
        this.diagrammePreference = HybridbpmCoreUtil.jsonToObject(this.module.getDesign(),
                DiagrammePreference.class);
    } else {
        diagrammePreference = DiagrammePreference.createDefault();
    }
    preferences.setItemDataSource(diagrammePreference);

    btnExecute.setIcon(FontAwesome.COG);
    btnExecute.setStyleName(ValoTheme.BUTTON_BORDERLESS);
    btnExecute.addStyleName(ValoTheme.BUTTON_SMALL);

    btnTest.setIcon(FontAwesome.PLAY);
    btnTest.setStyleName(ValoTheme.BUTTON_BORDERLESS);
    btnTest.addStyleName(ValoTheme.BUTTON_SMALL);

    horizontalSplitPanel.addComponents(codeEditorLayout, designEditorLayout);
    horizontalSplitPanel.setSplitPosition(50, Sizeable.Unit.PERCENTAGE);
    buttonBar.addComponent(btnTest, 0);

    table.setSizeFull();
    table.setStyleName(ValoTheme.TABLE_COMPACT);

    queryEditor.setCaption("Request");
    queryEditor.setMode(AceMode.sql);
    queryEditor.setTheme(AceTheme.textmate);
    queryEditor.setShowGutter(true);
    queryEditor.setSizeFull();

    codeEditorLayout.setSizeFull();
    codeEditorLayout.addStyleName("code");
    codeEditorLayout.setMargin(new MarginInfo(false, false, false, true));
    codeEditorLayout.setSpacing(true);
    codeEditorLayout.setExpandRatio(queryEditor, 1f);
    codeEditorLayout.setExpandRatio(table, 2f);

    for (DiagrammeChartType chartType : DiagrammeChartType.values()) {
        chartTypeGroup.addItem(chartType.toString());
        chartTypeGroup.setItemIcon(chartType, chartType.getIcon());
        chartTypeGroup.setItemCaption(chartType, chartType.getName());
    }
    chartTypeGroup.setStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
    chartTypeGroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);
    chartTypeGroup.setImmediate(true);
    chartTypeGroup.setNullSelectionAllowed(false);
    chartTypeGroup.addValueChangeListener(this);
    addComponent(chartTypeGroup, 1);

    designEditorLayout.setSizeFull();
    designEditorLayout.addStyleName("template");
    designEditorLayout.setMargin(new MarginInfo(false, true, false, true));
    designEditorLayout.setSpacing(true);

    preferences.bind(queryEditor, DiagrammePreference.QUERY);
    preferences.bind(chartTypeGroup, DiagrammePreference.CHART_TYPE);
    refreshChartConfigurationLayout();
}

From source file:com.lst.deploymentautomation.vaadin.core.AppLayout.java

License:Open Source License

private void initLayout() {
    addStyleName("app-layout");
    setSizeFull();//ww w  . j a v a  2 s.  co  m

    //main page layout
    layout = new CustomLayout("page");
    layout.setSizeFull();
    setCompositionRoot(layout);

    //navigation menu
    VerticalLayout navLayout = new VerticalLayout();
    navLayout.setSizeFull();
    layout.addComponent(navLayout, "usermenu");
    navigation = new NavigationMenu();
    navigation.addStyleName("navigation-menu");
    layout.addComponent(navigation, "navigation");

    final UserInfo user = ((LspsUI) UI.getCurrent()).getUser();
    LspsUI ui = (LspsUI) UI.getCurrent();

    if (user.hasRight(HumanRights.READ_ALL_TODO) || user.hasRight(HumanRights.READ_OWN_TODO)) {
        addViewItem(navigation, TodoListView.TITLE, TodoListView.ID, FontAwesome.LIST);
    }
    /*if (user.hasRight(HumanRights.ACCESS_DOCUMENTS)) {
       addViewItem(navigation, DocumentsView.TITLE, DocumentsView.ID, FontAwesome.FILE_TEXT_O);
    }
    if (user.hasRight(EngineRights.READ_MODEL) && user.hasRight(EngineRights.CREATE_MODEL_INSTANCE)) {
       addViewItem(navigation, RunModelView.TITLE, RunModelView.ID, FontAwesome.CARET_SQUARE_O_RIGHT);
    }*/

    addNavigationCommandItem(navigation, "Initialize deployment", new NavigationMenu.OpenDocumentCommand(ui, "",
            "'deployment-automation-ui'::InitiateDeploymentDoc", null), FontAwesome.PLAY);
    addNavigationCommandItem(navigation, "Deployments list",
            new NavigationMenu.OpenDocumentCommand(ui, "", "'deployment-automation-ui'::DeploymentsList", null),
            FontAwesome.LIST_OL);

    //user menu
    userMenu = new NavigationMenu();
    userMenu.addStyleName("navigation-menu");
    navLayout.addComponent(userMenu);

    addViewItem(userMenu, SettingsView.TITLE, SettingsView.ID, FontAwesome.COG);

    NavigationCommand logoutCmd = new LogoutCommand((LspsUI) getUI());
    MenuItem logout = addNavigationCommandItem(userMenu, logoutCmd.getTitle(), logoutCmd,
            FontAwesome.POWER_OFF);
    String fullName = user.getPerson().getFullName();
    logout.setDescription(ui.getMessage("nav.logout", fullName));

    boolean collapsed = user.getSettingBoolean("collapsedMenu", false);

    if (collapsed == true) {
        UI.getCurrent().addStyleName("l-menu-collapsed");
    }

    Button button = new Button("");
    button.addStyleName("l-menu-expander");
    button.addStyleName("link");
    navLayout.addComponent(button);
    button.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            boolean collapsed = user.getSettingBoolean("collapsedMenu", false);
            if (collapsed) {
                UI.getCurrent().removeStyleName("l-menu-collapsed");
            } else {
                UI.getCurrent().addStyleName("l-menu-collapsed");
            }
            user.setSetting("collapsedMenu", !collapsed);
        }
    });
}

From source file:com.mycollab.module.project.view.settings.UserSettingViewImpl.java

License:Open Source License

private void buildComponents() {
    userPresenter = PresenterResolver.getPresenter(ProjectUserPresenter.class);
    myProjectTab.addTab(userPresenter.getView(), UserUIContext.getMessage(ProjectMemberI18nEnum.LIST),
            FontAwesome.USERS);/*w ww .j  a  v a  2s.  c  o m*/

    rolePresenter = PresenterResolver.getPresenter(ProjectRolePresenter.class);
    myProjectTab.addTab(rolePresenter.getView(), UserUIContext.getMessage(ProjectRoleI18nEnum.LIST),
            FontAwesome.USER_MD);

    componentPresenter = PresenterResolver.getPresenter(ComponentPresenter.class);
    myProjectTab.addTab(componentPresenter.getView(), UserUIContext.getMessage(ComponentI18nEnum.LIST),
            ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG_COMPONENT));

    versionPresenter = PresenterResolver.getPresenter(VersionPresenter.class);
    myProjectTab.addTab(versionPresenter.getView(), UserUIContext.getMessage(VersionI18nEnum.LIST),
            ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG_VERSION));

    settingPresenter = PresenterResolver.getPresenter(ProjectSettingPresenter.class);
    myProjectTab.addTab(settingPresenter.getView(),
            UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_SETTINGS), FontAwesome.COG);

    myProjectTab.addSelectedTabChangeListener(new SelectedTabChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            Tab tab = ((TabSheetDecorator) event.getTabSheet()).getSelectedTabInfo();
            String caption = tab.getCaption();
            SimpleProject project = CurrentProjectVariables.getProject();

            if (UserUIContext.getMessage(ProjectMemberI18nEnum.LIST).equals(caption)) {
                ProjectMemberSearchCriteria criteria = new ProjectMemberSearchCriteria();
                criteria.setProjectId(new NumberSearchField(project.getId()));
                criteria.setStatuses(new SetSearchField<>(ProjectMemberStatusConstants.ACTIVE,
                        ProjectMemberStatusConstants.NOT_ACCESS_YET));
                userPresenter.go(UserSettingViewImpl.this, new ScreenData.Search<>(criteria));
            } else if (UserUIContext.getMessage(ProjectRoleI18nEnum.LIST).equals(caption)) {
                ProjectRoleSearchCriteria criteria = new ProjectRoleSearchCriteria();
                criteria.setProjectId(new NumberSearchField(project.getId()));
                rolePresenter.go(UserSettingViewImpl.this, new ProjectRoleScreenData.Search(criteria));
            } else if (UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_SETTINGS).equals(caption)) {
                settingPresenter.go(UserSettingViewImpl.this, null);
            } else if (UserUIContext.getMessage(ComponentI18nEnum.LIST).equals(caption)) {
                componentPresenter.go(UserSettingViewImpl.this, null);
            } else if (UserUIContext.getMessage(VersionI18nEnum.LIST).equals(caption)) {
                versionPresenter.go(UserSettingViewImpl.this, null);
            }
        }
    });

}

From source file:com.mycollab.module.project.view.user.ProjectInfoComponent.java

License:Open Source License

public ProjectInfoComponent(SimpleProject project) {
    this.withMargin(false).withFullWidth();
    Component projectIcon = ProjectAssetsUtil.buildProjectLogo(project.getShortname(), project.getId(),
            project.getAvatarid(), 64);/*from  w  w w.ja v a  2s  . c o m*/
    this.with(projectIcon).withAlign(projectIcon, Alignment.TOP_LEFT);

    ProjectBreadcrumb breadCrumb = ViewManager.getCacheComponent(ProjectBreadcrumb.class);
    breadCrumb.setProject(project);
    MVerticalLayout headerLayout = new MVerticalLayout().withSpacing(false)
            .withMargin(new MarginInfo(false, true, false, true));

    MHorizontalLayout footer = new MHorizontalLayout().withStyleName(UIConstants.META_INFO,
            WebThemes.FLEX_DISPLAY);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    ELabel createdTimeLbl = ELabel
            .html(FontAwesome.CLOCK_O.getHtml() + " "
                    + UserUIContext.formatPrettyTime(project.getCreatedtime()))
            .withDescription(UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME))
            .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
    footer.addComponents(createdTimeLbl);

    billableHoursLbl = ELabel
            .html(FontAwesome.MONEY.getHtml() + " "
                    + NumberUtils.roundDouble(2, project.getTotalBillableHours()))
            .withDescription(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS))
            .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
    footer.addComponents(billableHoursLbl);

    nonBillableHoursLbl = ELabel.html(FontAwesome.GIFT.getHtml() + " " + project.getTotalNonBillableHours())
            .withDescription(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS))
            .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
    footer.addComponents(nonBillableHoursLbl);

    if (project.getLead() != null) {
        Div leadAvatar = new DivLessFormatter()
                .appendChild(new Img("",
                        StorageFactory.getAvatarPath(project.getLeadAvatarId(), 16))
                                .setCSSClass(UIConstants.CIRCLE_BOX),
                        DivLessFormatter.EMPTY_SPACE(),
                        new A(ProjectLinkBuilder.generateProjectMemberFullLink(project.getId(),
                                project.getLead()))
                                        .appendText(StringUtils.trim(project.getLeadFullName(), 30, true)))
                .setTitle(project.getLeadFullName());
        ELabel leadLbl = ELabel
                .html(UserUIContext.getMessage(ProjectI18nEnum.FORM_LEADER) + ": " + leadAvatar.write())
                .withWidthUndefined();
        footer.addComponents(leadLbl);
    }
    if (project.getHomepage() != null) {
        ELabel homepageLbl = ELabel
                .html(FontAwesome.WECHAT.getHtml() + " " + new A(project.getHomepage())
                        .appendText(project.getHomepage()).setTarget("_blank").write())
                .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
        homepageLbl.setDescription(UserUIContext.getMessage(ProjectI18nEnum.FORM_HOME_PAGE));
    }

    if (project.getNumActiveMembers() > 0) {
        ELabel activeMembersLbl = ELabel.html(FontAwesome.USERS.getHtml() + " " + project.getNumActiveMembers())
                .withDescription(UserUIContext.getMessage(ProjectMemberI18nEnum.OPT_ACTIVE_MEMBERS))
                .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
        footer.addComponents(activeMembersLbl);
    }

    if (project.getAccountid() != null && !SiteConfiguration.isCommunityEdition()) {
        Div clientDiv = new Div();
        if (project.getClientAvatarId() == null) {
            clientDiv.appendText(FontAwesome.INSTITUTION.getHtml() + " ");
        } else {
            Img clientImg = new Img("", StorageFactory.getEntityLogoPath(MyCollabUI.getAccountId(),
                    project.getClientAvatarId(), 16)).setCSSClass(UIConstants.CIRCLE_BOX);
            clientDiv.appendChild(clientImg).appendChild(DivLessFormatter.EMPTY_SPACE());
        }
        clientDiv.appendChild(new A(ProjectLinkBuilder.generateClientPreviewFullLink(project.getAccountid()))
                .appendText(StringUtils.trim(project.getClientName(), 30, true)));
        ELabel accountBtn = ELabel.html(clientDiv.write()).withStyleName(WebThemes.BUTTON_LINK)
                .withWidthUndefined();
        footer.addComponents(accountBtn);
    }

    if (!SiteConfiguration.isCommunityEdition()) {
        MButton tagBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_TAG),
                clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoTagListView(this, null)))
                        .withIcon(FontAwesome.TAGS)
                        .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK);
        footer.addComponents(tagBtn);

        MButton favoriteBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_FAVORITES),
                clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoFavoriteView(this, null)))
                        .withIcon(FontAwesome.STAR)
                        .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK);
        footer.addComponents(favoriteBtn);

        MButton eventBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_CALENDAR),
                clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoCalendarView(this)))
                        .withIcon(FontAwesome.CALENDAR)
                        .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK);
        footer.addComponents(eventBtn);

        MButton ganttChartBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_GANTT_CHART),
                clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoGanttChart(this, null)))
                        .withIcon(FontAwesome.BAR_CHART_O)
                        .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK);
        footer.addComponents(ganttChartBtn);
    }

    headerLayout.with(breadCrumb, footer);

    MHorizontalLayout topPanel = new MHorizontalLayout().withMargin(false);
    this.with(headerLayout, topPanel).expand(headerLayout).withAlign(topPanel, Alignment.TOP_RIGHT);

    if (project.isProjectArchived()) {
        MButton activeProjectBtn = new MButton(
                UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECT), clickEvent -> {
                    ProjectService projectService = AppContextUtil.getSpringBean(ProjectService.class);
                    project.setProjectstatus(OptionI18nEnum.StatusI18nEnum.Open.name());
                    projectService.updateSelectiveWithSession(project, UserUIContext.getUsername());

                    PageActionChain chain = new PageActionChain(
                            new ProjectScreenData.Goto(CurrentProjectVariables.getProjectId()));
                    EventBusFactory.getInstance().post(new ProjectEvent.GotoMyProject(this, chain));
                }).withStyleName(WebThemes.BUTTON_ACTION);
        topPanel.with(activeProjectBtn).withAlign(activeProjectBtn, Alignment.MIDDLE_RIGHT);
    } else {
        SearchTextField searchField = new SearchTextField() {
            public void doSearch(String value) {
                ProjectView prjView = UIUtils.getRoot(this, ProjectView.class);
                if (prjView != null) {
                    prjView.displaySearchResult(value);
                }
            }

            @Override
            public void emptySearch() {

            }
        };

        final PopupButton controlsBtn = new PopupButton();
        controlsBtn.addStyleName(WebThemes.BOX);
        controlsBtn.setIcon(FontAwesome.ELLIPSIS_H);

        OptionPopupContent popupButtonsControl = new OptionPopupContent();

        if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS)) {
            MButton inviteMemberBtn = new MButton(
                    UserUIContext.getMessage(ProjectMemberI18nEnum.BUTTON_NEW_INVITEES), clickEvent -> {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance()
                                .post(new ProjectMemberEvent.GotoInviteMembers(this, null));
                    }).withIcon(FontAwesome.SEND);
            popupButtonsControl.addOption(inviteMemberBtn);
        }

        MButton settingBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_SETTINGS),
                clickEvent -> {
                    controlsBtn.setPopupVisible(false);
                    EventBusFactory.getInstance().post(new ProjectNotificationEvent.GotoList(this, null));
                }).withIcon(FontAwesome.COG);
        popupButtonsControl.addOption(settingBtn);

        popupButtonsControl.addSeparator();

        if (UserUIContext.canAccess(RolePermissionCollections.CREATE_NEW_PROJECT)) {
            final MButton markProjectTemplateBtn = new MButton().withIcon(FontAwesome.ANCHOR);
            markProjectTemplateBtn.addClickListener(clickEvent -> {
                Boolean isTemplate = !MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE);
                project.setIstemplate(isTemplate);
                ProjectService prjService = AppContextUtil.getSpringBean(ProjectService.class);
                prjService.updateWithSession(project, UserUIContext.getUsername());
                if (project.getIstemplate()) {
                    markProjectTemplateBtn
                            .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE));
                } else {
                    markProjectTemplateBtn
                            .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE));
                }
            });

            Boolean isTemplate = MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE);
            if (isTemplate) {
                markProjectTemplateBtn
                        .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE));
            } else {
                markProjectTemplateBtn
                        .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE));
            }
            popupButtonsControl.addOption(markProjectTemplateBtn);
        }

        if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROJECT)) {
            MButton editProjectBtn = new MButton(UserUIContext.getMessage(ProjectI18nEnum.EDIT), clickEvent -> {
                controlsBtn.setPopupVisible(false);
                EventBusFactory.getInstance()
                        .post(new ProjectEvent.GotoEdit(ProjectInfoComponent.this, project));
            }).withIcon(FontAwesome.EDIT);
            popupButtonsControl.addOption(editProjectBtn);
        }

        if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) {
            MButton archiveProjectBtn = new MButton(
                    UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECT), clickEvent -> {
                        controlsBtn.setPopupVisible(false);
                        ConfirmDialogExt.show(UI.getCurrent(),
                                UserUIContext.getMessage(GenericI18Enum.WINDOW_WARNING_TITLE,
                                        MyCollabUI.getSiteName()),
                                UserUIContext.getMessage(
                                        ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_ARCHIVE_MESSAGE),
                                UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                                UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                                    if (confirmDialog.isConfirmed()) {
                                        ProjectService projectService = AppContextUtil
                                                .getSpringBean(ProjectService.class);
                                        project.setProjectstatus(OptionI18nEnum.StatusI18nEnum.Archived.name());
                                        projectService.updateSelectiveWithSession(project,
                                                UserUIContext.getUsername());

                                        PageActionChain chain = new PageActionChain(new ProjectScreenData.Goto(
                                                CurrentProjectVariables.getProjectId()));
                                        EventBusFactory.getInstance()
                                                .post(new ProjectEvent.GotoMyProject(this, chain));
                                    }
                                });
                    }).withIcon(FontAwesome.ARCHIVE);
            popupButtonsControl.addOption(archiveProjectBtn);
        }

        if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) {
            popupButtonsControl.addSeparator();
            MButton deleteProjectBtn = new MButton(
                    UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_DELETE_PROJECT), clickEvent -> {
                        controlsBtn.setPopupVisible(false);
                        ConfirmDialogExt.show(UI.getCurrent(),
                                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                        MyCollabUI.getSiteName()),
                                UserUIContext.getMessage(
                                        ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_DELETE_MESSAGE),
                                UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                                UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                                    if (confirmDialog.isConfirmed()) {
                                        ProjectService projectService = AppContextUtil
                                                .getSpringBean(ProjectService.class);
                                        projectService.removeWithSession(CurrentProjectVariables.getProject(),
                                                UserUIContext.getUsername(), MyCollabUI.getAccountId());
                                        EventBusFactory.getInstance()
                                                .post(new ShellEvent.GotoProjectModule(this, null));
                                    }
                                });
                    }).withIcon(FontAwesome.TRASH_O);
            popupButtonsControl.addDangerOption(deleteProjectBtn);
        }

        controlsBtn.setContent(popupButtonsControl);
        controlsBtn.setWidthUndefined();

        topPanel.with(searchField, controlsBtn).withAlign(searchField, Alignment.TOP_RIGHT)
                .withAlign(controlsBtn, Alignment.TOP_RIGHT);
    }
}

From source file:org.balisunrise.vaadin.components.header.Configuration.java

private void init() {
    setStyleName("b-configuration");
    popup = new PopupView(FontAwesome.COG.getHtml(), new VerticalLayout(new Label("Configuration")));

    setCompositionRoot(popup);/*from   w  ww. j a v a  2 s.c om*/
}