Source Code Cross Referenced for BindingService.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » keys » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » ui workbench » org.eclipse.ui.internal.keys 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal.keys;
011:
012:        import java.io.IOException;
013:        import java.util.Map;
014:
015:        import org.eclipse.core.commands.ParameterizedCommand;
016:        import org.eclipse.core.commands.common.NotDefinedException;
017:        import org.eclipse.jface.bindings.Binding;
018:        import org.eclipse.jface.bindings.BindingManager;
019:        import org.eclipse.jface.bindings.Scheme;
020:        import org.eclipse.jface.bindings.TriggerSequence;
021:        import org.eclipse.jface.bindings.keys.SWTKeySupport;
022:        import org.eclipse.jface.bindings.keys.formatting.KeyFormatterFactory;
023:        import org.eclipse.swt.SWT;
024:        import org.eclipse.swt.widgets.Display;
025:        import org.eclipse.swt.widgets.Listener;
026:        import org.eclipse.ui.commands.ICommandService;
027:        import org.eclipse.ui.internal.Workbench;
028:        import org.eclipse.ui.internal.WorkbenchPlugin;
029:        import org.eclipse.ui.keys.IBindingService;
030:
031:        /**
032:         * <p>
033:         * Provides services related to the binding architecture (e.g., keyboard
034:         * shortcuts) within the workbench. This service can be used to access the
035:         * currently active bindings, as well as the current state of the binding
036:         * architecture.
037:         * </p>
038:         * 
039:         * @since 3.1
040:         */
041:        public final class BindingService implements  IBindingService {
042:
043:            /**
044:             * The binding manager that supports this service. This value is never
045:             * <code>null</code>.
046:             */
047:            private final BindingManager bindingManager;
048:
049:            /**
050:             * The persistence class responsible for bindings.
051:             */
052:            private final BindingPersistence bindingPersistence;
053:
054:            /**
055:             * The key binding support for the contexts. In the workbench, key bindings
056:             * are intimately tied to the context mechanism.
057:             */
058:            private WorkbenchKeyboard keyboard;
059:
060:            /**
061:             * Constructs a new instance of <code>BindingService</code> using a JFace
062:             * binding manager.
063:             * 
064:             * @param bindingManager
065:             *            The bind ing manager to use; must not be <code>null</code>.
066:             * @param commandService
067:             *            The command service providing support for this service; must
068:             *            not be <code>null</code>;
069:             * @param workbench
070:             *            The workbench on which this context service will act; must not
071:             *            be <code>null</code>.
072:             */
073:            public BindingService(final BindingManager bindingManager,
074:                    final ICommandService commandService,
075:                    final Workbench workbench) {
076:                if (bindingManager == null) {
077:                    throw new NullPointerException(
078:                            "Cannot create a binding service with a null manager"); //$NON-NLS-1$
079:                }
080:                if (commandService == null) {
081:                    throw new NullPointerException(
082:                            "Cannot create a binding service with a null command service"); //$NON-NLS-1$
083:                }
084:                this .bindingManager = bindingManager;
085:                this .bindingPersistence = new BindingPersistence(
086:                        bindingManager, commandService);
087:
088:                // Hook up the key binding support.
089:                keyboard = new WorkbenchKeyboard(workbench);
090:                final Display display = workbench.getDisplay();
091:                final Listener listener = keyboard.getKeyDownFilter();
092:                display.addFilter(SWT.KeyDown, listener);
093:                display.addFilter(SWT.Traverse, listener);
094:
095:                // Initialize the key formatter.
096:                KeyFormatterFactory.setDefault(SWTKeySupport
097:                        .getKeyFormatterForPlatform());
098:            }
099:
100:            /**
101:             * TODO Promote this method to API.
102:             * <p>
103:             * Adds a single new binding to the existing array of bindings. If the array
104:             * is currently <code>null</code>, then a new array is created and this
105:             * binding is added to it. This method does not detect duplicates.
106:             * </p>
107:             * <p>
108:             * This method completes in amortized <code>O(1)</code>.
109:             * </p>
110:             * 
111:             * @param binding
112:             *            The binding to be added; must not be <code>null</code>.
113:             */
114:            public final void addBinding(final Binding binding) {
115:                bindingManager.addBinding(binding);
116:            }
117:
118:            public final void dispose() {
119:                bindingPersistence.dispose();
120:            }
121:
122:            public final TriggerSequence[] getActiveBindingsFor(
123:                    final ParameterizedCommand parameterizedCommand) {
124:                return bindingManager
125:                        .getActiveBindingsFor(parameterizedCommand);
126:            }
127:
128:            public final TriggerSequence[] getActiveBindingsFor(
129:                    final String commandId) {
130:                return bindingManager.getActiveBindingsFor(commandId);
131:            }
132:
133:            public final Scheme getActiveScheme() {
134:                return bindingManager.getActiveScheme();
135:            }
136:
137:            public final TriggerSequence getBestActiveBindingFor(
138:                    final String commandId) {
139:                return bindingManager.getBestActiveBindingFor(commandId);
140:            }
141:
142:            public final String getBestActiveBindingFormattedFor(
143:                    final String commandId) {
144:                return bindingManager
145:                        .getBestActiveBindingFormattedFor(commandId);
146:            }
147:
148:            public final Binding[] getBindings() {
149:                return bindingManager.getBindings();
150:            }
151:
152:            public final TriggerSequence getBuffer() {
153:                return keyboard.getBuffer();
154:            }
155:
156:            public final String getDefaultSchemeId() {
157:                return BindingPersistence.getDefaultSchemeId();
158:            }
159:
160:            public final Scheme[] getDefinedSchemes() {
161:                return bindingManager.getDefinedSchemes();
162:            }
163:
164:            /**
165:             * Returns the key binding architecture for the workbench. This method is
166:             * internal, and is only intended for testing. This must not be used by
167:             * clients.
168:             * 
169:             * @return The key binding support; never <code>null</code>.
170:             */
171:            public final WorkbenchKeyboard getKeyboard() {
172:                return keyboard;
173:            }
174:
175:            public final String getLocale() {
176:                return bindingManager.getLocale();
177:            }
178:
179:            public final Map getPartialMatches(final TriggerSequence trigger) {
180:                return bindingManager.getPartialMatches(trigger);
181:            }
182:
183:            public final Binding getPerfectMatch(final TriggerSequence trigger) {
184:                return bindingManager.getPerfectMatch(trigger);
185:            }
186:
187:            public final String getPlatform() {
188:                return bindingManager.getPlatform();
189:            }
190:
191:            public final Scheme getScheme(final String schemeId) {
192:                return bindingManager.getScheme(schemeId);
193:            }
194:
195:            public final boolean isKeyFilterEnabled() {
196:                return keyboard.getKeyDownFilter().isEnabled();
197:            }
198:
199:            public final boolean isPartialMatch(final TriggerSequence sequence) {
200:                return bindingManager.isPartialMatch(sequence);
201:            }
202:
203:            public final boolean isPerfectMatch(final TriggerSequence sequence) {
204:                return bindingManager.isPerfectMatch(sequence);
205:            }
206:
207:            public final void openKeyAssistDialog() {
208:                keyboard.openMultiKeyAssistShell();
209:            }
210:
211:            public final void readRegistryAndPreferences(
212:                    final ICommandService commandService) {
213:                bindingPersistence.read();
214:            }
215:
216:            /**
217:             * Remove the specific binding by identity. Does nothing if the binding is
218:             * not in the manager.
219:             * 
220:             * @param binding
221:             *            The binding to be removed; must not be <code>null</code>.
222:             */
223:            public final void removeBinding(final Binding binding) {
224:                bindingManager.removeBinding(binding);
225:            }
226:
227:            public final void savePreferences(final Scheme activeScheme,
228:                    final Binding[] bindings) throws IOException {
229:                BindingPersistence.write(activeScheme, bindings);
230:                try {
231:                    bindingManager.setActiveScheme(activeScheme);
232:                } catch (final NotDefinedException e) {
233:                    WorkbenchPlugin.log(
234:                            "The active scheme is not currently defined.", //$NON-NLS-1$
235:                            WorkbenchPlugin.getStatus(e));
236:                }
237:                bindingManager.setBindings(bindings);
238:            }
239:
240:            public final void setKeyFilterEnabled(final boolean enabled) {
241:                keyboard.getKeyDownFilter().setEnabled(enabled);
242:            }
243:
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.