KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > keys > KeyFormatterFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 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
12 package org.eclipse.ui.keys;
13
14 import org.eclipse.ui.internal.keys.CompactKeyFormatter;
15 import org.eclipse.ui.internal.keys.EmacsKeyFormatter;
16 import org.eclipse.ui.internal.keys.FormalKeyFormatter;
17
18 /**
19  * A cache for formatters. It keeps a few instances of pre-defined instances of
20  * <code>IKeyFormatter</code> available for use. It also allows the default
21  * formatter to be changed.
22  *
23  * @deprecated Please use org.eclipse.jface.bindings.keys.KeyFormatterFactory
24  * @since 3.0
25  * @see org.eclipse.ui.keys.IKeyFormatter
26  */

27 public final class KeyFormatterFactory {
28     private static final IKeyFormatter COMPACT_KEY_FORMATTER = new CompactKeyFormatter();
29
30     private static final IKeyFormatter FORMAL_KEY_FORMATTER = new FormalKeyFormatter();
31
32     private static final IKeyFormatter EMACS_KEY_FORMATTER = new EmacsKeyFormatter();
33
34     private static IKeyFormatter defaultKeyFormatter = FORMAL_KEY_FORMATTER;
35
36     /**
37      * Provides an instance of <code>CompactKeyFormatter</code>.
38      *
39      * @return The compact formatter; never <code>null</code>.
40      */

41     public static final IKeyFormatter getCompactKeyFormatter() {
42         return COMPACT_KEY_FORMATTER;
43     }
44
45     /**
46      * An accessor for the current default key formatter.
47      *
48      * @return The default formatter; never <code>null</code>.
49      */

50     public static IKeyFormatter getDefault() {
51         return defaultKeyFormatter;
52     }
53
54     /**
55      * Provides an instance of <code>EmacsKeyFormatter</code>.
56      *
57      * @return The Xemacs formatter; never <code>null</code>.
58      */

59     public static IKeyFormatter getEmacsKeyFormatter() {
60         return EMACS_KEY_FORMATTER;
61     }
62
63     /**
64      * Provides an instance of <code>FormalKeyFormatter</code>.
65      *
66      * @return The formal formatter; never <code>null</code>.
67      */

68     public static IKeyFormatter getFormalKeyFormatter() {
69         return FORMAL_KEY_FORMATTER;
70     }
71
72     /**
73      * Sets the default key formatter.
74      *
75      * @param defaultKeyFormatter
76      * the default key formatter. Must not be <code>null</code>.
77      */

78     public static void setDefault(IKeyFormatter defaultKeyFormatter) {
79         if (defaultKeyFormatter == null) {
80             throw new NullPointerException JavaDoc();
81         }
82
83         KeyFormatterFactory.defaultKeyFormatter = defaultKeyFormatter;
84     }
85
86     private KeyFormatterFactory() {
87         // Not to be constructred.
88
}
89 }
90
Popular Tags