List of usage examples for com.vaadin.ui CssLayout CssLayout
public CssLayout()
From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.RoleListViewImpl.java
License:Open Source License
private ComponentContainer constructTableActionControls() { final CssLayout layoutWrapper = new CssLayout(); layoutWrapper.setWidth("100%"); final HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true);/*from ww w . ja v a2 s . c om*/ layoutWrapper.addStyleName(UIConstants.TABLE_ACTION_CONTROLS); layoutWrapper.addComponent(layout); this.selectOptionButton = new SelectionOptionButton(this.tableItem); layout.addComponent(this.selectOptionButton); final Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE)); deleteBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.ACCOUNT_ROLE)); this.tableActionControls = new DefaultMassItemActionHandlersContainer(); if (AppContext.canAccess(RolePermissionCollections.ACCOUNT_ROLE)) { tableActionControls.addActionItem(MassItemActionHandler.DELETE_ACTION, FontAwesome.TRASH_O, "delete", AppContext.getMessage(GenericI18Enum.BUTTON_DELETE)); } tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_PDF_ACTION, FontAwesome.FILE_PDF_O, "export", "export.pdf", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_PDF)); tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_EXCEL_ACTION, FontAwesome.FILE_EXCEL_O, "export", "export.xlsx", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_EXCEL)); tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_CSV_ACTION, FontAwesome.FILE_TEXT_O, "export", "export.csv", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_CSV)); layout.addComponent(this.tableActionControls); layout.addComponent(this.selectedItemsNumberLabel); layout.setComponentAlignment(this.selectedItemsNumberLabel, Alignment.MIDDLE_CENTER); return layoutWrapper; }
From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserListViewImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from w w w . jav a2 s . c om*/ public void setSearchCriteria(UserSearchCriteria searchCriteria) { UserService userService = ApplicationContextUtil.getSpringBean(UserService.class); List<SimpleUser> userAccountList = userService .findPagableListByCriteria(new SearchRequest<>(searchCriteria, 0, Integer.MAX_VALUE)); this.removeAllComponents(); this.setSpacing(true); HorizontalLayout header = new HorizontalLayout(); header.setStyleName(UIConstants.HEADER_VIEW); header.setWidth("100%"); header.setMargin(new MarginInfo(true, false, true, false)); Button createBtn = new Button("Invite user", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance().post(new UserEvent.GotoAdd(this, null)); } }); createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.ACCOUNT_USER)); createBtn.setStyleName(UIConstants.THEME_GREEN_LINK); createBtn.setIcon(FontAwesome.PLUS); header.addComponent(createBtn); header.setComponentAlignment(createBtn, Alignment.MIDDLE_RIGHT); this.addComponent(header); CssLayout contentLayout = new CssLayout(); contentLayout.setWidth("100%"); for (SimpleUser userAccount : userAccountList) { contentLayout.addComponent(generateMemberBlock(userAccount)); } this.addComponent(contentLayout); }
From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserListViewImpl.java
License:Open Source License
private Component generateMemberBlock(final SimpleUser member) { CssLayout memberBlock = new CssLayout(); memberBlock.addStyleName("member-block"); VerticalLayout blockContent = new VerticalLayout(); HorizontalLayout blockTop = new HorizontalLayout(); blockTop.setSpacing(true);/* ww w . j a va 2 s .c o m*/ Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getAvatarid(), 100); blockTop.addComponent(memberAvatar); VerticalLayout memberInfo = new VerticalLayout(); HorizontalLayout layoutButtonDelete = new HorizontalLayout(); layoutButtonDelete.setVisible(AppContext.canWrite(RolePermissionCollections.ACCOUNT_USER)); layoutButtonDelete.setWidth("100%"); Label emptylb = new Label(""); layoutButtonDelete.addComponent(emptylb); layoutButtonDelete.setExpandRatio(emptylb, 1.0f); Button deleteBtn = new Button(); deleteBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { UserService userService = ApplicationContextUtil .getSpringBean(UserService.class); userService.pendingUserAccounts(Arrays.asList(member.getUsername()), AppContext.getAccountId()); EventBusFactory.getInstance() .post(new UserEvent.GotoList(UserListViewImpl.this, null)); } } }); } }); deleteBtn.setIcon(FontAwesome.TRASH_O); deleteBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY); layoutButtonDelete.addComponent(deleteBtn); memberInfo.addComponent(layoutButtonDelete); ButtonLink userAccountLink = new ButtonLink(member.getDisplayName()); userAccountLink.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new UserEvent.GotoRead(UserListViewImpl.this, member.getUsername())); } }); userAccountLink.setWidth("100%"); userAccountLink.setHeight("100%"); memberInfo.addComponent(userAccountLink); Label memberEmailLabel = new Label( "<a href='mailto:" + member.getUsername() + "'>" + member.getUsername() + "</a>", ContentMode.HTML); memberEmailLabel.addStyleName("member-email"); memberEmailLabel.setWidth("100%"); memberInfo.addComponent(memberEmailLabel); Label memberSinceLabel = new Label("Member since: " + AppContext.formatDate(member.getRegisteredtime())); memberSinceLabel.addStyleName("member-email"); memberSinceLabel.setWidth("100%"); memberInfo.addComponent(memberSinceLabel); if (RegisterStatusConstants.SENT_VERIFICATION_EMAIL.equals(member.getRegisterstatus())) { final VerticalLayout waitingNotLayout = new VerticalLayout(); Label infoStatus = new Label("Waiting for accept invitation"); infoStatus.addStyleName("member-email"); waitingNotLayout.addComponent(infoStatus); ButtonLink resendInvitationLink = new ButtonLink("Resend Invitation", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { UserService userService = ApplicationContextUtil.getSpringBean(UserService.class); userService.updateUserAccountStatus(member.getUsername(), member.getAccountId(), RegisterStatusConstants.VERIFICATING); waitingNotLayout.removeAllComponents(); Label statusEmail = new Label("Sending invitation email"); statusEmail.addStyleName("member-email"); waitingNotLayout.addComponent(statusEmail); } }); resendInvitationLink.setStyleName("link"); resendInvitationLink.addStyleName("member-email"); waitingNotLayout.addComponent(resendInvitationLink); memberInfo.addComponent(waitingNotLayout); } else if (RegisterStatusConstants.ACTIVE.equals(member.getRegisterstatus())) { Label lastAccessTimeLbl = new Label("Logged in " + DateTimeUtils.getPrettyDateValue(member.getLastaccessedtime(), AppContext.getUserLocale())); lastAccessTimeLbl.addStyleName("member-email"); memberInfo.addComponent(lastAccessTimeLbl); } else if (RegisterStatusConstants.VERIFICATING.equals(member.getRegisterstatus())) { Label infoStatus = new Label("Sending invitation email"); infoStatus.addStyleName("member-email"); memberInfo.addComponent(infoStatus); } blockTop.addComponent(memberInfo); blockTop.setExpandRatio(memberInfo, 1.0f); blockTop.setWidth("100%"); blockContent.addComponent(blockTop); if (member.getRoleid() != null) { String memberRoleLinkPrefix = "<a href=\"" + AccountLinkBuilder.generatePreviewFullRoleLink(member.getRoleid()) + "\""; Label memberRole = new Label(); memberRole.setContentMode(ContentMode.HTML); if (member.getIsAccountOwner() != null && member.getIsAccountOwner()) { memberRole.setValue(memberRoleLinkPrefix + "style=\"color: #B00000;\">" + "Account Owner" + "</a>"); } else { memberRole.setValue(memberRoleLinkPrefix + "style=\"color:gray;font-size:12px;\">" + member.getRoleName() + "</a>"); } memberRole.setSizeUndefined(); blockContent.addComponent(memberRole); blockContent.setComponentAlignment(memberRole, Alignment.MIDDLE_RIGHT); } else if (member.getIsAccountOwner() != null && member.getIsAccountOwner() == Boolean.TRUE) { Label memberRole = new Label(); memberRole.setContentMode(ContentMode.HTML); memberRole.setValue("<a style=\"color: #B00000;\">" + "Account Owner" + "</a>"); memberRole.setSizeUndefined(); blockContent.addComponent(memberRole); blockContent.setComponentAlignment(memberRole, Alignment.MIDDLE_RIGHT); } else { Label lbl = new Label(); lbl.setHeight("10px"); blockContent.addComponent(lbl); } blockContent.setWidth("100%"); memberBlock.addComponent(blockContent); return memberBlock; }
From source file:com.esofthead.mycollab.module.user.ui.components.ImagePreviewCropWindow.java
License:Open Source License
public ImagePreviewCropWindow(final ImageSelectionCommand imageSelectionCommand, final byte[] imageData) { super("Preview and modify image"); setModal(true);/*from w ww . j av a 2 s . c om*/ setResizable(false); setWidth("700px"); center(); MVerticalLayout content = new MVerticalLayout(); setContent(content); try { originalImage = ImageIO.read(new ByteArrayInputStream(imageData)); } catch (IOException e) { throw new UserInvalidInputException("Invalid image type"); } originalImage = ImageUtil.scaleImage(originalImage, 650, 650); MHorizontalLayout previewBox = new MHorizontalLayout().withSpacing(true) .withMargin(new MarginInfo(false, true, true, false)).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)); Label lbPreview = new Label("<p style='margin: 0px;'><strong>To the bottom is what your profile photo will " + "look like.</strong></p>" + "<p style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. " + "When you are happy with your photo, click the “Accept“ button.</p>", ContentMode.HTML); previewBoxTitle.addComponent(lbPreview); MHorizontalLayout controlBtns = new MHorizontalLayout(); controlBtns.setSizeUndefined(); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { close(); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); Button acceptBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { 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); } } } }); acceptBtn.setStyleName(UIConstants.BUTTON_ACTION); acceptBtn.setIcon(FontAwesome.CHECK); controlBtns.with(acceptBtn, cancelBtn).alignAll(Alignment.MIDDLE_LEFT); 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(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { VCropSelection newSelection = (VCropSelection) event.getProperty().getValue(); int x1 = newSelection.getXTopLeft(); int y1 = newSelection.getYTopLeft(); int x2 = newSelection.getXBottomRight(); int y2 = newSelection.getYBottomRight(); if (x2 > x1 && y2 > y1) { BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1)); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); try { ImageIO.write(subImage, "png", outStream); scaleImageData = outStream.toByteArray(); displayPreviewImage(); } catch (IOException e) { LOG.error("Error while scale image: ", e); } } } }); currentPhotoBox.setWidth("520px"); currentPhotoBox.setHeight("470px"); currentPhotoBox.addComponent(cropField); cropBox.addComponent(currentPhotoBox); content.with(previewBox, ELabel.hr(), cropBox); displayPreviewImage(); }
From source file:com.esofthead.mycollab.shell.view.MainView.java
License:Open Source License
public void initialize() { this.removeAllComponents(); this.addComponent(this.createTopMenu()); this.bodyLayout = new CssLayout(); this.bodyLayout.addStyleName("main-body"); this.bodyLayout.setId("main-body"); this.bodyLayout.setWidth("100%"); this.bodyLayout.setHeight("100%"); this.addComponent(this.bodyLayout); this.setExpandRatio(this.bodyLayout, 1.0f); this.addComponent(this.createFooter()); ThemeManager.loadUserTheme(AppContext.getAccountId()); }
From source file:com.esofthead.mycollab.ui.chart.GenericChartWrapper.java
License:Open Source License
final protected void displayChart() { removeAllComponents();/*ww w . jav a 2 s. c o m*/ final JFreeChart chart = createChart(); final JFreeChartWrapper chartWrapper = new JFreeChartWrapper(chart); final CssLayout borderWrap = new CssLayout(); borderWrap.addComponent(chartWrapper); borderWrap.setStyleName("chart-wrapper"); borderWrap.setHeight(height + "px"); borderWrap.setWidth(width + "px"); chartWrapper.setHeight(height + "px"); chartWrapper.setWidth(width + "px"); chartWrapper.setGraphHeight(height); chartWrapper.setGraphWidth(width); this.addComponent(borderWrap); final Component legendBox = createLegendBox(); if (legendBox != null) { this.addComponent(legendBox); } }
From source file:com.esofthead.mycollab.ui.chart.PieChartWrapper.java
License:Open Source License
@Override protected final ComponentContainer createLegendBox() { final CssLayout mainLayout = new CssLayout(); mainLayout.addStyleName("legendBoxContent"); mainLayout.setSizeUndefined();//from w ww . ja v a 2s .co 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)); layout.addStyleName("inline-block"); layout.setSizeUndefined(); 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 Label lblCircle = new Label(color); lblCircle.setContentMode(ContentMode.HTML); 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)", AppContext.getMessage(enumKeyCls, key.toString()), pieDataSet.getValue(key).intValue()); } final Button btnLink = new Button(StringUtils.trim(btnCaption, 25, true), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (key instanceof Key) { clickLegendItem(((Key) key).getKey()); } else { clickLegendItem(key.toString()); } } }); btnLink.setDescription(btnCaption); btnLink.addStyleName(UIConstants.BUTTON_LINK); layout.with(lblCircle, btnLink); mainLayout.addComponent(layout); } mainLayout.setWidth("100%"); return mainLayout; }
From source file:com.esofthead.mycollab.vaadin.mvp.AbstractCssPageView.java
License:Open Source License
public void updateVerticalTabsheetFixStatus() { if (vTabsheetFix == null) { vTabsheetFix = new CssLayout(); vTabsheetFix.setStyleName("verticaltabsheet-fix"); this.addComponentAsFirst(vTabsheetFix); } else if (vTabsheetFix.getParent() != this) { this.addComponentAsFirst(vTabsheetFix); }/*from w ww. j av a2s .c o m*/ vTabsheetFix.setWidth(this.vTabsheetFixWidth); if (this.vTabsheetIsLeft) vTabsheetFix.addStyleName("is-left"); else vTabsheetFix.removeStyleName("is-left"); }
From source file:com.esofthead.mycollab.vaadin.ui.AbstractBeanBlockList.java
License:Open Source License
public AbstractBeanBlockList(final int defaultNumberSearchItems) { this.defaultNumberSearchItems = defaultNumberSearchItems; this.setSpacing(true); itemContainer = new CssLayout(); Component topControls = generateTopControls(); if (topControls != null) { this.addComponent(topControls); }/*w ww .j a va 2s .c o m*/ this.addComponent(itemContainer); }
From source file:com.esofthead.mycollab.vaadin.ui.AbstractBeanBlockList.java
License:Open Source License
protected CssLayout createPageControls() { this.controlBarWrapper = new CssLayout(); this.controlBarWrapper.setWidth("100%"); final HorizontalLayout controlBar = new HorizontalLayout(); controlBar.setWidth("100%"); this.controlBarWrapper.addComponent(controlBar); this.pageManagement = new HorizontalLayout(); // defined layout here --------------------------- if (this.currentPage > 1) { final Button firstLink = new ButtonLink("1", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override/*from w w w . jav a2s .co m*/ public void buttonClick(final ClickEvent event) { AbstractBeanBlockList.this.pageChange(1); } }, false); firstLink.addStyleName("buttonPaging"); this.pageManagement.addComponent(firstLink); } if (this.currentPage >= 5) { final Label ss1 = new Label("..."); ss1.addStyleName("buttonPaging"); this.pageManagement.addComponent(ss1); } if (this.currentPage > 3) { final Button previous2 = new ButtonLink("" + (this.currentPage - 2), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractBeanBlockList.this.pageChange(AbstractBeanBlockList.this.currentPage - 2); } }, false); previous2.addStyleName("buttonPaging"); this.pageManagement.addComponent(previous2); } if (this.currentPage > 2) { final Button previous1 = new ButtonLink("" + (this.currentPage - 1), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractBeanBlockList.this.pageChange(AbstractBeanBlockList.this.currentPage - 1); } }, false); previous1.addStyleName("buttonPaging"); this.pageManagement.addComponent(previous1); } // Here add current ButtonLink final Button current = new ButtonLink("" + this.currentPage, new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractBeanBlockList.this.pageChange(AbstractBeanBlockList.this.currentPage); } }, false); current.addStyleName("buttonPaging"); current.addStyleName("buttonPagingcurrent"); this.pageManagement.addComponent(current); final int range = this.totalPage - this.currentPage; if (range >= 1) { final Button next1 = new ButtonLink("" + (this.currentPage + 1), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractBeanBlockList.this.pageChange(AbstractBeanBlockList.this.currentPage + 1); } }, false); next1.addStyleName("buttonPaging"); this.pageManagement.addComponent(next1); } if (range >= 2) { final Button next2 = new ButtonLink("" + (this.currentPage + 2), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractBeanBlockList.this.pageChange(AbstractBeanBlockList.this.currentPage + 2); } }, false); next2.addStyleName("buttonPaging"); this.pageManagement.addComponent(next2); } if (range >= 4) { final Label ss2 = new Label("..."); ss2.addStyleName("buttonPaging"); this.pageManagement.addComponent(ss2); } if (range >= 3) { final Button last = new ButtonLink("" + this.totalPage, new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractBeanBlockList.this.pageChange(AbstractBeanBlockList.this.totalPage); } }, false); last.addStyleName("buttonPaging"); this.pageManagement.addComponent(last); } this.pageManagement.setWidth(null); this.pageManagement.setSpacing(true); controlBar.addComponent(this.pageManagement); controlBar.setComponentAlignment(this.pageManagement, Alignment.MIDDLE_RIGHT); return this.controlBarWrapper; }