Source Code Cross Referenced for SwingInstallerContext.java in  » Installer » AntInstaller » org » tp23 » antinstaller » renderer » swing » 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 » Installer » AntInstaller » org.tp23.antinstaller.renderer.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright 2005 Paul Hinds
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.tp23.antinstaller.renderer.swing;
017:
018:        import javax.swing.JFrame;
019:        import javax.swing.JLabel;
020:        import javax.swing.JProgressBar;
021:        import javax.swing.SwingUtilities;
022:
023:        import org.apache.tools.ant.BuildEvent;
024:        import org.tp23.antinstaller.InstallerContext;
025:        import org.tp23.antinstaller.runtime.SwingRunner;
026:
027:        /**
028:         * Hold a series of callbacks for the Swing UI for installation progress
029:         * @author teknopaul
030:         *
031:         */
032:        public class SwingInstallerContext {
033:
034:            private static JFrame masterFrame;
035:            private JLabel feedBackPanel;
036:            private ProgressPanel progressPanel;
037:            private JProgressBar jProgressBar;
038:            private InstallerContext ctx;
039:
040:            public SwingInstallerContext(InstallerContext ctx,
041:                    JFrame masterFrame) {
042:                this .ctx = ctx;
043:                SwingInstallerContext.masterFrame = masterFrame;
044:            }
045:
046:            public JFrame getMasterFrame() {
047:                return masterFrame;
048:            }
049:
050:            public SwingRunner getSwingRunner() {
051:                return (SwingRunner) ctx.getRunner();
052:            }
053:
054:            public void setFeedBackLabel(JLabel feedBackPanel) {
055:                this .feedBackPanel = feedBackPanel;
056:            }
057:
058:            /**
059:             * The progress panel is optional so not calling this method
060:             * should not cause errors or NPEs
061:             * @param progressPanel
062:             */
063:            public void setProgressPanel(ProgressPanel progressPanel) {
064:                this .progressPanel = progressPanel;
065:            }
066:
067:            /**
068:             * The progress bar is optional so not calling this method
069:             * should not cause errors or NPEs
070:             * @param progressPanel
071:             */
072:            public void setProgressBar(JProgressBar progressBar) {
073:                this .jProgressBar = progressBar;
074:            }
075:
076:            public void buildStarted(BuildEvent buildEvent) {
077:                provideAntFeedBack(buildEvent.getMessage());
078:                try {
079:                    SwingUtilities.invokeAndWait(new Runnable() {
080:                        public void run() {
081:                            if (SwingInstallerContext.this .progressPanel != null) {
082:                                SwingInstallerContext.this .progressPanel
083:                                        .prepareCalledTargets();
084:                            }
085:                        }
086:                    });
087:                } catch (Exception e) { //Interrupted or InvocationTarget
088:                    SwingInstallerContext.this .ctx.log(e);
089:                }
090:            }
091:
092:            public void buildFinished(BuildEvent buildEvent) {
093:                if (this .progressPanel != null) {
094:                    try {
095:                        SwingUtilities.invokeLater(new Runnable() {
096:                            public void run() {
097:                                SwingInstallerContext.this .progressPanel
098:                                        .buildFinished();
099:                            }
100:                        });
101:                    } catch (Exception e) { //Interrupted or InvocationTarget
102:                        SwingInstallerContext.this .ctx.log(e);
103:                    }
104:                }
105:                if (this .jProgressBar != null) {
106:                    jProgressBar.setValue(jProgressBar.getMaximum());
107:                }
108:            }
109:
110:            public void targetStarted(BuildEvent buildEvent) {
111:                TargetStarted targetStarted = new TargetStarted();
112:                targetStarted.buildEvent = buildEvent;
113:                try {
114:                    if (this .progressPanel != null) {
115:                        //Invoke and wait used since strict ordering od started and finished is requried
116:                        SwingUtilities.invokeAndWait(targetStarted);
117:                    }
118:                } catch (Exception e) { //Interrupted or InvocationTarget
119:                    SwingInstallerContext.this .ctx.log(e);
120:                }
121:            }
122:
123:            public void targetFinished(BuildEvent buildEvent) {
124:                try {
125:                    //Invoke and wait used since strict ordering od started and finished is requried
126:                    SwingUtilities.invokeAndWait(new Runnable() {
127:                        public void run() {
128:                            if (SwingInstallerContext.this .progressPanel != null) {
129:                                SwingInstallerContext.this .progressPanel
130:                                        .targetFinished();
131:                            }
132:                        }
133:                    });
134:                } catch (Exception e) { //Interrupted or InvocationTarget
135:                    SwingInstallerContext.this .ctx.log(e);
136:                }
137:            }
138:
139:            public void provideAntFeedBack(String message) {
140:                // We should never have Ant running without a ProgressPane
141:                // but do an if null here in case future FilterChains are different
142:                ProvideAntFeedBack provideAntFeedBack = new ProvideAntFeedBack();
143:                provideAntFeedBack.message = message;
144:                try {
145:                    if (feedBackPanel != null) {
146:                        SwingUtilities.invokeLater(provideAntFeedBack);
147:                    }
148:                } catch (Exception e) { //Interrupted or InvocationTarget
149:                    SwingInstallerContext.this .ctx.log(e);
150:                }
151:            }
152:
153:            public void tick() {
154:                if (jProgressBar != null) {
155:                    jProgressBar.setValue(jProgressBar.getValue() + 1);
156:                }
157:            }
158:
159:            /**
160:             * @return Returns the ctx.
161:             */
162:            public InstallerContext getInstallerContext() {
163:                return ctx;
164:            }
165:
166:            private class TargetStarted implements  Runnable {
167:                private BuildEvent buildEvent;
168:
169:                public void run() {
170:                    SwingInstallerContext.this .progressPanel
171:                            .targetStarted(buildEvent);
172:                }
173:            }
174:
175:            private class ProvideAntFeedBack implements  Runnable {
176:                private String message;
177:
178:                public void run() {
179:                    SwingInstallerContext.this.feedBackPanel.setText(message);
180:                }
181:            }
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.