@Override protected Component generateTopControls() { VerticalLayout controlsBtnWrap = new VerticalLayout(); controlsBtnWrap.setWidth("100%"); final SplitButton controlsBtn = new SplitButton(); controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK); controlsBtn.setCaption(AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY)); controlsBtn.setIcon(FontAwesome.PLUS); controlsBtn.addClickListener( new SplitButton.SplitButtonClickListener() { private static final long serialVersionUID = 1L; @Override public void splitButtonClick(SplitButton.SplitButtonClickEvent event) { fireNewRelatedItem(""); } }); controlsBtn.setSizeUndefined(); Button selectBtn = new Button( "Select from existing opportunities", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { ContactOpportunitySelectionWindow opportunitiesWindow = new ContactOpportunitySelectionWindow(ContactOpportunityListComp.this); OpportunitySearchCriteria criteria = new OpportunitySearchCriteria(); criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId())); UI.getCurrent().addWindow(opportunitiesWindow); opportunitiesWindow.setSearchCriteria(criteria); controlsBtn.setPopupVisible(false); } }); selectBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY)); OptionPopupContent buttonControlsLayout = new OptionPopupContent(); buttonControlsLayout.addOption(selectBtn); controlsBtn.setContent(buttonControlsLayout); controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY)); controlsBtnWrap.addComponent(controlsBtn); controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT); return controlsBtnWrap; }
public MassUpdateContactWindow(String title, ContactListPresenter presenter) { super(title, CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT), new Contact(), presenter); }
public LeadReadViewImpl() { super(CrmAssetsManager.getAsset(CrmTypeConstants.LEAD)); }
@Override public void displayConvertLeadInfo(final SimpleLead lead) { previewForm.removeAllComponents(); this.lead = lead; Label header = new Label("Conversion Details"); header.addStyleName("h2"); previewForm.addComponent(header); GridFormLayoutHelper layoutHelper = new GridFormLayoutHelper(1, 3); layoutHelper.getLayout().setWidth("100%"); layoutHelper.getLayout().setMargin(false); layoutHelper.getLayout().addStyleName("colored-gridlayout"); LOG.debug("Display associate account"); AccountService accountService = ApplicationContextUtil.getSpringBean(AccountService.class); final SimpleAccount account = accountService.findAccountAssoWithConvertedLead(lead.getId(), AppContext.getAccountId()); if (account != null) { Button accountLink = new Button( account.getAccountname(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new AccountEvent.GotoRead(this, account.getId())); } }); accountLink.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.ACCOUNT)); accountLink.setStyleName("link"); layoutHelper.addComponent(accountLink, "Account", 0, 0); } else { layoutHelper.addComponent(new Label(""), "Account", 0, 0); } LOG.debug("Display associate contact"); ContactService contactService = ApplicationContextUtil.getSpringBean(ContactService.class); final SimpleContact contact = contactService.findContactAssoWithConvertedLead(lead.getId(), AppContext.getAccountId()); if (contact != null) { Button contactLink = new Button( contact.getContactName(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new ContactEvent.GotoRead(this, contact.getId())); } }); contactLink.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT)); contactLink.setStyleName("link"); layoutHelper.addComponent(contactLink, "Contact", 0, 1); } else { layoutHelper.addComponent(new Label(""), "Contact", 0, 1); } LOG.debug("Display associate opportunity"); OpportunityService opportunityService = ApplicationContextUtil.getSpringBean(OpportunityService.class); final SimpleOpportunity opportunity = opportunityService.findOpportunityAssoWithConvertedLead( lead.getId(), AppContext.getAccountId()); if (opportunity != null) { Button opportunityLink = new Button( opportunity.getOpportunityname(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new OpportunityEvent.GotoRead(this, opportunity.getId())); } }); opportunityLink.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY)); opportunityLink.setStyleName("link"); layoutHelper.addComponent(opportunityLink, "Opportunity", 0, 2); } else { layoutHelper.addComponent(new Label(""), "Opportunity", 0, 2); } previewForm.addComponent(layoutHelper.getLayout()); previewLayout.addBody(previewContent); this.addComponent(previewItemContainer); }
@Override public Component generateBlock(final SimpleOpportunity opportunity, int blockIndex) { CssLayout beanBlock = new CssLayout(); beanBlock.addStyleName("bean-block"); beanBlock.setWidth("350px"); VerticalLayout blockContent = new VerticalLayout(); MHorizontalLayout blockTop = new MHorizontalLayout().withWidth("100%"); CssLayout iconWrap = new CssLayout(); iconWrap.setStyleName("icon-wrap"); FontIconLabel opportunityIcon = new FontIconLabel(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY)); iconWrap.addComponent(opportunityIcon); blockTop.addComponent(iconWrap); VerticalLayout opportunityInfo = new VerticalLayout(); opportunityInfo.setSpacing(true); MButton btnDelete = new MButton(FontAwesome.TRASH_O); btnDelete.addClickListener( new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { 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()) { ContactService contactService = ApplicationContextUtil.getSpringBean(ContactService.class); ContactOpportunity associateOpportunity = new ContactOpportunity(); associateOpportunity.setContactid(contact.getId()); associateOpportunity.setOpportunityid(opportunity.getId()); contactService.removeContactOpportunityRelationship( associateOpportunity, AppContext.getAccountId()); ContactOpportunityListComp.this.refresh(); } } }); } }); btnDelete.addStyleName(UIConstants.BUTTON_ICON_ONLY); blockContent.addComponent(btnDelete); blockContent.setComponentAlignment(btnDelete, Alignment.TOP_RIGHT); Label opportunityName = new Label( String.format( "Name: <a href='%s%s'>%s</a>", SiteConfiguration.getSiteUrl(AppContext.getUser().getSubdomain()), CrmLinkGenerator.generateCrmItemLink( CrmTypeConstants.OPPORTUNITY, opportunity.getId()), opportunity.getOpportunityname()), ContentMode.HTML); opportunityInfo.addComponent(opportunityName); Label opportunityAmount = new Label("Amount: " + (opportunity.getAmount() != null ? opportunity.getAmount() : "")); if (opportunity.getCurrency() != null && opportunity.getAmount() != null) { opportunityAmount.setValue( opportunityAmount.getValue() + opportunity.getCurrency().getSymbol()); } opportunityInfo.addComponent(opportunityAmount); Label opportunitySaleStage = new Label( "Sale Stage: " + (opportunity.getSalesstage() != null ? opportunity.getSalesstage() : "")); opportunityInfo.addComponent(opportunitySaleStage); ELabel opportunityExpectedCloseDate = new ELabel( "Expected Closed Date: " + AppContext.formatPrettyTime(opportunity.getExpectedcloseddate())) .withDescription(AppContext.formatDate(opportunity.getExpectedcloseddate())); opportunityInfo.addComponent(opportunityExpectedCloseDate); blockTop.with(opportunityInfo).expand(opportunityInfo); blockContent.addComponent(blockTop); blockContent.setWidth("100%"); beanBlock.addComponent(blockContent); return beanBlock; }