01: /*******************************************************************************
02: * Copyright (c) 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.cheatsheets.registry;
11:
12: import java.util.Map;
13: import java.util.TreeMap;
14:
15: import org.eclipse.core.commands.IParameterValues;
16:
17: /**
18: * Provides the parameter values for the open cheat sheet command.
19: *
20: * @since 3.2
21: */
22: public class CheatSheetParameterValues implements IParameterValues {
23:
24: public Map getParameterValues() {
25: Map values = new TreeMap();
26:
27: CheatSheetCollectionElement cheatSheetCollection = (CheatSheetCollectionElement) CheatSheetRegistryReader
28: .getInstance().getCheatSheets();
29: populateValues(values, cheatSheetCollection);
30:
31: return values;
32: }
33:
34: private void populateValues(Map values,
35: CheatSheetCollectionElement cheatSheetCollection) {
36:
37: Object[] cheatsheets = cheatSheetCollection.getCheatSheets();
38: for (int i = 0; i < cheatsheets.length; i++) {
39: Object cheatsheet = cheatsheets[i];
40: if (cheatsheet instanceof CheatSheetElement) {
41: CheatSheetElement element = (CheatSheetElement) cheatsheet;
42: values.put(element.getLabel(null), element.getID());
43: }
44: }
45:
46: Object[] children = cheatSheetCollection.getChildren();
47: for (int i = 0; i < children.length; i++) {
48: Object child = children[i];
49: if (child instanceof CheatSheetCollectionElement) {
50: populateValues(values,
51: (CheatSheetCollectionElement) child);
52: }
53: }
54: }
55:
56: }
|