コード例 #1
0
  /**
   * Returns true if given structured selection matches the conditions specified in the registry for
   * this action.
   */
  private boolean isEnabledFor(IStructuredSelection ssel) {
    int count = ssel.size();

    if (verifySelectionCount(count) == false) {
      return false;
    }

    // Compare selection to enablement expression.
    if (enablementExpression != null) {
      return enablementExpression.isEnabledFor(ssel);
    }

    // Compare selection to class requirements.
    if (classes.isEmpty()) {
      return true;
    }
    for (Iterator elements = ssel.iterator(); elements.hasNext(); ) {
      Object obj = elements.next();
      if (obj instanceof IAdaptable) {
        IAdaptable element = (IAdaptable) obj;
        if (verifyElement(element) == false) {
          return false;
        }
      } else {
        return false;
      }
    }

    return true;
  }
コード例 #2
0
  /**
   * Returns true if given structured selection matches the conditions specified in the registry for
   * this action.
   */
  private boolean isEnabledFor(ISelection sel) {
    Object obj = sel;
    int count = sel.isEmpty() ? 0 : 1;

    if (verifySelectionCount(count) == false) {
      return false;
    }

    // Compare selection to enablement expression.
    if (enablementExpression != null) {
      return enablementExpression.isEnabledFor(obj);
    }

    // Compare selection to class requirements.
    if (classes.isEmpty()) {
      return true;
    }
    if (obj instanceof IAdaptable) {
      IAdaptable element = (IAdaptable) obj;
      if (verifyElement(element) == false) {
        return false;
      }
    } else {
      return false;
    }

    return true;
  }
コード例 #3
0
 /**
  * Verifies if the given element matches one of the selection requirements. Element must at least
  * pass the type test, and optionally wildcard name match.
  */
 private boolean verifyElement(IAdaptable element) {
   if (classes.isEmpty()) {
     return true;
   }
   for (int i = 0; i < classes.size(); i++) {
     SelectionClass sc = (SelectionClass) classes.get(i);
     if (verifyClass(element, sc.className) == false) {
       continue;
     }
     if (sc.nameFilter == null) {
       return true;
     }
     IWorkbenchAdapter de = (IWorkbenchAdapter) Util.getAdapter(element, IWorkbenchAdapter.class);
     if ((de != null) && verifyNameMatch(de.getLabel(element), sc.nameFilter)) {
       return true;
     }
   }
   return false;
 }
コード例 #4
0
  /**
   * Returns true if given text selection matches the conditions specified in the registry for this
   * action.
   */
  private boolean isEnabledFor(ISelection sel, int count) {
    if (verifySelectionCount(count) == false) {
      return false;
    }

    // Compare selection to enablement expression.
    if (enablementExpression != null) {
      return enablementExpression.isEnabledFor(sel);
    }

    // Compare selection to class requirements.
    if (classes.isEmpty()) {
      return true;
    }
    for (int i = 0; i < classes.size(); i++) {
      SelectionClass sc = (SelectionClass) classes.get(i);
      if (verifyClass(sel, sc.className)) {
        return true;
      }
    }
    return false;
  }