comparison dwtx/jface/bindings/keys/KeyLookupFactory.d @ 16:e0f0aaf75edd

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