Source Code Cross Referenced for NewExtensionRegistryReader.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » wizards » extension » 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 » Eclipse plug in development » org.eclipse.pde.internal.ui.wizards.extension 
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.pde.internal.ui.wizards.extension;
011:
012:        import java.util.Locale;
013:        import java.util.StringTokenizer;
014:
015:        import org.eclipse.core.runtime.IConfigurationElement;
016:        import org.eclipse.core.runtime.IExtension;
017:        import org.eclipse.core.runtime.IExtensionPoint;
018:        import org.eclipse.core.runtime.IExtensionRegistry;
019:        import org.eclipse.core.runtime.Platform;
020:        import org.eclipse.pde.internal.ui.PDEPlugin;
021:        import org.eclipse.pde.internal.ui.PDEUIMessages;
022:        import org.eclipse.pde.internal.ui.elements.ElementList;
023:        import org.eclipse.pde.internal.ui.wizards.Category;
024:        import org.eclipse.pde.internal.ui.wizards.WizardCollectionElement;
025:        import org.eclipse.pde.internal.ui.wizards.WizardElement;
026:        import org.eclipse.swt.graphics.Image;
027:
028:        public class NewExtensionRegistryReader {
029:            public static final String TAG_WIZARD = "wizard"; //$NON-NLS-1$
030:            public static final String TAG_EDITOR_WIZARD = "editorWizard"; //$NON-NLS-1$
031:            public static final String ATT_CATEGORY = "category"; //$NON-NLS-1$
032:            public static final String ATT_SHORTCUTTABLE = "availableAsShortcut"; //$NON-NLS-1$
033:            public static final String CATEGORY_SEPARATOR = "/"; //$NON-NLS-1$
034:            public static final String TAG_CATEGORY = "category"; //$NON-NLS-1$
035:            public static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
036:
037:            private final static String UNCATEGORIZED_WIZARD_CATEGORY = "org.eclipse.pde.ui.Other"; //$NON-NLS-1$
038:            private final static String UNCATEGORIZED_WIZARD_CATEGORY_LABEL = "Other"; //$NON-NLS-1$
039:
040:            private boolean editorWizardMode;
041:
042:            public NewExtensionRegistryReader() {
043:                this (false);
044:            }
045:
046:            public NewExtensionRegistryReader(boolean editorWizardMode) {
047:                this .editorWizardMode = editorWizardMode;
048:            }
049:
050:            protected WizardCollectionElement createCollectionElement(
051:                    WizardCollectionElement parent, String id, String label) {
052:                WizardCollectionElement newElement = new WizardCollectionElement(
053:                        id, label, parent);
054:
055:                if (parent != null)
056:                    parent.add(newElement);
057:
058:                return newElement;
059:            }
060:
061:            protected WizardElement createWizardElement(
062:                    IConfigurationElement config) {
063:                String name = config.getAttribute(WizardElement.ATT_NAME);
064:                String id = config.getAttribute(WizardElement.ATT_ID);
065:                String className = config.getAttribute(WizardElement.ATT_CLASS);
066:                String template = config
067:                        .getAttribute(WizardElement.ATT_TEMPLATE);
068:                if (name == null || id == null)
069:                    return null;
070:                if (className == null && template == null)
071:                    return null;
072:                WizardElement element = new WizardElement(config);
073:                String imageName = config.getAttribute(WizardElement.ATT_ICON);
074:                if (imageName != null) {
075:                    String pluginID = config.getNamespaceIdentifier();
076:                    Image image = PDEPlugin.getDefault().getLabelProvider()
077:                            .getImageFromPlugin(pluginID, imageName);
078:                    element.setImage(image);
079:                }
080:                return element;
081:            }
082:
083:            protected WizardElement createEditorWizardElement(
084:                    IConfigurationElement config) {
085:                String name = config.getAttribute(WizardElement.ATT_NAME);
086:                String id = config.getAttribute(WizardElement.ATT_ID);
087:                String className = config.getAttribute(WizardElement.ATT_CLASS);
088:                String point = config.getAttribute(WizardElement.ATT_POINT);
089:                if (name == null || id == null || className == null)
090:                    return null;
091:                if (point == null)
092:                    return null;
093:                WizardElement element = new WizardElement(config);
094:                String imageName = config.getAttribute(WizardElement.ATT_ICON);
095:                if (imageName != null) {
096:                    String pluginID = config.getNamespaceIdentifier();
097:                    Image image = PDEPlugin.getDefault().getLabelProvider()
098:                            .getImageFromPlugin(pluginID, imageName);
099:                    element.setImage(image);
100:                }
101:                return element;
102:            }
103:
104:            protected String getCategoryStringFor(IConfigurationElement config) {
105:                String result = config.getAttribute(ATT_CATEGORY);
106:                if (result == null)
107:                    result = UNCATEGORIZED_WIZARD_CATEGORY;
108:
109:                return result;
110:            }
111:
112:            protected WizardCollectionElement getChildWithID(
113:                    WizardCollectionElement parent, String id) {
114:                Object[] children = parent.getChildren();
115:
116:                if (children != null) {
117:                    for (int i = 0; i < children.length; i++) {
118:                        WizardCollectionElement currentChild = (WizardCollectionElement) children[i];
119:                        if (currentChild.getId().equals(id))
120:                            return currentChild;
121:                    }
122:                }
123:                return null;
124:            }
125:
126:            protected void insertUsingCategory(WizardElement element,
127:                    ElementList result) {
128:                WizardCollectionElement currentResult = (WizardCollectionElement) result;
129:                StringTokenizer familyTokenizer = new StringTokenizer(
130:                        getCategoryStringFor(element.getConfigurationElement()),
131:                        CATEGORY_SEPARATOR);
132:
133:                // use the period-separated sections of the current Wizard's category
134:                // to traverse through the NamedSolution "tree" that was previously
135:                // created
136:                WizardCollectionElement currentCollectionElement = currentResult; // ie.-
137:                // root
138:                boolean moveToOther = false;
139:
140:                while (familyTokenizer.hasMoreElements()) {
141:                    WizardCollectionElement tempCollectionElement = getChildWithID(
142:                            currentCollectionElement, familyTokenizer
143:                                    .nextToken());
144:
145:                    if (tempCollectionElement == null) { // can't find the path; bump it
146:                        // to uncategorized
147:                        moveToOther = true;
148:                        break;
149:                    }
150:                    currentCollectionElement = tempCollectionElement;
151:                }
152:
153:                if (moveToOther)
154:                    moveElementToUncategorizedCategory(currentResult, element);
155:                else
156:                    currentCollectionElement.getWizards().add(element);
157:            }
158:
159:            protected void moveElementToUncategorizedCategory(
160:                    WizardCollectionElement root, WizardElement element) {
161:                WizardCollectionElement otherCategory = getChildWithID(root,
162:                        UNCATEGORIZED_WIZARD_CATEGORY);
163:
164:                if (otherCategory == null)
165:                    otherCategory = createCollectionElement(root,
166:                            UNCATEGORIZED_WIZARD_CATEGORY,
167:                            UNCATEGORIZED_WIZARD_CATEGORY_LABEL);
168:
169:                otherCategory.getWizards().add(element);
170:            }
171:
172:            private void processCategory(IConfigurationElement config,
173:                    ElementList list) {
174:                WizardCollectionElement result = (WizardCollectionElement) list;
175:                Category category = null;
176:
177:                category = new Category(config);
178:                if (category.getID() == null || category.getLabel() == null) {
179:                    System.out
180:                            .println(PDEUIMessages.NewExtensionRegistryReader_missingProperty);
181:                    return;
182:                }
183:
184:                String[] categoryPath = category.getParentCategoryPath();
185:                WizardCollectionElement parent = result; // ie.- root
186:
187:                if (categoryPath != null) {
188:                    for (int i = 0; i < categoryPath.length; i++) {
189:                        WizardCollectionElement tempElement = getChildWithID(
190:                                parent, categoryPath[i]);
191:                        if (tempElement == null) {
192:                            parent = null;
193:                            break;
194:                        }
195:                        parent = tempElement;
196:                    }
197:                }
198:
199:                if (parent != null)
200:                    createCollectionElement(parent, category.getID(), category
201:                            .getLabel());
202:            }
203:
204:            protected void processElement(IConfigurationElement element,
205:                    ElementList result, boolean shortcutsOnly) {
206:                String tag = element.getName();
207:                if (tag.equals(TAG_WIZARD) && !editorWizardMode) {
208:                    WizardElement wizard = createWizardElement(element);
209:                    if (shortcutsOnly) {
210:                        String shortcut = element
211:                                .getAttribute(ATT_SHORTCUTTABLE);
212:                        if (shortcut != null
213:                                && shortcut.toLowerCase(Locale.ENGLISH).equals(
214:                                        "true")) { //$NON-NLS-1$
215:                            result.add(wizard);
216:                        }
217:                    } else
218:                        insertUsingCategory(wizard, result);
219:                } else if (tag.equals(TAG_EDITOR_WIZARD) && editorWizardMode) {
220:                    WizardElement wizard = createEditorWizardElement(element);
221:                    if (shortcutsOnly) {
222:                        result.add(wizard);
223:                    } else
224:                        insertUsingCategory(wizard, result);
225:                } else if (tag.equals(TAG_CATEGORY)) {
226:                    if (shortcutsOnly == false) {
227:                        processCategory(element, result);
228:                    }
229:                }
230:            }
231:
232:            public ElementList readRegistry(String pluginId,
233:                    String pluginPointId, boolean shortcutsOnly) {
234:                ElementList result = (shortcutsOnly) ? (new ElementList(
235:                        "shortcuts")) //$NON-NLS-1$
236:                        : (new WizardCollectionElement("root", "root", null)); //$NON-NLS-1$ //$NON-NLS-2$
237:                IExtensionRegistry registry = Platform.getExtensionRegistry();
238:                IExtensionPoint point = registry.getExtensionPoint(pluginId,
239:                        pluginPointId);
240:                if (point == null)
241:                    return null;
242:
243:                IExtension[] extensions = point.getExtensions();
244:                for (int i = 0; i < extensions.length; i++) {
245:                    IConfigurationElement[] elements = extensions[i]
246:                            .getConfigurationElements();
247:                    for (int j = 0; j < elements.length; j++) {
248:                        IConfigurationElement config = elements[j];
249:                        processElement(config, result, shortcutsOnly);
250:                    }
251:                }
252:                return result;
253:            }
254:        }
w_w___w_.__j__a__va_2___s__.__c___o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.