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


001:        /**
002:         * 
003:         */package gui.actions;
004:
005:        import gui.wizards.RenameImplementationWizard;
006:        import logging.LoggingPlugin;
007:        import model.PropertyUtil;
008:
009:        import org.apache.commons.logging.Log;
010:        import org.apache.commons.logging.LogFactory;
011:        import org.eclipse.core.runtime.ILog;
012:        import org.eclipse.core.runtime.IStatus;
013:        import org.eclipse.core.runtime.Status;
014:        import org.eclipse.gef.EditPart;
015:        import org.eclipse.jface.action.Action;
016:        import org.eclipse.jface.action.IAction;
017:        import org.eclipse.jface.dialogs.MessageDialog;
018:        import org.eclipse.jface.viewers.ISelection;
019:        import org.eclipse.jface.viewers.IStructuredSelection;
020:        import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
021:        import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
022:        import org.eclipse.ui.IActionDelegate;
023:
024:        import core.ModelInfo;
025:        import core.RenameImplementationProcessor;
026:        import core.RenameProcessorHolder;
027:
028:        /**
029:         * This action will be called from the Context Menu in the Editor.
030:         * It starts the refactor implementation process, which changes
031:         * the implementation property for a model element. After
032:         * that the source code will be adapted to the changes
033:         * in the model 
034:         * 
035:         * @author sh
036:         */
037:        public class RenameImplementationAction extends Action implements 
038:                IActionDelegate {
039:
040:            // the current selection
041:            private EditPart selectedEditPart = null;
042:
043:            // the Info Object to refacter
044:            private ModelInfo info = new ModelInfo();
045:
046:            private Log log = LogFactory.getLog(getClass());
047:
048:            /* (non-Javadoc)
049:             * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
050:             */
051:            @Override
052:            public void run(IAction action) {
053:                if (selectedEditPart == null) {
054:                    refuse();
055:                } else {
056:                    applySelection();
057:                    if (ActionUtil.saveAll()) {
058:                        openWizard();
059:                    }
060:                }
061:            }
062:
063:            /**
064:             * helper method which is called when the current
065:             * selection cannot be used for that refactoring.
066:             */
067:            private void refuse() {
068:                String title = "Rename Implementation";
069:                String message = "This refactoring is not available for the selected Element.";
070:                MessageDialog.openInformation(ActionUtil.getShell(), title,
071:                        message);
072:            }
073:
074:            /**
075:             * helper method which applies the selection 
076:             * and stores it in the info object.
077:             */
078:            private void applySelection() {
079:                info.setOldImplementation(PropertyUtil
080:                        .getImplementation(selectedEditPart));
081:                info.setNewImplementation(PropertyUtil
082:                        .getImplementation(selectedEditPart));
083:                info.setSelectedEditPart(selectedEditPart);
084:            }
085:
086:            /**
087:             * helper method for opening the type refactoring wizard.
088:             */
089:            private void openWizard() {
090:                RefactoringProcessor processor = new RenameImplementationProcessor(
091:                        info);
092:                RenameProcessorHolder ref = new RenameProcessorHolder(processor);
093:                RenameImplementationWizard wizard = new RenameImplementationWizard(
094:                        ref, info);
095:                RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(
096:                        wizard);
097:                try {
098:                    String titleForFailedChecks = "";
099:                    op.run(ActionUtil.getShell(), titleForFailedChecks);
100:                } catch (final InterruptedException irex) {
101:                    String message = " operation was canceled";
102:                    ILog logger = LoggingPlugin.getDefault().getLog();
103:                    String symName = LoggingPlugin.getDefault().getBundle()
104:                            .getSymbolicName();
105:                    logger.log(new Status(IStatus.ERROR, symName, 0, message,
106:                            irex));
107:                    throw new RuntimeException(irex + message);
108:                }
109:            }
110:
111:            /* (non-Javadoc)
112:             * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
113:             */
114:            @Override
115:            public void selectionChanged(IAction action, ISelection selection) {
116:                if (selection instanceof  IStructuredSelection == false)
117:                    return;
118:
119:                IStructuredSelection structuredSelection = (IStructuredSelection) selection;
120:                if (structuredSelection.getFirstElement() instanceof  EditPart == false)
121:                    return;
122:
123:                // check if the selected EditPart is supported
124:                boolean isSupported = PropertyUtil
125:                        .isEditPartSupported((EditPart) structuredSelection
126:                                .getFirstElement());
127:                if (isSupported)
128:                    selectedEditPart = (EditPart) structuredSelection
129:                            .getFirstElement();
130:            }
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.