diff options
author | Chris Goldthorpe | 2009-06-22 23:20:22 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2009-06-22 23:20:22 +0000 |
commit | 8657a1ce7e50b901a9a2284e7e5e609b4830e2f9 (patch) | |
tree | 3e9eb709811b2ed08c8aad00e589fdf3ec4c5a23 /org.eclipse.ui.cheatsheets | |
parent | f23258e3dea07cf8d610797d45977d6c4bec5d23 (diff) | |
download | eclipse.platform.ua-8657a1ce7e50b901a9a2284e7e5e609b4830e2f9.tar.gz eclipse.platform.ua-8657a1ce7e50b901a9a2284e7e5e609b4830e2f9.tar.xz eclipse.platform.ua-8657a1ce7e50b901a9a2284e7e5e609b4830e2f9.zip |
Bug 280810 [CheatSheet] Adding a parent category to a cheat sheet category removes cheatsheets from this category
Diffstat (limited to 'org.eclipse.ui.cheatsheets')
-rw-r--r-- | org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetRegistryReader.java | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetRegistryReader.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetRegistryReader.java index 8bea4bfe8..3bafaa6be 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetRegistryReader.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetRegistryReader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 IBM Corporation and others. + * Copyright (c) 2002, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -169,7 +169,8 @@ public class CheatSheetRegistryReader extends RegistryReader implements IRegistr private final String csItemExtension = "cheatSheetItemExtension"; //$NON-NLS-1$ protected Map taskExplorers = new HashMap(); protected Map taskEditors = new HashMap(); - + private Map nestedCategoryIds = new HashMap(); + /** * Create an instance of this class. */ @@ -355,6 +356,7 @@ public class CheatSheetRegistryReader extends RegistryReader implements IRegistr // Traverse down into parent category. if (categoryPath != null) { + nestedCategoryIds.put(category.getId(), category); for (int i = 0; i < categoryPath.length; i++) { CheatSheetCollectionElement tempElement = getChildWithID(parent, categoryPath[i]); if (tempElement == null) { @@ -372,8 +374,13 @@ public class CheatSheetRegistryReader extends RegistryReader implements IRegistr if (test != null) return; - if (parent != null) - createCollectionElement(parent, category.getPluginId(), category.getId(), category.getLabel()); + if (parent != null) { + CheatSheetCollectionElement collectionElement = + createCollectionElement(parent, category.getPluginId(), category.getId(), category.getLabel()); + if (categoryPath != null) { + nestedCategoryIds.put(category.getId(), collectionElement); + } + } } /** @@ -386,7 +393,8 @@ public class CheatSheetRegistryReader extends RegistryReader implements IRegistr */ private void finishCheatSheet(CheatSheetElement element, IConfigurationElement config, CheatSheetCollectionElement result) { CheatSheetCollectionElement currentResult = (CheatSheetCollectionElement) result; - StringTokenizer familyTokenizer = new StringTokenizer(getCategoryStringFor(config), CATEGORY_SEPARATOR); + String category = getCategoryStringFor(config); + StringTokenizer familyTokenizer = new StringTokenizer(category, CATEGORY_SEPARATOR); // use the period-separated sections of the current CheatSheet's category // to traverse through the NamedSolution "tree" that was previously created @@ -396,17 +404,24 @@ public class CheatSheetRegistryReader extends RegistryReader implements IRegistr while (familyTokenizer.hasMoreElements()) { CheatSheetCollectionElement tempCollectionElement = getChildWithID(currentCollectionElement, familyTokenizer.nextToken()); - if (tempCollectionElement == null) { // can't find the path; bump it to uncategorized + if (tempCollectionElement == null) { // can't find the path; look for a simple path + moveToOther = true; break; } currentCollectionElement = tempCollectionElement; } - if (moveToOther) - moveElementToUncategorizedCategory(currentResult, element); - else + if (moveToOther) { + if (nestedCategoryIds.containsKey(category)) { + currentCollectionElement = (CheatSheetCollectionElement) nestedCategoryIds.get(category); + currentCollectionElement.add(element); + } else { + moveElementToUncategorizedCategory(currentResult, element); + } + } else { currentCollectionElement.add(element); + } } /** @@ -422,6 +437,7 @@ public class CheatSheetRegistryReader extends RegistryReader implements IRegistr } deferCheatSheets = null; } + nestedCategoryIds = null; } /** |