Source Code Cross Referenced for WizardProgressBarPanel.java in  » Database-Client » executequery » org » underworldlabs » swing » wizard » 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 » Database Client » executequery » org.underworldlabs.swing.wizard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * WizardProgressBarPanel.java
003:         *
004:         * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         *
020:         */
021:
022:        package org.underworldlabs.swing.wizard;
023:
024:        import java.awt.GridBagConstraints;
025:        import java.awt.GridBagLayout;
026:        import java.awt.event.ActionEvent;
027:        import java.awt.event.ActionListener;
028:        import java.sql.SQLException;
029:        import javax.swing.JButton;
030:        import javax.swing.JPanel;
031:        import javax.swing.JProgressBar;
032:        import javax.swing.JScrollPane;
033:        import javax.swing.SwingUtilities;
034:
035:        import org.underworldlabs.jdbc.DataSourceException;
036:        import org.underworldlabs.swing.GUIUtils;
037:        import org.underworldlabs.swing.StyledLogPane;
038:
039:        /* ----------------------------------------------------------
040:         * CVS NOTE: Changes to the CVS repository prior to the 
041:         *           release of version 3.0.0beta1 has meant a 
042:         *           resetting of CVS revision numbers.
043:         * ----------------------------------------------------------
044:         */
045:
046:        /**
047:         * Wizard progress bar panel rendering a progress bar and stop button.
048:         *
049:         * @author   Takis Diakoumis
050:         * @version  $Revision: 1.5 $
051:         * @date     $Date: 2006/06/04 07:16:33 $
052:         */
053:        public class WizardProgressBarPanel extends JPanel implements 
054:                ActionListener {
055:
056:            /** the stop button */
057:            private JButton stopButton;
058:
059:            /** The progress bar tracking the process */
060:            private JProgressBar progressBar;
061:
062:            /** the parent process */
063:            private InterruptibleWizardProcess parent;
064:
065:            /** The text area displaying process info */
066:            private StyledLogPane output;
067:
068:            /** Creates a new instance of WizardProgressBarPanel */
069:            public WizardProgressBarPanel(InterruptibleWizardProcess parent) {
070:                super (new GridBagLayout());
071:                this .parent = parent;
072:
073:                output = new StyledLogPane();
074:                output.setBackground(getBackground());
075:
076:                progressBar = new JProgressBar(0, 100);
077:
078:                stopButton = new JButton("Stop");
079:                stopButton.addActionListener(this );
080:
081:                GridBagConstraints gbc = new GridBagConstraints();
082:                gbc.gridy = 0;
083:                gbc.gridx = 0;
084:                gbc.weightx = 1.0;
085:                gbc.fill = GridBagConstraints.HORIZONTAL;
086:                add(progressBar, gbc);
087:                gbc.gridx = 1;
088:                gbc.weightx = 0;
089:                gbc.insets.left = 5;
090:                gbc.fill = GridBagConstraints.NONE;
091:                add(stopButton, gbc);
092:                gbc.gridy++;
093:                gbc.gridx = 0;
094:                gbc.weighty = 1.0;
095:                gbc.insets.top = 10;
096:                gbc.insets.left = 0;
097:                gbc.fill = GridBagConstraints.BOTH;
098:                gbc.gridwidth = GridBagConstraints.REMAINDER;
099:                add(new JScrollPane(output), gbc);
100:            }
101:
102:            /**
103:             * Sets the process as finished and disables the stop button.
104:             */
105:            public void finished() {
106:                setProgressStatus(-1);
107:                GUIUtils.invokeLater(new Runnable() {
108:                    public void run() {
109:                        stopButton.setEnabled(false);
110:                    }
111:                });
112:            }
113:
114:            /**
115:             * Resets the progress bar to zero and clears the output text area.
116:             */
117:            public void reset() {
118:                GUIUtils.invokeLater(new Runnable() {
119:                    public void run() {
120:                        progressBar.setValue(0);
121:                        output.setText("");
122:                        stopButton.setEnabled(true);
123:                    }
124:                });
125:            }
126:
127:            /**
128:             * Returns the text currently displayed in the output pane.
129:             */
130:            public String getText() {
131:                return output.getText();
132:            }
133:
134:            /** 
135:             * Sets the text to be appended within the
136:             * progress info text area.
137:             *
138:             * @param the text to append
139:             */
140:            public void appendProgressText(final String t) {
141:                Runnable setProgressText = new Runnable() {
142:                    public void run() {
143:                        output.append(StyledLogPane.PLAIN_MESSAGE_PREFORMAT, t);
144:                    }
145:                };
146:                SwingUtilities.invokeLater(setProgressText);
147:            }
148:
149:            /** 
150:             * Sets the text to be appended within the
151:             * progress info text area as an error message.
152:             *
153:             * @param the text to append
154:             */
155:            public void appendProgressErrorText(final String t) {
156:                Runnable setProgressText = new Runnable() {
157:                    public void run() {
158:                        output.append(StyledLogPane.ERROR_MESSAGE_PREFORMAT, t);
159:                    }
160:                };
161:                SwingUtilities.invokeLater(setProgressText);
162:            }
163:
164:            public void appendExceptionError(String message, Throwable e) {
165:                StringBuffer outputBuffer = new StringBuffer();
166:                if (message != null) {
167:                    outputBuffer.append(message);
168:                }
169:                outputBuffer.append("\n[ ");
170:
171:                String exceptionName = null;
172:                if (e.getCause() != null) {
173:                    Throwable _e = e.getCause();
174:                    exceptionName = _e.getClass().getName();
175:                } else {
176:                    exceptionName = e.getClass().getName();
177:                }
178:
179:                int index = exceptionName.lastIndexOf('.');
180:                if (index != -1) {
181:                    exceptionName = exceptionName.substring(index + 1);
182:                }
183:                outputBuffer.append(exceptionName);
184:                outputBuffer.append(" ] ");
185:
186:                if (e instanceof  DataSourceException) {
187:                    outputBuffer.append(e.getMessage());
188:                    outputBuffer.append(((DataSourceException) e)
189:                            .getExtendedMessage());
190:                } else if (e instanceof  SQLException) {
191:                    outputBuffer.append(e.getMessage());
192:                    SQLException _e = (SQLException) e;
193:                    outputBuffer.append("\nError Code: " + _e.getErrorCode());
194:
195:                    String state = _e.getSQLState();
196:                    if (state != null) {
197:                        outputBuffer.append("\nSQL State Code: " + state);
198:                    }
199:
200:                } else {
201:                    outputBuffer.append(e.getMessage());
202:                }
203:
204:                appendProgressErrorText(outputBuffer.toString());
205:            }
206:
207:            /** 
208:             * Sets the progress bar's position during the process.
209:             * A value of -1 will set the progress bar to its set maximum.
210:             *
211:             * @param the new process status
212:             */
213:            public void setProgressStatus(int status) {
214:                final int value = (status > 0 ? status : progressBar
215:                        .getMaximum());
216:                Runnable setProgressBar = new Runnable() {
217:                    public void run() {
218:                        progressBar.setValue(value);
219:                    }
220:                };
221:                SwingUtilities.invokeLater(setProgressBar);
222:            }
223:
224:            /** 
225:             * Sets the progress bar's minimum value to the specified value.
226:             *
227:             * @param min - the minimum value
228:             */
229:            public void setMinimum(int min) {
230:                progressBar.setMinimum(min);
231:            }
232:
233:            /** 
234:             * Sets the progress bar's maximum value to the specified value.
235:             *
236:             * @param max - the maximum value
237:             */
238:            public void setMaximum(int max) {
239:                progressBar.setMaximum(max);
240:            }
241:
242:            /** 
243:             * Retrieves the progress bar's maximum value.
244:             *
245:             * @param the progress bar's maximum value
246:             */
247:            public int getMaximum() {
248:                return progressBar.getMaximum();
249:            }
250:
251:            /** <p>Sets the progress bar to track
252:             *  indeterminate values - action of
253:             *  unknown length is taking place.
254:             */
255:            public void setIndeterminate(boolean indeterminate) {
256:                progressBar.setIndeterminate(indeterminate);
257:            }
258:
259:            /**
260:             * Invoked when the stop button is pushed.
261:             */
262:            public void actionPerformed(ActionEvent e) {
263:                parent.stop();
264:                stopButton.setEnabled(false);
265:            }
266:
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.