List of usage examples for com.vaadin.ui Label Label
public Label(String text)
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 w w w . jav a2s . 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 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.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 w w.j ava2s. c om*/ 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/* www .j ava 2s . co 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();// w ww .ja v a 2 s .c o m 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.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(AppContext.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 w w . ja va 2 s .com*/ 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) { Iterator<Component> iterator = serviceMenu.iterator(); while (iterator.hasNext()) { Component comp = iterator.next(); if (comp != event.getButton()) { comp.removeStyleName("selected"); } } event.getButton().addStyleName("selected"); } }; serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_CRM), VaadinIcons.MONEY, clickListener); serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PROJECT), VaadinIcons.TASKS, clickListener); serviceMenu.addService(AppContext.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( AppContext.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( AppContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT)); } } }; logoUploadField.setButtonCaption(AppContext.getMessage(GenericI18Enum.ACTION_CHANGE)); logoUploadField.addStyleName("upload-field"); logoUploadField.setSizeUndefined(); logoUploadField.setFieldType(UploadField.FieldType.BYTE_ARRAY); logoUploadField.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); Button resetButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_RESET), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { BillingAccountService billingAccountService = AppContextUtil .getSpringBean(BillingAccountService.class); billingAccount.setLogopath(null); billingAccountService.updateWithSession(billingAccount, AppContext.getUsername()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } }); resetButton.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); resetButton.setStyleName(UIConstants.BUTTON_OPTION); buttonControls.with(logoUploadField, resetButton); rightPanel.with(previewLayout, buttonControls); layout.with(leftPanel, rightPanel).expand(rightPanel); formContainer.addSection("Logo", layout); this.with(formContainer); }
From source file:com.esofthead.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java
License:Open Source License
private void buildShortcutIconPanel() { FormContainer formContainer = new FormContainer(); MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true)); MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false); Label logoDesc = new Label(AppContext.getMessage(FileI18nEnum.OPT_FAVICON_FORMAT_DESCRIPTION)); leftPanel.with(logoDesc).withWidth("250px"); MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false); final Image favIconRes = new Image("", new ExternalResource(StorageFactory.getInstance() .getFavIconPath(billingAccount.getId(), billingAccount.getFaviconpath()))); MHorizontalLayout buttonControls = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, false, false)); buttonControls.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT); final UploadField favIconUploadField = new UploadField() { private static final long serialVersionUID = 1L; @Override//from ww w . j a v a 2 s .c o m 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( AppContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT)); } else { mimeType = "image/png"; } } if (mimeType.equals("image/png")) { try { AccountFavIconService favIconService = AppContextUtil .getSpringBean(AccountFavIconService.class); BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData)); String newFavIconPath = favIconService.upload(AppContext.getUsername(), image, AppContext.getAccountId()); favIconRes.setSource(new ExternalResource(StorageFactory.getInstance() .getFavIconPath(billingAccount.getId(), newFavIconPath))); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } catch (IOException e) { throw new MyCollabException(e); } } else { throw new UserInvalidInputException( AppContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT)); } } }; favIconUploadField.setButtonCaption(AppContext.getMessage(GenericI18Enum.ACTION_CHANGE)); favIconUploadField.addStyleName("upload-field"); favIconUploadField.setSizeUndefined(); favIconUploadField.setFieldType(UploadField.FieldType.BYTE_ARRAY); favIconUploadField.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); Button resetButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_RESET), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { BillingAccountService billingAccountService = AppContextUtil .getSpringBean(BillingAccountService.class); billingAccount.setFaviconpath(null); billingAccountService.updateWithSession(billingAccount, AppContext.getUsername()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } }); resetButton.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); resetButton.setStyleName(UIConstants.BUTTON_OPTION); buttonControls.with(favIconUploadField, resetButton); rightPanel.with(favIconRes, buttonControls); layout.with(leftPanel, rightPanel).expand(rightPanel); formContainer.addSection("Favicon", layout); this.with(formContainer); }
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 ww . j a v a 2 s .c om*/ 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.ProfileReadViewImpl.java
License:Open Source License
private void displayUserAvatar() { this.userAvatar.removeAllComponents(); final Image cropField = UserAvatarControlFactory .createUserAvatarEmbeddedComponent(AppContext.getUserAvatarId(), 100); userAvatar.addComponent(cropField);/*from w w w . j a v a2s . c o m*/ this.avatarAndPass.removeAllComponents(); avatarAndPass.addComponent(userAvatar); User user = formItem.getUser(); final VerticalLayout basicLayout = new VerticalLayout(); basicLayout.setSpacing(true); final HorizontalLayout userWrapper = new HorizontalLayout(); final Label userName = new Label(AppContext.getSession().getDisplayName()); userName.setStyleName("h1"); userWrapper.addComponent(userName); final Button btnChangeBasicInfo = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { UI.getCurrent().addWindow(new BasicInfoChangeWindow(formItem.getUser())); } }); btnChangeBasicInfo.setStyleName("link"); HorizontalLayout btnChangeBasicInfoWrapper = new HorizontalLayout(); btnChangeBasicInfoWrapper.setWidth("40px"); btnChangeBasicInfoWrapper.addComponent(btnChangeBasicInfo); btnChangeBasicInfoWrapper.setComponentAlignment(btnChangeBasicInfo, Alignment.MIDDLE_RIGHT); userWrapper.addComponent(btnChangeBasicInfoWrapper); basicLayout.addComponent(userWrapper); basicLayout.setComponentAlignment(userWrapper, Alignment.MIDDLE_LEFT); basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_BIRTHDAY) + ": " + AppContext.formatDate(user.getDateofbirth()))); basicLayout.addComponent( new MHorizontalLayout(new Label(AppContext.getMessage(UserI18nEnum.FORM_EMAIL) + ": "), new LabelLink(user.getEmail(), "mailto:" + user.getEmail()))); basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_TIMEZONE) + ": " + TimezoneMapper.getTimezone(user.getTimezone()).getDisplayName())); basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_LANGUAGE) + ": " + AppContext.getMessage(LangI18Enum.class, user.getLanguage()))); HorizontalLayout passwordWrapper = new HorizontalLayout(); passwordWrapper .addComponent(new Label(AppContext.getMessage(ShellI18nEnum.FORM_PASSWORD) + ": ***********")); final Button btnChangePassword = new Button("Change", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { UI.getCurrent().addWindow(new PasswordChangeWindow(formItem.user)); } }); btnChangePassword.setStyleName("link"); HorizontalLayout btnChangePasswordWrapper = new HorizontalLayout(); btnChangePasswordWrapper.setWidth("50px"); btnChangePasswordWrapper.addComponent(btnChangePassword); btnChangePasswordWrapper.setComponentAlignment(btnChangePassword, Alignment.MIDDLE_RIGHT); passwordWrapper.addComponent(btnChangePasswordWrapper); basicLayout.addComponent(passwordWrapper); basicLayout.setComponentAlignment(passwordWrapper, Alignment.MIDDLE_LEFT); avatarAndPass.addComponent(basicLayout); avatarAndPass.setComponentAlignment(basicLayout, Alignment.TOP_LEFT); avatarAndPass.setExpandRatio(basicLayout, 1.0f); final UploadField avatarUploadField = 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("Do not support image format for avatar"); } else { mimeType = "image/png"; } } if (mimeType.equals("image/png")) { EventBusFactory.getInstance() .post(new ProfileEvent.GotoUploadPhoto(ProfileReadViewImpl.this, imageData)); } else { throw new UserInvalidInputException( "Upload file does not have valid image format. The supported formats are jpg/png"); } } }; avatarUploadField.addStyleName("upload-field"); avatarUploadField.setButtonCaption(AppContext.getMessage(UserI18nEnum.BUTTON_CHANGE_AVATAR)); avatarUploadField.setSizeUndefined(); avatarUploadField.setFieldType(FieldType.BYTE_ARRAY); this.userAvatar.addComponent(avatarUploadField); }
From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.RoleReadViewImpl.java
License:Open Source License
protected Depot constructPermissionSectionView(String depotTitle, PermissionMap permissionMap, PermissionDefItem[] defItems) {/* w ww.j a va 2s .c o m*/ final GridFormLayoutHelper formHelper = new GridFormLayoutHelper(2, defItems.length, "100%", "167px", Alignment.TOP_LEFT); formHelper.getLayout().setMargin(true); formHelper.getLayout().setWidth("100%"); formHelper.getLayout().addStyleName(UIConstants.COLORED_GRIDLAYOUT); final Depot component = new Depot(depotTitle, formHelper.getLayout()); for (int i = 0; i < defItems.length; i++) { final PermissionDefItem permissionDefItem = defItems[i]; formHelper.addComponent(new Label(getValueFromPerPath(permissionMap, permissionDefItem.getKey())), permissionDefItem.getCaption(), 0, i); } return component; }