Source Code Cross Referenced for PackageModelChange.java in  » Workflow-Engines » osbl-1_0 » gui » participants » 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 » Workflow Engines » osbl 1_0 » gui.participants 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * 
003:         */package gui.participants;
004:
005:        import logging.LoggingPlugin;
006:        import model.ModelModifier;
007:
008:        import org.apache.commons.logging.Log;
009:        import org.apache.commons.logging.LogFactory;
010:        import org.eclipse.core.runtime.CoreException;
011:        import org.eclipse.core.runtime.ILog;
012:        import org.eclipse.core.runtime.IProgressMonitor;
013:        import org.eclipse.core.runtime.IStatus;
014:        import org.eclipse.core.runtime.OperationCanceledException;
015:        import org.eclipse.core.runtime.Status;
016:        import org.eclipse.jdt.internal.core.PackageFragment;
017:        import org.eclipse.ltk.core.refactoring.Change;
018:        import org.eclipse.ltk.core.refactoring.RefactoringStatus;
019:        import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
020:
021:        /**
022:         * This change class is responsible for updating the implementation
023:         * property in the process models. It is used by the package renaming
024:         * refactoring. It checks which model element has the same implementation 
025:         * statement. If so the new string will be set. It also returns the 
026:         * undo operation for this modification.
027:         *
028:         * @author sh
029:         */
030:        public class PackageModelChange extends Change {
031:            // the selected element to refacter
032:            private Object selection = null;
033:
034:            // the input of the refactoring dialog
035:            private RenameArguments arguments = null;
036:
037:            private Log log = LogFactory.getLog(getClass());
038:
039:            /**
040:             * Constructor
041:             * 
042:             * @param selection the element to refacter
043:             * @param arguments the input data of the refactoring dialog
044:             */
045:            public PackageModelChange(Object selection,
046:                    RenameArguments arguments) {
047:                super ();
048:                this .selection = selection;
049:                this .arguments = arguments;
050:            }
051:
052:            /**
053:             * Returns the element modified by this <code>Change</code>. The method may return 
054:             * <code>null</code> if the change isn't related to an element.
055:             * 
056:             * @return the element modified by this change
057:             */
058:            @Override
059:            public Object getModifiedElement() {
060:                return null;
061:            }
062:
063:            /* (non-Javadoc)
064:             * @see org.eclipse.ltk.core.refactoring.Change#getName()
065:             */
066:            @Override
067:            public String getName() {
068:                return new String("Implementation change");
069:            }
070:
071:            /* (non-Javadoc)
072:             * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor)
073:             */
074:            @Override
075:            public void initializeValidationData(IProgressMonitor pm) {
076:            }
077:
078:            /* (non-Javadoc)
079:             * @see org.eclipse.ltk.core.refactoring.Change#isValid(org.eclipse.core.runtime.IProgressMonitor)
080:             */
081:            @Override
082:            public RefactoringStatus isValid(IProgressMonitor pm)
083:                    throws CoreException, OperationCanceledException {
084:                // if an fatal error will return, the refactoring will stoped
085:                RefactoringStatus result = new RefactoringStatus();
086:
087:                // TODO: check if some model could be read
088:
089:                return result;
090:            }
091:
092:            /**
093:             * Performs this change after the method isValid has been called. If isValid
094:             * returns an fatal error or the change is disabled this change will not be performed. 
095:             * Changes should in general not respond to {@link IProgressMonitor#isCanceled()} 
096:             * since canceling a change tree in the middle of its execution leaves the workspace 
097:             * in a half changed state.   
098:             * 
099:             * @param pm a progress monitor
100:             * @return the undo change for this change object or <code>null</code> if no
101:             *  undo is provided
102:             * @throws CoreException if an error occurred during change execution
103:             */
104:            @Override
105:            public Change perform(IProgressMonitor pm) throws CoreException {
106:                // get new implementation 
107:                String newImplementation = this .arguments.getNewName();
108:
109:                // get old implementation
110:                String oldImplementation = ((PackageFragment) this .selection)
111:                        .getElementName();
112:
113:                // check if values are valid
114:                if (!valuesValid(newImplementation, oldImplementation)) {
115:                    String message = "Model Update could't be done !";
116:                    ILog logger = LoggingPlugin.getDefault().getLog();
117:                    String symName = LoggingPlugin.getDefault().getBundle()
118:                            .getSymbolicName();
119:                    logger.log(new Status(IStatus.ERROR, symName, 0, message,
120:                            null));
121:                    throw new RuntimeException(message);
122:                }
123:
124:                // start the model update
125:                new ModelModifier().doPackageModification(oldImplementation,
126:                        newImplementation);
127:                log.info("Model: Implementation change performed");
128:
129:                // for the transaction handling the undo change element is returned
130:                // which reverts the implementation property change to the original state
131:                String undoOldImpl = newImplementation;
132:                String undoNewImpl = oldImplementation;
133:                return new PackageUndoModelChange(undoOldImpl, undoNewImpl);
134:            }
135:
136:            /**
137:             * check if the given values are valid, means they are initialized and
138:             * the string is not empty.
139:             * 
140:             * @param newImpl the full qualified name of a compilation unit
141:             * @param oldImpl the full qualified name of a compilation unit
142:             * 
143:             * @return true if all values pass the check
144:             */
145:            private boolean valuesValid(String newPackage, String oldPackage) {
146:                boolean valid = false;
147:
148:                if (newPackage != null)
149:                    if (!newPackage.equals(""))
150:                        valid = true;
151:
152:                if (oldPackage != null) {
153:                    if (!oldPackage.equals(""))
154:                        valid = true;
155:                }
156:
157:                return valid;
158:            }
159:
160:            /**
161:             * The undo change class which is used by the PackageModelChange participant.
162:             * If a model modification will be undone, an instance of that class
163:             * will be returned to set the original state.
164:             * 
165:             * @author sh
166:             *
167:             */
168:            private class PackageUndoModelChange extends Change {
169:                // the old implementation value to change
170:                private String oldImplementation = null;
171:                // the new implementation value  to set
172:                private String newImplementation = null;
173:
174:                public Object getModifiedElement() {
175:                    return null;
176:                }
177:
178:                public String getName() {
179:                    return "Undo implementation change";
180:                }
181:
182:                public void initializeValidationData(IProgressMonitor pm) {
183:                }
184:
185:                public PackageUndoModelChange(String oldImplementation,
186:                        String newImplementation) {
187:                    super ();
188:                    this .oldImplementation = oldImplementation;
189:                    this .newImplementation = newImplementation;
190:                }
191:
192:                /**
193:                 * check if properties are set.
194:                 */
195:                @Override
196:                public RefactoringStatus isValid(IProgressMonitor pm)
197:                        throws CoreException, OperationCanceledException {
198:
199:                    if (this .oldImplementation == null
200:                            || this .newImplementation == null) {
201:                        String message = "unable to undo the model implementation modification";
202:                        ILog logger = LoggingPlugin.getDefault().getLog();
203:                        String symName = LoggingPlugin.getDefault().getBundle()
204:                                .getSymbolicName();
205:                        logger.log(new Status(IStatus.ERROR, symName, 0,
206:                                message, null));
207:                        throw new RuntimeException(message);
208:                    }
209:                    return new RefactoringStatus();
210:                }
211:
212:                /**
213:                 * perform the undo operation
214:                 */
215:                @Override
216:                public Change perform(IProgressMonitor pm) throws CoreException {
217:                    new ModelModifier().doPackageModification(
218:                            oldImplementation, newImplementation);
219:                    log.info("Model: Implementation change undone");
220:                    return null;
221:                }
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.