public HorizontalLayout createTopBar() { TextField filter = new TextField(); filter.setStyleName("filter-textfield"); filter.setInputPrompt("Filter"); ResetButtonForTextField.extend(filter); filter.setImmediate(true); filter.addTextChangeListener( new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { grid.setFilter(event.getText()); } }); newProduct = new Button("New product"); newProduct.addStyleName(ValoTheme.BUTTON_PRIMARY); newProduct.setIcon(FontAwesome.PLUS_CIRCLE); newProduct.addClickListener( new ClickListener() { @Override public void buttonClick(ClickEvent event) { viewLogic.newProduct(); } }); HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setSpacing(true); topLayout.setWidth("100%"); topLayout.addComponent(filter); topLayout.addComponent(newProduct); topLayout.setComponentAlignment(filter, Alignment.MIDDLE_LEFT); topLayout.setExpandRatio(filter, 1); topLayout.setStyleName("top-bar"); return topLayout; }
private void createBasicSearchLayout() { final HorizontalLayout basicSearchBody = new HorizontalLayout(); basicSearchBody.setStyleName("message-search"); basicSearchBody.setSizeUndefined(); basicSearchBody.setSpacing(false); final TextField nameField = new TextField(); nameField.addTextChangeListener( new TextChangeListener() { @Override public void textChange(final TextChangeEvent event) { MessageSearchPanel.this.messageSearchCriteria = new MessageSearchCriteria(); MessageSearchPanel.this.messageSearchCriteria.setProjectids( new SetSearchField<Integer>( SearchField.AND, MessageSearchPanel.this.project.getId())); MessageSearchPanel.this.textSearch = event.getText().toString().trim(); MessageSearchPanel.this.messageSearchCriteria.setMessage( new StringSearchField(MessageSearchPanel.this.textSearch)); MessageSearchPanel.this.notifySearchHandler( MessageSearchPanel.this.messageSearchCriteria); } }); nameField.setTextChangeEventMode(TextChangeEventMode.LAZY); nameField.setTextChangeTimeout(200); nameField.setWidth(UIConstants.DEFAULT_CONTROL_WIDTH); UiUtils.addComponent(basicSearchBody, nameField, Alignment.MIDDLE_LEFT); final Button searchBtn = new Button(); searchBtn.addClickListener( new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { MessageSearchPanel.this.messageSearchCriteria = new MessageSearchCriteria(); MessageSearchPanel.this.messageSearchCriteria.setProjectids( new SetSearchField<Integer>( SearchField.AND, MessageSearchPanel.this.project.getId())); MessageSearchPanel.this.messageSearchCriteria.setMessage( new StringSearchField(MessageSearchPanel.this.textSearch)); MessageSearchPanel.this.notifySearchHandler( MessageSearchPanel.this.messageSearchCriteria); } }); searchBtn.setStyleName("search-icon-button"); searchBtn.setIcon(MyCollabResource.newResource("icons/16/search_white.png")); basicSearchBody.addComponent(searchBtn); this.setCompositionRoot(basicSearchBody); }
private void initializedPerspectiveSwticherPanel(MPerspectiveStack perspectiveStack) { if (perspectiveSwitcherPanel != null) return; // initialize perspective switcher panel perspectiveStackForSwitcher = perspectiveStack; boolean iconsOnly = perspectiveStackForSwitcher.getTags().contains(Tags.ICONS_ONLY); perspectiveSwitcherPanel = new HorizontalLayout(); perspectiveSwitcherPanel.setStyleName("perspectivepanel"); perspectiveSwitcherPanel.setSizeUndefined(); Button openPerspectiveButton = new Button("Open"); openPerspectiveButton.addStyleName("vaaclipsebutton"); openPerspectiveButton.addStyleName("icononly"); openPerspectiveButton.setIcon( new ThemeResource("../vaaclipse_default_theme/img/open_perspective.png")); perspectiveSwitcherPanel.addComponent(openPerspectiveButton); openPerspectiveButton.addListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { openOpenPerspectiveWindow(); // change focus Component parent = event.getButton().getParent(); while (parent != null) { if (parent instanceof Component.Focusable) { ((Component.Focusable) parent).focus(); break; } else { parent = parent.getParent(); } } } }); // add separator between openPerspectiveButton and perspective's buttons Label separator = new Label(); separator.setSizeUndefined(); separator.addStyleName("horizontalseparator"); separator.setHeight("100%"); perspectiveSwitcherPanel.addComponent(separator); // add buttons to perspective switch panel for (final MPerspective perspective : perspectiveStackForSwitcher.getChildren()) { Component button = createPerspectiveButton(perspective); if (button != null) perspectiveSwitcherPanel.addComponent(button); } }
private Layout getLayout(String caption, Class<? extends Layout> layoutClass, String width) { Layout l; if (layoutClass == VerticalLayout.class) { if (verticalLayout == null) { verticalLayout = new VerticalLayout(); verticalLayout.setStyleName("borders"); } l = verticalLayout; } else if (layoutClass == HorizontalLayout.class) { if (horizontalLayout == null) { horizontalLayout = new HorizontalLayout(); horizontalLayout.setStyleName("borders"); } l = horizontalLayout; } else if (layoutClass == GridLayout.class) { if (gridLayout == null) { gridLayout = new GridLayout(); gridLayout.setStyleName("borders"); } l = gridLayout; } else if (layoutClass == CssLayout.class) { if (cssLayout == null) { cssLayout = new CssLayout(); cssLayout.setStyleName("borders"); } l = cssLayout; } else if (layoutClass == FormLayout.class) { if (formLayout == null) { formLayout = new FormLayout(); formLayout.setStyleName("borders"); } l = formLayout; } else { return null; } l.setCaption(caption); if (width.equals("auto")) { width = null; } l.setWidth(width); // addComponent(l); return l; }
// 构造函数 public ComplainTypeListView(ComplainTypeManager complainTypeManager) { // ------------------------------------------加载dao this.complainTypeManager = complainTypeManager; // -------------------------------------------标题部分 HorizontalLayout navBar = new HorizontalLayout(); navBar.setStyleName(Reindeer.LAYOUT_BLACK); navBar.setWidth(100, Unit.PERCENTAGE); navBar.setHeight(29, Unit.PIXELS); Label lblNav = new Label("CRM系统 / 诉求类别"); Button btnAdd = new Button("新增"); // 增加 按钮 btnAdd.setIcon(new ThemeResource("icons/16/add.png")); btnAdd.setDescription("增加类别"); btnAdd.addClickListener( new Button.ClickListener() { @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { createWindow(null); } }); navBar.addComponent(lblNav); navBar.addComponent(btnAdd); navBar.setComponentAlignment(btnAdd, Alignment.TOP_RIGHT); // 定义位置 // -------------------------------------------正文部分 conentHSplit = new HorizontalSplitPanel(); conentHSplit.setStyleName(Reindeer.LAYOUT_WHITE); // 右侧样式 conentHSplit.setHeight(Constants.PAGE_HEIGHT, Unit.PIXELS); // -----------------------------------------左边 tree initTree(); conentHSplit.setFirstComponent(leftTree); conentHSplit.setSecondComponent(rightTable); conentHSplit.setSplitPosition(15F); // -----------------------------------------右边 table 使用 container = new BeanItemContainer<ComplainTypeDtilBean>(ComplainTypeDtilBean.class); initRightTable(rightTable, container); this.addComponent(navBar); this.addComponent(conentHSplit); }
@AutoGenerated private HorizontalLayout buildPnlPrincipal() { // common part: create layout pnlPrincipal = new HorizontalLayout(); pnlPrincipal.setStyleName("whiteBackGround"); pnlPrincipal.setImmediate(false); pnlPrincipal.setWidth("-1px"); pnlPrincipal.setHeight("-1px"); pnlPrincipal.setMargin(true); pnlPrincipal.setSpacing(true); // verticalLayout_2 verticalLayout_2 = buildVerticalLayout_2(); pnlPrincipal.addComponent(verticalLayout_2); // verticalLayout_3 verticalLayout_3 = buildVerticalLayout_3(); pnlPrincipal.addComponent(verticalLayout_3); return pnlPrincipal; }
private Layout createBottomPanel() { final HorizontalLayout controlPanel = new HorizontalLayout(); controlPanel.setMargin(true); controlPanel.setStyleName("more-info"); controlPanel.setHeight("40px"); controlPanel.setWidth("100%"); Button moreInfoBtn = new Button( "More information...", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { editUserForm.displayAdvancedForm(user); } }); moreInfoBtn.addStyleName(UIConstants.THEME_LINK); controlPanel.addComponent(moreInfoBtn); controlPanel.setComponentAlignment(moreInfoBtn, Alignment.MIDDLE_LEFT); return controlPanel; }
/** * Constructor, passing the Vaadin application page * * @param ui MainUI application page */ public HeaderComponent(MainUI ui) { setHeight("50px"); setStyleName("header"); final HorizontalLayout bannerArea = new HorizontalLayout(); bannerArea.setStyleName("menuArea"); bannerArea.setSizeFull(); final ThemeResource resource = new ThemeResource("img/intec-logo.gif.png"); final Image bannerImg = new Image(); bannerImg.setAlternateText("Intec"); bannerImg.setHeight("50px"); bannerImg.setDescription("Intec Logo"); bannerImg.setSource(resource); bannerImg.setWidth(null); bannerImg.setStyleName("bannerImg"); setMenubar(new MenuBar()); getMenubar().setStyleName(ValoTheme.MENU_SUBTITLE); getMenubar().addStyleName("valo-menu-subtitle-indent"); getMenubar().setWidth(100, Unit.PERCENTAGE); if (!"Anonymous".equals(getUserName())) { final MenuItem logout = menubar.addItem("Logout", null); logout.setStyleName("menuRight"); } final MenuItem userItem = menubar.addItem(getUserName(), null); userItem.setStyleName("menuRight"); bannerArea.addComponents(bannerImg, menubar); bannerArea.setExpandRatio(menubar, 1); addComponent(bannerArea); setExpandRatio(bannerArea, 1); setSizeFull(); }
private void initUI() { addStyleName(Reindeer.WINDOW_LIGHT); setModal(true); setHeight("90%"); setWidth("60%"); center(); HorizontalLayout bottom = new HorizontalLayout(); bottom.setStyleName(ExplorerLayout.THEME); bottom.setSizeFull(); // bottom.setMargin(true); bottom.setSpacing(true); bottom.addStyleName(Runo.LAYOUT_DARKER); this.setContent(bottom); scheduleEventFieldGroup = new FieldGroup(); scheduleEventFieldGroup.setBuffered(true); if (currentBeanItem != null) { scheduleEventFieldGroup.setItemDataSource(currentBeanItem); } line = new GridLayout(4, 20); line.addStyleName("v-gridlayout"); line.setWidth("100%"); line.setSpacing(true); line.setMargin(true); final Label lbTitle = CommonFieldHandler.createLable("计划名称:"); line.addComponent(lbTitle); line.setComponentAlignment(lbTitle, Alignment.MIDDLE_RIGHT); final TextField txtTitle = new TextField(); txtTitle.setWidth("80%"); scheduleEventFieldGroup.bind(txtTitle, "name"); line.addComponent(txtTitle, 1, 0, 3, 0); line.setComponentAlignment(txtTitle, Alignment.MIDDLE_LEFT); Label label2 = CommonFieldHandler.createLable("开始时间:"); line.addComponent(label2, 0, 1, 0, 1); line.setComponentAlignment(label2, Alignment.MIDDLE_RIGHT); // 创建一个时间后台变化的listener BlurListener startTimeListener = createTimeReCountListener(); DateField startDateField = CommonFieldHandler.createDateField("", false); scheduleEventFieldGroup.bind(startDateField, "startDate"); startDateField.addBlurListener(startTimeListener); line.addComponent(startDateField, 1, 1, 1, 1); line.setComponentAlignment(startDateField, Alignment.MIDDLE_LEFT); Label label3 = CommonFieldHandler.createLable("估算时间:"); line.addComponent(label3, 2, 1, 2, 1); line.setComponentAlignment(label3, Alignment.MIDDLE_RIGHT); HorizontalLayout hlay = new HorizontalLayout(); final TextField estimateField = new TextField(); estimateField.setValue("1"); estimateField.setWidth("60px"); estimateField.setNullSettingAllowed(false); BlurListener timeReCountListener = createTimeReCountListener(); estimateField.addBlurListener(timeReCountListener); scheduleEventFieldGroup.bind(estimateField, "estimate"); hlay.addComponent(estimateField); Map<Object, String> data = new HashMap(); data.put(0, "天"); data.put(1, "时"); data.put(2, "分"); // WW_TODO 估算时间单位 ComboBox unit_cb = createComboBox(data, "55px"); scheduleEventFieldGroup.bind(unit_cb, "estimateUnit"); hlay.addComponent(unit_cb); line.addComponent(hlay, 3, 1, 3, 1); line.setComponentAlignment(hlay, Alignment.MIDDLE_LEFT); Label label4 = CommonFieldHandler.createLable("到期时间:"); line.addComponent(label4, 0, 2, 0, 2); line.setComponentAlignment(label4, Alignment.MIDDLE_RIGHT); completionDateField = CommonFieldHandler.createDateField("", false); line.addComponent(completionDateField, 1, 2, 1, 2); line.setComponentAlignment(completionDateField, Alignment.MIDDLE_LEFT); scheduleEventFieldGroup.bind(completionDateField, "completionDate"); // line.setExpandRatio(completionDateField, 1.0f); Label label6 = CommonFieldHandler.createLable("消耗时间:"); line.addComponent(label6, 2, 2, 2, 2); line.setComponentAlignment(label6, Alignment.MIDDLE_RIGHT); TextField gs1 = new TextField(); gs1.setValue("20%"); gs1.setInputPrompt("50%"); scheduleEventFieldGroup.bind(gs1, "useup"); line.addComponent(gs1, 3, 2, 3, 2); line.setComponentAlignment(gs1, Alignment.MIDDLE_LEFT); Label label5 = CommonFieldHandler.createLable("优先级:"); // label.setWidth("80px"); line.addComponent(label5, 0, 3, 0, 3); line.setComponentAlignment(label5, Alignment.MIDDLE_RIGHT); Map<Object, String> dtp = new HashMap(); dtp.put(0, "底"); dtp.put(1, "中"); dtp.put(2, "高"); ComboBox selectPriority = createComboBox(dtp, "100px"); // NativeSelect select = new NativeSelect(); // select.addItem("无"); // select.addItem("0(最低)"); // String itemId = "1(中)"; // select.addItem(itemId); // select.addItem("2(高)"); selectPriority.setNullSelectionAllowed(false); selectPriority.select(2); scheduleEventFieldGroup.bind(selectPriority, "priority"); line.addComponent(selectPriority, 1, 3, 1, 3); line.setComponentAlignment(selectPriority, Alignment.MIDDLE_LEFT); Label label1 = CommonFieldHandler.createLable("完成百分比:"); line.addComponent(label1, 2, 3, 2, 3); line.setComponentAlignment(label1, Alignment.MIDDLE_RIGHT); TextField tf = new TextField(); tf.setInputPrompt("50%"); line.addComponent(tf, 3, 3, 3, 3); line.setComponentAlignment(tf, Alignment.MIDDLE_LEFT); Label label7 = CommonFieldHandler.createLable("关联日程:"); line.addComponent(label7, 0, 4, 0, 4); line.setComponentAlignment(label7, Alignment.MIDDLE_RIGHT); CheckBox relatedCalendar_cb = new CheckBox(); relatedCalendar_cb.setValue(false); line.addComponent(relatedCalendar_cb, 1, 4, 1, 4); line.setComponentAlignment(relatedCalendar_cb, Alignment.MIDDLE_LEFT); scheduleEventFieldGroup.bind(relatedCalendar_cb, "relatedCalendar"); Label lbStatus = CommonFieldHandler.createLable("计划状态:"); lbStatus.setWidth("20px"); line.addComponent(lbStatus, 2, 4, 2, 4); line.setComponentAlignment(lbStatus, Alignment.MIDDLE_RIGHT); Map<Object, String> sta = new HashMap(); sta.put(0, "新建"); sta.put(1, "完成"); sta.put(2, "关闭"); sta.put(3, "取消"); ComboBox sectStatus = createComboBox(sta, "100px"); sectStatus.setNullSelectionAllowed(false); scheduleEventFieldGroup.bind(sectStatus, "status"); line.addComponent(sectStatus, 3, 4, 3, 4); line.setComponentAlignment(sectStatus, Alignment.MIDDLE_LEFT); Label label8 = CommonFieldHandler.createLable("关联外部任务:"); label8.setWidth("20px"); line.addComponent(label8, 0, 5, 0, 5); line.setComponentAlignment(label8, Alignment.MIDDLE_RIGHT); CheckBox cb = new CheckBox(); cb.setValue(true); line.addComponent(cb, 1, 5, 1, 5); line.setComponentAlignment(cb, Alignment.MIDDLE_LEFT); scheduleEventFieldGroup.bind(cb, "relatedTask"); Label label9 = CommonFieldHandler.createLable("外部任务类型:"); label9.setWidth("20px"); line.addComponent(label9, 2, 5, 2, 5); line.setComponentAlignment(label9, Alignment.MIDDLE_RIGHT); Map<Object, String> oat = new HashMap(); oat.put(0, "外包任务"); oat.put(1, "外包任务-类型2"); ComboBox select2 = createComboBox(oat, "150px"); // NativeSelect select2 = new NativeSelect(); // select2.addItem("外包任务"); // select2.addItem("外包任务-类型2"); select2.setNullSelectionAllowed(false); scheduleEventFieldGroup.bind(select2, "type"); line.addComponent(select2, 3, 5, 3, 5); line.setComponentAlignment(select2, Alignment.MIDDLE_LEFT); // select2.select("Timed"); Label lbOwnGrp = CommonFieldHandler.createLable("计划分配团队:"); lbOwnGrp.setWidth("20px"); line.addComponent(lbOwnGrp, 0, 6, 0, 6); line.setComponentAlignment(lbOwnGrp, Alignment.MIDDLE_RIGHT); // NativeSelect sectOwnGrp = new NativeSelect(); Map<Object, String> groupsMap = teamService.queryTeamOfUser(LoginHandler.getLoggedInUser().getId()); groupsMap.put("", "请选择"); ComboBox sectOwnGrp = createComboBox(groupsMap, "150px"); // for (String p : groupsMap.keySet()) { // String title = groupsMap.get(p); // sectOwnGrp.addItem(p); // sectOwnGrp.setItemCaption(p, title); // } sectOwnGrp.setNullSelectionAllowed(false); ValueChangeListener valueChangeListener = createValueChangeListener(); sectOwnGrp.addValueChangeListener(valueChangeListener); sectOwnGrp.setImmediate(true); scheduleEventFieldGroup.bind(sectOwnGrp, "assignedTeam"); line.addComponent(sectOwnGrp, 1, 6, 1, 6); line.setComponentAlignment(sectOwnGrp, Alignment.MIDDLE_LEFT); final Label lbOwner = CommonFieldHandler.createLable("计划分配用户:"); lbOwner.setWidth("20px"); line.addComponent(lbOwner, 2, 6, 2, 6); line.setComponentAlignment(lbOwner, Alignment.MIDDLE_RIGHT); // sectOwner = new NativeSelect(); // sectOwner.addItem("请选择"); sectOwner.setNullSelectionAllowed(false); scheduleEventFieldGroup.bind(sectOwner, "assignedUser"); line.addComponent(sectOwner, 3, 6, 3, 6); line.setComponentAlignment(sectOwner, Alignment.MIDDLE_LEFT); final Label lbDesc = CommonFieldHandler.createLable("计划描述:"); lbDesc.setWidth("15px"); line.addComponent(lbDesc, 0, 7, 0, 7); line.setComponentAlignment(lbDesc, Alignment.MIDDLE_RIGHT); final TextArea taDesc = CommonFieldHandler.createTextArea(""); taDesc.setWidth("85%"); taDesc.setHeight("290px"); scheduleEventFieldGroup.bind(taDesc, "description"); line.addComponent(taDesc, 1, 7, 3, 13); line.setComponentAlignment(taDesc, Alignment.MIDDLE_LEFT); // CKEditorConfig config = new CKEditorConfig(); final Button updateSave = new Button("保存"); updateSave.addClickListener( new ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { // WW_TODO 修改保存到数据库 Todo fieldGroupTodo = saveFieldGroupToDB(); fireEvent( new SubmitEvent( updateSave, SubmitEvent.SUBMITTED, scheduleEventFieldGroup.getItemDataSource())); // close popup window close(); /* * Todo fieldGroupTodo = saveFieldGroupToDB(); //reflash current * Item copyBeanValueToContainer(hContainer,(BeanItem<Todo>)( * scheduleEventFieldGroup.getItemDataSource())); //刷新日历 * main.refreshCalendarView(); Notification.show("保存成功", * Notification.Type.HUMANIZED_MESSAGE); //如果有外部流程,启动外部流程 if * (fieldGroupTodo.getRelatedTask()) { ViewToolManager * .showPopupWindow(new ActivityStartPopupWindow( "1111")); } */ if (fieldGroupTodo.getRelatedTask()) { ViewToolManager.showPopupWindow(new ActivityStartPopupWindow("1111")); } } }); line.addComponent(updateSave, 3, 14, 3, 14); line.setComponentAlignment(updateSave, Alignment.MIDDLE_RIGHT); // line.setExpandRatio(updateSave, 1.0f); bottom.addComponent(line); }
/** @param el */ public BookImage(Books el, String user) { super(); this.Book = el; this.setStyleName("cells"); this.setHeight("250px"); this.setWidth("200px"); rating.setAnimated(true); rating.setCaption(null); rating.setMaxValue(5); rating.setStyleName("rating"); rating.setReadOnly(true); rating_my.setAnimated(true); rating_my.setCaption(null); rating_my.setMaxValue(5); rating_my.setStyleName("rating_my"); IRaitingService iRaitingService = new IRaitingService(); try { double rate = iRaitingService.getRaiting(el.getId()); rating.setReadOnly(false); rating.setValue(rate); rating.setReadOnly(true); double myrate = iRaitingService.getRaiting(user, el.getId()); rating_my.setValue(myrate); } catch (SQLException e) { e.printStackTrace(); } rating_my.addValueChangeListener( e -> { try { Rating rat = iRaitingService.getUser( getUI().getSession().getAttribute("user").toString(), el.getId()); rat.setRaiting(rating_my.getValue()); iRaitingService.update(rat); double rate = iRaitingService.getRaiting(el.getId()); rating.setReadOnly(false); rating.setValue(rate); rating.setReadOnly(true); new Notification(String.valueOf(rate), Notification.Type.TRAY_NOTIFICATION) .show(Page.getCurrent()); } catch (SQLException e1) { e1.printStackTrace(); } }); rating_layout.addComponent(rating); rating_layout.addComponent(rating_my); rating_layout.setComponentAlignment(rating, Alignment.MIDDLE_LEFT); rating_layout.setComponentAlignment(rating_my, Alignment.MIDDLE_LEFT); rating_layout.setStyleName("ratinglayout"); imageEmbedded.setSource(new FileResource(new File(Book.getImage()))); title.setValue(Book.getTitle()); author.setValue(Book.getAuthor()); if (Book.getFile().isEmpty()) buttonDownload.setEnabled(false); buttonDownload.setWidth("80%"); imageEmbedded.setWidth("100%"); imageEmbedded.setHeight("100%"); title.setWidth(null); author.setWidth(null); VerticalLayout bodyLayout = new VerticalLayout(title, author, imageEmbedded); bodyLayout.setExpandRatio(title, 12); bodyLayout.setExpandRatio(author, 8); bodyLayout.setExpandRatio(imageEmbedded, 80); bodyLayout.setSizeFull(); bodyLayout.setComponentAlignment(title, Alignment.MIDDLE_CENTER); bodyLayout.setComponentAlignment(author, Alignment.MIDDLE_CENTER); bodyLayout.setComponentAlignment(imageEmbedded, Alignment.MIDDLE_CENTER); buttonDownload.setStyleName("super-button"); title.setStyleName("name-label"); author.setStyleName("author-label"); this.addComponent(rating_layout); this.addComponent(bodyLayout); this.addComponent(buttonDownload); this.setComponentAlignment(rating_layout, Alignment.TOP_CENTER); this.setComponentAlignment(bodyLayout, Alignment.TOP_CENTER); this.setComponentAlignment(buttonDownload, Alignment.BOTTOM_CENTER); this.setExpandRatio(rating_layout, 5); this.setExpandRatio(bodyLayout, 85); this.setExpandRatio(buttonDownload, 10); StreamResource sr = getStream(); FileDownloader fileDownloader = new FileDownloader(sr); fileDownloader.extend(buttonDownload); bodyLayout.addLayoutClickListener( e -> { BookWin win = new BookWin(this.Book); UI.getCurrent().addWindow(win); }); }
@Override public Component generateRow(final SimpleMessage message, final int rowIndex) { final HorizontalLayout messageLayout = new HorizontalLayout(); messageLayout.setStyleName("message"); messageLayout.setSpacing(true); if (message.getIsstick() != null && message.getIsstick()) { messageLayout.addStyleName("important-message"); } messageLayout.setWidth("100%"); VerticalLayout userBlock = new VerticalLayout(); userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER); userBlock.setWidth("80px"); userBlock.setSpacing(true); userBlock.addComponent( UserAvatarControlFactory.createUserAvatarButtonLink( message.getPostedUserAvatarId(), message.getFullPostedUserName())); Label userName = new Label(message.getFullPostedUserName()); userName.setStyleName("user-name"); userBlock.addComponent(userName); messageLayout.addComponent(userBlock); final CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); final Button title = new Button( message.getTitle(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBus.getInstance() .fireEvent( new MessageEvent.GotoRead(MessageListViewImpl.this, message.getId())); } }); title.setWidth("550px"); title.setStyleName("link"); title.addStyleName(UIConstants.WORD_WRAP); final HorizontalLayout messageHeader = new HorizontalLayout(); messageHeader.setStyleName("message-header"); messageHeader.setMargin(new MarginInfo(true, true, false, true)); final VerticalLayout leftHeader = new VerticalLayout(); title.addStyleName("message-title"); leftHeader.addComponent(title); final HorizontalLayout rightHeader = new HorizontalLayout(); rightHeader.setSpacing(true); final Label timePostLbl = new Label(DateTimeUtils.getStringDateFromNow(message.getPosteddate())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); final HorizontalLayout notification = new HorizontalLayout(); notification.setStyleName("notification"); notification.setSizeUndefined(); notification.setSpacing(true); if (message.getCommentsCount() > 0) { final HorizontalLayout commentNotification = new HorizontalLayout(); final Label commentCountLbl = new Label(Integer.toString(message.getCommentsCount())); commentCountLbl.setStyleName("comment-count"); commentCountLbl.setSizeUndefined(); commentNotification.addComponent(commentCountLbl); final Image commentIcon = new Image(null, MyCollabResource.newResource("icons/16/project/message.png")); commentNotification.addComponent(commentIcon); notification.addComponent(commentNotification); } ResourceService attachmentService = ApplicationContextUtil.getSpringBean(ResourceService.class); List<Content> attachments = attachmentService.getContents( AttachmentUtils.getProjectEntityAttachmentPath( AppContext.getAccountId(), message.getProjectid(), AttachmentType.PROJECT_MESSAGE, message.getId())); if (attachments != null && !attachments.isEmpty()) { final HorizontalLayout attachmentNotification = new HorizontalLayout(); final Label attachmentCountLbl = new Label(Integer.toString(attachments.size())); attachmentCountLbl.setStyleName("attachment-count"); attachmentCountLbl.setSizeUndefined(); attachmentNotification.addComponent(attachmentCountLbl); final Image attachmentIcon = new Image(null, MyCollabResource.newResource("icons/16/attachment.png")); attachmentNotification.addComponent(attachmentIcon); notification.addComponent(attachmentNotification); } Button deleteBtn = new Button( "", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show( UI.getCurrent(), LocalizationHelper.getMessage( GenericI18Enum.DELETE_DIALOG_TITLE, SiteConfiguration.getSiteName()), LocalizationHelper.getMessage( GenericI18Enum.CONFIRM_DELETE_RECORD_DIALOG_MESSAGE), LocalizationHelper.getMessage(GenericI18Enum.BUTTON_YES_LABEL), LocalizationHelper.getMessage(GenericI18Enum.BUTTON_NO_LABEL), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(final ConfirmDialog dialog) { if (dialog.isConfirmed()) { final MessageService messageService = ApplicationContextUtil.getSpringBean(MessageService.class); messageService.removeWithSession( message.getId(), AppContext.getUsername(), AppContext.getAccountId()); MessageListViewImpl.this.tableItem.setSearchCriteria(searchCriteria); } } }); } }); deleteBtn.setIcon(MyCollabResource.newResource("icons/12/project/icon_x.png")); deleteBtn.addStyleName("link"); deleteBtn.setEnabled( CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MESSAGES)); rightHeader.addComponent(timePostLbl); rightHeader.addComponent(deleteBtn); rightHeader.setExpandRatio(timePostLbl, 1.0f); messageHeader.addComponent(leftHeader); messageHeader.setExpandRatio(leftHeader, 1.0f); messageHeader.addComponent(rightHeader); messageHeader.setWidth("100%"); rowLayout.addComponent(messageHeader); final Label messageContent = new Label(StringUtils.formatExtraLink(message.getMessage()), ContentMode.HTML); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); if (notification.getComponentCount() > 0) { VerticalLayout messageFooter = new VerticalLayout(); messageFooter.setWidth("100%"); messageFooter.setStyleName("message-footer"); messageFooter.addComponent(notification); messageFooter.setMargin(true); messageFooter.setComponentAlignment(notification, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } messageLayout.addComponent(rowLayout); messageLayout.setExpandRatio(rowLayout, 1.0f); return messageLayout; }