Source Code Cross Referenced for DesignApplet.java in  » Report » datavision-1.1.0 » jimm » datavision » gui » applet » 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 » Report » datavision 1.1.0 » jimm.datavision.gui.applet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jimm.datavision.gui.applet;
002:
003:        import jimm.datavision.Report;
004:        import jimm.datavision.ErrorHandler;
005:        import jimm.datavision.gui.Designer;
006:        import jimm.datavision.gui.AskStringDialog;
007:        import jimm.util.I18N;
008:        import jimm.util.XMLWriter;
009:        import java.io.InputStreamReader;
010:        import java.io.IOException;
011:        import java.net.URL;
012:        import java.net.URLConnection;
013:        import org.xml.sax.InputSource;
014:
015:        /**
016:         * A designer suitable for use with applets. This designer is created
017:         * by a {@link DVApplet} in its <code>init</code> method.
018:         *
019:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
020:         */
021:        class DesignApplet extends Designer {
022:
023:            DesignApplet(DVApplet applet) {
024:                super (null, null, applet, null);
025:
026:                reportFilePath = getAppletViaCheapTrick().getSaveURL();
027:            }
028:
029:            /**
030:             * Reads the named report file or, if it's <code>null</code>, creates
031:             * a new, empty report. Returns <code>true</code> if we need to ask
032:             * the user for connection info because this is a new report.
033:             *
034:             * @param fileName
035:             * @param databasePassword string to give to report; OK if it's
036:             * <code>null</code>
037:             * @return <code>true</code> if we need to ask the user for connection info
038:             */
039:            protected boolean readReport(String fileName,
040:                    String databasePassword) {
041:                report = new Report();
042:                String url = getAppletViaCheapTrick().getReportURL();
043:                try {
044:                    if (url != null && url.length() > 0)
045:                        report.read(new InputSource(url));
046:                } catch (Exception e) {
047:                    ErrorHandler.error(e);
048:                }
049:
050:                reportFilePath = null;
051:                return false; // No password needed
052:            }
053:
054:            /**
055:             * A cheap trick: we need the applet but this method is called from the
056:             * constructor indirectly so we can't assign the applet to an instance var
057:             * of the correct type. However, we passed the applet in as our root pane
058:             * container.
059:             *
060:             * @return the applet
061:             */
062:            protected DVApplet getAppletViaCheapTrick() {
063:                return (DVApplet) rootPaneContainer;
064:            }
065:
066:            /**
067:             * Saves the current report to a URL specified by the user.
068:             */
069:            protected void saveReportAs() {
070:                String name = new AskStringDialog(getFrame(), I18N
071:                        .get("DesignApplet.new_url_title"), I18N
072:                        .get("DesignApplet.new_url_prompt"), reportFilePath)
073:                        .getString();
074:
075:                if (name != null) {
076:                    reportFilePath = name;
077:                    writeReportFile(reportFilePath);
078:                }
079:            }
080:
081:            /**
082:             * Writes the current report to the specified file. Also tells the
083:             * command history the report has been saved so it knows how to report
084:             * if any changes have been made from this point on.
085:             *
086:             * @param fileName a file name
087:             */
088:            protected void writeReportFile(String fileName) {
089:                URLConnection conn = null;
090:
091:                try {
092:                    URL url = new URL(fileName);
093:                    conn = url.openConnection();
094:                    conn.setDoOutput(true);
095:
096:                    sendData(conn);
097:                    // I don't know why, but we have to read the response from the
098:                    // server, even if it's empty.
099:                    receiveResponse(conn);
100:                } catch (Exception e) {
101:                    ErrorHandler.error(e);
102:                }
103:
104:                // Don't forget this.
105:                commandHistory.setBaseline();
106:            }
107:
108:            protected void sendData(URLConnection conn) throws IOException {
109:                XMLWriter out = null;
110:                try {
111:                    out = new XMLWriter(conn.getOutputStream());
112:                    report.writeXML(out);
113:                    out.flush();
114:                } catch (IOException e) {
115:                    throw e;
116:                } finally {
117:                    if (out != null)
118:                        out.close();
119:                }
120:            }
121:
122:            protected void receiveResponse(URLConnection conn)
123:                    throws IOException {
124:                InputStreamReader in = null;
125:                try {
126:                    in = new InputStreamReader(conn.getInputStream());
127:                    char[] buf = new char[1024];
128:                    while (in.read(buf) > 0)
129:                        ;
130:                } catch (IOException e) {
131:                    throw e;
132:                } finally {
133:                    if (in != null)
134:                        in.close();
135:                }
136:            }
137:
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.