Source Code Cross Referenced for WorkbenchContextSupport.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » contexts » 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.contexts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2003, 2006 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.contexts;
011:
012:        import java.util.Collection;
013:        import java.util.HashMap;
014:        import java.util.Iterator;
015:        import java.util.Map;
016:
017:        import org.eclipse.core.commands.contexts.ContextManager;
018:        import org.eclipse.swt.widgets.Shell;
019:        import org.eclipse.ui.ISources;
020:        import org.eclipse.ui.LegacyHandlerSubmissionExpression;
021:        import org.eclipse.ui.contexts.EnabledSubmission;
022:        import org.eclipse.ui.contexts.IContextActivation;
023:        import org.eclipse.ui.contexts.IContextManager;
024:        import org.eclipse.ui.contexts.IContextService;
025:        import org.eclipse.ui.contexts.IWorkbenchContextSupport;
026:        import org.eclipse.ui.internal.Workbench;
027:        import org.eclipse.ui.keys.IBindingService;
028:
029:        /**
030:         * Provides support for contexts within the workbench -- including key bindings,
031:         * and some default contexts for shell types.
032:         * 
033:         * @since 3.0
034:         */
035:        public class WorkbenchContextSupport implements 
036:                IWorkbenchContextSupport {
037:
038:            /**
039:             * The map of activations that have been given to the handler service (<code>IHandlerActivation</code>),
040:             * indexed by the submissions (<code>HandlerSubmission</code>). This map
041:             * should be <code>null</code> if there are no such activations.
042:             */
043:            private Map activationsBySubmission = null;
044:
045:            /**
046:             * The binding service for the workbench. This value is never
047:             * <code>null</code>.
048:             */
049:            private IBindingService bindingService;
050:
051:            /**
052:             * The context service for the workbench. This value is never
053:             * <code>null</code>.
054:             */
055:            private IContextService contextService;
056:
057:            /**
058:             * The legacy context manager supported by this application.
059:             */
060:            private ContextManagerLegacyWrapper contextManagerWrapper;
061:
062:            /**
063:             * The workbench for which context support is being provided. This value
064:             * must not be <code>null</code>.
065:             */
066:            private final Workbench workbench;
067:
068:            /**
069:             * Constructs a new instance of <code>WorkbenchCommandSupport</code>.
070:             * This attaches the key binding support, and adds a global shell activation
071:             * filter.
072:             * 
073:             * @param workbenchToSupport
074:             *            The workbench that needs to be supported by this instance;
075:             *            must not be <code>null</code>.
076:             * @param contextManager
077:             *            The context manager to be wrappered; must not be
078:             *            <code>null</code>.
079:             */
080:            public WorkbenchContextSupport(final Workbench workbenchToSupport,
081:                    final ContextManager contextManager) {
082:                workbench = workbenchToSupport;
083:                contextService = (IContextService) workbench
084:                        .getService(IContextService.class);
085:                bindingService = (IBindingService) workbench
086:                        .getService(IBindingService.class);
087:                contextManagerWrapper = ContextManagerFactory
088:                        .getContextManagerWrapper(contextManager);
089:            }
090:
091:            public final void addEnabledSubmission(
092:                    final EnabledSubmission enabledSubmission) {
093:                /*
094:                 * Create the source priorities based on the conditions mentioned in the
095:                 * submission.
096:                 */
097:                int sourcePriorities = 0;
098:                if (enabledSubmission.getActivePartId() != null) {
099:                    sourcePriorities |= ISources.ACTIVE_PART_ID;
100:                }
101:                if (enabledSubmission.getActiveShell() != null) {
102:                    sourcePriorities |= (ISources.ACTIVE_SHELL | ISources.ACTIVE_WORKBENCH_WINDOW);
103:                }
104:                if (enabledSubmission.getActiveWorkbenchPartSite() != null) {
105:                    sourcePriorities |= ISources.ACTIVE_SITE;
106:                }
107:
108:                final IContextActivation activation = contextService
109:                        .activateContext(enabledSubmission.getContextId(),
110:                                new LegacyHandlerSubmissionExpression(
111:                                        enabledSubmission.getActivePartId(),
112:                                        enabledSubmission.getActiveShell(),
113:                                        enabledSubmission
114:                                                .getActiveWorkbenchPartSite()));
115:                if (activationsBySubmission == null) {
116:                    activationsBySubmission = new HashMap();
117:                }
118:                activationsBySubmission.put(enabledSubmission, activation);
119:            }
120:
121:            public final void addEnabledSubmissions(
122:                    final Collection enabledSubmissions) {
123:                final Iterator submissionItr = enabledSubmissions.iterator();
124:                while (submissionItr.hasNext()) {
125:                    addEnabledSubmission((EnabledSubmission) submissionItr
126:                            .next());
127:                }
128:            }
129:
130:            public final IContextManager getContextManager() {
131:                return contextManagerWrapper;
132:            }
133:
134:            public final int getShellType(Shell shell) {
135:                return contextService.getShellType(shell);
136:            }
137:
138:            public final boolean isKeyFilterEnabled() {
139:                return bindingService.isKeyFilterEnabled();
140:            }
141:
142:            public final void openKeyAssistDialog() {
143:                bindingService.openKeyAssistDialog();
144:            }
145:
146:            public final boolean registerShell(final Shell shell, final int type) {
147:                return contextService.registerShell(shell, type);
148:            }
149:
150:            public final void removeEnabledSubmission(
151:                    final EnabledSubmission enabledSubmission) {
152:                if (activationsBySubmission == null) {
153:                    return;
154:                }
155:
156:                final Object value = activationsBySubmission
157:                        .remove(enabledSubmission);
158:                if (value instanceof  IContextActivation) {
159:                    final IContextActivation activation = (IContextActivation) value;
160:                    contextService.deactivateContext(activation);
161:                }
162:            }
163:
164:            public final void removeEnabledSubmissions(
165:                    final Collection enabledSubmissions) {
166:                final Iterator submissionItr = enabledSubmissions.iterator();
167:                while (submissionItr.hasNext()) {
168:                    removeEnabledSubmission((EnabledSubmission) submissionItr
169:                            .next());
170:                }
171:            }
172:
173:            public final void setKeyFilterEnabled(final boolean enabled) {
174:                bindingService.setKeyFilterEnabled(enabled);
175:            }
176:
177:            public final boolean unregisterShell(final Shell shell) {
178:                return contextService.unregisterShell(shell);
179:            }
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.