Source Code Cross Referenced for PreferenceTransferRegistryReader.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) 2005, 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 com.ibm.icu.text.Collator;
013:        import java.util.ArrayList;
014:        import java.util.Collections;
015:        import java.util.Comparator;
016:        import java.util.HashMap;
017:        import java.util.List;
018:        import java.util.Map;
019:
020:        import org.eclipse.core.runtime.IConfigurationElement;
021:        import org.eclipse.core.runtime.IExtensionRegistry;
022:        import org.eclipse.core.runtime.Platform;
023:        import org.eclipse.core.runtime.preferences.PreferenceFilterEntry;
024:        import org.eclipse.ui.internal.WorkbenchPlugin;
025:        import org.eclipse.ui.internal.preferences.PreferenceTransferElement;
026:
027:        /**
028:         * Preference Transfer registry reader to read extenders of the
029:         * preferenceTranser schema.
030:         * 
031:         * @since 3.1
032:         */
033:        public class PreferenceTransferRegistryReader extends RegistryReader {
034:            private List preferenceTransfers;
035:
036:            private String pluginPoint;
037:
038:            /**
039:             * Create an instance of this class.
040:             * 
041:             * @param pluginPointId
042:             *            java.lang.String
043:             */
044:            public PreferenceTransferRegistryReader(String pluginPointId) {
045:                pluginPoint = pluginPointId;
046:            }
047:
048:            /**
049:             * Returns a new PreferenceTransferElement configured according to the
050:             * parameters contained in the passed Registry.
051:             * 
052:             * May answer null if there was not enough information in the Extension to
053:             * create an adequate wizard
054:             */
055:            protected PreferenceTransferElement createPreferenceTransferElement(
056:                    IConfigurationElement element) {
057:                // PreferenceTransfers must have a name and class attribute
058:                if (element.getAttribute(IWorkbenchRegistryConstants.ATT_NAME) == null) {
059:                    logMissingAttribute(element,
060:                            IWorkbenchRegistryConstants.ATT_NAME);
061:                    return null;
062:                }
063:
064:                // must specifiy a mapping
065:                if (element
066:                        .getChildren(IWorkbenchRegistryConstants.TAG_MAPPING) == null) {
067:                    logMissingElement(element,
068:                            IWorkbenchRegistryConstants.TAG_MAPPING);
069:                    return null;
070:                }
071:
072:                return new PreferenceTransferElement(element);
073:            }
074:
075:            /**
076:             * Returns a sorted list of preference transfers.
077:             * 
078:             * @return an array of <code>IPreferenceTransfer</code> objects
079:             */
080:            public PreferenceTransferElement[] getPreferenceTransfers() {
081:                readPreferenceTransfers();
082:                PreferenceTransferElement[] transfers = new PreferenceTransferElement[preferenceTransfers
083:                        .size()];
084:                Collections.sort(preferenceTransfers, new Comparator() {
085:                    public int compare(Object o1, Object o2) {
086:                        String name1 = ((PreferenceTransferElement) o1)
087:                                .getName();
088:                        String name2 = ((PreferenceTransferElement) o2)
089:                                .getName();
090:
091:                        return Collator.getInstance().compare(name1, name2);
092:                    }
093:                });
094:                preferenceTransfers.toArray(transfers);
095:                return transfers;
096:            }
097:
098:            /*
099:             * (non-Javadoc)
100:             * 
101:             * @see org.eclipse.ui.internal.registry.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
102:             */
103:            protected boolean readElement(IConfigurationElement element) {
104:                if (element.getName().equals(
105:                        IWorkbenchRegistryConstants.TAG_TRANSFER)) {
106:
107:                    PreferenceTransferElement transfer = createPreferenceTransferElement(element);
108:                    if (transfer != null)
109:                        preferenceTransfers.add(transfer);
110:                    return true;
111:                }
112:
113:                // Allow settings transfers as well.
114:
115:                return element.getName().equals(
116:                        IWorkbenchRegistryConstants.TAG_SETTINGS_TRANSFER);
117:            }
118:
119:            /**
120:             * Reads the wizards in a registry.
121:             */
122:            protected void readPreferenceTransfers() {
123:                preferenceTransfers = new ArrayList();
124:                IExtensionRegistry registry = Platform.getExtensionRegistry();
125:                readRegistry(registry, WorkbenchPlugin.PI_WORKBENCH,
126:                        pluginPoint);
127:            }
128:
129:            /**
130:             * Get the preference mappings.
131:             * 
132:             * @param configElement
133:             * @return the child configuration elements
134:             */
135:            public static IConfigurationElement[] getMappings(
136:                    IConfigurationElement configElement) {
137:                IConfigurationElement[] children = configElement
138:                        .getChildren(IWorkbenchRegistryConstants.TAG_MAPPING);
139:                if (children.length < 1) {
140:                    logMissingElement(configElement,
141:                            IWorkbenchRegistryConstants.TAG_MAPPING);
142:                    return null;
143:                }
144:                return children;
145:            }
146:
147:            /**
148:             * @param element
149:             * @return the scope attribute for this element
150:             */
151:            public static String getScope(IConfigurationElement element) {
152:                return element
153:                        .getAttribute(IWorkbenchRegistryConstants.ATT_SCOPE);
154:            }
155:
156:            /**
157:             * @param element
158:             * @return the maps mapping nodes to keys for this element
159:             */
160:            public static Map getEntry(IConfigurationElement element) {
161:                IConfigurationElement[] entries = element
162:                        .getChildren(IWorkbenchRegistryConstants.TAG_ENTRY);
163:                if (entries.length == 0) {
164:                    return null;
165:                }
166:                Map map = new HashMap(entries.length);
167:                for (int i = 0; i < entries.length; i++) {
168:                    IConfigurationElement entry = entries[i];
169:                    IConfigurationElement[] keys = entry
170:                            .getChildren(IWorkbenchRegistryConstants.ATT_KEY);
171:                    PreferenceFilterEntry[] prefFilters = null;
172:                    if (keys.length > 0) {
173:                        prefFilters = new PreferenceFilterEntry[keys.length];
174:                        for (int j = 0; j < keys.length; j++) {
175:                            IConfigurationElement keyElement = keys[j];
176:                            prefFilters[j] = new PreferenceFilterEntry(
177:                                    keyElement
178:                                            .getAttribute(IWorkbenchRegistryConstants.ATT_NAME));
179:                        }
180:                    }
181:                    map
182:                            .put(
183:                                    entry
184:                                            .getAttribute(IWorkbenchRegistryConstants.ATT_NODE),
185:                                    prefFilters);
186:                }
187:                return map;
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.