Source Code Cross Referenced for XEditorResourceManager.java in  » XML-UI » XUI » net » xoetrope » builder » editor » 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 » XML UI » XUI » net.xoetrope.builder.editor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.builder.editor;
002:
003:        import java.io.FileInputStream;
004:        import java.io.InputStream;
005:        import java.net.URL;
006:
007:        import java.awt.Image;
008:        import java.awt.Toolkit;
009:
010:        import net.xoetrope.debug.DebugLogger;
011:        import net.xoetrope.xui.XResourceManager;
012:        import net.xoetrope.xui.build.BuildProperties;
013:
014:        /**
015:         * An extension of XResourceManager to allow greater interaction with the Editor-IDE.
016:         * This class subclasses getInputStream to allow dynamic loading of pages via a
017:         * custom classloader. The class also accomodates the slightly different startup
018:         * sequence and the fact that the editor itself has a startup set of properties
019:         * in addition to the startup properties of the application being edited.
020:         * <p>Copyright (c) Xoetrope Ltd., 1998-2003</p>
021:         * @version $Revision: 1.21 $
022:         */
023:        public class XEditorResourceManager extends XResourceManager {
024:            /**
025:             * Construct an instance of this class.
026:             * @return the XEditorResourceManager instance
027:             * @deprecated use XEditorProjectManager.getResourceManager() instead
028:             */
029:            public static XResourceManager getInstance() {
030:                return XEditorProjectManager.getResourceManager();
031:            }
032:
033:            /**
034:             * Gets a stream for a resource
035:             * @param fileName the resource file name
036:             * @return the InputStream
037:             */
038:            public InputStream getInputStream(String fileName) {
039:                FileInputStream result = null;
040:                ClassLoader cl = getClass().getClassLoader();
041:
042:                try {
043:                    if (BuildProperties.DEBUG)
044:                        DebugLogger.trace("Opening resource file:" + fileName);
045:                    InputStream is = null;//cl.getResourceAsStream( fileName );
046:                    if (BuildProperties.DEBUG) {
047:                        if (is == null) {
048:                            int numClassLoaders = customClassLoaders.size();
049:                            if (numClassLoaders > 0) {
050:                                for (int i = 0; i < numClassLoaders; i++) {
051:                                    is = ((ClassLoader) customClassLoaders
052:                                            .elementAt(i))
053:                                            .getResourceAsStream(fileName);
054:                                    if (is != null)
055:                                        break;
056:                                }
057:                            }
058:                        }
059:                        if (is == null)
060:                            DebugLogger
061:                                    .logError("File not loaded from classpath: "
062:                                            + fileName);
063:                        else
064:                            return is;
065:                    }
066:                } catch (Exception ex1) {
067:                    ex1.printStackTrace();
068:                }
069:
070:                return super .getInputStream(fileName);
071:
072:            }
073:
074:            /*
075:             * Sets the startup file and loads the associated resource.
076:             * @param file the name of the startup resource file.
077:             */
078:            public static void setStartupFile(String fileName) {
079:                XEditorProjectManager.getCurrentProject().setStartupFile(
080:                        fileName);
081:            }
082:
083:            /**
084:             * Loads an image resource
085:             * @param name the image resource name
086:             * @return the image
087:             */
088:            public static Image getImage(String name) {
089:                if (name == null)
090:                    return null;
091:
092:                Image result = XResourceManager.getImage(name);
093:                if ((result == null) && (customClassLoaders.size() > 0)) {
094:                    int numClassLoaders = customClassLoaders.size();
095:                    if (numClassLoaders > 0) {
096:                        for (int i = 0; i < numClassLoaders; i++) {
097:                            result = Toolkit.getDefaultToolkit().createImage(
098:                                    ((ClassLoader) customClassLoaders
099:                                            .elementAt(i)).getResource(name));
100:                            if (result != null)
101:                                break;
102:                        }
103:                    }
104:                }
105:
106:                if (BuildProperties.DEBUG) {
107:                    if (result == null)
108:                        DebugLogger.logWarning("Cannot load image: " + name);
109:                }
110:
111:                return result;
112:            }
113:
114:            /**
115:             * Loads an image resource
116:             * @param url the image resource url
117:             * @return the image
118:             */
119:            public static Image getImage(URL url) {
120:                if (url == null)
121:                    return null;
122:
123:                Image result = Toolkit.getDefaultToolkit().getImage(url);
124:                if ((result == null) && (customClassLoaders.size() > 0)) {
125:                    int numClassLoaders = customClassLoaders.size();
126:                    if (numClassLoaders > 0) {
127:                        for (int i = 0; i < numClassLoaders; i++) {
128:                            result = Toolkit.getDefaultToolkit().createImage(
129:                                    ((ClassLoader) customClassLoaders
130:                                            .elementAt(i)).getResource(url
131:                                            .getFile()));
132:                            if (result != null)
133:                                break;
134:                        }
135:                    }
136:                }
137:
138:                if (BuildProperties.DEBUG) {
139:                    if (result == null)
140:                        DebugLogger.logWarning("Cannot load image: "
141:                                + url.getFile());
142:                }
143:
144:                return result;
145:            }
146:
147:            /**
148:             * Loads an image resource
149:             * @param clazz the class whos classloader will be used while attempting to load the image
150:             * @param name the image resource name
151:             * @return the image
152:             */
153:            public static Image getImage(Class clazz, String name) {
154:                Image result = Toolkit.getDefaultToolkit().createImage(
155:                        clazz.getClassLoader().getResource(name));
156:                if (result == null)
157:                    result = getImage(name);
158:
159:                return result;
160:            }
161:
162:            /**
163:             * Change or add a startup property
164:             * @param key the object key
165:             * @param value the object value
166:             */
167:            public void setStartupParam(String key, String value) {
168:                ((XEditorProject) XEditorProjectManager.getCurrentProject())
169:                        .setStartupParam(key, value);
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.