Source Code Cross Referenced for MemberTransaction.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 org.netbeans.modules.uml.integration.ide.ChangeUtils;
045:        import org.netbeans.modules.uml.integration.ide.JavaClassUtils;
046:        import org.netbeans.modules.uml.integration.ide.UMLSupport;
047:        import org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IAttribute;
048:        import org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IClassifier;
049:        import org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.INavigableEnd;
050:        import org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IStructuralFeature;
051:        import org.netbeans.modules.uml.core.metamodel.structure.IProject;
052:        import org.netbeans.modules.uml.core.roundtripframework.IAttributeChangeFacility;
053:        import org.netbeans.modules.uml.core.support.umlsupport.Log;
054:
055:        /**
056:         * The MemberTransaction is use to maintain a context when updating data
057:         * members.  The MemberTransaction will locate the data member in Describes
058:         * database.  When locating the data member the class symbol specified by
059:         * the SymbolTransaction will be searched for any attributes that match
060:         * the requested attribute.
061:         *
062:         * Revision History
063:         * No.  Date        Who         What
064:         * ---  ----        ---         ----
065:         *   1  2002-06-19  Darshan     Fixed fullScopeName not using the fully scoped
066:         *                              name in setAttribute().
067:         *   2  2002-06-21  Darshan     Added support for IStructuralFeature instead of
068:         *                              IAttribute and extended createAttribute to
069:         *                              create a navigable association where required.
070:         */
071:        public class MemberTransaction {
072:            /**
073:             *  The attribute that this context is managing. Note that this will be an
074:             * instance of INavigableEnd or IAttribute and can be downcast without
075:             * creating a proxy.
076:             */
077:            private IStructuralFeature mAttribute = null;
078:
079:            /**
080:             * If this attribute is an implmentation attribute the mMemberRel will contain
081:             * the relationship that contains teh attribute.
082:             */
083:            // private IGDRelation  mMemberRel  = null;
084:            /** The system that is to be updated. */
085:            private IProject mProj = null;
086:
087:            /** Flag to indicate if this is an implementation attribute. */
088:            private boolean mIsImplAttr = false;
089:
090:            private IClassifier mSym = null;
091:
092:            /**
093:             * Creates new MemberTransaction and specify which system to search for
094:             * the attribute.
095:             */
096:            public MemberTransaction(IProject proj) {
097:                setAttribute(null);
098:                setProject(proj);
099:            }
100:
101:            /**
102:             * Create a new MemberTransaction and specify the symbol to search and
103:             * data member to find.  If the member will be created if one is needed.
104:             * @param trans The symbol transaction used when searching for the memeber.
105:             * @param member The information required to locate the data member.
106:             */
107:            public MemberTransaction(SymbolTransaction trans,
108:                    final MemberInfo member) {
109:                this (UMLSupport.getCurrentProject());
110:                if (member != null) {
111:                    if (trans.getSymbol() != null)
112:                        setSymbol(trans.getSymbol());
113:                    setAttribute(trans, member);
114:                }
115:            }
116:
117:            /**
118:             * Sets the Describe system to use when retrieving the symbols information.  Therefore,
119:             * the symbol will also reside in the Describe system.
120:             * @param value The Describe system.
121:             */
122:            protected void setProject(IProject proj) {
123:                mProj = proj;
124:            }
125:
126:            /**
127:             * Retrieves the Describe system to use when retrieving the symbols information.  Therefore,
128:             * the symbol will also reside in the Describe system.
129:             * @param value The Describe system.
130:             */
131:            public IProject getProject() {
132:                return mProj;
133:            }
134:
135:            /**
136:             * Retrieve the Describe representation of the data member.
137:             * <i>In the future this may be abstracted. </i>
138:             */
139:            public IStructuralFeature getAttribute() {
140:                return mAttribute;
141:            }
142:
143:            /**
144:             * Set the Describe representation of the data member.
145:             * <i>In the future this may be abstracted. </i>
146:             */
147:            public void setAttribute(IStructuralFeature attr) {
148:                mAttribute = attr;
149:            }
150:
151:            /**
152:             * Checks if the data memeber is an implementation attribute.
153:             * @return true if the an implementation attribute, false otherwise.
154:             */
155:            public boolean isImplAttribute() {
156:                return mIsImplAttr;
157:            }
158:
159:            /**
160:             * Sets if the data memeber is an implementation attribute.
161:             * @param value true if the an implementation attribute, false otherwise.
162:             */
163:            public void setIsImplAttribute(boolean value) {
164:                mIsImplAttr = value;
165:            }
166:
167:            /**
168:             * Sets the Describe attribute that defines data member.  A Describe symbol
169:             * is search for a data member that matches the requested data member name.  If
170:             * a Describe attribute is not found then one is created for the data member.
171:             * @param trans The symbol transaction used to locate the data memeber.
172:             * @param member The information needed to locate the data memeber.
173:             */
174:            public void setAttribute(SymbolTransaction trans,
175:                    final MemberInfo member) {
176:                // First set the symbol to null to allow the current symbol to be GC
177:                setAttribute(null);
178:                IClassifier sym = trans.getSymbol();
179:
180:                if (sym != null) {
181:                    String fullScopeName = member.getQualifiedType();
182:                    String sourceName = member.getType();
183:                    Log.out("the fullScopeName = " + fullScopeName);
184:
185:                    // if(member.getChangeType() != ElementInfo.CREATE)
186:                    mAttribute = JavaClassUtils.findAttribute(sym, member
187:                            .getName());
188:
189:                    if (mAttribute == null
190:                            && member.getChangeType() == ElementInfo.CREATE)
191:                        mAttribute = createAttribute(sym, member.getName(),
192:                                fullScopeName, sourceName, member
193:                                        .getmodifierMask());
194:                }
195:            }
196:
197:            public void setSymbol(IClassifier clazz) {
198:                mSym = clazz;
199:            }
200:
201:            public IClassifier getSymbol() {
202:                return mSym;
203:            }
204:
205:            /**
206:             * Create a new Describe attribute to represent the data member.  This is helper
207:             * routine.
208:             * @param sym The symbol that will contain the attribute.
209:             * @param name The name of the attribute.
210:             * @param The type of the data member.
211:             */
212:            protected IStructuralFeature createAttribute(IClassifier sym,
213:                    String name, String fullName, String sourceName,
214:                    int modifierMask) {
215:                IAttribute retVal = null;
216:                EventManager.getEventManager().getEventFilter().blockEventType(
217:                        ChangeUtils.RDT_DEPENDENCY_ADDED);
218:                try {
219:                    int mul = MemberInfo.getMultiplicity(sourceName);
220:                    sourceName = MemberInfo.getTypeName(sourceName);
221:                    fullName = MemberInfo.getTypeName(fullName);
222:
223:                    if (JavaClassUtils.findAttribute(sym, name) == null) {
224:                        IAttributeChangeFacility facility = EventManager
225:                                .getAttributeFacility();
226:                        if (facility != null) {
227:                            Log.out("createAttribute: Creating attribute : "
228:                                    + name + ": " + sourceName + " : "
229:                                    + fullName);
230:                            //retVal = facility.createAttribute(name, sourceName, sym);
231:                            String umlFullName = JavaClassUtils
232:                                    .convertJavaToUML(fullName);
233:                            retVal = facility.addAttribute3(name, umlFullName,
234:                                    sym, true, false, modifierMask);
235:                            if (retVal != null)
236:                                MemberInfo.setMultiplicity(retVal, mul, 0);
237:                            else
238:                                Log
239:                                        .err("createAttribute(): Couldn't create attribute");
240:
241:                            if (retVal != null
242:                                    && retVal instanceof  INavigableEnd) {
243:                                IDEProcessor.addRelationshipLinkToDiagram(
244:                                        retVal, null);
245:                            }
246:                        } else {
247:                            Log
248:                                    .err("createAttribute(): IAttributeChangeFacility is null");
249:                        }
250:                        //            IClassifier clazz = JavaClassUtils.findClassSymbol(fullName);
251:                        //
252:                        //            if (clazz == null && !JavaClassUtils.isPrimitive(fullName))
253:                        //                clazz = JavaClassUtils.createDataType(fullName);
254:                        //
255:                        //            if (clazz == null) {
256:                        //                retVal = sym.createAttribute(sourceName, name);
257:                        //                sym.addAttribute(retVal);
258:                        //                sym.addOwnedElement(retVal);
259:                        //                Log.out("Setting multiplicity for '" + name
260:                        //                        + "' to " + mul);
261:                        //                MemberInfo.setMultiplicity(retVal, mul, 0);
262:                        //            }
263:                        //            else {
264:                        //                IStructuralFeature feat = IDEProcessor.
265:                        //                    makeNavigableAssociation(sym, clazz, name);
266:                        //                MemberInfo.setMultiplicity(feat, mul, 0);
267:                        //                return feat;
268:                        //            }
269:                        Log
270:                                .out("Successfully added the attrib ....... "
271:                                        + name);
272:                    } else {
273:                        Log.out("Attrib with same name already exists .....");
274:                    }
275:                } catch (Exception e) {
276:                    Log.stackTrace(e);
277:                } finally {
278:                    EventManager.getEventManager().getEventFilter()
279:                            .unblockEventType(ChangeUtils.RDT_DEPENDENCY_ADDED);
280:                }
281:                return retVal;
282:            }
283:
284:            /**
285:             * Checks if the type is a Java primitive.
286:             * @return true if the type is a Java primitive.
287:             */
288:            protected boolean isPrimative(String type) {
289:                boolean retVal = false;
290:
291:                if ((type.equals("int") == true)
292:                        || (type.equals("short") == true)
293:                        || (type.equals("char") == true)
294:                        || (type.equals("boolean") == true)
295:                        || (type.equals("double") == true)
296:                        || (type.equals("float") == true)
297:                        || (type.equals("long") == true)
298:                        || (type.equals("byte") == true)) {
299:                    retVal = true;
300:                }
301:
302:                return retVal;
303:            }
304:        }
w___ww_.__j_a__v__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.