コード例 #1
0
  private void deleteProductDeploy(EntityViewPart view) {
    try {
      String[] ids = this.getSelectedIDs();
      for (int i = 0; i < ids.length; i++) {
        Map parameters = new HashMap();
        parameters.put("dp_id", ids[i]);
        String[] sqls =
            new String[] {
              "com.hhh.platform.ops.sql.ops_pd_deployMapper.deleteDeploy",
              "com.hhh.platform.ops.sql.ops_log_exceptionMapper.deleteLog",
              "com.hhh.platform.ops.sql.ops_log_performanceMapper.deleteLog",
              "com.hhh.platform.ops.sql.ops_log_runMapper.deleteLog"
            };
        DaoUtil.delete(sqls, new Map[] {parameters, parameters, parameters, parameters});
        StructuredViewer viewer = this.getViewer();
        TableViewer viewer1 = (CheckboxTableViewerWithDoubleClick) viewer;
        TableModel tableModel = (TableModel) viewer1.getInput();

        TableRowModel updateRow = (TableRowModel) this.getSelectedElements()[i];
        tableModel.removeTableRows(new Object[] {updateRow});
        viewer1.refresh(tableModel, true);
      }
    } catch (Exception e) {
      MessageUtil.showErrorDialog(e, log, "删除的过程中发生异常", MessageUtil.ERROR_TYPE_OPERATION);
    }
  }
コード例 #2
0
  /** 增删改操作 */
  @Override
  public Object execute(ExecutionEvent event, EntityViewPart view, String operationID) {
    if (operationID.equals(OPSConstants.ADD_DEPLOY)) {
      ProductDeployDialog dialog = new ProductDeployDialog(operationID, this);
      dialog.setTitleText("新增部署信息");
      dialog.open();
    } else if (operationID.equals(OPSConstants.UPDATE_DEPLOY)) {
      if (!this.isOnlyOneSelected(view)) {
        return null;
      }

      TableRowModel model = (TableRowModel) this.getSelectedElements()[0];
      String addUser = (String) model.getData().get("a.dp_user");
      HttpSession session = RWT.getUISession().getHttpSession();
      boolean is_admin = (Boolean) session.getAttribute(FrameworkConstants.IS_ADMIN);
      if (!is_admin) {
        String account = OPSUtil.getUserNameAndAccount();
        if (account != null && !account.equals(addUser)) {
          MessageUtil.showMessageDialog(
              "抱歉,您不是该信息的部署人,不能修改或删除。", MessageUtil.MESSAGE_DIALOG_TYPE_INFO);
          return null;
        }
      }

      ProductDeployDialog dialog = new ProductDeployDialog(operationID, this);
      dialog.setTitleText("修改部署信息");
      dialog.open();
    } else if (operationID.equals(OPSConstants.READ_DEPLOY)) {
      if (!this.isOnlyOneSelected(view)) {
        return null;
      }
      ProductDeployDialog dialog = new ProductDeployDialog(operationID, this);
      dialog.setTitleText("查看部署信息");
      dialog.open();
    } else if (operationID.equals(OPSConstants.DELETE_DEPLOY)) {
      if (!this.isOnlyOneSelected(view)) {
        return null;
      }

      TableRowModel model = (TableRowModel) this.getSelectedElements()[0];
      String addUser = (String) model.getData().get("a.dp_user");
      HttpSession session = RWT.getUISession().getHttpSession();
      boolean is_admin = (Boolean) session.getAttribute(FrameworkConstants.IS_ADMIN);
      if (!is_admin) {
        String account = OPSUtil.getUserNameAndAccount();
        if (account != null && !account.equals(addUser)) {
          MessageUtil.showMessageDialog(
              "抱歉,您不是该信息的部署人,您不能修改或删除。", MessageUtil.MESSAGE_DIALOG_TYPE_INFO);
          return null;
        }
      }

      boolean result =
          MessageDialog.openConfirm(
              view.getSite().getShell(), "系统提示", "删除部署信息会影响监控的数据获取,确定删除部署信息?");
      if (!result) {
        return null;
      }
      deleteProductDeploy(view);
    }
    return null;
  }