01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.keys;
11:
12: import org.eclipse.ui.internal.keys.CompactKeyFormatter;
13: import org.eclipse.ui.internal.keys.EmacsKeyFormatter;
14: import org.eclipse.ui.internal.keys.FormalKeyFormatter;
15:
16: /**
17: * A cache for formatters. It keeps a few instances of pre-defined instances of
18: * <code>IKeyFormatter</code> available for use. It also allows the default
19: * formatter to be changed.
20: *
21: * @deprecated Please use org.eclipse.jface.bindings.keys.KeyFormatterFactory
22: * @since 3.0
23: * @see org.eclipse.ui.keys.IKeyFormatter
24: */
25: public final class KeyFormatterFactory {
26: private static final IKeyFormatter COMPACT_KEY_FORMATTER = new CompactKeyFormatter();
27:
28: private static final IKeyFormatter FORMAL_KEY_FORMATTER = new FormalKeyFormatter();
29:
30: private static final IKeyFormatter EMACS_KEY_FORMATTER = new EmacsKeyFormatter();
31:
32: private static IKeyFormatter defaultKeyFormatter = FORMAL_KEY_FORMATTER;
33:
34: /**
35: * Provides an instance of <code>CompactKeyFormatter</code>.
36: *
37: * @return The compact formatter; never <code>null</code>.
38: */
39: public static final IKeyFormatter getCompactKeyFormatter() {
40: return COMPACT_KEY_FORMATTER;
41: }
42:
43: /**
44: * An accessor for the current default key formatter.
45: *
46: * @return The default formatter; never <code>null</code>.
47: */
48: public static IKeyFormatter getDefault() {
49: return defaultKeyFormatter;
50: }
51:
52: /**
53: * Provides an instance of <code>EmacsKeyFormatter</code>.
54: *
55: * @return The Xemacs formatter; never <code>null</code>.
56: */
57: public static IKeyFormatter getEmacsKeyFormatter() {
58: return EMACS_KEY_FORMATTER;
59: }
60:
61: /**
62: * Provides an instance of <code>FormalKeyFormatter</code>.
63: *
64: * @return The formal formatter; never <code>null</code>.
65: */
66: public static IKeyFormatter getFormalKeyFormatter() {
67: return FORMAL_KEY_FORMATTER;
68: }
69:
70: /**
71: * Sets the default key formatter.
72: *
73: * @param defaultKeyFormatter
74: * the default key formatter. Must not be <code>null</code>.
75: */
76: public static void setDefault(IKeyFormatter defaultKeyFormatter) {
77: if (defaultKeyFormatter == null) {
78: throw new NullPointerException();
79: }
80:
81: KeyFormatterFactory.defaultKeyFormatter = defaultKeyFormatter;
82: }
83:
84: private KeyFormatterFactory() {
85: // Not to be constructred.
86: }
87: }
|