Mercurial > projects > dwt-addons
comparison dwtx/jface/text/templates/ContextTypeRegistry.d @ 129:eb30df5ca28b
Added JFace Text sources
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 23 Aug 2008 19:10:48 +0200 |
parents | |
children | c4fb132a086c |
comparison
equal
deleted
inserted
replaced
128:8df1d4193877 | 129:eb30df5ca28b |
---|---|
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 | |
15 import dwt.dwthelper.utils; | |
16 | |
17 import java.util.Iterator; | |
18 import java.util.LinkedHashMap; | |
19 import java.util.Map; | |
20 | |
21 /** | |
22 * A registry for context types. Editor implementors will usually instantiate a | |
23 * registry and configure the context types available in their editor. | |
24 * <p> | |
25 * In order to pick up templates contributed using the <code>dwtx.ui.editors.templates</code> | |
26 * extension point, use a <code>ContributionContextTypeRegistry</code>. | |
27 * </p> | |
28 * | |
29 * @since 3.0 | |
30 */ | |
31 public class ContextTypeRegistry { | |
32 | |
33 /** all known context types */ | |
34 private final Map fContextTypes= new LinkedHashMap(); | |
35 | |
36 /** | |
37 * Adds a context type to the registry. If there already is a context type | |
38 * with the same ID registered, it is replaced. | |
39 * | |
40 * @param contextType the context type to add | |
41 */ | |
42 public void addContextType(TemplateContextType contextType) { | |
43 fContextTypes.put(contextType.getId(), contextType); | |
44 } | |
45 | |
46 /** | |
47 * Returns the context type if the id is valid, <code>null</code> otherwise. | |
48 * | |
49 * @param id the id of the context type to retrieve | |
50 * @return the context type if <code>name</code> is valid, <code>null</code> otherwise | |
51 */ | |
52 public TemplateContextType getContextType(String id) { | |
53 return (TemplateContextType) fContextTypes.get(id); | |
54 } | |
55 | |
56 /** | |
57 * Returns an iterator over all registered context types. | |
58 * | |
59 * @return an iterator over all registered context types | |
60 */ | |
61 public Iterator contextTypes() { | |
62 return fContextTypes.values().iterator(); | |
63 } | |
64 } |