Exemplo n.º 1
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();
    }
  }
Exemplo n.º 2
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();
    }
  }
Exemplo n.º 3
0
  @Override
  protected void buildExtraControls() {
    MButton customizeViewBtn =
        ComponentUtils.createCustomizeViewButton()
            .withListener(
                new Button.ClickListener() {
                  @Override
                  public void buttonClick(ClickEvent clickEvent) {
                    UI.getCurrent()
                        .addWindow(
                            new CaseListCustomizeWindow(CaseListView.VIEW_DEF_ID, tableItem));
                  }
                });
    this.addExtraButton(customizeViewBtn);

    MButton importBtn =
        ComponentUtils.createImportEntitiesButton()
            .withListener(
                new Button.ClickListener() {
                  @Override
                  public void buttonClick(ClickEvent clickEvent) {
                    UI.getCurrent().addWindow(new CaseImportWindow());
                  }
                });
    importBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CASE));

    this.addExtraButton(importBtn);
  }
Exemplo n.º 4
0
  @Override
  protected DefaultMassItemActionHandlersContainer createActionControls() {
    DefaultMassItemActionHandlersContainer container = new DefaultMassItemActionHandlersContainer();

    if (AppContext.canAccess(RolePermissionCollections.CRM_CASE)) {
      container.addActionItem(
          MassItemActionHandler.DELETE_ACTION,
          FontAwesome.TRASH_O,
          "delete",
          AppContext.getMessage(GenericI18Enum.BUTTON_DELETE));
    }

    container.addActionItem(
        MassItemActionHandler.MAIL_ACTION,
        FontAwesome.ENVELOPE_O,
        "mail",
        AppContext.getMessage(GenericI18Enum.BUTTON_MAIL));

    container.addDownloadActionItem(
        MassItemActionHandler.EXPORT_PDF_ACTION,
        FontAwesome.FILE_PDF_O,
        "export",
        "export.pdf",
        AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_PDF));

    container.addDownloadActionItem(
        MassItemActionHandler.EXPORT_EXCEL_ACTION,
        FontAwesome.FILE_EXCEL_O,
        "export",
        "export.xlsx",
        AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_EXCEL));

    container.addDownloadActionItem(
        MassItemActionHandler.EXPORT_CSV_ACTION,
        FontAwesome.FILE_TEXT_O,
        "export",
        "export.csv",
        AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_CSV));

    if (AppContext.canWrite(RolePermissionCollections.CRM_CASE)) {
      container.addActionItem(
          MassItemActionHandler.MASS_UPDATE_ACTION,
          FontAwesome.DATABASE,
          "update",
          AppContext.getMessage(GenericI18Enum.TOOLTIP_MASS_UPDATE));
    }

    return container;
  }
  @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;
  }
Exemplo n.º 6
0
  @Override
  protected void buildExtraControls() {
    Button createAccountBtn =
        new Button(
            AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY),
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(final ClickEvent event) {
                EventBusFactory.getInstance()
                    .post(new OpportunityEvent.GotoAdd(OpportunitySearchPanel.this, null));
              }
            });
    createAccountBtn.setIcon(FontAwesome.PLUS);
    createAccountBtn.setStyleName(UIConstants.BUTTON_ACTION);
    createAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY));
    addHeaderRight(createAccountBtn);
  }
Exemplo n.º 7
0
  @Override
  protected DefaultMassItemActionHandlerContainer createActionControls() {
    DefaultMassItemActionHandlerContainer container = new DefaultMassItemActionHandlerContainer();

    if (AppContext.canAccess(RolePermissionCollections.CRM_ACCOUNT)) {
      container.addDeleteActionItem();
    }

    container.addMailActionItem();
    container.addDownloadPdfActionItem();
    container.addDownloadExcelActionItem();
    container.addDownloadCsvActionItem();

    if (AppContext.canWrite(RolePermissionCollections.CRM_ACCOUNT)) {
      container.addMassUpdateActionItem();
    }

    return container;
  }
Exemplo n.º 8
0
  @SuppressWarnings("serial")
  private void initUI() {
    final SplitButton controlsBtn = new SplitButton();
    controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT));
    controlsBtn.addStyleName(UIConstants.THEME_BLUE_LINK);
    controlsBtn.setCaption("New Contact");
    controlsBtn.setIcon(MyCollabResource.newResource("icons/16/addRecord.png"));
    controlsBtn.addClickListener(
        new SplitButton.SplitButtonClickListener() {
          @Override
          public void splitButtonClick(SplitButton.SplitButtonClickEvent event) {
            fireNewRelatedItem("");
          }
        });
    Button selectBtn =
        new Button(
            "Select from existing contacts",
            new Button.ClickListener() {
              @Override
              public void buttonClick(Button.ClickEvent event) {
                CaseContactSelectionWindow contactsWindow =
                    new CaseContactSelectionWindow(CaseContactListComp.this);
                ContactSearchCriteria criteria = new ContactSearchCriteria();
                criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
                UI.getCurrent().addWindow(contactsWindow);
                contactsWindow.setSearchCriteria(criteria);
                controlsBtn.setPopupVisible(false);
              }
            });
    selectBtn.setIcon(MyCollabResource.newResource("icons/16/select.png"));
    selectBtn.setStyleName("link");

    VerticalLayout buttonControlsLayout = new VerticalLayout();
    buttonControlsLayout.addComponent(selectBtn);
    controlsBtn.setContent(buttonControlsLayout);

    controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT));
    this.addComponent(controlsBtn);

    tableItem =
        new ContactTableDisplay(
            Arrays.asList(
                ContactTableFieldDef.name,
                ContactTableFieldDef.email,
                ContactTableFieldDef.phoneOffice,
                ContactTableFieldDef.account,
                ContactTableFieldDef.action));

    tableItem.addTableListener(
        new ApplicationEventListener<TableClickEvent>() {
          @Override
          public Class<? extends ApplicationEvent> getEventType() {
            return TableClickEvent.class;
          }

          @Override
          public void handle(TableClickEvent event) {
            SimpleContact contact = (SimpleContact) event.getData();
            if ("contactName".equals(event.getFieldName())) {
              EventBus.getInstance()
                  .fireEvent(new ContactEvent.GotoRead(CaseContactListComp.this, contact.getId()));
            }
          }
        });

    tableItem.addGeneratedColumn(
        "id",
        new Table.ColumnGenerator() {
          @Override
          public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleContact contact = (SimpleContact) tableItem.getBeanByIndex(itemId);
            HorizontalLayout controlLayout = new HorizontalLayout();
            Button editBtn =
                new Button(
                    null,
                    new Button.ClickListener() {
                      @Override
                      public void buttonClick(Button.ClickEvent event) {
                        EventBus.getInstance()
                            .fireEvent(
                                new ContactEvent.GotoEdit(CaseContactListComp.this, contact));
                      }
                    });
            editBtn.setStyleName("link");
            editBtn.setIcon(MyCollabResource.newResource("icons/16/edit.png"));
            controlLayout.addComponent(editBtn);

            Button deleteBtn =
                new Button(
                    null,
                    new Button.ClickListener() {
                      @Override
                      public void buttonClick(Button.ClickEvent event) {
                        ConfirmDialogExt.show(
                            UI.getCurrent(),
                            LocalizationHelper.getMessage(
                                GenericI18Enum.DELETE_DIALOG_TITLE,
                                SiteConfiguration.getSiteName()),
                            LocalizationHelper.getMessage(
                                CrmCommonI18nEnum.DIALOG_DELETE_RELATIONSHIP_TITLE),
                            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(ConfirmDialog dialog) {
                                if (dialog.isConfirmed()) {
                                  ContactService contactService =
                                      ApplicationContextUtil.getSpringBean(ContactService.class);
                                  ContactCase associateContact = new ContactCase();
                                  associateContact.setCaseid(cases.getId());
                                  associateContact.setContactid(contact.getId());
                                  contactService.removeContactCaseRelationship(
                                      associateContact, AppContext.getAccountId());
                                  CaseContactListComp.this.refresh();
                                }
                              }
                            });
                      }
                    });
            deleteBtn.setStyleName("link");
            deleteBtn.setIcon(MyCollabResource.newResource("icons/16/delete.png"));
            controlLayout.addComponent(deleteBtn);
            return controlLayout;
          }
        });
    this.addComponent(tableItem);
  }
  public HorizontalLayout createButtonControls(int buttonEnableFlags, final String permissionItem) {
    layout = new HorizontalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setWidth("100%");

    boolean canRead = true;
    boolean canWrite = true;
    boolean canAccess = true;
    if (permissionItem != null) {
      canRead = AppContext.canRead(permissionItem);
      canWrite = AppContext.canWrite(permissionItem);
      canAccess = AppContext.canAccess(permissionItem);
    }

    if ((buttonEnableFlags & BACK_BTN_PRESENTED) == BACK_BTN_PRESENTED) {
      backBtn =
          new Button(
              null,
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                  final T item = previewForm.getBean();
                  previewForm.fireCancelForm(item);
                }
              });
      backBtn.setIcon(MyCollabResource.newResource("icons/16/back.png"));
      backBtn.setDescription("Back to list");
      backBtn.setStyleName("link");
      layout.addComponent(backBtn);
      layout.setComponentAlignment(backBtn, Alignment.MIDDLE_LEFT);
      backBtn.setEnabled(canRead);
    }

    if ((buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) {
      editBtn =
          new Button(
              GenericBeanForm.EDIT_ACTION,
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                  final T item = previewForm.getBean();
                  previewForm.fireEditForm(item);
                }
              });
      editBtn.setIcon(MyCollabResource.newResource("icons/16/edit_white.png"));
      editBtn.setStyleName(UIConstants.THEME_BLUE_LINK);
      editButtons.addComponent(editBtn);
      editButtons.setComponentAlignment(editBtn, Alignment.MIDDLE_CENTER);
      editBtn.setEnabled(canWrite);
    }

    if ((buttonEnableFlags & DELETE_BTN_PRESENTED) == DELETE_BTN_PRESENTED) {
      deleteBtn =
          new Button(
              GenericBeanForm.DELETE_ACTION,
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                  final T item = previewForm.getBean();
                  previewForm.fireDeleteForm(item);
                }
              });
      deleteBtn.setIcon(MyCollabResource.newResource("icons/16/delete2.png"));
      deleteBtn.setStyleName(UIConstants.THEME_BLUE_LINK);
      editButtons.addComponent(deleteBtn);
      editButtons.setComponentAlignment(deleteBtn, Alignment.MIDDLE_CENTER);
      deleteBtn.setEnabled(canAccess);
    }

    if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED) {
      cloneBtn =
          new Button(
              GenericBeanForm.CLONE_ACTION,
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                  final T item = previewForm.getBean();
                  previewForm.fireCloneForm(item);
                }
              });
      cloneBtn.setIcon(MyCollabResource.newResource("icons/16/clone.png"));
      cloneBtn.setStyleName(UIConstants.THEME_BLUE_LINK);
      editButtons.addComponent(cloneBtn);
      editButtons.setComponentAlignment(cloneBtn, Alignment.MIDDLE_CENTER);
      cloneBtn.setEnabled(canWrite);
    }

    layout.addComponent(editButtons);
    layout.setComponentAlignment(editButtons, Alignment.MIDDLE_CENTER);
    layout.setExpandRatio(editButtons, 1.0f);

    if ((buttonEnableFlags & PREVIOUS_BTN_PRESENTED) == PREVIOUS_BTN_PRESENTED) {
      previousItem =
          new Button(
              null,
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                  final T item = previewForm.getBean();
                  previewForm.fireGotoPrevious(item);
                }
              });

      previousItem.setIcon(MyCollabResource.newResource("icons/16/previous.png"));
      previousItem.setStyleName("link");
      previousItem.setDescription("Read previous item");
      layout.addComponent(previousItem);
      layout.setComponentAlignment(previousItem, Alignment.MIDDLE_RIGHT);
      previousItem.setEnabled(canRead);
    }

    if ((buttonEnableFlags & NEXT_BTN_PRESENTED) == NEXT_BTN_PRESENTED) {
      nextItemBtn =
          new Button(
              null,
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                  final T item = previewForm.getBean();
                  previewForm.fireGotoNextItem(item);
                }
              });

      nextItemBtn.setIcon(MyCollabResource.newResource("icons/16/next.png"));
      nextItemBtn.setStyleName("link");
      nextItemBtn.setDescription("Read next item");
      layout.addComponent(nextItemBtn);
      layout.setComponentAlignment(nextItemBtn, Alignment.MIDDLE_RIGHT);
      nextItemBtn.setEnabled(canRead);
    }

    if ((buttonEnableFlags & HISTORY_BTN_PRESENTED) == HISTORY_BTN_PRESENTED) {
      historyBtn =
          new Button(
              null,
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                  previewForm.showHistory();
                }
              });
      historyBtn.setIcon(MyCollabResource.newResource("icons/16/history.png"));
      historyBtn.setStyleName("link");
      historyBtn.setDescription("Show history log");
      layout.addComponent(historyBtn);
      layout.setComponentAlignment(historyBtn, Alignment.MIDDLE_RIGHT);
      historyBtn.setEnabled(canRead);
    }

    return layout;
  }