annotate org.eclipse.jface/src/org/eclipse/jface/bindings/Binding.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 6f068362a363
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
1 /*******************************************************************************
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
2 * Copyright (c) 2004, 2008 IBM Corporation and others.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
7 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
8 * Contributors:
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
10 * Port to the D programming language:
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
11 * Frank Benoit <benoit@tionex.de>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
12 *******************************************************************************/
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
13 module org.eclipse.jface.bindings.Binding;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
14
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
15 import org.eclipse.jface.bindings.TriggerSequence;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
16 // import java.io.BufferedWriter;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
17 // import java.io.IOException;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
18 // import java.io.StringWriter;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
19
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
20 import org.eclipse.core.commands.ParameterizedCommand;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
21 import org.eclipse.jface.util.Util;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
22
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
23 import java.lang.all;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
24 import java.util.Set;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
25 import tango.text.convert.Format;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
26
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
27 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
28 * <p>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
29 * A binding is a link between user input and the triggering of a particular
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
30 * command. The most common example of a binding is a keyboard shortcut, but
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
31 * there are also mouse and gesture bindings.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
32 * </p>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
33 * <p>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
34 * Bindings are linked to particular conditions within the application. Some of
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
35 * these conditions change infrequently (e.g., locale, scheme), while some will
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
36 * tend to change quite frequently (e.g., context). This allows the bindings to
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
37 * be tailored to particular situations. For example, a set of bindings may be
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
38 * appropriate only inside a text editor. Or, perhaps, a set of bindings might
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
39 * be appropriate only for a given locale, such as bindings that coexist with
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
40 * the Input Method Editor (IME) on Chinese locales.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
41 * </p>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
42 * <p>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
43 * It is also possible to remove a particular binding. This is typically done as
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
44 * part of user configuration (e.g., user changing keyboard shortcuts). However,
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
45 * it can also be helpful when trying to change a binding on a particular locale
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
46 * or platform. An "unbinding" is really just a binding with no command
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
47 * identifier. For it to unbind a particular binding, it must match that binding
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
48 * in its context identifier and scheme identifier. Subclasses (e.g.,
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
49 * <code>KeyBinding</code>) may require other properties to match (e.g.,
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
50 * <code>keySequence</code>). If these properties match, then this is an
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
51 * unbinding. Note: the locale and platform can be different.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
52 * </p>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
53 * <p>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
54 * For example, imagine you have a key binding that looks like this:
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
55 * </p>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
56 * <code><pre>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
57 * KeyBinding(command, scheme, context, &quot;Ctrl+Shift+F&quot;)
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
58 * </pre></code>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
59 * <p>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
60 * On GTK+, the "Ctrl+Shift+F" interferes with some native behaviour. To change
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
61 * the binding, we first unbind the "Ctrl+Shift+F" key sequence by
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
62 * assigning it a null command on the gtk platform. We then create a new binding
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
63 * that maps the command to the "Esc Ctrl+F" key sequence.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
64 * </p>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
65 * <code><pre>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
66 * KeyBinding("Ctrl+Shift+F",null,scheme,context,null,gtk,null,SYSTEM)
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
67 * KeyBinding("Esc Ctrl+F",parameterizedCommand,scheme,context,null,gtk,SYSTEM)
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
68 * </pre></code>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
69 * <p>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
70 * Bindings are intended to be immutable objects.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
71 * </p>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
72 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
73 * @since 3.1
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
74 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
75 public abstract class Binding {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
76
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
77 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
78 * The constant integer hash code value meaning the hash code has not yet
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
79 * been computed.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
80 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
81 private static const int HASH_CODE_NOT_COMPUTED = -1;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
82
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
83 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
84 * A factor for computing the hash code for all key bindings.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
85 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
86 private final const int HASH_FACTOR = 89;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
87
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
88 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
89 * The type of binding that is defined by the system (i.e., by the
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
90 * application developer). In the case of an application based on the
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
91 * Eclipse workbench, this is the registry.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
92 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
93 public static const int SYSTEM = 0;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
94
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
95 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
96 * The type of binding that is defined by the user (i.e., by the end user of
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
97 * the application). In the case of an application based on the Eclipse
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
98 * workbench, this is the preference store.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
99 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
100 public static const int USER = 1;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
101
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
102 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
103 * The parameterized command to which this binding applies. This value may
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
104 * be <code>null</code> if this binding is meant to "unbind" an existing
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
105 * binding.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
106 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
107 private const ParameterizedCommand command;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
108
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
109 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
110 * The context identifier to which this binding applies. This context must
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
111 * be active before this key binding becomes active. This value will never
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
112 * be <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
113 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
114 private const String contextId;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
115
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
116 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
117 * The hash code for this key binding. This value is computed lazily, and
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
118 * marked as invalid when one of the values on which it is based changes.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
119 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
120 private /+transient+/ int hashCode = HASH_CODE_NOT_COMPUTED;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
121
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
122 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
123 * The locale in which this binding applies. This value may be
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
124 * <code>null</code> if this binding is meant to apply to all locales.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
125 * This string should be in the same format returned by
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
126 * <code>Locale.getDefault().toString()</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
127 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
128 private const String locale;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
129
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
130 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
131 * The platform on which this binding applies. This value may be
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
132 * <code>null</code> if this binding is meant to apply to all platforms.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
133 * This string should be in the same format returned by
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
134 * <code>SWT.getPlatform</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
135 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
136 private const String platform;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
137
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
138 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
139 * The identifier of the scheme in which this binding applies. This value
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
140 * will never be <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
141 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
142 private const String schemeId;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
143
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
144 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
145 * The string representation of this binding. This string is for debugging
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
146 * purposes only, and is not meant to be displayed to the user. This value
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
147 * is computed lazily.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
148 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
149 protected /+transient+/ String string = null;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
150
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
151 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
152 * The type of binding this represents. This is used to distinguish between
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
153 * different priority levels for bindings. For example, in our case,
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
154 * <code>USER</code> bindings override <code>SYSTEM</code> bindings.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
155 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
156 private const int type;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
157
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
158 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
159 * Constructs a new instance of <code>Binding</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
160 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
161 * @param command
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
162 * The parameterized command to which this binding applies; this
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
163 * value may be <code>null</code> if the binding is meant to
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
164 * "unbind" a previously defined binding.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
165 * @param schemeId
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
166 * The scheme to which this binding belongs; this value must not
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
167 * be <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
168 * @param contextId
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
169 * The context to which this binding applies; this value must not
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
170 * be <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
171 * @param locale
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
172 * The locale to which this binding applies; this value may be
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
173 * <code>null</code> if it applies to all locales.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
174 * @param platform
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
175 * The platform to which this binding applies; this value may be
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
176 * <code>null</code> if it applies to all platforms.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
177 * @param windowManager
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
178 * The window manager to which this binding applies; this value
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
179 * may be <code>null</code> if it applies to all window
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
180 * managers. This value is currently ignored.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
181 * @param type
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
182 * The type of binding. This should be either <code>SYSTEM</code>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
183 * or <code>USER</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
184 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
185 protected this(ParameterizedCommand command,
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
186 String schemeId, String contextId, String locale,
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
187 String platform, String windowManager, int type) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
188 if (schemeId is null) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
189 throw new NullPointerException("The scheme cannot be null"); //$NON-NLS-1$
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
190 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
191
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
192 if (contextId is null) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
193 throw new NullPointerException("The context cannot be null"); //$NON-NLS-1$
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
194 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
195
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
196 if ((type !is SYSTEM) && (type !is USER)) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
197 throw new IllegalArgumentException(
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
198 "The type must be SYSTEM or USER"); //$NON-NLS-1$
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
199 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
200
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
201 this.command = command;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
202 this.schemeId = schemeId.intern();
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
203 this.contextId = contextId.intern();
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
204 this.locale = (locale is null) ? null : locale.intern();
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
205 this.platform = (platform is null) ? null : platform.intern();
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
206 this.type = type;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
207 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
208
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
209 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
210 * Tests whether this binding is intended to delete another binding. The
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
211 * receiver must have a <code>null</code> command identifier.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
212 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
213 * @param binding
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
214 * The binding to test; must not be <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
215 * This binding must be a <code>SYSTEM</code> binding.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
216 * @return <code>true</code> if the receiver deletes the binding defined by
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
217 * the argument.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
218 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
219 final bool deletes(Binding binding) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
220 bool deletes = true;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
221 deletes &= Util.opEquals(getContextId(), binding.getContextId());
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
222 deletes &= Util.opEquals(getTriggerSequence(), binding
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
223 .getTriggerSequence());
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
224 if (getLocale() !is null) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
225 deletes &= !Util.opEquals(getLocale(), binding.getLocale());
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
226 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
227 if (getPlatform() !is null) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
228 deletes &= !Util.opEquals(getPlatform(), binding.getPlatform());
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
229 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
230 deletes &= (binding.getType() is SYSTEM);
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
231 deletes &= Util.opEquals(getParameterizedCommand(), null);
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
232
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
233 return deletes;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
234 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
235
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
236 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
237 * Tests whether this binding is equal to another object. Bindings are only
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
238 * equal to other bindings with equivalent values.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
239 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
240 * @param object
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
241 * The object with which to compare; may be <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
242 * @return <code>true</code> if the object is a binding with equivalent
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
243 * values for all of its properties; <code>false</code> otherwise.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
244 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
245 public final override int opEquals( Object object) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
246 if (this is object) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
247 return true;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
248
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
249 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
250 if (!(cast(Binding)object )) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
251 return false;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
252 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
253
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
254 Binding binding = cast(Binding) object;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
255 if (!Util.opEquals(getParameterizedCommand(), binding
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
256 .getParameterizedCommand())) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
257 return false;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
258 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
259 if (!Util.opEquals(getContextId(), binding.getContextId())) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
260 return false;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
261 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
262 if (!Util.opEquals(getTriggerSequence(), binding.getTriggerSequence())) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
263 return false;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
264 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
265 if (!Util.opEquals(getLocale(), binding.getLocale())) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
266 return false;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
267 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
268 if (!Util.opEquals(getPlatform(), binding.getPlatform())) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
269 return false;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
270 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
271 if (!Util.opEquals(getSchemeId(), binding.getSchemeId())) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
272 return false;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
273 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
274 return (getType() is binding.getType());
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
275 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
276
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
277 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
278 * Returns the parameterized command to which this binding applies. If the
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
279 * identifier is <code>null</code>, then this binding is "unbinding" an
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
280 * existing binding.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
281 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
282 * @return The fully-parameterized command; may be <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
283 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
284 public final ParameterizedCommand getParameterizedCommand() {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
285 return command;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
286 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
287
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
288 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
289 * Returns the identifier of the context in which this binding applies.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
290 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
291 * @return The context identifier; never <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
292 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
293 public final String getContextId() {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
294 return contextId;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
295 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
296
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
297 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
298 * Returns the locale in which this binding applies. If the locale is
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
299 * <code>null</code>, then this binding applies to all locales. This
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
300 * string is the same format as returned by
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
301 * <code>Locale.getDefault().toString()</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
302 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
303 * @return The locale; may be <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
304 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
305 public final String getLocale() {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
306 return locale;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
307 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
308
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
309 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
310 * Returns the platform on which this binding applies. If the platform is
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
311 * <code>null</code>, then this binding applies to all platforms. This
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
312 * string is the same format as returned by <code>SWT.getPlatform()</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
313 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
314 * @return The platform; may be <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
315 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
316 public final String getPlatform() {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
317 return platform;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
318 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
319
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
320 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
321 * Returns the identifier of the scheme in which this binding applies.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
322 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
323 * @return The scheme identifier; never <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
324 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
325 public final String getSchemeId() {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
326 return schemeId;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
327 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
328
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
329 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
330 * Returns the sequence of trigger for a given binding. The triggers can be
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
331 * anything, but above all it must be hashable. This trigger sequence is
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
332 * used by the binding manager to distinguish between different bindings.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
333 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
334 * @return The object representing an input event that will trigger this
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
335 * binding; must not be <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
336 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
337 public abstract TriggerSequence getTriggerSequence();
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
338
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
339 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
340 * Returns the type for this binding. As it stands now, this value will
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
341 * either be <code>SYSTEM</code> or <code>USER</code>. In the future,
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
342 * more types might be added.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
343 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
344 * @return The type for this binding.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
345 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
346 public final int getType() {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
347 return type;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
348 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
349
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
350 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
351 * Computes the hash code for this key binding based on all of its
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
352 * attributes.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
353 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
354 * @return The hash code for this key binding.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
355 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
356 public final override hash_t toHash() {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
357 if (hashCode is HASH_CODE_NOT_COMPUTED) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
358 auto HASH_INITIAL = java.lang.all.toHash(Binding.classinfo.name);
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
359 hashCode = HASH_INITIAL;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
360 hashCode = hashCode * HASH_FACTOR
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
361 + Util.toHash(getParameterizedCommand());
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
362 hashCode = hashCode * HASH_FACTOR + Util.toHash(getContextId());
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
363 hashCode = hashCode * HASH_FACTOR
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
364 + Util.toHash(getTriggerSequence());
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
365 hashCode = hashCode * HASH_FACTOR + Util.toHash(getLocale());
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
366 hashCode = hashCode * HASH_FACTOR + Util.toHash(getPlatform());
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
367 hashCode = hashCode * HASH_FACTOR + Util.toHash(getSchemeId());
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
368 hashCode = hashCode * HASH_FACTOR + Util.toHash(getType());
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
369 if (hashCode is HASH_CODE_NOT_COMPUTED) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
370 hashCode++;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
371 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
372 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
373
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
374 return hashCode;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
375 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
376
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
377 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
378 * The string representation of this binding -- for debugging purposes only.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
379 * This string should not be shown to an end user. This should be overridden
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
380 * by subclasses that add properties.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
381 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
382 * @return The string representation; never <code>null</code>.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
383 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
384 public override String toString() {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
385 if (string is null) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
386 string = Format("Binding({},\n\t{},\n\t{},\n\t{},{},{},{})",
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
387 getTriggerSequence().toString(),
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
388 command is null?"":command.toString(),
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
389 schemeId,
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
390 contextId,
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
391 locale is null?"":locale,
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
392 platform is null?"":platform,
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
393 (type is SYSTEM) ? "system" : "user");
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
394 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
395
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
396 return string;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
397 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
398 }