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.klwork.explorer.ui.task.HistoricTaskDetailPanel.java

License:Apache License

protected void initHeader() {
    GridLayout taskDetails = new GridLayout(5, 2);
    taskDetails.setWidth(100, UNITS_PERCENTAGE);
    taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    taskDetails.setSpacing(true);//from w  w  w.j  a va  2 s .com
    taskDetails.setMargin(new MarginInfo(false, false, true, false));

    // Add image
    Embedded image = new Embedded(null, Images.TASK_50);
    taskDetails.addComponent(image, 0, 0, 0, 1);

    // Add task name
    Label nameLabel = new Label(historicTask.getName());
    nameLabel.addStyleName(Reindeer.LABEL_H2);
    taskDetails.addComponent(nameLabel, 1, 0, 4, 0);

    // Add due date
    PrettyTimeLabel dueDateLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_DUEDATE_SHORT),
            historicTask.getDueDate(), i18nManager.getMessage(Messages.TASK_DUEDATE_UNKNOWN), false);
    dueDateLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_DUEDATE);
    taskDetails.addComponent(dueDateLabel, 1, 1);

    // Add priority
    Integer lowMedHighPriority = convertPriority(historicTask.getPriority());
    Label priorityLabel = new Label();
    switch (lowMedHighPriority) {
    case 1:
        priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_LOW));
        priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_LOW);
        break;
    case 2:
        priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_MEDIUM));
        priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_MEDIUM);
        break;
    case 3:
    default:
        priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_HIGH));
        priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_HIGH);
    }
    taskDetails.addComponent(priorityLabel, 2, 1);

    // Add create date
    PrettyTimeLabel createLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_CREATED_SHORT),
            historicTask.getStartTime(), "", true);
    createLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_CREATE_TIME);
    taskDetails.addComponent(createLabel, 3, 1);

    // Add label to fill excess space
    Label spacer = new Label();
    spacer.setContentMode(Label.CONTENT_XHTML);
    spacer.setValue(" ");
    spacer.setSizeUndefined();
    taskDetails.addComponent(spacer);

    taskDetails.setColumnExpandRatio(1, 1.0f);
    taskDetails.setColumnExpandRatio(2, 1.0f);
    taskDetails.setColumnExpandRatio(3, 1.0f);
    taskDetails.setColumnExpandRatio(4, 1.0f);
    centralLayout.addComponent(taskDetails);
}

From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initDescription(HorizontalLayout layout) {
    final CssLayout descriptionLayout = new CssLayout();
    descriptionLayout.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(descriptionLayout);
    layout.setExpandRatio(descriptionLayout, 1.0f);
    layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT);

    String descriptionText = null;
    if (task.getDescription() != null && !"".equals(task.getDescription())) {
        descriptionText = task.getDescription();
    } else {//??
        descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION);
    }/* w  ww.jav a2  s .c  o m*/
    final Label descriptionLabel = new Label(descriptionText);
    descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
    descriptionLayout.addComponent(descriptionLabel);

    descriptionLayout.addLayoutClickListener(new LayoutClickListener() {
        public void layoutClick(LayoutClickEvent event) {
            if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) {
                // layout for textarea + ok button
                final VerticalLayout editLayout = new VerticalLayout();
                editLayout.setSpacing(true);

                // textarea
                final TextArea descriptionTextArea = new TextArea();
                //
                descriptionTextArea.setNullRepresentation("");
                descriptionTextArea.setWidth(100, Unit.PERCENTAGE);
                descriptionTextArea.setValue(task.getDescription());
                editLayout.addComponent(descriptionTextArea);

                // ok button
                Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                editLayout.addComponent(okButton);
                editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT);

                // replace
                descriptionLayout.replaceComponent(descriptionLabel, editLayout);

                // When OK is clicked -> update task data + ui
                okButton.addClickListener(new ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        // Update data
                        task.setDescription(descriptionTextArea.getValue().toString());
                        taskService.saveTask(task);

                        // Update UI
                        descriptionLabel.setValue(task.getDescription());
                        descriptionLayout.replaceComponent(editLayout, descriptionLabel);
                    }
                });
            }
        }
    });
}

From source file:com.mycollab.mobile.module.project.view.message.MessageReadViewImpl.java

License:Open Source License

private void displayItem() {
    mainLayout.removeAllComponents();//from w  ww. ja v a2  s. c  o  m
    MHorizontalLayout messageBlock = new MHorizontalLayout().withSpacing(false).withFullWidth()
            .withStyleName("message-block");
    Image userAvatarImg = UserAvatarControlFactory
            .createUserAvatarEmbeddedComponent(bean.getPostedUserAvatarId(), 32);
    userAvatarImg.addStyleName(UIConstants.CIRCLE_BOX);
    messageBlock.addComponent(userAvatarImg);

    CssLayout rightCol = new CssLayout();
    rightCol.setWidth("100%");

    MHorizontalLayout metadataRow = new MHorizontalLayout().withFullWidth();

    ELabel userNameLbl = new ELabel(bean.getFullPostedUserName()).withStyleName(UIConstants.META_INFO);
    userNameLbl.addStyleName(UIConstants.TEXT_ELLIPSIS);
    CssLayout userNameWrap = new CssLayout(userNameLbl);

    ELabel messageTimePost = new ELabel().prettyDateTime(bean.getPosteddate())
            .withStyleName(UIConstants.META_INFO).withWidthUndefined();
    metadataRow.with(userNameWrap, messageTimePost).withAlign(messageTimePost, Alignment.TOP_RIGHT)
            .expand(userNameWrap);

    rightCol.addComponent(metadataRow);

    CssLayout titleRow = new CssLayout();
    titleRow.setWidth("100%");
    titleRow.setStyleName("title-row");
    Label messageTitle = new Label(bean.getTitle());
    messageTitle.setStyleName("message-title");
    titleRow.addComponent(messageTitle);
    rightCol.addComponent(titleRow);

    Label messageContent = new Label(StringUtils.trimHtmlTags(bean.getMessage()));
    rightCol.addComponent(messageContent);

    ResourceService attachmentService = AppContextUtil.getSpringBean(ResourceService.class);
    List<Content> attachments = attachmentService.getContents(AttachmentUtils.getProjectEntityAttachmentPath(
            MyCollabUI.getAccountId(), bean.getProjectid(), ProjectTypeConstants.MESSAGE, "" + bean.getId()));
    if (CollectionUtils.isNotEmpty(attachments)) {
        CssLayout attachmentPanel = new CssLayout();
        attachmentPanel.setStyleName("attachment-panel");
        attachmentPanel.setWidth("100%");

        for (Content attachment : attachments) {
            attachmentPanel.addComponent(MobileAttachmentUtils.renderAttachmentRow(attachment));
        }
        rightCol.addComponent(attachmentPanel);
    }

    messageBlock.with(rightCol).expand(rightCol);
    mainLayout.addComponent(messageBlock);

    Label commentTitleLbl = new Label();
    Component section = FormSectionBuilder.build(FontAwesome.COMMENT, commentTitleLbl);
    MessageCommentListDisplay commentDisplay = new MessageCommentListDisplay(ProjectTypeConstants.MESSAGE,
            bean.getId() + "", bean.getProjectid(), true);
    int numComments = commentDisplay.getNumComments();
    commentTitleLbl.setValue(UserUIContext.getMessage(GenericI18Enum.OPT_COMMENTS_VALUE, numComments));

    mainLayout.addComponent(section);
    mainLayout.addComponent(commentDisplay);
    this.setToolbar(commentDisplay.getCommentBox());
}

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

License:Open Source License

private void constructBody() {
    final MVerticalLayout layout = new MVerticalLayout().withFullWidth();
    CssLayout iconWrapper = new CssLayout();
    final ELabel iconEmbed = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(content.getName()));
    iconEmbed.addStyleName("icon-48px");
    iconWrapper.addComponent(iconEmbed);
    layout.with(iconWrapper).withAlign(iconWrapper, Alignment.MIDDLE_CENTER);

    final GridFormLayoutHelper inforLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4);

    if (content.getDescription() != null) {
        final Label descLbl = new Label();
        if (!content.getDescription().equals("")) {
            descLbl.setData(content.getDescription());
        } else {//  w  w w.  j a  v  a  2  s.c o  m
            descLbl.setValue("&nbsp;");
            descLbl.setContentMode(ContentMode.HTML);
        }
        inforLayout.addComponent(descLbl, "Description", 0, 0);
    }

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    SimpleUser user = userService.findUserByUserNameInAccount(content.getCreatedUser(),
            AppContext.getAccountId());
    if (user == null) {
        inforLayout.addComponent(new UserLink(AppContext.getUsername(), AppContext.getUserAvatarId(),
                AppContext.getUserDisplayName()), "Created by", 0, 1);
    } else {
        inforLayout.addComponent(new UserLink(user.getUsername(), user.getAvatarid(), user.getDisplayName()),
                "Created by", 0, 1);
    }

    final Label size = new Label(FileUtils.getVolumeDisplay(content.getSize()));
    inforLayout.addComponent(size, "Size", 0, 2);

    ELabel dateCreate = new ELabel().prettyDateTime(content.getCreated().getTime());
    inforLayout.addComponent(dateCreate, "Created date", 0, 3);

    layout.addComponent(inforLayout.getLayout());

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

    final Button downloadBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD));
    List<Resource> resources = new ArrayList<>();
    resources.add(content);

    StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources);

    FileDownloader fileDownloader = new FileDownloader(downloadResource);
    fileDownloader.extend(downloadBtn);
    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.addStyleName(UIConstants.BUTTON_ACTION);

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

                @Override
                public void buttonClick(ClickEvent event) {
                    close();
                }
            });
    cancelBtn.addStyleName(UIConstants.BUTTON_OPTION);
    buttonControls.with(cancelBtn, downloadBtn).alignAll(Alignment.TOP_RIGHT);
    layout.with(buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT);
    this.setContent(layout);
}

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

License:Open Source License

private void constructBody() {
    final MVerticalLayout layout = new MVerticalLayout().withFullWidth();
    CssLayout iconWrapper = new CssLayout();
    final ELabel iconEmbed = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(content.getName()));
    iconEmbed.addStyleName("icon-48px");
    iconWrapper.addComponent(iconEmbed);
    layout.with(iconWrapper).withAlign(iconWrapper, Alignment.MIDDLE_CENTER);

    final GridFormLayoutHelper inforLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4);

    if (content.getDescription() != null) {
        final Label descLbl = new Label();
        if (!content.getDescription().equals("")) {
            descLbl.setData(content.getDescription());
        } else {//w  ww.  ja  v  a 2 s  .c  o m
            descLbl.setValue("&nbsp;");
            descLbl.setContentMode(ContentMode.HTML);
        }
        inforLayout.addComponent(descLbl, UserUIContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0, 0);
    }

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    SimpleUser user = userService.findUserByUserNameInAccount(content.getCreatedUser(),
            MyCollabUI.getAccountId());
    if (user == null) {
        inforLayout.addComponent(
                new UserLink(UserUIContext.getUsername(), UserUIContext.getUserAvatarId(),
                        UserUIContext.getUserDisplayName()),
                UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1);
    } else {
        inforLayout.addComponent(new UserLink(user.getUsername(), user.getAvatarid(), user.getDisplayName()),
                UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1);
    }

    final Label size = new Label(FileUtils.getVolumeDisplay(content.getSize()));
    inforLayout.addComponent(size, UserUIContext.getMessage(FileI18nEnum.OPT_SIZE), 0, 2);

    ELabel dateCreate = new ELabel().prettyDateTime(content.getCreated().getTime());
    inforLayout.addComponent(dateCreate, UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME), 0, 3);

    layout.addComponent(inforLayout.getLayout());

    MButton downloadBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD))
            .withIcon(FontAwesome.DOWNLOAD).withStyleName(WebThemes.BUTTON_ACTION);
    List<Resource> resources = new ArrayList<>();
    resources.add(content);

    StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources);

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

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);
    final MHorizontalLayout buttonControls = new MHorizontalLayout(cancelBtn, downloadBtn);
    layout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);
    this.setContent(layout);
}

From source file:com.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%");
                MHorizontalLayout informBox = new MHorizontalLayout(informLbl).withFullHeight()
                        .withStyleName("trialInformBox");
                informBox.setMargin(new MarginInfo(false, true, false, false));
                informBox.addLayoutClickListener(layoutClickEvent -> 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%");
                MHorizontalLayout informBox = new MHorizontalLayout(informLbl).withStyleName("trialInformBox")
                        .withMargin(new MarginInfo(false, true, false, false)).withFullHeight();
                informBox.addLayoutClickListener(layoutClickEvent -> 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 ended<br></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));
                }/*from  w  ww  . j  a  va2s  .  c o m*/
            }
        }
    }

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

    if (SiteConfiguration.isCommunityEdition()) {
        MButton buyPremiumBtn = new MButton("Upgrade to Pro edition",
                clickEvent -> UI.getCurrent().addWindow(new AdWindow())).withIcon(FontAwesome.SHOPPING_CART)
                        .withStyleName("ad");
        accountLayout.addComponent(buyPremiumBtn);
    }

    LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class);
    if (licenseResolver != null) {
        LicenseInfo licenseInfo = licenseResolver.getLicenseInfo();
        if (licenseInfo != null) {
            if (licenseInfo.isExpired()) {
                MButton buyPremiumBtn = new MButton(AppContext.getMessage(LicenseI18nEnum.EXPIRE_NOTIFICATION),
                        clickEvent -> UI.getCurrent().addWindow(new BuyPremiumSoftwareWindow()))
                                .withIcon(FontAwesome.SHOPPING_CART).withStyleName("ad");
                accountLayout.addComponent(buyPremiumBtn);
            } else if (licenseInfo.isTrial()) {
                Duration dur = new Duration(new DateTime(), new DateTime(licenseInfo.getExpireDate()));
                int days = dur.toStandardDays().getDays();
                MButton buyPremiumBtn = new MButton(
                        AppContext.getMessage(LicenseI18nEnum.TRIAL_NOTIFICATION, days),
                        clickEvent -> UI.getCurrent().addWindow(new BuyPremiumSoftwareWindow()))
                                .withIcon(FontAwesome.SHOPPING_CART).withStyleName("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();

    MButton myProfileBtn = new MButton(AppContext.getMessage(AdminI18nEnum.VIEW_PROFILE), clickEvent -> {
        accountMenu.setPopupVisible(false);
        EventBusFactory.getInstance()
                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" }));
    }).withIcon(SettingAssetsManager.getAsset(SettingUIConstants.PROFILE));
    accountPopupContent.addOption(myProfileBtn);

    MButton userMgtBtn = new MButton(AppContext.getMessage(AdminI18nEnum.VIEW_USERS_AND_ROLES), clickEvent -> {
        accountMenu.setPopupVisible(false);
        EventBusFactory.getInstance()
                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" }));
    }).withIcon(SettingAssetsManager.getAsset(SettingUIConstants.USERS));
    accountPopupContent.addOption(userMgtBtn);

    MButton generalSettingBtn = new MButton(AppContext.getMessage(AdminI18nEnum.VIEW_SETTING), clickEvent -> {
        accountMenu.setPopupVisible(false);
        EventBusFactory.getInstance()
                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setting", "general" }));
    }).withIcon(SettingAssetsManager.getAsset(SettingUIConstants.GENERAL_SETTING));
    accountPopupContent.addOption(generalSettingBtn);

    MButton themeCustomizeBtn = new MButton(AppContext.getMessage(AdminI18nEnum.VIEW_THEME), clickEvent -> {
        accountMenu.setPopupVisible(false);
        EventBusFactory.getInstance()
                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setting", "theme" }));
    }).withIcon(SettingAssetsManager.getAsset(SettingUIConstants.THEME_CUSTOMIZE));
    accountPopupContent.addOption(themeCustomizeBtn);

    if (!SiteConfiguration.isDemandEdition()) {
        MButton setupBtn = new MButton(AppContext.getMessage(AdminI18nEnum.VIEW_SETUP), clickEvent -> {
            accountMenu.setPopupVisible(false);
            EventBusFactory.getInstance()
                    .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setup" }));
        }).withIcon(FontAwesome.WRENCH);
        accountPopupContent.addOption(setupBtn);
    }

    accountPopupContent.addSeparator();

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

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

    MButton translateBtn = new MButton(AppContext.getMessage(GenericI18Enum.ACTION_TRANSLATE))
            .withIcon(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()) {
        MButton myAccountBtn = new MButton(AppContext.getMessage(AdminI18nEnum.VIEW_BILLING), clickEvent -> {
            accountMenu.setPopupVisible(false);
            EventBusFactory.getInstance()
                    .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
        }).withIcon(SettingAssetsManager.getAsset(SettingUIConstants.BILLING));
        accountPopupContent.addOption(myAccountBtn);
    }

    accountPopupContent.addSeparator();
    MButton aboutBtn = new MButton("About MyCollab", clickEvent -> {
        accountMenu.setPopupVisible(false);
        Window aboutWindow = ViewManager.getCacheComponent(AbstractAboutWindow.class);
        UI.getCurrent().addWindow(aboutWindow);
    }).withIcon(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);

    MButton signoutBtn = new MButton(AppContext.getMessage(GenericI18Enum.BUTTON_SIGNOUT), clickEvent -> {
        accountMenu.setPopupVisible(false);
        EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null));
    }).withIcon(FontAwesome.SIGN_OUT);
    accountPopupContent.addSeparator();
    accountPopupContent.addOption(signoutBtn);

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

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.promote.ArticlePromotionViewImpl.java

License:Open Source License

private void createAlert() {
    VerticalLayout alertTextLayout = new VerticalLayout();
    alertTextLayout.setSpacing(true);/*ww w.jav a  2  s .  c o  m*/
    alertTextLayout.setCaption("Alert Text");

    MagnoliaRichTextField textField = (MagnoliaRichTextField) listener.createRichTextField();
    textField.setSizeFull();

    HorizontalLayout periodLayout = new HorizontalLayout();
    periodLayout.setSpacing(true);
    // periodLayout.setWidth("100%");
    DateField startDate = new DateField();
    // startDate.setWidth("100%");
    DateField endDate = new DateField();
    // endDate.setWidth("100%");

    periodLayout.addComponent(new Label("START"));
    periodLayout.addComponent(startDate);
    periodLayout.addComponent(new Label("END"));
    periodLayout.addComponent(endDate);

    alertTextLayout.addComponent(textField);
    alertTextLayout.addComponent(periodLayout);

    HorizontalLayout alertLayout = new HorizontalLayout();
    alertLayout.setSpacing(true);
    alertLayout.setWidth("100%");
    alertLayout.addComponent(alertTextLayout);

    final Label alertPreview = new Label("", ContentMode.HTML);
    alertPreview.setCaption("Alert Preview");
    alertPreview.addStyleName("preview-label");
    textField.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            alertPreview.setValue(String.valueOf(event.getProperty().getValue()));
        }
    });
    alertPreview.setSizeUndefined();
    alertLayout.addComponent(alertPreview);
    alert.setContent(alertLayout);

    textField.setValue(
            "<b>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,</b>");
}

From source file:com.ocs.dynamo.ui.composite.layout.BaseCustomComponent.java

License:Apache License

/**
 * Constructs a (formatted) label based on the attribute model
 * /*w  w  w.j a  v a  2 s  .  c om*/
 * @param entity
 *            the entity that is being displayed
 * @param attributeModel
 * @return
 */
@SuppressWarnings("unchecked")
protected Component constructLabel(Object entity, AttributeModel attributeModel) {
    Label fieldLabel = new Label();
    fieldLabel.setCaption(attributeModel.getDisplayName());

    Object value = ClassUtils.getFieldValue(entity, attributeModel.getName());
    if (value != null) {
        Class<?> type = attributeModel.getType();
        Property<?> property = null;
        if (attributeModel.isWeek()) {
            property = new ObjectProperty<Date>((Date) value);
            fieldLabel.setConverter(new WeekCodeConverter());
            fieldLabel.setPropertyDataSource(property);
        } else if (String.class.equals(type)) {
            // string
            property = new ObjectProperty<String>((String) value);
            fieldLabel.setPropertyDataSource(property);
        } else if (Date.class.equals(type)) {
            property = new ObjectProperty<Date>((Date) value);
            if (AttributeDateType.TIME.equals(attributeModel.getDateType())) {
                // for a time, do not include a time zone (we have no way of
                // knowing it!)
                fieldLabel.setConverter(
                        new FormattedStringToDateConverter(null, attributeModel.getDisplayFormat()));
            } else {
                fieldLabel.setConverter(new FormattedStringToDateConverter(
                        VaadinUtils.getTimeZone(UI.getCurrent()), attributeModel.getDisplayFormat()));
            }
        } else if (attributeModel.getType().isEnum()) {
            String msg = getMessageService().getEnumMessage((Class<Enum<?>>) attributeModel.getType(),
                    (Enum<?>) value);
            if (msg != null) {
                fieldLabel.setValue(msg);
            }
        } else if (BigDecimal.class.equals(type)) {
            property = new ObjectProperty<BigDecimal>((BigDecimal) value);
            fieldLabel.setConverter(ConverterFactory.createBigDecimalConverter(attributeModel.isCurrency(),
                    attributeModel.isPercentage(), attributeModel.isUseThousandsGrouping(),
                    attributeModel.getPrecision(), VaadinUtils.getCurrencySymbol()));
        } else if (Integer.class.equals(type)) {
            property = new ObjectProperty<Integer>((Integer) value);
            fieldLabel.setConverter(
                    ConverterFactory.createIntegerConverter(attributeModel.isUseThousandsGrouping()));
        } else if (Long.class.equals(type)) {
            property = new ObjectProperty<Long>((Long) value);
            fieldLabel.setConverter(
                    ConverterFactory.createLongConverter(attributeModel.isUseThousandsGrouping()));
        } else if (AbstractEntity.class.isAssignableFrom(type)) {
            // another entity - use the value of the "displayProperty"
            EntityModel<?> model = getEntityModelFactory().getModel(type);
            String displayProperty = model.getDisplayProperty();
            property = new NestedMethodProperty<String>(value, displayProperty);
        } else if (attributeModel.isImage()) {
            // create image preview
            final byte[] bytes = ClassUtils.getBytes(entity, attributeModel.getName());
            Embedded image = new DefaultEmbedded(attributeModel.getDisplayName(), bytes);
            image.setStyleName(DynamoConstants.CSS_CLASS_UPLOAD);
            return image;
        } else if (Boolean.class.equals(attributeModel.getType())
                || boolean.class.equals(attributeModel.getType())) {
            if (!StringUtils.isEmpty(attributeModel.getTrueRepresentation()) && Boolean.TRUE.equals(value)) {
                property = new ObjectProperty<String>(attributeModel.getTrueRepresentation());
            } else if (!StringUtils.isEmpty(attributeModel.getFalseRepresentation())
                    && Boolean.FALSE.equals(value)) {
                property = new ObjectProperty<String>(attributeModel.getFalseRepresentation());
            } else {
                property = new ObjectProperty<Boolean>((Boolean) value);
                fieldLabel.setConverter(new StringToBooleanConverter());
            }
        } else if (Iterable.class.isAssignableFrom(attributeModel.getType())) {
            // collection of entities
            String str = TableUtils.formatEntityCollection(getEntityModelFactory(), (Iterable<?>) value);
            property = new ObjectProperty<String>(str);
            fieldLabel.setPropertyDataSource(property);
        }

        if (attributeModel.isNumerical()) {
            fieldLabel.setStyleName(DynamoConstants.CSS_NUMERICAL);
        }

        if (property != null) {
            fieldLabel.setPropertyDataSource(property);
        }
    }
    return fieldLabel;
}

From source file:com.peergreen.webconsole.scope.logs.stream.TextColumnGenerator.java

License:Open Source License

/**
 * Generates the cell containing the Date value. The column is
 * irrelevant in this use case.//  w w w .j ava 2  s  .  c o  m
 */
@Override
public Component generateCell(Table source, Object itemId, Object columnId) {

    BeanItem<TableEntry> item = (BeanItem<TableEntry>) source.getItem(itemId);
    TableEntry tableEntry = item.getBean();
    Property<?> prop = item.getItemProperty(columnId);
    Label label = new Label();

    String text = item.getBean().getText().replaceAll(" ", "&nbsp;");

    if (StreamType.OUT.name().equals(item.getBean().getType()) || "INFO".equals(item.getBean().getType())) {
        label.setValue("<font color='black'>".concat(text).concat("</font>"));
    } else if (StreamType.ERR.name().equals(item.getBean().getType())
            || "ERROR".equals(item.getBean().getType())) {
        label.setValue("<font color='red'>".concat(text).concat("</font>"));
    } else if ("DEBUG".equals(item.getBean().getType())) {
        label.setValue("<font color='grey'>".concat(text).concat("</font>"));
    } else if ("WARNING".equals(item.getBean().getType())) {
        label.setValue("<font color='orange'>".concat(text).concat("</font>"));
    } else if ("SEVERE".equals(item.getBean().getType())) {
        label.setValue("<font color='red'>".concat(text).concat("</font>"));
    } else {
        label.setValue("<font color='black'>".concat(text).concat("</font>"));
    }

    label.setValue("<div style='font-family:Monaco, Menlo, Consolas, monospace;font-size:small;'>"
            .concat(label.getValue().concat("</div>")));

    label.setContentMode(ContentMode.HTML);
    return label;

}

From source file:com.philippefichet.vaadincdipush.view.FirstView.java

public void renameNewUser(String login, String newLogin) {
    for (int i = 0; i < listUserLayout.getComponentCount(); i++) {
        Label l = (Label) listUserLayout.getComponent(i);
        if (l.getValue().equals(login)) {
            l.setValue(newLogin);
            break;
        }//from  ww  w  . ja  v a  2  s.  co m
    }
}