KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > bindings > keys > KeyLookupFactory


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  *******************************************************************************/

11 package org.eclipse.jface.bindings.keys;
12
13
14 /**
15  * <p>
16  * A factory class for <code>ILookup</code> instances. This factory can be
17  * used to retrieve instances of look-ups defined by this package. It also
18  * allows you to define your own look-up for use in the classes.
19  * </p>
20  *
21  * @since 3.1
22  */

23 public final class KeyLookupFactory {
24
25     /**
26      * The SWT key look-up defined by this package.
27      */

28     private static final SWTKeyLookup SWT_KEY_LOOKUP = new SWTKeyLookup();
29
30     /**
31      * The instance that should be used by <code>KeyStroke</code> in
32      * converting string representations to instances.
33      */

34     private static IKeyLookup defaultLookup = SWT_KEY_LOOKUP;
35
36     /**
37      * Provides an instance of <code>SWTKeyLookup</code>.
38      *
39      * @return The SWT look-up table for key stroke format information; never
40      * <code>null</code>.
41      */

42     public static final IKeyLookup getSWTKeyLookup() {
43         return SWT_KEY_LOOKUP;
44     }
45
46     /**
47      * An accessor for the current default look-up.
48      *
49      * @return The default look-up; never <code>null</code>.
50      */

51     public static final IKeyLookup getDefault() {
52         return defaultLookup;
53     }
54
55     /**
56      * Sets the default look-up.
57      *
58      * @param defaultLookup
59      * the default look-up. Must not be <code>null</code>.
60      */

61     public static final void setDefault(final IKeyLookup defaultLookup) {
62         if (defaultLookup == null) {
63             throw new NullPointerException JavaDoc("The look-up must not be null"); //$NON-NLS-1$
64
}
65
66         KeyLookupFactory.defaultLookup = defaultLookup;
67     }
68
69     /**
70      * This class should not be instantiated.
71      */

72     private KeyLookupFactory() {
73         // Not to be constructred.
74
}
75 }
76
Popular Tags