Example usage for com.vaadin.ui Label addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:com.mcparland.john.vaadin_mvn_arch.samples.ErrorView.java

License:Apache License

public ErrorView() {
    setMargin(true);//from ww  w  .j  av a 2  s .c o m
    setSpacing(true);

    Label header = new Label("The view could not be found");
    header.addStyleName(Reindeer.LABEL_H1);
    addComponent(header);
    addComponent(explanation = new Label());
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.Menu.java

License:Apache License

public Menu(Navigator navigator) {
    this.navigator = navigator;
    setPrimaryStyleName(ValoTheme.MENU_ROOT);
    menuPart = new CssLayout();
    menuPart.addStyleName(ValoTheme.MENU_PART);

    // header of the menu
    final HorizontalLayout top = new HorizontalLayout();
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName(ValoTheme.MENU_TITLE);
    top.setSpacing(true);// w  w  w. ja  va 2 s .  c o m
    Label title = new Label("My CRUD");
    title.addStyleName(ValoTheme.LABEL_H3);
    title.setSizeUndefined();
    Image image = new Image(null, new ThemeResource("img/table-logo.png"));
    image.setStyleName("logo");
    top.addComponent(image);
    top.addComponent(title);
    menuPart.addComponent(top);

    // logout menu item
    MenuBar logoutMenu = new MenuBar();
    logoutMenu.addItem("Logout", FontAwesome.SIGN_OUT, new Command() {

        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void menuSelected(MenuItem selectedItem) {
            VaadinSession.getCurrent().getSession().invalidate();
            Page.getCurrent().reload();
        }
    });

    logoutMenu.addStyleName("user-menu");
    menuPart.addComponent(logoutMenu);

    // button for toggling the visibility of the menu when on a small screen
    final Button showMenu = new Button("Menu", new ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) {
                menuPart.removeStyleName(VALO_MENU_VISIBLE);
            } else {
                menuPart.addStyleName(VALO_MENU_VISIBLE);
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName(VALO_MENU_TOGGLE);
    showMenu.setIcon(FontAwesome.NAVICON);
    menuPart.addComponent(showMenu);

    // container for the navigation buttons, which are added by addView()
    menuItemsLayout = new CssLayout();
    menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS);
    menuPart.addComponent(menuItemsLayout);

    addComponent(menuPart);
}

From source file:com.mechanicshop.components.TableLayout.java

private void buildLayout() {
    HorizontalLayout layoutTitle = new HorizontalLayout();
    layoutTitle.setSizeUndefined();//from   w ww  .jav a  2 s . c o m
    layoutTitle.setWidth("100%");
    layoutTitle.setSpacing(false);
    layoutTitle.setMargin(false);
    titleLabel.addStyleName(ValoTheme.LABEL_H2);
    titleLabel.addStyleName(ValoTheme.LABEL_COLORED);
    titleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    titleLabel.addStyleName(ValoTheme.LABEL_BOLD);
    titleLabel.setSizeUndefined();

    layoutTitle.addComponent(titleLabel);
    layoutTitle.setComponentAlignment(titleLabel, Alignment.MIDDLE_CENTER);

    VerticalLayout layoutTable = new VerticalLayout();

    layoutTable.addComponent(table);
    layoutTable.setComponentAlignment(table, Alignment.TOP_CENTER);
    layoutTable.setSizeFull();

    layoutTable.setSpacing(true);
    HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.setMargin(false);
    layoutButtons.setSpacing(true);
    layoutButtons.setSizeUndefined();
    layoutButtons.setWidth("100%");
    Button addBtn = new Button("Add new Car");
    addBtn.addClickListener(addBtnListener);
    addBtn.setImmediate(true);
    addBtn.setStyleName(ValoTheme.BUTTON_TINY);
    addBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    Button deleteBtn = new Button("Delete Selected");
    deleteBtn.setStyleName(ValoTheme.BUTTON_TINY);
    deleteBtn.addStyleName(ValoTheme.BUTTON_DANGER);
    deleteBtn.setImmediate(true);
    deleteBtn.addClickListener(removeListener);

    btnSendSMS.setStyleName(ValoTheme.BUTTON_TINY);
    btnSendSMS.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    btnSendSMS.setImmediate(true);
    btnSendSMS.addClickListener(sendSMSBtnListener);

    searchTextField.setImmediate(true);
    searchTextField.addStyleName(ValoTheme.TEXTFIELD_TINY);
    searchTextField.addTextChangeListener(filterChangeListener);
    Label lbSearch = new Label("Search");
    lbSearch.addStyleName(ValoTheme.LABEL_TINY);
    lbSearch.setSizeUndefined();
    layoutButtons.addComponents(lbSearch, searchTextField, addBtn, deleteBtn, btnSendSMS);

    layoutButtons.setComponentAlignment(lbSearch, Alignment.MIDDLE_LEFT);
    layoutButtons.setComponentAlignment(searchTextField, Alignment.BOTTOM_LEFT);
    layoutButtons.setComponentAlignment(addBtn, Alignment.BOTTOM_RIGHT);
    layoutButtons.setComponentAlignment(deleteBtn, Alignment.BOTTOM_RIGHT);
    layoutButtons.setComponentAlignment(btnSendSMS, Alignment.BOTTOM_RIGHT);
    layoutButtons.setExpandRatio(addBtn, 3);
    addComponent(layoutTitle);
    addComponent(layoutTable);
    layoutTable.addComponent(layoutButtons);
    layoutTable.setExpandRatio(table, 3);
    setComponentAlignment(layoutTitle, Alignment.TOP_CENTER);
    setComponentAlignment(layoutTable, Alignment.TOP_CENTER);
    setExpandRatio(layoutTable, 3);
    setSpacing(true);
    setMargin(true);

}

From source file:com.mycollab.community.shell.view.components.AboutWindow.java

License:Open Source License

public AboutWindow() {

    MHorizontalLayout content = new MHorizontalLayout().withMargin(true).withFullWidth();
    this.setContent(content);

    Image about = new Image("",
            new ExternalResource(StorageFactory.generateAssetRelativeLink(WebResourceIds._about)));
    MVerticalLayout rightPanel = new MVerticalLayout();
    ELabel versionLbl = ELabel.h2(String.format("MyCollab Community Edition %s", Version.getVersion()));
    Label javaNameLbl = new Label(String.format("%s, %s", System.getProperty("java.vm.name"),
            System.getProperty("java.runtime.version")));
    Label homeFolderLbl = new Label("Home folder: " + FileUtils.getHomeFolder().getAbsolutePath());
    WebBrowser browser = Page.getCurrent().getWebBrowser();
    Label osLbl = new Label(
            String.format("%s, %s", System.getProperty("os.name"), browser.getBrowserApplication()));
    osLbl.addStyleName(UIConstants.LABEL_WORD_WRAP);
    Div licenseDiv = new Div().appendChild(new Text("Powered by: "))
            .appendChild(new A("https://www.mycollab.com").appendText("MyCollab"))
            .appendChild(new Text(". Open source under GPL license"));
    Label licenseLbl = new Label(licenseDiv.write(), ContentMode.HTML);
    Label copyRightLbl = new Label(String.format("© %s - %s MyCollab Ltd. All rights reserved", "2011",
            new GregorianCalendar().get(Calendar.YEAR) + ""), ContentMode.HTML);
    rightPanel.with(versionLbl, javaNameLbl, osLbl, homeFolderLbl, licenseLbl, copyRightLbl)
            .withAlign(copyRightLbl, Alignment.BOTTOM_LEFT);
    content.with(about, rightPanel).expand(rightPanel);
}

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

License:Open Source License

@Override
protected MHorizontalLayout buildAccountMenuLayout() {
    accountLayout.removeAllComponents();

    Label accountNameLabel = new Label(MyCollabUI.getSubDomain());
    accountNameLabel.addStyleName("subDomain");
    accountLayout.addComponent(accountNameLabel);

    /*MButton buyPremiumBtn = new MButton("", clickEvent -> UI.getCurrent().addWindow(new AdWindow()))
        .withIcon(FontAwesome.SHOPPING_CART).withStyleName("ad")
        .withDescription(UserUIContext.getMessage(LicenseI18nEnum.OPT_TRIAL_THE_PRO_EDITION));
    accountLayout.addComponent(buyPremiumBtn);*/

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

    if (StringUtils.isBlank(UserUIContext.getUser().getAvatarid())) {
        EventBusFactory.getInstance()//  w ww. j a  v a2  s .  c  o m
                .post(new ShellEvent.NewNotification(this, new RequestUploadAvatarNotification()));
    }

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

    SimpleUser user = UserUIContext.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(UserUIContext.getUserAvatarId(), 24);
    final PopupButton accountMenu = new PopupButton("");
    accountMenu.setIcon(userAvatarRes);
    accountMenu.setDescription(UserUIContext.getUserDisplayName());

    OptionPopupContent accountPopupContent = new OptionPopupContent();

    MButton myProfileBtn = new MButton(UserUIContext.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(UserUIContext.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(UserUIContext.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 setupBtn = new MButton(UserUIContext.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(UserUIContext.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(UserUIContext.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(UserUIContext.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);*/

    accountPopupContent.addSeparator();
    /* MButton aboutBtn = new MButton(UserUIContext.getMessage(ShellI18nEnum.OPT_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(UserUIContext.getMessage(ShellI18nEnum.OPT_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(UserUIContext.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.mycollab.module.project.ui.components.ProjectMemberBlock.java

License:Open Source License

public ProjectMemberBlock(String username, String userAvatarId, String displayName) {
    withMargin(false).withWidth("80px");
    Image userAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(userAvatarId, 48,
            displayName);//from ww w  .  j a va  2s  .  c  o m
    userAvatar.addStyleName(UIConstants.CIRCLE_BOX);
    A userLink = new A()
            .setId("tag" + TOOLTIP_ID).setHref(ProjectLinkBuilder
                    .generateProjectMemberFullLink(CurrentProjectVariables.getProjectId(), username))
            .appendText(StringUtils.trim(displayName, 30, true));
    userLink.setAttribute("onmouseover", TooltipHelper.userHoverJsFunction(username));
    userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction());
    Label userLbl = new Label(userLink.write(), ContentMode.HTML);
    userLbl.addStyleName(ValoTheme.LABEL_SMALL);
    with(userAvatar, userLbl);
}

From source file:com.mycollab.module.project.view.bug.BugTableDisplay.java

License:Open Source License

BugTableDisplay(String viewId, TableViewField requiredColumn, List<TableViewField> displayColumns) {
    super(AppContextUtil.getSpringBean(BugService.class), SimpleBug.class, viewId, requiredColumn,
            displayColumns);//w w w. j av  a  2 s .c  o m

    this.addGeneratedColumn("assignuserFullName", (source, itemId, columnId) -> {
        SimpleBug bug = getBeanByIndex(itemId);
        return new ProjectUserLink(bug.getAssignuser(), bug.getAssignUserAvatarId(),
                bug.getAssignuserFullName());
    });

    this.addGeneratedColumn("loguserFullName", (source, itemId, columnId) -> {
        SimpleBug bug = getBeanByIndex(itemId);
        return new ProjectUserLink(bug.getCreateduser(), bug.getLoguserAvatarId(), bug.getLoguserFullName());
    });

    this.addGeneratedColumn("name", (source, itemId, columnId) -> {
        SimpleBug bug = getBeanByIndex(itemId);
        LabelLink b = new LabelLink(bug.getName(),
                ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName()));

        if (StringUtils.isNotBlank(bug.getPriority())) {
            b.setIconLink(ProjectAssetsManager.getPriority(bug.getPriority()));
            b.addStyleName("priority-" + bug.getPriority().toLowerCase());
        }

        b.setDescription(ProjectTooltipGenerator.generateToolTipBug(UserUIContext.getUserLocale(),
                MyCollabUI.getDateFormat(), bug, MyCollabUI.getSiteUrl(), UserUIContext.getUserTimeZone(),
                false));

        if (bug.isCompleted()) {
            b.addStyleName(WebThemes.LINK_COMPLETED);
        } else if (bug.isOverdue()) {
            b.addStyleName(WebThemes.LINK_OVERDUE);
        }
        return b;
    });

    this.addGeneratedColumn("severity", (source, itemId, columnId) -> {
        SimpleBug bug = getBeanByIndex(itemId);
        Label lbPriority = new Label(UserUIContext.getMessage(BugSeverity.class, bug.getSeverity()));
        lbPriority.setIcon(FontAwesome.STAR);
        if (bug.getSeverity() != null) {
            lbPriority.addStyleName("bug-severity-" + bug.getSeverity().toLowerCase());
        }
        return lbPriority;
    });

    this.addGeneratedColumn("duedate", (source, itemId, columnId) -> {
        SimpleBug bug = getBeanByIndex(itemId);
        return new ELabel().prettyDate(bug.getDuedate());
    });

    this.addGeneratedColumn("createdtime", (source, itemId, columnId) -> {
        SimpleBug bug = getBeanByIndex(itemId);
        return new ELabel().prettyDateTime(bug.getCreatedtime());
    });

    this.addGeneratedColumn("resolution", (source, itemId, columnId) -> {
        SimpleBug bug = getBeanByIndex(itemId);
        return new Label(UserUIContext.getMessage(BugResolution.class, bug.getResolution()));
    });
    this.setWidth("100%");
}

From source file:com.mycollab.module.project.view.page.PageListViewImpl.java

License:Open Source License

private Layout displayFolderBlock(final Folder resource) {
    MVerticalLayout container = new MVerticalLayout().withFullWidth().withStyleName("page-item-block");

    A folderHtml = new A(ProjectLinkBuilder.generatePageFolderFullLink(CurrentProjectVariables.getProjectId(),
            resource.getPath())).appendText(FontAwesome.FOLDER_OPEN.getHtml() + " " + resource.getName());
    ELabel folderLink = ELabel.h3(folderHtml.write());
    container.addComponent(folderLink);/* w w  w .  j a  v a  2 s .c  o  m*/
    if (StringUtils.isNotBlank(resource.getDescription())) {
        container.addComponent(new Label(StringUtils.trimHtmlTags(resource.getDescription())));
    }

    Label lastUpdateInfo = new ELabel(UserUIContext.getMessage(PageI18nEnum.LABEL_LAST_UPDATE,
            ProjectLinkBuilder.generateProjectMemberHtmlLink(CurrentProjectVariables.getProjectId(),
                    resource.getCreatedUser(), true),
            UserUIContext.formatPrettyTime(resource.getCreatedTime().getTime())), ContentMode.HTML)
                    .withDescription(UserUIContext.formatDateTime(resource.getCreatedTime().getTime()));
    lastUpdateInfo.addStyleName(UIConstants.META_INFO);
    container.addComponent(lastUpdateInfo);

    MButton editBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_EDIT),
            clickEvent -> UI.getCurrent().addWindow(new GroupPageAddWindow(resource)))
                    .withStyleName(WebThemes.BUTTON_LINK, WebThemes.BUTTON_SMALL_PADDING)
                    .withIcon(FontAwesome.EDIT);
    editBtn.setVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));

    MButton deleteBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DELETE), clickEvent -> {
        ConfirmDialogExt.show(UI.getCurrent(),
                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()),
                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                    if (confirmDialog.isConfirmed()) {
                        PageService pageService = AppContextUtil.getSpringBean(PageService.class);
                        pageService.removeResource(resource.getPath());
                        resources.remove(resource);
                        displayPages(resources);
                    }
                });
    }).withIcon(FontAwesome.TRASH_O).withStyleName(WebThemes.BUTTON_LINK, WebThemes.BUTTON_SMALL_PADDING);
    deleteBtn.setVisible(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PAGES));

    container.addComponent(new MHorizontalLayout(editBtn, deleteBtn));
    return container;
}

From source file:com.mycollab.module.project.view.page.PageListViewImpl.java

License:Open Source License

private Layout displayPageBlock(final Page resource) {
    MVerticalLayout container = new MVerticalLayout().withFullWidth().withStyleName("page-item-block");
    A pageHtml = new A(
            ProjectLinkBuilder.generatePageFullLink(CurrentProjectVariables.getProjectId(), resource.getPath()))
                    .appendText(FontAwesome.FILE_WORD_O.getHtml() + " " + resource.getSubject());
    ELabel pageLink = ELabel.h3(pageHtml.write());

    container.with(pageLink, new SafeHtmlLabel(resource.getContent(), 400));

    Label lastUpdateInfo = new ELabel(UserUIContext.getMessage(PageI18nEnum.LABEL_LAST_UPDATE,
            ProjectLinkBuilder.generateProjectMemberHtmlLink(CurrentProjectVariables.getProjectId(),
                    resource.getLastUpdatedUser(), true),
            UserUIContext.formatPrettyTime(resource.getLastUpdatedTime().getTime())), ContentMode.HTML)
                    .withDescription(UserUIContext.formatDateTime(resource.getLastUpdatedTime().getTime()));
    lastUpdateInfo.addStyleName(UIConstants.META_INFO);
    container.addComponent(lastUpdateInfo);

    MButton editBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_EDIT),
            clickEvent -> EventBusFactory.getInstance()
                    .post(new PageEvent.GotoEdit(PageListViewImpl.this, resource))).withIcon(FontAwesome.EDIT)
                            .withStyleName(WebThemes.BUTTON_LINK, WebThemes.BUTTON_SMALL_PADDING);
    editBtn.setVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));

    MButton deleteBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DELETE), clickEvent -> {
        ConfirmDialogExt.show(UI.getCurrent(),
                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()),
                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                    if (confirmDialog.isConfirmed()) {
                        PageService pageService = AppContextUtil.getSpringBean(PageService.class);
                        pageService.removeResource(resource.getPath());
                        resources.remove(resource);
                        displayPages(resources);
                    }/*from  w  w  w  .  j av  a 2 s  .  c o m*/
                });
    }).withIcon(FontAwesome.TRASH_O).withStyleName(WebThemes.BUTTON_LINK, WebThemes.BUTTON_SMALL_PADDING);
    deleteBtn.setVisible(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PAGES));

    container.addComponent(new MHorizontalLayout(editBtn, deleteBtn));
    return container;
}

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 ww  w . jav a 2s  . 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;
}