Source Code Cross Referenced for QuickStartAction.java in  » IDE-Eclipse » ui-ide » 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 ide » 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 java.net.URL;
013:        import java.util.ArrayList;
014:
015:        import org.eclipse.core.runtime.IProduct;
016:        import org.eclipse.core.runtime.IStatus;
017:        import org.eclipse.core.runtime.Platform;
018:        import org.eclipse.core.runtime.Status;
019:        import org.eclipse.jface.action.Action;
020:        import org.eclipse.jface.dialogs.ErrorDialog;
021:        import org.eclipse.jface.dialogs.MessageDialog;
022:        import org.eclipse.jface.window.Window;
023:        import org.eclipse.swt.widgets.Shell;
024:        import org.eclipse.ui.IEditorPart;
025:        import org.eclipse.ui.IWorkbenchPage;
026:        import org.eclipse.ui.IWorkbenchWindow;
027:        import org.eclipse.ui.PartInitException;
028:        import org.eclipse.ui.PlatformUI;
029:        import org.eclipse.ui.WorkbenchException;
030:        import org.eclipse.ui.internal.ProductProperties;
031:        import org.eclipse.ui.internal.ide.AboutInfo;
032:        import org.eclipse.ui.internal.ide.FeatureSelectionDialog;
033:        import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
034:        import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
035:        import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
036:        import org.eclipse.ui.internal.ide.dialogs.WelcomeEditorInput;
037:
038:        /**
039:         * The quick start (Welcome...) action.
040:         * 
041:         * @deprecated the IDE now uses the new intro mechanism
042:         */
043:        public class QuickStartAction extends Action implements 
044:                ActionFactory.IWorkbenchAction {
045:
046:            private static final String EDITOR_ID = "org.eclipse.ui.internal.ide.dialogs.WelcomeEditor"; //$NON-NLS-1$
047:
048:            /**
049:             * The workbench window; or <code>null</code> if this
050:             * action has been <code>dispose</code>d.
051:             */
052:            private IWorkbenchWindow workbenchWindow;
053:
054:            /**
055:             * Create an instance of this class.
056:             * <p>
057:             * This consructor added to support calling the action from the welcome
058:             * page.
059:             * </p>
060:             */
061:            public QuickStartAction() {
062:                this (PlatformUI.getWorkbench().getActiveWorkbenchWindow());
063:            }
064:
065:            /**
066:             * Creates an instance of this action, for use in the given window.
067:             * @param window the window
068:             */
069:            public QuickStartAction(IWorkbenchWindow window) {
070:                super (IDEWorkbenchMessages.QuickStart_text);
071:                if (window == null) {
072:                    throw new IllegalArgumentException();
073:                }
074:                this .workbenchWindow = window;
075:                setToolTipText(IDEWorkbenchMessages.QuickStart_toolTip);
076:                PlatformUI.getWorkbench().getHelpSystem().setHelp(this ,
077:                        IIDEHelpContextIds.QUICK_START_ACTION);
078:                setActionDefinitionId("org.eclipse.ui.help.quickStartAction"); //$NON-NLS-1$
079:            }
080:
081:            /**
082:             * The user has invoked this action.  Prompts for a feature with a welcome page, 
083:             * then opens the corresponding welcome page.
084:             */
085:            public void run() {
086:                if (workbenchWindow == null) {
087:                    // action has been disposed
088:                    return;
089:                }
090:                try {
091:                    AboutInfo feature = promptForFeature();
092:                    if (feature != null) {
093:                        openWelcomePage(feature);
094:                    }
095:                } catch (WorkbenchException e) {
096:                    ErrorDialog
097:                            .openError(
098:                                    workbenchWindow.getShell(),
099:                                    IDEWorkbenchMessages.QuickStartAction_errorDialogTitle,
100:                                    IDEWorkbenchMessages.QuickStartAction_infoReadError,
101:                                    e.getStatus());
102:                }
103:            }
104:
105:            /**
106:             * Prompts the user for a feature that has a welcome page.
107:             * 
108:             * @return the chosen feature, or <code>null</code> if none was chosen
109:             */
110:            private AboutInfo promptForFeature() throws WorkbenchException {
111:                // Ask the user to select a feature
112:                ArrayList welcomeFeatures = new ArrayList();
113:
114:                URL productUrl = null;
115:                IProduct product = Platform.getProduct();
116:                if (product != null) {
117:                    productUrl = ProductProperties.getWelcomePageUrl(product);
118:                    welcomeFeatures.add(new AboutInfo(product));
119:                }
120:
121:                AboutInfo[] features = IDEWorkbenchPlugin.getDefault()
122:                        .getFeatureInfos();
123:                for (int i = 0; i < features.length; i++) {
124:                    URL url = features[i].getWelcomePageURL();
125:                    if (url != null && !url.equals(productUrl)) {
126:                        welcomeFeatures.add(features[i]);
127:                    }
128:                }
129:
130:                Shell shell = workbenchWindow.getShell();
131:
132:                if (welcomeFeatures.size() == 0) {
133:                    MessageDialog
134:                            .openInformation(
135:                                    shell,
136:                                    IDEWorkbenchMessages.QuickStartMessageDialog_title,
137:                                    IDEWorkbenchMessages.QuickStartMessageDialog_message);
138:                    return null;
139:                }
140:
141:                features = new AboutInfo[welcomeFeatures.size()];
142:                welcomeFeatures.toArray(features);
143:
144:                FeatureSelectionDialog d = new FeatureSelectionDialog(
145:                        shell,
146:                        features,
147:                        product == null ? null : product.getId(),
148:                        IDEWorkbenchMessages.WelcomePageSelectionDialog_title,
149:                        IDEWorkbenchMessages.WelcomePageSelectionDialog_message,
150:                        IIDEHelpContextIds.WELCOME_PAGE_SELECTION_DIALOG);
151:                if (d.open() != Window.OK || d.getResult().length != 1) {
152:                    return null;
153:                }
154:                return (AboutInfo) d.getResult()[0];
155:            }
156:
157:            /**
158:             * Opens the welcome page for the given feature.
159:             * 
160:             * @param featureId the about info for the feature
161:             * @return <code>true</code> if successful, <code>false</code> otherwise
162:             * @throws WorkbenchException 
163:             */
164:            public boolean openWelcomePage(String featureId)
165:                    throws WorkbenchException {
166:                AboutInfo feature = findFeature(featureId);
167:                if (feature == null || feature.getWelcomePageURL() == null) {
168:                    return false;
169:                }
170:                return openWelcomePage(feature);
171:            }
172:
173:            /**
174:             * Returns the about info for the feature with the given id, or <code>null</code>
175:             * if there is no such feature.
176:             * 
177:             * @return the about info for the feature with the given id, or <code>null</code>
178:             *   if there is no such feature.
179:             */
180:            private AboutInfo findFeature(String featureId)
181:                    throws WorkbenchException {
182:                AboutInfo[] features = IDEWorkbenchPlugin.getDefault()
183:                        .getFeatureInfos();
184:                for (int i = 0; i < features.length; i++) {
185:                    AboutInfo info = features[i];
186:                    if (info.getFeatureId().equals(featureId)) {
187:                        return info;
188:                    }
189:                }
190:                return null;
191:            }
192:
193:            /**
194:             * Opens the welcome page for a feature.
195:             * 
196:             * @param feature the about info for the feature
197:             * @return <code>true</code> if successful, <code>false</code> otherwise
198:             */
199:            private boolean openWelcomePage(AboutInfo feature) {
200:                IWorkbenchPage page = null;
201:
202:                // See if the feature wants a specific perspective
203:                String perspectiveId = feature.getWelcomePerspectiveId();
204:
205:                if (perspectiveId == null) {
206:                    // Just use the current perspective unless one is not open 
207:                    // in which case use the default
208:                    page = workbenchWindow.getActivePage();
209:
210:                    if (page == null || page.getPerspective() == null) {
211:                        perspectiveId = PlatformUI.getWorkbench()
212:                                .getPerspectiveRegistry()
213:                                .getDefaultPerspective();
214:                    }
215:                }
216:
217:                if (perspectiveId != null) {
218:                    try {
219:                        page = PlatformUI.getWorkbench().showPerspective(
220:                                perspectiveId, workbenchWindow);
221:                    } catch (WorkbenchException e) {
222:                        IDEWorkbenchPlugin
223:                                .log(
224:                                        "Error opening perspective: " + perspectiveId, e.getStatus()); //$NON-NLS-1$
225:                        return false;
226:                    }
227:                }
228:
229:                if (page == null) {
230:                    return false;
231:                }
232:
233:                page.setEditorAreaVisible(true);
234:
235:                // create input
236:                WelcomeEditorInput input = new WelcomeEditorInput(feature);
237:
238:                // see if we already have a welcome editorz
239:                IEditorPart editor = page.findEditor(input);
240:                if (editor != null) {
241:                    page.activate(editor);
242:                    return true;
243:                }
244:
245:                try {
246:                    page.openEditor(input, EDITOR_ID);
247:                } catch (PartInitException e) {
248:                    IDEWorkbenchPlugin
249:                            .log(
250:                                    "Error opening welcome editor for feature: " + feature.getFeatureId(), e); //$NON-NLS-1$
251:                    IStatus status = new Status(
252:                            IStatus.ERROR,
253:                            IDEWorkbenchPlugin.IDE_WORKBENCH,
254:                            1,
255:                            IDEWorkbenchMessages.QuickStartAction_openEditorException,
256:                            e);
257:                    ErrorDialog
258:                            .openError(
259:                                    workbenchWindow.getShell(),
260:                                    IDEWorkbenchMessages.Workbench_openEditorErrorDialogTitle,
261:                                    IDEWorkbenchMessages.Workbench_openEditorErrorDialogMessage,
262:                                    status);
263:                    return false;
264:                }
265:                return true;
266:            }
267:
268:            /* (non-Javadoc)
269:             * Method declared on ActionFactory.IWorkbenchAction.
270:             * @since 3.0
271:             */
272:            public void dispose() {
273:                if (workbenchWindow == null) {
274:                    // action has already been disposed
275:                    return;
276:                }
277:                workbenchWindow = null;
278:            }
279:
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.