Example usage for com.vaadin.ui Button setStyleName

List of usage examples for com.vaadin.ui Button setStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui Button setStyleName.

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

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

License:Open Source License

public TaskSearchViewImpl() {
    this.withMargin(new MarginInfo(false, true, true, true));

    MVerticalLayout taskListLayout = new MVerticalLayout().withSpacing(false);
    with(taskListLayout);//  ww w  . j a v  a2  s  .c  om

    this.taskSearchPanel = new TaskSearchPanel();
    this.generateDisplayTable();

    final MHorizontalLayout header = new MHorizontalLayout().withStyleName(UIConstants.HEADER_VIEW)
            .withWidth("100%");

    headerText = new Label(ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK).getHtml(),
            ContentMode.HTML);
    headerText.setSizeUndefined();
    headerText.setStyleName(UIConstants.HEADER_TEXT);

    Button backBtn = new Button(AppContext.getMessage(TaskI18nEnum.BUTTON_BACK_TO_DASHBOARD),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    EventBusFactory.getInstance().post(new TaskListEvent.GotoTaskListScreen(this, null));

                }
            });
    backBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    backBtn.setIcon(FontAwesome.ARROW_LEFT);

    header.with(headerText, backBtn).withAlign(headerText, Alignment.MIDDLE_LEFT)
            .withAlign(backBtn, Alignment.MIDDLE_RIGHT).expand(headerText);

    taskListLayout.with(header, taskSearchPanel, tableItem);
}

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

License:Open Source License

public TaskTableDisplay(TableViewField requiredColumn, List<TableViewField> displayColumns, int displayNums) {
    super(ApplicationContextUtil.getSpringBean(ProjectTaskService.class), SimpleTask.class, requiredColumn,
            displayColumns);//from   w w w.  j av a  2 s .  co m
    this.displayNumItems = displayNums;

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId);

            CssLayout taskName = new CssLayout();

            String taskname = "[%s-%s] %s";
            taskname = String.format(taskname, CurrentProjectVariables.getProject().getShortname(),
                    task.getTaskkey(), task.getTaskname());

            LabelLink b = new LabelLink(taskname, ProjectLinkBuilder
                    .generateTaskPreviewFullLink(task.getTaskkey(), task.getProjectShortname()));
            b.setDescription(ProjectTooltipGenerator.generateToolTipTask(AppContext.getUserLocale(), task,
                    AppContext.getSiteUrl(), AppContext.getTimezone()));

            if (StringUtils.isNotBlank(task.getPriority())) {
                b.setIconLink(ProjectResources.getIconResourceLink12ByTaskPriority(task.getPriority()));

            }

            if (task.isCompleted()) {
                b.addStyleName(UIConstants.LINK_COMPLETED);
            } else if (task.isPending()) {
                b.addStyleName(UIConstants.LINK_PENDING);
            } else if (task.isOverdue()) {
                b.addStyleName(UIConstants.LINK_OVERDUE);
            }

            taskName.addComponent(b);
            taskName.setWidth("100%");
            taskName.setHeightUndefined();
            return taskName;

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId);
            Double percomp = (task.getPercentagecomplete() == null) ? new Double(0)
                    : task.getPercentagecomplete();
            ProgressPercentageIndicator progress = new ProgressPercentageIndicator(percomp);
            progress.setWidth("100px");
            return progress;
        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(task.getStartdate()));

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(task.getDeadline()));

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId);
            PopupButton taskSettingPopupBtn = new PopupButton();
            taskSettingPopupBtn.setIcon(MyCollabResource.newResource("icons/16/item_settings.png"));
            taskSettingPopupBtn.setStyleName("link");
            taskSettingPopupBtn.addStyleName("noDefaultIcon");

            MVerticalLayout filterBtnLayout = new MVerticalLayout().withSpacing(true).withMargin(true)
                    .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 TaskEvent.GotoEdit(TaskTableDisplay.this, task));
                        }
                    });
            editButton.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
            editButton.setStyleName("link");
            filterBtnLayout.addComponent(editButton);

            if ((task.getPercentagecomplete() != null && task.getPercentagecomplete() != 100)
                    || task.getPercentagecomplete() == null) {
                Button closeBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLOSE),
                        new Button.ClickListener() {
                            private static final long serialVersionUID = 1L;

                            @Override
                            public void buttonClick(Button.ClickEvent event) {
                                task.setStatus(StatusI18nEnum.Closed.name());
                                task.setPercentagecomplete(100d);

                                ProjectTaskService projectTaskService = ApplicationContextUtil
                                        .getSpringBean(ProjectTaskService.class);
                                projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername());

                                fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "closeTask"));
                            }
                        });
                closeBtn.setStyleName("link");
                closeBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
                filterBtnLayout.addComponent(closeBtn);
            } else {
                Button reOpenBtn = new Button("ReOpen", new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        task.setStatus(StatusI18nEnum.Open.name());
                        task.setPercentagecomplete(0d);

                        ProjectTaskService projectTaskService = ApplicationContextUtil
                                .getSpringBean(ProjectTaskService.class);
                        projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername());
                        fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "reopenTask"));
                    }
                });
                reOpenBtn.setStyleName("link");
                reOpenBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
                filterBtnLayout.addComponent(reOpenBtn);
            }

            if (!"Pending".equals(task.getStatus())) {
                if (!"Closed".equals(task.getStatus())) {
                    Button pendingBtn = new Button("Pending", new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(ClickEvent event) {
                            task.setStatus("Pending");
                            task.setPercentagecomplete(0d);

                            ProjectTaskService projectTaskService = ApplicationContextUtil
                                    .getSpringBean(ProjectTaskService.class);
                            projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername());
                            fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "pendingTask"));
                        }
                    });
                    pendingBtn.setStyleName("link");
                    pendingBtn.setEnabled(
                            CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
                    filterBtnLayout.addComponent(pendingBtn);
                }
            } else {
                Button reOpenBtn = new Button("ReOpen", new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        task.setStatus("Open");
                        task.setPercentagecomplete(0d);

                        ProjectTaskService projectTaskService = ApplicationContextUtil
                                .getSpringBean(ProjectTaskService.class);
                        projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername());

                        fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "reopenTask"));
                    }
                });
                reOpenBtn.setStyleName("link");
                reOpenBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
                filterBtnLayout.addComponent(reOpenBtn);
            }

            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()) {
                                                ProjectTaskService projectTaskService = ApplicationContextUtil
                                                        .getSpringBean(ProjectTaskService.class);
                                                projectTaskService.removeWithSession(task.getId(),
                                                        AppContext.getUsername(), AppContext.getAccountId());
                                                fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task,
                                                        "deleteTask"));
                                            }
                                        }
                                    });
                        }
                    });
            deleteBtn.setStyleName("link");
            deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));
            filterBtnLayout.addComponent(deleteBtn);

            taskSettingPopupBtn.setContent(filterBtnLayout);
            return taskSettingPopupBtn;
        }
    });

    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 SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId);
            return new ProjectUserLink(task.getAssignuser(), task.getAssignUserAvatarId(),
                    task.getAssignUserFullName());

        }
    });
    this.setWidth("100%");
}

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

License:Open Source License

@Override
public void display() {
    projects = ApplicationContextUtil.getSpringBean(ProjectService.class)
            .getProjectsUserInvolved(AppContext.getUsername(), AppContext.getAccountId());
    if (CollectionUtils.isNotEmpty(projects)) {
        itemTimeLoggingService = ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class);

        final CssLayout headerWrapper = new CssLayout();
        headerWrapper.setWidth("100%");
        headerWrapper.setStyleName("projectfeed-hdr-wrapper");

        HorizontalLayout loggingPanel = new HorizontalLayout();

        HorizontalLayout controlBtns = new HorizontalLayout();
        controlBtns.setMargin(new MarginInfo(true, false, true, false));

        final Label layoutHeader = new Label(
                ProjectAssetsManager.getAsset(ProjectTypeConstants.TIME).getHtml() + " Time Tracking",
                ContentMode.HTML);
        layoutHeader.addStyleName("h2");

        final MHorizontalLayout header = new MHorizontalLayout().withWidth("100%");
        header.with(layoutHeader).withAlign(layoutHeader, Alignment.MIDDLE_LEFT).expand(layoutHeader);

        final CssLayout contentWrapper = new CssLayout();
        contentWrapper.setWidth("100%");
        contentWrapper.addStyleName(UIConstants.CONTENT_WRAPPER);

        headerWrapper.addComponent(header);
        this.addComponent(headerWrapper);
        contentWrapper.addComponent(controlBtns);

        MHorizontalLayout controlsPanel = new MHorizontalLayout().withWidth("100%");

        contentWrapper.addComponent(controlsPanel);
        contentWrapper.addComponent(loggingPanel);
        this.addComponent(contentWrapper);

        final Button backBtn = new Button("Back to Workboard");
        backBtn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override//from   w  w  w .  j  a  va  2  s .c  om
            public void buttonClick(final ClickEvent event) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoProjectModule(TimeTrackingSummaryViewImpl.this, null));

            }
        });

        backBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
        backBtn.setIcon(FontAwesome.ARROW_LEFT);

        controlBtns.addComponent(backBtn);

        VerticalLayout selectionLayoutWrapper = new VerticalLayout();
        selectionLayoutWrapper.setWidth("100%");
        selectionLayoutWrapper.addStyleName("time-tracking-summary-search-panel");
        controlsPanel.addComponent(selectionLayoutWrapper);

        final GridLayout selectionLayout = new GridLayout(9, 2);
        selectionLayout.setSpacing(true);
        selectionLayout.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
        selectionLayout.setMargin(true);
        selectionLayoutWrapper.addComponent(selectionLayout);

        Label fromLb = new Label("From:");
        fromLb.setWidthUndefined();
        selectionLayout.addComponent(fromLb, 0, 0);

        this.fromDateField = new PopupDateFieldExt();
        this.fromDateField.setResolution(Resolution.DAY);
        this.fromDateField.setDateFormat(AppContext.getUserDateFormat());
        this.fromDateField.setWidth("100px");
        selectionLayout.addComponent(this.fromDateField, 1, 0);

        Label toLb = new Label("To:");
        toLb.setWidthUndefined();
        selectionLayout.addComponent(toLb, 2, 0);

        this.toDateField = new PopupDateFieldExt();
        this.toDateField.setResolution(Resolution.DAY);
        this.toDateField.setDateFormat(AppContext.getUserDateFormat());
        this.toDateField.setWidth("100px");
        selectionLayout.addComponent(this.toDateField, 3, 0);

        Label groupLb = new Label("Group:");
        groupLb.setWidthUndefined();
        selectionLayout.addComponent(groupLb, 0, 1);

        this.groupField = new ValueComboBox(false, GROUPBY_PROJECT, GROUPBY_DATE, GROUPBY_USER);
        this.groupField.setWidth("100px");
        selectionLayout.addComponent(this.groupField, 1, 1);

        Label sortLb = new Label("Sort:");
        sortLb.setWidthUndefined();
        selectionLayout.addComponent(sortLb, 2, 1);

        this.orderField = new ItemOrderComboBox();
        this.orderField.setWidth("100px");
        selectionLayout.addComponent(this.orderField, 3, 1);

        Label projectLb = new Label("Project:");
        projectLb.setWidthUndefined();
        selectionLayout.addComponent(projectLb, 4, 0);

        this.projectField = new UserInvolvedProjectsListSelect();
        initListSelectStyle(this.projectField);
        selectionLayout.addComponent(this.projectField, 5, 0, 5, 1);

        Label userLb = new Label("User:");
        userLb.setWidthUndefined();
        selectionLayout.addComponent(userLb, 6, 0);

        this.userField = new UserInvolvedProjectsMemberListSelect(getProjectIds());
        initListSelectStyle(this.userField);
        selectionLayout.addComponent(this.userField, 7, 0, 7, 1);

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

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        fromDate = fromDateField.getValue();
                        toDate = toDateField.getValue();
                        searchCriteria.setRangeDate(new RangeDateSearchField(fromDate, toDate));
                        searchTimeReporting();
                    }
                });
        queryBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

        selectionLayout.addComponent(queryBtn, 8, 0);

        loggingPanel.setWidth("100%");
        loggingPanel.setHeight("80px");
        loggingPanel.setSpacing(true);

        totalHoursLoggingLabel = new Label("Total Hours Logging: 0 Hrs", ContentMode.HTML);
        totalHoursLoggingLabel.addStyleName(UIConstants.LAYOUT_LOG);
        totalHoursLoggingLabel.addStyleName(UIConstants.TEXT_LOG_DATE_FULL);
        loggingPanel.addComponent(totalHoursLoggingLabel);
        loggingPanel.setExpandRatio(totalHoursLoggingLabel, 1.0f);
        loggingPanel.setComponentAlignment(totalHoursLoggingLabel, Alignment.MIDDLE_LEFT);

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

            @Override
            public void buttonClick(ClickEvent event) {
                exportButtonControl.setPopupVisible(true);

            }
        });
        exportButtonControl = new SplitButton(exportBtn);
        exportButtonControl.setWidthUndefined();
        exportButtonControl.addStyleName(UIConstants.THEME_GRAY_LINK);
        exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK);

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

        Button exportPdfBtn = new Button("Pdf");
        FileDownloader pdfDownloader = new FileDownloader(constructStreamResource(ReportExportType.PDF));
        pdfDownloader.extend(exportPdfBtn);
        exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O);
        exportPdfBtn.setStyleName("link");
        popupButtonsControl.addComponent(exportPdfBtn);

        Button exportExcelBtn = new Button("Excel");
        FileDownloader excelDownloader = new FileDownloader(constructStreamResource(ReportExportType.EXCEL));
        excelDownloader.extend(exportExcelBtn);
        exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O);
        exportExcelBtn.setStyleName("link");
        popupButtonsControl.addComponent(exportExcelBtn);

        controlBtns.addComponent(exportButtonControl);
        controlBtns.setComponentAlignment(exportButtonControl, Alignment.TOP_RIGHT);
        controlBtns.setComponentAlignment(backBtn, Alignment.TOP_LEFT);
        controlBtns.setSizeFull();

        this.timeTrackingWrapper = new VerticalLayout();
        this.timeTrackingWrapper.setWidth("100%");
        contentWrapper.addComponent(this.timeTrackingWrapper);

        Calendar date = new GregorianCalendar();
        date.set(Calendar.DAY_OF_MONTH, 1);

        fromDate = date.getTime();
        date.add(Calendar.DAY_OF_MONTH, date.getActualMaximum(Calendar.DAY_OF_MONTH));
        toDate = date.getTime();

        fromDateField.setValue(fromDate);
        toDateField.setValue(toDate);

        searchCriteria = new ItemTimeLoggingSearchCriteria();

        searchCriteria.setRangeDate(new RangeDateSearchField(fromDate, toDate));
    } else {
        final Button backBtn = new Button("Back to Workboard");
        backBtn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoProjectModule(TimeTrackingSummaryViewImpl.this, null));

            }
        });

        backBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
        backBtn.setIcon(FontAwesome.ARROW_LEFT);

        VerticalLayout contentWrapper = new VerticalLayout();
        contentWrapper.setSpacing(true);

        Label infoLbl = new Label("You are not involved in any project yet to track time working");
        infoLbl.setWidthUndefined();
        contentWrapper.setMargin(true);
        contentWrapper.addComponent(infoLbl);
        contentWrapper.setComponentAlignment(infoLbl, Alignment.MIDDLE_CENTER);

        contentWrapper.addComponent(backBtn);
        contentWrapper.setComponentAlignment(backBtn, Alignment.MIDDLE_CENTER);
        this.addComponent(contentWrapper);
        this.setComponentAlignment(contentWrapper, Alignment.MIDDLE_CENTER);
    }
}

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

License:Open Source License

public MyProjectListComponent() {
    withSpacing(false).withMargin(false);
    this.addStyleName("myprojectlist");

    MHorizontalLayout header = new MHorizontalLayout().withSpacing(false)
            .withMargin(new MarginInfo(false, true, false, true)).withHeight("34px");
    header.addStyleName("panel-header");
    titleLbl = new Label(AppContext.getMessage(ProjectCommonI18nEnum.WIDGET_ACTIVE_PROJECTS_TITLE, 0));

    final PopupButton projectsPopup = new PopupButton("");
    projectsPopup.addStyleName("popuplistindicator");

    final MVerticalLayout filterBtnLayout = new MVerticalLayout().withWidth("200px");

    ProjectService projectService = ApplicationContextUtil.getSpringBean(ProjectService.class);
    int allProjectCount = projectService.getTotalCount(getAllProjectsSearchCriteria());
    Button allProjectsBtn = new Button(
            AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ALL_PROJECTS, allProjectCount),
            new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override//from  w w  w  . jav a 2 s. c o m
                public void buttonClick(ClickEvent event) {
                    displayAllProjects();
                    projectsPopup.setPopupVisible(false);
                }
            });
    allProjectsBtn.setStyleName("link");
    filterBtnLayout.addComponent(allProjectsBtn);

    int activeProjectsCount = projectService.getTotalCount(getActiveProjectsSearchCriteria());
    Button activeProjectsBtn = new Button(
            AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECTS, activeProjectsCount),
            new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    displayActiveProjects();
                    projectsPopup.setPopupVisible(false);
                }
            });
    activeProjectsBtn.setStyleName("link");
    filterBtnLayout.addComponent(activeProjectsBtn);

    int archiveProjectsCount = projectService.getTotalCount(getArchivedProjectsSearchCriteria());
    Button archiveProjectsBtn = new Button(
            AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECTS, archiveProjectsCount),
            new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    displayArchiveProjects();
                    projectsPopup.setPopupVisible(false);
                }
            });
    archiveProjectsBtn.setStyleName("link");
    filterBtnLayout.addComponent(archiveProjectsBtn);
    projectsPopup.setContent(filterBtnLayout);

    header.with(titleLbl, projectsPopup).withAlign(titleLbl, Alignment.MIDDLE_LEFT)
            .withAlign(projectsPopup, Alignment.MIDDLE_RIGHT).expand(titleLbl);

    this.projectList = new ProjectPagedList();
    this.with(header, projectList);
}

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

License:Open Source License

@Override
protected CssLayout createPageControls() {
    this.controlBarWrapper = new CssLayout();
    this.controlBarWrapper.setWidth("100%");
    this.controlBarWrapper.setStyleName("page-controls");
    ButtonGroup controlBtns = new ButtonGroup();
    controlBtns.setStyleName(UIConstants.THEME_GREEN_LINK);
    Button prevBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_NAV_NEWER),
            new Button.ClickListener() {
                private static final long serialVersionUID = -94021599166105307L;

                @Override//w ww.  j  av a 2s  .  com
                public void buttonClick(ClickEvent event) {
                    ProjectActivityStreamPagedList.this
                            .pageChange(ProjectActivityStreamPagedList.this.currentPage - 1);
                }
            });
    if (currentPage == 1) {
        prevBtn.setEnabled(false);
    }
    prevBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    prevBtn.setWidth("64px");

    Button nextBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_NAV_OLDER),
            new Button.ClickListener() {
                private static final long serialVersionUID = 3095522916508256018L;

                @Override
                public void buttonClick(ClickEvent event) {
                    ProjectActivityStreamPagedList.this
                            .pageChange(ProjectActivityStreamPagedList.this.currentPage + 1);
                }
            });
    if (currentPage == totalPage) {
        nextBtn.setEnabled(false);
    }
    nextBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    nextBtn.setWidth("64px");

    controlBtns.addButton(prevBtn);
    controlBtns.addButton(nextBtn);

    this.controlBarWrapper.addComponent(controlBtns);

    return this.controlBarWrapper;
}

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);//from  w w w.j  ava2 s .co  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.project.view.user.ProjectListComponent.java

License:Open Source License

public ProjectListComponent() {
    super();/* www.j  a  va  2  s .  c  om*/
    withSpacing(true).withMargin(false).withWidth("100%").withStyleName("project-list-comp");

    MHorizontalLayout headerBar = new MHorizontalLayout();

    headerPopupButton = new PopupButton();
    headerPopupButton.setStyleName("project-list-comp-hdr");
    headerPopupButton.setWidth("100%");

    Label componentHeader = new Label();
    componentHeader.setStyleName("h2");

    headerPopupButton.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.PROJECT));
    headerBar.with(headerPopupButton);

    if (AppContext.canBeYes(RolePermissionCollections.CREATE_NEW_PROJECT)) {
        final Button createProjectBtn = new Button("+", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final Button.ClickEvent event) {
                final ProjectAddWindow projectNewWindow = new ProjectAddWindow();
                UI.getCurrent().addWindow(projectNewWindow);
            }
        });
        createProjectBtn.setStyleName("add-project-btn");
        createProjectBtn.setDescription("New Project");
        createProjectBtn.setWidth("20px");
        createProjectBtn.setHeight("20px");

        headerBar.with(createProjectBtn).withAlign(createProjectBtn, Alignment.MIDDLE_RIGHT);
    }

    headerBar.withWidth("100%").withSpacing(true).expand(headerPopupButton);

    this.addComponent(headerBar);

    contentLayout = new MVerticalLayout().withStyleName("project-list-comp-content").withWidth("205px");

    projectList = new ProjectPagedList();
    headerPopupButton.setContent(projectList);

    projectDesc = new Label("", ContentMode.HTML);
    projectDesc.setStyleName("project-description");
    addComponent(projectDesc);
}

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

License:Open Source License

@Override
protected void displayView() {
    this.removeAllComponents();

    this.withMargin(false).withWidth("100%");

    final CssLayout headerWrapper = new CssLayout();
    headerWrapper.setWidth("100%");
    headerWrapper.setStyleName("projectfeed-hdr-wrapper");

    final MHorizontalLayout header = new MHorizontalLayout().withMargin(false).withWidth("100%");
    header.addStyleName("projectfeed-hdr");

    Button avatar = UserAvatarControlFactory.createUserAvatarEmbeddedButton(AppContext.getUserAvatarId(), 64);
    avatar.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override/*  ww  w . j  a  va2s.com*/
        public void buttonClick(final ClickEvent event) {
            String userFullLinkStr = AccountLinkGenerator.generatePreviewFullUserLink(AppContext.getSiteUrl(),
                    AppContext.getUsername());
            getUI().getPage().open(userFullLinkStr, null);
        }
    });

    header.addComponent(avatar);

    final MVerticalLayout headerContent = new MVerticalLayout()
            .withMargin(new MarginInfo(false, false, false, true));
    headerContent.addStyleName("projectfeed-hdr-content");

    final Label headerLabel = new Label(AppContext.getSession().getDisplayName());
    headerLabel.setStyleName(Reindeer.LABEL_H1);

    final MHorizontalLayout headerContentTop = new MHorizontalLayout()
            .withMargin(new MarginInfo(false, false, true, false));
    headerContentTop.with(headerLabel).withAlign(headerLabel, Alignment.TOP_LEFT);

    if (AppContext.canBeYes(RolePermissionCollections.CREATE_NEW_PROJECT)) {
        final Button createProjectBtn = new Button(
                AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_NEW_PROJECT), new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final Button.ClickEvent event) {
                        final ProjectAddWindow projectNewWindow = new ProjectAddWindow();
                        UI.getCurrent().addWindow(projectNewWindow);
                    }
                });
        createProjectBtn.setIcon(FontAwesome.PLUS);
        createProjectBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        headerContentTop.addComponent(createProjectBtn);
        headerContentTop.setComponentAlignment(createProjectBtn, Alignment.MIDDLE_LEFT);
    }

    followingTicketsLink = new LabelLink(AppContext.getMessage(FollowerI18nEnum.OPT_MY_FOLLOWING_TICKETS, 0),
            AppContext.getSiteUrl() + "#project/following");

    followingTicketsLink.setIconLink(FontAwesome.EYE);

    LabelLink timeTrackingLink = new LabelLink(AppContext.getMessage(TimeTrackingI18nEnum.TIME_RECORD_HEADER),
            AppContext.getSiteUrl() + "#project/timetracking");
    timeTrackingLink.setIconLink(ProjectAssetsManager.getAsset(ProjectTypeConstants.TIME));

    final MHorizontalLayout headerContentBottom = new MHorizontalLayout().withMargin(false)
            .with(followingTicketsLink, timeTrackingLink);

    headerContent.with(headerContentTop, headerContentBottom);

    header.with(headerContent).expand(headerContent);
    headerWrapper.addComponent(header);

    this.addComponent(headerWrapper);

    final MHorizontalLayout layout = new MHorizontalLayout()
            .withMargin(new MarginInfo(false, false, true, false)).withWidth("100%");

    ActivityStreamComponent activityStreamComponent = new ActivityStreamComponent();
    final MVerticalLayout leftPanel = new MVerticalLayout().withSpacing(false)
            .withMargin(new MarginInfo(false, true, false, false)).withWidth("100%")
            .with(activityStreamComponent);

    final MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false).withWidth("565px");
    MyProjectListComponent myProjectListComponent = new MyProjectListComponent();
    TaskStatusComponent taskStatusComponent = new TaskStatusComponent();
    rightPanel.with(myProjectListComponent, taskStatusComponent);

    layout.with(leftPanel, rightPanel).expand(leftPanel);

    final CssLayout contentWrapper = new CssLayout();
    contentWrapper.setWidth("100%");
    contentWrapper.addStyleName("content-wrapper");
    this.addComponent(contentWrapper);
    contentWrapper.addComponent(layout);

    final ProjectService prjService = ApplicationContextUtil.getSpringBean(ProjectService.class);
    prjKeys = prjService.getProjectKeysUserInvolved(AppContext.getUsername(), AppContext.getAccountId());
    if (CollectionUtils.isNotEmpty(prjKeys)) {
        activityStreamComponent.showFeeds(prjKeys);
        myProjectListComponent.displayDefaultProjectsList();
        displayFollowingTicketsCount();
    }

    taskStatusComponent.showProjectTasksByStatus(prjKeys);

}

From source file:com.esofthead.mycollab.module.user.accountsettings.customize.view.AccountInfoChangeWindow.java

License:Open Source License

AccountInfoChangeWindow() {
    super(AppContext.getMessage(AdminI18nEnum.OPT_CHANGE_ACCOUNT_INFO));
    this.setModal(true);
    this.setResizable(false);
    this.setWidth("700px");

    billingAccount = BeanUtility.deepClone(AppContext.getBillingAccount());
    MVerticalLayout content = new MVerticalLayout();
    this.setContent(content);
    editForm = new AdvancedEditBeanForm<>();
    editForm.setFormLayoutFactory(new AbstractFormLayoutFactory() {
        private GridFormLayoutHelper gridFormLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(1, 9,
                "200px");

        @Override//  w w  w. j  ava  2s. c o m
        public ComponentContainer getLayout() {
            return gridFormLayoutHelper.getLayout();
        }

        @Override
        public Component onAttachField(Object propertyId, Field<?> field) {
            if (BillingAccount.Field.sitename.equalTo(propertyId)) {
                return gridFormLayoutHelper.addComponent(field,
                        AppContext.getMessage(AdminI18nEnum.FORM_SITE_NAME), 0, 0);
            } else if (BillingAccount.Field.subdomain.equalTo(propertyId)) {
                return gridFormLayoutHelper.addComponent(field,
                        AppContext.getMessage(AdminI18nEnum.FORM_SITE_ADDRESS), 0, 1);
            } else if (BillingAccount.Field.defaulttimezone.equalTo(propertyId)) {
                return gridFormLayoutHelper.addComponent(field,
                        AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_TIMEZONE), 0, 2);
            } else if (BillingAccount.Field.defaultcurrencyid.equalTo(propertyId)) {
                return gridFormLayoutHelper.addComponent(field,
                        AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_CURRENCY), 0, 3);
            } else if (BillingAccount.Field.defaultyymmddformat.equalTo(propertyId)) {
                return gridFormLayoutHelper.addComponent(field,
                        AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_YYMMDD_FORMAT),
                        AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 4);
            } else if (BillingAccount.Field.defaultmmddformat.equalTo(propertyId)) {
                return gridFormLayoutHelper.addComponent(field,
                        AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_MMDD_FORMAT),
                        AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 5);
            } else if (BillingAccount.Field.defaulthumandateformat.equalTo(propertyId)) {
                return gridFormLayoutHelper.addComponent(field,
                        AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_HUMAN_DATE_FORMAT),
                        AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 6);
            } else if (BillingAccount.Field.defaultlanguagetag.equalTo(propertyId)) {
                return gridFormLayoutHelper.addComponent(field,
                        AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_LANGUAGE), 0, 7);
            } else if (BillingAccount.Field.displayemailpublicly.equalTo(propertyId)) {
                return gridFormLayoutHelper.addComponent(field,
                        AppContext.getMessage(AdminI18nEnum.FORM_SHOW_EMAIL_PUBLICLY),
                        AppContext.getMessage(AdminI18nEnum.FORM_SHOW_EMAIL_PUBLICLY_HELP), 0, 8);
            }
            return null;
        }
    });

    editForm.setBeanFormFieldFactory(
            new AbstractBeanFieldGroupEditFieldFactory<SimpleBillingAccount>(editForm) {
                @Override
                protected Field<?> onCreateField(Object propertyId) {
                    if (BillingAccount.Field.subdomain.equalTo(propertyId)) {
                        return new SubDomainField();
                    } else if (BillingAccount.Field.defaulttimezone.equalTo(propertyId)) {
                        return new TimeZoneSelectionField(false);
                    } else if (BillingAccount.Field.defaultcurrencyid.equalTo(propertyId)) {
                        return new CurrencyComboBoxField();
                    } else if (BillingAccount.Field.defaultyymmddformat.equalTo(propertyId)) {
                        return new DateFormatField(billingAccount.getDateFormatInstance());
                    } else if (BillingAccount.Field.defaultmmddformat.equalTo(propertyId)) {
                        return new DateFormatField(billingAccount.getShortDateFormatInstance());
                    } else if (BillingAccount.Field.defaulthumandateformat.equalTo(propertyId)) {
                        return new DateFormatField(billingAccount.getLongDateFormatInstance());
                    } else if (BillingAccount.Field.defaultlanguagetag.equalTo(propertyId)) {
                        return new LanguageSelectionField();
                    }
                    return null;
                }

            });

    editForm.setBean(billingAccount);

    MHorizontalLayout buttonControls = new MHorizontalLayout().withMargin(true);
    Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            if (editForm.validateForm()) {
                BillingAccountService billingAccountService = AppContextUtil
                        .getSpringBean(BillingAccountService.class);
                billingAccountService.updateSelectiveWithSession(billingAccount, AppContext.getUsername());
                close();
                String siteUrl = SiteConfiguration.getSiteUrl(billingAccount.getSubdomain());
                String assignExec = String.format("window.location.assign(\'%s\');", siteUrl);
                Page.getCurrent().getJavaScript().execute(assignExec);
            }
        }
    });
    saveBtn.setIcon(FontAwesome.SAVE);
    saveBtn.setStyleName(UIConstants.BUTTON_ACTION);

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent clickEvent) {
                    close();
                }
            });
    cancelBtn.setStyleName(UIConstants.BUTTON_OPTION);
    buttonControls.with(cancelBtn, saveBtn);

    content.with(editForm, buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);
}

From source file:com.esofthead.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java

License:Open Source License

@Override
public void displayView() {
    removeAllComponents();/*from   w  w w .ja  v  a2  s  . com*/

    billingAccount = AppContext.getBillingAccount();
    FormContainer formContainer = new FormContainer();
    this.addComponent(formContainer);

    MHorizontalLayout generalSettingHeader = new MHorizontalLayout();
    Label headerLbl = new Label(AppContext.getMessage(AdminI18nEnum.OPT_GENERAL_SETTINGS));

    Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            UI.getCurrent().addWindow(new AccountInfoChangeWindow());
        }
    });
    editBtn.setStyleName(UIConstants.BUTTON_LINK);

    generalSettingHeader.with(headerLbl, editBtn).alignAll(Alignment.MIDDLE_LEFT);

    GridFormLayoutHelper gridFormLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(2, 5, "200px");
    gridFormLayoutHelper.addComponent(new Label(billingAccount.getSitename()),
            AppContext.getMessage(AdminI18nEnum.FORM_SITE_NAME), 0, 0);
    gridFormLayoutHelper.addComponent(
            new Label(String.format("https://%s.mycollab.com", billingAccount.getSubdomain())),
            AppContext.getMessage(AdminI18nEnum.FORM_SITE_ADDRESS), 0, 1);
    gridFormLayoutHelper.addComponent(
            new Label(TimezoneVal.getDisplayName(billingAccount.getDefaulttimezone())),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_TIMEZONE), 0, 2);
    Currency defaultCurrency = billingAccount.getCurrencyInstance();
    gridFormLayoutHelper.addComponent(new ELabel(defaultCurrency.getDisplayName(AppContext.getUserLocale())),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_CURRENCY), 0, 3);

    Date now = new GregorianCalendar().getTime();
    String defaultFullDateFormat = billingAccount.getDateFormatInstance();
    gridFormLayoutHelper.addComponent(new Label(String.format("%s (%s)",
            DateTimeUtils.formatDate(now, billingAccount.getDateFormatInstance()), defaultFullDateFormat)),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_YYMMDD_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 1, 0);

    String defaultShortDateFormat = billingAccount.getShortDateFormatInstance();
    gridFormLayoutHelper.addComponent(
            new Label(String.format("%s (%s)",
                    DateTimeUtils.formatDate(now, billingAccount.getShortDateFormatInstance()),
                    defaultShortDateFormat)),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_MMDD_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 1, 1);

    String defaultLongDateFormat = billingAccount.getLongDateFormatInstance();
    gridFormLayoutHelper.addComponent(new Label(String.format("%s (%s)",
            DateTimeUtils.formatDate(now, billingAccount.getLongDateFormatInstance()), defaultLongDateFormat)),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_HUMAN_DATE_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 1, 2);

    gridFormLayoutHelper.addComponent(
            new Label(LocalizationHelper.getLocaleInstance(billingAccount.getDefaultlanguagetag())
                    .getDisplayLanguage(AppContext.getUserLocale())),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_LANGUAGE), 1, 3);

    gridFormLayoutHelper.addComponent(
            new Label(AppContext
                    .getMessage(LocalizationHelper.localizeYesNo(billingAccount.getDisplayemailpublicly()))),
            AppContext.getMessage(AdminI18nEnum.FORM_SHOW_EMAIL_PUBLICLY),
            AppContext.getMessage(AdminI18nEnum.FORM_SHOW_EMAIL_PUBLICLY_HELP), 0, 4, 2, "100%");

    formContainer.addSection(new CssLayout(generalSettingHeader), gridFormLayoutHelper.getLayout());

    buildLogoPanel();
    buildShortcutIconPanel();
}