Beispiel #1
0
  @Override
  public void run(IAction action) {
    if (project == null) {
      return;
    }
    // 不是初始化的项目不能删除
    DBObject projectData = project.getData();
    if (!DataUtil.isInactive(projectData) && !DataUtil.isInactive(projectData)) {
      MessageDialog.openWarning(
          window.getShell(),
          UIConstants.TEXT_REMOVE_PROJECT,
          UIConstants.MESSAGE_CANNOT_DELETE_PROJECT_NOT_INIT_OR_READY);
      return;
    }

    // 项目管理员和项目创建者可以删除
    if (!DataUtil.isProjectCreator(projectData) && !DataUtil.isProjectAdmin(projectData)) {
      MessageDialog.openWarning(
          window.getShell(),
          UIConstants.TEXT_REMOVE_PROJECT,
          UIConstants.MESSAGE_CANNOT_DELETE_PROJECT_NOT_AUTH);
      return;
    }

    boolean ok =
        MessageDialog.openQuestion(
            window.getShell(),
            UIConstants.TEXT_REMOVE_PROJECT,
            ""
                + project.getText(IDBConstants.FIELD_DESC)
                + UIConstants.MESSAGE_QUESTION_REMOVE_PROJECT);
    if (!ok) return;
    removeUserInformation();
    project.remove();
  }
Beispiel #2
0
  private void removeUserInformation() {
    if (element instanceof ISingleObject) {
      ISingleObject so = (ISingleObject) element;
      DBObject projectData = so.getData();
      ObjectId id = (ObjectId) projectData.get(IDBConstants.FIELD_SYSID);
      DBObject charger = (DBObject) projectData.get(IDBConstants.FIELD_PROJECT_PM);

      DataUtil.saveUserRelationInformation(
          (ObjectId) charger.get(IDBConstants.FIELD_SYSID),
          null,
          IDBConstants.COLLECTION_USER_PROJECT_IN_CHARGED,
          id);
    }
  }