List of usage examples for com.vaadin.ui Alignment TOP_RIGHT
Alignment TOP_RIGHT
To view the source code for com.vaadin.ui Alignment TOP_RIGHT.
Click Source Link
From source file:com.mycollab.module.crm.view.CrmHomeViewImpl.java
License:Open Source License
@Override protected void displayView() { MHorizontalLayout contentLayout = new MHorizontalLayout().withMargin(true).withFullWidth(); MVerticalLayout myAssignmentsLayout = new MVerticalLayout() .withMargin(new MarginInfo(false, false, true, false)); if (UserUIContext.canRead(RolePermissionCollections.CRM_ACCOUNT)) { accountDashlet = new AccountListDashlet(); myAssignmentsLayout.addComponent(accountDashlet); }/*from ww w . j a v a 2 s .c o m*/ if (UserUIContext.canRead(RolePermissionCollections.CRM_MEETING)) { meetingDashlet = new MeetingListDashlet(); myAssignmentsLayout.addComponent(meetingDashlet); } if (UserUIContext.canRead(RolePermissionCollections.CRM_CALL)) { callDashlet = new CallListDashlet(); myAssignmentsLayout.addComponent(callDashlet); } if (UserUIContext.canRead(RolePermissionCollections.CRM_LEAD)) { leadDashlet = new LeadListDashlet(); myAssignmentsLayout.addComponent(leadDashlet); } contentLayout.with(myAssignmentsLayout).expand(myAssignmentsLayout); MVerticalLayout streamsLayout = new MVerticalLayout().withMargin(new MarginInfo(true, false, false, true)); streamsLayout.setSizeUndefined(); salesDashboard = new SalesDashboardView(); salesDashboard.setWidth("550px"); streamsLayout.with(salesDashboard); activityStreamPanel = new ActivityStreamPanel(); activityStreamPanel.setWidth("550px"); streamsLayout.with(activityStreamPanel); contentLayout.with(streamsLayout).withAlign(streamsLayout, Alignment.TOP_RIGHT); this.addComponent(contentLayout); displayDashboard(); }
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 va2s . com*/ descLbl.setValue(" "); 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.project.ui.components.AbstractPreviewItemComp.java
License:Open Source License
private void initContent() { previewForm = initPreviewForm();/* ww w .ja v a 2 s . c o m*/ actionControls = createButtonControls(); if (actionControls != null) { actionControls.setWidthUndefined(); header.with(actionControls).withAlign(actionControls, Alignment.TOP_RIGHT); } MCssLayout contentWrapper = new MCssLayout().withFullWidth().withStyleName(WebUIConstants.CONTENT_WRAPPER); if (previewLayout == null) previewLayout = new DefaultReadViewLayout(""); contentWrapper.addComponent(previewLayout); if (isDisplaySideBar) { RightSidebarLayout bodyContainer = new RightSidebarLayout(); bodyContainer.setSizeFull(); bodyContainer.addStyleName("readview-body-wrap"); bodyContent = new MVerticalLayout().withSpacing(false).withMargin(false).withFullWidth() .with(previewForm); bodyContainer.setContent(bodyContent); sidebarContent = new MVerticalLayout().withWidth("250px").withStyleName("readview-sidebar"); bodyContainer.setSidebar(sidebarContent); previewLayout.addBody(bodyContainer); } else { CssLayout bodyContainer = new CssLayout(); bodyContainer.setSizeFull(); bodyContainer.addStyleName("readview-body-wrap"); bodyContent = new MVerticalLayout().withSpacing(false).withFullWidth().withMargin(false) .with(previewForm); bodyContainer.addComponent(bodyContent); previewLayout.addBody(bodyContainer); } this.addComponent(contentWrapper); }
From source file:com.mycollab.module.project.ui.components.ProjectCommentInput.java
License:Open Source License
ProjectCommentInput(final ReloadableComponent component, final String typeVal, Integer extraTypeIdVal) { this.withMargin(new MarginInfo(true, true, false, false)).withFullWidth().withHeightUndefined(); SimpleUser currentUser = UserUIContext.getUser(); ProjectMemberBlock userBlock = new ProjectMemberBlock(currentUser.getUsername(), currentUser.getAvatarid(), currentUser.getDisplayName()); MVerticalLayout textAreaWrap = new MVerticalLayout().withFullWidth() .withStyleName(WebThemes.MESSAGE_CONTAINER); this.with(userBlock, textAreaWrap).expand(textAreaWrap); type = typeVal;//from w w w. j a v a 2s.c o m extraTypeId = extraTypeIdVal; commentArea = new RichTextArea(); commentArea.setWidth("100%"); commentArea.setHeight("200px"); commentArea.addStyleName("comment-attachment"); final AttachmentPanel attachments = new AttachmentPanel(); attachments.setWidth("100%"); final MButton newCommentBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_POST), clickEvent -> { CommentWithBLOBs comment = new CommentWithBLOBs(); comment.setComment(Jsoup.clean(commentArea.getValue(), Whitelist.relaxed())); comment.setCreatedtime(new GregorianCalendar().getTime()); comment.setCreateduser(UserUIContext.getUsername()); comment.setSaccountid(MyCollabUI.getAccountId()); comment.setType(type); comment.setTypeid("" + typeId); comment.setExtratypeid(extraTypeId); final CommentService commentService = AppContextUtil.getSpringBean(CommentService.class); int commentId = commentService.saveWithSession(comment, UserUIContext.getUsername()); String attachmentPath = AttachmentUtils.getCommentAttachmentPath(typeVal, MyCollabUI.getAccountId(), CurrentProjectVariables.getProjectId(), typeId, commentId); if (!"".equals(attachmentPath)) { attachments.saveContentsToRepo(attachmentPath); } // save success, clear comment area and load list // comments again commentArea.setValue(""); component.reload(); }).withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.SEND); textAreaWrap.with(new MCssLayout(commentArea, attachments), newCommentBtn).withAlign(newCommentBtn, Alignment.TOP_RIGHT); }
From source file:com.mycollab.module.project.view.settings.component.ComponentAddWindow.java
License:Open Source License
public ComponentAddWindow() { super(UserUIContext.getMessage(ComponentI18nEnum.NEW)); AdvancedEditBeanForm<Component> editForm = new AdvancedEditBeanForm<>(); editForm.addFormHandler(this); editForm.setFormLayoutFactory(new DefaultDynaFormLayout(ProjectTypeConstants.BUG_COMPONENT, ComponentDefaultFormLayoutFactory.getForm(), "id")); editForm.setBeanFormFieldFactory(new ComponentEditFormFieldFactory(editForm)); Component component = new Component(); component.setProjectid(CurrentProjectVariables.getProjectId()); component.setSaccountid(MyCollabUI.getAccountId()); component.setStatus(OptionI18nEnum.StatusI18nEnum.Open.name()); editForm.setBean(component);//from w w w . j av a 2 s . c o m ComponentContainer buttonControls = generateEditFormControls(editForm, true, false, true); this.setContent( new MVerticalLayout(editForm, buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT)); this.withWidth("750px").withModal(true).withResizable(false).withCenter(); }
From source file:com.mycollab.module.project.view.settings.component.NotificationSettingWindow.java
License:Open Source License
public NotificationSettingWindow(SimpleProjectMember projectMember) { super(UserUIContext.getMessage(ProjectCommonI18nEnum.ACTION_EDIT_NOTIFICATION)); withModal(true).withResizable(false).withWidth("600px").withCenter(); ProjectNotificationSettingService prjNotificationSettingService = AppContextUtil .getSpringBean(ProjectNotificationSettingService.class); ProjectNotificationSetting notification = prjNotificationSettingService.findNotification( projectMember.getUsername(), projectMember.getProjectid(), projectMember.getSaccountid()); MVerticalLayout body = new MVerticalLayout(); final OptionGroup optionGroup = new OptionGroup(null); optionGroup.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT); optionGroup.addItem(NotificationType.Default.name()); optionGroup.setItemCaption(NotificationType.Default.name(), UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_DEFAULT_SETTING)); optionGroup.addItem(NotificationType.None.name()); optionGroup.setItemCaption(NotificationType.None.name(), UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_NONE_SETTING)); optionGroup.addItem(NotificationType.Minimal.name()); optionGroup.setItemCaption(NotificationType.Minimal.name(), UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_MINIMUM_SETTING)); optionGroup.addItem(NotificationType.Full.name()); optionGroup.setItemCaption(NotificationType.Full.name(), UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_MAXIMUM_SETTING)); optionGroup.setWidth("100%"); body.with(optionGroup).withAlign(optionGroup, Alignment.MIDDLE_LEFT); String levelVal = notification.getLevel(); if (levelVal == null) { optionGroup.select(NotificationType.Default.name()); } else {/* w ww .j av a2s. c o m*/ optionGroup.select(levelVal); } MButton closeBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLOSE), clickEvent -> close()) .withStyleName(WebThemes.BUTTON_OPTION); MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> { try { notification.setLevel((String) optionGroup.getValue()); ProjectNotificationSettingService projectNotificationSettingService = AppContextUtil .getSpringBean(ProjectNotificationSettingService.class); if (notification.getId() == null) { projectNotificationSettingService.saveWithSession(notification, UserUIContext.getUsername()); } else { projectNotificationSettingService.updateWithSession(notification, UserUIContext.getUsername()); } NotificationUtil.showNotification(UserUIContext.getMessage(GenericI18Enum.OPT_CONGRATS), UserUIContext.getMessage(ProjectSettingI18nEnum.DIALOG_UPDATE_SUCCESS)); close(); } catch (Exception e) { throw new MyCollabException(e); } }).withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.SAVE); MHorizontalLayout btnControls = new MHorizontalLayout(closeBtn, saveBtn); body.with(btnControls).withAlign(btnControls, Alignment.TOP_RIGHT); withContent(body); }
From source file:com.mycollab.module.project.view.settings.component.VersionAddWindow.java
License:Open Source License
VersionAddWindow() { super(UserUIContext.getMessage(VersionI18nEnum.NEW)); AdvancedEditBeanForm<Version> editForm = new AdvancedEditBeanForm<>(); editForm.addFormHandler(this); editForm.setFormLayoutFactory(new DefaultDynaFormLayout(ProjectTypeConstants.BUG_VERSION, VersionDefaultFormLayoutFactory.getForm(), "id")); editForm.setBeanFormFieldFactory(new VersionEditFormFieldFactory(editForm)); Version version = new Version(); version.setProjectid(CurrentProjectVariables.getProjectId()); version.setSaccountid(MyCollabUI.getAccountId()); version.setStatus(StatusI18nEnum.Open.name()); editForm.setBean(version);/*from w ww.jav a 2 s .c om*/ ComponentContainer buttonControls = generateEditFormControls(editForm, true, false, true); withWidth("750px").withModal(true).withResizable(false).withContent( new MVerticalLayout(editForm, buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT)) .withCenter(); }
From source file:com.mycollab.module.project.view.settings.ProjectMemberListViewImpl.java
License:Open Source License
private Component generateMemberBlock(final SimpleProjectMember member) { HorizontalLayout blockContent = new HorizontalLayout(); blockContent.setStyleName("member-block"); if (ProjectMemberStatusConstants.NOT_ACCESS_YET.equals(member.getStatus())) { blockContent.addStyleName("inactive"); }//from w ww . ja va2 s. c om blockContent.setWidth("350px"); Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getMemberAvatarId(), 100); memberAvatar.addStyleName(UIConstants.CIRCLE_BOX); memberAvatar.setWidthUndefined(); blockContent.addComponent(memberAvatar); MVerticalLayout blockTop = new MVerticalLayout().withMargin(new MarginInfo(false, false, false, true)) .withFullWidth(); MButton editBtn = new MButton("", clickEvent -> EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoEdit(this, member))) .withIcon(FontAwesome.EDIT).withStyleName(WebThemes.BUTTON_LINK) .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS)); editBtn.setDescription("Edit user '" + member.getDisplayName() + "' information"); MButton deleteBtn = new MButton("", 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()) { ProjectMemberService prjMemberService = AppContextUtil .getSpringBean(ProjectMemberService.class); prjMemberService.removeWithSession(member, UserUIContext.getUsername(), MyCollabUI.getAccountId()); EventBusFactory.getInstance() .post(new ProjectMemberEvent.GotoList(ProjectMemberListViewImpl.this, null)); } }); }).withIcon(FontAwesome.TRASH_O).withStyleName(WebThemes.BUTTON_LINK) .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS)); deleteBtn.setDescription("Remove user '" + member.getDisplayName() + "' out of this project"); MHorizontalLayout buttonControls = new MHorizontalLayout(editBtn, deleteBtn); blockTop.addComponent(buttonControls); blockTop.setComponentAlignment(buttonControls, Alignment.TOP_RIGHT); A memberLink = new A( ProjectLinkBuilder.generateProjectMemberFullLink(member.getProjectid(), member.getUsername())) .appendText(member.getMemberFullName()).setTitle(member.getMemberFullName()); ELabel memberNameLbl = ELabel.h3(memberLink.write()).withStyleName(UIConstants.TEXT_ELLIPSIS) .withFullWidth(); blockTop.with(memberNameLbl, ELabel.hr()); String roleLink = String.format("<a href=\"%s%s%s\"", MyCollabUI.getSiteUrl(), GenericLinkUtils.URL_PREFIX_PARAM, ProjectLinkGenerator.generateRolePreviewLink(member.getProjectid(), member.getProjectroleid())); ELabel memberRole = new ELabel("", ContentMode.HTML).withFullWidth() .withStyleName(UIConstants.TEXT_ELLIPSIS); if (member.isProjectOwner()) { memberRole.setValue(String.format("%sstyle=\"color: #B00000;\">%s</a>", roleLink, UserUIContext.getMessage(ProjectRoleI18nEnum.OPT_ADMIN_ROLE_DISPLAY))); } else { memberRole.setValue( String.format("%sstyle=\"color:gray;font-size:12px;\">%s</a>", roleLink, member.getRoleName())); } blockTop.addComponent(memberRole); if (Boolean.TRUE.equals(MyCollabUI.showEmailPublicly())) { Label memberEmailLabel = ELabel .html(String.format("<a href='mailto:%s'>%s</a>", member.getUsername(), member.getUsername())) .withStyleName(UIConstants.META_INFO).withFullWidth(); blockTop.addComponent(memberEmailLabel); } ELabel memberSinceLabel = ELabel .html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_SINCE, UserUIContext.formatPrettyTime(member.getJoindate()))) .withDescription(UserUIContext.formatDateTime(member.getJoindate())).withFullWidth(); blockTop.addComponent(memberSinceLabel); if (ProjectMemberStatusConstants.ACTIVE.equals(member.getStatus())) { ELabel lastAccessTimeLbl = ELabel .html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_LOGGED_IN, UserUIContext.formatPrettyTime(member.getLastAccessTime()))) .withDescription(UserUIContext.formatDateTime(member.getLastAccessTime())); blockTop.addComponent(lastAccessTimeLbl); } String memberWorksInfo = ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK).getHtml() + " " + new Span().appendText("" + member.getNumOpenTasks()) .setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_TASKS)) + " " + ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG).getHtml() + " " + new Span().appendText("" + member.getNumOpenBugs()) .setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_BUGS)) + " " + FontAwesome.MONEY.getHtml() + " " + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalBillableLogTime())) .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS)) + " " + FontAwesome.GIFT.getHtml() + " " + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalNonBillableLogTime())) .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS)); blockTop.addComponent(ELabel.html(memberWorksInfo).withStyleName(UIConstants.META_INFO)); blockContent.addComponent(blockTop); blockContent.setExpandRatio(blockTop, 1.0f); return blockContent; }
From source file:com.mycollab.module.project.view.user.ProjectInfoComponent.java
License:Open Source License
public ProjectInfoComponent(SimpleProject project) { this.withMargin(false).withFullWidth(); Component projectIcon = ProjectAssetsUtil.buildProjectLogo(project.getShortname(), project.getId(), project.getAvatarid(), 64);// w w w . j a v a 2 s. co m this.with(projectIcon).withAlign(projectIcon, Alignment.TOP_LEFT); ProjectBreadcrumb breadCrumb = ViewManager.getCacheComponent(ProjectBreadcrumb.class); breadCrumb.setProject(project); MVerticalLayout headerLayout = new MVerticalLayout().withSpacing(false) .withMargin(new MarginInfo(false, true, false, true)); MHorizontalLayout footer = new MHorizontalLayout().withStyleName(UIConstants.META_INFO, WebThemes.FLEX_DISPLAY); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); ELabel createdTimeLbl = ELabel .html(FontAwesome.CLOCK_O.getHtml() + " " + UserUIContext.formatPrettyTime(project.getCreatedtime())) .withDescription(UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME)) .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); footer.addComponents(createdTimeLbl); billableHoursLbl = ELabel .html(FontAwesome.MONEY.getHtml() + " " + NumberUtils.roundDouble(2, project.getTotalBillableHours())) .withDescription(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS)) .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); footer.addComponents(billableHoursLbl); nonBillableHoursLbl = ELabel.html(FontAwesome.GIFT.getHtml() + " " + project.getTotalNonBillableHours()) .withDescription(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS)) .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); footer.addComponents(nonBillableHoursLbl); if (project.getLead() != null) { Div leadAvatar = new DivLessFormatter() .appendChild(new Img("", StorageFactory.getAvatarPath(project.getLeadAvatarId(), 16)) .setCSSClass(UIConstants.CIRCLE_BOX), DivLessFormatter.EMPTY_SPACE(), new A(ProjectLinkBuilder.generateProjectMemberFullLink(project.getId(), project.getLead())) .appendText(StringUtils.trim(project.getLeadFullName(), 30, true))) .setTitle(project.getLeadFullName()); ELabel leadLbl = ELabel .html(UserUIContext.getMessage(ProjectI18nEnum.FORM_LEADER) + ": " + leadAvatar.write()) .withWidthUndefined(); footer.addComponents(leadLbl); } if (project.getHomepage() != null) { ELabel homepageLbl = ELabel .html(FontAwesome.WECHAT.getHtml() + " " + new A(project.getHomepage()) .appendText(project.getHomepage()).setTarget("_blank").write()) .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); homepageLbl.setDescription(UserUIContext.getMessage(ProjectI18nEnum.FORM_HOME_PAGE)); } if (project.getNumActiveMembers() > 0) { ELabel activeMembersLbl = ELabel.html(FontAwesome.USERS.getHtml() + " " + project.getNumActiveMembers()) .withDescription(UserUIContext.getMessage(ProjectMemberI18nEnum.OPT_ACTIVE_MEMBERS)) .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); footer.addComponents(activeMembersLbl); } if (project.getAccountid() != null && !SiteConfiguration.isCommunityEdition()) { Div clientDiv = new Div(); if (project.getClientAvatarId() == null) { clientDiv.appendText(FontAwesome.INSTITUTION.getHtml() + " "); } else { Img clientImg = new Img("", StorageFactory.getEntityLogoPath(MyCollabUI.getAccountId(), project.getClientAvatarId(), 16)).setCSSClass(UIConstants.CIRCLE_BOX); clientDiv.appendChild(clientImg).appendChild(DivLessFormatter.EMPTY_SPACE()); } clientDiv.appendChild(new A(ProjectLinkBuilder.generateClientPreviewFullLink(project.getAccountid())) .appendText(StringUtils.trim(project.getClientName(), 30, true))); ELabel accountBtn = ELabel.html(clientDiv.write()).withStyleName(WebThemes.BUTTON_LINK) .withWidthUndefined(); footer.addComponents(accountBtn); } if (!SiteConfiguration.isCommunityEdition()) { MButton tagBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_TAG), clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoTagListView(this, null))) .withIcon(FontAwesome.TAGS) .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK); footer.addComponents(tagBtn); MButton favoriteBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_FAVORITES), clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoFavoriteView(this, null))) .withIcon(FontAwesome.STAR) .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK); footer.addComponents(favoriteBtn); MButton eventBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_CALENDAR), clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoCalendarView(this))) .withIcon(FontAwesome.CALENDAR) .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK); footer.addComponents(eventBtn); MButton ganttChartBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_GANTT_CHART), clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoGanttChart(this, null))) .withIcon(FontAwesome.BAR_CHART_O) .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK); footer.addComponents(ganttChartBtn); } headerLayout.with(breadCrumb, footer); MHorizontalLayout topPanel = new MHorizontalLayout().withMargin(false); this.with(headerLayout, topPanel).expand(headerLayout).withAlign(topPanel, Alignment.TOP_RIGHT); if (project.isProjectArchived()) { MButton activeProjectBtn = new MButton( UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECT), clickEvent -> { ProjectService projectService = AppContextUtil.getSpringBean(ProjectService.class); project.setProjectstatus(OptionI18nEnum.StatusI18nEnum.Open.name()); projectService.updateSelectiveWithSession(project, UserUIContext.getUsername()); PageActionChain chain = new PageActionChain( new ProjectScreenData.Goto(CurrentProjectVariables.getProjectId())); EventBusFactory.getInstance().post(new ProjectEvent.GotoMyProject(this, chain)); }).withStyleName(WebThemes.BUTTON_ACTION); topPanel.with(activeProjectBtn).withAlign(activeProjectBtn, Alignment.MIDDLE_RIGHT); } else { SearchTextField searchField = new SearchTextField() { public void doSearch(String value) { ProjectView prjView = UIUtils.getRoot(this, ProjectView.class); if (prjView != null) { prjView.displaySearchResult(value); } } @Override public void emptySearch() { } }; final PopupButton controlsBtn = new PopupButton(); controlsBtn.addStyleName(WebThemes.BOX); controlsBtn.setIcon(FontAwesome.ELLIPSIS_H); OptionPopupContent popupButtonsControl = new OptionPopupContent(); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS)) { MButton inviteMemberBtn = new MButton( UserUIContext.getMessage(ProjectMemberI18nEnum.BUTTON_NEW_INVITEES), clickEvent -> { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance() .post(new ProjectMemberEvent.GotoInviteMembers(this, null)); }).withIcon(FontAwesome.SEND); popupButtonsControl.addOption(inviteMemberBtn); } MButton settingBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_SETTINGS), clickEvent -> { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance().post(new ProjectNotificationEvent.GotoList(this, null)); }).withIcon(FontAwesome.COG); popupButtonsControl.addOption(settingBtn); popupButtonsControl.addSeparator(); if (UserUIContext.canAccess(RolePermissionCollections.CREATE_NEW_PROJECT)) { final MButton markProjectTemplateBtn = new MButton().withIcon(FontAwesome.ANCHOR); markProjectTemplateBtn.addClickListener(clickEvent -> { Boolean isTemplate = !MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE); project.setIstemplate(isTemplate); ProjectService prjService = AppContextUtil.getSpringBean(ProjectService.class); prjService.updateWithSession(project, UserUIContext.getUsername()); if (project.getIstemplate()) { markProjectTemplateBtn .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE)); } else { markProjectTemplateBtn .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE)); } }); Boolean isTemplate = MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE); if (isTemplate) { markProjectTemplateBtn .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE)); } else { markProjectTemplateBtn .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE)); } popupButtonsControl.addOption(markProjectTemplateBtn); } if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROJECT)) { MButton editProjectBtn = new MButton(UserUIContext.getMessage(ProjectI18nEnum.EDIT), clickEvent -> { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance() .post(new ProjectEvent.GotoEdit(ProjectInfoComponent.this, project)); }).withIcon(FontAwesome.EDIT); popupButtonsControl.addOption(editProjectBtn); } if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) { MButton archiveProjectBtn = new MButton( UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECT), clickEvent -> { controlsBtn.setPopupVisible(false); ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.WINDOW_WARNING_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage( ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_ARCHIVE_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { ProjectService projectService = AppContextUtil .getSpringBean(ProjectService.class); project.setProjectstatus(OptionI18nEnum.StatusI18nEnum.Archived.name()); projectService.updateSelectiveWithSession(project, UserUIContext.getUsername()); PageActionChain chain = new PageActionChain(new ProjectScreenData.Goto( CurrentProjectVariables.getProjectId())); EventBusFactory.getInstance() .post(new ProjectEvent.GotoMyProject(this, chain)); } }); }).withIcon(FontAwesome.ARCHIVE); popupButtonsControl.addOption(archiveProjectBtn); } if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) { popupButtonsControl.addSeparator(); MButton deleteProjectBtn = new MButton( UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_DELETE_PROJECT), clickEvent -> { controlsBtn.setPopupVisible(false); ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage( ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_DELETE_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { ProjectService projectService = AppContextUtil .getSpringBean(ProjectService.class); projectService.removeWithSession(CurrentProjectVariables.getProject(), UserUIContext.getUsername(), MyCollabUI.getAccountId()); EventBusFactory.getInstance() .post(new ShellEvent.GotoProjectModule(this, null)); } }); }).withIcon(FontAwesome.TRASH_O); popupButtonsControl.addDangerOption(deleteProjectBtn); } controlsBtn.setContent(popupButtonsControl); controlsBtn.setWidthUndefined(); topPanel.with(searchField, controlsBtn).withAlign(searchField, Alignment.TOP_RIGHT) .withAlign(controlsBtn, Alignment.TOP_RIGHT); } }
From source file:com.mycollab.module.project.view.UserDashboardViewImpl.java
License:Open Source License
private ComponentContainer setupHeader() { MHorizontalLayout headerWrapper = new MHorizontalLayout().withFullWidth() .withStyleName("projectfeed-hdr-wrapper"); Image avatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(UserUIContext.getUserAvatarId(), 64);//from w ww.j a va 2s . c om avatar.setStyleName(UIConstants.CIRCLE_BOX); headerWrapper.addComponent(avatar); MVerticalLayout headerContent = new MVerticalLayout().withMargin(new MarginInfo(false, false, false, true)); ELabel headerLabel = ELabel.h2(UserUIContext.getUser().getDisplayName()) .withStyleName(UIConstants.TEXT_ELLIPSIS); MHorizontalLayout headerContentTop = new MHorizontalLayout(); headerContentTop.with(headerLabel).withAlign(headerLabel, Alignment.TOP_LEFT).expand(headerLabel); SearchTextField searchTextField = new SearchTextField() { @Override public void doSearch(String value) { displaySearchResult(value); } @Override public void emptySearch() { } }; headerContentTop.with(searchTextField).withAlign(searchTextField, Alignment.TOP_RIGHT); headerContent.with(headerContentTop); MHorizontalLayout metaInfoLayout = new MHorizontalLayout(); if (Boolean.TRUE.equals(MyCollabUI.getBillingAccount().getDisplayemailpublicly())) { metaInfoLayout.with( new ELabel(UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL) + ": ") .withStyleName(UIConstants.META_INFO), ELabel.html(new A(String.format("mailto:%s", UserUIContext.getUsername())) .appendText(UserUIContext.getUsername()).write())); } metaInfoLayout.with(ELabel.html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_SINCE, UserUIContext.formatPrettyTime(UserUIContext.getUser().getRegisteredtime())))); metaInfoLayout.with(ELabel.html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_LOGGED_IN, UserUIContext.formatPrettyTime(UserUIContext.getUser().getLastaccessedtime())))); metaInfoLayout.alignAll(Alignment.TOP_LEFT); headerContent.addComponent(metaInfoLayout); headerWrapper.with(headerContent).expand(headerContent); return headerWrapper; }