129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2005 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 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.jface.text.templates.ContextTypeRegistry;
|
|
14
|
131
|
15 import dwtx.jface.text.templates.SimpleTemplateVariableResolver; // packageimport
|
|
16 import dwtx.jface.text.templates.TemplateBuffer; // packageimport
|
|
17 import dwtx.jface.text.templates.TemplateContext; // packageimport
|
|
18 import dwtx.jface.text.templates.TemplateContextType; // packageimport
|
|
19 import dwtx.jface.text.templates.Template; // packageimport
|
|
20 import dwtx.jface.text.templates.TemplateVariable; // packageimport
|
|
21 import dwtx.jface.text.templates.PositionBasedCompletionProposal; // packageimport
|
|
22 import dwtx.jface.text.templates.TemplateException; // packageimport
|
|
23 import dwtx.jface.text.templates.TemplateTranslator; // packageimport
|
|
24 import dwtx.jface.text.templates.DocumentTemplateContext; // packageimport
|
|
25 import dwtx.jface.text.templates.GlobalTemplateVariables; // packageimport
|
|
26 import dwtx.jface.text.templates.InclusivePositionUpdater; // packageimport
|
|
27 import dwtx.jface.text.templates.TemplateProposal; // packageimport
|
|
28 import dwtx.jface.text.templates.JFaceTextTemplateMessages; // packageimport
|
|
29 import dwtx.jface.text.templates.TemplateCompletionProcessor; // packageimport
|
|
30 import dwtx.jface.text.templates.TextTemplateMessages; // packageimport
|
|
31 import dwtx.jface.text.templates.TemplateVariableType; // packageimport
|
|
32 import dwtx.jface.text.templates.TemplateVariableResolver; // packageimport
|
|
33
|
|
34
|
129
|
35 import dwt.dwthelper.utils;
|
|
36
|
|
37 import java.util.Iterator;
|
|
38 import java.util.LinkedHashMap;
|
|
39 import java.util.Map;
|
|
40
|
|
41 /**
|
|
42 * A registry for context types. Editor implementors will usually instantiate a
|
|
43 * registry and configure the context types available in their editor.
|
|
44 * <p>
|
|
45 * In order to pick up templates contributed using the <code>dwtx.ui.editors.templates</code>
|
|
46 * extension point, use a <code>ContributionContextTypeRegistry</code>.
|
|
47 * </p>
|
|
48 *
|
|
49 * @since 3.0
|
|
50 */
|
|
51 public class ContextTypeRegistry {
|
|
52
|
|
53 /** all known context types */
|
146
|
54 private const Map fContextTypes= new LinkedHashMap();
|
129
|
55
|
|
56 /**
|
|
57 * Adds a context type to the registry. If there already is a context type
|
|
58 * with the same ID registered, it is replaced.
|
|
59 *
|
|
60 * @param contextType the context type to add
|
|
61 */
|
|
62 public void addContextType(TemplateContextType contextType) {
|
|
63 fContextTypes.put(contextType.getId(), contextType);
|
|
64 }
|
|
65
|
|
66 /**
|
|
67 * Returns the context type if the id is valid, <code>null</code> otherwise.
|
|
68 *
|
|
69 * @param id the id of the context type to retrieve
|
|
70 * @return the context type if <code>name</code> is valid, <code>null</code> otherwise
|
|
71 */
|
|
72 public TemplateContextType getContextType(String id) {
|
134
|
73 return cast(TemplateContextType) fContextTypes.get(id);
|
129
|
74 }
|
|
75
|
|
76 /**
|
|
77 * Returns an iterator over all registered context types.
|
|
78 *
|
|
79 * @return an iterator over all registered context types
|
|
80 */
|
|
81 public Iterator contextTypes() {
|
|
82 return fContextTypes.values().iterator();
|
|
83 }
|
|
84 }
|