Example usage for com.vaadin.ui VerticalLayout addComponent

List of usage examples for com.vaadin.ui VerticalLayout addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout addComponent.

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

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

License:Open Source License

public TaskSearchTableDisplay(TableViewField requiredColumn, List<TableViewField> displayColumns) {
    super(ApplicationContextUtil.getSpringBean(ProjectTaskService.class), SimpleTask.class, requiredColumn,
            displayColumns);/*  w  w  w  .  ja v  a 2s  .  c o m*/

    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 = TaskSearchTableDisplay.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.getPercentagecomplete() != null && 100d == task.getPercentagecomplete()) {
                b.addStyleName(UIConstants.LINK_COMPLETED);
            } else {
                if ("Pending".equals(task.getStatus())) {
                    b.addStyleName(UIConstants.LINK_PENDING);
                } else if ((task.getEnddate() != null
                        && (task.getEnddate().before(new GregorianCalendar().getTime())))
                        || (task.getActualenddate() != null
                                && (task.getActualenddate().before(new GregorianCalendar().getTime())))
                        || (task.getDeadline() != null
                                && (task.getDeadline().before(new GregorianCalendar().getTime())))) {
                    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 = TaskSearchTableDisplay.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 = TaskSearchTableDisplay.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 = TaskSearchTableDisplay.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 = TaskSearchTableDisplay.this.getBeanByIndex(itemId);
            PopupButton taskSettingPopupBtn = new PopupButton();
            VerticalLayout filterBtnLayout = new VerticalLayout();
            filterBtnLayout.setMargin(true);
            filterBtnLayout.setSpacing(true);
            filterBtnLayout.setWidth("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(TaskSearchTableDisplay.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("Close", new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

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

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

                        fireTableEvent(new TableClickEvent(TaskSearchTableDisplay.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("Open");
                        task.setPercentagecomplete(0d);

                        ProjectTaskService projectTaskService = ApplicationContextUtil
                                .getSpringBean(ProjectTaskService.class);
                        projectTaskService.updateWithSession(task, AppContext.getUsername());
                        fireTableEvent(new TableClickEvent(TaskSearchTableDisplay.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.updateWithSession(task, AppContext.getUsername());
                            fireTableEvent(
                                    new TableClickEvent(TaskSearchTableDisplay.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.updateWithSession(task, AppContext.getUsername());

                        fireTableEvent(new TableClickEvent(TaskSearchTableDisplay.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(TaskSearchTableDisplay.this,
                                                        task, "deleteTask"));
                                            }
                                        }
                                    });
                        }
                    });
            deleteBtn.setStyleName("link");
            deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));
            filterBtnLayout.addComponent(deleteBtn);

            taskSettingPopupBtn.setIcon(MyCollabResource.newResource("icons/16/item_settings.png"));
            taskSettingPopupBtn.setStyleName("link");
            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 = TaskSearchTableDisplay.this.getBeanByIndex(itemId);
            return new ProjectUserLink(task.getAssignuser(), task.getAssignUserAvatarId(),
                    task.getAssignUserFullName());

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

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

License:Open Source License

public TimeTrackingTableDisplay(List<TableViewField> displayColumns) {
    super(ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class), SimpleItemTimeLogging.class,
            displayColumns);/*from ww w  .j  av a2  s .  c  om*/

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

        @Override
        public com.vaadin.ui.Component generateCell(final Table source, final Object itemId,
                final Object columnId) {
            final SimpleItemTimeLogging timeItem = TimeTrackingTableDisplay.this.getBeanByIndex(itemId);

            return new ProjectUserLink(timeItem.getLoguser(), timeItem.getLogUserAvatarId(),
                    timeItem.getLogUserFullName());

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(final Table source, final Object itemId,
                final Object columnId) {
            SimpleItemTimeLogging itemLogging = TimeTrackingTableDisplay.this.getBeanByIndex(itemId);

            try {
                VerticalLayout summaryWrapper = new VerticalLayout();

                String type = itemLogging.getType();

                if (type == null) {
                    return new Label(itemLogging.getNote(), ContentMode.HTML);
                } else {
                    Label timeTrackingLink = new Label(buildItemValue(itemLogging), ContentMode.HTML);
                    timeTrackingLink.addStyleName("link");
                    timeTrackingLink.addStyleName(UIConstants.WORD_WRAP);
                    timeTrackingLink.setWidth("100%");

                    if (ProjectTypeConstants.BUG.equals(type)) {
                        if (BugStatus.Verified.name().equals(itemLogging.getStatus())) {
                            timeTrackingLink.addStyleName(UIConstants.LINK_COMPLETED);
                        } else if (itemLogging.getDueDate() != null
                                && (itemLogging.getDueDate().before(DateTimeUtils.getCurrentDateWithoutMS()))) {
                            timeTrackingLink.addStyleName(UIConstants.LINK_OVERDUE);
                        }
                    } else if (type.equals(ProjectTypeConstants.TASK)) {
                        if (itemLogging.getPercentageComplete() != null
                                && 100d == itemLogging.getPercentageComplete()) {
                            timeTrackingLink.addStyleName(UIConstants.LINK_COMPLETED);
                        } else {
                            if (OptionI18nEnum.StatusI18nEnum.Pending.name().equals(itemLogging.getStatus())) {
                                timeTrackingLink.addStyleName(UIConstants.LINK_PENDING);
                            } else if (itemLogging.getDueDate() != null && (itemLogging.getDueDate()
                                    .before(DateTimeUtils.getCurrentDateWithoutMS()))) {
                                timeTrackingLink.addStyleName(UIConstants.LINK_OVERDUE);
                            }
                        }
                    } else {
                        if (OptionI18nEnum.StatusI18nEnum.Closed.name().equals(itemLogging.getStatus())) {
                            timeTrackingLink.addStyleName(UIConstants.LINK_COMPLETED);
                        } else if (itemLogging.getDueDate() != null
                                && (itemLogging.getDueDate().before(DateTimeUtils.getCurrentDateWithoutMS()))) {
                            timeTrackingLink.addStyleName(UIConstants.LINK_OVERDUE);
                        }
                    }
                    summaryWrapper.addComponent(timeTrackingLink);

                    if (StringUtils.isNotBlank(itemLogging.getNote())) {
                        summaryWrapper.addComponent(new Label(itemLogging.getNote(), ContentMode.HTML));
                    }

                    return summaryWrapper;
                }

            } catch (Exception e) {
                LOG.error("Error: " + BeanUtility.printBeanObj(itemLogging), e);
                return new Label("");
            }

        }
    }

    );

    this.

            addGeneratedColumn("projectName", new ColumnGenerator() {
                private static final long serialVersionUID = 1L;

                @Override
                public Object generateCell(Table source, Object itemId, Object columnId) {
                    final SimpleItemTimeLogging itemLogging = TimeTrackingTableDisplay.this
                            .getBeanByIndex(itemId);

                    LabelLink b = new LabelLink(itemLogging.getProjectName(),
                            ProjectLinkBuilder.generateProjectFullLink(itemLogging.getProjectid()));
                    b.setIconLink(ProjectAssetsManager.getAsset(ProjectTypeConstants.PROJECT));
                    return b;
                }
            }

    );

    this.

            addGeneratedColumn("isbillable", new ColumnGenerator() {
                private static final long serialVersionUID = 1L;

                @Override
                public Object generateCell(Table source, Object itemId, Object columnId) {
                    final SimpleItemTimeLogging timeLogging = TimeTrackingTableDisplay.this
                            .getBeanByIndex(itemId);
                    FontIconLabel icon;
                    if (timeLogging.getIsbillable()) {
                        icon = new FontIconLabel(FontAwesome.CHECK);
                    } else {
                        icon = new FontIconLabel(FontAwesome.TIMES);
                    }
                    return icon;
                }
            }

    );

    this.

            addGeneratedColumn("logforday", new ColumnGenerator() {
                private static final long serialVersionUID = 1L;

                @Override
                public com.vaadin.ui.Component generateCell(final Table source, final Object itemId,
                        final Object columnId) {
                    final SimpleItemTimeLogging timeLogging = TimeTrackingTableDisplay.this
                            .getBeanByIndex(itemId);
                    final Label l = new Label();
                    l.setValue(AppContext.formatDate(timeLogging.getLogforday()));
                    return l;
                }
            }

    );

    this.

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

                @Override
                public Object generateCell(Table source, Object itemId, Object columnId) {
                    final SimpleItemTimeLogging itemLogging = TimeTrackingTableDisplay.this
                            .getBeanByIndex(itemId);

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

                        @Override
                        public void buttonClick(ClickEvent event) {
                            fireTableEvent(
                                    new TableClickEvent(TimeTrackingTableDisplay.this, itemLogging, "edit"));

                        }
                    });
                    editBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
                    editBtn.setIcon(FontAwesome.EDIT);

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

                        @Override
                        public void buttonClick(ClickEvent event) {
                            fireTableEvent(
                                    new TableClickEvent(TimeTrackingTableDisplay.this, itemLogging, "delete"));

                        }
                    });
                    deleteBtn.setIcon(FontAwesome.TRASH_O);
                    deleteBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
                    layout.with(editBtn, deleteBtn);
                    return layout;
                }

            }

    );

    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 www  .  j  a  va2s  .com
            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.ProjectSummaryViewImpl.java

License:Open Source License

@Override
protected void displayView() {
    withMargin(new MarginInfo(true, false, false, false));

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

    ProjectInformationComponent prjView = new ProjectInformationComponent();
    contentWrapper.addComponent(prjView);

    final MHorizontalLayout layout = new MHorizontalLayout().withWidth("100%");
    contentWrapper.addComponent(layout);

    final VerticalLayout leftPanel = new VerticalLayout();

    ProjectActivityStreamComponent activityPanel = new ProjectActivityStreamComponent();
    leftPanel.addComponent(activityPanel);
    layout.addComponent(leftPanel);/*from   w  ww .  j a v a 2 s .  c  o  m*/

    final MVerticalLayout rightPanel = new MVerticalLayout()
            .withMargin(new MarginInfo(false, false, false, true));
    layout.addComponent(rightPanel);

    ProjectMessageListComponent messageWidget = new ProjectMessageListComponent();
    ProjectMembersWidget membersWidget = new ProjectMembersWidget();
    ProjectAssignmentsWidget taskOverdueWidget = new ProjectAssignmentsWidget();

    rightPanel.with(messageWidget, membersWidget, taskOverdueWidget);

    activityPanel.showProjectFeeds();
    prjView.displayProjectInformation();
    membersWidget.showInformation();
    taskOverdueWidget.showOpenAssignments();
    messageWidget.showLatestMessages();
}

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

License:Open Source License

private void editPhoto(byte[] imageData) {
    try {/*w  w  w  .  j  a  v a2 s. c  o  m*/
        originalImage = ImageIO.read(new ByteArrayInputStream(imageData));
    } catch (IOException e) {
        throw new UserInvalidInputException("Invalid image type");
    }
    originalImage = ImageUtil.scaleImage(originalImage, 650, 650);

    MHorizontalLayout previewBox = new MHorizontalLayout().withMargin(new MarginInfo(false, true, true, false))
            .withFullWidth();

    final String logoPath = AppContext.getBillingAccount().getLogopath();
    Resource defaultPhoto = AccountAssetsResolver.createLogoResource(logoPath, 150);
    previewImage = new Embedded(null, defaultPhoto);
    previewImage.setWidth("100px");
    previewBox.addComponent(previewImage);
    previewBox.setComponentAlignment(previewImage, Alignment.TOP_LEFT);

    MVerticalLayout previewBoxRight = new MVerticalLayout().withSpacing(false)
            .withMargin(new MarginInfo(false, true, false, true));

    Label lbPreview = new Label(
            "<p style='margin: 0px;'><strong>To the below is what your logo will look like.</strong></p><p "
                    + "style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. "
                    + "When you are happy with your photo, click the <strong>Accept</strong> button.</p>",
            ContentMode.HTML);
    previewBoxRight.addComponent(lbPreview);

    MHorizontalLayout controlBtns = new MHorizontalLayout();
    controlBtns.setSizeUndefined();
    controlBtns.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    EventBusFactory.getInstance()
                            .post(new SettingEvent.GotoGeneralSetting(LogoEditWindow.this, null));
                }
            });
    cancelBtn.setStyleName(UIConstants.BUTTON_OPTION);
    controlBtns.with(cancelBtn);

    Button acceptBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT),
            new Button.ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    if (scaleImageData != null && scaleImageData.length > 0) {
                        try {
                            BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData));
                            AccountLogoService accountLogoService = AppContextUtil
                                    .getSpringBean(AccountLogoService.class);
                            accountLogoService.upload(AppContext.getUsername(), image,
                                    AppContext.getAccountId());
                            Page.getCurrent().getJavaScript().execute("window.location.reload();");
                        } catch (IOException e) {
                            throw new MyCollabException("Error when saving account logo", e);
                        }

                    }

                }
            });
    acceptBtn.setStyleName(UIConstants.BUTTON_ACTION);
    controlBtns.with(acceptBtn);

    previewBoxRight.with(controlBtns).withAlign(controlBtns, Alignment.TOP_LEFT);
    previewBox.with(previewBoxRight).expand(previewBoxRight);
    content.addComponent(previewBox);

    CssLayout cropBox = new CssLayout();
    cropBox.setWidth("100%");
    VerticalLayout currentPhotoBox = new VerticalLayout();
    Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage),
            "image/png");
    CropField cropField = new CropField(resource);
    cropField.setImmediate(true);
    cropField.setSelectionAspectRatio(150 / 28);
    cropField.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            VCropSelection newSelection = (VCropSelection) event.getProperty().getValue();
            int x1 = newSelection.getXTopLeft();
            int y1 = newSelection.getYTopLeft();
            int x2 = newSelection.getXBottomRight();
            int y2 = newSelection.getYBottomRight();
            if (x2 > x1 && y2 > y1) {
                BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1));
                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
                try {
                    ImageIO.write(subImage, "png", outStream);
                    scaleImageData = outStream.toByteArray();
                    displayPreviewImage();
                } catch (IOException e) {
                    LOG.error("Error while scale image: ", e);
                }
            }

        }

    });
    currentPhotoBox.setWidth("650px");
    currentPhotoBox.setHeight("650px");
    currentPhotoBox.addComponent(cropField);
    cropBox.addComponent(currentPhotoBox);

    content.with(previewBox, ELabel.hr(), cropBox);
}

From source file:com.esofthead.mycollab.module.user.accountsettings.profile.view.ProfilePhotoUploadViewImpl.java

License:Open Source License

@SuppressWarnings("serial")
@Override/* ww  w  .  j a v  a  2  s . c o m*/
public void editPhoto(final byte[] imageData) {
    this.removeAllComponents();
    LOG.debug("Receive avatar upload with size: " + imageData.length);
    try {
        originalImage = ImageIO.read(new ByteArrayInputStream(imageData));
    } catch (IOException e) {
        throw new UserInvalidInputException("Invalid image type");
    }
    originalImage = ImageUtil.scaleImage(originalImage, 650, 650);

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

    Resource defaultPhoto = UserAvatarControlFactory.createAvatarResource(AppContext.getUserAvatarId(), 100);
    previewImage = new Embedded(null, defaultPhoto);
    previewImage.setWidth("100px");
    previewBox.addComponent(previewImage);
    previewBox.setComponentAlignment(previewImage, Alignment.TOP_LEFT);

    VerticalLayout previewBoxRight = new VerticalLayout();
    previewBoxRight.setMargin(new MarginInfo(false, true, false, true));
    Label lbPreview = new Label(
            "<p style='margin: 0px;'><strong>To the left is what your profile photo will look like.</strong></p><p style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. When you are happy with your photo, click the &ldquo;Accept&ldquo; button.</p>",
            ContentMode.HTML);
    previewBoxRight.addComponent(lbPreview);

    MHorizontalLayout controlBtns = new MHorizontalLayout();
    controlBtns.setSizeUndefined();

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    EventBusFactory.getInstance()
                            .post(new ProfileEvent.GotoProfileView(ProfilePhotoUploadViewImpl.this, null));
                }
            });
    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);

    Button acceptBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT),
            new Button.ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    if (scaleImageData != null && scaleImageData.length > 0) {

                        try {
                            BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData));
                            UserAvatarService userAvatarService = ApplicationContextUtil
                                    .getSpringBean(UserAvatarService.class);
                            userAvatarService.uploadAvatar(image, AppContext.getUsername(),
                                    AppContext.getUserAvatarId());
                            Page.getCurrent().getJavaScript().execute("window.location.reload();");
                        } catch (IOException e) {
                            throw new MyCollabException("Error when saving user avatar", e);
                        }

                    }

                }
            });
    acceptBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    acceptBtn.setIcon(FontAwesome.CHECK);

    controlBtns.with(acceptBtn, cancelBtn).alignAll(Alignment.MIDDLE_LEFT);

    previewBoxRight.addComponent(controlBtns);
    previewBoxRight.setComponentAlignment(controlBtns, Alignment.TOP_LEFT);

    previewBox.addComponent(previewBoxRight);
    previewBox.setExpandRatio(previewBoxRight, 1.0f);

    this.addComponent(previewBox);

    CssLayout cropBox = new CssLayout();
    cropBox.addStyleName(UIConstants.PHOTO_CROPBOX);
    cropBox.setWidth("100%");
    VerticalLayout currentPhotoBox = new VerticalLayout();
    Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage),
            "image/png");
    CropField cropField = new CropField(resource);
    cropField.setImmediate(true);
    cropField.setSelectionAspectRatio(1.0f);
    cropField.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            VCropSelection newSelection = (VCropSelection) event.getProperty().getValue();
            int x1 = newSelection.getXTopLeft();
            int y1 = newSelection.getYTopLeft();
            int x2 = newSelection.getXBottomRight();
            int y2 = newSelection.getYBottomRight();
            if (x2 > x1 && y2 > y1) {
                BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1));
                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
                try {
                    ImageIO.write(subImage, "png", outStream);
                    scaleImageData = outStream.toByteArray();
                    displayPreviewImage();
                } catch (IOException e) {
                    LOG.error("Error while scale image: ", e);
                }
            }

        }

    });
    currentPhotoBox.setWidth("650px");
    currentPhotoBox.setHeight("650px");

    currentPhotoBox.addComponent(cropField);

    cropBox.addComponent(currentPhotoBox);

    this.addComponent(previewBox);
    this.addComponent(cropBox);
    this.setExpandRatio(cropBox, 1.0f);
}

From source file:com.esofthead.mycollab.module.user.accountsettings.profile.view.ProfileReadViewImpl.java

License:Open Source License

private void displayUserAvatar() {
    this.userAvatar.removeAllComponents();
    final Image cropField = UserAvatarControlFactory
            .createUserAvatarEmbeddedComponent(AppContext.getUserAvatarId(), 100);
    userAvatar.addComponent(cropField);/*from   w w  w  .j a  v  a  2s  . c o  m*/

    this.avatarAndPass.removeAllComponents();
    avatarAndPass.addComponent(userAvatar);

    User user = formItem.getUser();

    final VerticalLayout basicLayout = new VerticalLayout();
    basicLayout.setSpacing(true);

    final HorizontalLayout userWrapper = new HorizontalLayout();

    final Label userName = new Label(AppContext.getSession().getDisplayName());
    userName.setStyleName("h1");
    userWrapper.addComponent(userName);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    UI.getCurrent().addWindow(new BasicInfoChangeWindow(formItem.getUser()));
                }
            });
    btnChangeBasicInfo.setStyleName("link");
    HorizontalLayout btnChangeBasicInfoWrapper = new HorizontalLayout();
    btnChangeBasicInfoWrapper.setWidth("40px");
    btnChangeBasicInfoWrapper.addComponent(btnChangeBasicInfo);
    btnChangeBasicInfoWrapper.setComponentAlignment(btnChangeBasicInfo, Alignment.MIDDLE_RIGHT);
    userWrapper.addComponent(btnChangeBasicInfoWrapper);
    basicLayout.addComponent(userWrapper);
    basicLayout.setComponentAlignment(userWrapper, Alignment.MIDDLE_LEFT);

    basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_BIRTHDAY) + ": "
            + AppContext.formatDate(user.getDateofbirth())));
    basicLayout.addComponent(
            new MHorizontalLayout(new Label(AppContext.getMessage(UserI18nEnum.FORM_EMAIL) + ": "),
                    new LabelLink(user.getEmail(), "mailto:" + user.getEmail())));
    basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_TIMEZONE) + ": "
            + TimezoneMapper.getTimezone(user.getTimezone()).getDisplayName()));
    basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_LANGUAGE) + ": "
            + AppContext.getMessage(LangI18Enum.class, user.getLanguage())));

    HorizontalLayout passwordWrapper = new HorizontalLayout();
    passwordWrapper
            .addComponent(new Label(AppContext.getMessage(ShellI18nEnum.FORM_PASSWORD) + ": ***********"));

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

        @Override
        public void buttonClick(final ClickEvent event) {
            UI.getCurrent().addWindow(new PasswordChangeWindow(formItem.user));
        }
    });
    btnChangePassword.setStyleName("link");
    HorizontalLayout btnChangePasswordWrapper = new HorizontalLayout();
    btnChangePasswordWrapper.setWidth("50px");
    btnChangePasswordWrapper.addComponent(btnChangePassword);
    btnChangePasswordWrapper.setComponentAlignment(btnChangePassword, Alignment.MIDDLE_RIGHT);
    passwordWrapper.addComponent(btnChangePasswordWrapper);
    basicLayout.addComponent(passwordWrapper);
    basicLayout.setComponentAlignment(passwordWrapper, Alignment.MIDDLE_LEFT);

    avatarAndPass.addComponent(basicLayout);
    avatarAndPass.setComponentAlignment(basicLayout, Alignment.TOP_LEFT);
    avatarAndPass.setExpandRatio(basicLayout, 1.0f);

    final UploadField avatarUploadField = new UploadField() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void updateDisplay() {
            byte[] imageData = (byte[]) this.getValue();
            String mimeType = this.getLastMimeType();
            if (mimeType.equals("image/jpeg")) {
                imageData = ImageUtil.convertJpgToPngFormat(imageData);
                if (imageData == null) {
                    throw new UserInvalidInputException("Do not support image format for avatar");
                } else {
                    mimeType = "image/png";
                }
            }

            if (mimeType.equals("image/png")) {
                EventBusFactory.getInstance()
                        .post(new ProfileEvent.GotoUploadPhoto(ProfileReadViewImpl.this, imageData));
            } else {
                throw new UserInvalidInputException(
                        "Upload file does not have valid image format. The supported formats are jpg/png");
            }
        }
    };
    avatarUploadField.addStyleName("upload-field");
    avatarUploadField.setButtonCaption(AppContext.getMessage(UserI18nEnum.BUTTON_CHANGE_AVATAR));
    avatarUploadField.setSizeUndefined();
    avatarUploadField.setFieldType(FieldType.BYTE_ARRAY);
    this.userAvatar.addComponent(avatarUploadField);
}

From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserListViewImpl.java

License:Open Source License

private Component generateMemberBlock(final SimpleUser member) {
    CssLayout memberBlock = new CssLayout();
    memberBlock.addStyleName("member-block");

    VerticalLayout blockContent = new VerticalLayout();
    HorizontalLayout blockTop = new HorizontalLayout();
    blockTop.setSpacing(true);//w ww .  jav a 2  s.  c o m
    Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getAvatarid(), 100);
    blockTop.addComponent(memberAvatar);

    VerticalLayout memberInfo = new VerticalLayout();

    HorizontalLayout layoutButtonDelete = new HorizontalLayout();
    layoutButtonDelete.setVisible(AppContext.canWrite(RolePermissionCollections.ACCOUNT_USER));
    layoutButtonDelete.setWidth("100%");

    Label emptylb = new Label("");
    layoutButtonDelete.addComponent(emptylb);
    layoutButtonDelete.setExpandRatio(emptylb, 1.0f);

    Button deleteBtn = new Button();
    deleteBtn.addClickListener(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()) {
                                UserService userService = ApplicationContextUtil
                                        .getSpringBean(UserService.class);
                                userService.pendingUserAccounts(Arrays.asList(member.getUsername()),
                                        AppContext.getAccountId());
                                EventBusFactory.getInstance()
                                        .post(new UserEvent.GotoList(UserListViewImpl.this, null));
                            }
                        }
                    });
        }
    });
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
    layoutButtonDelete.addComponent(deleteBtn);

    memberInfo.addComponent(layoutButtonDelete);

    ButtonLink userAccountLink = new ButtonLink(member.getDisplayName());
    userAccountLink.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            EventBusFactory.getInstance()
                    .post(new UserEvent.GotoRead(UserListViewImpl.this, member.getUsername()));
        }
    });
    userAccountLink.setWidth("100%");
    userAccountLink.setHeight("100%");

    memberInfo.addComponent(userAccountLink);

    Label memberEmailLabel = new Label(
            "<a href='mailto:" + member.getUsername() + "'>" + member.getUsername() + "</a>", ContentMode.HTML);
    memberEmailLabel.addStyleName("member-email");
    memberEmailLabel.setWidth("100%");
    memberInfo.addComponent(memberEmailLabel);

    Label memberSinceLabel = new Label("Member since: " + AppContext.formatDate(member.getRegisteredtime()));
    memberSinceLabel.addStyleName("member-email");
    memberSinceLabel.setWidth("100%");
    memberInfo.addComponent(memberSinceLabel);

    if (RegisterStatusConstants.SENT_VERIFICATION_EMAIL.equals(member.getRegisterstatus())) {
        final VerticalLayout waitingNotLayout = new VerticalLayout();
        Label infoStatus = new Label("Waiting for accept invitation");
        infoStatus.addStyleName("member-email");
        waitingNotLayout.addComponent(infoStatus);

        ButtonLink resendInvitationLink = new ButtonLink("Resend Invitation", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                UserService userService = ApplicationContextUtil.getSpringBean(UserService.class);
                userService.updateUserAccountStatus(member.getUsername(), member.getAccountId(),
                        RegisterStatusConstants.VERIFICATING);
                waitingNotLayout.removeAllComponents();
                Label statusEmail = new Label("Sending invitation email");
                statusEmail.addStyleName("member-email");
                waitingNotLayout.addComponent(statusEmail);
            }
        });
        resendInvitationLink.setStyleName("link");
        resendInvitationLink.addStyleName("member-email");
        waitingNotLayout.addComponent(resendInvitationLink);
        memberInfo.addComponent(waitingNotLayout);
    } else if (RegisterStatusConstants.ACTIVE.equals(member.getRegisterstatus())) {
        Label lastAccessTimeLbl = new Label("Logged in "
                + DateTimeUtils.getPrettyDateValue(member.getLastaccessedtime(), AppContext.getUserLocale()));
        lastAccessTimeLbl.addStyleName("member-email");
        memberInfo.addComponent(lastAccessTimeLbl);
    } else if (RegisterStatusConstants.VERIFICATING.equals(member.getRegisterstatus())) {
        Label infoStatus = new Label("Sending invitation email");
        infoStatus.addStyleName("member-email");
        memberInfo.addComponent(infoStatus);
    }

    blockTop.addComponent(memberInfo);
    blockTop.setExpandRatio(memberInfo, 1.0f);
    blockTop.setWidth("100%");
    blockContent.addComponent(blockTop);

    if (member.getRoleid() != null) {
        String memberRoleLinkPrefix = "<a href=\""
                + AccountLinkBuilder.generatePreviewFullRoleLink(member.getRoleid()) + "\"";
        Label memberRole = new Label();
        memberRole.setContentMode(ContentMode.HTML);
        if (member.getIsAccountOwner() != null && member.getIsAccountOwner()) {
            memberRole.setValue(memberRoleLinkPrefix + "style=\"color: #B00000;\">" + "Account Owner" + "</a>");
        } else {
            memberRole.setValue(memberRoleLinkPrefix + "style=\"color:gray;font-size:12px;\">"
                    + member.getRoleName() + "</a>");
        }
        memberRole.setSizeUndefined();
        blockContent.addComponent(memberRole);
        blockContent.setComponentAlignment(memberRole, Alignment.MIDDLE_RIGHT);
    } else if (member.getIsAccountOwner() != null && member.getIsAccountOwner() == Boolean.TRUE) {
        Label memberRole = new Label();
        memberRole.setContentMode(ContentMode.HTML);
        memberRole.setValue("<a style=\"color: #B00000;\">" + "Account Owner" + "</a>");
        memberRole.setSizeUndefined();
        blockContent.addComponent(memberRole);
        blockContent.setComponentAlignment(memberRole, Alignment.MIDDLE_RIGHT);
    } else {
        Label lbl = new Label();
        lbl.setHeight("10px");
        blockContent.addComponent(lbl);
    }
    blockContent.setWidth("100%");

    memberBlock.addComponent(blockContent);

    return memberBlock;
}

From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserReadViewImpl.java

License:Open Source License

private void displayUserAvatar() {
    this.userAvatar.removeAllComponents();
    final Image cropField = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(user.getAvatarid(), 100);
    userAvatar.addComponent(cropField);/*from w w w.ja va 2s .c  o  m*/

    this.avatarAndPass.removeAllComponents();
    avatarAndPass.addComponent(userAvatar);

    final VerticalLayout basicLayout = new VerticalLayout();
    basicLayout.setSpacing(true);
    final HorizontalLayout userWrapper = new HorizontalLayout();

    String nickName = user.getNickname();

    final Label userName = new Label(
            user.getDisplayName() + (StringUtils.isEmpty(nickName) ? "" : (" ( " + nickName + " )")));
    userName.setStyleName("h1");
    userWrapper.addComponent(userName);

    basicLayout.addComponent(userWrapper);
    basicLayout.setComponentAlignment(userWrapper, Alignment.MIDDLE_LEFT);

    Component role;
    if (user.getIsAccountOwner() != null && user.getIsAccountOwner() == Boolean.TRUE) {
        role = new DefaultViewField("Account Owner");
    } else {
        role = new LinkViewField(user.getRoleName(),
                AccountLinkBuilder.generatePreviewFullRoleLink(user.getRoleid()));
    }
    MHorizontalLayout roleWrapper = new MHorizontalLayout();
    roleWrapper.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_ROLE) + ": "));
    roleWrapper.addComponent(role);

    basicLayout.addComponent(roleWrapper);

    basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_BIRTHDAY) + ": "
            + AppContext.formatDate(user.getDateofbirth())));
    basicLayout.addComponent(
            new MHorizontalLayout().add(new Label(AppContext.getMessage(UserI18nEnum.FORM_EMAIL) + ": "))
                    .add(new LabelLink(user.getEmail(), "mailto:" + user.getEmail())));
    basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_TIMEZONE) + ": "
            + TimezoneMapper.getTimezone(user.getTimezone()).getDisplayName()));
    basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_LANGUAGE) + ": "
            + AppContext.getMessage(LangI18Enum.class, user.getLanguage())));

    avatarAndPass.addComponent(basicLayout);
    avatarAndPass.setComponentAlignment(basicLayout, Alignment.TOP_LEFT);
    avatarAndPass.setExpandRatio(basicLayout, 1.0f);
}

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

License:Open Source License

public AccountModuleImpl() {
    super(true);// ww w . j  av  a  2 s  .  c om
    ControllerRegistry.addController(new UserAccountController(this));
    this.setWidth("100%");
    this.addStyleName("main-content-wrapper");
    this.addStyleName("accountViewContainer");

    final MHorizontalLayout topPanel = new MHorizontalLayout().withWidth("100%").withStyleName("top-panel")
            .withMargin(new MarginInfo(true, true, true, false));
    AccountSettingBreadcrumb breadcrumb = ViewManager.getCacheComponent(AccountSettingBreadcrumb.class);

    topPanel.addComponent(breadcrumb);

    this.accountTab = new UserVerticalTabsheet();
    this.accountTab.setWidth("100%");
    this.accountTab.setNavigatorWidth("250px");
    this.accountTab.setNavigatorStyleName("sidebar-menu");
    this.accountTab.setContainerStyleName("tab-content");
    this.accountTab.setHeight(null);

    VerticalLayout contentWrapper = this.accountTab.getContentWrapper();
    contentWrapper.addStyleName("main-content");
    contentWrapper.addComponentAsFirst(topPanel);

    VerticalLayout introTextWrap = new VerticalLayout();
    introTextWrap.setStyleName("intro-text-wrap");
    introTextWrap.setMargin(new MarginInfo(true, true, false, true));
    introTextWrap.setWidth("100%");
    introTextWrap.addComponent(generateIntroText());

    this.accountTab.getNavigatorWrapper().setWidth("250px");
    this.accountTab.getNavigatorWrapper().addComponentAsFirst(introTextWrap);

    this.buildComponents();

    this.addComponent(this.accountTab);
}