source: trunk/gli/src/org/greenstone/gatherer/gui/WriteCDImagePrompt.java@ 14045

Last change on this file since 14045 was 14045, checked in by xiao, 17 years ago

Changes made to look for collectionConfig.xml in gs3 mode and collect.cfg in gs2 mode, rather than presumably only for the file collect.cfg.

  • Property svn:keywords set to Author Date Id Revision
File size: 24.4 KB
Line 
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 */
37package org.greenstone.gatherer.gui;
38
39import java.awt.*;
40import java.awt.event.*;
41import java.io.*;
42import java.util.ArrayList;
43import javax.swing.*;
44import javax.swing.event.*;
45import org.greenstone.gatherer.Configuration;
46import org.greenstone.gatherer.DebugStream;
47import org.greenstone.gatherer.Dictionary;
48import org.greenstone.gatherer.Gatherer;
49import org.greenstone.gatherer.collection.BasicCollectionConfiguration;
50import org.greenstone.gatherer.collection.CollectionManager;
51import org.greenstone.gatherer.greenstone.LocalGreenstone;
52import org.greenstone.gatherer.shell.GShell;
53import org.greenstone.gatherer.shell.GShellEvent;
54import org.greenstone.gatherer.shell.GShellListener;
55import org.greenstone.gatherer.util.ArrayTools;
56import org.greenstone.gatherer.util.CheckList;
57import org.greenstone.gatherer.util.CheckListEntry;
58import org.greenstone.gatherer.util.StaticStrings;
59import org.greenstone.gatherer.util.Utility;
60
61/** This class provides the functionality to write a CD-ROM/DVD image of current collections from the GSDLHOME/collect/ directory to CDROM. The user chooses the collection from a list, where each entry also displays details about itself, confirms the delete of a collection by checking a checkbox then presses the ok button to actually delete the collection.
62 Copied from DeleteCollectionPrompt
63 * @author John Thompson, Greenstone Digital Library, University of Waikato
64 * @version 2.3
65 */
66public class WriteCDImagePrompt
67 extends ModalDialog
68 implements GShellListener {
69
70 private OKButtonListener ok_button_listener;
71 private ArrayList all_collections = null;
72 private ArrayList selected_collections = null;
73 /** The list of collections to include in exported cd-rom/dvd image */
74 private CheckList list = null;
75 /** The currently selected collection for deletion. */
76 private BasicCollectionConfiguration collection = null;
77 /** A reference to ourself so any inner-classes can dispose of us. */
78 private WriteCDImagePrompt prompt = null;
79 /** The close button, which exits the prompt without deleting anything. */
80 private JButton cancel_button = null;
81 /** The ok button which causes the selected collection to be deleted. */
82 private JButton ok_button = null;
83 /** The label above details. */
84 private JLabel details_label = null;
85 /** The label above the list. */
86 private JLabel list_label = null;
87 /** The text area used to display details about the collection selected. */
88 private JTextArea details_textarea = null;
89 /** The text area used to display instructions for the cd-rom/dvd export */
90 private JTextArea instructions_textarea;
91
92 /** The radio button for switching on the noinstall option */
93 private JRadioButton noinstall_button = null;
94 private JRadioButton install_button = null;
95 private JTextField title_field = null;
96 private JTextField estimated_size_field = null;
97 private JLabel title_label = null;
98 private JLabel estimated_size_label = null;
99 /** A string array used to pass arguments to the exportcol.pl script */
100 private String args[] = null;
101 private String cd_title = null;
102 /** whether the exporting was successful or not */
103 private boolean successful = false;
104 /** whether we are trying to export or not */
105 private boolean exporting = false;
106 /** the error message if any */
107 private StringBuffer error_message = null;
108 /** This is the size of the exported stuff on its own without collections. */
109 private long total_exported_size = 14000000;
110 /** The size of the export prompt screen. */
111 public static final Dimension SIZE = new Dimension(500, 500);
112
113 /** Constructor.
114 * @see org.greenstone.gatherer.collection.WriteCDImagePrompt.CancelButtonListener
115 * @see org.greenstone.gatherer.collection.WriteCDImagePrompt.CollectionListListener
116 * @see org.greenstone.gatherer.collection.WriteCDImagePrompt.OKButtonListener
117 */
118 public WriteCDImagePrompt() {
119 super(Gatherer.g_man, true);
120 cancel_button = new GLIButton(Dictionary.get("General.Close"), Dictionary.get("General.Close_Tooltip"));
121
122 details_textarea = new JTextArea(Dictionary.get("DeleteCollectionPrompt.No_Collection"));
123 details_textarea.setEditable(false);
124
125 details_label = new JLabel(Dictionary.get("DeleteCollectionPrompt.Collection_Details"));
126
127 instructions_textarea = new JTextArea(Dictionary.get("WriteCDImagePrompt.Instructions"));
128 instructions_textarea.setCaretPosition(0);
129 instructions_textarea.setEditable(false);
130 instructions_textarea.setLineWrap(true);
131 instructions_textarea.setRows(4);
132 instructions_textarea.setWrapStyleWord(true);
133
134 all_collections = new ArrayList();
135 list = new CheckList(true);
136 list_label = new JLabel(Dictionary.get("DeleteCollectionPrompt.Collection_List"));
137
138 ok_button = new GLIButton(Dictionary.get("WriteCDImagePrompt.Export"), Dictionary.get("WriteCDImagePrompt.Export_Tooltip"));
139
140 title_field = new JTextField();
141 // Dictionary.setTooltip(title_field, "WriteCDImagePrompt.CD_Name_Tooltip");
142 title_label = new JLabel(Dictionary.get("WriteCDImagePrompt.CD_Name"));
143
144
145 estimated_size_field = new JTextField();
146 estimated_size_field.setEditable(false);
147
148 // work out the size of the images directory - could be large if they
149 // have the classic interface pack installed
150 total_exported_size += getFileSize(new File(LocalGreenstone.getDirectoryPath()+File.separator+"images"));
151 estimated_size_field.setText(Utility.formatFileLength(total_exported_size));
152 estimated_size_field.setBackground(Configuration.getColor("coloring.collection_tree_background", false));
153 estimated_size_label = new JLabel(Dictionary.get("WriteCDImagePrompt.Size_Label"));
154
155 scanForCollections();
156 list.setListData(all_collections);
157
158 prompt = this;
159 setSize(SIZE);
160 setTitle(Dictionary.get("WriteCDImagePrompt.Export"));
161
162 setJMenuBar(new SimpleMenuBar("exportingcollections"));
163 cancel_button.addActionListener(new CancelButtonListener());
164 list.addListSelectionListener(new CollectionListListener());
165 list.clearSelection();
166 list.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
167 ok_button_listener = new OKButtonListener();
168 ok_button.addActionListener(ok_button_listener);
169 ok_button.setEnabled(false);
170 //title.getDocument().addDocumentListener(new DocumentListener());
171
172 noinstall_button = new JRadioButton(Dictionary.get("WriteCDImagePrompt.NoInstall"));
173 noinstall_button.setToolTipText(Dictionary.get("WriteCDImagePrompt.NoInstall_Tooltip"));
174
175
176 install_button = new JRadioButton(Dictionary.get("WriteCDImagePrompt.Install"));
177 install_button.setToolTipText(Dictionary.get("WriteCDImagePrompt.Install_Tooltip"));
178
179
180
181 }
182
183 /** Destructor. */
184 public void destroy() {
185 all_collections.clear();
186 all_collections = null;
187 cancel_button = null;
188 details_textarea = null;
189 details_label = null;
190 list = null;
191 ok_button = null;
192 prompt = null;
193 if (selected_collections!=null) {
194 selected_collections.clear();
195 selected_collections = null;
196 }
197 title_field = null;
198 title_label = null;
199 }
200
201 /** This method causes the modal prompt to be displayed.
202 * returns true if it has exported the collections that are currently selected */
203 public boolean display() {
204
205 // Radio buttons
206 ButtonGroup radio_group = new ButtonGroup();
207 radio_group.add(install_button);
208 install_button.setSelected(true);
209 radio_group.add(noinstall_button);
210
211 // Top pane
212 JPanel instructions_pane = new JPanel(new BorderLayout());
213 instructions_pane.setBorder(BorderFactory.createEmptyBorder(5,5,0,5));
214 instructions_pane.add(new JScrollPane(instructions_textarea), BorderLayout.CENTER);
215
216 title_label.setBorder(BorderFactory.createEmptyBorder(0,5,0,15));
217
218 JPanel title_pane = new JPanel(new BorderLayout());
219 title_pane.add(title_label, BorderLayout.WEST);
220 title_pane.add(title_field, BorderLayout.CENTER);
221 title_pane.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
222
223 JPanel radio_pane = new JPanel(new GridLayout(2,1));
224 install_button.setBackground(Configuration.getColor("coloring.collection_heading_background", true));
225 noinstall_button.setBackground(Configuration.getColor("coloring.collection_heading_background", true));
226 radio_pane.add(install_button);
227 radio_pane.add(noinstall_button);
228
229
230 JPanel options_pane = new JPanel(new BorderLayout());
231 options_pane.add(title_pane, BorderLayout.NORTH);
232 options_pane.add(radio_pane, BorderLayout.CENTER);
233 instructions_pane.add(options_pane, BorderLayout.SOUTH);
234
235 // Central pane
236 JPanel list_pane = new JPanel(new BorderLayout());
237 list_pane.add(list_label, BorderLayout.NORTH);
238 list_pane.add(new JScrollPane(list), BorderLayout.CENTER);
239 list_pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
240
241 JPanel details_pane = new JPanel(new BorderLayout());
242 details_pane.add(details_label, BorderLayout.NORTH);
243 details_pane.add(new JScrollPane(details_textarea), BorderLayout.CENTER);
244 details_pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
245
246 JPanel central_pane = new JPanel(new GridLayout(2, 1));
247 central_pane.add(list_pane);
248 central_pane.add(details_pane);
249 central_pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
250
251 // Lower pane
252 JPanel estimated_size_pane = new JPanel(new BorderLayout());
253 estimated_size_pane.add(estimated_size_label, BorderLayout.WEST);
254 estimated_size_pane.add(estimated_size_field, BorderLayout.CENTER);
255 estimated_size_pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
256
257 JPanel button_pane = new JPanel(new GridLayout(1, 2));
258 button_pane.add(ok_button);
259 button_pane.add(cancel_button);
260 button_pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
261
262 JPanel lower_pane = new JPanel(new BorderLayout());
263 lower_pane.add(estimated_size_pane, BorderLayout.NORTH);
264 lower_pane.add(button_pane, BorderLayout.SOUTH);
265 lower_pane.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));
266
267 // Final.
268 JPanel content_pane = (JPanel)this.getContentPane();
269 content_pane.setLayout(new BorderLayout());
270 content_pane.add(instructions_pane, BorderLayout.NORTH);
271 content_pane.add(central_pane, BorderLayout.CENTER);
272 content_pane.add(lower_pane, BorderLayout.SOUTH);
273
274 // Center and display.
275 Dimension screen_size = Configuration.screen_size;
276 this.setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
277 this.setVisible(true); // blocks until the dialog is killed
278 return true;
279
280 }
281
282
283 private long getFileSize(File file)
284 {
285 long file_size = 0;
286
287 // Directory case
288 if (file.isDirectory()) {
289 File files[] = file.listFiles();
290 for (int i = 0; i < files.length; i++) {
291 file_size += getFileSize(files[i]);
292 }
293 }
294 // File case
295 else {
296 file_size = file.length();
297 }
298
299 return file_size;
300 }
301
302 /** This method calls the builcol.pl scripts via a GShell so as to not lock up the processor.
303 * @see org.greenstone.gatherer.Configuration
304 * @see org.greenstone.gatherer.Gatherer
305 * @see org.greenstone.gatherer.collection.Collection
306 * @see org.greenstone.gatherer.gui.BuildOptions
307 * @see org.greenstone.gatherer.shell.GShell
308 * @see org.greenstone.gatherer.shell.GShellListener
309 * @see org.greenstone.gatherer.shell.GShellProgressMonitor
310 * @see org.greenstone.gatherer.util.Utility
311 */
312 public void writeCDImageCollections()
313 {
314 DebugStream.println("WriteCDImagePrompt.writeCDImageCollections()");
315
316 int num_collections = selected_collections.size();
317 if (num_collections == 0) return;
318 cd_title = title_field.getText();
319 cd_title = cd_title.trim();
320 cd_title = cd_title.replaceAll("\"","");
321
322 // Generate the exportcol.pl command
323 ArrayList command_parts_list = new ArrayList();
324 if (Utility.isWindows() && (!Gatherer.isGsdlRemote)) {
325 command_parts_list.add(Configuration.perl_path);
326 command_parts_list.add("-S");
327 }
328 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "exportcol.pl");
329
330 command_parts_list.add("-gli");
331 command_parts_list.add("-language");
332 command_parts_list.add(Configuration.getLanguage());
333
334 if (cd_title.equals("")) {
335 command_parts_list.add("-cdname");
336 command_parts_list.add("Greenstone Collections");
337
338 command_parts_list.add("-cddir");
339 command_parts_list.add("exported_collections");
340 }
341 else {
342 command_parts_list.add("-cdname");
343 command_parts_list.add(cd_title);
344
345 String cd_dir = "exported_"+cd_title.replaceAll("\\s","");
346 command_parts_list.add("-cddir");
347 command_parts_list.add(cd_dir);
348 }
349
350 if (noinstall_button.isSelected()) {
351 command_parts_list.add("-noinstall");
352 }
353
354 for (int i = 0; i < num_collections; i++) {
355 command_parts_list.add(((BasicCollectionConfiguration) selected_collections.get(i)).getShortName());
356 }
357
358 DebugStream.print("export command = ");
359 for (int i = 0; i < command_parts_list.size(); i++) {
360 DebugStream.print(command_parts_list.get(i) + " ");
361 }
362 DebugStream.println("");
363 // Run the exportcol.pl command
364 String[] command_parts = (String[]) command_parts_list.toArray(new String[0]);
365 GShell process = new GShell(command_parts, GShell.CDIMAGE, 3, this, null, GShell.GSHELL_CDIMAGE);
366 process.start();
367 //process.run();
368 DebugStream.println("WriteCDImagePrompt.writeCDImageCollections().return");
369
370 }
371
372 /** Shows an export complete prompt.
373 * @param success A <strong>boolean</strong> indicating if the collection was successfully deleted.
374 * @see org.greenstone.gatherer.collection.Collection
375 */
376 public void resultPrompt(boolean success, String extra) {
377 args = new String[2];
378 StringBuffer coll_names = new StringBuffer();
379 for (int i=0; i<selected_collections.size();i++) {
380 if (i>0) {
381 coll_names.append(", ");
382 }
383 BasicCollectionConfiguration complete_collection = (BasicCollectionConfiguration)selected_collections.get(i);
384 coll_names.append(complete_collection.getName() + StaticStrings.SPACE_CHARACTER + StaticStrings.OPEN_PARENTHESIS_CHARACTER + complete_collection.getShortName() + StaticStrings.CLOSE_PARENTHESIS_CHARACTER);
385 complete_collection = null;
386 }
387
388 args[0] = coll_names.toString();
389 args[1] = LocalGreenstone.getTmpDirectoryPath();
390 if(cd_title.equals("")) {
391 args[1] += "exported_collections";
392 } else {
393 args[1] += "exported_"+cd_title.replaceAll("\\s","");
394 }
395 String title;
396 String label;
397 if (success) {
398 title = Dictionary.get("WriteCDImagePrompt.Successful_Title");
399 label = Dictionary.get("WriteCDImagePrompt.Successful_Export", args);
400 } else {
401 title = Dictionary.get("WriteCDImagePrompt.Failed_Title");
402 label = Dictionary.get("WriteCDImagePrompt.Failed_Export", args);
403 }
404 SimpleResultDialog result_dialog = new SimpleResultDialog(title, label, extra);
405 result_dialog.setVisible(true); // Blocks
406 result_dialog.dispose();
407 result_dialog = null;
408 }
409
410 /** Method to scan the collect directory retrieving and reloading each collection it finds, while building the list of known collections.
411 * @see org.greenstone.gatherer.Configuration
412 * @see org.greenstone.gatherer.Gatherer
413 * @see org.greenstone.gatherer.util.ArrayTools
414 * @see org.greenstone.gatherer.util.Utility
415 */
416 private void scanForCollections() {
417 // Start at the collect dir.
418 File collect_directory = new File(Gatherer.getCollectDirectoryPath());
419 String file_name = (Gatherer.GS3)? Utility.CONFIG_GS3_FILE : Utility.CONFIG_FILE;
420 if (collect_directory.exists()) {
421 // Now for each child directory see if it contains a .col file and
422 // if so try to load it..
423 File collections[] = collect_directory.listFiles();
424 ArrayTools.sort(collections);
425 for(int i = 0; collections != null && i < collections.length; i++) {
426 if(collections[i].isDirectory() && !collections[i].getName().equals(StaticStrings.MODEL_COLLECTION_NAME)) {
427 File config_file = new File(collections[i], file_name);
428 if (config_file.exists()) {
429 BasicCollectionConfiguration config = new BasicCollectionConfiguration(config_file);
430 all_collections.add(config);
431 config = null;
432 }
433 }
434 }
435 }
436 // Otherwise the collect directory doesn't actually exist, so there ain't much we can do.
437 }
438
439
440 /** All implementation of GShellListener must include this method so the listener can be informed of messages from the GShell.
441 * @param event A <strong>GShellEvent</strong> that contains, amoung other things, the message.
442 */
443 public synchronized void message(GShellEvent event) {
444 // Ignore the messages from RecPlug with 'show_progress' set (used for progress bars)
445 String message = event.getMessage();
446 if (message.startsWith("exportcol.pl>")) {
447 message = message.substring(13);
448 //DebugStream.println("message = "+event.getMessage());
449 error_message.append(message);
450 error_message.append("\n");
451 }
452 }
453
454 /** All implementation of GShellListener must include this method so the listener can be informed when a GShell begins its task. Implementation side-effect, not actually used.
455 * @param event A <strong>GShellEvent</strong> that contains details of the initial state of the <strong>GShell</strong> before task comencement.
456 */
457 public synchronized void processBegun(GShellEvent event) {
458 // We don't care.
459 }
460 /** All implementation of GShellListener must include this method so the listener can be informed when a GShell completes its task.
461 * @param event A <strong>GShellEvent</strong> that contains details of the final state of the <strong>GShell</strong> after task completion.
462 */
463 public synchronized void processComplete(GShellEvent event) {
464 successful = false;
465 if(event.getStatus() == GShell.OK) {
466 if(event.getType() == GShell.CDIMAGE) {
467 successful = true;
468 }
469 }
470 ok_button_listener.processComplete();
471 }
472
473 /** A button listener implementation, which listens for actions on the close button and disposes of the dialog when detected. */
474 private class CancelButtonListener
475 implements ActionListener {
476 /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned.
477 * @param event An <strong>ActionEvent</strong> containing all the relevant information garnered from the event itself.
478 */
479 public void actionPerformed(ActionEvent event) {
480 prompt.dispose();
481 }
482 }
483
484 /** This private class listens for selection events in from the list and then displays the appropriate details for that collection.
485 */
486 private class CollectionListListener
487 implements ListSelectionListener
488 {
489 /** Any implementation of ListSelectionListener must include this method so we can be informed when the list selection changes.
490 * @param event a <strong>ListSelectionEvent</strong> containing all the relevant information garnered from the event itself
491 */
492 public void valueChanged(ListSelectionEvent event)
493 {
494 // Wait for things to settle down a bit
495 if (event.getValueIsAdjusting()) {
496 return;
497 }
498
499 // Can only export when something is ticked
500 ok_button.setEnabled(!list.isNothingTicked());
501
502 if (list.isSelectionEmpty()) {
503 // This only happens when the dialog is first entered
504 details_textarea.setText(Dictionary.get("DeleteCollectionPrompt.No_Collection"));
505 return;
506 }
507
508 collection = (BasicCollectionConfiguration) ((CheckListEntry) list.getSelectedValue()).getObject();
509 args = new String[3];
510 args[0] = collection.getCreator();
511 args[1] = collection.getMaintainer();
512 args[2] = collection.getDescription();
513 details_textarea.setText(Dictionary.get("DeleteCollectionPrompt.Details", args));
514 details_textarea.setCaretPosition(0);
515
516 // Find the size of the "etc", "images" and "index" directories of the collection
517 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection.getShortName());
518 File etc_directory = new File(collection_directory_path + "etc");
519 File images_directory = new File(collection_directory_path + "images");
520 File index_directory = new File(collection_directory_path + "index");
521 long collection_size_built = getFileSize(etc_directory) + getFileSize(images_directory) + getFileSize(index_directory);
522
523 // Add/subtract it from the total, depending on whether the collection has just been ticked/unticked
524 if (((CheckListEntry) list.getSelectedValue()).isSelected()) {
525 total_exported_size += collection_size_built;
526 }
527 else {
528 total_exported_size -= collection_size_built;
529 }
530
531 // Update the size field
532 estimated_size_field.setText(Utility.formatFileLength(total_exported_size));
533 }
534 }
535
536
537 /** The OK button listener implementation. */
538 private class OKButtonListener
539 implements ActionListener {
540 private Component glass_pane;
541 private MouseListener mouse_blocker_listener;
542 private ProgressDialog progress_dialog;
543
544 /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned.
545 * @param event An <strong>ActionEvent</strong> containing all the relevant information garnered from the event itself.
546 * @see org.greenstone.gatherer.Configuration
547 * @see org.greenstone.gatherer.Gatherer
548 * @see org.greenstone.gatherer.util.Utility
549 */
550 public void actionPerformed(ActionEvent event) {
551 ///ystem.err.println("OK Clicked");
552 // Make sure there are some colls specified
553 selected_collections = list.getTicked();
554 error_message = new StringBuffer();
555
556 // Set the cursor to hourglass
557 glass_pane = getGlassPane();
558 mouse_blocker_listener = new MouseAdapter() {};
559 glass_pane.addMouseListener(mouse_blocker_listener);
560 glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
561 glass_pane.setVisible(true);
562
563 // Export the selected collection.
564 ///ystem.err.println("Write CD-ROM/DVD image for named collections");
565 writeCDImageCollections();
566
567 // Show progress dialog
568 ///ystem.err.println("Showing progress dialog");
569 progress_dialog = new ProgressDialog();
570 progress_dialog.setVisible(true);
571 }
572
573 public void processComplete() {
574 ///ystem.err.println("Process complete");
575 // Dispose of progress dialog
576 progress_dialog.setVisible(false);
577 progress_dialog.dispose();
578 progress_dialog = null;
579
580 // unset the cursor
581 glass_pane.setVisible(false);
582 glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
583 glass_pane.removeMouseListener(mouse_blocker_listener);
584 glass_pane = null;
585 mouse_blocker_listener= null;
586
587 if (successful) {
588 resultPrompt(true, error_message.toString());
589 } else {
590 resultPrompt(false, error_message.toString());
591 }
592 error_message = null;
593 }
594
595 private class ProgressDialog
596 extends ModalDialog {
597
598 private Dimension size = new Dimension(400,65);
599
600 public ProgressDialog() {
601 super(Gatherer.g_man, Dictionary.get("WriteCDImagePrompt.Title"), true);
602 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
603 setSize(size);
604 JPanel content_pane = (JPanel) getContentPane();
605 JLabel progress_label = new JLabel(Dictionary.get("WriteCDImagePrompt.Progress_Label"));
606
607 JProgressBar progress_bar = new JProgressBar();
608 progress_bar.setIndeterminate(true);
609 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
610 content_pane.setLayout(new BorderLayout());
611 content_pane.add(progress_label, BorderLayout.NORTH);
612 content_pane.add(progress_bar, BorderLayout.CENTER);
613 // Position
614 Rectangle frame_bounds = Gatherer.g_man.getBounds();
615 setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2);
616 }
617 }
618 }
619}
Note: See TracBrowser for help on using the repository browser.