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


001:        /*******************************************************************************
002:         * Copyright (c) 2006, 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.handlers;
011:
012:        import org.eclipse.core.commands.AbstractHandler;
013:        import org.eclipse.core.commands.ExecutionEvent;
014:        import org.eclipse.core.commands.ExecutionException;
015:        import org.eclipse.core.runtime.CoreException;
016:        import org.eclipse.jface.action.IAction;
017:        import org.eclipse.jface.viewers.StructuredSelection;
018:        import org.eclipse.jface.wizard.WizardDialog;
019:        import org.eclipse.swt.widgets.Shell;
020:        import org.eclipse.ui.IWorkbenchWindow;
021:        import org.eclipse.ui.IWorkbenchWizard;
022:        import org.eclipse.ui.PlatformUI;
023:        import org.eclipse.ui.actions.ExportResourcesAction;
024:        import org.eclipse.ui.actions.ImportResourcesAction;
025:        import org.eclipse.ui.actions.NewWizardAction;
026:        import org.eclipse.ui.handlers.HandlerUtil;
027:        import org.eclipse.ui.wizards.IWizardDescriptor;
028:        import org.eclipse.ui.wizards.IWizardRegistry;
029:
030:        /**
031:         * Abstract handler for commands that launch the import, export and new wizards.
032:         * <p>
033:         * This class is only intended to be extended by the three inner classes (<code>Export</code>,
034:         * <code>Import</code> and <code>New</code>) defined here.
035:         * </p>
036:         * 
037:         * @since 3.2
038:         */
039:        public abstract class WizardHandler extends AbstractHandler {
040:
041:            /**
042:             * Default handler for launching export wizards.
043:             */
044:            public static final class Export extends WizardHandler {
045:
046:                protected IAction createWizardChooserDialogAction(
047:                        IWorkbenchWindow window) {
048:                    return new ExportResourcesAction(window);
049:                }
050:
051:                protected String getWizardIdParameterId() {
052:                    return "exportWizardId"; //$NON-NLS-1$
053:                }
054:
055:                protected IWizardRegistry getWizardRegistry() {
056:                    return PlatformUI.getWorkbench().getExportWizardRegistry();
057:                }
058:
059:            }
060:
061:            /**
062:             * Default handler for launching import wizards.
063:             */
064:            public static final class Import extends WizardHandler {
065:
066:                protected IAction createWizardChooserDialogAction(
067:                        IWorkbenchWindow window) {
068:                    return new ImportResourcesAction(window);
069:                }
070:
071:                protected String getWizardIdParameterId() {
072:                    return "importWizardId"; //$NON-NLS-1$
073:                }
074:
075:                protected IWizardRegistry getWizardRegistry() {
076:                    return PlatformUI.getWorkbench().getImportWizardRegistry();
077:                }
078:
079:            }
080:
081:            /**
082:             * Default handler for launching new wizards.
083:             */
084:            public static final class New extends WizardHandler {
085:
086:                protected IAction createWizardChooserDialogAction(
087:                        IWorkbenchWindow window) {
088:                    return new NewWizardAction(window);
089:                }
090:
091:                protected String getWizardIdParameterId() {
092:                    return "newWizardId"; //$NON-NLS-1$
093:                }
094:
095:                protected IWizardRegistry getWizardRegistry() {
096:                    return PlatformUI.getWorkbench().getNewWizardRegistry();
097:                }
098:
099:            }
100:
101:            /**
102:             * Returns an <code>IAction</code> that opens a dialog to allow the user
103:             * to choose a wizard.
104:             * 
105:             * @param window
106:             *            The workbench window to use when constructing the action.
107:             * @return An <code>IAction</code> that opens a dialog to allow the user
108:             *         to choose a wizard.
109:             */
110:            protected abstract IAction createWizardChooserDialogAction(
111:                    IWorkbenchWindow window);
112:
113:            public Object execute(ExecutionEvent event)
114:                    throws ExecutionException {
115:
116:                String wizardId = event.getParameter(getWizardIdParameterId());
117:
118:                IWorkbenchWindow activeWindow = HandlerUtil
119:                        .getActiveWorkbenchWindowChecked(event);
120:
121:                if (wizardId == null) {
122:                    IAction wizardAction = createWizardChooserDialogAction(activeWindow);
123:                    wizardAction.run();
124:                } else {
125:
126:                    IWizardRegistry wizardRegistry = getWizardRegistry();
127:                    IWizardDescriptor wizardDescriptor = wizardRegistry
128:                            .findWizard(wizardId);
129:                    if (wizardDescriptor == null) {
130:                        throw new ExecutionException(
131:                                "unknown wizard: " + wizardId); //$NON-NLS-1$
132:                    }
133:
134:                    try {
135:                        IWorkbenchWizard wizard = wizardDescriptor
136:                                .createWizard();
137:                        wizard.init(PlatformUI.getWorkbench(),
138:                                StructuredSelection.EMPTY);
139:
140:                        if (wizardDescriptor.canFinishEarly()
141:                                && !wizardDescriptor.hasPages()) {
142:                            wizard.performFinish();
143:                            return null;
144:                        }
145:
146:                        Shell parent = activeWindow.getShell();
147:                        WizardDialog dialog = new WizardDialog(parent, wizard);
148:                        dialog.create();
149:                        dialog.open();
150:
151:                    } catch (CoreException ex) {
152:                        throw new ExecutionException(
153:                                "error creating wizard", ex); //$NON-NLS-1$
154:                    }
155:
156:                }
157:
158:                return null;
159:            }
160:
161:            /**
162:             * Returns the id of the parameter used to indicate which wizard this
163:             * command should launch.
164:             * 
165:             * @return The id of the parameter used to indicate which wizard this
166:             *         command should launch.
167:             */
168:            protected abstract String getWizardIdParameterId();
169:
170:            /**
171:             * Returns the wizard registry for the concrete <code>WizardHandler</code>
172:             * implementation class.
173:             * 
174:             * @return The wizard registry for the concrete <code>WizardHandler</code>
175:             *         implementation class.
176:             */
177:            protected abstract IWizardRegistry getWizardRegistry();
178:
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.