List of usage examples for com.vaadin.ui CssLayout CssLayout
public CssLayout()
From source file:com.mycollab.module.project.view.user.UserUnresolvedAssignmentWidget.java
License:Open Source License
public UserUnresolvedAssignmentWidget() { super("", new CssLayout()); this.setWidth("100%"); final CheckBox myItemsSelection = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS)); myItemsSelection.addValueChangeListener(valueChangeEvent -> { boolean isMyItemsOption = myItemsSelection.getValue(); if (searchCriteria != null) { if (isMyItemsOption) { searchCriteria.setAssignUser(StringSearchField.and(UserUIContext.getUsername())); } else { searchCriteria.setAssignUser(null); }/*from w w w.ja va 2 s. c om*/ updateSearchResult(); } }); taskList = new DefaultBeanPagedList<ProjectTicketService, ProjectTicketSearchCriteria, ProjectTicket>( AppContextUtil.getSpringBean(ProjectTicketService.class), new TicketRowDisplayHandler(), 10) { @Override protected String stringWhenEmptyList() { return UserUIContext.getMessage(ProjectI18nEnum.OPT_NO_TICKET); } }; this.addHeaderElement(myItemsSelection); this.bodyContent.addComponent(taskList); }
From source file:com.mycollab.module.project.view.user.UserUnresolvedTicketWidget.java
License:Open Source License
public UserUnresolvedTicketWidget() { super("", new CssLayout()); this.setWidth("100%"); final CheckBox myItemsSelection = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS)); myItemsSelection.addValueChangeListener(valueChangeEvent -> { boolean isMyItemsOption = myItemsSelection.getValue(); if (searchCriteria != null) { if (isMyItemsOption) { searchCriteria.setAssignUser(StringSearchField.and(UserUIContext.getUsername())); } else { searchCriteria.setAssignUser(null); }/*from w w w . j ava 2 s.c o m*/ updateSearchResult(); } }); ticketList = new DefaultBeanPagedList<ProjectTicketService, ProjectTicketSearchCriteria, ProjectTicket>( AppContextUtil.getSpringBean(ProjectTicketService.class), new TicketRowDisplayHandler(), 10) { @Override protected String stringWhenEmptyList() { return UserUIContext.getMessage(ProjectI18nEnum.OPT_NO_TICKET); } }; this.addHeaderElement(myItemsSelection); this.bodyContent.addComponent(ticketList); }
From source file:com.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 a2 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 = 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();// w w w . ja v a2 s . c o 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.UserListViewImpl.java
License:Open Source License
public UserListViewImpl() { super();/*from w w w .ja v a 2s.co m*/ this.setMargin(new MarginInfo(false, true, false, true)); MHorizontalLayout header = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false)) .withFullWidth(); MButton createBtn = new MButton(UserUIContext.getMessage(UserI18nEnum.NEW), clickEvent -> EventBusFactory.getInstance().post(new UserEvent.GotoAdd(this, null))) .withIcon(FontAwesome.PLUS).withStyleName(WebThemes.BUTTON_ACTION) .withVisible(UserUIContext.canWrite(RolePermissionCollections.ACCOUNT_USER)); headerText = HeaderWithFontAwesome.h2(FontAwesome.USERS, UserUIContext.getMessage(UserI18nEnum.LIST) + " " + UserUIContext.getMessage(GenericI18Enum.OPT_TOTAL_VALUE, 0)); final MButton sortBtn = new MButton().withIcon(FontAwesome.SORT_ALPHA_ASC) .withStyleName(WebThemes.BUTTON_ICON_ONLY); sortBtn.addClickListener(clickEvent -> { sortAsc = !sortAsc; if (sortAsc) { sortBtn.setIcon(FontAwesome.SORT_ALPHA_ASC); displayUsers(); } else { sortBtn.setIcon(FontAwesome.SORT_ALPHA_DESC); displayUsers(); } }); header.addComponent(sortBtn); final SearchTextField searchTextField = new SearchTextField() { @Override public void doSearch(String value) { searchCriteria.setDisplayName(StringSearchField.and(value)); displayUsers(); } @Override public void emptySearch() { searchCriteria.setDisplayName(null); displayUsers(); } }; searchTextField.addStyleName(ValoTheme.TEXTFIELD_SMALL); MButton printBtn = new MButton("", clickEvent -> UI.getCurrent() .addWindow(new UserCustomizeReportOutputWindow(new LazyValueInjector() { @Override protected Object doEval() { return searchCriteria; } }))).withIcon(FontAwesome.PRINT).withStyleName(WebThemes.BUTTON_OPTION) .withDescription(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT)); header.with(headerText, sortBtn, searchTextField, printBtn, createBtn).alignAll(Alignment.MIDDLE_LEFT) .expand(headerText); this.addComponent(header); contentLayout = new CssLayout(); contentLayout.setWidth("100%"); this.addComponent(contentLayout); }
From source file:com.mycollab.module.user.accountsettings.team.view.UserReadViewImpl.java
License:Open Source License
private void displayUserAvatar() { header.removeAllComponents();//w w w. j a v a 2 s . c o 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 {//from w w w .j a va 2 s.co 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(); 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.ui.chart.PieChartWrapper.java
License:Open Source License
@Override protected final ComponentContainer createLegendBox() { final CssLayout mainLayout = new CssLayout(); mainLayout.addStyleName("legendBoxContent"); mainLayout.setSizeUndefined();/* ww w .ja v a2 s . c o m*/ final List keys = pieDataSet.getKeys(); for (int i = 0; i < keys.size(); i++) { MHorizontalLayout layout = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true)) .withStyleName("inline-block").withWidthUndefined(); layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); final Comparable key = (Comparable) keys.get(i); int colorIndex = i % CHART_COLOR_STR.size(); final String color = "<div style = \" width:13px;height:13px;background: #" + CHART_COLOR_STR.get(colorIndex) + "\" />"; final ELabel lblCircle = ELabel.html(color); String btnCaption; if (enumKeyCls == null) { if (key instanceof Key) { btnCaption = String.format("%s (%d)", StringUtils.trim(((Key) key).getDisplayName(), 20, true), pieDataSet.getValue(key).intValue()); } else { btnCaption = String.format("%s (%d)", key, pieDataSet.getValue(key).intValue()); } } else { btnCaption = String.format("%s(%d)", UserUIContext.getMessage(enumKeyCls, key.toString()), pieDataSet.getValue(key).intValue()); } MButton btnLink = new MButton(StringUtils.trim(btnCaption, 25, true), clickEvent -> { if (key instanceof Key) { clickLegendItem(((Key) key).getKey()); } else { clickLegendItem(key.toString()); } }).withStyleName(WebThemes.BUTTON_LINK).withDescription(btnCaption); layout.with(lblCircle, btnLink); mainLayout.addComponent(layout); } mainLayout.setWidth("100%"); return mainLayout; }
From source file:com.mycollab.vaadin.mvp.AbstractSingleContainerPageView.java
License:Open Source License
public AbstractSingleContainerPageView() { contentLayout = new CssLayout(); contentLayout.setSizeFull(); setCompositionRoot(contentLayout); setSizeFull(); }
From source file:com.mycollab.vaadin.ui.BeanList.java
License:Open Source License
public BeanList(SearchService searchService, IBeanList.RowDisplayHandler<T> rowDisplayHandler) { this.searchService = searchService; this.rowDisplayHandler = rowDisplayHandler; this.contentLayout = new CssLayout(); this.contentLayout.setWidth("100%"); this.setCompositionRoot(this.contentLayout); this.setStyleName("bean-list"); }