Source Code Cross Referenced for EventDispatchController.java in  » IDE-Netbeans » uml » org » netbeans » modules » uml » core » eventframework » 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 Netbeans » uml » org.netbeans.modules.uml.core.eventframework 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.uml.core.eventframework;
043:
044:        import java.util.Enumeration;
045:        import java.util.Hashtable;
046:
047:        public class EventDispatchController extends EventDispatcher implements 
048:                IEventDispatchController
049:
050:        {
051:            /// EventDispatcher ID, actual EventDispatcher
052:            private Hashtable<String, IEventDispatcher> m_Dispatchers = new Hashtable<String, IEventDispatcher>();
053:
054:            public EventDispatchController() {
055:                super ();
056:            }
057:
058:            /**
059:             *
060:             * Adds a new EventDispatcher to this Controller.
061:             *
062:             * @param id[in] The unique identifier of the dispatcher
063:             * @param dispatcher[in] The actual Dispatcher
064:             *
065:             * @return S_OK unless there is a Dispatcher with the same ID. In that
066:             *         case, EDCR_E_DISPATCHER_EXISTS is returned 
067:             */
068:            public long addDispatcher(String id, IEventDispatcher dispatcher) {
069:                validateID(id);
070:                m_Dispatchers.put(id, dispatcher);
071:                return 0;
072:            }
073:
074:            /**
075:             *
076:             * Adds the EventDispatcher that matches the passed in enumeration.
077:             *
078:             * @param nKind[in] The dispatcher to match against
079:             * @param dispatcher[out] The EventDispatcher
080:             *
081:             * @return HRESULT
082:             */
083:            public long addDispatcher( /* EventDispatcherKind */int nKind,
084:                    IEventDispatcher dispatcher) {
085:                int eventDispatchType = getDispatchType(nKind);
086:                if (eventDispatchType < 0) {
087:                    eventDispatchType = EventDispatchNameKeeper.EDT_WORKSPACE_KIND;
088:                }
089:                addDispatcher(EventDispatchNameKeeper
090:                        .dispatcherName(eventDispatchType), dispatcher);
091:                return 0;
092:            }
093:
094:            /**
095:             * Removes the EventDispatcher with the matching ID from this Controller and returns it
096:             *
097:             * @param id[in] The ID of the dispatcher to remove
098:             * @param dispatcher[out] The removed EventDispatcher
099:             *
100:             * @return HRESULT
101:             */
102:            public IEventDispatcher removeDispatcher(String id) {
103:                IEventDispatcher disp = null;
104:                if (m_Dispatchers != null) {
105:                    disp = m_Dispatchers.get(id);
106:                    if (disp != null) {
107:                        m_Dispatchers.remove(id);
108:                    }
109:                }
110:                return disp;
111:            }
112:
113:            /**
114:             * Removes the EventDispatcher that matches the passed in enumeration.
115:             *
116:             * @param nKind[in] The dispatcher to match against
117:             * @param dispatcher[out] The EventDispatcher
118:             *
119:             * @return HRESULT
120:             */
121:            public IEventDispatcher removeDispatcher(
122:                    /* EventDispatcherKind */int nKind) {
123:                int eventDispatchType = getDispatchType(nKind);
124:                if (eventDispatchType < 0) {
125:                    eventDispatchType = EventDispatchNameKeeper.EDT_WORKSPACE_KIND;
126:                }
127:                return removeDispatcher(EventDispatchNameKeeper
128:                        .dispatcherName(eventDispatchType));
129:            }
130:
131:            /**
132:             * Retrieves the EventDispatcher that matches the passed in ID.
133:             *
134:             * @param id[in] The ID to match against
135:             * @param dispatcher[out] The EventDispatcher
136:             *
137:             * @return HRESULT
138:             */
139:            public IEventDispatcher retrieveDispatcher(String id) {
140:                return m_Dispatchers.get(id);
141:            }
142:
143:            /**
144:             * Retrieves the EventDispatcher that matches the passed in enumeration.
145:             *
146:             * @param nKind[in] The dispatcher to match against
147:             * @param dispatcher[out] The EventDispatcher
148:             *
149:             * @return HRESULT
150:             */
151:            public IEventDispatcher retrieveDispatcher(
152:                    /* EventDispatcherKind */int nKind) {
153:                int eventDispatchType = getDispatchType(nKind);
154:                if (eventDispatchType < 0) {
155:                    eventDispatchType = EventDispatchNameKeeper.EDT_WORKSPACE_KIND;
156:                }
157:                return retrieveDispatcher(EventDispatchNameKeeper
158:                        .dispatcherName(eventDispatchType));
159:            }
160:
161:            /**
162:             * Returns the name keeper type.
163:             * 
164:             * @param nKind [in] The kind of the dispatcher to get
165:             * @param nNameKeeperType [out] The namekeeper type
166:             * @return true if we were able to convert between the IDL enumeration and the name keeper enumeration
167:             */
168:            protected int getDispatchType(int nKind) {
169:                int nNameKeeperType = -1;
170:                if (nKind == EventDispatcherKind.EDK_WORKSPACE) {
171:                    nNameKeeperType = EventDispatchNameKeeper.EDT_WORKSPACE_KIND;
172:                } else if (nKind == EventDispatcherKind.EDK_DRAWINGAREA) {
173:                    nNameKeeperType = EventDispatchNameKeeper.EDT_DRAWINGAREA_KIND;
174:                } else if (nKind == EventDispatcherKind.EDK_PROJECTTREE) {
175:                    nNameKeeperType = EventDispatchNameKeeper.EDT_PROJECTTREE_KIND;
176:                } else if (nKind == EventDispatcherKind.EDK_ELEMENTMODIFIED) {
177:                    nNameKeeperType = EventDispatchNameKeeper.EDT_ELEMENTMODIFIED_KIND;
178:                } else if (nKind == EventDispatcherKind.EDK_EDITCTRL) {
179:                    nNameKeeperType = EventDispatchNameKeeper.EDT_EDITCTRL_KIND;
180:                } else if (nKind == EventDispatcherKind.EDK_PROJECTTREEDIALOGFILTER) {
181:                    nNameKeeperType = EventDispatchNameKeeper.EDT_PROJECTTREEDIALOGFILTER_KIND;
182:                } else if (nKind == EventDispatcherKind.EDK_ADDIN) {
183:                    nNameKeeperType = EventDispatchNameKeeper.EDT_ADDIN_KIND;
184:                } else if (nKind == EventDispatcherKind.EDK_MESSAGING) {
185:                    nNameKeeperType = EventDispatchNameKeeper.EDT_MESSAGING_KIND;
186:                } else if (nKind == EventDispatcherKind.EDK_VBA) {
187:                    nNameKeeperType = EventDispatchNameKeeper.EDT_VBA_KIND;
188:                } else if (nKind == EventDispatcherKind.EDK_RELATION) {
189:                    nNameKeeperType = EventDispatchNameKeeper.EDT_RELATION_KIND;
190:                } else if (nKind == EventDispatcherKind.EDK_ELEMENT_LIFETIME) {
191:                    nNameKeeperType = EventDispatchNameKeeper.EDT_ELEMENT_LIFETIME_KIND;
192:                } else if (nKind == EventDispatcherKind.EDK_CLASSIFIER) {
193:                    nNameKeeperType = EventDispatchNameKeeper.EDT_CLASSIFIER_KIND;
194:                } else if (nKind == EventDispatcherKind.EDK_COREPRODUCT) {
195:                    nNameKeeperType = EventDispatchNameKeeper.EDT_COREPRODUCT_KIND;
196:                } else if (nKind == EventDispatcherKind.EDK_PREFERENCEMANAGER) {
197:                    nNameKeeperType = EventDispatchNameKeeper.EDT_PREFERENCEMANAGER_KIND;
198:                } else if (nKind == EventDispatcherKind.EDK_SCM) {
199:                    nNameKeeperType = EventDispatchNameKeeper.EDT_SCM_KIND;
200:                } else if (nKind == EventDispatcherKind.EDK_DYNAMICS) {
201:                    nNameKeeperType = EventDispatchNameKeeper.EDT_DYNAMICS_KIND;
202:                } else if (nKind == EventDispatcherKind.EDK_STRUCTURE) {
203:                    nNameKeeperType = EventDispatchNameKeeper.EDT_STRUCTURE_KIND;
204:                } else if (nKind == EventDispatcherKind.EDK_ACTIVITIES) {
205:                    nNameKeeperType = EventDispatchNameKeeper.EDT_ACTIVITIES_KIND;
206:                }
207:
208:                return nNameKeeperType;
209:            }
210:
211:            /**
212:             *
213:             * Determines whether or not all the EventDispatchers this controller is 
214:             * controlling are blocked from sending events to their listeners.
215:             *
216:             * @param pVal[out] The value. true if all the dispatchers are blocked.
217:             *                  false if at least one dispatcher can send events.
218:             *
219:             * @return HRESULT
220:             */
221:            public boolean getPreventAllEvents() {
222:                boolean pVal = true;
223:                Enumeration<IEventDispatcher> enumVal = m_Dispatchers
224:                        .elements();
225:                while (enumVal.hasMoreElements()) {
226:                    boolean blocked = false;
227:                    blocked = enumVal.nextElement().getPreventAllEvents();
228:                    if (blocked == false) {
229:                        pVal = false;
230:                        break;
231:                    }
232:                }
233:                return pVal;
234:            }
235:
236:            /**
237:             * Loops through every EventDispatcher on this controller and sets their
238:             * internal PreventAllEvents flags to newVal.
239:             *
240:             * @param newVal[in] The value to set the flag to
241:             *
242:             * @return HRESULT
243:             */
244:            public void setPreventAllEvents(boolean val) {
245:                Enumeration<IEventDispatcher> enumVal = m_Dispatchers
246:                        .elements();
247:                while (enumVal.hasMoreElements()) {
248:                    enumVal.nextElement().setPreventAllEvents(val);
249:                }
250:            }
251:
252:            /**
253:             *
254:             * Makes sure that an EventDispatcher with a matching ID does not exist.
255:             *
256:             * @param id[in] The ID to match against
257:             *
258:             * @return S_OK unless there is a Dispatcher with the same ID. In that
259:             *         case, EDCR_E_DISPATCHER_EXISTS is returned 
260:             */
261:            protected void validateID(String id) {
262:
263:            }
264:
265:            /**
266:             * Push the context onto our list and all dispatchers owned by the controller.
267:             *
268:             * @param context[in] The EventContext to push
269:             *
270:             * @return HRESULT
271:             */
272:            public void pushEventContext(IEventContext context) {
273:                pushEventContext3(context);
274:            }
275:
276:            /**
277:             * Push the context onto our list and all dispatchers owned by the controller.
278:             *
279:             * @param pContext[in]
280:             *
281:             * @return 
282:             */
283:            public void pushEventContext3(IEventContext pContext) {
284:                super .pushEventContext3(pContext);
285:                establishContext(pContext);
286:            }
287:
288:            /**
289:             * Pops the current EventContext present on each dispatcher this controller manages.
290:             *
291:             * @return HRESULT
292:             * @warning This should only be called after previously calling PushEventContext().
293:             *          Each PushEventContext() should be paired with a PopEventContext().
294:             */
295:            public void popEventContext() {
296:                try {
297:                    Enumeration<IEventDispatcher> enumVal = m_Dispatchers
298:                            .elements();
299:                    while (enumVal.hasMoreElements()) {
300:                        enumVal.nextElement().popEventContext();
301:                    }
302:                    super .popEventContext();
303:                } catch (Exception e) {
304:                }
305:            }
306:
307:            /**
308:             * Pops the current EventContext present on each dispatcher this controller manages.
309:             *
310:             * @return HRESULT
311:             * @warning This should only be called after previously calling PushEventContext().
312:             *          Each PushEventContext() should be paired with a PopEventContext().
313:             */
314:            public IEventContext popEventContext2() {
315:                IEventContext pContext = null;
316:                try {
317:                    Enumeration<IEventDispatcher> enumVal = m_Dispatchers
318:                            .elements();
319:                    while (enumVal.hasMoreElements()) {
320:                        enumVal.nextElement().popEventContext2();
321:                    }
322:                    pContext = super .popEventContext2();
323:                } catch (Exception err) {
324:                }
325:                return pContext;
326:            }
327:
328:            /**
329:             * Pops an event context by name from each dispatcher this controller maintains.
330:             *
331:             * @param name[in] The name of the Context to pop
332:             *
333:             * @return HRESULT
334:             */
335:            public void removeEventContextByName(String name) {
336:                try {
337:                    if (name != null && name.length() > 0) {
338:                        Enumeration<IEventDispatcher> enumVal = m_Dispatchers
339:                                .elements();
340:                        while (enumVal.hasMoreElements()) {
341:                            enumVal.nextElement()
342:                                    .removeEventContextByName(name);
343:                        }
344:                        super .removeEventContextByName(name);
345:                    }
346:                } catch (Exception err) {
347:                }
348:            }
349:
350:            /**
351:             * Pops an event context if it contains a filter with the passed in ID from every
352:             * dispatcher this controller manages.
353:             *
354:             * @param filterID[in] The id to match against
355:             *
356:             * @return HRESULT
357:             */
358:            public void removeEventContextByFilterID(String filterID) {
359:                try {
360:                    if (filterID.length() > 0) {
361:                        Enumeration<IEventDispatcher> enumVal = m_Dispatchers
362:                                .elements();
363:                        while (enumVal.hasMoreElements()) {
364:                            enumVal.nextElement().removeEventContextByFilterID(
365:                                    filterID);
366:                        }
367:                        super .removeEventContextByFilterID(filterID);
368:                    }
369:                } catch (Exception err) {
370:                }
371:            }
372:
373:            /**
374:             * Returns how many listeners are associated with this dispatcher.
375:             *
376:             * @param pVal[out] The number of listeners on this dispatcher
377:             *
378:             * @return HRESULT
379:             */
380:            public int getNumRegisteredSinks() {
381:                return super .getNumRegisteredSinks();
382:            }
383:
384:            /**
385:             * Push the context onto all owned dispatchers.
386:             *
387:             * @param pContext[in]
388:             *
389:             * @return 
390:             */
391:            protected void establishContext(IEventContext pContext) {
392:                try {
393:                    Enumeration<IEventDispatcher> enumVal = m_Dispatchers
394:                            .elements();
395:                    while (enumVal.hasMoreElements()) {
396:                        enumVal.nextElement().pushEventContext3(pContext);
397:                    }
398:                } catch (Exception err) {
399:                }
400:            }
401:
402:            public static final String CLSID = "{A2C15050-7977-4896-B810-E7E1B00B51D3}";
403:
404:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.