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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 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.actions;
011:
012:        import org.eclipse.jface.action.Action;
013:        import org.eclipse.jface.dialogs.IDialogSettings;
014:        import org.eclipse.jface.viewers.ISelection;
015:        import org.eclipse.jface.viewers.IStructuredSelection;
016:        import org.eclipse.jface.viewers.StructuredSelection;
017:        import org.eclipse.jface.wizard.WizardDialog;
018:        import org.eclipse.swt.widgets.Shell;
019:        import org.eclipse.ui.IEditorInput;
020:        import org.eclipse.ui.IEditorPart;
021:        import org.eclipse.ui.ISharedImages;
022:        import org.eclipse.ui.IWorkbenchPart;
023:        import org.eclipse.ui.IWorkbenchWindow;
024:        import org.eclipse.ui.PlatformUI;
025:        import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
026:        import org.eclipse.ui.internal.LegacyResourceSupport;
027:        import org.eclipse.ui.internal.PerspectiveTracker;
028:        import org.eclipse.ui.internal.WorkbenchMessages;
029:        import org.eclipse.ui.internal.WorkbenchPlugin;
030:        import org.eclipse.ui.internal.dialogs.NewWizard;
031:        import org.eclipse.ui.internal.util.Util;
032:
033:        /**
034:         * Invoke the resource creation wizard selection Wizard.
035:         * <p>
036:         * This class may be instantiated; it is not intended to be subclassed.
037:         * </p>
038:         * <p>
039:         * This method automatically registers listeners so that it can keep its
040:         * enablement state up to date. Ordinarily, the window's references to these
041:         * listeners will be dropped automatically when the window closes. However,
042:         * if the client needs to get rid of an action while the window is still open,
043:         * the client must call #dispose() to give the
044:         * action an opportunity to deregister its listeners and to perform any other
045:         * cleanup.
046:         * </p>
047:         */
048:        public class NewWizardAction extends Action implements 
049:                ActionFactory.IWorkbenchAction {
050:
051:            /**
052:             * The wizard dialog width
053:             */
054:            private static final int SIZING_WIZARD_WIDTH = 500;
055:
056:            /**
057:             * The wizard dialog height
058:             */
059:            private static final int SIZING_WIZARD_HEIGHT = 500;
060:
061:            /**
062:             * The id of the category to show or <code>null</code> to
063:             * show all the categories.
064:             */
065:            private String categoryId = null;
066:
067:            /**
068:             * The workbench window; or <code>null</code> if this
069:             * action has been <code>dispose</code>d.
070:             */
071:            private IWorkbenchWindow workbenchWindow;
072:
073:            /**
074:             * Tracks perspective activation, to update this action's
075:             * enabled state.
076:             */
077:            private PerspectiveTracker tracker;
078:
079:            /**
080:             * Create a new instance of this class.
081:             * @param window
082:             */
083:            public NewWizardAction(IWorkbenchWindow window) {
084:                super (WorkbenchMessages.NewWizardAction_text);
085:                if (window == null) {
086:                    throw new IllegalArgumentException();
087:                }
088:                this .workbenchWindow = window;
089:                tracker = new PerspectiveTracker(window, this );
090:                // @issues should be IDE-specific images
091:                ISharedImages images = PlatformUI.getWorkbench()
092:                        .getSharedImages();
093:                setImageDescriptor(images
094:                        .getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD));
095:                setDisabledImageDescriptor(images
096:                        .getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD_DISABLED));
097:                setToolTipText(WorkbenchMessages.NewWizardAction_toolTip);
098:                PlatformUI.getWorkbench().getHelpSystem().setHelp(this ,
099:                        IWorkbenchHelpContextIds.NEW_ACTION);
100:            }
101:
102:            /**
103:             * Create a new instance of this class
104:             * 
105:             * @deprecated use the constructor <code>NewWizardAction(IWorkbenchWindow)</code>
106:             */
107:            public NewWizardAction() {
108:                this (PlatformUI.getWorkbench().getActiveWorkbenchWindow());
109:            }
110:
111:            /**
112:             * Returns the id of the category of wizards to show
113:             * or <code>null</code> to show all categories.
114:             * @return String
115:             */
116:            public String getCategoryId() {
117:                return categoryId;
118:            }
119:
120:            /**
121:             * Sets the id of the category of wizards to show
122:             * or <code>null</code> to show all categories.
123:             * @param id
124:             */
125:            public void setCategoryId(String id) {
126:                categoryId = id;
127:            }
128:
129:            /* (non-Javadoc)
130:             * Method declared on IAction.
131:             */
132:            public void run() {
133:                if (workbenchWindow == null) {
134:                    // action has been disposed
135:                    return;
136:                }
137:                NewWizard wizard = new NewWizard();
138:                wizard.setCategoryId(categoryId);
139:
140:                ISelection selection = workbenchWindow.getSelectionService()
141:                        .getSelection();
142:                IStructuredSelection selectionToPass = StructuredSelection.EMPTY;
143:                if (selection instanceof  IStructuredSelection) {
144:                    selectionToPass = (IStructuredSelection) selection;
145:                } else {
146:                    // @issue the following is resource-specific legacy code
147:                    // Build the selection from the IFile of the editor
148:                    Class resourceClass = LegacyResourceSupport
149:                            .getResourceClass();
150:                    if (resourceClass != null) {
151:                        IWorkbenchPart part = workbenchWindow.getPartService()
152:                                .getActivePart();
153:                        if (part instanceof  IEditorPart) {
154:                            IEditorInput input = ((IEditorPart) part)
155:                                    .getEditorInput();
156:                            Object resource = Util.getAdapter(input,
157:                                    resourceClass);
158:                            if (resource != null) {
159:                                selectionToPass = new StructuredSelection(
160:                                        resource);
161:                            }
162:                        }
163:                    }
164:                }
165:
166:                wizard.init(workbenchWindow.getWorkbench(), selectionToPass);
167:                IDialogSettings workbenchSettings = WorkbenchPlugin
168:                        .getDefault().getDialogSettings();
169:                IDialogSettings wizardSettings = workbenchSettings
170:                        .getSection("NewWizardAction"); //$NON-NLS-1$
171:                if (wizardSettings == null) {
172:                    wizardSettings = workbenchSettings
173:                            .addNewSection("NewWizardAction"); //$NON-NLS-1$
174:                }
175:                wizard.setDialogSettings(wizardSettings);
176:                wizard.setForcePreviousAndNextButtons(true);
177:
178:                Shell parent = workbenchWindow.getShell();
179:                WizardDialog dialog = new WizardDialog(parent, wizard);
180:                dialog.create();
181:                dialog.getShell().setSize(
182:                        Math.max(SIZING_WIZARD_WIDTH, dialog.getShell()
183:                                .getSize().x), SIZING_WIZARD_HEIGHT);
184:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
185:                        dialog.getShell(), IWorkbenchHelpContextIds.NEW_WIZARD);
186:                dialog.open();
187:            }
188:
189:            /* (non-Javadoc)
190:             * Method declared on ActionFactory.IWorkbenchAction.
191:             * @since 3.0
192:             */
193:            public void dispose() {
194:                if (workbenchWindow == null) {
195:                    // action has already been disposed
196:                    return;
197:                }
198:                tracker.dispose();
199:                workbenchWindow = null;
200:            }
201:
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.