Source Code Cross Referenced for EnumLiteralChangeFacility.java in  » IDE-Netbeans » uml » org » netbeans » modules » uml » core » roundtripframework » 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.roundtripframework 
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:        /*
043:         * EnumLiteralChangeFacility.java
044:         *
045:         * Created on April 8, 2005, 11:08 AM
046:         */
047:
048:        package org.netbeans.modules.uml.core.roundtripframework;
049:
050:        import org.netbeans.modules.uml.core.metamodel.core.constructs.IEnumeration;
051:        import org.netbeans.modules.uml.core.metamodel.core.constructs.IEnumerationLiteral;
052:        import org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ILanguage;
053:        import org.netbeans.modules.uml.core.support.umlsupport.ProductRetriever;
054:        import org.netbeans.modules.uml.core.support.umlutils.ETList;
055:
056:        /**
057:         *
058:         * @author Administrator
059:         */
060:        public abstract class EnumLiteralChangeFacility extends RequestFacility
061:                implements  IEnumLiteralChangeFacility {
062:
063:            /** Creates a new instance of EnumLiteralChangeFacility */
064:            public EnumLiteralChangeFacility() {
065:            }
066:
067:            public IEnumerationLiteral addLiteral(String sName,
068:                    IEnumeration pClassifier, boolean rtOffCreate,
069:                    boolean rtOffPostProcessing) {
070:                if (pClassifier == null)
071:                    return null;
072:
073:                int roundTripMode = getRoundTripMode();
074:
075:                // We do not want to send round trip events if rtOffCreate is true
076:                if (rtOffCreate) {
077:                    setRoundTripMode(RTMode.RTM_OFF);
078:                } else {
079:                    setRoundTripMode(RTMode.RTM_LIVE);
080:                }
081:
082:                IEnumerationLiteral literal = null;
083:
084:                try {
085:
086:                    literal = createLiteral(sName, pClassifier);
087:
088:                    // Only handle the post processing of the attribute if round 
089:                    // trip was off during the creation of the attribute.  If RT
090:                    // was on during the creation of the attribute RT has already
091:                    // done the post processing, so do not do it again.
092:                    if (literal != null && rtOffCreate) {
093:                        if (rtOffPostProcessing) {
094:                            setRoundTripMode(RTMode.RTM_OFF);
095:                        } else {
096:                            setRoundTripMode(RTMode.RTM_LIVE);
097:                        }
098:
099:                        added(literal);
100:                    }
101:                } finally {
102:                    // Reset the state of RT.
103:                    setRoundTripMode(roundTripMode);
104:                }
105:
106:                return literal;
107:            }
108:
109:            public void changeName(IEnumerationLiteral literal,
110:                    String sNewName, boolean rtOffCreate,
111:                    boolean rtOffPostProcessing) {
112:                if (literal == null)
113:                    return;
114:
115:                int createFlag = RoundTripUtils
116:                        .getRTModeFromTurnOffFlag(rtOffCreate);
117:                RoundTripModeRestorer restorer = new RoundTripModeRestorer(
118:                        createFlag);
119:
120:                literal.setName(sNewName);
121:
122:                int postFlag = RoundTripUtils
123:                        .getRTModeFromTurnOffFlag(rtOffPostProcessing);
124:                restorer.setMode(postFlag);
125:
126:                nameChanged(literal);
127:            }
128:
129:            public IEnumerationLiteral createLiteral(String sName,
130:                    IEnumeration pClassifier) {
131:                if (pClassifier == null)
132:                    return null;
133:
134:                ILanguage pLanguage = getLanguage();
135:
136:                // Now if the attribute type is a data type (as specified by the
137:                // language manager then we want to create a IAttribute inside the
138:                // classifier.  Otherwise we want to create an association.
139:                if (pLanguage != null) {
140:                    RoundTripModeRestorer rest = new RoundTripModeRestorer(
141:                            RTMode.RTM_OFF);
142:                    try {
143:                        return pClassifier.createLiteral(sName);
144:                    } finally {
145:                        rest.restoreOriginalMode();
146:                    }
147:                }
148:
149:                return null;
150:            }
151:
152:            public void delete(IEnumerationLiteral literal,
153:                    boolean rtOffDelete, boolean rtOffPostDelete) {
154:                if (literal == null)
155:                    return;
156:
157:                IEnumeration pClassifier = literal.getEnumeration();
158:
159:                if (pClassifier != null) {
160:                    int deleteFlag = RoundTripUtils
161:                            .getRTModeFromTurnOffFlag(rtOffDelete);
162:                    RoundTripModeRestorer restorer = new RoundTripModeRestorer(
163:                            deleteFlag);
164:
165:                    pClassifier.removeLiteral(literal);
166:                    literal.delete();
167:
168:                    int postFlag = RoundTripUtils
169:                            .getRTModeFromTurnOffFlag(rtOffPostDelete);
170:                    restorer.setMode(postFlag);
171:
172:                    deleted(literal, pClassifier);
173:                }
174:            }
175:
176:            public void findAndChangeName(String sOldName, String sNewName,
177:                    IEnumeration pClassifier) {
178:                ETList<IEnumerationLiteral> literals = pClassifier
179:                        .getLiterals();
180:                for (IEnumerationLiteral literal : literals) {
181:                    String name = literal.getName();
182:                    if (sOldName.equals(name) == true) {
183:                        literal.setName(sNewName);
184:                        nameChanged(literal);
185:                        break;
186:                    }
187:                }
188:            }
189:
190:            public void findAndDelete(String sName, IEnumeration pClassifier) {
191:                ETList<IEnumerationLiteral> literals = pClassifier
192:                        .getLiterals();
193:                for (IEnumerationLiteral literal : literals) {
194:                    String name = literal.getName();
195:                    if (sName.equals(name) == true) {
196:                        literal.delete();
197:                        deleted(literal, pClassifier);
198:                        break;
199:                    }
200:                }
201:            }
202:
203:            ///////////////////////////////////////////////////////////////////////////
204:            // Helper Methods
205:
206:            protected int getRoundTripMode() {
207:                return ProductRetriever.retrieveProduct()
208:                        .getRoundTripController().getMode();
209:            }
210:
211:            protected void setRoundTripMode(/*RTMode*/int value) {
212:                // IZ 84855 conover - RT is always off and shouldn't be 
213:                // turned on for any reason
214:                if (value != RTMode.RTM_LIVE)
215:                    ProductRetriever.retrieveProduct().getRoundTripController()
216:                            .setMode(value);
217:            }
218:
219:            protected String retrieveShortName(String fullNameStr) {
220:                int pos = fullNameStr.lastIndexOf("::");
221:                return pos != -1 ? fullNameStr.substring(pos + 2) : fullNameStr;
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.