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


001:        /*******************************************************************************
002:         * Copyright (c) 2004, 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;
011:
012:        import java.net.MalformedURLException;
013:        import java.net.URL;
014:        import java.util.ArrayList;
015:        import java.util.StringTokenizer;
016:
017:        import org.eclipse.core.runtime.Path;
018:        import org.eclipse.core.runtime.Platform;
019:        import org.eclipse.jface.resource.ImageDescriptor;
020:        import org.osgi.framework.Bundle;
021:
022:        /**
023:         * The branding properties are retrieved as strings, but often used as other
024:         * types (e.g., <code>java.net.URL</code>s. This class provides some utility
025:         * functions for converting the string values to these well known classes. This
026:         * may be subclassed by clients that use more than just these few types.
027:         */
028:        public abstract class BrandingProperties {
029:
030:            /**
031:             * Create an url from the argument absolute or relative path. The bundle
032:             * parameter is used as the base for relative paths and is allowed to be
033:             * null.
034:             * 
035:             * @param value
036:             *            the absolute or relative path
037:             * @param definingBundle
038:             *            bundle to be used for relative paths (may be null)
039:             * @return
040:             */
041:            public static URL getUrl(String value, Bundle definingBundle) {
042:                try {
043:                    if (value != null) {
044:                        return new URL(value);
045:                    }
046:                } catch (MalformedURLException e) {
047:                    if (definingBundle != null) {
048:                        return Platform.find(definingBundle, new Path(value));
049:                    }
050:                }
051:
052:                return null;
053:            }
054:
055:            /**
056:             * Create a descriptor from the argument absolute or relative path to an
057:             * image file. bundle parameter is used as the base for relative paths and
058:             * is allowed to be null.
059:             * 
060:             * @param value
061:             *            the absolute or relative path
062:             * @param definingBundle
063:             *            bundle to be used for relative paths (may be null)
064:             * @return
065:             */
066:            public static ImageDescriptor getImage(String value,
067:                    Bundle definingBundle) {
068:                URL url = getUrl(value, definingBundle);
069:                return url == null ? null : ImageDescriptor.createFromURL(url);
070:            }
071:
072:            /**
073:             * Returns a array of URL for the given property or <code>null</code>.
074:             * The property value should be a comma separated list of urls (either
075:             * absolute or relative to the argument bundle). Tokens that do not
076:             * represent a valid url will be represented with a null entry in the
077:             * returned array.
078:             * 
079:             * @param value
080:             *            value of a property that contains a comma-separated list of
081:             *            product relative urls
082:             * @param definingBundle
083:             *            bundle to be used as base for relative paths (may be null)
084:             * @return a URL for the given property, or <code>null</code>
085:             */
086:            public static URL[] getURLs(String value, Bundle definingBundle) {
087:                if (value == null) {
088:                    return null;
089:                }
090:
091:                StringTokenizer tokens = new StringTokenizer(value, ","); //$NON-NLS-1$
092:                ArrayList array = new ArrayList(10);
093:                while (tokens.hasMoreTokens()) {
094:                    array
095:                            .add(getUrl(tokens.nextToken().trim(),
096:                                    definingBundle));
097:                }
098:
099:                return (URL[]) array.toArray(new URL[array.size()]);
100:            }
101:
102:            /**
103:             * Returns an array of image descriptors for the given property, or
104:             * <code>null</code>. The property value should be a comma separated list
105:             * of image paths. Each path should either be absolute or relative to the
106:             * optional bundle parameter.
107:             * 
108:             * @param value
109:             *            value of a property that contains a comma-separated list of
110:             *            product relative urls describing images
111:             * @param definingBundle
112:             *            bundle to be used for relative paths (may be null)
113:             * @return an array of image descriptors for the given property, or
114:             *         <code>null</code>
115:             */
116:            public static ImageDescriptor[] getImages(String value,
117:                    Bundle definingBundle) {
118:                URL[] urls = getURLs(value, definingBundle);
119:                if (urls == null || urls.length <= 0) {
120:                    return null;
121:                }
122:
123:                ImageDescriptor[] images = new ImageDescriptor[urls.length];
124:                for (int i = 0; i < images.length; ++i) {
125:                    images[i] = ImageDescriptor.createFromURL(urls[i]);
126:                }
127:
128:                return images;
129:            }
130:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.