Mercurial > projects > dwt-addons
comparison dwtx/jface/bindings/keys/formatting/KeyFormatterFactory.d @ 16:e0f0aaf75edd
PopupDialog, bindings and actions
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 01 Apr 2008 08:00:31 +0200 |
parents | |
children | e10d9c2648be |
comparison
equal
deleted
inserted
replaced
15:db8940420ed8 | 16:e0f0aaf75edd |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2004, 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 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 | |
14 module dwtx.jface.bindings.keys.formatting.KeyFormatterFactory; | |
15 | |
16 import dwtx.jface.bindings.keys.formatting.FormalKeyFormatter; | |
17 import dwtx.jface.bindings.keys.formatting.EmacsKeyFormatter; | |
18 import dwtx.jface.bindings.keys.formatting.IKeyFormatter; | |
19 | |
20 import dwt.dwthelper.utils; | |
21 | |
22 /** | |
23 * <p> | |
24 * A cache for formatters. It keeps a few instances of pre-defined instances of | |
25 * <code>IKeyFormatter</code> available for use. It also allows the default | |
26 * formatter to be changed. | |
27 * </p> | |
28 * | |
29 * @since 3.1 | |
30 * @see dwtx.jface.bindings.keys.formatting.IKeyFormatter | |
31 */ | |
32 public final class KeyFormatterFactory { | |
33 | |
34 /** | |
35 * The formatter that renders key bindings in a platform-dependent manner. | |
36 */ | |
37 private static const IKeyFormatter FORMAL_KEY_FORMATTER; | |
38 | |
39 /** | |
40 * The formatter that renders key bindings in a form similar to XEmacs | |
41 */ | |
42 private static const IKeyFormatter EMACS_KEY_FORMATTER; | |
43 | |
44 /** | |
45 * The default formatter. This is normally the formal key formatter, but can | |
46 * be changed by users of this API. | |
47 */ | |
48 private static IKeyFormatter defaultKeyFormatter; | |
49 | |
50 static this(){ | |
51 FORMAL_KEY_FORMATTER = new FormalKeyFormatter(); | |
52 EMACS_KEY_FORMATTER = new EmacsKeyFormatter(); | |
53 defaultKeyFormatter = FORMAL_KEY_FORMATTER; | |
54 } | |
55 | |
56 /** | |
57 * An accessor for the current default key formatter. | |
58 * | |
59 * @return The default formatter; never <code>null</code>. | |
60 */ | |
61 public static final IKeyFormatter getDefault() { | |
62 return defaultKeyFormatter; | |
63 } | |
64 | |
65 /** | |
66 * Provides an instance of <code>EmacsKeyFormatter</code>. | |
67 * | |
68 * @return The Xemacs formatter; never <code>null</code>. | |
69 */ | |
70 public static final IKeyFormatter getEmacsKeyFormatter() { | |
71 return EMACS_KEY_FORMATTER; | |
72 } | |
73 | |
74 /** | |
75 * Provides an instance of <code>FormalKeyFormatter</code>. | |
76 * | |
77 * @return The formal formatter; never <code>null</code>. | |
78 */ | |
79 public static final IKeyFormatter getFormalKeyFormatter() { | |
80 return FORMAL_KEY_FORMATTER; | |
81 } | |
82 | |
83 /** | |
84 * Sets the default key formatter. | |
85 * | |
86 * @param defaultKeyFormatter | |
87 * the default key formatter. Must not be <code>null</code>. | |
88 */ | |
89 public static final void setDefault(IKeyFormatter defaultKeyFormatter) { | |
90 if (defaultKeyFormatter is null) { | |
91 throw new NullPointerException(); | |
92 } | |
93 | |
94 KeyFormatterFactory.defaultKeyFormatter = defaultKeyFormatter; | |
95 } | |
96 | |
97 /** | |
98 * This class should not be instantiated. | |
99 */ | |
100 private this() { | |
101 // Not to be constructred. | |
102 } | |
103 } |