예제 #1
0
  @Override
  protected void deleteSelectedItems() {
    if (!isSelectAll) {
      Collection<SimpleRole> currentDataList = view.getPagedBeanTable().getCurrentDataList();
      List<Role> keyList = new ArrayList<>();
      for (SimpleRole item : currentDataList) {
        if (item.isSelected()) {
          if (Boolean.TRUE.equals(item.getIssystemrole())) {
            NotificationUtil.showErrorNotification(
                String.format(
                    "Can not delete role %s because it is the system role.", item.getRolename()));
          } else {
            keyList.add(item);
          }
        }
      }

      if (keyList.size() > 0) {
        roleService.massRemoveWithSession(
            keyList, AppContext.getUsername(), AppContext.getAccountId());
        doSearch(searchCriteria);
      }
    } else {
      roleService.removeByCriteria(searchCriteria, AppContext.getAccountId());
      doSearch(searchCriteria);
    }
  }
예제 #2
0
 protected void handlePage(String... params) {
   String username = new UrlTokenizer(params[0]).getString();
   UserService userService = ApplicationContextUtil.getSpringBean(UserService.class);
   SimpleUser user =
       userService.findUserByUserNameInAccount(username, AppContext.getAccountId());
   EventBusFactory.getInstance().post(new UserEvent.GotoEdit(EditUrlResolver.this, user));
 }
예제 #3
0
  @Override
  protected void onGo(ComponentContainer container, ScreenData<?> data) {
    if (AppContext.canWrite(RolePermissionCollections.CRM_MEETING)) {
      MeetingWithBLOBs meeting = null;
      if (data.getParams() instanceof MeetingWithBLOBs) {
        meeting = (MeetingWithBLOBs) data.getParams();
      } else if (data.getParams() instanceof Integer) {
        MeetingService meetingService = ApplicationContextUtil.getSpringBean(MeetingService.class);
        meeting =
            meetingService.findByPrimaryKey((Integer) data.getParams(), AppContext.getAccountId());
      }
      if (meeting == null) {
        NotificationUtil.showRecordNotExistNotification();
        return;
      }
      super.onGo(container, data);

      view.editItem(meeting);

      if (meeting.getId() == null) {
        AppContext.addFragment(
            "crm/activity/meeting/add/",
            AppContext.getMessage(GenericI18Enum.BROWSER_ADD_ITEM_TITLE, "Meeting"));
      } else {
        AppContext.addFragment(
            "crm/activity/meeting/edit/" + UrlEncodeDecoder.encode(meeting.getId()),
            AppContext.getMessage(
                GenericI18Enum.BROWSER_EDIT_ITEM_TITLE, "Meeting", meeting.getSubject()));
      }
    } else {
      NotificationUtil.showMessagePermissionAlert();
    }
  }
예제 #4
0
 protected void displayActivities() {
   ActivitySearchCriteria criteria = new ActivitySearchCriteria();
   criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
   criteria.setType(new StringSearchField(SearchField.AND, CrmTypeConstants.LEAD));
   criteria.setTypeid(new NumberSearchField(beanItem.getId()));
   associateActivityList.setSearchCriteria(criteria);
 }
예제 #5
0
 public void display() {
   final CallSearchCriteria criteria = new CallSearchCriteria();
   criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
   criteria.setAssignUsers(new SetSearchField<>(AppContext.getUsername()));
   criteria.setIsClosed(BitSearchField.FALSE);
   tableItem.setSearchCriteria(criteria);
 }
예제 #6
0
  @Override
  protected void onGo(ComponentContainer container, ScreenData<?> data) {
    if (AppContext.canWrite(RolePermissionCollections.CRM_TASK)) {
      Task task;
      if (data.getParams() instanceof Task) {
        task = (Task) data.getParams();
      } else if (data.getParams() instanceof Integer) {
        TaskService taskService = ApplicationContextUtil.getSpringBean(TaskService.class);
        task = taskService.findByPrimaryKey((Integer) data.getParams(), AppContext.getAccountId());
        if (task == null) {
          NotificationUtil.showRecordNotExistNotification();
          return;
        }
      } else {
        throw new MyCollabException("Do not support param data: " + data);
      }

      super.onGo(container, data);
      view.editItem(task);

      if (task.getId() == null) {
        AppContext.addFragment("crm/activity/task/add/", "Add Activity Task");
      } else {
        AppContext.addFragment(
            "crm/activity/task/edit/" + UrlEncodeDecoder.encode(task.getId()),
            "Edit Activity Task: " + task.getSubject());
      }
    } else {
      NotificationUtil.showMessagePermissionAlert();
    }
  }
예제 #7
0
  @Override
  protected void onGo(final ComponentContainer container, final ScreenData<?> data) {
    if (CurrentProjectVariables.canRead(ProjectRolePermissionCollections.TASKS)) {

      InsideProjectNavigationMenu projectModuleMenu =
          (InsideProjectNavigationMenu)
              ((MobileNavigationManager) UI.getCurrent().getContent()).getNavigationMenu();
      projectModuleMenu.selectButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TASK));

      if (data.getParams() instanceof Integer) {
        ProjectTaskService taskService =
            ApplicationContextUtil.getSpringBean(ProjectTaskService.class);
        SimpleTask task =
            taskService.findById((Integer) data.getParams(), AppContext.getAccountId());

        if (task != null) {
          this.view.previewItem(task);
          super.onGo(container, data);

          AppContext.addFragment(
              ProjectLinkGenerator.generateTaskPreviewLink(
                  task.getTaskkey(), task.getProjectShortname()),
              task.getTaskname());
        } else {
          NotificationUtil.showRecordNotExistNotification();
          return;
        }
      }
    } else {
      NotificationUtil.showMessagePermissionAlert();
    }
  }
예제 #8
0
  public void save(Task item) {
    TaskService taskService = ApplicationContextUtil.getSpringBean(TaskService.class);

    item.setSaccountid(AppContext.getAccountId());
    if (item.getId() == null) {
      taskService.saveWithSession(item, AppContext.getUsername());
    } else {
      taskService.updateWithSession(item, AppContext.getUsername());
    }
  }
예제 #9
0
  public void save(MeetingWithBLOBs item) {
    MeetingService meetingService = ApplicationContextUtil.getSpringBean(MeetingService.class);

    item.setSaccountid(AppContext.getAccountId());
    if (item.getId() == null) {
      meetingService.saveWithSession(item, AppContext.getUsername());
    } else {
      meetingService.updateWithSession(item, AppContext.getUsername());
    }
  }
 private void save(Version item) {
   VersionService versionService = ApplicationContextUtil.getSpringBean(VersionService.class);
   item.setSaccountid(AppContext.getAccountId());
   item.setProjectid(CurrentProjectVariables.getProjectId());
   item.setStatus(StatusI18nEnum.Open.name());
   if (item.getId() == null) {
     versionService.saveWithSession(item, AppContext.getUsername());
   } else {
     versionService.updateWithSession(item, AppContext.getUsername());
   }
 }
예제 #11
0
  private int saveMilestone(Milestone milestone) {
    MilestoneService milestoneService =
        ApplicationContextUtil.getSpringBean(MilestoneService.class);
    milestone.setProjectid(CurrentProjectVariables.getProjectId());
    milestone.setSaccountid(AppContext.getAccountId());

    if (milestone.getId() == null) {
      milestone.setCreateduser(AppContext.getUsername());
      milestoneService.saveWithSession(milestone, AppContext.getUsername());
    } else {
      milestoneService.updateWithSession(milestone, AppContext.getUsername());
    }
    return milestone.getId();
  }
예제 #12
0
    @Override
    protected void saveTimeInvest(double spentHours, boolean isBillable, Date forDate) {
      ItemTimeLogging item = new ItemTimeLogging();
      item.setLoguser(AppContext.getUsername());
      item.setLogvalue(spentHours);
      item.setTypeid(bean.getId());
      item.setType(ProjectTypeConstants.TASK);
      item.setSaccountid(AppContext.getAccountId());
      item.setProjectid(CurrentProjectVariables.getProjectId());
      item.setLogforday(forDate);
      item.setIsbillable(isBillable);

      itemTimeLoggingService.saveWithSession(item, AppContext.getUsername());
    }
  @Override
  protected Component initContent() {
    ResourceService resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);
    List<Content> attachments =
        resourceService.getContents(
            AttachmentUtils.getProjectEntityAttachmentPath(
                AppContext.getAccountId(), projectid, type, typeid));
    if (CollectionUtils.isNotEmpty(attachments)) {
      VerticalLayout comp = new VerticalLayout();
      comp.setStyleName("attachment-view-panel");

      for (final Content attachment : attachments) {
        String docName = attachment.getPath();
        int lastIndex = docName.lastIndexOf("/");
        if (lastIndex != -1) {
          docName = docName.substring(lastIndex + 1, docName.length());
        }

        if (MimeTypesUtil.isImageType(docName)) {
          Button b =
              new Button(
                  attachment.getTitle(),
                  new Button.ClickListener() {

                    private static final long serialVersionUID = 293396615972447886L;

                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                      AttachmentPreviewView previewView =
                          new AttachmentPreviewView(
                              VaadinResourceManager.getResourceManager()
                                  .getImagePreviewResource(attachment.getPath(), DEFAULT_SOURCE));
                      EventBusFactory.getInstance()
                          .post(new ShellEvent.PushView(this, previewView));
                    }
                  });
          b.setWidth("100%");
          comp.addComponent(b);
        } else {
          Label l = new Label(attachment.getTitle());
          l.setWidth("100%");
          comp.addComponent(l);
        }
      }

      return comp;
    }
    return new Label("&nbsp;", ContentMode.HTML);
  }
예제 #14
0
    void displayPageInfo(Page beanItem) {
      MVerticalLayout header = new MVerticalLayout().withMargin(false);
      Label titleLbl = new Label(beanItem.getSubject());
      titleLbl.setStyleName("headerName");
      header.with(titleLbl);
      Div footer = new Div().setStyle("width:100%").setCSSClass("footer2");
      Span lastUpdatedTimeTxt =
          new Span()
              .appendText(
                  AppContext.getMessage(
                      DayI18nEnum.LAST_UPDATED_ON,
                      AppContext.formatPrettyTime(beanItem.getLastUpdatedTime().getTime())))
              .setTitle(AppContext.formatDateTime(beanItem.getLastUpdatedTime().getTime()));
      String uid = UUID.randomUUID().toString();
      ProjectMemberService projectMemberService =
          ApplicationContextUtil.getSpringBean(ProjectMemberService.class);
      SimpleProjectMember member =
          projectMemberService.findMemberByUsername(
              beanItem.getCreatedUser(),
              CurrentProjectVariables.getProjectId(),
              AppContext.getAccountId());
      if (member != null) {
        Img userAvatar =
            new Img("", StorageFactory.getInstance().getAvatarPath(member.getMemberAvatarId(), 16));
        A userLink =
            new A()
                .setId("tag" + uid)
                .setHref(
                    ProjectLinkBuilder.generateProjectMemberFullLink(
                        member.getProjectid(), member.getUsername()))
                .appendText(StringUtils.trim(member.getMemberFullName(), 30, true));
        userLink.setAttribute(
            "onmouseover", TooltipHelper.userHoverJsFunction(uid, member.getUsername()));
        userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction(uid));
        footer.appendChild(
            lastUpdatedTimeTxt,
            new Text("&nbsp;-&nbsp;Created by: "),
            userAvatar,
            DivLessFormatter.EMPTY_SPACE(),
            userLink,
            DivLessFormatter.EMPTY_SPACE(),
            TooltipHelper.buildDivTooltipEnable(uid));
      } else {
        footer.appendChild(lastUpdatedTimeTxt);
      }

      header.addComponent(new Label(footer.write(), ContentMode.HTML));
      this.addHeader(header);
    }
        @Override
        @Subscribe
        public void handle(TaskEvent.NewTaskAdded event) {
          final ProjectTaskService projectTaskService =
              ApplicationContextUtil.getSpringBean(ProjectTaskService.class);
          SimpleTask task =
              projectTaskService.findById((Integer) event.getData(), AppContext.getAccountId());
          if (task != null && taskGroupOrderComponent != null) {
            taskGroupOrderComponent.insertTasks(Arrays.asList(task));
          }
          displayTaskStatistic();

          int totalTasks = projectTaskService.getTotalCount(baseCriteria);
          taskSearchPanel.setTotalCountNumber(totalTasks);
        }
예제 #16
0
    @Override
    protected SearchCriteria fillUpSearchCriteria() {
      OpportunitySearchCriteria searchCriteria = new OpportunitySearchCriteria();
      searchCriteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));

      if (StringUtils.isNotBlank(this.nameField.getValue().trim())) {
        searchCriteria.setOpportunityName(StringSearchField.and(this.nameField.getValue().trim()));
      }

      if (this.myItemCheckbox.getValue()) {
        searchCriteria.setAssignUsers(new SetSearchField<>(AppContext.getUsername()));
      } else {
        searchCriteria.setAssignUsers(null);
      }

      return searchCriteria;
    }
  private void doSearch() {
    searchCriteria = new CampaignSearchCriteria();
    searchCriteria.setSaccountid(new NumberSearchField(SearchField.AND, AppContext.getAccountId()));

    String searchType = (String) group.getValue();
    if (StringUtils.isNotBlank(searchType)) {
      if (textValueField != null) {
        String strSearch = textValueField.getValue();
        if (StringUtils.isNotBlank(strSearch)) {
          if (searchType.equals("Campaign Name")) {
            searchCriteria.setCampaignName(new StringSearchField(SearchField.AND, strSearch));
          }
        }
      }
    }
    notifySearchHandler(searchCriteria);
  }
예제 #18
0
 @Override
 protected String initFormTitle() {
   // check if there is converted lead associates with this contact
   LeadService leadService = ApplicationContextUtil.getSpringBean(LeadService.class);
   SimpleLead lead =
       leadService.findConvertedLeadOfContact(beanItem.getId(), AppContext.getAccountId());
   if (lead != null) {
     return "<h2>"
         + beanItem.getContactName()
         + LocalizationHelper.getMessage(
             LeadI18nEnum.CONVERT_FROM_LEAD_TITLE,
             CrmResources.getResourceLink(CrmTypeConstants.LEAD),
             CrmLinkGenerator.generateCrmItemLink(CrmTypeConstants.LEAD, lead.getId()),
             lead.getLeadName())
         + "</h2>";
   } else {
     return beanItem.getContactName();
   }
 }
예제 #19
0
  @Override
  protected void onGo(ComponentContainer container, ScreenData<?> data) {
    if (AppContext.canRead(RolePermissionCollections.ACCOUNT_ROLE)) {
      RoleService roleService = ApplicationContextUtil.getSpringBean(RoleService.class);
      SimpleRole role = roleService.findById((Integer) data.getParams(), AppContext.getAccountId());
      if (role != null) {
        RoleContainer roleContainer = (RoleContainer) container;
        roleContainer.removeAllComponents();
        roleContainer.addComponent(view.getWidget());
        view.previewItem(role);

        AccountSettingBreadcrumb breadcrumb =
            ViewManager.getCacheComponent(AccountSettingBreadcrumb.class);
        breadcrumb.gotoRoleRead(role);
      } else {
        NotificationUtil.showRecordNotExistNotification();
      }
    } else {
      NotificationUtil.showMessagePermissionAlert();
    }
  }
  @Override
  protected void displayView() {
    constructUI();
    baseCriteria = new TaskSearchCriteria();
    baseCriteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId()));
    OptionValService optionValService =
        ApplicationContextUtil.getSpringBean(OptionValService.class);
    List<OptionVal> options =
        optionValService.findOptionValsExcludeClosed(
            ProjectTypeConstants.TASK,
            CurrentProjectVariables.getProjectId(),
            AppContext.getAccountId());

    SetSearchField<String> statuses = new SetSearchField<>();
    for (OptionVal option : options) {
      statuses.addValue(option.getTypeval());
    }
    baseCriteria.setStatuses(statuses);
    statisticSearchCriteria = BeanUtility.deepClone(baseCriteria);
    queryAndDisplayTasks();
    displayTaskStatistic();
  }
예제 #21
0
 protected void displayAssociateOpportunityList() {
   final OpportunitySearchCriteria criteria = new OpportunitySearchCriteria();
   criteria.setSaccountid(new NumberSearchField(SearchField.AND, AppContext.getAccountId()));
   criteria.setContactId(new NumberSearchField(SearchField.AND, this.beanItem.getId()));
   this.associateOpportunityList.displayOpportunities(this.beanItem);
 }
예제 #22
0
 private void loadContacts() {
   ContactSearchCriteria criteria = new ContactSearchCriteria();
   criteria.setSaccountid(new NumberSearchField(SearchField.AND, AppContext.getAccountId()));
   criteria.setCaseId(new NumberSearchField(SearchField.AND, cases.getId()));
   this.setSearchCriteria(criteria);
 }
예제 #23
0
    @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;
    }
  @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);
  }
 private void loadOpportunities() {
   OpportunitySearchCriteria criteria = new OpportunitySearchCriteria();
   criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
   criteria.setContactId(new NumberSearchField(contact.getId()));
   setSearchCriteria(criteria);
 }