Source Code Cross Referenced for PreferencePageRegistryReader.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.List;
015:
016:        import org.eclipse.core.runtime.IConfigurationElement;
017:        import org.eclipse.core.runtime.IExtensionRegistry;
018:        import org.eclipse.jface.preference.IPreferenceNode;
019:        import org.eclipse.ui.IWorkbench;
020:        import org.eclipse.ui.PlatformUI;
021:        import org.eclipse.ui.internal.Workbench;
022:        import org.eclipse.ui.internal.dialogs.WorkbenchPreferenceNode;
023:
024:        /**
025:         *  Instances access the registry that is provided at creation time in order
026:         *  to determine the contributed preference pages
027:         */
028:        public class PreferencePageRegistryReader extends
029:                CategorizedPageRegistryReader {
030:
031:            private static final String TAG_PAGE = "page"; //$NON-NLS-1$
032:
033:            private List nodes;
034:
035:            private IWorkbench workbench;
036:
037:            class PreferencesCategoryNode extends CategoryNode {
038:
039:                WorkbenchPreferenceNode node;
040:
041:                /**
042:                 * Create a new instance of the receiver.
043:                 * @param reader
044:                 * @param nodeToCategorize
045:                 */
046:                public PreferencesCategoryNode(
047:                        CategorizedPageRegistryReader reader,
048:                        WorkbenchPreferenceNode nodeToCategorize) {
049:                    super (reader);
050:                    this .node = nodeToCategorize;
051:                }
052:
053:                /* (non-Javadoc)
054:                 * @see org.eclipse.ui.internal.registry.CategorizedPageRegistryReader.CategoryNode#getLabelText()
055:                 */
056:                String getLabelText() {
057:                    return node.getLabelText();
058:                }
059:
060:                /* (non-Javadoc)
061:                 * @see org.eclipse.ui.internal.registry.CategorizedPageRegistryReader.CategoryNode#getLabelText(java.lang.Object)
062:                 */
063:                String getLabelText(Object element) {
064:                    return ((WorkbenchPreferenceNode) element).getLabelText();
065:                }
066:
067:                /* (non-Javadoc)
068:                 * @see org.eclipse.ui.internal.registry.CategorizedPageRegistryReader.CategoryNode#getNode()
069:                 */
070:                Object getNode() {
071:                    return node;
072:                }
073:            }
074:
075:            /**
076:             * Create a new instance configured with the workbench
077:             * 
078:             * @param newWorkbench the workbench
079:             */
080:            public PreferencePageRegistryReader(IWorkbench newWorkbench) {
081:                workbench = newWorkbench;
082:            }
083:
084:            /* (non-Javadoc)
085:             * @see org.eclipse.ui.internal.registry.CategorizedPageRegistryReader#findNode(java.lang.String)
086:             */
087:            Object findNode(String id) {
088:                for (int i = 0; i < nodes.size(); i++) {
089:                    WorkbenchPreferenceNode node = (WorkbenchPreferenceNode) nodes
090:                            .get(i);
091:                    if (node.getId().equals(id)) {
092:                        return node;
093:                    }
094:                }
095:                return null;
096:            }
097:
098:            /* (non-Javadoc)
099:             * @see org.eclipse.ui.internal.registry.CategorizedPageRegistryReader#findNode(java.lang.Object, java.lang.String)
100:             */
101:            Object findNode(Object parent, String currentToken) {
102:                IPreferenceNode[] subNodes = ((WorkbenchPreferenceNode) parent)
103:                        .getSubNodes();
104:                for (int i = 0; i < subNodes.length; i++) {
105:                    WorkbenchPreferenceNode node = (WorkbenchPreferenceNode) subNodes[i];
106:                    if (node.getId().equals(currentToken)) {
107:                        return node;
108:                    }
109:                }
110:                return null;
111:            }
112:
113:            /* (non-Javadoc)
114:             * @see org.eclipse.ui.internal.registry.CategorizedPageRegistryReader#add(java.lang.Object, java.lang.Object)
115:             */
116:            void add(Object parent, Object node) {
117:                ((IPreferenceNode) parent).add((IPreferenceNode) node);
118:            }
119:
120:            /* (non-Javadoc)
121:             * @see org.eclipse.ui.internal.registry.CategorizedPageRegistryReader#createCategoryNode(org.eclipse.ui.internal.registry.CategorizedPageRegistryReader, java.lang.Object)
122:             */
123:            CategoryNode createCategoryNode(
124:                    CategorizedPageRegistryReader reader, Object object) {
125:                return new PreferencesCategoryNode(reader,
126:                        (WorkbenchPreferenceNode) object);
127:            }
128:
129:            /* (non-Javadoc)
130:             * @see org.eclipse.ui.internal.registry.CategorizedPageRegistryReader#getCategory(java.lang.Object)
131:             */
132:            String getCategory(Object node) {
133:                return ((WorkbenchPreferenceNode) node).getCategory();
134:            }
135:
136:            /* (non-Javadoc)
137:             * @see org.eclipse.ui.internal.registry.CategorizedPageRegistryReader#getNodes()
138:             */
139:            Collection getNodes() {
140:                return nodes;
141:            }
142:
143:            /**
144:             * Load the preference page contirbutions from the registry and
145:             * organize preference node contributions by category into hierarchies
146:             * If there is no page for a given node in the hierarchy then a blank
147:             * page will be created.
148:             * If no category has been specified or category information
149:             * is incorrect, page will appear at the root level. workbench
150:             * log entry will be created for incorrect category information.
151:             * 
152:             * @param registry the extension registry
153:             */
154:            public void loadFromRegistry(IExtensionRegistry registry) {
155:                nodes = new ArrayList();
156:
157:                readRegistry(registry, PlatformUI.PLUGIN_ID,
158:                        IWorkbenchRegistryConstants.PL_PREFERENCES);
159:
160:                processNodes();
161:
162:            }
163:
164:            /**
165:             * Read preference page element.
166:             */
167:            protected boolean readElement(IConfigurationElement element) {
168:                if (element.getName().equals(TAG_PAGE) == false) {
169:                    return false;
170:                }
171:                WorkbenchPreferenceNode node = createNode(element);
172:                if (node != null) {
173:                    nodes.add(node);
174:                }
175:                return true;
176:            }
177:
178:            /**
179:             * Create a workbench preference node.
180:             * @param element
181:             * @return WorkbenchPreferenceNode
182:             */
183:            public static WorkbenchPreferenceNode createNode(
184:                    IConfigurationElement element) {
185:                boolean nameMissing = element
186:                        .getAttribute(IWorkbenchRegistryConstants.ATT_NAME) == null;
187:                String id = element
188:                        .getAttribute(IWorkbenchRegistryConstants.ATT_ID);
189:                boolean classMissing = getClassValue(element,
190:                        IWorkbenchRegistryConstants.ATT_CLASS) == null;
191:
192:                if (nameMissing) {
193:                    logMissingAttribute(element,
194:                            IWorkbenchRegistryConstants.ATT_NAME);
195:                }
196:                if (id == null) {
197:                    logMissingAttribute(element,
198:                            IWorkbenchRegistryConstants.ATT_ID);
199:                }
200:                if (classMissing) {
201:                    logMissingAttribute(element,
202:                            IWorkbenchRegistryConstants.ATT_CLASS);
203:                }
204:
205:                if (nameMissing || id == null || classMissing) {
206:                    return null;
207:                }
208:
209:                WorkbenchPreferenceNode node = new WorkbenchPreferenceNode(id,
210:                        element);
211:                return node;
212:            }
213:
214:            /**
215:             * Return the top level IPreferenceNodes.
216:             * @return  Collection of IPreferenceNode.
217:             */
218:            public Collection getTopLevelNodes() {
219:                return topLevelNodes;
220:            }
221:
222:            /* (non-Javadoc)
223:             * @see org.eclipse.ui.internal.registry.CategorizedPageRegistryReader#getFavoriteNodeId()
224:             */
225:            String getFavoriteNodeId() {
226:                return ((Workbench) workbench).getMainPreferencePageId();
227:            }
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.