/** * 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; }
/** * 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; }
/** 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); }