Source Code Cross Referenced for EventManager.java in  » IDE-Netbeans » uml » org » netbeans » modules » uml » integration » ide » events » 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.integration.ide.events 
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.integration.ide.events;
043:
044:        import java.lang.reflect.Modifier;
045:
046:        //import org.netbeans.modules.uml.integration.ide.UMLSupport;
047:        import org.netbeans.modules.uml.integration.ide.JavaClassUtils;
048:        import org.netbeans.modules.uml.integration.ide.UMLSupport; //import org.netbeans.modules.uml.integration.ide.Log;
049:        import org.netbeans.modules.uml.core.metamodel.core.constructs.IClass;
050:        import org.netbeans.modules.uml.core.metamodel.core.constructs.IEnumeration;
051:        import org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IClassifier;
052:        import org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IInterface;
053:        import org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IOperation;
054:        import org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IStructuralFeature;
055:        import org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.IFacilityManager;
056:        import org.netbeans.modules.uml.core.roundtripframework.IAttributeChangeFacility;
057:        import org.netbeans.modules.uml.core.roundtripframework.IMethodChangeFacility;
058:        import org.netbeans.modules.uml.core.support.umlsupport.Log;
059:
060:        /**
061:         * The EventManages manages the communication between an IDE integration and
062:         * Describe.  The event mangaer is a singleton.  Therefore, all communication
063:         * to and from Describe can only occur in one direction at a time.  If the
064:         * EventManager is handling a RoundTrip event any attemp to communciate with
065:         * Describe will be ignored.
066:         * <br>
067:         * In order to initiate communication with Describe a GDSymbolTransaction
068:         * must first be created.  Once a transaction has been initated communciation
069:         * may begin.  When Methods and Members are being changed GDMemberTransaction
070:         * and GDMethodTransactions must be created.
071:         *
072:         * Revision History
073:         * No.  Date        Who         What
074:         * ---  ----        ---         ----
075:         *   1  2002-05-27  Darshan     Removed call to set attribute native.
076:         *   2  2002-06-12  Darshan     Uncommented call to setIsAbstract().
077:         *
078:         * @see GDSymbolTransaction
079:         * @see GDMethodTransaction
080:         * @see GDMemberTransaction
081:         * @see #beginClassTransaction(ClassInfo info, IGDSystem system)
082:         * @see #beginMethodTransaction(GDSymbolTransaction trans, ConstructorInfo method)
083:         * @see #beginMemberTransaction(GDSymbolTransaction trans, MemberInfo member)
084:         */
085:        public class EventManager {
086:
087:            private boolean mPreventEvents = false;
088:
089:            //private _IGDAddInRoundTripEvents mRTEvents = new GDProRTEvents();
090:            //private GDEventProcessor         mIntegration   = null;
091:            private EventProcessor mToGDPro = null;
092:            private static EventManager mManager = null;
093:            private EventFilter filter = new EventFilter();
094:
095:            private static boolean roundTripActive = false;
096:
097:            private static IAttributeChangeFacility attributeFacility = null;
098:            private static IMethodChangeFacility methodFacility = null;
099:
100:            /**
101:             * Constructor a EventManager object.  Upon creation the round trip connection
102:             * is establish with Describe.
103:             */
104:            protected EventManager() {
105:                connectGDPro();
106:            }
107:
108:            public static synchronized void setRoundTripActive(boolean active) {
109:                roundTripActive = active;
110:            }
111:
112:            public static synchronized boolean isRoundTripActive() {
113:                return roundTripActive;
114:            }
115:
116:            public static IAttributeChangeFacility getAttributeFacility() {
117:                if (attributeFacility == null) {
118:                    IFacilityManager facMan = UMLSupport.getUMLSupport()
119:                            .getProduct().getFacilityManager();
120:                    attributeFacility = (IAttributeChangeFacility) facMan
121:                            .retrieveFacility("RoundTrip.JavaAttributeChangeFacility");
122:                }
123:                return attributeFacility;
124:            }
125:
126:            public static IMethodChangeFacility getMethodFacility() {
127:                if (methodFacility == null) {
128:                    IFacilityManager facMan = UMLSupport.getUMLSupport()
129:                            .getProduct().getFacilityManager();
130:                    methodFacility = (IMethodChangeFacility) facMan
131:                            .retrieveFacility("RoundTrip.JavaMethodChangeFacility");
132:                }
133:                return methodFacility;
134:            }
135:
136:            /**
137:             * Retrieves the Event Process that is used to communicate to integated enviornment.
138:             * @return The event process to be used.
139:             */
140:            /*
141:            protected  GDEventProcessor getIDEProcessor(  )
142:            {
143:             return mIntegration;
144:            }
145:             */
146:
147:            /**
148:             * Sets the Event Process that is used to communicate to integated enviornment.
149:             * @param ideProcessor The event process to be used.
150:             */
151:            /*
152:            public void setIDEProcessor( GDEventProcessor ideProcessor )
153:            {
154:             mIntegration = null;
155:             mIntegration = ideProcessor;
156:            }
157:             */
158:
159:            /**
160:             * Retrieves the Event Process that is used to communicate to Describe.
161:             * New event processor can be created to communicate with different processes
162:             * or different Describe methodologies.
163:             * @return The event process to use when communicating with Describe, or null
164:             *         if the event proesses has not been initialized.
165:             */
166:            protected EventProcessor getGDProProcessor() {
167:                return mToGDPro;
168:            }
169:
170:            /**
171:             * The singleton implementation used to retrieve an instance of the EventManager.
172:             * @return A event manager instance.
173:             */
174:            public synchronized static EventManager getEventManager() {
175:                if (mManager == null) {
176:                    mManager = new EventManager();
177:                }
178:                return mManager;
179:            }
180:
181:            public EventFilter getEventFilter() {
182:                return filter;
183:            }
184:
185:            /**
186:             * Initializes the event processor to be used to communicate with Descibe.
187:             */
188:            public void connectGDPro() {
189:                // // **## Log.out("Disconnected from GDPro...");
190:                mToGDPro = new IDEProcessor();
191:            }
192:
193:            /**
194:             * Disconnects the communication from the integrated environment to Describe.
195:             * After calling this routine communication to Describe will be broken.
196:             */
197:            public void disconnectGDPro() {
198:                // // **## Log.out("Disconnected from GDPro...");
199:                mToGDPro = null;
200:            }
201:
202:            // Operations to allow the IDE to send events to GDPro.
203:
204:            /**
205:             * Issue a command to Describe to delete a class symbol.
206:             * @param state The transaction to act upon.
207:             */
208:            public void deleteClass(SymbolTransaction state) {
209:                if (isBlocked() == false) {
210:                    EventProcessor processor = getGDProProcessor();
211:                    if (getGDProProcessor() != null) {
212:                        processor.deleteClass(state);
213:                    }
214:                }
215:            }
216:
217:            /**
218:             * Issue a command to Describe to delete a method from a class symbol.
219:             * @param state The transaction to act upon.
220:             */
221:            public void deleteMethod(MethodTransaction state) {
222:                if (isBlocked() == false) {
223:                    EventProcessor processor = getGDProProcessor();
224:                    if (getGDProProcessor() != null)
225:                        processor.deleteMethod(state);
226:                }
227:            }
228:
229:            /**
230:             * Issue a command to Describe add an interface implementation to a class symbol.
231:             * @param state The transaction to act upon.
232:             * @param pName The name of the package that contains the interface.
233:             * @param name The name of the interface.
234:             */
235:            public void addInterface(SymbolTransaction state, String pName,
236:                    String name) {
237:                if (isBlocked() == false) {
238:                    EventProcessor processor = getGDProProcessor();
239:                    if (processor != null) {
240:                        processor.addInterface(state, pName, name);
241:                    }
242:                }
243:            }
244:
245:            /**
246:             * Issue a command to Describe remvoe an interface implementation from a class symbol.
247:             * @param state The transaction to act upon.
248:             * @param pName The name of the package that contains the interface.
249:             * @param name The name of the interface.
250:             */
251:            public void removeInterface(SymbolTransaction state, String pName,
252:                    String name) {
253:                if (isBlocked() == false) {
254:                    EventProcessor processor = getGDProProcessor();
255:                    if (processor != null) {
256:                        processor.removeInterface(state, pName, name);
257:                    }
258:                } else {
259:                    Log
260:                            .out("Roundtrip is blocked in removeInterface, aborting");
261:                }
262:            }
263:
264:            /**
265:             * Issue a command to Describe add a collection of exceptions to a class symbol.
266:             * @param state The transaction to act upon.
267:             * @param value The exceptions to add.
268:             */
269:            public void setExceptions(MethodTransaction state, String[] value) {
270:                if (isBlocked() == false) {
271:                    EventProcessor processor = getGDProProcessor();
272:                    if (processor != null) {
273:                        String exceptions = "";
274:                        for (int i = 0; i < value.length; i++) {
275:                            if (i > 0)
276:                                exceptions += ",";
277:                            exceptions += value[i];
278:                        }
279:                        processor.setExceptions(state, exceptions);
280:                    }
281:                }
282:            }
283:
284:            /**
285:             * Issue a command to Describe update the package that contains the class symbol.
286:             * @param state The transaction to act upon.
287:             * @param value The name of the pacakge.
288:             */
289:            public void updatePackage(SymbolTransaction state, String value) {
290:                if (!isBlocked()) {
291:                    EventProcessor processor = getGDProProcessor();
292:                    if (processor != null) {
293:                        processor.setAttribute(state,
294:                                "ClassIdentifier.PackageName", value);
295:                    }
296:                }
297:            }
298:
299:            /**
300:             * Issue a command to Describe update the modifiers of a class symbols.
301:             * @param state The transaction to act upon.
302:             * @param value The java modifiers that have been changed.
303:             */
304:            public void updateClassModifers(SymbolTransaction state, int value) {
305:                if (isBlocked() == false) {
306:                    IClassifier clazz = state.getSymbol();
307:                    if (clazz != null) {
308:                        if (clazz.getIsAbstract() != Modifier.isAbstract(value))
309:                            clazz.setIsAbstract(Modifier.isAbstract(value));
310:                        if (clazz.getIsLeaf() != Modifier.isFinal(value))
311:                            clazz.setIsLeaf(Modifier.isFinal(value));
312:                        // TO DO
313:                        //processor.setTaggedValue(state, "GDHidden^strictfp", (Modifier.isStrict(value) == true ? "True" : "False"));
314:
315:                        if (clazz.getVisibility() != JavaClassUtils
316:                                .getDescribeModifier(value))
317:                            clazz.setVisibility(JavaClassUtils
318:                                    .getDescribeModifier(value));
319:                    }
320:                }
321:            }
322:
323:            /**
324:             * Issue a command to Describe update the modifiers of a class's method.
325:             * @param state The transaction to act upon.
326:             * @param value The java modifiers that have been changed.
327:             */
328:            public void updateMethodModifers(MethodTransaction state, int value) {
329:                if (isBlocked() == false) {
330:                    IOperation oper = state.getOperation();
331:                    if (oper != null) {
332:                        Log
333:                                .out("Setting diff modifiers for the method .................. ");
334:                        if (oper.getIsAbstract() != Modifier.isAbstract(value))
335:                            oper.setIsAbstract(Modifier.isAbstract(value));
336:                        if (oper.getIsFinal() != Modifier.isFinal(value))
337:                            oper.setIsFinal(Modifier.isFinal(value));
338:                        if (oper.getIsStatic() != Modifier.isStatic(value))
339:                            oper.setIsStatic(Modifier.isStatic(value));
340:                        if (oper.getIsNative() != Modifier.isNative(value))
341:                            oper.setIsNative(Modifier.isNative(value));
342:                        if (oper.getIsStrictFP() != Modifier.isStrict(value))
343:                            oper.setIsStrictFP(Modifier.isStrict(value));
344:                        if (Modifier.isSynchronized(value)) {
345:                            if (oper.getConcurrency() != 1)
346:                                oper.setConcurrency(1);
347:                        } else {
348:                            if (oper.getConcurrency() != 0)
349:                                oper.setConcurrency(0);
350:                        }
351:
352:                        if (oper.getIsNative() != Modifier.isNative(value))
353:                            oper.setIsNative(Modifier.isNative(value));
354:                        // TO DO Native, Synchronized,
355:                        //oper.setIsQuery(Modifier.isNative(value) == true ? 0 : 1));
356:                        //processor.setNativeMethod(state(Modifier.isNative(value));
357:                        //processor.setTaggedValue(state, "GDHidden^native", (Modifier.isNative(value) == true ? "True" : "False"));
358:
359:                        if (oper.getVisibility() != JavaClassUtils
360:                                .getDescribeModifier(value))
361:                            oper.setVisibility(JavaClassUtils
362:                                    .getDescribeModifier(value));
363:                    }
364:                }
365:            }
366:
367:            /**
368:             * Issue a command to Describe update return type of a method.
369:             * @param state The transaction to act upon.
370:             * @param value The return type.
371:             */
372:            public void updateMethodType(MethodTransaction state, String type) {
373:                if (isBlocked() == false) {
374:                    EventProcessor processor = getGDProProcessor();
375:                    if (processor != null) {
376:                        processor.setAttribute(state, "ReturnType", type);
377:                    }
378:                }
379:            }
380:
381:            /**
382:             * Issue a command to Describe update type of a data membere.
383:             * @param state The transaction to act upon.
384:             * @param value The type.
385:             */
386:            public void updateMemberType(MemberTransaction state,
387:                    String fullName, String sourceName) {
388:                if (isBlocked() == false) {
389:                    EventProcessor processor = getGDProProcessor();
390:                    if (processor != null) {
391:                        //processor.setAttribute(state, "Type", type);
392:                        processor.updateMemberType(state, fullName, sourceName);
393:                    }
394:                }
395:            }
396:
397:            /**
398:             * Issue a command to Describe update the modifiers of a class's data member.
399:             * @param state The transaction to act upon.
400:             * @param value The java modifiers that have been changed.
401:             */
402:            public void updateMemberModifers(MemberTransaction state, int value) {
403:                if (isBlocked() == false) {
404:                    IStructuralFeature attribute = state.getAttribute();
405:                    if (attribute != null) {
406:
407:                        attribute.setIsFinal(Modifier.isFinal(value));
408:                        attribute.setIsStatic(Modifier.isStatic(value));
409:                        //attribute.setIsNative(Modifier.isNative(value));
410:                        attribute.setIsVolatile(Modifier.isVolatile(value));
411:                        attribute.setIsTransient(Modifier.isTransient(value));
412:                        // TO DO Transient, Volatile
413:                        //attribute.setI(Modifier.isTransient(value));
414:                        //attribute.setI(Modifier.isVolatile(value));
415:                        //(Modifier.isStrict(value));
416:                        attribute.setVisibility(JavaClassUtils
417:                                .getDescribeModifier(value));
418:                    }
419:                }
420:            }
421:
422:            /**
423:             * Issue a command to Describe make a class symbol an interface.
424:             * @param state The transaction to act upon.
425:             * @param isInterface if true then the class is an inteface otherwise it is a class.
426:             */
427:            public void setAsInterface(SymbolTransaction state,
428:                    boolean isInterface) {
429:                if (isBlocked() == false) {
430:                    EventProcessor processor = getGDProProcessor();
431:                    if (processor != null) {
432:                        if (isInterface) {
433:                            //processor.setAttribute(state, "ClassFormat", "interface");
434:                            //processor.setAttribute(state, "ClassType", "Abstract");
435:                            if (state.getSymbol() instanceof  IClass) {
436:                                IClassifier intfc = state.getSymbol()
437:                                        .transform(ClassInfo.DS_INTERFACE);
438:                                state.setSymbol(intfc);
439:                            }
440:                        } else {
441:                            // processor.setAttribute(state, "ClassFormat", "class");
442:                            if (state.getSymbol() instanceof  IInterface) {
443:                                IClassifier cls = state.getSymbol().transform(
444:                                        ClassInfo.DS_CLASS);
445:                                cls
446:                                        .removeStereotype2(ClassInfo.DS_STE_INTERFACE);
447:                                state.setSymbol(cls);
448:                            }
449:                        }
450:                    }
451:                }
452:            }
453:
454:            /**
455:             * Issue a command to Describe make a class symbol an interface.
456:             * @param state The transaction to act upon.
457:             * @param isInterface if true then the class is an inteface otherwise it is a class.
458:             */
459:            public void setAsEnumeration(SymbolTransaction state,
460:                    boolean isEnumeration) {
461:                if (isBlocked() == false) {
462:                    EventProcessor processor = getGDProProcessor();
463:                    if (processor != null) {
464:                        if (isEnumeration) {
465:                            //processor.setAttribute(state, "ClassFormat", "interface");
466:                            //processor.setAttribute(state, "ClassType", "Abstract");
467:                            if (state.getSymbol() instanceof  IClass) {
468:                                IClassifier intfc = state.getSymbol()
469:                                        .transform(ClassInfo.DS_ENUMERATION);
470:                                state.setSymbol(intfc);
471:                            }
472:                        } else {
473:                            // processor.setAttribute(state, "ClassFormat", "class");
474:                            if (state.getSymbol() instanceof  IEnumeration) {
475:                                IClassifier cls = state.getSymbol().transform(
476:                                        ClassInfo.DS_CLASS);
477:                                cls
478:                                        .removeStereotype2(ClassInfo.DS_STE_ENUMERATION);
479:                                state.setSymbol(cls);
480:                            }
481:                        }
482:                    }
483:                }
484:            }
485:
486:            /**
487:             * When GDPro issues round trip events and we update the IDE we do not want to
488:             * execute event back to GDPro.  To pervent this from occuring I will set
489:             * a flag to prevent events from firing.  This is like the batch trigger flag
490:             * in GDPro.
491:             * @param turnOn True if the events are blocked.
492:             */
493:            protected final synchronized void blockTransactions(boolean turnOn) {
494:                // **## Log.out("BLOCKTRANSACTIONS: " + turnOn);
495:                mPreventEvents = turnOn;
496:            }
497:
498:            protected final synchronized boolean isBlocked() {
499:                return mPreventEvents;
500:            }
501:
502:            /**
503:             * A class that implements the _IGDAddInRoundTripEvents.  The _IGDAddInRoundTripEvents
504:             * interface allows a class to listener to round trip notification.  When a
505:             * round trip event occurs the source file will be update using the
506:             * Event Processor returned by getIDEProcessor.
507:             * @author  Trey Spiva
508:             * @version 1.0
509:             *
510:             * @see EventManager#getIDEProcessor()
511:             * @see GDEventProcessor
512:             */
513:            public class GDProRTEvents /* extends _IGDAddInRoundTripEventsAdapter */
514:            {
515:                /** Creates new GDProRTEvents   */
516:                public GDProRTEvents() {
517:                }
518:
519:                protected boolean isJavaFile(String filename) {
520:                    return filename.endsWith(".java");
521:                }
522:            }
523:
524:        }
w___w_w_.___j__av___a_2__s_.c_o__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.