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


001:        /*******************************************************************************
002:         * Copyright (c) 2007 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.splash;
011:
012:        import java.util.HashMap;
013:        import java.util.Map;
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.IProduct;
019:        import org.eclipse.core.runtime.Platform;
020:        import org.eclipse.core.runtime.SafeRunner;
021:        import org.eclipse.jface.util.SafeRunnable;
022:        import org.eclipse.ui.PlatformUI;
023:        import org.eclipse.ui.internal.WorkbenchPlugin;
024:        import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
025:        import org.eclipse.ui.splash.AbstractSplashHandler;
026:
027:        /**
028:         * Simple non-caching access to the splashHandler extension point.
029:         * 
030:         * @since 3.3
031:         */
032:        public final class SplashHandlerFactory {
033:
034:            /**
035:             * Find the splash handler for the given product or <code>null</code> if
036:             * it cannot be found.
037:             * 
038:             * @param product
039:             *            the product
040:             * @return the splash or <code>null</code>
041:             */
042:            public static AbstractSplashHandler findSplashHandlerFor(
043:                    IProduct product) {
044:                if (product == null)
045:                    return null;
046:
047:                IExtensionPoint point = Platform.getExtensionRegistry()
048:                        .getExtensionPoint(PlatformUI.PLUGIN_ID,
049:                                IWorkbenchRegistryConstants.PL_SPLASH_HANDLERS);
050:
051:                if (point == null)
052:                    return null;
053:
054:                IExtension[] extensions = point.getExtensions();
055:                Map idToSplash = new HashMap(); // String->ConfigurationElement
056:                String[] targetId = new String[1];
057:                for (int i = 0; i < extensions.length; i++) {
058:                    IConfigurationElement[] children = extensions[i]
059:                            .getConfigurationElements();
060:                    for (int j = 0; j < children.length; j++) {
061:                        AbstractSplashHandler handler = processElement(
062:                                children[j], idToSplash, targetId, product);
063:                        if (handler != null)
064:                            return handler;
065:
066:                    }
067:                }
068:                return null;
069:            }
070:
071:            /**
072:             * Process a given element.
073:             * 
074:             * @param configurationElement
075:             *            the element to process
076:             * @param idToSplash
077:             *            the map of current splash elements
078:             * @param targetId
079:             *            the target id if known
080:             * @param product
081:             *            the product to search for
082:             * @return a splash matching the target id from this element or
083:             *         <code>null</code>
084:             */
085:            private static AbstractSplashHandler processElement(
086:                    IConfigurationElement configurationElement, Map idToSplash,
087:                    String[] targetId, IProduct product) {
088:                String type = configurationElement.getName();
089:                if (IWorkbenchRegistryConstants.TAG_SPLASH_HANDLER.equals(type)) {
090:                    String id = configurationElement
091:                            .getAttribute(IWorkbenchRegistryConstants.ATT_ID);
092:                    if (id == null)
093:                        return null;
094:
095:                    // we know the target and this element is it
096:                    if (targetId[0] != null && id.equals(targetId[0])) {
097:                        return create(configurationElement);
098:                    }
099:                    // store for later examination
100:                    idToSplash.put(id, configurationElement);
101:
102:                } else if (IWorkbenchRegistryConstants.TAG_SPLASH_HANDLER_PRODUCT_BINDING
103:                        .equals(type)) {
104:                    String productId = configurationElement
105:                            .getAttribute(IWorkbenchRegistryConstants.ATT_PRODUCTID);
106:                    if (product.getId().equals(productId)
107:                            && targetId[0] == null) { // we
108:                        // found the target ID
109:                        targetId[0] = configurationElement
110:                                .getAttribute(IWorkbenchRegistryConstants.ATT_SPLASH_ID);
111:                        // check all currently located splashes
112:                        IConfigurationElement splashElement = (IConfigurationElement) idToSplash
113:                                .get(targetId[0]);
114:                        if (splashElement != null)
115:                            return create(splashElement);
116:                    }
117:                }
118:
119:                return null;
120:            }
121:
122:            /**
123:             * Create the splash implementation.
124:             * 
125:             * @param splashElement
126:             *            the element to create from
127:             * @return the element or <code>null</code> if it couldn't be created
128:             */
129:            private static AbstractSplashHandler create(
130:                    final IConfigurationElement splashElement) {
131:                final AbstractSplashHandler[] handler = new AbstractSplashHandler[1];
132:                SafeRunner.run(new SafeRunnable() {
133:
134:                    /*
135:                     * (non-Javadoc)
136:                     * 
137:                     * @see org.eclipse.core.runtime.ISafeRunnable#run()
138:                     */
139:                    public void run() throws Exception {
140:                        handler[0] = (AbstractSplashHandler) WorkbenchPlugin
141:                                .createExtension(splashElement,
142:                                        IWorkbenchRegistryConstants.ATT_CLASS);
143:                    }
144:
145:                    /*
146:                     * (non-Javadoc)
147:                     * 
148:                     * @see org.eclipse.jface.util.SafeRunnable#handleException(java.lang.Throwable)
149:                     */
150:                    public void handleException(Throwable e) {
151:                        WorkbenchPlugin.log(
152:                                "Problem creating splash implementation", e); //$NON-NLS-1$
153:                    }
154:                });
155:
156:                return handler[0];
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.