コード例 #1
0
  /**
   * Returns the cheatsheet collection child object corresponding to the passed path (relative to
   * this object), or <code>null</code> if such an object could not be found.
   *
   * @param searchPath org.eclipse.core.runtime.IPath
   * @return CheatSheetCollectionElement
   */
  public CheatSheetCollectionElement findChildCollection(IPath searchPath) {
    Object[] children = getChildren();
    String searchString = searchPath.segment(0);
    for (int i = 0; i < children.length; ++i) {
      CheatSheetCollectionElement currentCategory = (CheatSheetCollectionElement) children[i];
      if (currentCategory.getLabel(null).equals(searchString)) {
        if (searchPath.segmentCount() == 1) return currentCategory;

        return currentCategory.findChildCollection(searchPath.removeFirstSegments(1));
      }
    }

    return null;
  }
コード例 #2
0
 /**
  * Returns this collection's associated cheatsheet object corresponding to the passed id, or
  * <code>null</code> if such an object could not be found.
  */
 public CheatSheetElement findCheatSheet(String searchId, boolean recursive) {
   Object[] cheatsheets = getCheatSheets();
   for (int i = 0; i < cheatsheets.length; ++i) {
     CheatSheetElement currentCheatSheet = (CheatSheetElement) cheatsheets[i];
     if (currentCheatSheet.getID().equals(searchId)) return currentCheatSheet;
   }
   if (!recursive) return null;
   for (Iterator iterator = childCollections.iterator(); iterator.hasNext(); ) {
     CheatSheetCollectionElement child = (CheatSheetCollectionElement) iterator.next();
     CheatSheetElement result = child.findCheatSheet(searchId, true);
     if (result != null) return result;
   }
   return null;
 }
コード例 #3
0
  /** Returns a path representing this collection's ancestor chain. */
  public IPath getPath() {
    if (parent == null) return new Path(ICheatSheetResource.EMPTY_STRING);

    return parent.getPath().append(name);
  }