Пример #1
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));
 }
 private StreamResource buildStreamSource(ReportExportType exportType) {
   List fields =
       Arrays.asList(
           TaskTableFieldDef.taskname(),
           TaskTableFieldDef.status(),
           TaskTableFieldDef.duedate(),
           TaskTableFieldDef.percentagecomplete(),
           TaskTableFieldDef.startdate(),
           TaskTableFieldDef.assignee(),
           TaskTableFieldDef.billableHours(),
           TaskTableFieldDef.nonBillableHours());
   SimpleReportTemplateExecutor reportTemplateExecutor =
       new SimpleReportTemplateExecutor.AllItems<>(
           "Tasks",
           new RpFieldsBuilder(fields),
           exportType,
           SimpleTask.class,
           ApplicationContextUtil.getSpringBean(ProjectTaskService.class));
   ReportStreamSource streamSource =
       new ReportStreamSource(reportTemplateExecutor) {
         @Override
         protected Map<String, Object> initReportParameters() {
           Map<String, Object> parameters = new HashMap<>();
           parameters.put("siteUrl", AppContext.getSiteUrl());
           parameters.put(SimpleReportTemplateExecutor.CRITERIA, baseCriteria);
           return parameters;
         }
       };
   return new StreamResource(streamSource, exportType.getDefaultFileName());
 }
Пример #3
0
 @Override
 protected void updateTimeRemain(double newValue) {
   ProjectTaskService taskService =
       ApplicationContextUtil.getSpringBean(ProjectTaskService.class);
   bean.setRemainestimate(newValue);
   taskService.updateWithSession(bean, AppContext.getUsername());
 }
Пример #4
0
  public MessageListViewImpl() {
    super();
    this.setWidth("100%");
    this.setMargin(true);

    this.topMessagePanel = new TopMessagePanel();
    this.topMessagePanel.setWidth("100%");

    this.topMessagePanel
        .getSearchHandlers()
        .addSearchHandler(
            new SearchHandler<MessageSearchCriteria>() {
              @Override
              public void onSearch(final MessageSearchCriteria criteria) {
                MessageListViewImpl.this.tableItem.setSearchCriteria(criteria);
              }
            });
    this.addComponent(this.topMessagePanel);
    this.tableItem =
        new DefaultBeanPagedList<MessageService, MessageSearchCriteria, SimpleMessage>(
            ApplicationContextUtil.getSpringBean(MessageService.class),
            new MessageRowDisplayHandler());
    this.tableItem.setStyleName("message-list");
    this.addComponent(this.tableItem);
  }
Пример #5
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();
    }
  }
Пример #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(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();
    }
  }
Пример #8
0
  private void deleteRelatedComments(int projectId) {
    log.debug("Delete related comments");
    CommentMapper commentMapper = ApplicationContextUtil.getSpringBean(CommentMapper.class);

    CommentExample ex = new CommentExample();
    ex.createCriteria().andExtratypeidEqualTo(projectId);
    commentMapper.deleteByExample(ex);
  }
Пример #9
0
  private void deleteProjectFiles(int accountid, int projectId) {
    log.debug("Delete files of project {}", projectId);

    ResourceService resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);

    String rootPath = String.format("%d/project/%d", accountid, projectId);
    resourceService.removeResource(rootPath, "", accountid);
  }
Пример #10
0
  private void deleteProjectActivityStream(int projectId) {
    log.debug("Delete activity stream of project {}", projectId);

    ActivityStreamMapper activityStreamMapper =
        ApplicationContextUtil.getSpringBean(ActivityStreamMapper.class);
    ActivityStreamExample ex = new ActivityStreamExample();
    ex.createCriteria().andExtratypeidEqualTo(projectId).andModuleEqualTo(ModuleNameConstants.PRJ);
    activityStreamMapper.deleteByExample(ex);
  }
Пример #11
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());
    }
  }
Пример #12
0
 public void displayTotalComments(String typeId) {
   this.typeId = typeId;
   CommentService commentService = ApplicationContextUtil.getSpringBean(CommentService.class);
   CommentSearchCriteria searchCriteria = new CommentSearchCriteria();
   searchCriteria.setType(StringSearchField.and(type));
   searchCriteria.setTypeid(StringSearchField.and(typeId));
   this.setCaption(
       AppContext.getMessage(
           GenericI18Enum.TAB_COMMENT, commentService.getTotalCount(searchCriteria)));
 }
Пример #13
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());
   }
 }
  private void queryAndDisplayTasks() {
    wrapBody.removeAllComponents();

    if (GROUP_DUE_DATE.equals(groupByState)) {
      baseCriteria.setOrderFields(
          Arrays.asList(new SearchCriteria.OrderField("deadline", sortDirection)));
      taskGroupOrderComponent = new DueDateOrderComponent();
    } else if (GROUP_START_DATE.equals(groupByState)) {
      baseCriteria.setOrderFields(
          Arrays.asList(new SearchCriteria.OrderField("startdate", sortDirection)));
      taskGroupOrderComponent = new StartDateOrderComponent();
    } else if (PLAIN_LIST.equals(groupByState)) {
      baseCriteria.setOrderFields(
          Arrays.asList(new SearchCriteria.OrderField("lastupdatedtime", sortDirection)));
      taskGroupOrderComponent = new SimpleListOrderComponent();
    } else {
      throw new MyCollabException("Do not support group view by " + groupByState);
    }
    wrapBody.addComponent(taskGroupOrderComponent);
    final ProjectTaskService projectTaskService =
        ApplicationContextUtil.getSpringBean(ProjectTaskService.class);
    int totalTasks = projectTaskService.getTotalCount(baseCriteria);
    taskSearchPanel.setTotalCountNumber(totalTasks);
    currentPage = 0;
    int pages = totalTasks / 20;
    if (currentPage < pages) {
      Button moreBtn =
          new Button(
              "More",
              new Button.ClickListener() {
                @Override
                public void buttonClick(ClickEvent clickEvent) {
                  int totalTasks = projectTaskService.getTotalCount(baseCriteria);
                  int pages = totalTasks / 20;
                  currentPage++;
                  List<SimpleTask> otherTasks =
                      projectTaskService.findPagableListByCriteria(
                          new SearchRequest<>(baseCriteria, currentPage + 1, 20));
                  taskGroupOrderComponent.insertTasks(otherTasks);
                  if (currentPage == pages) {
                    wrapBody.removeComponent(wrapBody.getComponent(1));
                  }
                }
              });
      moreBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
      wrapBody.addComponent(moreBtn);
    }
    List<SimpleTask> tasks =
        projectTaskService.findPagableListByCriteria(
            new SearchRequest<>(baseCriteria, currentPage + 1, 20));
    taskGroupOrderComponent.insertTasks(tasks);
  }
  public ProjectMemberSelectionBox(boolean isNullAllowable) {
    this.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    this.setNullSelectionAllowed(isNullAllowable);

    ProjectMemberSearchCriteria criteria = new ProjectMemberSearchCriteria();
    criteria.setProjectId(new NumberSearchField(CurrentProjectVariables.getProjectId()));
    criteria.setStatus(new StringSearchField(ProjectMemberStatusConstants.ACTIVE));

    ProjectMemberService userService =
        ApplicationContextUtil.getSpringBean(ProjectMemberService.class);
    List<SimpleProjectMember> memberList =
        userService.findPagableListByCriteria(new SearchRequest<>(criteria, 0, Integer.MAX_VALUE));
    loadUserList(memberList);
  }
Пример #17
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();
  }
Пример #18
0
 public static Lock getLock(String lockName) {
   try {
     DistributionLockService lockService =
         ApplicationContextUtil.getSpringBean(DistributionLockService.class);
     Lock lock = lockService.getLock(lockName);
     if (lock == null) {
       return getStaticDefaultLock(lockName);
     } else {
       return lock;
     }
   } catch (Exception e) {
     return getStaticDefaultLock(lockName);
   }
 }
  @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);
  }
Пример #20
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);
    }
Пример #21
0
  private void updateFieldValue(TextField editField) {
    removeComponent(editField);
    addComponent(taskLinkLbl);
    addStyleName("editable-field");
    String newValue = editField.getValue();
    if (StringUtils.isNotBlank(newValue) && !newValue.equals(task.getTaskname())) {
      task.setTaskname(newValue);
      taskLinkLbl.setValue(buildTaskLink());
      ProjectTaskService taskService =
          ApplicationContextUtil.getSpringBean(ProjectTaskService.class);
      taskService.updateWithSession(task, AppContext.getUsername());
    }

    isRead = !isRead;
  }
        @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);
        }
  public FileSearchResultComponent() {
    this.resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);

    final CssLayout headerWrapper = new CssLayout();
    headerWrapper.setWidth("100%");
    headerWrapper.addStyleName(UIConstants.THEME_COMP_HEADER);

    final HorizontalLayout headerLayout = new HorizontalLayout();
    headerLayout.setWidth("100%");
    headerLayout.setSpacing(true);

    headerWrapper.addComponent(headerLayout);
    this.addComponent(headerWrapper);

    final Embedded headerIcon = new Embedded();
    headerIcon.setSource(MyCollabResource.newResource("icons/16/search.png"));
    headerLayout.addComponent(headerIcon);
    headerLayout.setComponentAlignment(headerIcon, Alignment.MIDDLE_LEFT);

    this.searchHeader = new Label();
    headerLayout.addComponent(this.searchHeader);
    headerLayout.setComponentAlignment(this.searchHeader, Alignment.MIDDLE_LEFT);
    headerLayout.setExpandRatio(this.searchHeader, 1.0f);

    final Button backButton =
        new Button(
            "Back to dashboard",
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(final ClickEvent event) {
                backView();
              }
            });
    backButton.addStyleName(UIConstants.THEME_BLUE_LINK);
    headerLayout.addComponent(backButton);

    this.resourceTable = new ResourceTableDisplay();
    this.resourceTable.setWidth("100%");

    this.bodyLayout = new VerticalLayout();
    this.bodyLayout.addComponent(this.resourceTable);
    this.addComponent(this.bodyLayout);
    this.setMargin(true);
  }
Пример #24
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();
   }
 }
Пример #25
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();
  }
  private void constructHeader() {
    CssLayout headerWrapper = new CssLayout();
    headerWrapper.setWidth("100%");
    headerWrapper.addStyleName("taskgroup-header");

    MHorizontalLayout header = new MHorizontalLayout().withWidth("100%");
    Label headerLbl = new Label("All Tasks");
    headerLbl.setStyleName("h2");
    header.with(headerLbl).withAlign(headerLbl, Alignment.MIDDLE_LEFT).expand(headerLbl);

    Button backToListBtn =
        new Button(
            "Back to dashboard",
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(Button.ClickEvent event) {
                EventBusFactory.getInstance()
                    .post(new TaskListEvent.GotoTaskListScreen(this, null));
              }
            });
    backToListBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    header.addComponent(backToListBtn);
    header.setComponentAlignment(backToListBtn, Alignment.MIDDLE_RIGHT);

    Button saveOrderBtn =
        new Button(
            AppContext.getMessage(GenericI18Enum.BUTTON_SAVE),
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(Button.ClickEvent event) {
                EventBusFactory.getInstance()
                    .post(new TaskListEvent.SaveReoderTaskList(event, changeSet));
              }
            });
    saveOrderBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    saveOrderBtn.setIcon(FontAwesome.SAVE);
    header.with(saveOrderBtn).withAlign(saveOrderBtn, Alignment.MIDDLE_RIGHT);

    headerWrapper.addComponent(header);

    this.addComponent(headerWrapper);

    final DDVerticalLayout ddLayout = new DDVerticalLayout();
    ddLayout.addStyleName("taskgroup-reorder");
    ddLayout.setComponentVerticalDropRatio(0.3f);
    ddLayout.setDragMode(LayoutDragMode.CLONE);
    ddLayout.setDropHandler(
        new DropHandler() {
          private static final long serialVersionUID = 1L;

          @Override
          public AcceptCriterion getAcceptCriterion() {
            return new Not(VerticalLocationIs.MIDDLE);
          }

          @Override
          public void drop(DragAndDropEvent event) {
            LayoutBoundTransferable transferable =
                (LayoutBoundTransferable) event.getTransferable();

            DDVerticalLayout.VerticalLayoutTargetDetails details =
                (DDVerticalLayout.VerticalLayoutTargetDetails) event.getTargetDetails();

            TaskListComponent comp = (TaskListComponent) transferable.getComponent();

            int currentIndex = ddLayout.getComponentIndex(comp);
            int newIndex = details.getOverIndex();

            ddLayout.removeComponent(comp);

            if (currentIndex > newIndex
                && details.getDropLocation() == VerticalDropLocation.BOTTOM) {
              newIndex++;
            }

            SimpleTaskList dropTaskList = comp.getTaskList();
            dropTaskList.setGroupindex(newIndex);
            changeSet.add(dropTaskList);
            ddLayout.addComponent(comp, newIndex);

            // change affected task list items
            for (int i = 0; i < ddLayout.getComponentCount(); i++) {
              TaskListComponent affectedComp = (TaskListComponent) ddLayout.getComponent(i);
              SimpleTaskList affectedTaskList = affectedComp.getTaskList();
              affectedTaskList.setGroupindex(i);
              changeSet.add(affectedTaskList);
            }
          }
        });

    taskLists =
        new BeanList<>(
            null,
            ApplicationContextUtil.getSpringBean(ProjectTaskListService.class),
            TaskListRowDisplayHandler.class,
            ddLayout);
    this.addComponent(taskLists);
  }
Пример #28
0
 public RoleListPresenter() {
   super(RoleListView.class);
   roleService = ApplicationContextUtil.getSpringBean(RoleService.class);
 }
Пример #29
0
 @Override
 public ISearchableService<RoleSearchCriteria> getSearchService() {
   return ApplicationContextUtil.getSpringBean(RoleService.class);
 }
  @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);
  }