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


001:        /*******************************************************************************
002:         * Copyright (c) 2006, 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.commands;
011:
012:        import java.util.ArrayList;
013:        import java.util.Collection;
014:        import java.util.HashSet;
015:        import java.util.Map;
016:        import java.util.Set;
017:
018:        import org.eclipse.core.commands.Category;
019:        import org.eclipse.core.commands.Command;
020:        import org.eclipse.core.commands.IExecutionListener;
021:        import org.eclipse.core.commands.IHandler;
022:        import org.eclipse.core.commands.ParameterType;
023:        import org.eclipse.core.commands.ParameterizedCommand;
024:        import org.eclipse.core.commands.SerializationException;
025:        import org.eclipse.core.commands.common.NotDefinedException;
026:        import org.eclipse.ui.commands.IElementReference;
027:        import org.eclipse.ui.commands.ICommandService;
028:        import org.eclipse.ui.menus.UIElement;
029:
030:        /**
031:         * A command service which delegates almost all responsibility to the parent
032:         * service.
033:         * <p>
034:         * This class is not intended for use outside of the
035:         * <code>org.eclipse.ui.workbench</code> plug-in.
036:         * </p>
037:         * 
038:         * @since 3.2
039:         */
040:        public class SlaveCommandService implements  ICommandService {
041:
042:            private Collection fExecutionListeners = new ArrayList();
043:
044:            /**
045:             * The collection of ICallbackReferences added through this service.
046:             * 
047:             * @since 3.3
048:             */
049:            private Set fCallbackCache = new HashSet();
050:
051:            private ICommandService fParentService;
052:
053:            /**
054:             * The scoping constant added to callback registrations submitted through
055:             * this service.
056:             * 
057:             * @since 3.3
058:             */
059:            private String fScopingName;
060:
061:            /**
062:             * The object to scope. In theory, the service locator that would find this
063:             * service.
064:             * 
065:             * @since 3.3
066:             */
067:            private Object fScopingValue;
068:
069:            /**
070:             * Build the slave service.
071:             * 
072:             * @param parent
073:             *            the parent service. This must not be <code>null</code>.
074:             */
075:            public SlaveCommandService(ICommandService parent,
076:                    String scopeName, Object scopeValue) {
077:                if (parent == null) {
078:                    throw new NullPointerException(
079:                            "The parent command service must not be null"); //$NON-NLS-1$
080:                }
081:                fParentService = parent;
082:                fScopingName = scopeName;
083:                fScopingValue = scopeValue;
084:            }
085:
086:            /*
087:             * (non-Javadoc)
088:             * 
089:             * @see org.eclipse.ui.commands.ICommandService#addExecutionListener(org.eclipse.core.commands.IExecutionListener)
090:             */
091:            public void addExecutionListener(IExecutionListener listener) {
092:                if (!fExecutionListeners.contains(listener)) {
093:                    fExecutionListeners.add(listener);
094:                }
095:                fParentService.addExecutionListener(listener);
096:            }
097:
098:            /*
099:             * (non-Javadoc)
100:             * 
101:             * @see org.eclipse.ui.commands.ICommandService#defineUncategorizedCategory(java.lang.String,
102:             *      java.lang.String)
103:             */
104:            public void defineUncategorizedCategory(String name,
105:                    String description) {
106:                fParentService.defineUncategorizedCategory(name, description);
107:            }
108:
109:            /*
110:             * (non-Javadoc)
111:             * 
112:             * @see org.eclipse.ui.commands.ICommandService#deserialize(java.lang.String)
113:             */
114:            public ParameterizedCommand deserialize(
115:                    String serializedParameterizedCommand)
116:                    throws NotDefinedException, SerializationException {
117:                return fParentService
118:                        .deserialize(serializedParameterizedCommand);
119:            }
120:
121:            /*
122:             * (non-Javadoc)
123:             * 
124:             * @see org.eclipse.ui.services.IDisposable#dispose()
125:             */
126:            public void dispose() {
127:                if (!fExecutionListeners.isEmpty()) {
128:                    Object[] array = fExecutionListeners.toArray();
129:                    for (int i = 0; i < array.length; i++) {
130:                        removeExecutionListener((IExecutionListener) array[i]);
131:                    }
132:                    fExecutionListeners.clear();
133:                }
134:                if (!fCallbackCache.isEmpty()) {
135:                    Object[] array = fCallbackCache.toArray();
136:                    for (int i = 0; i < array.length; i++) {
137:                        unregisterElement((IElementReference) array[i]);
138:                    }
139:                }
140:            }
141:
142:            /*
143:             * (non-Javadoc)
144:             * 
145:             * @see org.eclipse.ui.commands.ICommandService#getCategory(java.lang.String)
146:             */
147:            public Category getCategory(String categoryId) {
148:                return fParentService.getCategory(categoryId);
149:            }
150:
151:            /*
152:             * (non-Javadoc)
153:             * 
154:             * @see org.eclipse.ui.commands.ICommandService#getCommand(java.lang.String)
155:             */
156:            public Command getCommand(String commandId) {
157:                return fParentService.getCommand(commandId);
158:            }
159:
160:            /*
161:             * (non-Javadoc)
162:             * 
163:             * @see org.eclipse.ui.commands.ICommandService#getDefinedCategories()
164:             */
165:            public Category[] getDefinedCategories() {
166:                return fParentService.getDefinedCategories();
167:            }
168:
169:            /*
170:             * (non-Javadoc)
171:             * 
172:             * @see org.eclipse.ui.commands.ICommandService#getDefinedCategoryIds()
173:             */
174:            public Collection getDefinedCategoryIds() {
175:                return fParentService.getDefinedCategoryIds();
176:            }
177:
178:            /*
179:             * (non-Javadoc)
180:             * 
181:             * @see org.eclipse.ui.commands.ICommandService#getDefinedCommandIds()
182:             */
183:            public Collection getDefinedCommandIds() {
184:                return fParentService.getDefinedCommandIds();
185:            }
186:
187:            /*
188:             * (non-Javadoc)
189:             * 
190:             * @see org.eclipse.ui.commands.ICommandService#getDefinedCommands()
191:             */
192:            public Command[] getDefinedCommands() {
193:                return fParentService.getDefinedCommands();
194:            }
195:
196:            /*
197:             * (non-Javadoc)
198:             * 
199:             * @see org.eclipse.ui.commands.ICommandService#getDefinedParameterTypeIds()
200:             */
201:            public Collection getDefinedParameterTypeIds() {
202:                return fParentService.getDefinedParameterTypeIds();
203:            }
204:
205:            /*
206:             * (non-Javadoc)
207:             * 
208:             * @see org.eclipse.ui.commands.ICommandService#getDefinedParameterTypes()
209:             */
210:            public ParameterType[] getDefinedParameterTypes() {
211:                return fParentService.getDefinedParameterTypes();
212:            }
213:
214:            public final String getHelpContextId(final Command command)
215:                    throws NotDefinedException {
216:                return fParentService.getHelpContextId(command);
217:            }
218:
219:            public final String getHelpContextId(final String commandId)
220:                    throws NotDefinedException {
221:                return fParentService.getHelpContextId(commandId);
222:            }
223:
224:            /*
225:             * (non-Javadoc)
226:             * 
227:             * @see org.eclipse.ui.commands.ICommandService#getParameterType(java.lang.String)
228:             */
229:            public ParameterType getParameterType(String parameterTypeId) {
230:                return fParentService.getParameterType(parameterTypeId);
231:            }
232:
233:            /*
234:             * (non-Javadoc)
235:             * 
236:             * @see org.eclipse.ui.commands.ICommandService#readRegistry()
237:             */
238:            public void readRegistry() {
239:                fParentService.readRegistry();
240:            }
241:
242:            /*
243:             * (non-Javadoc)
244:             * 
245:             * @see org.eclipse.ui.commands.ICommandService#removeExecutionListener(org.eclipse.core.commands.IExecutionListener)
246:             */
247:            public void removeExecutionListener(IExecutionListener listener) {
248:                fExecutionListeners.remove(listener);
249:                fParentService.removeExecutionListener(listener);
250:            }
251:
252:            public final void setHelpContextId(final IHandler handler,
253:                    final String helpContextId) {
254:                fParentService.setHelpContextId(handler, helpContextId);
255:            }
256:
257:            /*
258:             * (non-Javadoc)
259:             * 
260:             * @see org.eclipse.ui.commands.ICommandService#refreshElements(java.lang.String,
261:             *      java.util.Map)
262:             */
263:            public void refreshElements(String commandId, Map filter) {
264:                fParentService.refreshElements(commandId, filter);
265:            }
266:
267:            /*
268:             * (non-Javadoc)
269:             * 
270:             * @see org.eclipse.ui.commands.ICommandService#registerElementForCommand(org.eclipse.core.commands.ParameterizedCommand,
271:             *      org.eclipse.ui.menus.UIElement)
272:             */
273:            public IElementReference registerElementForCommand(
274:                    ParameterizedCommand command, UIElement element)
275:                    throws NotDefinedException {
276:                if (!command.getCommand().isDefined()) {
277:                    throw new NotDefinedException(
278:                            "Cannot define a callback for undefined command " //$NON-NLS-1$
279:                                    + command.getCommand().getId());
280:                }
281:                if (element == null) {
282:                    throw new NotDefinedException(
283:                            "No callback defined for command " //$NON-NLS-1$
284:                                    + command.getCommand().getId());
285:                }
286:
287:                ElementReference ref = new ElementReference(command.getId(),
288:                        element, command.getParameterMap());
289:                registerElement(ref);
290:                return ref;
291:            }
292:
293:            /*
294:             * (non-Javadoc)
295:             * 
296:             * @see org.eclipse.ui.commands.ICommandService#registerElement(org.eclipse.ui.commands.IElementReference)
297:             */
298:            public void registerElement(IElementReference elementReference) {
299:                fCallbackCache.add(elementReference);
300:                elementReference.getParameters().put(fScopingName,
301:                        fScopingValue);
302:                fParentService.registerElement(elementReference);
303:            }
304:
305:            /*
306:             * (non-Javadoc)
307:             * 
308:             * @see org.eclipse.ui.commands.ICommandService#unregisterElement(org.eclipse.ui.commands.IElementReference)
309:             */
310:            public void unregisterElement(IElementReference elementReference) {
311:                fCallbackCache.remove(elementReference);
312:                fParentService.unregisterElement(elementReference);
313:            }
314:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.