Source Code Cross Referenced for ExtensionPointUtil.java in  » GIS » udig-1.1 » net » refractions » udig » core » internal » 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 » GIS » udig 1.1 » net.refractions.udig.core.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    uDig - User Friendly Desktop Internet GIS client
003:         *    http://udig.refractions.net
004:         *    (C) 2004, Refractions Research Inc.
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         *
016:         */
017:        package net.refractions.udig.core.internal;
018:
019:        import java.text.MessageFormat;
020:        import java.util.ArrayList;
021:        import java.util.Collections;
022:        import java.util.List;
023:
024:        import org.eclipse.core.runtime.IConfigurationElement;
025:        import org.eclipse.core.runtime.IExtension;
026:        import org.eclipse.core.runtime.IExtensionPoint;
027:        import org.eclipse.core.runtime.IExtensionRegistry;
028:        import org.eclipse.core.runtime.IStatus;
029:        import org.eclipse.core.runtime.Platform;
030:        import org.eclipse.core.runtime.Plugin;
031:        import org.eclipse.core.runtime.Status;
032:
033:        /**
034:         * A utility class to assist in processing extensions
035:         * 
036:         * @see net.refractions.udig.core.internal.ExtensionPointProcessor
037:         * @author Jesse Eichar
038:         * @version $Revision: 1.9 $
039:         */
040:        public class ExtensionPointUtil {
041:
042:            /**
043:             * Finds all the Extension or the Extension point identified by the xpid method and calls a
044:             * callback method on the processor class for processing of the extension.
045:             * 
046:             * @see net.refractions.udig.core.internal.ExtensionPointProcessor#process(IExtension,
047:             *      IConfigurationElement)
048:             * @param xpid The id of the ExtensionPoint for which the extensions are to be processed
049:             * @param processor The object that wishes to process the extension for the ExtensionPoint
050:             * @deprecated Please use process( Plugin, String, ExtentionPointProcessor ) - so we can
051:             */
052:            public static void process(String xpid,
053:                    ExtensionPointProcessor processor) {
054:                process(CorePlugin.getDefault(), xpid, processor);
055:            }
056:
057:            /**
058:             * Finds all the Extension or the Extension point identified by the xpid method and calls a
059:             * callback method on the processor class for processing of the extension.
060:             * 
061:             * @see net.refractions.udig.core.internal.ExtensionPointProcessor#process(IExtension,
062:             *      IConfigurationElement)
063:             * @param plugin plugin processing this extention point
064:             * @param xpid The id of the ExtensionPoint for which the extensions are to be processed
065:             * @param processor The object that wishes to process the extension for the ExtensionPoint
066:             */
067:            public static void process(Plugin plugin, String xpid,
068:                    ExtensionPointProcessor processor) {
069:                IExtensionRegistry registry = Platform.getExtensionRegistry();
070:                IExtensionPoint extensionPoint = registry
071:                        .getExtensionPoint(xpid);
072:                if (extensionPoint == null)
073:                    return;
074:                IExtension[] extensions = extensionPoint.getExtensions();
075:
076:                // For each extension ...
077:                for (int i = 0; i < extensions.length; i++) {
078:                    IExtension extension = extensions[i];
079:                    IConfigurationElement[] elements = extension
080:                            .getConfigurationElements();
081:
082:                    // For each member of the extension ...
083:                    for (int j = 0; j < elements.length; j++) {
084:                        IConfigurationElement element = elements[j];
085:                        try {
086:                            processor.process(extension, element);
087:                        } catch (Throwable exception) {
088:                            plugin
089:                                    .getLog()
090:                                    .log(
091:                                            new Status(
092:                                                    IStatus.ERROR,
093:                                                    element
094:                                                            .getNamespaceIdentifier(),
095:                                                    0,
096:                                                    MessageFormat
097:                                                            .format(
098:                                                                    "Error processing extension {0}", new Object[] { exception }), exception)); //$NON-NLS-1$                    
099:                        }
100:                    }
101:                }
102:            }
103:
104:            /**
105:             * Process extentionpoint with an itemCreator.
106:             * <p>
107:             * Example Use:
108:             * 
109:             * <pre><code>
110:             *  List&lt;Thingy&gt; stuff = ExtentionPointUtil.list( new ExtentionPointProcessor2(){
111:             *     public Object process( IExtention extention, IConfigurationElement element ){
112:             *         return new Thingy( element );
113:             *     }
114:             *  }
115:             * </code></pre>
116:             * 
117:             * </p>
118:             * 
119:             * @param xpid
120:             * @param itemCreator Used to process extention points into items for a list
121:             * @return List
122:             */
123:            public static List list(String xpid,
124:                    ExtensionPointItemCreator itemCreator) {
125:                IExtensionRegistry registry = Platform.getExtensionRegistry();
126:                IExtensionPoint extensionPoint = registry
127:                        .getExtensionPoint(xpid);
128:                if (extensionPoint == null) {
129:                    return Collections.EMPTY_LIST;
130:                }
131:                IExtension[] extensions = extensionPoint.getExtensions();
132:                List<Object> list = new ArrayList<Object>();
133:                // For each extension ...
134:                for (int i = 0; i < extensions.length; i++) {
135:                    IExtension extension = extensions[i];
136:                    IConfigurationElement[] elements = extension
137:                            .getConfigurationElements();
138:
139:                    // For each member of the extension ...
140:                    for (int j = 0; j < elements.length; j++) {
141:                        IConfigurationElement element = elements[j];
142:                        try {
143:                            Object obj = itemCreator.createItem(extension,
144:                                    element);
145:                            if (obj == null)
146:                                continue; // warning?
147:
148:                            list.add(obj);
149:                        } catch (Throwable exception) {
150:                            CorePlugin
151:                                    .getDefault()
152:                                    .getLog()
153:                                    .log(
154:                                            new Status(
155:                                                    IStatus.WARNING,
156:                                                    extension.getNamespace(),
157:                                                    0,
158:                                                    MessageFormat
159:                                                            .format(
160:                                                                    "Error processing extension {0}", new Object[] { exception }), exception)); //$NON-NLS-1$
161:                        }
162:                    }
163:                }
164:                return list;
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.