Mercurial > projects > dwt2
comparison org.eclipse.jface/src/org/eclipse/jface/bindings/keys/KeyLookupFactory.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2005, 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 module org.eclipse.jface.bindings.keys.KeyLookupFactory; | |
14 | |
15 import org.eclipse.jface.bindings.keys.SWTKeyLookup; | |
16 import org.eclipse.jface.bindings.keys.IKeyLookup; | |
17 | |
18 import java.lang.all; | |
19 import java.util.Set; | |
20 | |
21 /** | |
22 * <p> | |
23 * A factory class for <code>ILookup</code> instances. This factory can be | |
24 * used to retrieve instances of look-ups defined by this package. It also | |
25 * allows you to define your own look-up for use in the classes. | |
26 * </p> | |
27 * | |
28 * @since 3.1 | |
29 */ | |
30 public final class KeyLookupFactory { | |
31 | |
32 /** | |
33 * The SWT key look-up defined by this package. | |
34 */ | |
35 private static SWTKeyLookup SWT_KEY_LOOKUP; | |
36 | |
37 /** | |
38 * The instance that should be used by <code>KeyStroke</code> in | |
39 * converting string representations to instances. | |
40 */ | |
41 private static IKeyLookup defaultLookup; | |
42 | |
43 private static void check_staticthis(){ | |
44 if( SWT_KEY_LOOKUP is null ){ | |
45 synchronized{ | |
46 if( SWT_KEY_LOOKUP is null ){ | |
47 SWT_KEY_LOOKUP = new SWTKeyLookup(); | |
48 defaultLookup = SWT_KEY_LOOKUP; | |
49 } | |
50 } | |
51 } | |
52 } | |
53 | |
54 /** | |
55 * Provides an instance of <code>SWTKeyLookup</code>. | |
56 * | |
57 * @return The SWT look-up table for key stroke format information; never | |
58 * <code>null</code>. | |
59 */ | |
60 public static final IKeyLookup getSWTKeyLookup() { | |
61 check_staticthis(); | |
62 return SWT_KEY_LOOKUP; | |
63 } | |
64 | |
65 /** | |
66 * An accessor for the current default look-up. | |
67 * | |
68 * @return The default look-up; never <code>null</code>. | |
69 */ | |
70 public static final IKeyLookup getDefault() { | |
71 check_staticthis(); | |
72 return defaultLookup; | |
73 } | |
74 | |
75 /** | |
76 * Sets the default look-up. | |
77 * | |
78 * @param defaultLookup | |
79 * the default look-up. Must not be <code>null</code>. | |
80 */ | |
81 public static final void setDefault(IKeyLookup defaultLookup) { | |
82 check_staticthis(); | |
83 if (defaultLookup is null) { | |
84 throw new NullPointerException("The look-up must not be null"); //$NON-NLS-1$ | |
85 } | |
86 | |
87 KeyLookupFactory.defaultLookup = defaultLookup; | |
88 } | |
89 | |
90 /** | |
91 * This class should not be instantiated. | |
92 */ | |
93 private this() { | |
94 // Not to be constructred. | |
95 } | |
96 } |