Source Code Cross Referenced for WorkingSetRegistry.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, 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.internal.registry;
011:
012:        import java.util.ArrayList;
013:        import java.util.Collection;
014:        import java.util.HashMap;
015:        import java.util.Iterator;
016:        import java.util.List;
017:
018:        import org.eclipse.core.runtime.Assert;
019:        import org.eclipse.core.runtime.IConfigurationElement;
020:        import org.eclipse.core.runtime.IExtension;
021:        import org.eclipse.core.runtime.IExtensionPoint;
022:        import org.eclipse.core.runtime.Platform;
023:        import org.eclipse.core.runtime.dynamichelpers.ExtensionTracker;
024:        import org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler;
025:        import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
026:        import org.eclipse.ui.PlatformUI;
027:        import org.eclipse.ui.dialogs.IWorkingSetPage;
028:
029:        /**
030:         * Stores working set descriptors for working set extensions.
031:         */
032:        public class WorkingSetRegistry implements  IExtensionChangeHandler {
033:            // used in Workbench plugin.xml for default workingSet extension
034:            // @issue this is an IDE specific working set page!
035:            private static final String DEFAULT_PAGE_ID = "org.eclipse.ui.resourceWorkingSetPage"; //$NON-NLS-1$
036:
037:            private HashMap/*<String, WorkingSetDescriptor>*/workingSetDescriptors = new HashMap();
038:
039:            /**
040:             * 
041:             */
042:            public WorkingSetRegistry() {
043:                IExtensionTracker tracker = PlatformUI.getWorkbench()
044:                        .getExtensionTracker();
045:                tracker.registerHandler(this , ExtensionTracker
046:                        .createExtensionPointFilter(getExtensionPointFilter()));
047:
048:            }
049:
050:            /**
051:             * 
052:             * @return
053:             * @since 3.3
054:             */
055:            private IExtensionPoint getExtensionPointFilter() {
056:                return Platform.getExtensionRegistry().getExtensionPoint(
057:                        PlatformUI.PLUGIN_ID,
058:                        IWorkbenchRegistryConstants.PL_WORKINGSETS);
059:            }
060:
061:            /**
062:             * Adds a working set descriptor.
063:             * 
064:             * @param descriptor working set descriptor to add. Must not 
065:             * 	exist in the registry yet.
066:             */
067:            public void addWorkingSetDescriptor(WorkingSetDescriptor descriptor) {
068:                Assert.isTrue(!workingSetDescriptors.containsValue(descriptor),
069:                        "working set descriptor already registered"); //$NON-NLS-1$
070:                IExtensionTracker tracker = PlatformUI.getWorkbench()
071:                        .getExtensionTracker();
072:                tracker.registerObject(descriptor.getConfigurationElement()
073:                        .getDeclaringExtension(), descriptor,
074:                        IExtensionTracker.REF_WEAK);
075:                workingSetDescriptors.put(descriptor.getId(), descriptor);
076:            }
077:
078:            /**
079:             * Returns the default, resource based, working set page
080:             * 
081:             * @return the default working set page.
082:             */
083:            public IWorkingSetPage getDefaultWorkingSetPage() {
084:                // @issue this will return the IDE resource working set page... not good for generic workbench
085:                WorkingSetDescriptor descriptor = (WorkingSetDescriptor) workingSetDescriptors
086:                        .get(DEFAULT_PAGE_ID);
087:
088:                if (descriptor != null) {
089:                    return descriptor.createWorkingSetPage();
090:                }
091:                return null;
092:            }
093:
094:            /**
095:             * Returns the working set descriptor with the given id.
096:             * 
097:             * @param pageId working set page id
098:             * @return the working set descriptor with the given id.
099:             */
100:            public WorkingSetDescriptor getWorkingSetDescriptor(String pageId) {
101:                return (WorkingSetDescriptor) workingSetDescriptors.get(pageId);
102:            }
103:
104:            /**
105:             * Returns an array of all working set descriptors.
106:             * 
107:             * @return an array of all working set descriptors.
108:             */
109:            public WorkingSetDescriptor[] getWorkingSetDescriptors() {
110:                return (WorkingSetDescriptor[]) workingSetDescriptors.values()
111:                        .toArray(
112:                                new WorkingSetDescriptor[workingSetDescriptors
113:                                        .size()]);
114:            }
115:
116:            /**
117:             * Returns an array of all working set descriptors having
118:             * a page class attribute
119:             * 
120:             * @return an array of all working set descriptors having a 
121:             * page class attribute
122:             */
123:            public WorkingSetDescriptor[] getNewPageWorkingSetDescriptors() {
124:                Collection descriptors = workingSetDescriptors.values();
125:                List result = new ArrayList(descriptors.size());
126:                for (Iterator iter = descriptors.iterator(); iter.hasNext();) {
127:                    WorkingSetDescriptor descriptor = (WorkingSetDescriptor) iter
128:                            .next();
129:                    if (descriptor.getPageClassName() != null) {
130:                        result.add(descriptor);
131:                    }
132:                }
133:                return (WorkingSetDescriptor[]) result
134:                        .toArray(new WorkingSetDescriptor[result.size()]);
135:            }
136:
137:            /**
138:             * Returns <code>true</code> if there is a working set descriptor with
139:             * a page class attribute. Otherwise <code>false</code> is returned.
140:             * 
141:             * @return whether a descriptor with a page class attribute exists
142:             */
143:            public boolean hasNewPageWorkingSetDescriptor() {
144:                Collection descriptors = workingSetDescriptors.values();
145:                for (Iterator iter = descriptors.iterator(); iter.hasNext();) {
146:                    WorkingSetDescriptor descriptor = (WorkingSetDescriptor) iter
147:                            .next();
148:                    if (descriptor.getPageClassName() != null) {
149:                        return true;
150:                    }
151:                }
152:                return false;
153:            }
154:
155:            public WorkingSetDescriptor[] getUpdaterDescriptorsForNamespace(
156:                    String namespace) {
157:                Collection descriptors = workingSetDescriptors.values();
158:                List result = new ArrayList();
159:                for (Iterator iter = descriptors.iterator(); iter.hasNext();) {
160:                    WorkingSetDescriptor descriptor = (WorkingSetDescriptor) iter
161:                            .next();
162:                    if (namespace.equals(descriptor.getUpdaterNamespace())) {
163:                        result.add(descriptor);
164:                    }
165:                }
166:                return (WorkingSetDescriptor[]) result
167:                        .toArray(new WorkingSetDescriptor[result.size()]);
168:            }
169:
170:            public WorkingSetDescriptor[] getElementAdapterDescriptorsForNamespace(
171:                    String namespace) {
172:                Collection descriptors = workingSetDescriptors.values();
173:                List result = new ArrayList();
174:                for (Iterator iter = descriptors.iterator(); iter.hasNext();) {
175:                    WorkingSetDescriptor descriptor = (WorkingSetDescriptor) iter
176:                            .next();
177:                    if (namespace.equals(descriptor.getDeclaringNamespace())) {
178:                        result.add(descriptor);
179:                    }
180:                }
181:                return (WorkingSetDescriptor[]) result
182:                        .toArray(new WorkingSetDescriptor[result.size()]);
183:            }
184:
185:            /**
186:             * Returns the working set page with the given id.
187:             * 
188:             * @param pageId working set page id
189:             * @return the working set page with the given id.
190:             */
191:            public IWorkingSetPage getWorkingSetPage(String pageId) {
192:                WorkingSetDescriptor descriptor = (WorkingSetDescriptor) workingSetDescriptors
193:                        .get(pageId);
194:
195:                if (descriptor == null) {
196:                    return null;
197:                }
198:                return descriptor.createWorkingSetPage();
199:            }
200:
201:            /**
202:             * Loads the working set registry.
203:             */
204:            public void load() {
205:                WorkingSetRegistryReader reader = new WorkingSetRegistryReader();
206:                reader.readWorkingSets(Platform.getExtensionRegistry(), this );
207:            }
208:
209:            /* (non-Javadoc)
210:             * @see org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler#addExtension(org.eclipse.core.runtime.dynamichelpers.IExtensionTracker, org.eclipse.core.runtime.IExtension)
211:             */
212:            public void addExtension(IExtensionTracker tracker,
213:                    IExtension extension) {
214:                WorkingSetRegistryReader reader = new WorkingSetRegistryReader(
215:                        this );
216:                IConfigurationElement[] elements = extension
217:                        .getConfigurationElements();
218:                for (int i = 0; i < elements.length; i++) {
219:                    reader.readElement(elements[i]);
220:                }
221:            }
222:
223:            /* (non-Javadoc)
224:             * @see org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler#removeExtension(org.eclipse.core.runtime.IExtension, java.lang.Object[])
225:             */
226:            public void removeExtension(IExtension extension, Object[] objects) {
227:                for (int i = 0; i < objects.length; i++) {
228:                    if (objects[i] instanceof  WorkingSetDescriptor) {
229:                        WorkingSetDescriptor desc = (WorkingSetDescriptor) objects[i];
230:                        workingSetDescriptors.remove(desc.getId());
231:                    }
232:                }
233:            }
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.