Example usage for com.vaadin.server FontAwesome ELLIPSIS_H

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

Introduction

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

Prototype

FontAwesome ELLIPSIS_H

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

Click Source Link

Usage

From source file:com.esofthead.mycollab.module.crm.ui.components.RelatedEditItemField.java

License:Open Source License

public RelatedEditItemField(String[] types, Object bean) {
    this.bean = bean;

    relatedItemComboBox = new RelatedItemComboBox(types);
    itemField = new TextField();
    itemField.setEnabled(true);//from www.  j  ava2  s  . c o m

    browseBtn = new Button(null, FontAwesome.ELLIPSIS_H);
    browseBtn.addStyleName(UIConstants.THEME_GRAY_LINK);
    browseBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            String type = (String) relatedItemComboBox.getValue();
            if ("Account".equals(type)) {
                AccountSelectionWindow accountWindow = new AccountSelectionWindow(RelatedEditItemField.this);
                UI.getCurrent().addWindow(accountWindow);
                accountWindow.show();
            } else if ("Campaign".equals(type)) {
                CampaignSelectionWindow campaignWindow = new CampaignSelectionWindow(RelatedEditItemField.this);
                UI.getCurrent().addWindow(campaignWindow);
                campaignWindow.show();
            } else if ("Contact".equals(type)) {
                ContactSelectionWindow contactWindow = new ContactSelectionWindow(RelatedEditItemField.this);
                UI.getCurrent().addWindow(contactWindow);
                contactWindow.show();
            } else if ("Lead".equals(type)) {
                LeadSelectionWindow leadWindow = new LeadSelectionWindow(RelatedEditItemField.this);
                UI.getCurrent().addWindow(leadWindow);
                leadWindow.show();
            } else if ("Opportunity".equals(type)) {
                OpportunitySelectionWindow opportunityWindow = new OpportunitySelectionWindow(
                        RelatedEditItemField.this);
                UI.getCurrent().addWindow(opportunityWindow);
                opportunityWindow.show();
            } else if ("Case".equals(type)) {
                CaseSelectionWindow caseWindow = new CaseSelectionWindow(RelatedEditItemField.this);
                UI.getCurrent().addWindow(caseWindow);
                caseWindow.show();
            } else {
                relatedItemComboBox.focus();
            }
        }
    });

    clearBtn = new Button(null, FontAwesome.TRASH_O);
    clearBtn.addStyleName(UIConstants.THEME_GRAY_LINK);
    clearBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            try {
                PropertyUtils.setProperty(RelatedEditItemField.this.bean, "typeid", null);
            } catch (Exception e) {
                LOG.error("Error while saving type", e);
            }
        }
    });
}

From source file:com.esofthead.mycollab.module.crm.view.account.AccountSelectionField.java

License:Open Source License

@Override
protected Component initContent() {
    MHorizontalLayout layout = new MHorizontalLayout().withWidth("100%");
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    accountName.setNullRepresentation("");
    accountName.setEnabled(true);/*  w  w w . j av  a2s  . c o  m*/
    accountName.setWidth("100%");

    Button browseBtn = new Button(null, FontAwesome.ELLIPSIS_H);
    browseBtn.addStyleName(UIConstants.THEME_GRAY_LINK);
    browseBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);

    browseBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            AccountSelectionWindow accountWindow = new AccountSelectionWindow(AccountSelectionField.this);
            UI.getCurrent().addWindow(accountWindow);
            accountWindow.show();
        }
    });

    Button clearBtn = new Button(null, FontAwesome.TRASH_O);
    clearBtn.addStyleName(UIConstants.THEME_GRAY_LINK);
    clearBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
    clearBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            clearValue();
        }
    });

    layout.with(accountName, browseBtn, clearBtn).expand(accountName);
    return layout;
}

From source file:com.esofthead.mycollab.module.crm.view.campaign.CampaignSelectionField.java

License:Open Source License

@Override
protected Component initContent() {
    MHorizontalLayout layout = new MHorizontalLayout().withWidth("100%");
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    Button browseBtn = new Button(null, FontAwesome.ELLIPSIS_H);
    browseBtn.addStyleName(UIConstants.THEME_GRAY_LINK);
    browseBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
    browseBtn.addClickListener(new Button.ClickListener() {
        @Override//from   w ww  .  j ava  2  s.  c  om
        public void buttonClick(Button.ClickEvent clickEvent) {
            CampaignSelectionWindow campaignWindow = new CampaignSelectionWindow(CampaignSelectionField.this);
            UI.getCurrent().addWindow(campaignWindow);
            campaignWindow.show();
        }
    });

    Button clearBtn = new Button(null, FontAwesome.TRASH_O);
    clearBtn.addStyleName(UIConstants.THEME_GRAY_LINK);
    clearBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
    clearBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            campaignName.setValue("");
            internalValue = null;
        }
    });

    layout.with(campaignName, browseBtn, clearBtn).expand(campaignName);
    return layout;
}

From source file:com.esofthead.mycollab.module.crm.view.contact.ContactSelectionField.java

License:Open Source License

public ContactSelectionField() {
    contactName = new TextField();
    contactName.setNullRepresentation("");
    contactName.setWidth("100%");
    browseBtn = new Button(null, FontAwesome.ELLIPSIS_H);
    browseBtn.addStyleName(UIConstants.THEME_GRAY_LINK);
    browseBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
    browseBtn.addClickListener(new Button.ClickListener() {
        @Override/*from   www.j  a v a2  s  . c om*/
        public void buttonClick(Button.ClickEvent clickEvent) {
            ContactSelectionWindow contactWindow = new ContactSelectionWindow(ContactSelectionField.this);
            UI.getCurrent().addWindow(contactWindow);
            contactWindow.show();
        }
    });

    clearBtn = new Button(null, FontAwesome.TRASH_O);
    clearBtn.addStyleName(UIConstants.THEME_GRAY_LINK);
    clearBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);

    clearBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            contactName.setValue("");
            contact = null;
        }
    });
}

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

License:Open Source License

@Override
protected Component initContent() {
    MHorizontalLayout layout = new MHorizontalLayout();
    Button browseBtn = new Button(FontAwesome.ELLIPSIS_H);
    browseBtn.addStyleName(UIConstants.BUTTON_OPTION);
    browseBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
    browseBtn.addClickListener(new Button.ClickListener() {
        @Override/*from   w  ww  .j a v  a  2s  . c  om*/
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().addWindow(new BugSelectionWindow(BugSelectionField.this));
        }
    });
    layout.with(suggestField, new Label("or browse"), browseBtn);
    return layout;
}

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

License:Open Source License

@Override
public void initView(final SimpleProject project) {
    this.removeAllComponents();
    updateVerticalTabsheetFixStatus();// ww w  .j av  a2 s . c  om
    ControllerRegistry.addController(new ProjectController(this));
    this.setWidth("100%");

    this.addStyleName("main-content-wrapper");
    this.addStyleName("projectDashboardView");

    myProjectTab = new ProjectVerticalTabsheet();
    myProjectTab.setSizeFull();
    myProjectTab.setNavigatorWidth("100%");
    myProjectTab.setNavigatorStyleName("sidebar-menu");
    myProjectTab.setContainerStyleName("tab-content");

    myProjectTab.addSelectedTabChangeListener(new SelectedTabChangeListener() {

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            Tab tab = ((ProjectVerticalTabsheet) event.getSource()).getSelectedTab();
            String caption = ((TabImpl) tab).getTabId();
            if (ProjectTypeConstants.MESSAGE.equals(caption)) {
                messagePresenter.go(ProjectViewImpl.this, null);
            } else if (ProjectTypeConstants.MILESTONE.equals(caption)) {
                MilestoneSearchCriteria searchCriteria = new MilestoneSearchCriteria();
                searchCriteria.setProjectId(
                        new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProjectId()));
                gotoMilestoneView(new MilestoneScreenData.Search(searchCriteria));
            } else if (ProjectTypeConstants.TASK.equals(caption)) {
                taskPresenter.go(ProjectViewImpl.this, null);
            } else if (ProjectTypeConstants.BUG.equals(caption)) {
                gotoBugView(null);
            } else if (ProjectTypeConstants.RISK.equals(caption)) {
                RiskSearchCriteria searchCriteria = new RiskSearchCriteria();
                searchCriteria.setProjectId(
                        new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProjectId()));
                gotoRiskView(new RiskScreenData.Search(searchCriteria));
            } else if (ProjectTypeConstants.FILE.equals(caption)) {
                filePresenter.go(ProjectViewImpl.this, new FileScreenData.GotoDashboard());
            } else if (ProjectTypeConstants.PAGE.equals(caption)) {
                pagePresenter.go(ProjectViewImpl.this,
                        new PageScreenData.Search(CurrentProjectVariables.getBasePagePath()));
            } else if (ProjectTypeConstants.PROBLEM.equals(caption)) {
                ProblemSearchCriteria searchCriteria = new ProblemSearchCriteria();
                searchCriteria.setProjectId(
                        new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProjectId()));
                problemPresenter.go(ProjectViewImpl.this, new ProblemScreenData.Search(searchCriteria));
            } else if (ProjectTypeConstants.DASHBOARD.equals(caption)) {
                dashboardPresenter.go(ProjectViewImpl.this, null);
            } else if (ProjectTypeConstants.MEMBER.equals(caption)) {
                ProjectMemberSearchCriteria criteria = new ProjectMemberSearchCriteria();
                criteria.setProjectId(new NumberSearchField(CurrentProjectVariables.getProjectId()));
                criteria.setStatus(new StringSearchField(ProjectMemberStatusConstants.ACTIVE));
                gotoUsersAndGroup(new ProjectMemberScreenData.Search(criteria));
            } else if (ProjectTypeConstants.TIME.equals(caption)) {
                ItemTimeLoggingSearchCriteria searchCriteria = new ItemTimeLoggingSearchCriteria();
                searchCriteria.setProjectIds(new SetSearchField<>(CurrentProjectVariables.getProjectId()));
                searchCriteria
                        .setRangeDate(ItemTimeLoggingSearchCriteria.getCurrentRangeDateOfWeekSearchField());
                gotoTimeTrackingView(new TimeTrackingScreenData.Search(searchCriteria));
            } else if (ProjectTypeConstants.STANDUP.equals(caption)) {
                StandupReportSearchCriteria criteria = new StandupReportSearchCriteria();
                criteria.setProjectId(new NumberSearchField(CurrentProjectVariables.getProjectId()));
                criteria.setOnDate(new DateSearchField(SearchField.AND, DateSearchField.EQUAL,
                        new GregorianCalendar().getTime()));
                standupPresenter.go(ProjectViewImpl.this, new StandupScreenData.Search(criteria));
            }

        }
    });

    VerticalLayout contentWrapper = myProjectTab.getContentWrapper();
    contentWrapper.addStyleName("main-content");
    MHorizontalLayout topPanel = new MHorizontalLayout().withSpacing(false).withMargin(true).withWidth("100%")
            .withStyleName("top-panel");
    contentWrapper.addComponentAsFirst(topPanel);

    ProjectListComponent prjList = new ProjectListComponent();
    CssLayout navigatorWrapper = myProjectTab.getNavigatorWrapper();
    navigatorWrapper.addComponentAsFirst(prjList);
    navigatorWrapper.setWidth("250px");

    buildComponents();
    this.addComponent(myProjectTab);

    ProjectBreadcrumb breadCrumb = ViewManager.getCacheComponent(ProjectBreadcrumb.class);
    breadCrumb.setProject(project);

    topPanel.with(breadCrumb).withAlign(breadCrumb, Alignment.MIDDLE_LEFT).expand(breadCrumb);

    if (project.isProjectArchived()) {
        Button activeProjectBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECT),
                new ClickListener() {

                    @Override
                    public void buttonClick(ClickEvent event) {
                        ProjectService projectService = ApplicationContextUtil
                                .getSpringBean(ProjectService.class);
                        project.setProjectstatus(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.THEME_GREEN_LINK);
        topPanel.with(activeProjectBtn).withAlign(activeProjectBtn, Alignment.MIDDLE_RIGHT);
    } else {
        final PopupButton controlsBtn = new PopupButton();
        controlsBtn.setIcon(FontAwesome.ELLIPSIS_H);
        controlsBtn.addStyleName(UIConstants.THEME_BLANK_LINK);

        VerticalLayout popupButtonsControl = new VerticalLayout();
        popupButtonsControl.setSpacing(true);
        popupButtonsControl.setWidth("150px");

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

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

        Button createBugBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_BUG),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(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));
        createBugBtn.setStyleName("link");
        popupButtonsControl.addComponent(createBugBtn);

        Button createRiskBtn = new Button(AppContext.getMessage(RiskI18nEnum.BUTTON_NEW_RISK),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(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));
        createRiskBtn.setStyleName("link");
        popupButtonsControl.addComponent(createRiskBtn);

        Button createProblemBtn = new Button(AppContext.getMessage(ProblemI18nEnum.BUTTON_NEW_PROBLEM),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance().post(new ProblemEvent.GotoAdd(this, null));
                    }
                });
        createProblemBtn
                .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROBLEMS));
        createProblemBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.PROBLEM));
        createProblemBtn.setStyleName("link");
        popupButtonsControl.addComponent(createProblemBtn);

        Button editProjectBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_EDIT_PROJECT),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        dashboardPresenter.go(ProjectViewImpl.this, new ProjectScreenData.Edit(project));
                    }
                });
        editProjectBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROJECT));
        editProjectBtn.setIcon(FontAwesome.EDIT);
        editProjectBtn.setStyleName("link");
        popupButtonsControl.addComponent(editProjectBtn);

        Button archieveProjectBtn = new Button(
                AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECT),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        ConfirmDialogExt.show(UI.getCurrent(),
                                AppContext.getMessage(GenericI18Enum.WINDOW_WARNING_TITLE,
                                        SiteConfiguration.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 = ApplicationContextUtil
                                                    .getSpringBean(ProjectService.class);
                                            project.setProjectstatus(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));
                                        }
                                    }
                                });
                    }
                });
        archieveProjectBtn
                .setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT));
        archieveProjectBtn.setIcon(FontAwesome.ARCHIVE);
        archieveProjectBtn.setStyleName("link");
        popupButtonsControl.addComponent(archieveProjectBtn);

        if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) {
            Button deleteProjectBtn = new Button(
                    AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_DELETE_PROJECT),
                    new Button.ClickListener() {
                        @Override
                        public void buttonClick(ClickEvent event) {
                            controlsBtn.setPopupVisible(false);
                            ConfirmDialogExt.show(UI.getCurrent(),
                                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                            SiteConfiguration.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 = ApplicationContextUtil
                                                        .getSpringBean(ProjectService.class);
                                                projectService.removeWithSession(
                                                        CurrentProjectVariables.getProjectId(),
                                                        AppContext.getUsername(), AppContext.getAccountId());
                                                EventBusFactory.getInstance()
                                                        .post(new ShellEvent.GotoProjectModule(this, null));
                                            }
                                        }
                                    });
                        }
                    });
            deleteProjectBtn
                    .setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT));
            deleteProjectBtn.setIcon(FontAwesome.TRASH_O);
            deleteProjectBtn.setStyleName("link");
            popupButtonsControl.addComponent(deleteProjectBtn);
        }

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

        topPanel.with(controlsBtn).withAlign(controlsBtn, Alignment.MIDDLE_RIGHT);
    }

    prjList.showProjects();
}

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);//w ww  . j a v a2s.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.esofthead.mycollab.module.user.ui.components.PreviewFormControlsGenerator.java

License:Open Source License

public HorizontalLayout createButtonControls(int buttonEnableFlags, String permissionItem) {
    optionBtn = new PopupButton();
    optionBtn.addStyleName(UIConstants.BOX);
    optionBtn.setIcon(FontAwesome.ELLIPSIS_H);

    if (permissionItem != null) {
        boolean canWrite = AppContext.canWrite(permissionItem);
        boolean canAccess = AppContext.canAccess(permissionItem);
        boolean canRead = AppContext.canRead(permissionItem);

        if ((buttonEnableFlags & ADD_BTN_PRESENTED) == ADD_BTN_PRESENTED) {
            Button addBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD),
                    new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            optionBtn.setPopupVisible(false);
                            T item = previewForm.getBean();
                            previewForm.fireAddForm(item);
                        }/*from w w  w. j  av  a  2 s .  c  om*/
                    });
            addBtn.setIcon(FontAwesome.PLUS);
            addBtn.setStyleName(UIConstants.BUTTON_ACTION);
            addBtn.setEnabled(canWrite);
            editButtons.addComponent(addBtn);
        }

        if ((buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) {
            Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT),
                    new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            optionBtn.setPopupVisible(false);
                            T item = previewForm.getBean();
                            previewForm.fireEditForm(item);
                        }
                    });
            editBtn.setIcon(FontAwesome.EDIT);
            editBtn.setStyleName(UIConstants.BUTTON_ACTION);
            editBtn.setEnabled(canWrite);
            editButtons.addComponent(editBtn);
        }

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

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            T item = previewForm.getBean();
                            previewForm.fireDeleteForm(item);
                        }
                    });
            deleteBtn.setIcon(FontAwesome.TRASH_O);
            deleteBtn.setStyleName(UIConstants.BUTTON_DANGER);
            deleteBtn.setEnabled(canAccess);
            editButtons.addComponent(deleteBtn);
        }

        layout.with(editButtons);

        if ((buttonEnableFlags & NAVIGATOR_BTN_PRESENTED) == NAVIGATOR_BTN_PRESENTED) {
            ButtonGroup navigationBtns = new ButtonGroup();
            Button previousItem = new Button(null, new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    T item = previewForm.getBean();
                    previewForm.fireGotoPrevious(item);
                }
            });
            previousItem.setIcon(FontAwesome.CHEVRON_LEFT);
            previousItem.setStyleName(UIConstants.BUTTON_ACTION);
            previousItem.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_PREVIOUS_ITEM));
            previousItem.setEnabled(canRead);
            navigationBtns.addButton(previousItem);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    T item = previewForm.getBean();
                    previewForm.fireGotoNextItem(item);
                }
            });
            nextItemBtn.setIcon(FontAwesome.CHEVRON_RIGHT);
            nextItemBtn.setStyleName(UIConstants.BUTTON_ACTION);
            nextItemBtn.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_NEXT_ITEM));
            nextItemBtn.setEnabled(canRead);
            navigationBtns.addButton(nextItemBtn);
            layout.with(navigationBtns);
        }

        if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED) {
            Button cloneBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLONE),
                    new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            optionBtn.setPopupVisible(false);
                            T item = previewForm.getBean();
                            previewForm.fireCloneForm(item);
                        }
                    });
            cloneBtn.setIcon(FontAwesome.ROAD);
            cloneBtn.setEnabled(canWrite);
            popupButtonsControl.addOption(cloneBtn);
        }

        if (popupButtonsControl.getComponentCount() > 0) {
            optionBtn.setContent(popupButtonsControl);
            layout.with(optionBtn);
        }
    }
    return layout;
}

From source file:com.esofthead.mycollab.vaadin.web.ui.ProjectPreviewFormControlsGenerator.java

License:Open Source License

public HorizontalLayout createButtonControls(int buttonEnableFlags, String permissionItem) {
    optionBtn = new PopupButton();
    optionBtn.addStyleName(UIConstants.BOX);
    optionBtn.setIcon(FontAwesome.ELLIPSIS_H);

    if (permissionItem != null) {
        boolean canWrite = CurrentProjectVariables.canWrite(permissionItem);
        boolean canAccess = CurrentProjectVariables.canAccess(permissionItem);
        boolean canRead = CurrentProjectVariables.canRead(permissionItem);

        if ((buttonEnableFlags & ASSIGN_BTN_PRESENTED) == ASSIGN_BTN_PRESENTED) {
            Button assignBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ASSIGN),
                    new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            T item = previewForm.getBean();
                            previewForm.fireAssignForm(item);
                        }/*from  w ww  .  j av  a  2s  . c  o  m*/
                    });
            assignBtn.setIcon(FontAwesome.SHARE);
            assignBtn.setStyleName(UIConstants.BUTTON_ACTION);
            editButtons.addComponent(assignBtn);
            assignBtn.setEnabled(canWrite);
        }

        if ((buttonEnableFlags & ADD_BTN_PRESENTED) == ADD_BTN_PRESENTED) {
            Button addBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD),
                    new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            optionBtn.setPopupVisible(false);
                            T item = previewForm.getBean();
                            previewForm.fireAddForm(item);
                        }
                    });
            addBtn.setIcon(FontAwesome.PLUS);
            addBtn.setStyleName(UIConstants.BUTTON_ACTION);
            addBtn.setEnabled(canWrite);
            editButtons.addComponent(addBtn);
        }

        if ((buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) {
            Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT),
                    new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            optionBtn.setPopupVisible(false);
                            T item = previewForm.getBean();
                            previewForm.fireEditForm(item);
                        }
                    });
            editBtn.setIcon(FontAwesome.EDIT);
            editBtn.setStyleName(UIConstants.BUTTON_ACTION);
            editBtn.setEnabled(canWrite);
            editButtons.addComponent(editBtn);
        }

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

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            T item = previewForm.getBean();
                            previewForm.fireDeleteForm(item);
                        }
                    });
            deleteBtn.setIcon(FontAwesome.TRASH_O);
            deleteBtn.setStyleName(UIConstants.BUTTON_DANGER);
            deleteBtn.setEnabled(canAccess);
            editButtons.addComponent(deleteBtn);
        }

        if ((buttonEnableFlags & PRINT_BTN_PRESENTED) == PRINT_BTN_PRESENTED) {
            final PrintButton printBtn = new PrintButton();
            printBtn.addClickListener(new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    T item = previewForm.getBean();
                    previewForm.firePrintForm(printBtn, item);
                }
            });
            printBtn.setStyleName(UIConstants.BUTTON_OPTION);
            printBtn.setDescription(AppContext.getMessage(GenericI18Enum.ACTION_PRINT));
            printBtn.setEnabled(canRead);
            editButtons.addComponent(printBtn);
        }

        if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED) {
            Button cloneBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLONE),
                    new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            optionBtn.setPopupVisible(false);
                            T item = previewForm.getBean();
                            previewForm.fireCloneForm(item);
                        }
                    });
            cloneBtn.setIcon(FontAwesome.ROAD);
            cloneBtn.setEnabled(canWrite);
            popupButtonsControl.addOption(cloneBtn);
        }

        layout.with(editButtons);

        if ((buttonEnableFlags & NAVIGATOR_BTN_PRESENTED) == NAVIGATOR_BTN_PRESENTED) {
            ButtonGroup navigationBtns = new ButtonGroup();
            Button previousItem = new Button(null, new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    T item = previewForm.getBean();
                    previewForm.fireGotoPrevious(item);
                }
            });
            previousItem.setIcon(FontAwesome.CHEVRON_LEFT);
            previousItem.setCaptionAsHtml(true);
            previousItem.setStyleName(UIConstants.BUTTON_OPTION);
            previousItem.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_PREVIOUS_ITEM));
            previousItem.setEnabled(canRead);
            navigationBtns.addButton(previousItem);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    T item = previewForm.getBean();
                    previewForm.fireGotoNextItem(item);
                }
            });
            nextItemBtn.setIcon(FontAwesome.CHEVRON_RIGHT);
            nextItemBtn.setStyleName(UIConstants.BUTTON_OPTION);
            nextItemBtn.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_NEXT_ITEM));
            nextItemBtn.setEnabled(canRead);
            navigationBtns.addButton(nextItemBtn);

            layout.addComponent(navigationBtns);
        }

        if (popupButtonsControl.getComponentCount() > 0) {
            optionBtn.setContent(popupButtonsControl);
            layout.addComponent(optionBtn);
        }
    }

    return layout;
}

From source file:com.mycollab.module.crm.ui.components.CrmPreviewFormControlsGenerator.java

License:Open Source License

public CrmPreviewFormControlsGenerator(AdvancedPreviewBeanForm<T> editForm) {
    this.previewForm = editForm;
    layout = new MHorizontalLayout();

    optionBtn = new PopupButton();
    optionBtn.addStyleName(WebThemes.BUTTON_OPTION);
    optionBtn.setIcon(FontAwesome.ELLIPSIS_H);
}