Source Code Cross Referenced for ProcessPanel.java in  » Installer » IzPack » com » izforge » izpack » panels » 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 » IzPack » com.izforge.izpack.panels 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
003:         * 
004:         * http://izpack.org/
005:         * http://izpack.codehaus.org/
006:         * 
007:         * Copyright 2004 Tino Schwarze
008:         * 
009:         * Licensed under the Apache License, Version 2.0 (the "License");
010:         * you may not use this file except in compliance with the License.
011:         * You may obtain a copy of the License at
012:         * 
013:         *     http://www.apache.org/licenses/LICENSE-2.0
014:         *     
015:         * Unless required by applicable law or agreed to in writing, software
016:         * distributed under the License is distributed on an "AS IS" BASIS,
017:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018:         * See the License for the specific language governing permissions and
019:         * limitations under the License.
020:         */
021:
022:        package com.izforge.izpack.panels;
023:
024:        import java.awt.BorderLayout;
025:        import java.awt.Dimension;
026:        import java.awt.Font;
027:        import java.io.IOException;
028:
029:        import javax.swing.BoxLayout;
030:        import javax.swing.JLabel;
031:        import javax.swing.JPanel;
032:        import javax.swing.JProgressBar;
033:        import javax.swing.JScrollPane;
034:        import javax.swing.JTextArea;
035:        import javax.swing.SwingConstants;
036:        import javax.swing.SwingUtilities;
037:
038:        import net.n3.nanoxml.XMLElement;
039:
040:        import com.izforge.izpack.installer.InstallData;
041:        import com.izforge.izpack.installer.InstallerFrame;
042:        import com.izforge.izpack.installer.IzPanel;
043:        import com.izforge.izpack.installer.ProcessPanelWorker;
044:        import com.izforge.izpack.util.AbstractUIProcessHandler;
045:
046:        /**
047:         * The process panel class.
048:         * 
049:         * This class allows external processes to be executed during installation.
050:         * 
051:         * Parts of the code have been taken from CompilePanel.java and modified a lot.
052:         * 
053:         * @author Tino Schwarze
054:         * @author Julien Ponge
055:         */
056:        public class ProcessPanel extends IzPanel implements 
057:                AbstractUIProcessHandler {
058:
059:            /**
060:             * 
061:             */
062:            private static final long serialVersionUID = 3258417209583155251L;
063:
064:            /** The operation label . */
065:            protected JLabel processLabel;
066:
067:            /** The overall progress bar. */
068:            protected JProgressBar overallProgressBar;
069:
070:            /** True if the compilation has been done. */
071:            private boolean validated = false;
072:
073:            /** The processing worker. Does all the work. */
074:            private ProcessPanelWorker worker;
075:
076:            /** Number of jobs to process. Used for progress indication. */
077:            private int noOfJobs = 0;
078:
079:            private int currentJob = 0;
080:
081:            /** Where the output is displayed */
082:            private JTextArea outputPane;
083:
084:            /**
085:             * The constructor.
086:             * 
087:             * @param parent The parent window.
088:             * @param idata The installation data.
089:             */
090:            public ProcessPanel(InstallerFrame parent, InstallData idata)
091:                    throws IOException {
092:                super (parent, idata);
093:
094:                this .worker = new ProcessPanelWorker(idata, this );
095:
096:                JLabel heading = new JLabel();
097:                Font font = heading.getFont();
098:                font = font.deriveFont(Font.BOLD, font.getSize() * 2.0f);
099:                heading.setFont(font);
100:                heading.setHorizontalAlignment(SwingConstants.CENTER);
101:                heading.setText(parent.langpack
102:                        .getString("ProcessPanel.heading"));
103:                heading.setVerticalAlignment(SwingConstants.TOP);
104:                BorderLayout layout = new BorderLayout();
105:                layout.setHgap(2);
106:                layout.setVgap(2);
107:                setLayout(layout);
108:                add(heading, BorderLayout.NORTH);
109:
110:                // put everything but the heading into it's own panel
111:                // (to center it vertically)
112:                JPanel subpanel = new JPanel();
113:
114:                subpanel.setAlignmentX(0.5f);
115:                subpanel.setLayout(new BoxLayout(subpanel, BoxLayout.Y_AXIS));
116:
117:                this .processLabel = new JLabel();
118:                this .processLabel.setAlignmentX(0.5f);
119:                this .processLabel.setText(" ");
120:                subpanel.add(this .processLabel);
121:
122:                this .overallProgressBar = new JProgressBar();
123:                this .overallProgressBar.setAlignmentX(0.5f);
124:                this .overallProgressBar.setStringPainted(true);
125:                subpanel.add(this .overallProgressBar);
126:
127:                this .outputPane = new JTextArea();
128:                this .outputPane.setEditable(false);
129:                JScrollPane outputScrollPane = new JScrollPane(this .outputPane);
130:                subpanel.add(outputScrollPane);
131:
132:                add(subpanel, BorderLayout.CENTER);
133:            }
134:
135:            /**
136:             * Indicates wether the panel has been validated or not.
137:             * 
138:             * @return The validation state.
139:             */
140:            public boolean isValidated() {
141:                return validated;
142:            }
143:
144:            /** The compiler starts. */
145:            public void startProcessing(int no_of_jobs) {
146:                this .noOfJobs = no_of_jobs;
147:                overallProgressBar.setMaximum(no_of_jobs);
148:                overallProgressBar.setIndeterminate(true);
149:                parent.lockPrevButton();
150:            }
151:
152:            /** The compiler stops. */
153:            public void finishProcessing() {
154:                overallProgressBar.setIndeterminate(false);
155:                String no_of_jobs = Integer.toString(this .noOfJobs);
156:                overallProgressBar.setString(no_of_jobs + " / " + no_of_jobs);
157:
158:                processLabel.setText(" ");
159:                processLabel.setEnabled(false);
160:
161:                validated = true;
162:                idata.installSuccess = worker.getResult();
163:                if (idata.panels.indexOf(this ) != (idata.panels.size() - 1))
164:                    parent.unlockNextButton();
165:            }
166:
167:            /**
168:             * Log a message.
169:             * 
170:             * @param message The message.
171:             * @param stderr Whether the message came from stderr or stdout.
172:             */
173:            public void logOutput(String message, boolean stderr) {
174:                // TODO: make it colored
175:                this .outputPane.append(message + '\n');
176:
177:                SwingUtilities.invokeLater(new Runnable() {
178:
179:                    public void run() {
180:                        outputPane.setCaretPosition(outputPane.getText()
181:                                .length());
182:                    }
183:                });
184:            }
185:
186:            /**
187:             * Next job starts.
188:             * 
189:             * @param jobName The job name.
190:             */
191:            public void startProcess(String jobName) {
192:                processLabel.setText(jobName);
193:
194:                this .currentJob++;
195:                overallProgressBar.setValue(this .currentJob);
196:                overallProgressBar.setString(Integer.toString(this .currentJob)
197:                        + " / " + Integer.toString(this .noOfJobs));
198:            }
199:
200:            public void finishProcess() {
201:
202:            }
203:
204:            /** Called when the panel becomes active. */
205:            public void panelActivate() {
206:                // We clip the panel
207:                Dimension dim = parent.getPanelsContainerSize();
208:                dim.width -= (dim.width / 4);
209:                dim.height = 150;
210:                setMinimumSize(dim);
211:                setMaximumSize(dim);
212:                setPreferredSize(dim);
213:
214:                parent.lockNextButton();
215:
216:                this .worker.startThread();
217:            }
218:
219:            /** Create XML data for automated installation. */
220:            public void makeXMLData(XMLElement panelRoot) {
221:                // does nothing (no state to save)
222:            }
223:
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.