source: trunk/gli/src/org/greenstone/gatherer/gui/ModalProgressPopup.java@ 9340

Last change on this file since 9340 was 9340, checked in by mdewsnip, 19 years ago

Changed to use Gatherer.g_man.wait() instead of setModal() to implement its modality. This makes it a lot easier to use and prevents nasty race conditions.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1/**
2 *############################################################################
3 * A component of the Greenstone Librarian Interface, part of the Greenstone
4 * digital library suite from the New Zealand Digital Library Project at the
5 * University of Waikato, New Zealand.
6 *
7 * Author: Michael Dewsnip, NZDL Project, University of Waikato, NZ
8 *
9 * Copyright (C) 2005 New Zealand Digital Library Project
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *############################################################################
25 */
26
27package org.greenstone.gatherer.gui;
28
29
30import java.awt.*;
31import javax.swing.*;
32import org.greenstone.gatherer.Configuration;
33import org.greenstone.gatherer.Gatherer;
34
35
36public class ModalProgressPopup
37 extends ModalDialog
38{
39 /** The size of the popup */
40 final static private Dimension SIZE = new Dimension(300, 75);
41
42 private String message = null;
43
44
45 public ModalProgressPopup(String title, String message)
46 {
47 super(Gatherer.g_man, title);
48 this.message = message;
49 }
50
51
52 /** Method to close the popup. */
53 public void close()
54 {
55 setVisible(false);
56 Gatherer.g_man.wait(false);
57 }
58
59
60 /** Method to display the popup on screen. */
61 public void display()
62 {
63 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
64 setSize(SIZE);
65
66 // Create
67 JProgressBar progress_bar = new JProgressBar();
68 progress_bar.setIndeterminate(true);
69
70 // Layout
71 JPanel content_pane = (JPanel) getContentPane();
72 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
73 content_pane.setLayout(new BorderLayout());
74 content_pane.add(new JLabel(message), BorderLayout.NORTH);
75 content_pane.add(progress_bar, BorderLayout.CENTER);
76
77 Dimension screen_size = Configuration.screen_size;
78 setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
79 setVisible(true);
80
81 // Lock the rest of the GLI interface until close() is called
82 Gatherer.g_man.wait(true);
83 }
84}
Note: See TracBrowser for help on using the repository browser.