Source Code Cross Referenced for WorkbenchWizardNode.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » dialogs » 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 » IDE Eclipse » ui workbench » org.eclipse.ui.internal.dialogs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal.dialogs;
011:
012:        import org.eclipse.core.runtime.CoreException;
013:        import org.eclipse.core.runtime.IStatus;
014:        import org.eclipse.core.runtime.SafeRunner;
015:        import org.eclipse.core.runtime.Status;
016:        import org.eclipse.jface.util.SafeRunnable;
017:        import org.eclipse.jface.viewers.IStructuredSelection;
018:        import org.eclipse.jface.wizard.IWizard;
019:        import org.eclipse.jface.wizard.IWizardNode;
020:        import org.eclipse.swt.custom.BusyIndicator;
021:        import org.eclipse.swt.graphics.Point;
022:        import org.eclipse.swt.widgets.Shell;
023:        import org.eclipse.ui.IPluginContribution;
024:        import org.eclipse.ui.IWorkbench;
025:        import org.eclipse.ui.IWorkbenchWizard;
026:        import org.eclipse.ui.internal.WorkbenchMessages;
027:        import org.eclipse.ui.internal.WorkbenchPlugin;
028:        import org.eclipse.ui.internal.util.Util;
029:        import org.eclipse.ui.statushandlers.StatusAdapter;
030:        import org.eclipse.ui.statushandlers.StatusManager;
031:        import org.eclipse.ui.wizards.IWizardDescriptor;
032:
033:        /**
034:         * A wizard node represents a "potential" wizard. Wizard nodes
035:         * are used by wizard selection pages to allow the user to pick
036:         * from several available nested wizards.
037:         * <p>
038:         * <b>Subclasses</b> simply need to override method <code>createWizard()</code>,
039:         * which is responsible for creating an instance of the wizard it represents
040:         * AND ensuring that this wizard is the "right" type of wizard (e.g.-
041:         * New, Import, etc.).</p>
042:         */
043:        public abstract class WorkbenchWizardNode implements  IWizardNode,
044:                IPluginContribution {
045:            protected WorkbenchWizardSelectionPage parentWizardPage;
046:
047:            protected IWizard wizard;
048:
049:            protected IWizardDescriptor wizardElement;
050:
051:            /**
052:             * Creates a <code>WorkbenchWizardNode</code> that holds onto a wizard
053:             * element.  The wizard element provides information on how to create
054:             * the wizard supplied by the ISV's extension.
055:             * 
056:             * @param aWizardPage the wizard page
057:             * @param element the wizard descriptor
058:             */
059:            public WorkbenchWizardNode(
060:                    WorkbenchWizardSelectionPage aWizardPage,
061:                    IWizardDescriptor element) {
062:                super ();
063:                this .parentWizardPage = aWizardPage;
064:                this .wizardElement = element;
065:            }
066:
067:            /**
068:             * Returns the wizard represented by this wizard node.  <b>Subclasses</b>
069:             * must override this method.
070:             * 
071:             * @return the wizard object
072:             * @throws CoreException 
073:             */
074:            public abstract IWorkbenchWizard createWizard()
075:                    throws CoreException;
076:
077:            /* (non-Javadoc)
078:             * @see org.eclipse.jface.wizard.IWizardNode#dispose()
079:             */
080:            public void dispose() {
081:                // Do nothing since the wizard wasn't created via reflection.
082:            }
083:
084:            /**
085:             * Returns the current resource selection that is being given to the wizard.
086:             */
087:            protected IStructuredSelection getCurrentResourceSelection() {
088:                return parentWizardPage.getCurrentResourceSelection();
089:            }
090:
091:            /* (non-Javadoc)
092:             * @see org.eclipse.jface.wizard.IWizardNode#getExtent()
093:             */
094:            public Point getExtent() {
095:                return new Point(-1, -1);
096:            }
097:
098:            /* (non-Javadoc)
099:             * @see org.eclipse.ui.IPluginContribution#getLocalId()
100:             */
101:            public String getLocalId() {
102:                IPluginContribution contribution = (IPluginContribution) Util
103:                        .getAdapter(wizardElement, IPluginContribution.class);
104:                if (contribution != null) {
105:                    return contribution.getLocalId();
106:                }
107:                return wizardElement.getId();
108:            }
109:
110:            /* (non-Javadoc)
111:             * @see org.eclipse.ui.IPluginContribution#getPluginId()
112:             */
113:            public String getPluginId() {
114:                IPluginContribution contribution = (IPluginContribution) Util
115:                        .getAdapter(wizardElement, IPluginContribution.class);
116:                if (contribution != null) {
117:                    return contribution.getPluginId();
118:                }
119:                return null;
120:            }
121:
122:            /* (non-Javadoc)
123:             * @see org.eclipse.jface.wizard.IWizardNode#getWizard()
124:             */
125:            public IWizard getWizard() {
126:                if (wizard != null) {
127:                    return wizard; // we've already created it
128:                }
129:
130:                final IWorkbenchWizard[] workbenchWizard = new IWorkbenchWizard[1];
131:                final IStatus statuses[] = new IStatus[1];
132:                // Start busy indicator.
133:                BusyIndicator.showWhile(parentWizardPage.getShell()
134:                        .getDisplay(), new Runnable() {
135:                    public void run() {
136:                        SafeRunner.run(new SafeRunnable() {
137:                            /**
138:                             * Add the exception details to status is one happens.
139:                             */
140:                            public void handleException(Throwable e) {
141:                                IPluginContribution contribution = (IPluginContribution) Util
142:                                        .getAdapter(wizardElement,
143:                                                IPluginContribution.class);
144:                                statuses[0] = new Status(
145:                                        IStatus.ERROR,
146:                                        contribution != null ? contribution
147:                                                .getPluginId()
148:                                                : WorkbenchPlugin.PI_WORKBENCH,
149:                                        IStatus.OK,
150:                                        WorkbenchMessages.WorkbenchWizard_errorMessage,
151:                                        e);
152:                            }
153:
154:                            public void run() {
155:                                try {
156:                                    workbenchWizard[0] = createWizard();
157:                                    // create instance of target wizard
158:                                } catch (CoreException e) {
159:                                    IPluginContribution contribution = (IPluginContribution) Util
160:                                            .getAdapter(wizardElement,
161:                                                    IPluginContribution.class);
162:                                    statuses[0] = new Status(
163:                                            IStatus.ERROR,
164:                                            contribution != null ? contribution
165:                                                    .getPluginId()
166:                                                    : WorkbenchPlugin.PI_WORKBENCH,
167:                                            IStatus.OK,
168:                                            WorkbenchMessages.WorkbenchWizard_errorMessage,
169:                                            e);
170:                                }
171:                            }
172:                        });
173:                    }
174:                });
175:
176:                if (statuses[0] != null) {
177:                    parentWizardPage
178:                            .setErrorMessage(WorkbenchMessages.WorkbenchWizard_errorMessage);
179:                    StatusAdapter statusAdapter = new StatusAdapter(statuses[0]);
180:                    statusAdapter.addAdapter(Shell.class, parentWizardPage
181:                            .getShell());
182:                    statusAdapter.setProperty(StatusAdapter.TITLE_PROPERTY,
183:                            WorkbenchMessages.WorkbenchWizard_errorTitle);
184:                    StatusManager.getManager().handle(statusAdapter,
185:                            StatusManager.SHOW);
186:                    return null;
187:                }
188:
189:                IStructuredSelection currentSelection = getCurrentResourceSelection();
190:
191:                //Get the adapted version of the selection that works for the
192:                //wizard node
193:                currentSelection = wizardElement
194:                        .adaptedSelection(currentSelection);
195:
196:                workbenchWizard[0].init(getWorkbench(), currentSelection);
197:
198:                wizard = workbenchWizard[0];
199:                return wizard;
200:            }
201:
202:            /**
203:             * Returns the wizard element.
204:             * 
205:             * @return the wizard descriptor
206:             */
207:            public IWizardDescriptor getWizardElement() {
208:                return wizardElement;
209:            }
210:
211:            /**
212:             * Returns the current workbench.
213:             */
214:            protected IWorkbench getWorkbench() {
215:                return parentWizardPage.getWorkbench();
216:            }
217:
218:            /* (non-Javadoc)
219:             * @see org.eclipse.jface.wizard.IWizardNode#isContentCreated()
220:             */
221:            public boolean isContentCreated() {
222:                return wizard != null;
223:            }
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.