KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > cheatsheets > registry > CheatSheetParameterValues


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.cheatsheets.registry;
12
13 import java.util.Map JavaDoc;
14 import java.util.TreeMap JavaDoc;
15
16 import org.eclipse.core.commands.IParameterValues;
17
18 /**
19  * Provides the parameter values for the open cheat sheet command.
20  *
21  * @since 3.2
22  */

23 public class CheatSheetParameterValues implements IParameterValues {
24
25     public Map JavaDoc getParameterValues() {
26         Map JavaDoc values = new TreeMap JavaDoc();
27
28         CheatSheetCollectionElement cheatSheetCollection = (CheatSheetCollectionElement) CheatSheetRegistryReader
29                 .getInstance().getCheatSheets();
30         populateValues(values, cheatSheetCollection);
31
32         return values;
33     }
34
35     private void populateValues(Map JavaDoc values,
36             CheatSheetCollectionElement cheatSheetCollection) {
37
38         Object JavaDoc[] cheatsheets = cheatSheetCollection.getCheatSheets();
39         for (int i = 0; i < cheatsheets.length; i++) {
40             Object JavaDoc cheatsheet = cheatsheets[i];
41             if (cheatsheet instanceof CheatSheetElement) {
42                 CheatSheetElement element = (CheatSheetElement) cheatsheet;
43                 values.put(element.getLabel(null), element.getID());
44             }
45         }
46
47         Object JavaDoc[] children = cheatSheetCollection.getChildren();
48         for (int i = 0; i < children.length; i++) {
49             Object JavaDoc child = children[i];
50             if (child instanceof CheatSheetCollectionElement) {
51                 populateValues(values, (CheatSheetCollectionElement) child);
52             }
53         }
54     }
55
56 }
57
Popular Tags