Example usage for com.vaadin.ui Label setValue

List of usage examples for com.vaadin.ui Label setValue

Introduction

In this page you can find the example usage for com.vaadin.ui Label setValue.

Prototype

public void setValue(String value) 

Source Link

Document

Sets the text to be shown in the label.

Usage

From source file:com.esofthead.mycollab.module.project.ui.components.AbstractPreviewItemComp.java

License:Open Source License

public AbstractPreviewItemComp(String headerText, Resource iconResource, ReadViewLayout layout) {
    Label headerLbl = new Label("", ContentMode.HTML);
    headerLbl.setSizeUndefined();//from w  ww.  jav  a2  s .  co  m
    headerLbl.setStyleName("hdr-text");

    this.previewLayout = layout;

    header = new MHorizontalLayout();

    if (iconResource != null) {
        if (iconResource instanceof FontAwesome) {
            String title = ((FontAwesome) iconResource).getHtml() + " " + headerText;
            headerLbl.setValue(title);
        } else {
            Image titleIcon = new Image(null, iconResource);
            ((MHorizontalLayout) header).with(titleIcon).withAlign(titleIcon, Alignment.MIDDLE_LEFT);
            headerLbl.setValue(headerText);
        }
    } else {
        headerLbl.setValue(headerText);
    }

    ((MHorizontalLayout) header).with(headerLbl).withAlign(headerLbl, Alignment.MIDDLE_LEFT).expand(headerLbl)
            .withStyleName("hdr-view").withWidth("100%").withSpacing(true).withMargin(true);

    this.addComponent(header);
    initContent();
}

From source file:com.esofthead.mycollab.module.project.ui.components.TimeLogEditWindow.java

License:Open Source License

private void initUI() {
    this.setWidth("900px");

    headerPanel = new MHorizontalLayout().withWidth("100%");
    content.addComponent(headerPanel);/*from w ww .jav  a2s  .c o  m*/
    constructSpentTimeEntryPanel();
    constructRemainTimeEntryPanel();

    this.tableItem = new DefaultPagedBeanTable<>(
            ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class), SimpleItemTimeLogging.class,
            Arrays.asList(TimeTableFieldDef.logUser, TimeTableFieldDef.logForDate, TimeTableFieldDef.logValue,
                    TimeTableFieldDef.billable,
                    new TableViewField(null, "id", UIConstants.TABLE_CONTROL_WIDTH)));

    this.tableItem.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 timeLoggingItem = TimeLogEditWindow.this.tableItem
                    .getBeanByIndex(itemId);

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

        }
    });

    this.tableItem.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 monitorItem = TimeLogEditWindow.this.tableItem.getBeanByIndex(itemId);
            final Label l = new Label();
            l.setValue(AppContext.formatDate(monitorItem.getLogforday()));
            return l;
        }
    });

    this.tableItem.addGeneratedColumn("logvalue", 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 itemTimeLogging = TimeLogEditWindow.this.tableItem
                    .getBeanByIndex(itemId);
            final Label l = new Label();
            l.setValue(itemTimeLogging.getLogvalue() + "");
            return l;
        }
    });

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

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleItemTimeLogging monitorItem = tableItem.getBeanByIndex(itemId);
            FontIconLabel icon;
            if (monitorItem.getIsbillable()) {
                icon = new FontIconLabel(FontAwesome.CHECK);
            } else {
                icon = new FontIconLabel(FontAwesome.TIMES);
            }
            icon.setStyleName(UIConstants.BUTTON_ICON_ONLY);
            return icon;
        }
    });

    this.tableItem.addGeneratedColumn("id", 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 itemTimeLogging = TimeLogEditWindow.this.tableItem
                    .getBeanByIndex(itemId);
            final Button deleteBtn = new Button(null, new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    TimeLogEditWindow.this.itemTimeLoggingService.removeWithSession(itemTimeLogging.getId(),
                            AppContext.getUsername(), AppContext.getAccountId());
                    TimeLogEditWindow.this.loadTimeValue();
                }
            });
            deleteBtn.setIcon(FontAwesome.TRASH_O);
            deleteBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
            itemTimeLogging.setExtraData(deleteBtn);

            deleteBtn.setEnabled(CurrentProjectVariables.isAdmin()
                    || AppContext.getUsername().equals(itemTimeLogging.getLoguser()));
            return deleteBtn;
        }
    });

    this.tableItem.setWidth("100%");
    content.addComponent(tableItem);
}

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

License:Open Source License

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

    VerticalLayout blockContent = new VerticalLayout();
    MHorizontalLayout blockTop = new MHorizontalLayout();
    Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getMemberAvatarId(),
            100);/* ww w . j  a  va  2 s .  co m*/
    blockTop.addComponent(memberAvatar);

    VerticalLayout memberInfo = new VerticalLayout();

    Button deleteBtn = new Button("", FontAwesome.TRASH_O);
    deleteBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            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()) {
                                ProjectMemberService prjMemberService = ApplicationContextUtil
                                        .getSpringBean(ProjectMemberService.class);
                                member.setStatus(ProjectMemberStatusConstants.INACTIVE);
                                prjMemberService.updateWithSession(member, AppContext.getUsername());

                                EventBusFactory.getInstance().post(
                                        new ProjectMemberEvent.GotoList(ProjectMemberListViewImpl.this, null));
                            }
                        }
                    });
        }
    });
    deleteBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);

    blockContent.addComponent(deleteBtn);
    deleteBtn.setVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS));
    blockContent.setComponentAlignment(deleteBtn, Alignment.TOP_RIGHT);

    LabelLink memberLink = new LabelLink(member.getMemberFullName(),
            ProjectLinkBuilder.generateProjectMemberFullLink(member.getProjectid(), member.getUsername()));

    memberLink.setWidth("100%");
    memberLink.addStyleName("member-name");

    memberInfo.addComponent(memberLink);

    String roleLink = "<a href=\"" + AppContext.getSiteUrl() + GenericLinkUtils.URL_PREFIX_PARAM
            + ProjectLinkGenerator.generateRolePreviewLink(member.getProjectid(), member.getProjectRoleId())
            + "\"";
    Label memberRole = new Label();
    memberRole.setContentMode(ContentMode.HTML);
    memberRole.setStyleName("member-role");
    if (member.isAdmin()) {
        memberRole.setValue(roleLink + "style=\"color: #B00000;\">" + "Project Admin" + "</a>");
    } else {
        memberRole.setValue(roleLink + "style=\"color:gray;font-size:12px;\">" + member.getRoleName() + "</a>");
    }
    memberRole.setSizeUndefined();
    memberInfo.addComponent(memberRole);

    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.getJoindate()));
    memberSinceLabel.addStyleName("member-email");
    memberSinceLabel.setWidth("100%");
    memberInfo.addComponent(memberSinceLabel);

    if (RegisterStatusConstants.SENT_VERIFICATION_EMAIL.equals(member.getStatus())) {
        final VerticalLayout waitingNotLayout = new VerticalLayout();
        Label infoStatus = new Label(AppContext.getMessage(ProjectMemberI18nEnum.WAITING_ACCEPT_INVITATION));
        infoStatus.addStyleName("member-email");
        waitingNotLayout.addComponent(infoStatus);

        ButtonLink resendInvitationLink = new ButtonLink(
                AppContext.getMessage(ProjectMemberI18nEnum.BUTTON_RESEND_INVITATION),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        ProjectMemberMapper projectMemberMapper = ApplicationContextUtil
                                .getSpringBean(ProjectMemberMapper.class);
                        member.setStatus(RegisterStatusConstants.VERIFICATING);
                        projectMemberMapper.updateByPrimaryKeySelective(member);
                        waitingNotLayout.removeAllComponents();
                        Label statusEmail = new Label(
                                AppContext.getMessage(ProjectMemberI18nEnum.SENDING_EMAIL_INVITATION));
                        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.getStatus())) {
        Label lastAccessTimeLbl = new Label("Logged in "
                + DateTimeUtils.getPrettyDateValue(member.getLastAccessTime(), AppContext.getUserLocale()));
        lastAccessTimeLbl.addStyleName("member-email");
        memberInfo.addComponent(lastAccessTimeLbl);
    } else if (RegisterStatusConstants.VERIFICATING.equals(member.getStatus())) {
        Label infoStatus = new Label(AppContext.getMessage(ProjectMemberI18nEnum.SENDING_EMAIL_INVITATION));
        infoStatus.addStyleName("member-email");
        memberInfo.addComponent(infoStatus);
    }

    String bugStatus = member.getNumOpenBugs() + " open bug";
    if (member.getNumOpenBugs() > 1) {
        bugStatus += "s";
    }

    String taskStatus = member.getNumOpenTasks() + " open task";
    if (member.getNumOpenTasks() > 1) {
        taskStatus += "s";
    }

    Label memberWorkStatus = new Label(bugStatus + " - " + taskStatus);
    memberInfo.addComponent(memberWorkStatus);
    memberInfo.setWidth("100%");

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

    blockContent.setWidth("100%");

    memberBlock.addComponent(blockContent);
    return memberBlock;
}

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);//  ww  w.  ja v a  2s.c o m

    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.user.ProjectSearchItemsViewImpl.java

License:Open Source License

@Override
public void displayResults(String value) {
    this.removeAllComponents();

    MVerticalLayout layout = new MVerticalLayout().withWidth("100%");
    this.addComponent(layout);

    Label headerLbl = new Label("", ContentMode.HTML);
    headerLbl.addStyleName("headerName");

    DefaultBeanPagedList<ProjectGenericItemService, ProjectGenericItemSearchCriteria, ProjectGenericItem> searchItemsTable = new DefaultBeanPagedList<>(
            ApplicationContextUtil.getSpringBean(ProjectGenericItemService.class), new ItemRowDisplayHandler());
    searchItemsTable.setControlStyle("borderlessControl");

    layout.with(headerLbl, searchItemsTable);
    ProjectGenericItemSearchCriteria criteria = new ProjectGenericItemSearchCriteria();
    criteria.setPrjKeys(new SetSearchField<>(CurrentProjectVariables.getProjectId()));
    criteria.setTxtValue(new StringSearchField(value));
    int foundNum = searchItemsTable.setSearchCriteria(criteria);
    headerLbl.setValue(String.format(headerTitle, value, foundNum));
}

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);//from  www  .  j a  v a 2 s .co  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.shell.view.MainView.java

License:Open Source License

private CustomLayout createTopMenu() {
    final CustomLayout layout = CustomLayoutExt.createLayout("topNavigation");
    layout.setStyleName("topNavigation");
    layout.setHeight("40px");
    layout.setWidth("100%");

    Button accountLogo = AccountLogoFactory
            .createAccountLogoImageComponent(ThemeManager.loadLogoPath(AppContext.getAccountId()), 150);

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

        @Override//  w ww . j ava2  s.c  om
        public void buttonClick(final ClickEvent event) {
            final UserPreference pref = AppContext.getUserPreference();
            if (pref.getLastmodulevisit() == null
                    || ModuleNameConstants.PRJ.equals(pref.getLastmodulevisit())) {
                EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null));
            } else if (ModuleNameConstants.CRM.equals(pref.getLastmodulevisit())) {
                EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null));
            } else if (ModuleNameConstants.ACCOUNT.equals(pref.getLastmodulevisit())) {
                EventBusFactory.getInstance().post(new ShellEvent.GotoUserAccountModule(this, null));
            } else if (ModuleNameConstants.FILE.equals(pref.getLastmodulevisit())) {
                EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null));
            }
        }
    });
    layout.addComponent(accountLogo, "mainLogo");

    serviceMenu = new ServiceMenu();
    serviceMenu.addStyleName("topNavPopup");

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_CRM),
            MyCollabResource.newResource(WebResourceIds._16_customer), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

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

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PROJECT),
            MyCollabResource.newResource(WebResourceIds._16_project), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    if (!event.isCtrlKey() && !event.isMetaKey()) {
                        EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null));
                    }
                }
            });

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_DOCUMENT),
            MyCollabResource.newResource(WebResourceIds._16_document), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

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

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PEOPLE),
            MyCollabResource.newResource(WebResourceIds._16_account), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" }));
                }
            });

    layout.addComponent(serviceMenu, "serviceMenu");

    final MHorizontalLayout accountLayout = new MHorizontalLayout()
            .withMargin(new MarginInfo(false, true, false, false));
    accountLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    final Label accountNameLabel = new Label(AppContext.getSubDomain());
    accountNameLabel.setStyleName("subdomain");
    accountLayout.addComponent(accountNameLabel);

    // display trial box if user in trial mode
    SimpleBillingAccount billingAccount = AppContext.getBillingAccount();
    if (AccountStatusConstants.TRIAL.equals(billingAccount.getStatus())) {
        Label informLbl = new Label("", ContentMode.HTML);
        informLbl.addStyleName("trialEndingNotification");
        informLbl.setHeight("100%");
        HorizontalLayout informBox = new HorizontalLayout();
        informBox.addStyleName("trialInformBox");
        informBox.setSizeFull();
        informBox.addComponent(informLbl);
        informBox.setMargin(new MarginInfo(false, true, false, false));
        informBox.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void layoutClick(LayoutClickEvent event) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
            }
        });
        accountLayout.addComponent(informBox);
        accountLayout.setSpacing(true);
        accountLayout.setComponentAlignment(informBox, Alignment.MIDDLE_LEFT);

        Date createdTime = billingAccount.getCreatedtime();
        long timeDeviation = System.currentTimeMillis() - createdTime.getTime();
        int daysLeft = (int) Math.floor(timeDeviation / (1000 * 60 * 60 * 24));
        if (daysLeft > 30) {
            BillingService billingService = ApplicationContextUtil.getSpringBean(BillingService.class);
            BillingPlan freeBillingPlan = billingService.getFreeBillingPlan();
            billingAccount.setBillingPlan(freeBillingPlan);

            informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>"
                    + " 0 DAYS LEFT</div><div class='informBlock'>&gt;&gt;</div>");
        } else {
            if (AppContext.isAdmin()) {
                informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + (30 - daysLeft)
                        + " DAYS LEFT</div><div class='informBlock'>&gt;&gt;</div>");
            } else {
                informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + (30 - daysLeft)
                        + " DAYS LEFT</div><div class='informBlock'>&gt;&gt;</div>");
            }
        }
    }

    NotificationButton notificationButton = new NotificationButton();
    accountLayout.addComponent(notificationButton);
    if (AppContext.getSession().getTimezone() == null) {
        EventBusFactory.getInstance().post(new ShellEvent.NewNotification(this, new TimezoneNotification()));
    }

    if (StringUtils.isBlank(AppContext.getSession().getAvatarid())) {
        EventBusFactory.getInstance()
                .post(new ShellEvent.NewNotification(this, new RequestUploadAvatarNotification()));
    }

    if (SiteConfiguration.getDeploymentMode() != DeploymentMode.site && AppContext.isAdmin()) {
        try {
            Client client = ClientBuilder.newBuilder().build();
            WebTarget target = client.target("https://api.mycollab.com/api/checkupdate");
            Response response = target.request().get();
            String values = response.readEntity(String.class);
            Gson gson = new Gson();
            Properties props = gson.fromJson(values, Properties.class);
            String version = props.getProperty("version");
            if (!MyCollabVersion.getVersion().equals(version)) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.NewNotification(this, new NewUpdateNotification(props)));
            }
        } catch (Exception e) {
            LOG.error("Error when call remote api", e);
        }
    }

    UserAvatarComp userAvatar = new UserAvatarComp();
    accountLayout.addComponent(userAvatar);
    accountLayout.setComponentAlignment(userAvatar, Alignment.MIDDLE_LEFT);

    final PopupButton accountMenu = new PopupButton(AppContext.getSession().getDisplayName());
    final VerticalLayout accLayout = new VerticalLayout();
    accLayout.setWidth("140px");

    final Button myProfileBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_PROFILE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" }));
                }
            });
    myProfileBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.PROFILE));
    myProfileBtn.setStyleName("link");
    accLayout.addComponent(myProfileBtn);

    final Button myAccountBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_BILLING),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
                }
            });
    myAccountBtn.setStyleName("link");
    myAccountBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.BILLING));
    accLayout.addComponent(myAccountBtn);

    final Button userMgtBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_USERS_AND_ROLES),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" }));
                }
            });
    userMgtBtn.setStyleName("link");
    userMgtBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.USERS));
    accLayout.addComponent(userMgtBtn);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    AppContext.getInstance().clearSession();
                    EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null));
                }
            });
    signoutBtn.setStyleName("link");
    signoutBtn.setIcon(FontAwesome.SIGN_OUT);
    accLayout.addComponent(signoutBtn);

    accountMenu.setContent(accLayout);
    accountMenu.setStyleName("accountMenu");
    accountMenu.addStyleName("topNavPopup");
    accountLayout.addComponent(accountMenu);

    layout.addComponent(accountLayout, "accountMenu");

    return layout;
}

From source file:com.esofthead.mycollab.shell.view.MainViewImpl.java

License:Open Source License

private MHorizontalLayout buildAccountMenuLayout() {
    accountLayout.removeAllComponents();

    if (SiteConfiguration.isDemandEdition()) {
        // display trial box if user in trial mode
        SimpleBillingAccount billingAccount = AppContext.getBillingAccount();
        if (AccountStatusConstants.TRIAL.equals(billingAccount.getStatus())) {
            if ("Free".equals(billingAccount.getBillingPlan().getBillingtype())) {
                Label informLbl = new Label(
                        "<div class='informBlock'>FREE CHARGE<br>UPGRADE</div><div class='informBlock'>&gt;&gt;</div>",
                        ContentMode.HTML);
                informLbl.addStyleName("trialEndingNotification");
                informLbl.setHeight("100%");
                HorizontalLayout informBox = new HorizontalLayout();
                informBox.addStyleName("trialInformBox");
                informBox.setSizeFull();
                informBox.addComponent(informLbl);
                informBox.setMargin(new MarginInfo(false, true, false, false));
                informBox.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override//from  w ww .j  a  v a 2 s.  co  m
                    public void layoutClick(LayoutClickEvent event) {
                        EventBusFactory.getInstance()
                                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
                    }
                });
                accountLayout.with(informBox).withAlign(informBox, Alignment.MIDDLE_LEFT);
            } else {
                Label informLbl = new Label("", ContentMode.HTML);
                informLbl.addStyleName("trialEndingNotification");
                informLbl.setHeight("100%");
                HorizontalLayout informBox = new HorizontalLayout();
                informBox.addStyleName("trialInformBox");
                informBox.setSizeFull();
                informBox.setMargin(new MarginInfo(false, true, false, false));
                informBox.addComponent(informLbl);
                informBox.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void layoutClick(LayoutClickEvent event) {
                        EventBusFactory.getInstance()
                                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
                    }
                });
                accountLayout.with(informBox).withAlign(informBox, Alignment.MIDDLE_LEFT);

                Duration dur = new Duration(new DateTime(billingAccount.getCreatedtime()), new DateTime());
                int daysLeft = dur.toStandardDays().getDays();
                if (daysLeft > 30) {
                    informLbl.setValue(
                            "<div class='informBlock'>Trial<br></div><div class='informBlock'>&gt;&gt;</div>");
                    //                        AppContext.getInstance().setIsValidAccount(false);
                } else {
                    informLbl.setValue(String.format("<div class='informBlock'>Trial ending<br>%d days "
                            + "left</div><div class='informBlock'>&gt;&gt;</div>", 30 - daysLeft));
                }
            }
        }
    }

    Label accountNameLabel = new Label(AppContext.getSubDomain());
    accountNameLabel.addStyleName("subdomain");
    accountLayout.addComponent(accountNameLabel);

    if (SiteConfiguration.isCommunityEdition()) {
        Button buyPremiumBtn = new Button("Upgrade to Pro edition", new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                UI.getCurrent().addWindow(new AdWindow());
            }
        });
        buyPremiumBtn.setIcon(FontAwesome.SHOPPING_CART);
        buyPremiumBtn.addStyleName("ad");
        accountLayout.addComponent(buyPremiumBtn);
    }

    LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class);
    if (licenseResolver != null) {
        LicenseInfo licenseInfo = licenseResolver.getLicenseInfo();
        if (licenseInfo != null) {
            if (licenseInfo.isExpired()) {
                Button buyPremiumBtn = new Button(AppContext.getMessage(LicenseI18nEnum.EXPIRE_NOTIFICATION),
                        new ClickListener() {
                            @Override
                            public void buttonClick(ClickEvent event) {
                                UI.getCurrent().addWindow(new BuyPremiumSoftwareWindow());
                            }
                        });
                buyPremiumBtn.setIcon(FontAwesome.SHOPPING_CART);
                buyPremiumBtn.addStyleName("ad");
                accountLayout.addComponent(buyPremiumBtn);
            } else if (licenseInfo.isTrial()) {
                Duration dur = new Duration(new DateTime(), new DateTime(licenseInfo.getExpireDate()));
                int days = dur.toStandardDays().getDays();
                Button buyPremiumBtn = new Button(
                        AppContext.getMessage(LicenseI18nEnum.TRIAL_NOTIFICATION, days), new ClickListener() {
                            @Override
                            public void buttonClick(ClickEvent event) {
                                UI.getCurrent().addWindow(new BuyPremiumSoftwareWindow());
                            }
                        });
                buyPremiumBtn.setIcon(FontAwesome.SHOPPING_CART);
                buyPremiumBtn.addStyleName("ad");
                accountLayout.addComponent(buyPremiumBtn);
            }
        }
    }

    NotificationComponent notificationComponent = new NotificationComponent();
    accountLayout.addComponent(notificationComponent);

    if (StringUtils.isBlank(AppContext.getUser().getAvatarid())) {
        EventBusFactory.getInstance()
                .post(new ShellEvent.NewNotification(this, new RequestUploadAvatarNotification()));
    }

    if (!SiteConfiguration.isDemandEdition()) {
        ExtMailService mailService = AppContextUtil.getSpringBean(ExtMailService.class);
        if (!mailService.isMailSetupValid()) {
            EventBusFactory.getInstance()
                    .post(new ShellEvent.NewNotification(this, new SmtpSetupNotification()));
        }

        SimpleUser user = AppContext.getUser();
        GregorianCalendar tenDaysAgo = new GregorianCalendar();
        tenDaysAgo.add(Calendar.DATE, -10);

        if (Boolean.TRUE.equals(user.getRequestad()) && user.getRegisteredtime().before(tenDaysAgo.getTime())) {
            UI.getCurrent().addWindow(new AdRequestWindow(user));
        }
    }

    Resource userAvatarRes = UserAvatarControlFactory.createAvatarResource(AppContext.getUserAvatarId(), 24);
    final PopupButton accountMenu = new PopupButton("");
    accountMenu.setIcon(userAvatarRes);
    accountMenu.setDescription(AppContext.getUserDisplayName());

    OptionPopupContent accountPopupContent = new OptionPopupContent();

    Button myProfileBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_PROFILE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" }));
                }
            });
    myProfileBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.PROFILE));
    accountPopupContent.addOption(myProfileBtn);

    Button userMgtBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_USERS_AND_ROLES),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" }));
                }
            });
    userMgtBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.USERS));
    accountPopupContent.addOption(userMgtBtn);

    Button generalSettingBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_SETTING),
            new ClickListener() {
                @Override
                public void buttonClick(ClickEvent clickEvent) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance().post(
                            new ShellEvent.GotoUserAccountModule(this, new String[] { "setting", "general" }));
                }
            });
    generalSettingBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.GENERAL_SETTING));
    accountPopupContent.addOption(generalSettingBtn);

    Button themeCustomizeBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_THEME), new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            accountMenu.setPopupVisible(false);
            EventBusFactory.getInstance()
                    .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setting", "theme" }));
        }
    });
    themeCustomizeBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.THEME_CUSTOMIZE));
    accountPopupContent.addOption(themeCustomizeBtn);

    if (!SiteConfiguration.isDemandEdition()) {
        Button setupBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_SETUP), new ClickListener() {
            @Override
            public void buttonClick(ClickEvent clickEvent) {
                accountMenu.setPopupVisible(false);
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setup" }));
            }
        });
        setupBtn.setIcon(FontAwesome.WRENCH);
        accountPopupContent.addOption(setupBtn);
    }

    accountPopupContent.addSeparator();

    Button helpBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_HELP));
    helpBtn.setIcon(FontAwesome.MORTAR_BOARD);
    ExternalResource helpRes = new ExternalResource("https://community.mycollab.com/meet-mycollab/");
    BrowserWindowOpener helpOpener = new BrowserWindowOpener(helpRes);
    helpOpener.extend(helpBtn);
    accountPopupContent.addOption(helpBtn);

    Button supportBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SUPPORT));
    supportBtn.setIcon(FontAwesome.LIFE_SAVER);
    ExternalResource supportRes = new ExternalResource("http://support.mycollab.com/");
    BrowserWindowOpener supportOpener = new BrowserWindowOpener(supportRes);
    supportOpener.extend(supportBtn);
    accountPopupContent.addOption(supportBtn);

    Button translateBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_TRANSLATE));
    translateBtn.setIcon(FontAwesome.PENCIL);
    ExternalResource translateRes = new ExternalResource(
            "https://community.mycollab.com/docs/developing-mycollab/translating/");
    BrowserWindowOpener translateOpener = new BrowserWindowOpener(translateRes);
    translateOpener.extend(translateBtn);
    accountPopupContent.addOption(translateBtn);

    if (!SiteConfiguration.isCommunityEdition()) {
        Button myAccountBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_BILLING),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        accountMenu.setPopupVisible(false);
                        EventBusFactory.getInstance()
                                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
                    }
                });
        myAccountBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.BILLING));
        accountPopupContent.addOption(myAccountBtn);
    }

    accountPopupContent.addSeparator();
    Button aboutBtn = new Button("About MyCollab", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            accountMenu.setPopupVisible(false);
            Window aboutWindow = ViewManager.getCacheComponent(AbstractAboutWindow.class);
            UI.getCurrent().addWindow(aboutWindow);
        }
    });
    aboutBtn.setIcon(FontAwesome.INFO_CIRCLE);
    accountPopupContent.addOption(aboutBtn);

    Button releaseNotesBtn = new Button("Release Notes");
    ExternalResource releaseNotesRes = new ExternalResource(
            "https://community.mycollab.com/docs/hosting-mycollab-on-your-own-server/releases/");
    BrowserWindowOpener releaseNotesOpener = new BrowserWindowOpener(releaseNotesRes);
    releaseNotesOpener.extend(releaseNotesBtn);

    releaseNotesBtn.setIcon(FontAwesome.BULLHORN);
    accountPopupContent.addOption(releaseNotesBtn);

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

                @Override
                public void buttonClick(ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null));
                }
            });
    signoutBtn.setIcon(FontAwesome.SIGN_OUT);
    accountPopupContent.addSeparator();
    accountPopupContent.addOption(signoutBtn);

    accountMenu.setContent(accountPopupContent);
    accountLayout.addComponent(accountMenu);
    return accountLayout;
}

From source file:com.esofthead.mycollab.vaadin.ui.form.field.DateTimeViewField.java

License:Open Source License

@Override
protected Component initContent() {
    final Label l = new Label();
    l.setWidth("100%");
    if (date == null) {
        l.setValue("&nbsp;");
        l.setContentMode(ContentMode.HTML);
    } else {/*from ww  w.  j  av a2s.co m*/
        l.setValue(AppContext.formatDateTime(date));
    }
    return l;
}

From source file:com.esofthead.mycollab.vaadin.ui.form.field.DateViewField.java

License:Open Source License

@Override
protected Component initContent() {
    final Label l = new Label();
    l.setWidth("100%");
    if (date == null) {
        l.setValue("&nbsp;");
        l.setContentMode(ContentMode.HTML);
    } else {//from   w w  w  .j a  va 2 s  . c  o m
        l.setValue(AppContext.formatDate(date));
    }
    return l;
}