Source Code Cross Referenced for ActionSequenceNewWizard.java in  » Report » pentaho-report » org » pentaho » designstudio » editors » actionsequence » 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 » Report » pentaho report » org.pentaho.designstudio.editors.actionsequence.wizards 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Pentaho Corporation.  All rights reserved. 
003:         * This software was developed by Pentaho Corporation and is provided under the terms 
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use 
005:         * this file except in compliance with the license. If you need a copy of the license, 
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho 
007:         * BI Platform.  The Initial Developer is Pentaho Corporation.
008:         *
009:         * Software distributed under the Mozilla Public License is distributed on an "AS IS" 
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
011:         * the license for the specific language governing your rights and limitations.
012:         */
013:        package org.pentaho.designstudio.editors.actionsequence.wizards;
014:
015:        import java.io.IOException;
016:        import java.io.InputStream;
017:        import java.lang.reflect.InvocationTargetException;
018:
019:        import org.eclipse.core.resources.IContainer;
020:        import org.eclipse.core.resources.IFile;
021:        import org.eclipse.core.resources.IResource;
022:        import org.eclipse.core.resources.IWorkspaceRoot;
023:        import org.eclipse.core.resources.ResourcesPlugin;
024:        import org.eclipse.core.runtime.CoreException;
025:        import org.eclipse.core.runtime.IProgressMonitor;
026:        import org.eclipse.core.runtime.IStatus;
027:        import org.eclipse.core.runtime.Path;
028:        import org.eclipse.core.runtime.Status;
029:        import org.eclipse.jface.dialogs.MessageDialog;
030:        import org.eclipse.jface.operation.IRunnableWithProgress;
031:        import org.eclipse.jface.resource.ImageDescriptor;
032:        import org.eclipse.jface.viewers.ISelection;
033:        import org.eclipse.jface.viewers.IStructuredSelection;
034:        import org.eclipse.jface.wizard.Wizard;
035:        import org.eclipse.ui.INewWizard;
036:        import org.eclipse.ui.IWorkbench;
037:        import org.eclipse.ui.IWorkbenchPage;
038:        import org.eclipse.ui.IWorkbenchWizard;
039:        import org.eclipse.ui.PartInitException;
040:        import org.eclipse.ui.PlatformUI;
041:        import org.eclipse.ui.ide.IDE;
042:        import org.pentaho.designstudio.editors.actionsequence.ActionSequenceEditorPlugin;
043:        import org.pentaho.designstudio.messages.Messages;
044:
045:        /**
046:         * This is a sample new wizard. Its role is to create a new file 
047:         * resource in the provided container. If the container resource
048:         * (a folder or a project) is selected in the workspace 
049:         * when the wizard is opened, it will accept it as the target
050:         * container. The wizard creates one file with the extension
051:         * "action_xml". If a sample multi-page editor (also available
052:         * as a template) is registered for the same extension, it will
053:         * be able to open it.
054:         */
055:
056:        public class ActionSequenceNewWizard extends Wizard implements 
057:                INewWizard {
058:            private ActionSequenceNewWizardPage page;
059:            private ISelection selection;
060:
061:            /**
062:             * Constructor for ActionSequenceNewWizard.
063:             */
064:            public ActionSequenceNewWizard() {
065:                super ();
066:                setNeedsProgressMonitor(true);
067:            }
068:
069:            /**
070:             * Adding the page to the wizard.
071:             */
072:
073:            public void addPages() {
074:                page = new ActionSequenceNewWizardPage(selection);
075:                addPage(page);
076:
077:            }
078:
079:            /**
080:             * This method is called when 'Finish' button is pressed in
081:             * the wizard. We will create an operation and run it
082:             * using wizard as execution context.
083:             */
084:            public boolean performFinish() {
085:                final String containerName = page.getContainerName();
086:                String tmpFileName = page.getFileName();
087:                if (tmpFileName.indexOf(".") == -1) { //$NON-NLS-1$
088:                    tmpFileName = tmpFileName
089:                            + "." + ActionSequenceNewWizardPage.ACTION_SEQUENCE_FILE_EXTENSION; //$NON-NLS-1$
090:                }
091:                final String fileName = tmpFileName;
092:                IRunnableWithProgress op = new IRunnableWithProgress() {
093:                    public void run(IProgressMonitor monitor)
094:                            throws InvocationTargetException {
095:                        try {
096:                            doFinish(containerName, fileName, monitor);
097:                        } catch (CoreException e) {
098:                            throw new InvocationTargetException(e);
099:                        } finally {
100:                            monitor.done();
101:                        }
102:                    }
103:                };
104:                try {
105:                    getContainer().run(true, false, op);
106:                } catch (InterruptedException e) {
107:                    return false;
108:                } catch (InvocationTargetException e) {
109:                    Throwable realException = e.getTargetException();
110:                    MessageDialog
111:                            .openError(
112:                                    getShell(),
113:                                    Messages
114:                                            .getString("ActionSequenceNewWizard.UI_WIZ_ERROR_DLG_TITLE"), realException.getMessage()); //$NON-NLS-1$
115:                    return false;
116:                }
117:                return true;
118:            }
119:
120:            /**
121:             * The worker method. It will find the container, create the
122:             * file if missing or just replace its contents, and open
123:             * the editor on the newly created file.
124:             */
125:
126:            private void doFinish(String containerName, String fileName,
127:                    IProgressMonitor monitor) throws CoreException {
128:                // create a sample file
129:                monitor
130:                        .beginTask(
131:                                Messages
132:                                        .getString(
133:                                                "ActionSequenceNewWizard.UI_WIZ_CREATING_MSG", fileName), 2); //$NON-NLS-1$
134:                IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
135:                IResource resource = root.findMember(new Path(containerName));
136:                if (!resource.exists() || !(resource instanceof  IContainer)) {
137:                    throwCoreException(Messages
138:                            .getString(
139:                                    "ActionSequenceNewWizard.UI_WIZ_CREATING_ERROR_MSG", containerName)); //$NON-NLS-1$
140:                }
141:                IContainer container = (IContainer) resource;
142:                final IFile file = container.getFile(new Path(fileName));
143:                try {
144:                    InputStream stream = openContentStream();
145:                    if (file.exists()) {
146:                        file.setContents(stream, true, true, monitor);
147:                    } else {
148:                        file.create(stream, true, monitor);
149:                    }
150:                    stream.close();
151:                } catch (IOException e) {
152:                }
153:                monitor.worked(1);
154:                monitor
155:                        .setTaskName(Messages
156:                                .getString("ActionSequenceNewWizard.UI_WIZ_OPENING_MSG")); //$NON-NLS-1$
157:                getShell().getDisplay().asyncExec(new Runnable() {
158:                    public void run() {
159:                        IWorkbenchPage page = PlatformUI.getWorkbench()
160:                                .getActiveWorkbenchWindow().getActivePage();
161:                        try {
162:                            IDE.openEditor(page, file, true);
163:                        } catch (PartInitException e) {
164:                        }
165:                    }
166:                });
167:                monitor.worked(1);
168:            }
169:
170:            /**
171:             * We will initialize file contents with a sample text.
172:             */
173:
174:            private InputStream openContentStream() {
175:                return (page.getInitialContent());
176:            }
177:
178:            private void throwCoreException(String message)
179:                    throws CoreException {
180:                IStatus status = new Status(
181:                        IStatus.ERROR,
182:                        "org.pentaho.designstudio.editors.actionsequence", IStatus.OK, message, null); //$NON-NLS-1$
183:                throw new CoreException(status);
184:            }
185:
186:            /**
187:             * We will accept the selection in the workbench to see if
188:             * we can initialize from it.
189:             * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
190:             */
191:            public void init(IWorkbench workbench,
192:                    IStructuredSelection selection) {
193:                this .selection = selection;
194:                setWindowTitle("Pentaho"); //$NON-NLS-1$
195:                ImageDescriptor image = ActionSequenceEditorPlugin
196:                        .getImageDescriptor(Messages
197:                                .getString("ActionSequenceNewWizard.ICON_NEW_ACTION_SEQUENCE")); //$NON-NLS-1$
198:                setDefaultPageImageDescriptor(image);
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.