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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 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.registry;
011:
012:        import java.util.ArrayList;
013:        import java.util.Arrays;
014:        import java.util.List;
015:
016:        import org.eclipse.core.runtime.CoreException;
017:        import org.eclipse.core.runtime.IConfigurationElement;
018:        import org.eclipse.core.runtime.IExtension;
019:        import org.eclipse.core.runtime.IStatus;
020:        import org.eclipse.core.runtime.Status;
021:        import org.eclipse.jface.resource.ImageDescriptor;
022:        import org.eclipse.ui.IPluginContribution;
023:        import org.eclipse.ui.IWorkingSetElementAdapter;
024:        import org.eclipse.ui.IWorkingSetUpdater;
025:        import org.eclipse.ui.dialogs.IWorkingSetPage;
026:        import org.eclipse.ui.internal.WorkbenchPlugin;
027:        import org.eclipse.ui.plugin.AbstractUIPlugin;
028:
029:        /**
030:         * A working set descriptor stores the plugin registry data for 
031:         * a working set page extension.
032:         * 
033:         * @since 2.0
034:         */
035:        public class WorkingSetDescriptor implements  IPluginContribution {
036:            private String id;
037:
038:            private String name;
039:
040:            private String icon;
041:
042:            private String pageClassName;
043:
044:            private String updaterClassName;
045:
046:            private IConfigurationElement configElement;
047:
048:            private String[] classTypes;
049:
050:            private String[] adapterTypes;
051:
052:            private static final String ATT_ID = "id"; //$NON-NLS-1$
053:
054:            private static final String ATT_NAME = "name"; //$NON-NLS-1$
055:
056:            private static final String ATT_ICON = "icon"; //$NON-NLS-1$	
057:
058:            private static final String ATT_PAGE_CLASS = "pageClass"; //$NON-NLS-1$
059:
060:            private static final String ATT_UPDATER_CLASS = "updaterClass"; //$NON-NLS-1$
061:
062:            private static final String ATT_ELEMENT_ADAPTER_CLASS = "elementAdapterClass"; //$NON-NLS-1$
063:
064:            private static final String TAG_APPLICABLE_TYPE = "applicableType"; //$NON-NLS-1$
065:
066:            /**
067:             * Creates a descriptor from a configuration element.
068:             * 
069:             * @param configElement configuration element to create a descriptor from
070:             */
071:            public WorkingSetDescriptor(IConfigurationElement configElement)
072:                    throws CoreException {
073:                super ();
074:                this .configElement = configElement;
075:                id = configElement.getAttribute(ATT_ID);
076:                name = configElement.getAttribute(ATT_NAME);
077:                icon = configElement.getAttribute(ATT_ICON);
078:                pageClassName = configElement.getAttribute(ATT_PAGE_CLASS);
079:                updaterClassName = configElement
080:                        .getAttribute(ATT_UPDATER_CLASS);
081:
082:                if (name == null) {
083:                    throw new CoreException(new Status(IStatus.ERROR,
084:                            WorkbenchPlugin.PI_WORKBENCH, 0,
085:                            "Invalid extension (missing class name): " + id, //$NON-NLS-1$
086:                            null));
087:                }
088:
089:                IConfigurationElement[] containsChildren = configElement
090:                        .getChildren(TAG_APPLICABLE_TYPE);
091:                if (containsChildren.length > 0) {
092:                    List byClassList = new ArrayList(containsChildren.length);
093:                    List byAdapterList = new ArrayList(containsChildren.length);
094:                    for (int i = 0; i < containsChildren.length; i++) {
095:                        IConfigurationElement child = containsChildren[i];
096:                        String className = child
097:                                .getAttribute(IWorkbenchRegistryConstants.ATT_CLASS);
098:                        if (className != null)
099:                            byClassList.add(className);
100:                        if ("true".equals(child.getAttribute(IWorkbenchRegistryConstants.ATT_ADAPTABLE))) //$NON-NLS-1$
101:                            byAdapterList.add(className);
102:                    }
103:                    if (!byClassList.isEmpty()) {
104:                        classTypes = (String[]) byClassList
105:                                .toArray(new String[byClassList.size()]);
106:                        Arrays.sort(classTypes);
107:                    }
108:
109:                    if (!byAdapterList.isEmpty()) {
110:                        adapterTypes = (String[]) byAdapterList
111:                                .toArray(new String[byAdapterList.size()]);
112:                        Arrays.sort(adapterTypes);
113:                    }
114:                }
115:            }
116:
117:            /**
118:             * Returns the name space that declares this working set.
119:             * 
120:             * @return the name space declaring this working set
121:             */
122:            public String getDeclaringNamespace() {
123:                return configElement.getNamespace();
124:            }
125:
126:            /**
127:             * Return the namespace that contains the class referenced by the
128:             * updaterClass. May be the bundle that declared this extension or another
129:             * bundle that contains the referenced class.
130:             * 
131:             * @return the namespace
132:             * @since 3.3
133:             */
134:            public String getUpdaterNamespace() {
135:                return WorkbenchPlugin.getBundleForExecutableExtension(
136:                        configElement, ATT_UPDATER_CLASS).getSymbolicName();
137:            }
138:
139:            /**
140:             * Return the namespace that contains the class referenced by the
141:             * elementAdapterClass. May be the bundle that declared this extension or
142:             * another bundle that contains the referenced class.
143:             * 
144:             * @return the namespace
145:             * @since 3.3
146:             */
147:            public String getElementAdapterNamespace() {
148:                return WorkbenchPlugin.getBundleForExecutableExtension(
149:                        configElement, ATT_UPDATER_CLASS).getSymbolicName();
150:            }
151:
152:            /**
153:             * Creates a working set page from this extension descriptor.
154:             * 
155:             * @return a working set page created from this extension descriptor.
156:             */
157:            public IWorkingSetPage createWorkingSetPage() {
158:                Object page = null;
159:
160:                if (pageClassName != null) {
161:                    try {
162:                        page = WorkbenchPlugin.createExtension(configElement,
163:                                ATT_PAGE_CLASS);
164:                    } catch (CoreException exception) {
165:                        WorkbenchPlugin.log(
166:                                "Unable to create working set page: " + //$NON-NLS-1$
167:                                        pageClassName, exception.getStatus());
168:                    }
169:                }
170:                return (IWorkingSetPage) page;
171:            }
172:
173:            /**
174:             * Returns the page's icon
175:             * 
176:             * @return the page's icon
177:             */
178:            public ImageDescriptor getIcon() {
179:                if (icon == null) {
180:                    return null;
181:                }
182:
183:                IExtension extension = configElement.getDeclaringExtension();
184:                String extendingPluginId = extension.getNamespace();
185:                return AbstractUIPlugin.imageDescriptorFromPlugin(
186:                        extendingPluginId, icon);
187:            }
188:
189:            /**
190:             * Returns the working set page id.
191:             * 
192:             * @return the working set page id.
193:             */
194:            public String getId() {
195:                return id;
196:            }
197:
198:            /**
199:             * Returns the working set page class name
200:             * 
201:             * @return the working set page class name or <code>null</code> if
202:             *  no page class name has been provided by the extension
203:             */
204:            public String getPageClassName() {
205:                return pageClassName;
206:            }
207:
208:            /**
209:             * Returns the name of the working set element type the 
210:             * page works with.
211:             * 
212:             * @return the working set element type name
213:             */
214:            public String getName() {
215:                return name;
216:            }
217:
218:            /**
219:             * Returns the working set updater class name
220:             * 
221:             * @return the working set updater class name or <code>null</code> if
222:             *  no updater class name has been provided by the extension
223:             */
224:            public String getUpdaterClassName() {
225:                return updaterClassName;
226:            }
227:
228:            /**
229:             * Creates a working set element adapter.
230:             * 
231:             * @return the element adapter or <code>null</code> if no adapter has been
232:             *         declared
233:             */
234:            public IWorkingSetElementAdapter createWorkingSetElementAdapter() {
235:                if (!WorkbenchPlugin.hasExecutableExtension(configElement,
236:                        ATT_ELEMENT_ADAPTER_CLASS))
237:                    return null;
238:                IWorkingSetElementAdapter result = null;
239:                try {
240:                    result = (IWorkingSetElementAdapter) WorkbenchPlugin
241:                            .createExtension(configElement,
242:                                    ATT_ELEMENT_ADAPTER_CLASS);
243:                } catch (CoreException exception) {
244:                    WorkbenchPlugin.log(
245:                            "Unable to create working set element adapter: " + //$NON-NLS-1$
246:                                    result, exception.getStatus());
247:                }
248:                return result;
249:            }
250:
251:            /**
252:             * Creates a working set updater.
253:             * 
254:             * @return the working set updater or <code>null</code> if no updater has
255:             *         been declared
256:             */
257:            public IWorkingSetUpdater createWorkingSetUpdater() {
258:                if (updaterClassName == null) {
259:                    return null;
260:                }
261:                IWorkingSetUpdater result = null;
262:                try {
263:                    result = (IWorkingSetUpdater) WorkbenchPlugin
264:                            .createExtension(configElement, ATT_UPDATER_CLASS);
265:                } catch (CoreException exception) {
266:                    WorkbenchPlugin.log(
267:                            "Unable to create working set updater: " + //$NON-NLS-1$
268:                                    updaterClassName, exception.getStatus());
269:                }
270:                return result;
271:            }
272:
273:            public boolean isUpdaterClassLoaded() {
274:                return WorkbenchPlugin.isBundleLoadedForExecutableExtension(
275:                        configElement, ATT_UPDATER_CLASS);
276:            }
277:
278:            public boolean isElementAdapterClassLoaded() {
279:                return WorkbenchPlugin.isBundleLoadedForExecutableExtension(
280:                        configElement, ATT_ELEMENT_ADAPTER_CLASS);
281:            }
282:
283:            /**
284:             * Returns whether working sets based on this descriptor are editable.
285:             * 
286:             * @return <code>true</code> if working sets based on this descriptor are editable; otherwise
287:             *  <code>false</code>
288:             * 
289:             * @since 3.1
290:             */
291:            public boolean isEditable() {
292:                return getPageClassName() != null;
293:            }
294:
295:            public String getLocalId() {
296:                return getId();
297:            }
298:
299:            public String getPluginId() {
300:                return getDeclaringNamespace();
301:            }
302:
303:            /**
304:             * Return the config element for this descriptor.
305:             * 
306:             * @return the config element
307:             * @since 3.3
308:             */
309:            public IConfigurationElement getConfigurationElement() {
310:                return configElement;
311:            }
312:
313:            /**
314:             * Return the description for this working set type.
315:             * 
316:             * @return the description for this type. May be an empty string.
317:             * @since 3.4
318:             */
319:            public String getDescription() {
320:                String description = configElement
321:                        .getAttribute(IWorkbenchRegistryConstants.ATT_DESCRIPTION);
322:                if (description == null)
323:                    description = ""; //$NON-NLS-1$
324:                return description;
325:            }
326:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.