List of usage examples for com.vaadin.ui CssLayout addComponent
@Override public void addComponent(Component c)
From source file:com.mycollab.module.project.ui.components.ProjectSubscribersComp.java
License:Open Source License
@Override protected Component initContent() { ProjectMemberService projectMemberService = AppContextUtil.getSpringBean(ProjectMemberService.class); List<SimpleUser> members = projectMemberService.getActiveUsersInProject(projectId, MyCollabUI.getAccountId());/* w ww . j a v a 2s .c o m*/ CssLayout container = new CssLayout(); container.setStyleName("followers-container"); final CheckBox selectAllCheckbox = new CheckBox("All", defaultSelectAll); selectAllCheckbox.addValueChangeListener(valueChangeEvent -> { boolean val = selectAllCheckbox.getValue(); for (FollowerCheckbox followerCheckbox : memberSelections) { followerCheckbox.setValue(val); } }); container.addComponent(selectAllCheckbox); for (SimpleUser user : members) { final FollowerCheckbox memberCheckbox = new FollowerCheckbox(user); memberCheckbox.addValueChangeListener(valueChangeEvent -> { if (!memberCheckbox.getValue()) { selectAllCheckbox.setValue(false); } }); if (defaultSelectAll || selectedUsers.contains(user.getUsername())) { memberCheckbox.setValue(true); } memberSelections.add(memberCheckbox); container.addComponent(memberCheckbox); } return container; }
From source file:com.mycollab.module.project.view.settings.ComponentListViewImpl.java
License:Open Source License
private ComponentContainer constructTableActionControls() { final CssLayout layoutWrapper = new CssLayout(); layoutWrapper.setWidth("100%"); MHorizontalLayout layout = new MHorizontalLayout(); layoutWrapper.addStyleName(WebThemes.TABLE_ACTION_CONTROLS); layoutWrapper.addComponent(layout); this.selectOptionButton = new SelectionOptionButton(tableItem); layout.addComponent(this.selectOptionButton); tableActionControls = new DefaultMassItemActionHandlerContainer(); if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.COMPONENTS)) { tableActionControls.addDeleteActionItem(); }// www . jav a 2 s.c o m tableActionControls.addMailActionItem(); tableActionControls.addDownloadPdfActionItem(); tableActionControls.addDownloadExcelActionItem(); tableActionControls.addDownloadCsvActionItem(); layout.with(tableActionControls, selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel, Alignment.MIDDLE_CENTER); return layoutWrapper; }
From source file:com.mycollab.module.project.view.settings.ProjectRoleListViewImpl.java
License:Open Source License
private ComponentContainer constructTableActionControls() { CssLayout layoutWrapper = new CssLayout(); layoutWrapper.setWidth("100%"); MHorizontalLayout layout = new MHorizontalLayout(); layoutWrapper.addStyleName(WebThemes.TABLE_ACTION_CONTROLS); layoutWrapper.addComponent(layout); selectOptionButton = new SelectionOptionButton(this.tableItem); layout.addComponent(this.selectOptionButton); tableActionControls = new DefaultMassItemActionHandlerContainer(); if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.ROLES)) { tableActionControls.addDeleteActionItem(); }//from w ww. ja va 2s .c om tableActionControls.addDownloadPdfActionItem(); tableActionControls.addDownloadExcelActionItem(); tableActionControls.addDownloadCsvActionItem(); layout.with(this.tableActionControls, this.selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel, Alignment.MIDDLE_LEFT); return layoutWrapper; }
From source file:com.mycollab.module.project.view.settings.ProjectRoleReadViewImpl.java
License:Open Source License
public ProjectRoleReadViewImpl() { withMargin(new MarginInfo(true, false, true, false)); headerText = HeaderWithFontAwesome.h2(FontAwesome.USERS, UserUIContext.getMessage(ProjectRoleI18nEnum.DETAIL)); headerText.setSizeUndefined();// w ww .ja v a2s.c o m this.addComponent(constructHeader()); previewForm = initPreviewForm(); ComponentContainer actionControls = createButtonControls(); addHeaderRightContent(actionControls); CssLayout contentWrapper = new CssLayout(); contentWrapper.setWidth("100%"); contentWrapper.setStyleName(WebThemes.CONTENT_WRAPPER); previewLayout = new DefaultReadViewLayout(""); contentWrapper.addComponent(previewLayout); previewLayout.addBody(previewForm); this.addComponent(contentWrapper); }
From source file:com.mycollab.module.project.view.settings.VersionListViewImpl.java
License:Open Source License
private ComponentContainer constructTableActionControls() { final CssLayout layoutWrapper = new CssLayout(); layoutWrapper.setWidth("100%"); MHorizontalLayout layout = new MHorizontalLayout(); layoutWrapper.addStyleName(WebThemes.TABLE_ACTION_CONTROLS); layoutWrapper.addComponent(layout); this.selectOptionButton = new SelectionOptionButton(this.tableItem); layout.addComponent(this.selectOptionButton); tableActionControls = new DefaultMassItemActionHandlerContainer(); if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.VERSIONS)) { tableActionControls.addDeleteActionItem(); }// w ww. ja v a 2 s . com tableActionControls.addMailActionItem(); tableActionControls.addDownloadPdfActionItem(); tableActionControls.addDownloadExcelActionItem(); tableActionControls.addDownloadCsvActionItem(); layout.with(tableActionControls, selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel, Alignment.MIDDLE_CENTER); return layoutWrapper; }
From source file:com.mycollab.module.project.view.ticket.TicketRowRenderer.java
License:Open Source License
TicketRowRenderer(final ProjectTicket ticket) { this.ticket = ticket; withMargin(false).withFullWidth().addStyleName(WebThemes.BORDER_LIST_ROW); if (ticket.isTask()) { addStyleName("task"); } else if (ticket.isBug()) { addStyleName("bug"); } else if (ticket.isRisk()) { addStyleName("risk"); }/*from ww w .ja v a2 s . c o m*/ toggleTicketField = new ToggleTicketSummaryField(ticket); MHorizontalLayout headerLayout = new MHorizontalLayout( ELabel.fontIcon(ProjectAssetsManager.getAsset(ticket.getType())).withWidthUndefined(), toggleTicketField).expand(toggleTicketField).withFullWidth() .withMargin(new MarginInfo(false, true, false, false)); TicketComponentFactory popupFieldFactory = AppContextUtil.getSpringBean(TicketComponentFactory.class); AbstractComponent assigneeField = wrapListenerComponent(popupFieldFactory.createAssigneePopupField(ticket)); headerLayout.with(assigneeField, toggleTicketField).expand(toggleTicketField); CssLayout footer = new CssLayout(); footer.addComponent(popupFieldFactory.createCommentsPopupField(ticket)); footer.addComponent(wrapListenerComponent(popupFieldFactory.createPriorityPopupField(ticket))); footer.addComponent(popupFieldFactory.createFollowersPopupField(ticket)); footer.addComponent(wrapListenerComponent(popupFieldFactory.createStatusPopupField(ticket))); footer.addComponent(wrapListenerComponent(popupFieldFactory.createStartDatePopupField(ticket))); footer.addComponent(wrapListenerComponent(popupFieldFactory.createEndDatePopupField(ticket))); footer.addComponent(wrapListenerComponent(popupFieldFactory.createDueDatePopupField(ticket))); if (!SiteConfiguration.isCommunityEdition()) { footer.addComponent(popupFieldFactory.createBillableHoursPopupField(ticket)); footer.addComponent(popupFieldFactory.createNonBillableHoursPopupField(ticket)); } this.with(headerLayout, footer); }
From source file:com.mycollab.module.project.view.user.ProjectActivityStreamPagedList.java
License:Open Source License
@Override protected void doSearch() { totalCount = projectActivityStreamService.getTotalActivityStream( ((BasicSearchRequest<ActivityStreamSearchCriteria>) searchRequest).getSearchCriteria()); totalPage = (totalCount - 1) / searchRequest.getNumberOfItems() + 1; if (searchRequest.getCurrentPage() > totalPage) { searchRequest.setCurrentPage(totalPage); }/*from ww w . j a v a2 s . c om*/ if (totalPage > 1) { if (controlBarWrapper != null) { removeComponent(controlBarWrapper); } this.addComponent(createPageControls()); } else { if (getComponentCount() == 2) { removeComponent(getComponent(1)); } } List<ProjectActivityStream> currentListData = projectActivityStreamService .getProjectActivityStreams((BasicSearchRequest<ActivityStreamSearchCriteria>) searchRequest); this.listContainer.removeAllComponents(); Date currentDate = new GregorianCalendar(2100, 1, 1).getTime(); CssLayout currentFeedBlock = new CssLayout(); AuditLogRegistry auditLogRegistry = AppContextUtil.getSpringBean(AuditLogRegistry.class); try { for (ProjectActivityStream activityStream : currentListData) { if (ProjectTypeConstants.PAGE.equals(activityStream.getType())) { ProjectPageService pageService = AppContextUtil.getSpringBean(ProjectPageService.class); Page page = pageService.getPage(activityStream.getTypeid(), UserUIContext.getUsername()); if (page != null) { activityStream.setNamefield(page.getSubject()); } } Date itemCreatedDate = activityStream.getCreatedtime(); if (!DateUtils.isSameDay(currentDate, itemCreatedDate)) { currentFeedBlock = new CssLayout(); currentFeedBlock.setStyleName("feed-block"); feedBlocksPut(currentDate, itemCreatedDate, currentFeedBlock); currentDate = itemCreatedDate; } StringBuilder content = new StringBuilder(); String itemType = ProjectLocalizationTypeMap.getType(activityStream.getType()); String assigneeParam = buildAssigneeValue(activityStream); String itemParam = buildItemValue(activityStream); if (ActivityStreamConstants.ACTION_CREATE.equals(activityStream.getAction())) { content.append( UserUIContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_CREATE_ACTION_TITLE, assigneeParam, itemType, itemParam)); } else if (ActivityStreamConstants.ACTION_UPDATE.equals(activityStream.getAction())) { content.append( UserUIContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_UPDATE_ACTION_TITLE, assigneeParam, itemType, itemParam)); if (activityStream.getAssoAuditLog() != null) { content.append(auditLogRegistry.generatorDetailChangeOfActivity(activityStream)); } } else if (ActivityStreamConstants.ACTION_COMMENT.equals(activityStream.getAction())) { content.append( UserUIContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_COMMENT_ACTION_TITLE, assigneeParam, itemType, itemParam)); if (activityStream.getAssoAuditLog() != null) { content.append("<p><ul><li>\"").append( StringUtils.trimHtmlTags(activityStream.getAssoAuditLog().getChangeset(), 200)) .append("\"</li></ul></p>"); } } else if (ActivityStreamConstants.ACTION_DELETE.equals(activityStream.getAction())) { content.append( UserUIContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_DELETE_ACTION_TITLE, assigneeParam, itemType, itemParam)); } Label actionLbl = new Label(content.toString(), ContentMode.HTML); CssLayout streamWrapper = new CssLayout(); streamWrapper.setWidth("100%"); streamWrapper.addStyleName("stream-wrapper"); streamWrapper.addComponent(actionLbl); currentFeedBlock.addComponent(streamWrapper); } } catch (Exception e) { throw new MyCollabException(e); } }
From source file:com.mycollab.module.user.accountsettings.customize.view.LogoEditWindow.java
License:Open Source License
private void editPhoto(byte[] imageData) { try {/*w ww . j a va 2 s . com*/ 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 = MyCollabUI.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)); previewBoxRight .addComponent(ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_IMAGE_EDIT_INSTRUCTION))); MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> EventBusFactory.getInstance() .post(new SettingEvent.GotoGeneralSetting(LogoEditWindow.this, null))) .withStyleName(WebThemes.BUTTON_OPTION); MButton acceptBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), clickEvent -> { if (scaleImageData != null && scaleImageData.length > 0) { try { BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData)); AccountLogoService accountLogoService = AppContextUtil.getSpringBean(AccountLogoService.class); accountLogoService.upload(UserUIContext.getUsername(), image, MyCollabUI.getAccountId()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } catch (IOException e) { throw new MyCollabException("Error when saving account logo", e); } } }).withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.SAVE) .withClickShortcut(ShortcutAction.KeyCode.ENTER); MHorizontalLayout controlBtns = new MHorizontalLayout(acceptBtn, cancelBtn); 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(valueChangeEvent -> { VCropSelection newSelection = (VCropSelection) valueChangeEvent.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.mycollab.module.user.accountsettings.profile.view.ProfileReadViewImpl.java
License:Open Source License
private void displayUserAvatar() { avatarAndPass.removeAllComponents(); Image cropField = UserAvatarControlFactory .createUserAvatarEmbeddedComponent(UserUIContext.getUserAvatarId(), 100); cropField.addStyleName(UIConstants.CIRCLE_BOX); CssLayout avatarWrapper = new CssLayout(); avatarWrapper.addComponent(cropField); MVerticalLayout userAvatar = new MVerticalLayout().withMargin(false).with(avatarWrapper); userAvatar.setSizeUndefined();//from w w w . ja v a2s .co m final UploadImageField avatarUploadField = new UploadImageField(this); avatarUploadField.setButtonCaption(UserUIContext.getMessage(UserI18nEnum.BUTTON_CHANGE_AVATAR)); userAvatar.addComponent(avatarUploadField); avatarAndPass.with(userAvatar); User user = formItem.getBean(); MVerticalLayout basicLayout = new MVerticalLayout().withMargin(false); ELabel usernameLbl = ELabel.h2(UserUIContext.getUser().getDisplayName()).withWidthUndefined(); MButton btnChangeBasicInfo = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_EDIT), clickEvent -> UI.getCurrent().addWindow(new BasicInfoChangeWindow(formItem.getBean()))) .withStyleName(WebThemes.BUTTON_LINK); MHorizontalLayout userWrapper = new MHorizontalLayout(usernameLbl, btnChangeBasicInfo); basicLayout.addComponent(userWrapper); basicLayout.setComponentAlignment(userWrapper, Alignment.MIDDLE_LEFT); GridFormLayoutHelper userFormLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 5) .withCaptionWidth("140px"); userFormLayout.getLayout().addStyleName(WebThemes.GRIDFORM_BORDERLESS); userFormLayout.addComponent(new Label(UserUIContext.formatDate(user.getDateofbirth())), UserUIContext.getMessage(UserI18nEnum.FORM_BIRTHDAY), 0, 0); userFormLayout .addComponent( new Label(new A("mailto:" + user.getEmail()).appendText(user.getEmail()).setTarget("_blank") .write(), ContentMode.HTML), UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL), 0, 1); userFormLayout.addComponent( new Label(TimezoneVal.getDisplayName(UserUIContext.getUserLocale(), user.getTimezone())), UserUIContext.getMessage(UserI18nEnum.FORM_TIMEZONE), 0, 2); userFormLayout.addComponent( new Label(LocalizationHelper.getLocaleInstance(user.getLanguage()) .getDisplayLanguage(UserUIContext.getUserLocale())), UserUIContext.getMessage(UserI18nEnum.FORM_LANGUAGE), UserUIContext.getMessage(ShellI18nEnum.OPT_SUPPORTED_LANGUAGES_INTRO), 0, 3); MButton btnChangePassword = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE), clickEvent -> UI.getCurrent().addWindow(new PasswordChangeWindow(formItem.getBean()))) .withStyleName(WebThemes.BUTTON_LINK); userFormLayout.addComponent(new MHorizontalLayout(new Label("***********"), btnChangePassword), UserUIContext.getMessage(ShellI18nEnum.FORM_PASSWORD), 0, 4); basicLayout.addComponent(userFormLayout.getLayout()); avatarAndPass.with(basicLayout).expand(basicLayout); }
From source file:com.mycollab.module.user.accountsettings.team.view.UserReadViewImpl.java
License:Open Source License
private void displayUserAvatar() { header.removeAllComponents();/* w w w . ja v a 2 s .c om*/ MHorizontalLayout avatarAndPass = new MHorizontalLayout().withFullWidth(); Image cropField = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(user.getAvatarid(), 100); cropField.addStyleName(UIConstants.CIRCLE_BOX); CssLayout userAvatar = new CssLayout(); userAvatar.addComponent(cropField); avatarAndPass.addComponent(userAvatar); MVerticalLayout basicLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, false, true)); CssLayout userWrapper = new CssLayout(); String nickName = user.getNickname(); ELabel userName = ELabel.h2(user.getDisplayName() + (StringUtils.isEmpty(nickName) ? "" : (String.format(" ( %s )", nickName)))); userWrapper.addComponent(userName); basicLayout.addComponent(userWrapper); basicLayout.setComponentAlignment(userWrapper, Alignment.MIDDLE_LEFT); GridFormLayoutHelper userFormLayout; if (UserUIContext.isAdmin()) { userFormLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 6).withCaptionWidth("140px"); } else { userFormLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 5).withCaptionWidth("140px"); } userFormLayout.getLayout().addStyleName(WebThemes.GRIDFORM_BORDERLESS); basicLayout.addComponent(userFormLayout.getLayout()); Node roleDiv; if (Boolean.TRUE.equals(user.getIsAccountOwner())) { roleDiv = new Div().appendText(UserUIContext.getMessage(RoleI18nEnum.OPT_ACCOUNT_OWNER)); } else { roleDiv = new A(AccountLinkBuilder.generatePreviewFullRoleLink(user.getRoleid())) .appendText(user.getRoleName()); } userFormLayout.addComponent(ELabel.html(roleDiv.write()), UserUIContext.getMessage(UserI18nEnum.FORM_ROLE), 0, 0); userFormLayout.addComponent(new Label(UserUIContext.formatDate(user.getDateofbirth())), UserUIContext.getMessage(UserI18nEnum.FORM_BIRTHDAY), 0, 1); if (Boolean.TRUE.equals(MyCollabUI.showEmailPublicly())) { userFormLayout.addComponent( ELabel.html(new A("mailto:" + user.getEmail()).appendText(user.getEmail()).write()), UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL), 0, 2); } else { userFormLayout.addComponent(ELabel.html("******"), UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL), 0, 2); } userFormLayout.addComponent( new Label(TimezoneVal.getDisplayName(UserUIContext.getUserLocale(), user.getTimezone())), UserUIContext.getMessage(UserI18nEnum.FORM_TIMEZONE), 0, 3); userFormLayout.addComponent( new Label(LocalizationHelper.getLocaleInstance(user.getLanguage()) .getDisplayLanguage(UserUIContext.getUserLocale())), UserUIContext.getMessage(UserI18nEnum.FORM_LANGUAGE), 0, 4); if (UserUIContext.isAdmin()) { MButton btnChangePassword = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE), clickEvent -> UI.getCurrent().addWindow(new PasswordChangeWindow(user))) .withStyleName(WebThemes.BUTTON_LINK); userFormLayout.addComponent(new MHorizontalLayout(new Label("***********"), btnChangePassword), UserUIContext.getMessage(ShellI18nEnum.FORM_PASSWORD), 0, 5); } avatarAndPass.with(basicLayout).withAlign(basicLayout, Alignment.TOP_LEFT).expand(basicLayout); Layout controlButtons = createTopPanel(); CssLayout avatarAndPassWrapper = new CssLayout(); avatarAndPass.setWidthUndefined(); avatarAndPassWrapper.addComponent(avatarAndPass); header.with(avatarAndPass, controlButtons).withAlign(avatarAndPass, Alignment.TOP_LEFT) .withAlign(controlButtons, Alignment.TOP_RIGHT); }