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


001:        /*******************************************************************************
002:         * Copyright (c) 2004, 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.wizards;
011:
012:        import org.eclipse.core.runtime.IConfigurationElement;
013:        import org.eclipse.core.runtime.IExtension;
014:        import org.eclipse.core.runtime.IExtensionPoint;
015:        import org.eclipse.core.runtime.Platform;
016:        import org.eclipse.core.runtime.dynamichelpers.ExtensionTracker;
017:        import org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler;
018:        import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
019:        import org.eclipse.ui.PlatformUI;
020:        import org.eclipse.ui.internal.dialogs.WizardCollectionElement;
021:        import org.eclipse.ui.internal.dialogs.WorkbenchWizardElement;
022:        import org.eclipse.ui.internal.registry.WizardsRegistryReader;
023:        import org.eclipse.ui.internal.util.Util;
024:        import org.eclipse.ui.wizards.IWizardDescriptor;
025:
026:        /**
027:         * Abstract baseclass for wizard registries that listen to extension changes.
028:         * 
029:         * @since 3.1
030:         */
031:        public abstract class AbstractExtensionWizardRegistry extends
032:                AbstractWizardRegistry implements  IExtensionChangeHandler {
033:
034:            /**
035:             * Create a new instance of this class.
036:             */
037:            public AbstractExtensionWizardRegistry() {
038:                super ();
039:            }
040:
041:            /* (non-Javadoc)
042:             * @see org.eclipse.core.runtime.dynamicHelpers.IExtensionChangeHandler#addExtension(org.eclipse.core.runtime.dynamicHelpers.IExtensionTracker, org.eclipse.core.runtime.IExtension)
043:             */
044:            public void addExtension(IExtensionTracker tracker,
045:                    IExtension extension) {
046:                WizardsRegistryReader reader = new WizardsRegistryReader(
047:                        getPlugin(), getExtensionPoint());
048:                reader.setInitialCollection(getWizardElements());
049:                IConfigurationElement[] configurationElements = extension
050:                        .getConfigurationElements();
051:                for (int i = 0; i < configurationElements.length; i++) {
052:                    reader.readElement(configurationElements[i]);
053:                }
054:                // no need to reset the wizard elements - getWizardElements will parse
055:                // the
056:                // results of the registry reading
057:                setWizardElements(reader.getWizardElements());
058:                // reregister all object handles - it'd be better to process the deltas
059:                // in this case
060:                registerWizards(getWizardElements());
061:
062:                // handle the primary wizards
063:                WorkbenchWizardElement[] additionalPrimary = reader
064:                        .getPrimaryWizards();
065:                if (additionalPrimary.length == 0) {
066:                    return;
067:                }
068:                IWizardDescriptor[] localPrimaryWizards = getPrimaryWizards();
069:                WorkbenchWizardElement[] newPrimary = new WorkbenchWizardElement[additionalPrimary.length
070:                        + localPrimaryWizards.length];
071:                System.arraycopy(localPrimaryWizards, 0, newPrimary, 0,
072:                        localPrimaryWizards.length);
073:                System.arraycopy(additionalPrimary, 0, newPrimary,
074:                        localPrimaryWizards.length, additionalPrimary.length);
075:                setPrimaryWizards(newPrimary);
076:            }
077:
078:            /* (non-Javadoc)
079:             * @see org.eclipse.ui.internal.wizards.AbstractWizardRegistry#dispose()
080:             */
081:            public void dispose() {
082:                super .dispose();
083:                PlatformUI.getWorkbench().getExtensionTracker()
084:                        .unregisterHandler(this );
085:            }
086:
087:            /*
088:             * (non-Javadoc)
089:             * 
090:             * @see org.eclipse.ui.internal.wizards.AbstractWizardRegistry#doInitialize()
091:             */
092:            protected void doInitialize() {
093:
094:                PlatformUI
095:                        .getWorkbench()
096:                        .getExtensionTracker()
097:                        .registerHandler(
098:                                this ,
099:                                ExtensionTracker
100:                                        .createExtensionPointFilter(getExtensionPointFilter()));
101:
102:                WizardsRegistryReader reader = new WizardsRegistryReader(
103:                        getPlugin(), getExtensionPoint());
104:                setWizardElements(reader.getWizardElements());
105:                setPrimaryWizards(reader.getPrimaryWizards());
106:                registerWizards(getWizardElements());
107:            }
108:
109:            /**
110:             * Return the extension point id that should be used for extension registry
111:             * queries.
112:             * 
113:             * @return the extension point id
114:             */
115:            protected abstract String getExtensionPoint();
116:
117:            private IExtensionPoint getExtensionPointFilter() {
118:                return Platform.getExtensionRegistry().getExtensionPoint(
119:                        getPlugin(), getExtensionPoint());
120:            }
121:
122:            /**
123:             * Return the plugin id that should be used for extension registry queries.
124:             * 
125:             * @return the plugin id
126:             */
127:            protected abstract String getPlugin();
128:
129:            /**
130:             * Register the object with the workbench tracker.
131:             * 
132:             * @param extension
133:             *            the originating extension
134:             * @param object
135:             *            the object to track
136:             */
137:            private void register(IExtension extension, Object object) {
138:                PlatformUI.getWorkbench().getExtensionTracker().registerObject(
139:                        extension, object, IExtensionTracker.REF_WEAK);
140:            }
141:
142:            /**
143:             * Register all wizards in the given collection with the extension tracker.
144:             * 
145:             * @param collection
146:             *            the collection to register
147:             */
148:            private void registerWizards(WizardCollectionElement collection) {
149:                registerWizards(collection.getWorkbenchWizardElements());
150:
151:                WizardCollectionElement[] collections = collection
152:                        .getCollectionElements();
153:                for (int i = 0; i < collections.length; i++) {
154:                    IConfigurationElement configurationElement = collections[i]
155:                            .getConfigurationElement();
156:                    if (configurationElement != null) {
157:                        register(configurationElement.getDeclaringExtension(),
158:                                collections[i]);
159:                    }
160:                    registerWizards(collections[i]);
161:                }
162:            }
163:
164:            /**
165:             * Register all wizards in the given array.
166:             * 
167:             * @param wizards
168:             *            the wizards to register
169:             */
170:            private void registerWizards(WorkbenchWizardElement[] wizards) {
171:                for (int i = 0; i < wizards.length; i++) {
172:                    register(wizards[i].getConfigurationElement()
173:                            .getDeclaringExtension(), wizards[i]);
174:                }
175:            }
176:
177:            /* (non-Javadoc)
178:             * @see org.eclipse.core.runtime.dynamicHelpers.IExtensionChangeHandler#removeExtension(org.eclipse.core.runtime.IExtension, java.lang.Object[])
179:             */
180:            public void removeExtension(IExtension extension, Object[] objects) {
181:                if (!extension.getExtensionPointUniqueIdentifier().equals(
182:                        getExtensionPointFilter().getUniqueIdentifier())) {
183:                    return;
184:                }
185:                for (int i = 0; i < objects.length; i++) {
186:                    Object object = objects[i];
187:                    if (object instanceof  WizardCollectionElement) {
188:                        // TODO: should we move child wizards to the "other" node?
189:                        WizardCollectionElement collection = (WizardCollectionElement) object;
190:                        collection.getParentCollection().remove(collection);
191:                    } else if (object instanceof  WorkbenchWizardElement) {
192:                        WorkbenchWizardElement wizard = (WorkbenchWizardElement) object;
193:                        WizardCollectionElement parent = wizard
194:                                .getCollectionElement();
195:                        if (parent != null) {
196:                            parent.remove(wizard);
197:                        }
198:                        IWizardDescriptor[] primaryWizards = getPrimaryWizards();
199:                        for (int j = 0; j < primaryWizards.length; j++) {
200:                            if (primaryWizards[j] == wizard) {
201:                                WorkbenchWizardElement[] newPrimary = new WorkbenchWizardElement[primaryWizards.length - 1];
202:                                Util.arrayCopyWithRemoval(primaryWizards,
203:                                        newPrimary, j);
204:                                primaryWizards = newPrimary;
205:                                break;
206:                            }
207:                        }
208:                        setPrimaryWizards((WorkbenchWizardElement[]) primaryWizards);
209:                    }
210:                }
211:            }
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.