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


001:        /**
002:         * 
003:         */package refactor;
004:
005:        import java.lang.reflect.InvocationTargetException;
006:
007:        import org.eclipse.core.runtime.IProgressMonitor;
008:        import org.eclipse.jdt.core.ICompilationUnit;
009:        import org.eclipse.jdt.core.IJavaElement;
010:        import org.eclipse.jdt.core.IPackageFragment;
011:        import org.eclipse.jdt.core.dom.FieldDeclaration;
012:        import org.eclipse.jface.operation.IRunnableWithProgress;
013:
014:        import core.IRefactoring;
015:        import core.RenameImplementation;
016:
017:        /**
018:         * This class starts the monitored refactoring progress. This progress consists of three
019:         * parts. At the beginning the modify operation, then source update and the model update 
020:         * progress.
021:         * 
022:         * @author sh
023:         *
024:         */
025:        public class RenameRefactoring {
026:
027:            /**
028:             * Starts the monitored rename refactoring progress.
029:             * 
030:             * @param selection the selected object
031:             * @param newName the new name to set
032:             */
033:            public void startRenameRefactoring(Object selection, String newName) {
034:                /*
035:                try {
036:                	IRunnableWithProgress op = new RefacturingProgress(selection, newName);
037:                	Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
038:                	new ProgressMonitorDialog(shell).run(true, true, op);
039:                } catch (InvocationTargetException e) {
040:                	throw new RuntimeException(e + " Refactoring Progress could not be invoked !");
041:                } catch (InterruptedException e) {
042:                	throw new RuntimeException(e + " Refactoring Progress could not be invoked !");
043:                }
044:                 */
045:                if (selection instanceof  IPackageFragment)
046:                    renamePackageFragment((IPackageFragment) selection, newName);
047:
048:                if (selection instanceof  ICompilationUnit)
049:                    renameCompilationUnit((ICompilationUnit) selection, newName);
050:
051:                if (selection instanceof  FieldDeclaration)
052:                    renameFieldDeclaration((FieldDeclaration) selection,
053:                            newName);
054:
055:                // if(selection instanceof IType) 
056:                // if(selection instanceof IMethod)
057:            }
058:
059:            /**
060:             * Renames a compilation unit.
061:             * 
062:             * @param unit the compilation unit to rename
063:             * @param newName the new name to set
064:             */
065:            private void renameCompilationUnit(ICompilationUnit unit,
066:                    String newName) {
067:                //rename(new RenameCompilationUnit(newName), unit);
068:            }
069:
070:            /**
071:             * Renames a package fragment.
072:             * 
073:             * @param packagefragment the package fragment to rename
074:             * @param newName the new name to set
075:             */
076:            private void renamePackageFragment(
077:                    IPackageFragment packagefragment, String newName) {
078:                rename(new RenamePackageFragment(newName), packagefragment);
079:            }
080:
081:            /**
082:             * Renames a field declaration.
083:             * 
084:             * @param fielddeclaration the field declaration to rename
085:             * @param newName the new name to set
086:             */
087:            private void renameFieldDeclaration(
088:                    FieldDeclaration fielddeclaration, String newName) {
089:                /*
090:                RenameFieldDeclaration renFD = new RenameFieldDeclaration(newName);
091:                // 1. do the modification
092:                renFD.modification(fielddeclaration);
093:                
094:                // 2. modify the source
095:                renFD.updateSource(fielddeclaration);
096:                
097:                // 3. do the model update
098:                renFD.updateModel(fielddeclaration);
099:                 */
100:            }
101:
102:            /**
103:             * Does the three steps of the refactoring
104:             * 
105:             * @param refObj the kind of refactoring to execute
106:             * @param element the element to refactor
107:             */
108:            private void rename(IRefactoring refObj, IJavaElement element) {
109:                if (refObj instanceof  RenamePackageFragment)
110:                    refObj = (RenamePackageFragment) refObj;
111:
112:                if (refObj instanceof  RenameImplementation)
113:                    //refObj = (RenameCompilationUnit)refObj;
114:
115:                    // 1. do the modification
116:                    refObj.modification(element);
117:
118:                // 2. modify the source
119:                refObj.updateSource(element);
120:
121:                // 3. do the model update
122:                refObj.updateModel(element);
123:            }
124:
125:            /**
126:             * A helper class to initialize the Progress Dialog with the 
127:             * selected object and the the name to set.
128:             * In the run method the refactoring will be started.
129:             * 
130:             * @author sh
131:             *
132:             */
133:            private class RefacturingProgress implements  IRunnableWithProgress {
134:                private Object selection = null;
135:                private String newName = null;
136:
137:                public RefacturingProgress(Object selection, String newName) {
138:                    super ();
139:                    this .selection = selection;
140:                    this .newName = newName;
141:                }
142:
143:                public void run(IProgressMonitor monitor)
144:                        throws InvocationTargetException, InterruptedException {
145:
146:                    if (selection instanceof  IPackageFragment)
147:                        renamePackageFragment((IPackageFragment) selection,
148:                                newName);
149:
150:                    if (selection instanceof  ICompilationUnit)
151:                        renameCompilationUnit((ICompilationUnit) selection,
152:                                newName);
153:
154:                    // if(selection instanceof IType) 
155:                    // if(selection instanceof IMethod)
156:                }
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.