@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;
  }
Esempio n. 2
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;
  }
  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;
  }