Source Code Cross Referenced for AbstractAnnotationWizard.java in  » Workflow-Engines » osbl-1_0 » newprocess » diagram » cust » annotations » wizards » 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 » newprocess.diagram.cust.annotations.wizards 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * 
003:         */package newprocess.diagram.cust.annotations.wizards;
004:
005:        import newprocess.diagram.cust.annotations.commands.WriteCommand;
006:        import newprocess.diagram.cust.annotations.utils.URIConvertUtil;
007:
008:        import org.eclipse.core.resources.IFile;
009:        import org.eclipse.gef.EditPart;
010:        import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DecorationEditPolicy;
011:        import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
012:        import org.eclipse.jface.dialogs.MessageDialog;
013:        import org.eclipse.jface.resource.ImageDescriptor;
014:        import org.eclipse.jface.viewers.IStructuredSelection;
015:        import org.eclipse.swt.widgets.Listener;
016:        import org.eclipse.ui.IWorkbench;
017:        import org.eclipse.ui.IWorkbenchPage;
018:        import org.eclipse.ui.IWorkbenchWindow;
019:        import org.eclipse.ui.PartInitException;
020:        import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
021:        import org.eclipse.ui.ide.IDE;
022:        import org.eclipse.ui.plugin.AbstractUIPlugin;
023:        import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
024:
025:        /**
026:         * @author sh
027:         *
028:         */
029:        public abstract class AbstractAnnotationWizard extends
030:                BasicNewResourceWizard implements  Listener {
031:
032:            protected WizardNewFileCreationPage mainPage;
033:            protected String title = null;
034:            protected String fileName = null;
035:            protected String windowTitle = null;
036:            protected String plugin = null;
037:            protected String icon = null;
038:            protected String annotationType = null;
039:            protected String projectName = null;
040:            protected String path = null;
041:
042:            /**
043:             * Method declared on IWizard.
044:             */
045:            public void addPages() {
046:                super .addPages();
047:                mainPage = new NewFileCreationPage("newFilePage1",
048:                        getSelection(), annotationType);
049:                mainPage.setTitle(title);
050:                mainPage.setFileName(fileName);
051:                addPage(mainPage);
052:            }
053:
054:            /**
055:             * 
056:             */
057:            @Override
058:            public void init(IWorkbench workbench,
059:                    IStructuredSelection currentSelection) {
060:                super .init(workbench, currentSelection);
061:                setWindowTitle(windowTitle);
062:                setNeedsProgressMonitor(true);
063:            }
064:
065:            /** 
066:             * Method declared on BasicNewResourceWizard.
067:             */
068:            @Override
069:            protected void initializeDefaultPageImageDescriptor() {
070:                super .initializeDefaultPageImageDescriptor();
071:                ImageDescriptor desc = AbstractUIPlugin
072:                        .imageDescriptorFromPlugin(plugin, icon);
073:                setDefaultPageImageDescriptor(desc);
074:                getNextPage(mainPage);
075:            }
076:
077:            /* 
078:             * Method for the Wizard finish.
079:             * Before the external editor opens the file,
080:             * a SetValueCommand is executed to write the object.
081:             * returns FALSE if no file has been created
082:             * returns TRUE if the new file has been created successf
083:             */
084:            @Override
085:            public boolean performFinish() {
086:                // creates the file at the given location
087:                IFile file = mainPage.createNewFile();
088:                if (file == null)
089:                    return false;
090:
091:                // get the relative path for the created file
092:                URIConvertUtil uriUtil = new URIConvertUtil();
093:                String path = uriUtil.getPathForFile(file, projectName);
094:
095:                selectAndReveal(file);
096:
097:                // get the selected object
098:                IStructuredSelection selection = getSelection();
099:                Object object = selection.getFirstElement();
100:                if (object == null) {
101:                    MessageDialog.openError(mainPage.getShell(), "Error",
102:                            "saving Object failed");
103:                    return false;
104:                }
105:
106:                // write input to the model
107:                EditPart selectedEditPart = (EditPart) object;
108:                boolean ret = writeUri(selectedEditPart, path);
109:                if (ret == false)
110:                    return false;
111:
112:                // notify the decorator
113:                notifyDecorator(selectedEditPart);
114:
115:                // Open editor on new file.
116:                openEditor(file);
117:                return true;
118:            }
119:
120:            /**
121:             * open the editor on new file
122:             */
123:            private void openEditor(IFile file) {
124:                IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
125:                try {
126:                    if (dw != null) {
127:                        IWorkbenchPage page = dw.getActivePage();
128:                        if (page != null) {
129:                            IDE.openEditor(page, file, true);
130:                        }
131:                    }
132:                } catch (PartInitException e) {
133:                    MessageDialog.openError(dw.getShell(), "Error",
134:                            "file could not be opened");
135:                }
136:            }
137:
138:            /**
139:             * notify the decorator
140:             */
141:            private void notifyDecorator(EditPart selectedEditPart) {
142:                Object editPolicy = selectedEditPart
143:                        .getEditPolicy(EditPolicyRoles.DECORATION_ROLE);
144:                if (editPolicy instanceof  DecorationEditPolicy) {
145:                    ((DecorationEditPolicy) editPolicy).refresh();
146:                }
147:            }
148:
149:            /**
150:             * write uri of the file to the model
151:             */
152:            private boolean writeUri(EditPart selectedEditPart, String uri) {
153:                // write input to the model
154:                WriteCommand writeCommand = new WriteCommand();
155:                writeCommand.executeWriteCommand(selectedEditPart, uri);
156:
157:                /*
158:                // check if object stored successfully
159:                if(!writeCommand.containsObject(selectedEditPart, uri.toString()))  {
160:                  MessageDialog.openError(mainPage.getShell(), "Error", "saving Object failed");
161:                  return false;
162:                }
163:                 */
164:                return true;
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.