1 | /**
|
---|
2 | *#########################################################################
|
---|
3 | *
|
---|
4 | * A component of the Core GUI application, part of the Greenstone digital
|
---|
5 | * library suite from the New Zealand Digital Library Project at the
|
---|
6 | * University of Waikato, New Zealand.
|
---|
7 | *
|
---|
8 | * <BR><BR>
|
---|
9 | *
|
---|
10 | * Author: John Thompson, Greenstone Digital Library, University of Waikato
|
---|
11 | *
|
---|
12 | * <BR><BR>
|
---|
13 | *
|
---|
14 | * Copyright (C) 1999 New Zealand Digital Library Project
|
---|
15 | *
|
---|
16 | * <BR><BR>
|
---|
17 | *
|
---|
18 | * This program is free software; you can redistribute it and/or modify
|
---|
19 | * it under the terms of the GNU General Public License as published by
|
---|
20 | * the Free Software Foundation; either version 2 of the License, or
|
---|
21 | * (at your option) any later version.
|
---|
22 | *
|
---|
23 | * <BR><BR>
|
---|
24 | *
|
---|
25 | * This program is distributed in the hope that it will be useful,
|
---|
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
28 | * GNU General Public License for more details.
|
---|
29 | *
|
---|
30 | * <BR><BR>
|
---|
31 | *
|
---|
32 | * You should have received a copy of the GNU General Public License
|
---|
33 | * along with this program; if not, write to the Free Software
|
---|
34 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
35 | *########################################################################
|
---|
36 | */
|
---|
37 | package org.greenstone.core;
|
---|
38 |
|
---|
39 | import java.awt.*;
|
---|
40 | import java.lang.Object;
|
---|
41 | import javax.swing.*;
|
---|
42 |
|
---|
43 | /** This class provides a progress bar to be displayed whenever the module
|
---|
44 | * is running some background tasks
|
---|
45 | * @author John Thompson, Greenstone Digital Library, University of Waikato
|
---|
46 | * @version 2.3
|
---|
47 | */
|
---|
48 | public class ParsingProgress
|
---|
49 | extends JDialog {
|
---|
50 | //implements ActionListener {
|
---|
51 |
|
---|
52 | public final static int ONE_SECOND = 1000;
|
---|
53 |
|
---|
54 | /** The content pane within the dialog box. */
|
---|
55 | private JPanel content_pane = null;
|
---|
56 | private Timer timer;
|
---|
57 | /** The progress bar itself. */
|
---|
58 | private JProgressBar progressBar = null;
|
---|
59 |
|
---|
60 | /** The default size of the progress dialog. */
|
---|
61 | static final Dimension SIZE = new Dimension(400,75);
|
---|
62 |
|
---|
63 |
|
---|
64 | /** Constructor.
|
---|
65 | * @param title The title to show on the dialog, as a <strong>String</strong>.
|
---|
66 | * @param message The message to show on the dialog, as a <strong>String</strong>.
|
---|
67 | * @param max The total amount of the time the process is running before
|
---|
68 | * the progress bar can be disposed of, as an <i>int</i>.
|
---|
69 | */
|
---|
70 | public ParsingProgress(String title, String message, int max) {
|
---|
71 | super();
|
---|
72 | this.setSize(SIZE);
|
---|
73 | this.setTitle(title);
|
---|
74 | //updateUI();
|
---|
75 |
|
---|
76 | // Creation
|
---|
77 | this.content_pane = (JPanel) getContentPane();
|
---|
78 | this.content_pane = new JPanel();
|
---|
79 |
|
---|
80 | this.progressBar = new JProgressBar();
|
---|
81 | this.progressBar.setMaximum(max);
|
---|
82 | this.progressBar.setIndeterminate(true);
|
---|
83 |
|
---|
84 |
|
---|
85 | // Layout
|
---|
86 | this.content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
87 | this.content_pane.setLayout(new BorderLayout());
|
---|
88 | this.content_pane.add(new JLabel(message), BorderLayout.NORTH);
|
---|
89 | this.content_pane.add(progressBar, BorderLayout.CENTER);
|
---|
90 |
|
---|
91 | //Create a timer
|
---|
92 | //timer = new Timer (ONE_SECOND, new ActionListener() {
|
---|
93 | // public void actionPerformed (ActionEvent evt) {
|
---|
94 | progressBar.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
---|
95 |
|
---|
96 | //container.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
---|
97 | /* progressBar.setValue(max);
|
---|
98 | Toolkit.getDefaultToolkit().beep();
|
---|
99 | timer.stop();
|
---|
100 | startButton.setEnabled(true);
|
---|
101 | setCursor(null); //turn off the wait cursor
|
---|
102 | progressBar.setValue(progressBar.getMinimum());*/
|
---|
103 | //}
|
---|
104 | //});
|
---|
105 |
|
---|
106 | // Center and display
|
---|
107 | Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
|
---|
108 | setLocation((screen_size.width - SIZE.width) / 2,
|
---|
109 | (screen_size.height - SIZE.height) / 2);
|
---|
110 |
|
---|
111 | setVisible(true);
|
---|
112 | }
|
---|
113 |
|
---|
114 | public void destroy() {
|
---|
115 | }
|
---|
116 |
|
---|
117 | /** Method which increments the progress count by one, which should be called
|
---|
118 | ** after every successful parsing of a classifier or plugin.
|
---|
119 | */
|
---|
120 | public void inc() {
|
---|
121 | this.progressBar.setValue(progressBar.getValue() + 1);
|
---|
122 | }
|
---|
123 | }
|
---|