示例#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();
  }
示例#2
0
  @Override
  public void selectionChanged(IAction action, ISelection selection) {
    if (!selection.isEmpty()) {
      currentSelection = (CascadeObject) ((IStructuredSelection) selection).getFirstElement();
    } else {
      currentSelection = null;
    }
    // 考虑选项和权限
    boolean enable = currentSelection != null;
    if (enable) {
      // 考虑对象类型,在角色类型、用户类型下不可用
      if (DataUtil.isUserObject(currentSelection) || DataUtil.isRoleObject(currentSelection)) {
        enable = false;
      }
    }

    // 考虑权限
    action.setEnabled(enable);
  }
示例#3
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);
    }
  }
示例#4
0
  @Override
  public void run(IAction action) {

    if (currentSelection == null) return;

    // ************************************************************************************************************
    if (!hasAuth()) return;

    // ************************************************************************************************************

    int ok =
        DataUtil.createOBSItemUI(
            view.getSite().getShell(), currentSelection, IDBConstants.VALUE_OBS_TEAMTYPE);

    if (ok == SingleObjectEditorDialog.OK) {
      getViewer().refresh(currentSelection, false);
      getViewer().expandToLevel(currentSelection, AbstractTreeViewer.ALL_LEVELS);
    }
  }
示例#5
0
 @Override
 public void selectionChanged(IAction action, ISelection selection) {
   if (Util.isNullOrEmptySelection(selection)) {
     project = null;
     action.setEnabled(false);
     return;
   } else {
     Object element = ((IStructuredSelection) selection).getFirstElement();
     if (element instanceof ISingleObject) {
       if (DataUtil.isProjectObject((ISingleObject) element)) {
         project = (ISingleObject) element;
         action.setEnabled(true);
         return;
       }
     }
   }
   project = null;
   action.setEnabled(false);
 }