List of usage examples for com.vaadin.ui Alignment TOP_LEFT
Alignment TOP_LEFT
To view the source code for com.vaadin.ui Alignment TOP_LEFT.
Click Source Link
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 ww . ja va 2s. com 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 2 s. co m*/ 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; }
From source file:com.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java
License:Open Source License
private void buildLogoPanel() { FormContainer formContainer = new FormContainer(); MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(true); MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false); Label logoDesc = new Label(UserUIContext.getMessage(AdminI18nEnum.OPT_LOGO_FORMAT_DESCRIPTION)); leftPanel.with(logoDesc).withWidth("250px"); MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false); CustomLayout previewLayout = CustomLayoutExt.createLayout("topNavigation"); previewLayout.setStyleName("example-block"); previewLayout.setHeight("40px"); previewLayout.setWidth("520px"); Button currentLogo = AccountAssetsResolver.createAccountLogoImageComponent(billingAccount.getLogopath(), 150);/* w ww .ja v a 2 s. c o m*/ previewLayout.addComponent(currentLogo, "mainLogo"); final ServiceMenu serviceMenu = new ServiceMenu(); Button.ClickListener clickListener = new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { for (Component comp : serviceMenu) { if (comp != event.getButton()) { comp.removeStyleName("selected"); } } event.getButton().addStyleName("selected"); } }; serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM), VaadinIcons.MONEY, clickListener); serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT), VaadinIcons.TASKS, clickListener); serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), VaadinIcons.SUITCASE, clickListener); serviceMenu.selectService(0); previewLayout.addComponent(serviceMenu, "serviceMenu"); MHorizontalLayout buttonControls = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, false, false)); buttonControls.setDefaultComponentAlignment(Alignment.TOP_LEFT); final UploadField logoUploadField = new UploadField() { private static final long serialVersionUID = 1L; @Override protected void updateDisplay() { byte[] imageData = (byte[]) this.getValue(); String mimeType = this.getLastMimeType(); if (mimeType.equals("image/jpeg")) { imageData = ImageUtil.convertJpgToPngFormat(imageData); if (imageData == null) { throw new UserInvalidInputException( UserUIContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT)); } else { mimeType = "image/png"; } } if (mimeType.equals("image/png")) { UI.getCurrent().addWindow(new LogoEditWindow(imageData)); } else { throw new UserInvalidInputException( UserUIContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT)); } } }; logoUploadField.setButtonCaption(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE)); logoUploadField.addStyleName("upload-field"); logoUploadField.setSizeUndefined(); logoUploadField.setFieldType(UploadField.FieldType.BYTE_ARRAY); logoUploadField.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); MButton resetButton = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_RESET), clickEvent -> { BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class); billingAccount.setLogopath(null); billingAccountService.updateWithSession(billingAccount, UserUIContext.getUsername()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); }).withStyleName(WebThemes.BUTTON_OPTION); resetButton.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); buttonControls.with(resetButton, logoUploadField); rightPanel.with(previewLayout, buttonControls); layout.with(leftPanel, rightPanel).expand(rightPanel); formContainer.addSection("Logo", layout); this.with(formContainer); }
From source file:com.mycollab.module.user.accountsettings.customize.view.LogoEditWindow.java
License:Open Source License
private void editPhoto(byte[] imageData) { try {// w ww.ja va 2s .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 = 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.AdvancedInfoChangeWindow.java
License:Open Source License
private void initUI() { MVerticalLayout mainLayout = new MVerticalLayout().withMargin(new MarginInfo(false, false, true, false)) .withFullWidth();/*from ww w. jav a 2 s .co m*/ GridFormLayoutHelper passInfo = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4); passInfo.addComponent(txtWebsite, UserUIContext.getMessage(UserI18nEnum.FORM_WEBSITE), 0, 0); passInfo.addComponent(txtCompany, UserUIContext.getMessage(UserI18nEnum.FORM_COMPANY), 0, 1); passInfo.addComponent(cboCountry, UserUIContext.getMessage(UserI18nEnum.FORM_COUNTRY), 0, 2); txtWebsite.setValue(MoreObjects.firstNonNull(user.getWebsite(), "")); txtCompany.setValue(MoreObjects.firstNonNull(user.getCompany(), "")); cboCountry.setValue(MoreObjects.firstNonNull(user.getCountry(), "")); mainLayout.with(passInfo.getLayout()).withAlign(passInfo.getLayout(), Alignment.TOP_LEFT); MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION); MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> changeInfo()).withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.SAVE) .withClickShortcut(ShortcutAction.KeyCode.ENTER); MHorizontalLayout buttonControls = new MHorizontalLayout(cancelBtn, saveBtn) .withMargin(new MarginInfo(false, true, false, true)); mainLayout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT); this.setModal(true); this.setContent(mainLayout); }
From source file:com.mycollab.module.user.accountsettings.profile.view.BasicInfoChangeWindow.java
License:Open Source License
private void initUI() { final MVerticalLayout mainLayout = new MVerticalLayout() .withMargin(new MarginInfo(false, false, true, false)).withFullWidth(); final GridFormLayoutHelper passInfo = GridFormLayoutHelper.defaultFormLayoutHelper(1, 6); passInfo.addComponent(txtFirstName, UserUIContext.getMessage(UserI18nEnum.FORM_FIRST_NAME), 0, 0); passInfo.addComponent(txtLastName, UserUIContext.getMessage(UserI18nEnum.FORM_LAST_NAME), 0, 1); txtLastName.setRequired(true);/*from ww w .ja v a 2 s .c o m*/ passInfo.addComponent(txtEmail, UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL), 0, 2); txtEmail.setRequired(true); passInfo.addComponent(birthdayField, UserUIContext.getMessage(UserI18nEnum.FORM_BIRTHDAY), 0, 3); birthdayField.setDate(user.getDateofbirth()); passInfo.addComponent(timeZoneField, UserUIContext.getMessage(UserI18nEnum.FORM_TIMEZONE), 0, 4); timeZoneField.setValue(user.getTimezone()); passInfo.addComponent(languageBox, UserUIContext.getMessage(UserI18nEnum.FORM_LANGUAGE), UserUIContext.getMessage(ShellI18nEnum.OPT_SUPPORTED_LANGUAGES_INTRO), 0, 5); languageBox.setValue(user.getLanguage()); txtFirstName.setValue(MoreObjects.firstNonNull(user.getFirstname(), "")); txtLastName.setValue(MoreObjects.firstNonNull(user.getLastname(), "")); txtEmail.setValue(MoreObjects.firstNonNull(user.getEmail(), "")); birthdayField.setValue(user.getDateofbirth()); mainLayout.addComponent(passInfo.getLayout()); mainLayout.setComponentAlignment(passInfo.getLayout(), Alignment.TOP_LEFT); MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION); MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> changeUserInfo()).withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.SAVE) .withClickShortcut(ShortcutAction.KeyCode.ENTER); MHorizontalLayout hlayoutControls = new MHorizontalLayout(cancelBtn, saveBtn) .withMargin(new MarginInfo(false, true, false, true)); mainLayout.with(hlayoutControls).withAlign(hlayoutControls, Alignment.MIDDLE_RIGHT); this.setContent(mainLayout); }
From source file:com.mycollab.module.user.accountsettings.profile.view.ContactInfoChangeWindow.java
License:Open Source License
private void initUI() { MVerticalLayout mainLayout = new MVerticalLayout().withMargin(new MarginInfo(false, false, true, false)) .withFullWidth();/*from www . j a v a 2 s . co m*/ GridFormLayoutHelper passInfo = GridFormLayoutHelper.defaultFormLayoutHelper(1, 6); passInfo.addComponent(txtWorkPhone, UserUIContext.getMessage(UserI18nEnum.FORM_WORK_PHONE), 0, 0); passInfo.addComponent(txtHomePhone, UserUIContext.getMessage(UserI18nEnum.FORM_HOME_PHONE), 0, 1); passInfo.addComponent(txtFaceBook, "Facebook", 0, 2); passInfo.addComponent(txtTwitter, "Twitter", 0, 3); passInfo.addComponent(txtSkype, "Skype", 0, 4); txtWorkPhone.setValue(MoreObjects.firstNonNull(user.getWorkphone(), "")); txtHomePhone.setValue(MoreObjects.firstNonNull(user.getHomephone(), "")); txtFaceBook.setValue(MoreObjects.firstNonNull(user.getFacebookaccount(), "")); txtTwitter.setValue(MoreObjects.firstNonNull(user.getTwitteraccount(), "")); txtSkype.setValue(MoreObjects.firstNonNull(user.getSkypecontact(), "")); mainLayout.addComponent(passInfo.getLayout()); mainLayout.setComponentAlignment(passInfo.getLayout(), Alignment.TOP_LEFT); MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION); MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> changeUserInfo()).withIcon(FontAwesome.SAVE).withStyleName(WebThemes.BUTTON_ACTION) .withClickShortcut(ShortcutAction.KeyCode.ENTER); MHorizontalLayout hlayoutControls = new MHorizontalLayout(cancelBtn, saveBtn) .withMargin(new MarginInfo(false, true, false, true)); mainLayout.with(hlayoutControls).withAlign(hlayoutControls, Alignment.MIDDLE_RIGHT); this.setContent(mainLayout); }
From source file:com.mycollab.module.user.accountsettings.team.view.UserReadViewImpl.java
License:Open Source License
private void displayUserAvatar() { header.removeAllComponents();//from w w w . j a v a 2s.co m 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); }
From source file:com.mycollab.module.user.ui.components.ImagePreviewCropWindow.java
License:Open Source License
public ImagePreviewCropWindow(final ImageSelectionCommand imageSelectionCommand, final byte[] imageData) { super(UserUIContext.getMessage(ShellI18nEnum.OPT_PREVIEW_EDIT_IMAGE)); MVerticalLayout content = new MVerticalLayout(); withModal(true).withResizable(false).withWidth("700px").withCenter().withContent(content); try {// w w w . j av a 2 s . c om 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(); previewPhoto = new VerticalLayout(); previewPhoto.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); previewPhoto.setWidth("100px"); previewBox.with(previewPhoto).withAlign(previewPhoto, Alignment.TOP_LEFT); VerticalLayout previewBoxTitle = new VerticalLayout(); previewBoxTitle.setMargin(new MarginInfo(false, true, false, true)); previewBoxTitle .addComponent(ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_IMAGE_EDIT_INSTRUCTION))); MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> close()).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)); imageSelectionCommand.process(image); close(); } catch (IOException e) { throw new MyCollabException("Error when saving user avatar", e); } } }).withIcon(FontAwesome.CHECK).withStyleName(WebThemes.BUTTON_ACTION); MHorizontalLayout controlBtns = new MHorizontalLayout(acceptBtn, cancelBtn); previewBoxTitle.addComponent(controlBtns); previewBoxTitle.setComponentAlignment(controlBtns, Alignment.TOP_LEFT); previewBox.with(previewBoxTitle).expand(previewBoxTitle); 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(1.0f); 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("520px"); currentPhotoBox.setHeight("470px"); currentPhotoBox.addComponent(cropField); cropBox.addComponent(currentPhotoBox); content.with(previewBox, ELabel.hr(), cropBox); displayPreviewImage(); }
From source file:com.mycollab.shell.view.SetupNewInstanceView.java
License:Open Source License
SetupNewInstanceView() { this.setDefaultComponentAlignment(Alignment.TOP_CENTER); MHorizontalLayout content = new MHorizontalLayout().withFullHeight(); this.with(content); content.with(new MHorizontalLayout( ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_SUPPORTED_LANGUAGES_INTRO)) .withStyleName(WebThemes.META_COLOR)).withMargin(true).withWidth("400px") .withStyleName("separator")); MVerticalLayout formLayout = new MVerticalLayout().withWidth("600px"); content.with(formLayout).withAlign(formLayout, Alignment.TOP_LEFT); formLayout.with(ELabel.h2("Last step, you are almost there!").withWidthUndefined()); formLayout.with(ELabel.h3("All fields are required *").withStyleName("overdue").withWidthUndefined()); GridFormLayoutHelper formLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(2, 8, "200px"); formLayoutHelper.getLayout().setWidth("600px"); final TextField adminField = formLayoutHelper.addComponent(new TextField(), "Admin email", 0, 0); final PasswordField passwordField = formLayoutHelper.addComponent(new PasswordField(), "Admin password", 0, 1);/*from ww w . j a va 2 s . c o m*/ final PasswordField retypePasswordField = formLayoutHelper.addComponent(new PasswordField(), "Retype Admin password", 0, 2); final DateFormatField dateFormatField = formLayoutHelper.addComponent( new DateFormatField(SimpleBillingAccount.DEFAULT_DATE_FORMAT), UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_YYMMDD_FORMAT), UserUIContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 3); final DateFormatField shortDateFormatField = formLayoutHelper.addComponent( new DateFormatField(SimpleBillingAccount.DEFAULT_SHORT_DATE_FORMAT), UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_MMDD_FORMAT), UserUIContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 4); final DateFormatField longDateFormatField = formLayoutHelper.addComponent( new DateFormatField(SimpleBillingAccount.DEFAULT_LONG_DATE_FORMAT), UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_HUMAN_DATE_FORMAT), UserUIContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 5); final TimeZoneSelectionField timeZoneSelectionField = formLayoutHelper.addComponent( new TimeZoneSelectionField(false), UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_TIMEZONE), 0, 6); timeZoneSelectionField.setValue(TimeZone.getDefault().getID()); final LanguageSelectionField languageBox = formLayoutHelper.addComponent(new LanguageSelectionField(), UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_LANGUAGE), 0, 7); languageBox.setValue(Locale.US.toLanguageTag()); formLayout.with(formLayoutHelper.getLayout()); CheckBox createSampleDataSelection = new CheckBox("Create sample data", true); MButton installBtn = new MButton("Setup", clickEvent -> { String adminName = adminField.getValue(); String password = passwordField.getValue(); String retypePassword = retypePasswordField.getValue(); if (!StringUtils.isValidEmail(adminName)) { NotificationUtil.showErrorNotification("Invalid email value"); return; } if (!password.equals(retypePassword)) { NotificationUtil.showErrorNotification("Password is not match"); return; } String dateFormat = dateFormatField.getValue(); String shortDateFormat = shortDateFormatField.getValue(); String longDateFormat = longDateFormatField.getValue(); if (!isValidDayPattern(dateFormat) || !isValidDayPattern(shortDateFormat) || !isValidDayPattern(longDateFormat)) { NotificationUtil.showErrorNotification("Invalid date format"); return; } String language = languageBox.getValue(); String timezoneDbId = timeZoneSelectionField.getValue(); BillingAccountMapper billingAccountMapper = AppContextUtil.getSpringBean(BillingAccountMapper.class); BillingAccountExample ex = new BillingAccountExample(); ex.createCriteria().andIdEqualTo(MyCollabUI.getAccountId()); List<BillingAccount> billingAccounts = billingAccountMapper.selectByExample(ex); BillingAccount billingAccount = billingAccounts.get(0); billingAccount.setDefaultlanguagetag(language); billingAccount.setDefaultyymmddformat(dateFormat); billingAccount.setDefaultmmddformat(shortDateFormat); billingAccount.setDefaulthumandateformat(longDateFormat); billingAccount.setDefaulttimezone(timezoneDbId); billingAccountMapper.updateByPrimaryKey(billingAccount); BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class); billingAccountService.createDefaultAccountData(adminName, password, timezoneDbId, language, true, createSampleDataSelection.getValue(), MyCollabUI.getAccountId()); ((DesktopApplication) UI.getCurrent()).doLogin(adminName, password, false); }).withStyleName(WebThemes.BUTTON_ACTION); MHorizontalLayout buttonControls = new MHorizontalLayout(createSampleDataSelection, installBtn) .alignAll(Alignment.MIDDLE_RIGHT); formLayout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT); }