Example usage for com.vaadin.ui Label setContentMode

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

Introduction

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

Prototype

public void setContentMode(ContentMode contentMode) 

Source Link

Document

Sets the content mode of the label.

Usage

From source file:annis.gui.ExampleQueriesPanel.java

License:Apache License

/**
 * Sets some layout properties./*w w  w .j  av a2s .  c o m*/
 */
private void setUpTable() {
    setSizeFull();
    // expand the table
    table.setSizeFull();

    // Allow selecting items from the table.
    table.setSelectable(false);

    // Send changes in selection immediately to server.
    table.setImmediate(true);

    // set custom style
    table.addStyleName("example-queries-table");

    // put stripes to the table
    table.addStyleName(ChameleonTheme.TABLE_STRIPED);

    // configure columns
    table.addGeneratedColumn(COLUMN_OPEN_CORPUS_BROWSER, new ShowCorpusBrowser());

    table.addGeneratedColumn(COLUMN_EXAMPLE_QUERY, new QueryColumn());

    table.addGeneratedColumn(COLUMN_DESCRIPTION, new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            ExampleQuery eQ = (ExampleQuery) itemId;
            Label l = new Label(eQ.getDescription());
            l.setContentMode(ContentMode.TEXT);
            l.addStyleName(Helper.CORPUS_FONT_FORCE);
            return l;
        }
    });

    table.setVisibleColumns(
            new Object[] { COLUMN_EXAMPLE_QUERY, COLUMN_DESCRIPTION, COLUMN_OPEN_CORPUS_BROWSER });

    table.setColumnExpandRatio(table.getVisibleColumns()[0], 0.40f);
    table.setColumnExpandRatio(table.getVisibleColumns()[1], 0.40f);

    table.setColumnHeader(table.getVisibleColumns()[0], "Example Query");
    table.setColumnHeader(table.getVisibleColumns()[1], "Description");
    table.setColumnHeader(table.getVisibleColumns()[2], "open corpus browser");

}

From source file:annis.gui.HelpUsWindow.java

License:Apache License

public HelpUsWindow() {
    setSizeFull();//from w w w  .  ja va  2s.  co  m
    layout = new VerticalLayout();
    setContent(layout);

    layout.setSizeFull();
    layout.setMargin(new MarginInfo(false, false, true, false));

    HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setSizeFull();
    hLayout.setMargin(false);

    VerticalLayout labelLayout = new VerticalLayout();
    labelLayout.setMargin(true);
    labelLayout.setSizeFull();

    Label lblOpenSource = new Label();

    lblOpenSource.setValue("<h1>ANNIS is <a href=\"http://opensource.org/osd\">Open Source</a> "
            + "software.</h1>" + "<p>This means you are free to download the source code and add new "
            + "features or make other adjustments to ANNIS on your own.<p/>"
            + "Here are some examples how you can help ANNIS:" + "<ul>"
            + "<li>Fix or report problems (bugs) you encounter when using the ANNIS software.</li>"
            + "<li>Add new features.</li>" + "<li>Enhance the documentation</li>" + "</ul>"
            + "<p>Feel free to visit our GitHub page for more information: <a href=\"https://github.com/korpling/ANNIS\" target=\"_blank\">https://github.com/korpling/ANNIS</a></p>");
    lblOpenSource.setContentMode(ContentMode.HTML);
    lblOpenSource.setStyleName("opensource");
    lblOpenSource.setWidth("100%");
    lblOpenSource.setHeight("-1px");
    labelLayout.addComponent(lblOpenSource);

    Link lnkFork = new Link();
    lnkFork.setResource(new ExternalResource("https://github.com/korpling/ANNIS"));
    lnkFork.setIcon(
            new ExternalResource("https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"));
    lnkFork.setTargetName("_blank");

    hLayout.addComponent(labelLayout);
    hLayout.addComponent(lnkFork);
    hLayout.setComponentAlignment(labelLayout, Alignment.TOP_LEFT);
    hLayout.setComponentAlignment(lnkFork, Alignment.TOP_RIGHT);
    hLayout.setExpandRatio(labelLayout, 1.0f);

    layout.addComponent(hLayout);

    final HelpUsWindow finalThis = this;

    btClose = new Button("Close");
    btClose.addClickListener(new OkClickListener(finalThis));
    layout.addComponent(btClose);

    layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(btClose, Alignment.MIDDLE_CENTER);
    layout.setExpandRatio(hLayout, 1.0f);
}

From source file:by.bigvova.views.HomeView.java

License:Apache License

public HomeView() {
    setSpacing(true);/*from  w w w.j a va2 s .c om*/
    setMargin(true);
    setSizeFull();

    Label header = new Label("   -=FoodNote=-");
    header.addStyleName(ValoTheme.LABEL_H1);
    addComponent(header);
    Label body = new Label(
            "<h3> ?? ? ? <b>CRUD</b> ?  ? <b>enterprise</b> ."
                    + "   ?  ?? ,    ?  ? .</h3>"
                    + "? ?:" + "<ul>"
                    + "<li>?  ?  <b>Spring Boot</b>, ? ? - propertie .</li>"
                    + "<li>? ?  ?? ? ???   <b>Repository</b> - <b>Spring Data JPA</b>, <b>Hibernate</b> (<b>JdbcTemplate</b>  ?).</li>"
                    + "<li> ?? - ?? ,  :</li>"
                    + "<ul>" + "<li>  - <b>PostgreSQL</b></li>"
                    + "<li>connection pool - <b>HikariCP</b></li>" + "</ul>"
                    + "<li>? - <b>EhCache</b>.</li>"
                    + "<li> ? -  <b>EventBus</b>, ? <b>Google Guava</b>.</li>"
                    + "<li>?,  - <b>Spring Security</b>:</li>"
                    + "<ul>"
                    + "<li>    , ? <b>UserDetails</b></li>"
                    + "<li> ??   ? <b>BCrypt</b></li>"
                    + "<li>  <b>Remember Me</b> ??</li>"
                    + "</ul>" + "<li>? - <b>JUnit4</b></li>"
                    + "<li> - <b>slf4j</b>, <b>logback</b></li>"
                    + "<li>Front-end - <b>Vaadin framework</b>, <b>GWT</b></li>"
                    + "<li>   <b>Docker</b>      ? <b>Ubuntu Server 14.04</b></li>"
                    + "</ul>"
                    + "<p>? Spring Boot - Vaadin ?? : <a href=\"https://github.com/peholmst/vaadin4spring\">vaadin4spring</a></p>"
                    + "<p> ? <a href=\"https://github.com/BigVOVA/FoodNote\">github.com/BigVOVA/FoodNote</a></p>");
    body.setContentMode(ContentMode.HTML);
    VerticalLayout bodyLayout = new VerticalLayout();
    bodyLayout.setWidth(100, Unit.PERCENTAGE);
    bodyLayout.setMargin(new MarginInfo(false, true, false, true));
    bodyLayout.addComponent(body);
    Panel panel = new Panel();
    panel.setSizeFull();
    panel.setContent(bodyLayout);
    addComponent(panel);
    setExpandRatio(panel, 1);
}

From source file:com.constellio.app.ui.pages.base.MainLayoutImpl.java

protected Component buildLicense() {
    boolean showFooter = !"true".equals(System.getProperty("no_footer_message"));
    Label licenseLabel = new Label($("MainLayout.footerLicense"));
    licenseLabel.addStyleName(ValoTheme.LABEL_TINY);
    licenseLabel.setContentMode(ContentMode.HTML);
    licenseLabel.setVisible(showFooter);
    return licenseLabel;
}

From source file:com.esofthead.mycollab.community.ui.chart.PieChartWrapper.java

License:Open Source License

@Override
protected final ComponentContainer createLegendBox() {
    final CustomLayout boxWrapper = CustomLayoutExt.createLayout("legendBox");
    final CssLayout mainLayout = new CssLayout();

    mainLayout.setSizeUndefined();/* ww  w. j a va2 s.  c  o  m*/
    final List keys = pieDataSet.getKeys();

    for (int i = 0; i < keys.size(); i++) {
        final HorizontalLayout layout = new HorizontalLayout();
        layout.setMargin(new MarginInfo(false, false, false, true));
        layout.addStyleName("inline-block");
        final Comparable key = (Comparable) keys.get(i);
        final String color = "<div style = \" width:8px;height:8px;border-radius:5px;background: #"
                + GenericChartWrapper.CHART_COLOR_STR[i % GenericChartWrapper.CHART_COLOR_STR.length] + "\" />";
        final Label lblCircle = new Label(color);
        lblCircle.setContentMode(ContentMode.HTML);

        String btnCaption;
        if (enumKeyCls == null) {
            btnCaption = String.format("%s(%d)", key, pieDataSet.getValue(key).intValue());
        } else {
            btnCaption = String.format("%s(%d)", AppContext.getMessage(enumKeyCls, key.toString()),
                    pieDataSet.getValue(key).intValue());
        }
        final Button btnLink = new Button(btnCaption, new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                PieChartWrapper.this.onClickedDescription(key.toString());
            }
        });
        btnLink.addStyleName("link");
        layout.addComponent(lblCircle);
        layout.setComponentAlignment(lblCircle, Alignment.MIDDLE_CENTER);
        layout.addComponent(btnLink);
        layout.setComponentAlignment(btnLink, Alignment.MIDDLE_CENTER);
        layout.setSizeUndefined();
        mainLayout.addComponent(layout);
    }
    boxWrapper.setWidth("100%");
    boxWrapper.addComponent(mainLayout, "legendBoxContent");
    return boxWrapper;
}

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

License:Open Source License

@Override
public void displayDashboard() {
    mainLayout.removeAllComponents();/*w  w  w .  ja  va2s.  com*/
    SimpleProject currentProject = CurrentProjectVariables.getProject();
    VerticalLayout projectInfo = new VerticalLayout();
    projectInfo.setStyleName("project-info-layout");
    projectInfo.setWidth("100%");
    projectInfo.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Label projectIcon = new Label("<span aria-hidden=\"true\" data-icon=\"&#xe614\"></span>");
    projectIcon.setStyleName("project-icon");
    projectIcon.setContentMode(ContentMode.HTML);
    projectIcon.setWidthUndefined();
    projectInfo.addComponent(projectIcon);

    Label projectName = new Label(StringUtils.trim(currentProject.getName(), 50, true));
    projectName.setWidth("100%");
    projectName.setStyleName("project-name");
    projectInfo.addComponent(projectName);

    GridLayout projectModulesList = new GridLayout(2, 3);
    projectModulesList.setStyleName("project-modules-layout");
    projectModulesList.setWidth("100%");
    projectModulesList.setSpacing(true);
    projectModulesList.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_MESSAGE), "&#xf04f;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_MILESTONE), "&#xf075;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TASK), "&#xe60f;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_BUG), "&#xf188;"));

    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_FILE), "&#xf017;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_RISK), "&#xf02d;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_PROBLEM), "&#xf0d2;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_TIME), "&#xe612;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_STANDAUP), "&#xf0c0;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_USERS), "&#xe601;"), 0, 2,
            1, 2);

    mainLayout.addComponent(projectInfo);
    mainLayout.addComponent(projectModulesList);
}

From source file:com.esofthead.mycollab.module.file.view.components.FileDownloadWindow.java

License:Open Source License

private void constructBody() {
    final MVerticalLayout layout = new MVerticalLayout();
    final Embedded iconEmbed = new Embedded();
    iconEmbed.setSource(MyCollabResource.newResource("icons/page_white.png"));
    layout.with(iconEmbed).withAlign(iconEmbed, Alignment.MIDDLE_CENTER);

    final GridFormLayoutHelper info = new GridFormLayoutHelper(1, 4, "100%", "80px", Alignment.TOP_LEFT);
    info.getLayout().setWidth("100%");
    info.getLayout().setMargin(new MarginInfo(false, true, false, true));
    info.getLayout().setSpacing(false);//from  w  ww . j  a v a 2 s  .  c o m

    if (this.content.getDescription() != null) {
        final Label desvalue = new Label();
        if (!this.content.getDescription().equals("")) {
            desvalue.setData(this.content.getDescription());
        } else {
            desvalue.setValue("&nbsp;");
            desvalue.setContentMode(ContentMode.HTML);
        }
        info.addComponent(desvalue, "Description", 0, 0);
    }
    final Label author = new Label(this.content.getCreatedBy());
    info.addComponent(author, "Created by", 0, 1);

    final Label size = new Label(ResourceUtils.getVolumeDisplay(this.content.getSize()));
    info.addComponent(size, "Size", 0, 2);

    final Label dateCreate = new Label(AppContext.formatDate(this.content.getCreated().getTime()));
    info.addComponent(dateCreate, "Date created", 0, 3);

    layout.addComponent(info.getLayout());

    final MHorizontalLayout buttonControls = new MHorizontalLayout();
    buttonControls.setSpacing(true);
    buttonControls.setMargin(new MarginInfo(true, false, true, false));

    final Button downloadBtn = new Button("Download");
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(content);

    StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources);

    FileDownloader fileDownloader = new FileDownloader(downloadResource);
    fileDownloader.extend(downloadBtn);

    downloadBtn.addStyleName(UIConstants.THEME_GREEN_LINK);

    buttonControls.with(downloadBtn).withAlign(downloadBtn, Alignment.MIDDLE_CENTER);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    FileDownloadWindow.this.close();
                }
            });
    cancelBtn.addStyleName(UIConstants.THEME_GRAY_LINK);
    buttonControls.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);
    layout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_CENTER);
    this.setContent(layout);
}

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);//from  w  ww  .j a v  a 2s  .  com
    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.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 va  2 s  . com
    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.ui.chart.PieChartWrapper.java

License:Open Source License

@Override
protected final ComponentContainer createLegendBox() {
    final CssLayout mainLayout = new CssLayout();
    mainLayout.addStyleName("legendBoxContent");
    mainLayout.setSizeUndefined();//from  w  ww .ja  v a 2s.  co m
    final List keys = pieDataSet.getKeys();

    for (int i = 0; i < keys.size(); i++) {
        MHorizontalLayout layout = new MHorizontalLayout()
                .withMargin(new MarginInfo(false, false, false, true));
        layout.addStyleName("inline-block");
        layout.setSizeUndefined();
        layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

        final Comparable key = (Comparable) keys.get(i);
        int colorIndex = i % CHART_COLOR_STR.size();
        final String color = "<div style = \" width:13px;height:13px;background: #"
                + CHART_COLOR_STR.get(colorIndex) + "\" />";
        final Label lblCircle = new Label(color);
        lblCircle.setContentMode(ContentMode.HTML);

        String btnCaption;
        if (enumKeyCls == null) {
            if (key instanceof Key) {
                btnCaption = String.format("%s (%d)", StringUtils.trim(((Key) key).getDisplayName(), 20, true),
                        pieDataSet.getValue(key).intValue());
            } else {
                btnCaption = String.format("%s (%d)", key, pieDataSet.getValue(key).intValue());
            }
        } else {
            btnCaption = String.format("%s(%d)", AppContext.getMessage(enumKeyCls, key.toString()),
                    pieDataSet.getValue(key).intValue());
        }
        final Button btnLink = new Button(StringUtils.trim(btnCaption, 25, true), new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                if (key instanceof Key) {
                    clickLegendItem(((Key) key).getKey());
                } else {
                    clickLegendItem(key.toString());
                }
            }
        });
        btnLink.setDescription(btnCaption);
        btnLink.addStyleName(UIConstants.BUTTON_LINK);
        layout.with(lblCircle, btnLink);
        mainLayout.addComponent(layout);
    }
    mainLayout.setWidth("100%");
    return mainLayout;
}