List of usage examples for com.vaadin.ui Alignment MIDDLE_LEFT
Alignment MIDDLE_LEFT
To view the source code for com.vaadin.ui Alignment MIDDLE_LEFT.
Click Source Link
From source file:com.esofthead.mycollab.module.project.view.user.MyProjectListComponent.java
License:Open Source License
public MyProjectListComponent() { withSpacing(false).withMargin(false); this.addStyleName("myprojectlist"); MHorizontalLayout header = new MHorizontalLayout().withSpacing(false) .withMargin(new MarginInfo(false, true, false, true)).withHeight("34px"); header.addStyleName("panel-header"); titleLbl = new Label(AppContext.getMessage(ProjectCommonI18nEnum.WIDGET_ACTIVE_PROJECTS_TITLE, 0)); final PopupButton projectsPopup = new PopupButton(""); projectsPopup.addStyleName("popuplistindicator"); final MVerticalLayout filterBtnLayout = new MVerticalLayout().withWidth("200px"); ProjectService projectService = ApplicationContextUtil.getSpringBean(ProjectService.class); int allProjectCount = projectService.getTotalCount(getAllProjectsSearchCriteria()); Button allProjectsBtn = new Button( AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ALL_PROJECTS, allProjectCount), new ClickListener() { private static final long serialVersionUID = 1L; @Override//from w w w.j a v a 2s.co m public void buttonClick(ClickEvent event) { displayAllProjects(); projectsPopup.setPopupVisible(false); } }); allProjectsBtn.setStyleName("link"); filterBtnLayout.addComponent(allProjectsBtn); int activeProjectsCount = projectService.getTotalCount(getActiveProjectsSearchCriteria()); Button activeProjectsBtn = new Button( AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECTS, activeProjectsCount), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { displayActiveProjects(); projectsPopup.setPopupVisible(false); } }); activeProjectsBtn.setStyleName("link"); filterBtnLayout.addComponent(activeProjectsBtn); int archiveProjectsCount = projectService.getTotalCount(getArchivedProjectsSearchCriteria()); Button archiveProjectsBtn = new Button( AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECTS, archiveProjectsCount), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { displayArchiveProjects(); projectsPopup.setPopupVisible(false); } }); archiveProjectsBtn.setStyleName("link"); filterBtnLayout.addComponent(archiveProjectsBtn); projectsPopup.setContent(filterBtnLayout); header.with(titleLbl, projectsPopup).withAlign(titleLbl, Alignment.MIDDLE_LEFT) .withAlign(projectsPopup, Alignment.MIDDLE_RIGHT).expand(titleLbl); this.projectList = new ProjectPagedList(); this.with(header, projectList); }
From source file:com.esofthead.mycollab.module.project.view.user.ProjectAssignmentsWidget.java
License:Open Source License
public ProjectAssignmentsWidget() { withSpacing(false).withMargin(false); titleLbl = new Label(AppContext.getMessage(ProjectCommonI18nEnum.WIDGET_OPEN_ASSIGNMENTS_TITLE, 0)); final CheckBox overdueSelection = new CheckBox("Overdue"); overdueSelection.addValueChangeListener(new Property.ValueChangeListener() { @Override//from www .j ava 2 s . co m public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean isOverdueOption = overdueSelection.getValue(); if (isOverdueOption) { searchCriteria.setDueDate( new DateSearchField(DateSearchField.AND, DateTimeUtils.getCurrentDateWithoutMS())); } else { searchCriteria.setDueDate(null); } updateSearchResult(); } }); final CheckBox myItemsSelection = new CheckBox("My Items"); myItemsSelection.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean isMyItemsOption = myItemsSelection.getValue(); if (isMyItemsOption) { searchCriteria.setAssignUser(new StringSearchField(AppContext.getUsername())); } else { searchCriteria.setAssignUser(null); } updateSearchResult(); } }); MHorizontalLayout header = new MHorizontalLayout().withMargin(new MarginInfo(false, true, false, true)) .withHeight("34px").with(titleLbl, overdueSelection, myItemsSelection) .withAlign(titleLbl, Alignment.MIDDLE_LEFT).withAlign(overdueSelection, Alignment.MIDDLE_RIGHT) .withAlign(myItemsSelection, Alignment.MIDDLE_RIGHT).expand(titleLbl); header.addStyleName("panel-header"); taskList = new DefaultBeanPagedList<>(ApplicationContextUtil.getSpringBean(ProjectGenericTaskService.class), new TaskRowDisplayHandler(), 10); this.with(header, taskList); }
From source file:com.esofthead.mycollab.module.project.view.user.ProjectInfoComponent.java
License:Open Source License
public ProjectInfoComponent(final SimpleProject project) { this.withMargin(true).withStyleName("project-info").withFullWidth(); Component projectIcon = ProjectAssetsUtil.buildProjectLogo(project.getShortname(), project.getId(), project.getAvatarid(), 64);/* w w w .j a va2 s . c o m*/ this.with(projectIcon).withAlign(projectIcon, Alignment.TOP_LEFT); ELabel headerLbl = ELabel.h2(project.getName()); headerLbl.setDescription(ProjectTooltipGenerator.generateToolTipProject(AppContext.getUserLocale(), AppContext.getDateFormat(), project, AppContext.getSiteUrl(), AppContext.getUserTimeZone())); headerLbl.addStyleName(UIConstants.TEXT_ELLIPSIS); MVerticalLayout headerLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, false, true)); MHorizontalLayout footer = new MHorizontalLayout(); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); footer.addStyleName(UIConstants.META_INFO); footer.addStyleName(UIConstants.FLEX_DISPLAY); ELabel createdTimeLbl = new ELabel( FontAwesome.CLOCK_O.getHtml() + " " + AppContext.formatPrettyTime(project.getCreatedtime()), ContentMode.HTML).withDescription(AppContext.getMessage(GenericI18Enum.FORM_CREATED_TIME)) .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); footer.addComponents(createdTimeLbl); billableHoursLbl = new ELabel( FontAwesome.MONEY.getHtml() + " " + NumberUtils.roundDouble(2, project.getTotalBillableHours()), ContentMode.HTML).withDescription(AppContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS)) .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); footer.addComponents(billableHoursLbl); nonBillableHoursLbl = new ELabel(FontAwesome.GIFT.getHtml() + " " + project.getTotalNonBillableHours(), ContentMode.HTML) .withDescription(AppContext.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.getInstance().getAvatarPath(project.getLeadAvatarId(), 16)), DivLessFormatter.EMPTY_SPACE(), new A(ProjectLinkBuilder.generateProjectMemberFullLink(project.getId(), project.getLead())) .appendText(StringUtils.trim(project.getLeadFullName(), 30, true))) .setTitle(project.getLeadFullName()); ELabel leadLbl = new ELabel("Lead: " + leadAvatar.write(), ContentMode.HTML).withWidthUndefined(); footer.addComponents(leadLbl); } if (project.getHomepage() != null) { ELabel homepageLbl = new ELabel(FontAwesome.WECHAT.getHtml() + " " + new A(project.getHomepage()).appendText(project.getHomepage()).setTarget("_blank").write(), ContentMode.HTML).withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined(); homepageLbl.setDescription(AppContext.getMessage(ProjectI18nEnum.FORM_HOME_PAGE)); } if (project.getNumActiveMembers() > 0) { ELabel activeMembersLbl = new ELabel(FontAwesome.USERS.getHtml() + " " + project.getNumActiveMembers(), ContentMode.HTML).withDescription("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.getInstance() .getEntityLogoPath(AppContext.getAccountId(), project.getClientAvatarId(), 16)); clientDiv.appendChild(clientImg).appendChild(DivLessFormatter.EMPTY_SPACE()); } clientDiv.appendChild(new A(ProjectLinkBuilder.generateClientPreviewFullLink(project.getAccountid())) .appendText(project.getClientName())); ELabel accountBtn = new ELabel(clientDiv.write(), ContentMode.HTML) .withStyleName(UIConstants.BUTTON_BLOCK).withWidthUndefined(); footer.addComponents(accountBtn); } if (!SiteConfiguration.isCommunityEdition()) { Button tagBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TAG), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { EventBusFactory.getInstance().post(new ProjectEvent.GotoTagListView(this, null)); } }); tagBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING); tagBtn.addStyleName(UIConstants.BUTTON_ACTION); tagBtn.setDescription("Tag management"); tagBtn.setIcon(FontAwesome.TAGS); footer.addComponents(tagBtn); Button favoriteBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_FAVORITES), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { EventBusFactory.getInstance().post(new ProjectEvent.GotoFavoriteView(this, null)); } }); favoriteBtn.setCaptionAsHtml(true); favoriteBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING); favoriteBtn.addStyleName(UIConstants.BUTTON_ACTION); favoriteBtn.setIcon(FontAwesome.STAR); favoriteBtn.setDescription("Your favorite list"); footer.addComponents(favoriteBtn); Button eventBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_CALENDAR), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { EventBusFactory.getInstance().post(new ProjectEvent.GotoCalendarView(this)); } }); eventBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING); eventBtn.addStyleName(UIConstants.BUTTON_ACTION); eventBtn.setIcon(FontAwesome.CALENDAR); eventBtn.setDescription("Calendar"); footer.addComponents(eventBtn); Button ganttChartBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_GANTT_CHART), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { EventBusFactory.getInstance().post(new ProjectEvent.GotoGanttChart(this, null)); } }); ganttChartBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING); ganttChartBtn.addStyleName(UIConstants.BUTTON_ACTION); ganttChartBtn.setIcon(FontAwesome.BAR_CHART_O); ganttChartBtn.setDescription("Gantt chart"); footer.addComponents(ganttChartBtn); } headerLayout.with(headerLbl, footer); MHorizontalLayout topPanel = new MHorizontalLayout().withMargin(false); this.with(headerLayout, topPanel).expand(headerLayout).withAlign(topPanel, Alignment.TOP_RIGHT); if (project.isProjectArchived()) { Button activeProjectBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECT), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { ProjectService projectService = AppContextUtil.getSpringBean(ProjectService.class); project.setProjectstatus(OptionI18nEnum.StatusI18nEnum.Open.name()); projectService.updateSelectiveWithSession(project, AppContext.getUsername()); PageActionChain chain = new PageActionChain( new ProjectScreenData.Goto(CurrentProjectVariables.getProjectId())); EventBusFactory.getInstance().post(new ProjectEvent.GotoMyProject(this, chain)); } }); activeProjectBtn.setStyleName(UIConstants.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(UIConstants.BOX); controlsBtn.setIcon(FontAwesome.ELLIPSIS_H); OptionPopupContent popupButtonsControl = new OptionPopupContent(); Button createPhaseBtn = new Button(AppContext.getMessage(MilestoneI18nEnum.NEW), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance() .post(new MilestoneEvent.GotoAdd(ProjectInfoComponent.this, null)); } }); createPhaseBtn .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)); createPhaseBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.MILESTONE)); popupButtonsControl.addOption(createPhaseBtn); Button createTaskBtn = new Button(AppContext.getMessage(TaskI18nEnum.NEW), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance().post(new TaskEvent.GotoAdd(ProjectInfoComponent.this, null)); } }); createTaskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); createTaskBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK)); popupButtonsControl.addOption(createTaskBtn); Button createBugBtn = new Button(AppContext.getMessage(BugI18nEnum.NEW), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance().post(new BugEvent.GotoAdd(this, null)); } }); createBugBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)); createBugBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG)); popupButtonsControl.addOption(createBugBtn); Button createComponentBtn = new Button(AppContext.getMessage(ComponentI18nEnum.NEW), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance().post(new BugComponentEvent.GotoAdd(this, null)); } }); createComponentBtn .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.COMPONENTS)); createComponentBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG_COMPONENT)); popupButtonsControl.addOption(createComponentBtn); Button createVersionBtn = new Button(AppContext.getMessage(VersionI18nEnum.NEW), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance().post(new BugVersionEvent.GotoAdd(this, null)); } }); createVersionBtn .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.VERSIONS)); createVersionBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG_VERSION)); popupButtonsControl.addOption(createVersionBtn); if (!SiteConfiguration.isCommunityEdition()) { Button createRiskBtn = new Button(AppContext.getMessage(RiskI18nEnum.NEW), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance().post(new RiskEvent.GotoAdd(this, null)); } }); createRiskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.RISKS)); createRiskBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.RISK)); popupButtonsControl.addOption(createRiskBtn); } popupButtonsControl.addSeparator(); Button inviteMemberBtn = new Button(AppContext.getMessage(ProjectMemberI18nEnum.BUTTON_NEW_INVITEES), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance() .post(new ProjectMemberEvent.GotoInviteMembers(this, null)); } }); inviteMemberBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS)); inviteMemberBtn.setIcon(FontAwesome.SEND); popupButtonsControl.addOption(inviteMemberBtn); Button settingBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_SETTINGS), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance().post(new ProjectNotificationEvent.GotoList(this, null)); } }); settingBtn.setIcon(FontAwesome.COG); popupButtonsControl.addOption(settingBtn); popupButtonsControl.addSeparator(); final Button markProjectTemplateBtn = new Button(); markProjectTemplateBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { Boolean isTemplate = !MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE); project.setIstemplate(isTemplate); ProjectService prjService = AppContextUtil.getSpringBean(ProjectService.class); prjService.updateWithSession(project, AppContext.getUsername()); if (project.getIstemplate()) { markProjectTemplateBtn .setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE)); } else { markProjectTemplateBtn .setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE)); } } }); markProjectTemplateBtn.setIcon(FontAwesome.STICKY_NOTE); Boolean isTemplate = MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE); if (isTemplate) { markProjectTemplateBtn.setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE)); } else { markProjectTemplateBtn.setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE)); } markProjectTemplateBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.CREATE_NEW_PROJECT)); popupButtonsControl.addOption(markProjectTemplateBtn); Button editProjectBtn = new Button(AppContext.getMessage(ProjectI18nEnum.EDIT), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { controlsBtn.setPopupVisible(false); EventBusFactory.getInstance() .post(new ProjectEvent.GotoEdit(ProjectInfoComponent.this, project)); } }); editProjectBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROJECT)); editProjectBtn.setIcon(FontAwesome.EDIT); popupButtonsControl.addOption(editProjectBtn); Button archiveProjectBtn = new Button( AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECT), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { controlsBtn.setPopupVisible(false); ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.WINDOW_WARNING_TITLE, AppContext.getSiteName()), AppContext.getMessage( ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_ARCHIVE_MESSAGE), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { ProjectService projectService = AppContextUtil .getSpringBean(ProjectService.class); project.setProjectstatus( OptionI18nEnum.StatusI18nEnum.Archived.name()); projectService.updateSelectiveWithSession(project, AppContext.getUsername()); PageActionChain chain = new PageActionChain( new ProjectScreenData.Goto( CurrentProjectVariables.getProjectId())); EventBusFactory.getInstance() .post(new ProjectEvent.GotoMyProject(this, chain)); } } }); } }); archiveProjectBtn .setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)); archiveProjectBtn.setIcon(FontAwesome.ARCHIVE); popupButtonsControl.addOption(archiveProjectBtn); if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) { popupButtonsControl.addSeparator(); Button deleteProjectBtn = new Button( AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_DELETE_PROJECT), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { controlsBtn.setPopupVisible(false); ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()), AppContext.getMessage( ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_DELETE_MESSAGE), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { ProjectService projectService = AppContextUtil .getSpringBean(ProjectService.class); projectService.removeWithSession( CurrentProjectVariables.getProject(), AppContext.getUsername(), AppContext.getAccountId()); EventBusFactory.getInstance() .post(new ShellEvent.GotoProjectModule(this, null)); } } }); } }); deleteProjectBtn .setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)); deleteProjectBtn.setIcon(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.esofthead.mycollab.module.project.view.user.ProjectMessageListComponent.java
License:Open Source License
public ProjectMessageListComponent() { withSpacing(false).withMargin(false); Label titleLbl = new Label(AppContext.getMessage(MessageI18nEnum.WIDGET_LASTEST_NEWS)); MHorizontalLayout header = new MHorizontalLayout().withSpacing(true) .withMargin(new MarginInfo(false, true, false, true)).withHeight("34px").withWidth("100%") .with(titleLbl).withAlign(titleLbl, Alignment.MIDDLE_LEFT); header.addStyleName("panel-header"); messageList = new DefaultBeanPagedList<>(ApplicationContextUtil.getSpringBean(MessageService.class), new MessageRowDisplayHandler(), 5); this.with(header, messageList); }
From source file:com.esofthead.mycollab.module.project.view.user.TaskStatusComponent.java
License:Open Source License
public TaskStatusComponent() { withSpacing(false).withMargin(false); this.addStyleName("myprojectlist"); MHorizontalLayout header = new MHorizontalLayout().withSpacing(false) .withMargin(new MarginInfo(false, true, false, true)).withHeight("34px"); header.addStyleName("panel-header"); titleLbl = new Label(AppContext.getMessage(ProjectCommonI18nEnum.WIDGET_OPEN_ASSIGNMENTS_TITLE, 0)); final CheckBox overdueSelection = new CheckBox("Overdue"); overdueSelection.addValueChangeListener(new Property.ValueChangeListener() { @Override//from w ww . j a v a 2 s . c o m public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean isOverdueOption = overdueSelection.getValue(); if (isOverdueOption) { searchCriteria.setDueDate( new DateSearchField(DateSearchField.AND, DateTimeUtils.getCurrentDateWithoutMS())); } else { searchCriteria.setDueDate(null); } updateSearchResult(); } }); final CheckBox myItemsOnly = new CheckBox("My Items"); myItemsOnly.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean selectMyItemsOnly = myItemsOnly.getValue(); if (selectMyItemsOnly) { searchCriteria.setAssignUser(new StringSearchField(AppContext.getUsername())); } else { searchCriteria.setAssignUser(null); } taskComponents.setSearchCriteria(searchCriteria); } }); header.with(titleLbl, overdueSelection, myItemsOnly).withAlign(titleLbl, Alignment.MIDDLE_LEFT) .withAlign(overdueSelection, Alignment.MIDDLE_RIGHT).withAlign(myItemsOnly, Alignment.MIDDLE_RIGHT) .expand(titleLbl); taskComponents = new TaskStatusPagedList(); this.with(header, taskComponents); }
From source file:com.esofthead.mycollab.module.project.view.UserDashboardViewImpl.java
License:Open Source License
@Override protected void displayView() { this.removeAllComponents(); this.withMargin(false).withWidth("100%"); final CssLayout headerWrapper = new CssLayout(); headerWrapper.setWidth("100%"); headerWrapper.setStyleName("projectfeed-hdr-wrapper"); final MHorizontalLayout header = new MHorizontalLayout().withMargin(false).withWidth("100%"); header.addStyleName("projectfeed-hdr"); Button avatar = UserAvatarControlFactory.createUserAvatarEmbeddedButton(AppContext.getUserAvatarId(), 64); avatar.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override//from w ww . j a v a2 s .c o m public void buttonClick(final ClickEvent event) { String userFullLinkStr = AccountLinkGenerator.generatePreviewFullUserLink(AppContext.getSiteUrl(), AppContext.getUsername()); getUI().getPage().open(userFullLinkStr, null); } }); header.addComponent(avatar); final MVerticalLayout headerContent = new MVerticalLayout() .withMargin(new MarginInfo(false, false, false, true)); headerContent.addStyleName("projectfeed-hdr-content"); final Label headerLabel = new Label(AppContext.getSession().getDisplayName()); headerLabel.setStyleName(Reindeer.LABEL_H1); final MHorizontalLayout headerContentTop = new MHorizontalLayout() .withMargin(new MarginInfo(false, false, true, false)); headerContentTop.with(headerLabel).withAlign(headerLabel, Alignment.TOP_LEFT); if (AppContext.canBeYes(RolePermissionCollections.CREATE_NEW_PROJECT)) { final Button createProjectBtn = new Button( AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_NEW_PROJECT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { final ProjectAddWindow projectNewWindow = new ProjectAddWindow(); UI.getCurrent().addWindow(projectNewWindow); } }); createProjectBtn.setIcon(FontAwesome.PLUS); createProjectBtn.setStyleName(UIConstants.THEME_GREEN_LINK); headerContentTop.addComponent(createProjectBtn); headerContentTop.setComponentAlignment(createProjectBtn, Alignment.MIDDLE_LEFT); } followingTicketsLink = new LabelLink(AppContext.getMessage(FollowerI18nEnum.OPT_MY_FOLLOWING_TICKETS, 0), AppContext.getSiteUrl() + "#project/following"); followingTicketsLink.setIconLink(FontAwesome.EYE); LabelLink timeTrackingLink = new LabelLink(AppContext.getMessage(TimeTrackingI18nEnum.TIME_RECORD_HEADER), AppContext.getSiteUrl() + "#project/timetracking"); timeTrackingLink.setIconLink(ProjectAssetsManager.getAsset(ProjectTypeConstants.TIME)); final MHorizontalLayout headerContentBottom = new MHorizontalLayout().withMargin(false) .with(followingTicketsLink, timeTrackingLink); headerContent.with(headerContentTop, headerContentBottom); header.with(headerContent).expand(headerContent); headerWrapper.addComponent(header); this.addComponent(headerWrapper); final MHorizontalLayout layout = new MHorizontalLayout() .withMargin(new MarginInfo(false, false, true, false)).withWidth("100%"); ActivityStreamComponent activityStreamComponent = new ActivityStreamComponent(); final MVerticalLayout leftPanel = new MVerticalLayout().withSpacing(false) .withMargin(new MarginInfo(false, true, false, false)).withWidth("100%") .with(activityStreamComponent); final MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false).withWidth("565px"); MyProjectListComponent myProjectListComponent = new MyProjectListComponent(); TaskStatusComponent taskStatusComponent = new TaskStatusComponent(); rightPanel.with(myProjectListComponent, taskStatusComponent); layout.with(leftPanel, rightPanel).expand(leftPanel); final CssLayout contentWrapper = new CssLayout(); contentWrapper.setWidth("100%"); contentWrapper.addStyleName("content-wrapper"); this.addComponent(contentWrapper); contentWrapper.addComponent(layout); final ProjectService prjService = ApplicationContextUtil.getSpringBean(ProjectService.class); prjKeys = prjService.getProjectKeysUserInvolved(AppContext.getUsername(), AppContext.getAccountId()); if (CollectionUtils.isNotEmpty(prjKeys)) { activityStreamComponent.showFeeds(prjKeys); myProjectListComponent.displayDefaultProjectsList(); displayFollowingTicketsCount(); } taskStatusComponent.showProjectTasksByStatus(prjKeys); }
From source file:com.esofthead.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java
License:Open Source License
@Override public void displayView() { removeAllComponents();/* ww w . j a v a 2 s . c om*/ billingAccount = AppContext.getBillingAccount(); FormContainer formContainer = new FormContainer(); this.addComponent(formContainer); MHorizontalLayout generalSettingHeader = new MHorizontalLayout(); Label headerLbl = new Label(AppContext.getMessage(AdminI18nEnum.OPT_GENERAL_SETTINGS)); Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { UI.getCurrent().addWindow(new AccountInfoChangeWindow()); } }); editBtn.setStyleName(UIConstants.BUTTON_LINK); generalSettingHeader.with(headerLbl, editBtn).alignAll(Alignment.MIDDLE_LEFT); GridFormLayoutHelper gridFormLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(2, 5, "200px"); gridFormLayoutHelper.addComponent(new Label(billingAccount.getSitename()), AppContext.getMessage(AdminI18nEnum.FORM_SITE_NAME), 0, 0); gridFormLayoutHelper.addComponent( new Label(String.format("https://%s.mycollab.com", billingAccount.getSubdomain())), AppContext.getMessage(AdminI18nEnum.FORM_SITE_ADDRESS), 0, 1); gridFormLayoutHelper.addComponent( new Label(TimezoneVal.getDisplayName(billingAccount.getDefaulttimezone())), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_TIMEZONE), 0, 2); Currency defaultCurrency = billingAccount.getCurrencyInstance(); gridFormLayoutHelper.addComponent(new ELabel(defaultCurrency.getDisplayName(AppContext.getUserLocale())), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_CURRENCY), 0, 3); Date now = new GregorianCalendar().getTime(); String defaultFullDateFormat = billingAccount.getDateFormatInstance(); gridFormLayoutHelper.addComponent(new Label(String.format("%s (%s)", DateTimeUtils.formatDate(now, billingAccount.getDateFormatInstance()), defaultFullDateFormat)), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_YYMMDD_FORMAT), AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 1, 0); String defaultShortDateFormat = billingAccount.getShortDateFormatInstance(); gridFormLayoutHelper.addComponent( new Label(String.format("%s (%s)", DateTimeUtils.formatDate(now, billingAccount.getShortDateFormatInstance()), defaultShortDateFormat)), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_MMDD_FORMAT), AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 1, 1); String defaultLongDateFormat = billingAccount.getLongDateFormatInstance(); gridFormLayoutHelper.addComponent(new Label(String.format("%s (%s)", DateTimeUtils.formatDate(now, billingAccount.getLongDateFormatInstance()), defaultLongDateFormat)), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_HUMAN_DATE_FORMAT), AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 1, 2); gridFormLayoutHelper.addComponent( new Label(LocalizationHelper.getLocaleInstance(billingAccount.getDefaultlanguagetag()) .getDisplayLanguage(AppContext.getUserLocale())), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_LANGUAGE), 1, 3); gridFormLayoutHelper.addComponent( new Label(AppContext .getMessage(LocalizationHelper.localizeYesNo(billingAccount.getDisplayemailpublicly()))), AppContext.getMessage(AdminI18nEnum.FORM_SHOW_EMAIL_PUBLICLY), AppContext.getMessage(AdminI18nEnum.FORM_SHOW_EMAIL_PUBLICLY_HELP), 0, 4, 2, "100%"); formContainer.addSection(new CssLayout(generalSettingHeader), gridFormLayoutHelper.getLayout()); buildLogoPanel(); buildShortcutIconPanel(); }
From source file:com.esofthead.mycollab.module.user.accountsettings.customize.view.LogoEditWindow.java
License:Open Source License
private void editPhoto(byte[] imageData) { try {//from w w w .j a v a 2 s . c o m originalImage = ImageIO.read(new ByteArrayInputStream(imageData)); } catch (IOException e) { throw new UserInvalidInputException("Invalid image type"); } originalImage = ImageUtil.scaleImage(originalImage, 650, 650); MHorizontalLayout previewBox = new MHorizontalLayout().withMargin(new MarginInfo(false, true, true, false)) .withFullWidth(); final String logoPath = AppContext.getBillingAccount().getLogopath(); Resource defaultPhoto = AccountAssetsResolver.createLogoResource(logoPath, 150); previewImage = new Embedded(null, defaultPhoto); previewImage.setWidth("100px"); previewBox.addComponent(previewImage); previewBox.setComponentAlignment(previewImage, Alignment.TOP_LEFT); MVerticalLayout previewBoxRight = new MVerticalLayout().withSpacing(false) .withMargin(new MarginInfo(false, true, false, true)); Label lbPreview = new Label( "<p style='margin: 0px;'><strong>To the below is what your logo will look like.</strong></p><p " + "style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. " + "When you are happy with your photo, click the <strong>Accept</strong> button.</p>", ContentMode.HTML); previewBoxRight.addComponent(lbPreview); MHorizontalLayout controlBtns = new MHorizontalLayout(); controlBtns.setSizeUndefined(); controlBtns.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new SettingEvent.GotoGeneralSetting(LogoEditWindow.this, null)); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); controlBtns.with(cancelBtn); Button acceptBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (scaleImageData != null && scaleImageData.length > 0) { try { BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData)); AccountLogoService accountLogoService = AppContextUtil .getSpringBean(AccountLogoService.class); accountLogoService.upload(AppContext.getUsername(), image, AppContext.getAccountId()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } catch (IOException e) { throw new MyCollabException("Error when saving account logo", e); } } } }); acceptBtn.setStyleName(UIConstants.BUTTON_ACTION); controlBtns.with(acceptBtn); previewBoxRight.with(controlBtns).withAlign(controlBtns, Alignment.TOP_LEFT); previewBox.with(previewBoxRight).expand(previewBoxRight); content.addComponent(previewBox); CssLayout cropBox = new CssLayout(); cropBox.setWidth("100%"); VerticalLayout currentPhotoBox = new VerticalLayout(); Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage), "image/png"); CropField cropField = new CropField(resource); cropField.setImmediate(true); cropField.setSelectionAspectRatio(150 / 28); cropField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { VCropSelection newSelection = (VCropSelection) event.getProperty().getValue(); int x1 = newSelection.getXTopLeft(); int y1 = newSelection.getYTopLeft(); int x2 = newSelection.getXBottomRight(); int y2 = newSelection.getYBottomRight(); if (x2 > x1 && y2 > y1) { BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1)); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); try { ImageIO.write(subImage, "png", outStream); scaleImageData = outStream.toByteArray(); displayPreviewImage(); } catch (IOException e) { LOG.error("Error while scale image: ", e); } } } }); currentPhotoBox.setWidth("650px"); currentPhotoBox.setHeight("650px"); currentPhotoBox.addComponent(cropField); cropBox.addComponent(currentPhotoBox); content.with(previewBox, ELabel.hr(), cropBox); }
From source file:com.esofthead.mycollab.module.user.accountsettings.profile.view.PasswordChangeWindow.java
License:Open Source License
private void initUI() { final MVerticalLayout mainLayout = new MVerticalLayout().withWidth("100%"); final Label lbInstruct1 = new Label(AppContext.getMessage(UserI18nEnum.MSG_PASSWORD_INSTRUCT_LABEL_1)); mainLayout.addComponent(lbInstruct1); mainLayout.setComponentAlignment(lbInstruct1, Alignment.MIDDLE_LEFT); final Label lbInstruct2 = new Label(AppContext.getMessage(UserI18nEnum.MSG_PASSWORD_INSTRUCT_LABEL_2)); mainLayout.addComponent(lbInstruct2); mainLayout.setComponentAlignment(lbInstruct2, Alignment.MIDDLE_LEFT); final GridFormLayoutHelper passInfo = new GridFormLayoutHelper(1, 3, "300px", "180px"); txtNewPassword = new PasswordField(); passInfo.addComponent(txtNewPassword, "New Password", 0, 0); txtConfirmPassword = new PasswordField(); passInfo.addComponent(txtConfirmPassword, "Confirmed New Password", 0, 1); passInfo.getLayout().setSpacing(true); mainLayout.addComponent(passInfo.getLayout()); mainLayout.setComponentAlignment(passInfo.getLayout(), Alignment.MIDDLE_CENTER); final MHorizontalLayout hlayoutControls = new MHorizontalLayout().withMargin(true); final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override/*from w w w . jav a2s . co m*/ public void buttonClick(final ClickEvent event) { PasswordChangeWindow.this.close(); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { PasswordChangeWindow.this.changePassword(); } }); saveBtn.setStyleName(UIConstants.THEME_GREEN_LINK); saveBtn.setIcon(FontAwesome.SAVE); hlayoutControls.with(saveBtn, cancelBtn).alignAll(Alignment.MIDDLE_CENTER); mainLayout.with(hlayoutControls).withAlign(hlayoutControls, Alignment.MIDDLE_RIGHT); this.setModal(true); this.setContent(mainLayout); }
From source file:com.esofthead.mycollab.module.user.accountsettings.profile.view.ProfilePhotoUploadViewImpl.java
License:Open Source License
@SuppressWarnings("serial") @Override/*from w ww . j a va2 s.c o m*/ public void editPhoto(final byte[] imageData) { this.removeAllComponents(); LOG.debug("Receive avatar upload with size: " + imageData.length); try { originalImage = ImageIO.read(new ByteArrayInputStream(imageData)); } catch (IOException e) { throw new UserInvalidInputException("Invalid image type"); } originalImage = ImageUtil.scaleImage(originalImage, 650, 650); MHorizontalLayout previewBox = new MHorizontalLayout().withSpacing(true) .withMargin(new MarginInfo(false, true, true, false)).withWidth("100%"); Resource defaultPhoto = UserAvatarControlFactory.createAvatarResource(AppContext.getUserAvatarId(), 100); previewImage = new Embedded(null, defaultPhoto); previewImage.setWidth("100px"); previewBox.addComponent(previewImage); previewBox.setComponentAlignment(previewImage, Alignment.TOP_LEFT); VerticalLayout previewBoxRight = new VerticalLayout(); previewBoxRight.setMargin(new MarginInfo(false, true, false, true)); Label lbPreview = new Label( "<p style='margin: 0px;'><strong>To the left is what your profile photo will look like.</strong></p><p style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. When you are happy with your photo, click the “Accept“ button.</p>", ContentMode.HTML); previewBoxRight.addComponent(lbPreview); MHorizontalLayout controlBtns = new MHorizontalLayout(); controlBtns.setSizeUndefined(); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new ProfileEvent.GotoProfileView(ProfilePhotoUploadViewImpl.this, null)); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); Button acceptBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (scaleImageData != null && scaleImageData.length > 0) { try { BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData)); UserAvatarService userAvatarService = ApplicationContextUtil .getSpringBean(UserAvatarService.class); userAvatarService.uploadAvatar(image, AppContext.getUsername(), AppContext.getUserAvatarId()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } catch (IOException e) { throw new MyCollabException("Error when saving user avatar", e); } } } }); acceptBtn.setStyleName(UIConstants.THEME_GREEN_LINK); acceptBtn.setIcon(FontAwesome.CHECK); controlBtns.with(acceptBtn, cancelBtn).alignAll(Alignment.MIDDLE_LEFT); previewBoxRight.addComponent(controlBtns); previewBoxRight.setComponentAlignment(controlBtns, Alignment.TOP_LEFT); previewBox.addComponent(previewBoxRight); previewBox.setExpandRatio(previewBoxRight, 1.0f); this.addComponent(previewBox); CssLayout cropBox = new CssLayout(); cropBox.addStyleName(UIConstants.PHOTO_CROPBOX); cropBox.setWidth("100%"); VerticalLayout currentPhotoBox = new VerticalLayout(); Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage), "image/png"); CropField cropField = new CropField(resource); cropField.setImmediate(true); cropField.setSelectionAspectRatio(1.0f); cropField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { VCropSelection newSelection = (VCropSelection) event.getProperty().getValue(); int x1 = newSelection.getXTopLeft(); int y1 = newSelection.getYTopLeft(); int x2 = newSelection.getXBottomRight(); int y2 = newSelection.getYBottomRight(); if (x2 > x1 && y2 > y1) { BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1)); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); try { ImageIO.write(subImage, "png", outStream); scaleImageData = outStream.toByteArray(); displayPreviewImage(); } catch (IOException e) { LOG.error("Error while scale image: ", e); } } } }); currentPhotoBox.setWidth("650px"); currentPhotoBox.setHeight("650px"); currentPhotoBox.addComponent(cropField); cropBox.addComponent(currentPhotoBox); this.addComponent(previewBox); this.addComponent(cropBox); this.setExpandRatio(cropBox, 1.0f); }