1 | /**
|
---|
2 | *#########################################################################
|
---|
3 | *
|
---|
4 | * A component of the Gatherer 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 |
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 | /* GPL_HEADER */
|
---|
44 | package org.greenstone.gatherer.gui;
|
---|
45 | /**************************************************************************************
|
---|
46 | * Title: Gatherer
|
---|
47 | * Description: The Gatherer: a tool for gathering and enriching a digital collection.
|
---|
48 | * Company: The University of Waikato
|
---|
49 | * Written: 19/09/02
|
---|
50 | * Revised:
|
---|
51 | * @author John Thompson, 9826509
|
---|
52 | * @version 2.3
|
---|
53 | **************************************************************************************/
|
---|
54 |
|
---|
55 | import java.awt.BorderLayout;
|
---|
56 | import java.awt.Dimension;
|
---|
57 | import java.lang.Runnable;
|
---|
58 | import java.lang.Thread;
|
---|
59 | import javax.swing.JDialog;
|
---|
60 | import javax.swing.JPanel;
|
---|
61 | import javax.swing.JProgressBar;
|
---|
62 | import javax.swing.SwingUtilities;
|
---|
63 | import org.greenstone.gatherer.Gatherer;
|
---|
64 |
|
---|
65 | public class SaveProgressDialog
|
---|
66 | extends Thread {
|
---|
67 |
|
---|
68 | private Gatherer gatherer;
|
---|
69 | private JDialog dialog;
|
---|
70 | private JProgressBar progress;
|
---|
71 | static final public int METADATA = 50;
|
---|
72 | static final public int COLLECTION = 40;
|
---|
73 | static final public int MISC = 10;
|
---|
74 | static final private Dimension SIZE = new Dimension(300,30);
|
---|
75 |
|
---|
76 | public SaveProgressDialog(Gatherer gatherer) {
|
---|
77 | this.gatherer = gatherer;
|
---|
78 | // Creation
|
---|
79 | dialog = new JDialog();
|
---|
80 | dialog.setUndecorated(true);
|
---|
81 | dialog.setModal(true);
|
---|
82 | dialog.setSize(SIZE);
|
---|
83 | JPanel content_pane = (JPanel)dialog.getContentPane();
|
---|
84 | progress = new JProgressBar();
|
---|
85 | progress.setMinimum(0);
|
---|
86 | progress.setMaximum(100);
|
---|
87 | progress.setString(gatherer.get("SaveProgressDialog.Saving", "0"));
|
---|
88 | progress.setStringPainted(true);
|
---|
89 | // Layout
|
---|
90 | content_pane.setLayout(new BorderLayout());
|
---|
91 | content_pane.add(progress, BorderLayout.CENTER);
|
---|
92 | Dimension screen_size = gatherer.config.screen_size;
|
---|
93 | dialog.setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
|
---|
94 | }
|
---|
95 |
|
---|
96 | public void dispose() {
|
---|
97 | dialog.dispose();
|
---|
98 | }
|
---|
99 |
|
---|
100 | public void run() {
|
---|
101 | dialog.show(); // Modal.
|
---|
102 | }
|
---|
103 |
|
---|
104 | public void update(final int amount) {
|
---|
105 | final JProgressBar final_progress = progress;
|
---|
106 | final Runnable update = new Runnable() {
|
---|
107 | public void run() {
|
---|
108 | progress.setValue(final_progress.getValue() + amount);
|
---|
109 | }
|
---|
110 | };
|
---|
111 | try {
|
---|
112 | SwingUtilities.invokeLater(update);
|
---|
113 | }
|
---|
114 | catch (Exception e) {
|
---|
115 | gatherer.debug(e, "Error in SaveProgressDialog.update(): " + e);
|
---|
116 | }
|
---|
117 | }
|
---|
118 | }
|
---|