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


001:        /*******************************************************************************
002:         * Copyright (c) 2004, 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.cheatsheets;
011:
012:        import java.net.URL;
013:
014:        import org.eclipse.help.ui.internal.views.HelpTray;
015:        import org.eclipse.help.ui.internal.views.IHelpPartPage;
016:        import org.eclipse.help.ui.internal.views.ReusableHelpPart;
017:        import org.eclipse.jface.action.Action;
018:        import org.eclipse.jface.dialogs.TrayDialog;
019:        import org.eclipse.swt.widgets.Display;
020:        import org.eclipse.swt.widgets.Shell;
021:        import org.eclipse.ui.IWorkbenchPage;
022:        import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetElement;
023:        import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetRegistryReader;
024:        import org.eclipse.ui.internal.cheatsheets.state.DefaultStateManager;
025:        import org.eclipse.ui.internal.cheatsheets.views.CheatSheetHelpPart;
026:        import org.eclipse.ui.internal.cheatsheets.views.CheatSheetView;
027:        import org.eclipse.ui.internal.cheatsheets.views.ViewUtilities;
028:
029:        /**
030:         * Action for opening a cheat sheet. The cheat sheet can be specified 
031:         * either by a cheat sheet id or by a URL of a cheat sheet content file.
032:         * <p>
033:         * This class is not intended to be subclassed by clients.
034:         * </p>
035:         * 
036:         * @since 3.0
037:         */
038:        public final class OpenCheatSheetAction extends Action {
039:            private String id;
040:            private String name;
041:            private URL url;
042:            private String xml;
043:            private String basePath;
044:
045:            /**
046:             * Creates an action that opens the cheat sheet with the given id.
047:             * The cheat sheet content file is located via the
048:             * <code>org.eclipse.ui.cheatsheets.cheatSheetContent</code>
049:             * extension point.
050:             * 
051:             * @param id the cheat sheet id
052:             * @exception IllegalArgumentException if <code>id</code>
053:             * is <code>null</code>
054:             */
055:            public OpenCheatSheetAction(String id) {
056:                if (id == null) {
057:                    throw new IllegalArgumentException();
058:                }
059:                this .id = id;
060:            }
061:
062:            /**
063:             * Creates an action that opens the cheat sheet with the 
064:             * given cheat sheet content file.
065:             * 
066:             * @param id the id to give this cheat sheet
067:             * @param name the name to give this cheat sheet
068:             * @param url URL of the cheat sheet content file
069:             * @exception IllegalArgumentException if the parameters
070:             * are <code>null</code>
071:             */
072:            public OpenCheatSheetAction(String id, String name, URL url) {
073:                if (id == null || name == null || url == null) {
074:                    throw new IllegalArgumentException();
075:                }
076:                this .id = id;
077:                this .name = name;
078:                this .url = url;
079:            }
080:
081:            /**
082:             * Creates an action that opens a cheat sheet using
083:             * XML passed in as a string.
084:             * 
085:             * @param id the id to give this cheat sheet
086:             * @param name the name to give this cheat sheet
087:             * @param xml the cheatsheet content in xml format
088:             * @param baseURL is a URL which is only required if the cheat sheet is
089:             * a composite cheat sheet which has tasks which use path parameters in which 
090:             * case the paths will be relative to baseURL. May be <code>null</code>
091:             * if this is not a composite cheat sheet
092:             * @exception IllegalArgumentException if the parameters
093:             * are <code>null</code>
094:             * @since 3.3
095:             */
096:            public OpenCheatSheetAction(String id, String name, String xml,
097:                    URL baseURL) {
098:                if (id == null || name == null || xml == null) {
099:                    throw new IllegalArgumentException();
100:                }
101:                this .id = id;
102:                this .name = name;
103:                this .xml = xml;
104:                if (baseURL != null) {
105:                    basePath = baseURL.toExternalForm();
106:                }
107:            }
108:
109:            /* (non-javadoc)
110:             * This action will try to launch the cheat sheet view and populate
111:             * it with the content specified either in the URL or the content
112:             * file specified in the cheatsheetContent extension point
113:             * for the cheat sheet with the id passed to this action.
114:             * @see IAction#run()
115:             */
116:            public void run() {
117:                Shell shell = Display.getDefault().getActiveShell();
118:                Object data = shell.getData();
119:                // are we in a dialog that can show a cheat sheet?
120:                if (!shell.isFocusControl() && data instanceof  TrayDialog) {
121:                    TrayDialog dialog = (TrayDialog) data;
122:                    HelpTray tray = (HelpTray) dialog.getTray();
123:                    if (tray == null) {
124:                        tray = new HelpTray();
125:                        dialog.openTray(tray);
126:                    }
127:                    ReusableHelpPart helpPart = tray.getHelpPart();
128:                    IHelpPartPage page = helpPart.createPage(
129:                            CheatSheetHelpPart.ID, null, null);
130:                    page.setVerticalSpacing(0);
131:                    page.setHorizontalMargin(0);
132:                    CheatSheetElement contentElement = CheatSheetRegistryReader
133:                            .getInstance().findCheatSheet(id);
134:                    helpPart.addPart(CheatSheetHelpPart.ID,
135:                            new CheatSheetHelpPart(helpPart.getForm().getForm()
136:                                    .getBody(),
137:                                    helpPart.getForm().getToolkit(), page
138:                                            .getToolBarManager(),
139:                                    contentElement, new DefaultStateManager()));
140:                    page.addPart(CheatSheetHelpPart.ID, true);
141:                    helpPart.addPage(page);
142:                    helpPart.showPage(CheatSheetHelpPart.ID);
143:                } else {
144:                    CheatSheetView view = ViewUtilities.showCheatSheetView();
145:                    if (view == null) {
146:                        return;
147:                    }
148:                    // Depending on which constructor was used open the cheat sheet view from a
149:                    // URL, an XML string or based on the id
150:                    if (url != null) {
151:                        view.setInput(id, name, url);
152:                    } else if (xml != null) {
153:                        view.setInputFromXml(id, name, xml, basePath);
154:                    } else {
155:                        view.setInput(id);
156:                    }
157:                    IWorkbenchPage page = view.getSite().getWorkbenchWindow()
158:                            .getActivePage();
159:                    page.bringToTop(view);
160:                }
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.