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


001:        /*******************************************************************************
002:         * Copyright (c) 2002, 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.cheatsheets.registry;
011:
012:        import org.eclipse.core.runtime.*;
013:        import org.eclipse.osgi.util.NLS;
014:        import org.eclipse.ui.IPluginContribution;
015:        import org.eclipse.ui.cheatsheets.CheatSheetListener;
016:        import org.eclipse.ui.internal.cheatsheets.*;
017:        import org.eclipse.ui.model.WorkbenchAdapter;
018:        import org.eclipse.ui.model.IWorkbenchAdapter;
019:        import org.osgi.framework.Bundle;
020:
021:        /**
022:         *	Instances represent registered cheatsheets or cheatsheets opened using the content file.
023:         */
024:        public class CheatSheetElement extends WorkbenchAdapter implements 
025:                IAdaptable, IPluginContribution {
026:            private String contentFile;
027:            private String id;
028:            private String name;
029:            private String description;
030:            private IConfigurationElement configurationElement;
031:            private String listenerClass;
032:            private boolean composite;
033:            private boolean registered = false;
034:            private String contentXml;
035:            private String href;
036:
037:            /**
038:             *	Create a new instance of this class
039:             *
040:             *	@param name java.lang.String
041:             */
042:            public CheatSheetElement(String name) {
043:                this .name = name;
044:            }
045:
046:            /**
047:             * Returns an object which is an instance of the given class
048:             * associated with this object. Returns <code>null</code> if
049:             * no such object can be found.
050:             */
051:            public Object getAdapter(Class adapter) {
052:                if (adapter == IWorkbenchAdapter.class) {
053:                    return this ;
054:                }
055:                return Platform.getAdapterManager().getAdapter(this , adapter);
056:            }
057:
058:            /**
059:             * 
060:             * @return IConfigurationElement
061:             */
062:            public IConfigurationElement getConfigurationElement() {
063:                return configurationElement;
064:            }
065:
066:            /**
067:             *	Get the content File path of this element
068:             *
069:             *	@return java.lang.String
070:             */
071:            public String getContentFile() {
072:                return contentFile;
073:            }
074:
075:            /**
076:             *	Answer the description parameter of this element
077:             *
078:             *	@return java.lang.String
079:             */
080:            public String getDescription() {
081:                return description;
082:            }
083:
084:            /**
085:             *	Answer the id as specified in the extension.
086:             *
087:             *	@return java.lang.String
088:             */
089:            public String getID() {
090:                return id;
091:            }
092:
093:            /**
094:             * Returns the name of this cheatsheet element.
095:             */
096:            public String getLabel(Object element) {
097:                return name;
098:            }
099:
100:            /**
101:             * Returns the listener class name of this cheatsheet element.
102:             */
103:            public String getListenerClass() {
104:                return listenerClass;
105:            }
106:
107:            /**
108:             * 
109:             * @param newConfigurationElement IConfigurationElement
110:             */
111:            public void setConfigurationElement(
112:                    IConfigurationElement newConfigurationElement) {
113:                configurationElement = newConfigurationElement;
114:            }
115:
116:            /**
117:             *	Set the contentFile parameter of this element
118:             *
119:             *	@param value the path of the content file
120:             */
121:            public void setContentFile(String value) {
122:                contentFile = value;
123:            }
124:
125:            /**
126:             *	Set the description parameter of this element
127:             *
128:             *	@param value java.lang.String
129:             */
130:            public void setDescription(String value) {
131:                description = value;
132:            }
133:
134:            /**
135:             *	Set the id parameter of this element
136:             *
137:             *	@param value java.lang.String
138:             */
139:            public void setID(String value) {
140:                id = value;
141:            }
142:
143:            /**
144:             * Set the listener class name of this element.
145:             */
146:            public void setListenerClass(String value) {
147:                listenerClass = value;
148:            }
149:
150:            public CheatSheetListener createListenerInstance() {
151:                if (listenerClass == null || configurationElement == null) {
152:                    return null;
153:                }
154:
155:                Class extClass = null;
156:                CheatSheetListener listener = null;
157:                String pluginId = configurationElement.getContributor()
158:                        .getName();
159:
160:                try {
161:                    Bundle bundle = Platform.getBundle(pluginId);
162:                    extClass = bundle.loadClass(listenerClass);
163:                } catch (Exception e) {
164:                    String message = NLS.bind(Messages.ERROR_LOADING_CLASS,
165:                            (new Object[] { listenerClass }));
166:                    IStatus status = new Status(IStatus.ERROR,
167:                            ICheatSheetResource.CHEAT_SHEET_PLUGIN_ID,
168:                            IStatus.OK, message, e);
169:                    CheatSheetPlugin.getPlugin().getLog().log(status);
170:                }
171:                try {
172:                    if (extClass != null) {
173:                        listener = (CheatSheetListener) extClass.newInstance();
174:                    }
175:                } catch (Exception e) {
176:                    String message = NLS.bind(Messages.ERROR_CREATING_CLASS,
177:                            (new Object[] { listenerClass }));
178:                    IStatus status = new Status(IStatus.ERROR,
179:                            ICheatSheetResource.CHEAT_SHEET_PLUGIN_ID,
180:                            IStatus.OK, message, e);
181:                    CheatSheetPlugin.getPlugin().getLog().log(status);
182:                }
183:
184:                if (listener != null) {
185:                    return listener;
186:                }
187:
188:                return null;
189:            }
190:
191:            public String getLocalId() {
192:                return id;
193:            }
194:
195:            public String getPluginId() {
196:                return configurationElement.getContributor().getName();
197:            }
198:
199:            public void setComposite(boolean composite) {
200:                this .composite = composite;
201:            }
202:
203:            public boolean isComposite() {
204:                return composite;
205:            }
206:
207:            /**
208:             * Get a URL which is saved with the state so the cheatsheet can later be 
209:             * reopened from the state file.
210:             * @return null if the cheatsheet was opened from the registry otherwise
211:             * the URL of the content file.
212:             */
213:            public String getRestorePath() {
214:                if (!registered) {
215:                    return contentFile;
216:                }
217:                return null;
218:            }
219:
220:            public void setRegistered(boolean registered) {
221:                this .registered = registered;
222:            }
223:
224:            public boolean isRegistered() {
225:                return registered;
226:            }
227:
228:            public void setContentXml(String xml) {
229:                this .contentXml = xml;
230:            }
231:
232:            public String getContentXml() {
233:                return contentXml;
234:            }
235:
236:            public void setHref(String contentPath) {
237:                this .href = contentPath;
238:            }
239:
240:            public String getHref() {
241:                return href;
242:            }
243:
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.