Source Code Cross Referenced for XEditorUtilities.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.BufferedInputStream;
004:        import java.io.File;
005:        import java.io.InputStream;
006:        import java.io.OutputStream;
007:
008:        import java.awt.Component;
009:        import java.awt.Container;
010:        import java.awt.Dimension;
011:        import java.awt.Toolkit;
012:        import java.awt.Window;
013:
014:        import net.xoetrope.xui.XProjectManager;
015:        import net.xoetrope.xui.XResourceManager;
016:
017:        /**
018:         * A collection of useful methods
019:         * <p> Copyright (c) Xoetrope Ltd., 2002-2003</p>
020:         * <p> $Revision: 1.12 $</p>
021:         * <p> License: see License.txt</p>
022:         */
023:        public class XEditorUtilities {
024:            /**
025:             * Copy a file specified by the source path to the target path
026:             * @param clazz a class whos classloader will be used to load the resource
027:             * @param source the file which we want to copy
028:             * @param target the file we want to create
029:             * @return true if the copy operation was successful, otherwise false is returned
030:             */
031:            public static boolean copyFile(Class clazz, String source,
032:                    String target) {
033:                byte[] fileBytes = new byte[0];
034:                InputStream is = null;
035:                if (clazz != null)
036:                    is = new BufferedInputStream(clazz.getClassLoader()
037:                            .getResourceAsStream(source));
038:                if (is == null)
039:                    is = XProjectManager.getResourceManager()
040:                            .getBufferedInputStream(source);
041:
042:                try {
043:                    byte[] b = new byte[1000];
044:                    if (is != null) {
045:                        OutputStream fos = XResourceManager
046:                                .getBufferedOutputStream(target, false);
047:                        int i = is.read(b);
048:                        while (i != -1) {
049:                            fileBytes = new byte[i];
050:                            System.arraycopy(b, 0, fileBytes, 0, i);
051:                            fos.write(fileBytes);
052:                            b = new byte[1000];
053:                            i = is.read(b);
054:                        }
055:                        fos.flush();
056:                        fos.close();
057:                    } else
058:                        return false;
059:                } catch (Exception ex) {
060:                    ex.printStackTrace();
061:                    return false;
062:                }
063:
064:                return true;
065:            }
066:
067:            /**
068:             * Copy a file specified by the source path to the target path
069:             * @param source the file which we want to copy
070:             * @param target the file we want to create
071:             * @return true if the copy operation was successful, otherwise false is returned
072:             */
073:            public static boolean copyFile(String source, String target) {
074:                return copyFile(null, source, target);
075:            }
076:
077:            /**
078:             * Create the directory specified by filename
079:             * @param filename the directory to create
080:             */
081:            public static void createDir(String filename) {
082:                File f = new File(filename);
083:                f.mkdirs();
084:            }
085:
086:            /**
087:             * Set the default font for all the components in this container.
088:             * @param cont the container
089:             */
090:            public static void setDefaultFont(Container cont) {
091:                cont.setFont(XuiDefaults.defaultFont);
092:
093:                int numComponents = cont.getComponentCount();
094:                for (int i = 0; i < numComponents; i++) {
095:                    Component c = cont.getComponent(i);
096:
097:                    if (c instanceof  Container)
098:                        setDefaultFont((Container) c);
099:                    else
100:                        c.setFont(XuiDefaults.defaultFont);
101:                }
102:            }
103:
104:            public static void centreWindow(Window window, Dimension windowSize) {
105:                Dimension screenSize = Toolkit.getDefaultToolkit()
106:                        .getScreenSize();
107:                Dimension frameSize = new Dimension(Math.min(windowSize.width,
108:                        screenSize.width), Math.min(windowSize.height,
109:                        screenSize.height));
110:                if (frameSize.height > screenSize.height)
111:                    frameSize.height = screenSize.height;
112:
113:                if (frameSize.width > screenSize.width)
114:                    frameSize.width = screenSize.width;
115:
116:                window.setLocation((screenSize.width - frameSize.width) / 2,
117:                        (screenSize.height - frameSize.height) / 2);
118:                window.setSize(frameSize);
119:            }
120:
121:            public static String getComponentClassName(Component c) {
122:                String compName = c.getClass().getName();
123:                if (compName.indexOf("XLabelProxy") > 0)
124:                    return "XLabel";
125:                if (compName.indexOf("XPanelProxy") > 0)
126:                    return "XPanel";
127:                else
128:                    return c.getClass().getName();
129:            }
130:
131:            //  public Component getProxiedComponent( net.xoetrope.builder.editor.components.swing.XComponentProxy c )
132:            //  {
133:            //
134:            //  }
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.