List of usage examples for com.vaadin.ui Button setVisible
@Override public void setVisible(boolean visible)
From source file:at.peppol.webgui.app.components.PartyDetailForm.java
License:Mozilla Public License
private void initElements() { setCaption(party + " Party"); //setStyleName("light"); final VerticalLayout outerLayout = new VerticalLayout(); outerLayout.setSpacing(true);//from w ww . j a v a2 s. c o m outerLayout.setMargin(true); hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true); hiddenContent.setMargin(true); PropertysetItem partyItemSet = new PropertysetItem(); PartyIdentificationType supplierPartyID; if (partyBean.getPartyIdentification().size() == 0) { supplierPartyID = new PartyIdentificationType(); supplierPartyID.setID(new IDType()); partyBean.getPartyIdentification().add(supplierPartyID); } else { supplierPartyID = partyBean.getPartyIdentification().get(0); } partyItemSet.addItemProperty("Party ID", new NestedMethodProperty(supplierPartyID, "ID.value")); EndpointIDType endPointID; if (partyBean.getEndpointID() == null) { endPointID = new EndpointIDType(); partyBean.setEndpointID(endPointID); } else { endPointID = partyBean.getEndpointID(); } partyItemSet.addItemProperty("Endpoint ID", new NestedMethodProperty(endPointID, "SchemeAgencyID")); PartyNameType partyName; if (partyBean.getPartyName().size() == 0) { partyName = new PartyNameType(); partyName.setName(new NameType()); partyBean.getPartyName().add(partyName); } else { partyName = partyBean.getPartyName().get(0); } partyItemSet.addItemProperty("Party Name", new NestedMethodProperty(partyName, "name.value")); /* partyItemSet.addItemProperty("Agency Name", new NestedMethodProperty(supplierPartyID, "ID.SchemeAgencyID") ); */ /* final AddressType partyrAddress = new AddressType(); partyBean.setPostalAddress(partyrAddress); partyrAddress.setStreetName(new StreetNameType()); partyrAddress.setCityName(new CityNameType()); partyrAddress.setPostalZone(new PostalZoneType()); partyrAddress.setCountry(new CountryType()); partyrAddress.getCountry().setIdentificationCode(new IdentificationCodeType()); partyItemSet.addItemProperty("Street Name", new NestedMethodProperty(partyrAddress, "streetName.value")); partyItemSet.addItemProperty("City", new NestedMethodProperty(partyrAddress, "cityName.value")); partyItemSet.addItemProperty("Postal Zone", new NestedMethodProperty(partyrAddress, "postalZone.value")); partyItemSet.addItemProperty("Country", new NestedMethodProperty(partyrAddress, "country.identificationCode.value")); */ AddressDetailForm partyAddressForm; AddressType address; if (partyBean.getPostalAddress() == null) { address = new AddressType(); } else { address = partyBean.getPostalAddress(); } partyAddressForm = new AddressDetailForm(party, address); partyBean.setPostalAddress(address); PartyTaxSchemeType taxScheme; if (partyBean.getPartyTaxScheme().size() == 0) { taxScheme = new PartyTaxSchemeType(); taxScheme.setCompanyID(new CompanyIDType()); //partyItemSet.addItemProperty(taxSchemeCompanyID, // new NestedMethodProperty(taxScheme.getCompanyID(),"value")); // TODO: Hardcoded ShemeID etc for TaxScheme. Should be from a codelist? taxScheme.setTaxScheme(new TaxSchemeType()); taxScheme.getTaxScheme().setID(new IDType()); taxScheme.getTaxScheme().getID().setValue("VAT"); taxScheme.getTaxScheme().getID().setSchemeID("UN/ECE 5153"); taxScheme.getTaxScheme().getID().setSchemeAgencyID("6"); partyBean.getPartyTaxScheme().add(taxScheme); } else { taxScheme = partyBean.getPartyTaxScheme().get(0); } partyItemSet.addItemProperty(taxSchemeCompanyID, new NestedMethodProperty(taxScheme.getCompanyID(), "value")); partyItemSet.addItemProperty(taxSchemeID, new NestedMethodProperty(taxScheme.getTaxScheme().getID(), "value")); final Form partyForm = new Form(); partyForm.setFormFieldFactory(new PartyFieldFactory()); partyForm.setItemDataSource(partyItemSet); partyForm.setImmediate(true); final Button addLegalEntityBtn = new Button("Add Legal Entity"); final Button removeLegalEntityBtn = new Button("Remove Legal Entity"); //removeLegalEntityBtn.setVisible(false); addLegalEntityBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { //add the legal entity component Panel panel = createLegalEntityPanel(removeLegalEntityBtn); outerLayout.addComponent(panel); panel.setWidth("90%"); addLegalEntityBtn.setVisible(false); //removeLegalEntityBtn.setVisible(true); //outerLayout.replaceComponent(removeLegalEntityBtn, panel); } }); removeLegalEntityBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { //remove the legal entity component for (int i = 0; i < outerLayout.getComponentCount(); i++) { Component c = outerLayout.getComponent(i); if (c instanceof Panel) { if (c.getCaption().equals("Legal Entity")) { outerLayout.removeComponent(c); if (partyBean.getPartyLegalEntity().size() > 0) { partyBean.getPartyLegalEntity().clear(); ValidatorsList.removeListeners(Utils.getFieldListeners(legalEntityForm)); } } } } //removeLegalEntityBtn.setVisible(false); addLegalEntityBtn.setVisible(true); } }); outerLayout.addComponent(partyForm); partyForm.setWidth("90%"); outerLayout.addComponent(partyAddressForm); partyAddressForm.setWidth("90%"); outerLayout.addComponent(addLegalEntityBtn); if (partyBean.getPartyLegalEntity().size() > 0) addLegalEntityBtn.click(); //outerLayout.addComponent(removeLegalEntityBtn); //outerLayout.addComponent(createLegalEntityPanel()); setContent(outerLayout); }
From source file:at.peppol.webgui.app.components.TabInvoiceHeader.java
License:Mozilla Public License
private void initElements() { additionalDocRefList = parent.getInvoice().getAdditionalDocumentReference(); setWidth("100%"); setHeight("100%"); //final GridLayout grid = new GridLayout(4, 4); final VerticalLayout outerLayout = new VerticalLayout(); //outerLayout.setMargin(true); //outerLayout.setSpacing(true); //grid that contains "Details", "Contract", "Order" final GridLayout topGridLayout = new GridLayout(2, 2); //topGridLayout.setSizeFull(); topGridLayout.setMargin(true);/*from w w w . j av a 2 s . c o m*/ topGridLayout.setSpacing(true); hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true); hiddenContent.setMargin(true); final Panel outerPanel = new Panel("Invoice Header"); //outerPanel.addComponent(grid); outerPanel.setScrollable(true); outerPanel.setContent(outerLayout); //outerLayout.addComponent(outerPanel); VerticalLayout tabLayout = new VerticalLayout(); tabLayout.addComponent(outerPanel); outerLayout.addComponent(topGridLayout); final Panel invoiceDetailsPanel = new Panel("Invoice Header Details"); invoiceDetailsPanel.setStyleName("light"); invoiceDetailsPanel.setWidth("50%"); //invoiceDetailsPanel.setSizeFull(); invoiceDetailsPanel.addComponent(createInvoiceTopForm()); topGridLayout.addComponent(invoiceDetailsPanel, 0, 0); final Panel orderReferencePanel = new Panel("Referencing Order"); orderReferencePanel.setStyleName("light"); orderReferencePanel.setWidth("50%"); //orderReferencePanel.setSizeFull(); orderReferencePanel.addComponent(createInvoiceOrderReferenceForm()); topGridLayout.addComponent(orderReferencePanel, 0, 1); final VerticalLayout tableVerticalLayout = new VerticalLayout(); //tableVerticalLayout.setSpacing (true); tableVerticalLayout.setMargin(true); outerLayout.addComponent(tableVerticalLayout); table = new InvoiceAdditionalDocRefTable(parent.getInvoice().getAdditionalDocumentReference()); table.setSelectable(true); table.setImmediate(true); table.setNullSelectionAllowed(false); table.setHeight(150, UNITS_PIXELS); table.setSizeFull(); //table.setWidth("300px"); table.setFooterVisible(false); table.addStyleName("striped strong"); Panel tablePanel = new Panel("Relevant Documents"); tablePanel.setStyleName("light"); tablePanel.setWidth("60%"); tableVerticalLayout.addComponent(tablePanel); GridLayout h = new GridLayout(2, 2); h.setMargin(true); h.setSpacing(true); tablePanel.setContent(h); h.addComponent(table, 0, 0); h.setColumnExpandRatio(0, 3); h.setColumnExpandRatio(1, 1); h.setSizeFull(); Button addButton = new Button("Add new"); Button editButton = new Button("Edit selected"); Button deleteButton = new Button("Delete selected"); VerticalLayout buttonsContainer = new VerticalLayout(); buttonsContainer.setSpacing(true); buttonsContainer.addComponent(addButton); buttonsContainer.addComponent(editButton); buttonsContainer.addComponent(deleteButton); InvoiceAdditionalDocRefTableEditor editor = new InvoiceAdditionalDocRefTableEditor(editMode); Label label = new Label("<h3>Adding new relevant document</h3>", Label.CONTENT_XHTML); addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table, additionalDocRefList, label)); label = new Label("<h3>Edit relevant document</h3>", Label.CONTENT_XHTML); editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table, additionalDocRefList, label)); deleteButton.addListener(editor.deleteButtonListener(table)); final Button addContractReferenceBtn = new Button("Add Contract Reference"); final Button removeContractReferenceBtn = new Button("Remove Contract Reference"); removeContractReferenceBtn.setVisible(false); addContractReferenceBtn.setStyleName("marginLeft"); removeContractReferenceBtn.setStyleName("marginLeft"); addContractReferenceBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Panel panel = createInvoiceContractReference(removeContractReferenceBtn); topGridLayout.removeComponent(1, 0); topGridLayout.addComponent(panel, 1, 0); removeContractReferenceBtn.setVisible(true); } }); removeContractReferenceBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { //remove the legal entity component panel Component c = removeContractReferenceBtn.getParent().getParent(); topGridLayout.removeComponent(c); if (parent.getInvoice().getContractDocumentReference().size() > 0) { //parent.getInvoice().getContractDocumentReference().remove(0); parent.getInvoice().getContractDocumentReference().clear(); ValidatorsList.removeListeners(Utils.getFieldListeners(contractReferenceForm)); } topGridLayout.addComponent(addContractReferenceBtn, 1, 0); } }); h.addComponent(buttonsContainer, 1, 0); topGridLayout.addComponent(addContractReferenceBtn, 1, 0); if (parent.getInvoice().getContractDocumentReference().size() > 0) addContractReferenceBtn.click(); // ---- HIDDEN FORM BEGINS ----- VerticalLayout formLayout = new VerticalLayout(); formLayout.addComponent(hiddenContent); hiddenContent.setVisible(false); h.addComponent(formLayout, 0, 1); // ---- HIDDEN FORM ENDS ----- setLayout(tabLayout); }
From source file:com.adonis.ui.menu.Menu.java
private void createViewButtonWithEditableImage(final String name, String caption, String nameImage) { Button button = new Button(caption, new ClickListener() { @Override/*from w w w . j ava 2 s . c om*/ public void buttonClick(ClickEvent event) { navigator.navigateTo(name); } }); button.setPrimaryStyleName(ValoTheme.BUTTON_FRIENDLY); // button.setWidth(50, Unit.PERCENTAGE); image.setWidth(90, Unit.PIXELS); image.setHeight(90, Unit.PIXELS); FileReader.createDirectoriesFromCurrent(getInitialPath()); final Image image = new Image("", new ThemeResource("img/" + nameImage)); try { FileReader.copyFile(VaadinUtils.getResourcePath(nameImage), VaadinUtils.getInitialPath() + File.separator + nameImage); image.setSource(new FileResource(new File(VaadinUtils.getInitialPath() + File.separator + nameImage))); } catch (IOException e) { e.printStackTrace(); image.setSource(new ThemeResource("img/" + nameImage)); } // image.setWidth(50, Unit.PERCENTAGE); image.setWidth(90, Unit.PIXELS); image.setHeight(90, Unit.PIXELS); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setPrimaryStyleName(ValoTheme.MENU_ITEM); horizontalLayout.addComponents(image, button); image.addClickListener(new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { uploadFieldImage = new UploadField(); uploadFieldImage.setAcceptFilter("image/*"); uploadFieldImage.getUpload().addListener(new com.vaadin.v7.ui.Upload.FailedListener() { @Override public void uploadFailed(com.vaadin.v7.ui.Upload.FailedEvent event) { uploadFieldImage.clearDefaulLayout(); horizontalLayout.removeComponent(uploadFieldImage); } private static final long serialVersionUID = 1L; }); horizontalLayout.addComponent(uploadFieldImage, 2); uploadFieldImage.getUpload().addListener(new com.vaadin.v7.ui.Upload.SucceededListener() { @Override public void uploadSucceeded(com.vaadin.v7.ui.Upload.SucceededEvent event) { File file = (File) uploadFieldImage.getValue(); try { showUploadedImage(uploadFieldImage, image, file.getName(), nameImage); } catch (IOException e) { e.printStackTrace(); } uploadFieldImage.clearDefaulLayout(); horizontalLayout.removeComponent(uploadFieldImage); } }); uploadFieldImage.setFieldType(UploadField.FieldType.FILE); horizontalLayout.markAsDirty(); // image.setWidth(50, Unit.PERCENTAGE); image.setWidth(90, Unit.PIXELS); image.setHeight(90, Unit.PIXELS); image.setVisible(false); image.markAsDirty(); horizontalLayout.addComponent(image, 0); } }); button.setVisible(true); image.setVisible(true); menuItemsLayout.addComponents(horizontalLayout); viewButtons.put(name, button); }
From source file:com.arcusys.liferay.vaadinplugin.ControlPanelUI.java
License:Apache License
private Button createTerminateCompilationButton() { Button button = new Button("Cancel", new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { compiler.terminate();//w w w .j av a2 s.c o m } }); button.setVisible(false); return button; }
From source file:com.constellio.app.ui.pages.base.MainLayoutImpl.java
private ConstellioMenuButton buildButton(final NavigationItem item) { ComponentState state = presenter.getStateFor(item); Button button = new Button($("MainLayout." + item.getCode())); button.setVisible(state.isVisible()); button.setEnabled(state.isEnabled()); button.addStyleName(item.getCode()); if (item.getFontAwesome() != null) { button.setIcon(item.getFontAwesome()); }// www. j a va2 s. c om button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { item.activate(navigate()); } }); return new ConstellioMenuButton(item.getViewGroup(), button); }
From source file:com.constellio.app.ui.pages.management.updates.UpdateManagerViewImpl.java
private Component buildAvailableUpdateLayout() { Label message = new Label($("UpdateManagerViewImpl.updateAvailable", presenter.getUpdateVersion())); message.addStyleName(ValoTheme.LABEL_BOLD); Button update = new LinkButton($("UpdateManagerViewImpl.updateButton")) { @Override// ww w . j a va 2 s . c o m protected void buttonClick(ClickEvent event) { UI.getCurrent().access(new Thread(UpdateManagerViewImpl.class.getName() + "-updateFromServer") { @Override public void run() { presenter.updateFromServer(); } }); } }; update.setVisible(presenter.isUpdateEnabled()); HorizontalLayout updater = new HorizontalLayout(message, update); updater.setComponentAlignment(message, Alignment.MIDDLE_LEFT); updater.setComponentAlignment(update, Alignment.MIDDLE_LEFT); updater.setSpacing(true); Label changelog = new Label(presenter.getChangelog(), ContentMode.HTML); VerticalLayout layout = new VerticalLayout(updater, changelog); layout.setSpacing(true); layout.setWidth("100%"); return layout; }
From source file:com.esofthead.mycollab.common.ui.components.CommentRowDisplayHandler.java
License:Open Source License
@Override public Component generateRow(final SimpleComment comment, int rowIndex) { final MHorizontalLayout layout = new MHorizontalLayout().withSpacing(true).withMargin(false) .withWidth("100%").withStyleName("message"); MVerticalLayout userBlock = new MVerticalLayout().withSpacing(true).withMargin(false).withWidth("80px"); userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER); ClickListener gotoUser = new ClickListener() { private static final long serialVersionUID = 1L; @Override/* w w w . j a v a 2 s. c om*/ public void buttonClick(ClickEvent event) { EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoRead(this, comment.getCreateduser())); } }; Button userAvatarBtn = UserAvatarControlFactory.createUserAvatarButtonLink(comment.getOwnerAvatarId(), comment.getOwnerFullName()); userAvatarBtn.addClickListener(gotoUser); userBlock.addComponent(userAvatarBtn); Button userName = new Button(comment.getOwnerFullName()); userName.setStyleName("user-name"); userName.addStyleName("link"); userName.addStyleName(UIConstants.WORD_WRAP); userName.addClickListener(gotoUser); userBlock.addComponent(userName); layout.addComponent(userBlock); CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); MHorizontalLayout messageHeader = new MHorizontalLayout().withSpacing(true) .withMargin(new MarginInfo(true, true, false, true)).withWidth("100%") .withStyleName("message-header"); messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); Label timePostLbl = new Label( AppContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(), DateTimeUtils.getPrettyDateValue(comment.getCreatedtime(), AppContext.getUserLocale())), ContentMode.HTML); timePostLbl.setDescription(AppContext.formatDateTime(comment.getCreatedtime())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); messageHeader.addComponent(timePostLbl); messageHeader.setExpandRatio(timePostLbl, 1.0f); // Message delete button Button msgDeleteBtn = new Button(); msgDeleteBtn.setIcon(FontAwesome.TRASH_O); msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); messageHeader.addComponent(msgDeleteBtn); if (hasDeletePermission(comment)) { msgDeleteBtn.setVisible(true); msgDeleteBtn.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()) { CommentService commentService = ApplicationContextUtil .getSpringBean(CommentService.class); commentService.removeWithSession(comment.getId(), AppContext.getUsername(), AppContext.getAccountId()); CommentRowDisplayHandler.this.owner.removeRow(layout); } } }); } }); } else { msgDeleteBtn.setVisible(false); } rowLayout.addComponent(messageHeader); Label messageContent = new UrlDetectableLabel(comment.getComment()); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); List<Content> attachments = comment.getAttachments(); if (!CollectionUtils.isEmpty(attachments)) { MVerticalLayout messageFooter = new MVerticalLayout().withSpacing(false).withMargin(true) .withWidth("100%").withStyleName("message-footer"); AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments); attachmentDisplay.setWidth("100%"); messageFooter.addComponent(attachmentDisplay); messageFooter.setComponentAlignment(attachmentDisplay, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } layout.addComponent(rowLayout); layout.setExpandRatio(rowLayout, 1.0f); return layout; }
From source file:com.esofthead.mycollab.module.crm.ui.components.CommentRowDisplayHandler.java
License:Open Source License
@Override public Component generateRow(final SimpleComment comment, int rowIndex) { final MHorizontalLayout layout = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, true, false)).withWidth("100%").withStyleName("message"); UserBlock memberBlock = new UserBlock(comment.getCreateduser(), comment.getOwnerAvatarId(), comment.getOwnerFullName()); layout.addComponent(memberBlock);/*w ww . j a va2s . c o m*/ CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); MHorizontalLayout messageHeader = new MHorizontalLayout() .withMargin(new MarginInfo(true, true, false, true)).withWidth("100%") .withStyleName("message-header"); messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); ELabel timePostLbl = new ELabel(AppContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(), AppContext.formatPrettyTime(comment.getCreatedtime())), ContentMode.HTML).withDescription(AppContext.formatDateTime(comment.getCreatedtime())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); messageHeader.with(timePostLbl).expand(timePostLbl); // Message delete button Button msgDeleteBtn = new Button(); msgDeleteBtn.setIcon(FontAwesome.TRASH_O); msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); messageHeader.addComponent(msgDeleteBtn); if (hasDeletePermission(comment)) { msgDeleteBtn.setVisible(true); msgDeleteBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.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()) { CommentService commentService = ApplicationContextUtil .getSpringBean(CommentService.class); commentService.removeWithSession(comment.getId(), AppContext.getUsername(), AppContext.getAccountId()); CommentRowDisplayHandler.this.owner.removeRow(layout); } } }); } }); } else { msgDeleteBtn.setVisible(false); } rowLayout.addComponent(messageHeader); Label messageContent = new SafeHtmlLabel(comment.getComment()); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); List<Content> attachments = comment.getAttachments(); if (!CollectionUtils.isEmpty(attachments)) { MVerticalLayout messageFooter = new MVerticalLayout().withSpacing(false).withWidth("100%") .withStyleName("message-footer"); AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments); attachmentDisplay.setWidth("100%"); messageFooter.with(attachmentDisplay).withAlign(attachmentDisplay, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } layout.with(rowLayout).expand(rowLayout); return layout; }
From source file:com.esofthead.mycollab.module.crm.ui.components.CrmActivityComponent.java
License:Open Source License
private Component buildCommentBlock(final SimpleComment comment) { final MHorizontalLayout layout = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, true, false)).withFullWidth().withStyleName("message"); ProjectMemberBlock memberBlock = new ProjectMemberBlock(comment.getCreateduser(), comment.getOwnerAvatarId(), comment.getOwnerFullName()); layout.addComponent(memberBlock);//from w w w . j av a 2s. c om MVerticalLayout rowLayout = new MVerticalLayout().withFullWidth().withStyleName("message-container"); MHorizontalLayout messageHeader = new MHorizontalLayout().withFullWidth(); messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); ELabel timePostLbl = new ELabel(AppContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(), AppContext.formatPrettyTime(comment.getCreatedtime())), ContentMode.HTML).withDescription(AppContext.formatDateTime(comment.getCreatedtime())); timePostLbl.setStyleName(UIConstants.META_INFO); if (hasDeletePermission(comment)) { Button msgDeleteBtn = new Button(); msgDeleteBtn.setIcon(FontAwesome.TRASH_O); msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); msgDeleteBtn.setVisible(true); msgDeleteBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.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()) { CommentService commentService = AppContextUtil .getSpringBean(CommentService.class); commentService.removeWithSession(comment, AppContext.getUsername(), AppContext.getAccountId()); activityBox.removeComponent(layout); } } }); } }); messageHeader.with(timePostLbl, msgDeleteBtn).expand(timePostLbl); } else { messageHeader.with(timePostLbl).expand(timePostLbl); } rowLayout.addComponent(messageHeader); Label messageContent = new SafeHtmlLabel(comment.getComment()); rowLayout.addComponent(messageContent); List<Content> attachments = comment.getAttachments(); if (!CollectionUtils.isEmpty(attachments)) { MVerticalLayout messageFooter = new MVerticalLayout().withMargin(false).withSpacing(false) .withFullWidth(); AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments); attachmentDisplay.setWidth("100%"); messageFooter.with(attachmentDisplay); rowLayout.addComponent(messageFooter); } layout.with(rowLayout).expand(rowLayout); return layout; }
From source file:com.esofthead.mycollab.module.project.ui.components.CommentRowDisplayHandler.java
License:Open Source License
@Override public Component generateRow(final SimpleComment comment, int rowIndex) { final MHorizontalLayout layout = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, true, false)).withWidth("100%").withStyleName("message"); ProjectMemberBlock memberBlock = new ProjectMemberBlock(comment.getCreateduser(), comment.getOwnerAvatarId(), comment.getOwnerFullName()); layout.addComponent(memberBlock);/*w w w .j av a 2 s. co m*/ CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); MHorizontalLayout messageHeader = new MHorizontalLayout() .withMargin(new MarginInfo(true, true, false, true)).withWidth("100%") .withStyleName("message-header"); messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); ELabel timePostLbl = new ELabel(AppContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(), AppContext.formatPrettyTime(comment.getCreatedtime())), ContentMode.HTML).withDescription(AppContext.formatDateTime(comment.getCreatedtime())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); messageHeader.with(timePostLbl).expand(timePostLbl); // Message delete button Button msgDeleteBtn = new Button(); msgDeleteBtn.setIcon(FontAwesome.TRASH_O); msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); messageHeader.addComponent(msgDeleteBtn); if (hasDeletePermission(comment)) { msgDeleteBtn.setVisible(true); msgDeleteBtn.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()) { CommentService commentService = ApplicationContextUtil .getSpringBean(CommentService.class); commentService.removeWithSession(comment.getId(), AppContext.getUsername(), AppContext.getAccountId()); CommentRowDisplayHandler.this.owner.removeRow(layout); } } }); } }); } else { msgDeleteBtn.setVisible(false); } rowLayout.addComponent(messageHeader); Label messageContent = new SafeHtmlLabel(comment.getComment()); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); List<Content> attachments = comment.getAttachments(); if (!CollectionUtils.isEmpty(attachments)) { MVerticalLayout messageFooter = new MVerticalLayout().withSpacing(false).withWidth("100%") .withStyleName("message-footer"); AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments); attachmentDisplay.setWidth("100%"); messageFooter.with(attachmentDisplay).withAlign(attachmentDisplay, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } layout.with(rowLayout).expand(rowLayout); return layout; }