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

Last change on this file since 11480 was 11423, checked in by kjdon, 18 years ago

changed teh title so it matches the menu item

  • Property svn:keywords set to Author Date Id Revision
File size: 24.7 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.LocalGreenstone;
50import org.greenstone.gatherer.collection.BasicCollectionConfiguration;
51import org.greenstone.gatherer.collection.CollectionManager;
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 /** A string array used to pass arguments to the phrase retrieval method. */
92 private JCheckBox netscape_checkbox = null;
93 JLabel netscape_label = null;
94 private JTextField title_field = null;
95 private JTextField estimated_size_field = null;
96 private JLabel title_label = null;
97 private JLabel estimated_size_label = null;
98 private String args[] = null;
99 private String cd_title = null;
100 /** whether the exporting was successful or not */
101 private boolean successful = false;
102 /** whether we are trying to export or not */
103 private boolean exporting = false;
104 /** the error message if any */
105 private StringBuffer error_message = null;
106 /** This is the size of the exported stuff on its own without
107 netscape and no collections. */
108 private long total_exported_size = 16250000;
109 /** the size of netscape */
110 private long netscape_size = 16500000;
111 /** The size of the export prompt screen. */
112 public static final Dimension SIZE = new Dimension(500, 500);
113
114 /** Constructor.
115 * @see org.greenstone.gatherer.collection.WriteCDImagePrompt.CancelButtonListener
116 * @see org.greenstone.gatherer.collection.WriteCDImagePrompt.CollectionListListener
117 * @see org.greenstone.gatherer.collection.WriteCDImagePrompt.OKButtonListener
118 */
119 public WriteCDImagePrompt() {
120 super(Gatherer.g_man, true);
121 cancel_button = new GLIButton();
122 cancel_button.setMnemonic(KeyEvent.VK_C);
123 Dictionary.setBoth(cancel_button, "General.Close", "General.Close_Tooltip");
124 details_textarea = new JTextArea();
125 details_textarea.setEditable(false);
126 Dictionary.setText(details_textarea, "DeleteCollectionPrompt.No_Collection");
127 details_label = new JLabel();
128 Dictionary.setText(details_label, "DeleteCollectionPrompt.Collection_Details");
129
130 instructions_textarea = new JTextArea();
131 instructions_textarea.setCaretPosition(0);
132 instructions_textarea.setEditable(false);
133 instructions_textarea.setLineWrap(true);
134 instructions_textarea.setRows(4);
135 instructions_textarea.setWrapStyleWord(true);
136 Dictionary.registerText(instructions_textarea, "WriteCDImagePrompt.Instructions");
137
138 all_collections = new ArrayList();
139 list = new CheckList(true);
140 list_label = new JLabel();
141 Dictionary.setText(list_label, "DeleteCollectionPrompt.Collection_List");
142 ok_button = new GLIButton();
143 ok_button.setMnemonic(KeyEvent.VK_D);
144 Dictionary.setBoth(ok_button, "WriteCDImagePrompt.Export", "WriteCDImagePrompt.Export_Tooltip");
145
146 title_field = new JTextField();
147 // Dictionary.setTooltip(title_field, "WriteCDImagePrompt.CD_Name_Tooltip");
148 title_label = new JLabel();
149 Dictionary.setText(title_label, "WriteCDImagePrompt.CD_Name");
150
151 estimated_size_field = new JTextField();
152 estimated_size_field.setEditable(false);
153 estimated_size_field.setText(Utility.formatFileLength(total_exported_size));
154 estimated_size_field.setBackground(Configuration.getColor("coloring.collection_tree_background", false));
155 estimated_size_label = new JLabel();
156 Dictionary.setText(estimated_size_label, "WriteCDImagePrompt.Size_Label");
157
158 netscape_checkbox = new JCheckBox();
159 netscape_checkbox.addActionListener(new NetscapeCheckBoxListener());
160 netscape_label = new JLabel();
161 Dictionary.setText(netscape_label, "WriteCDImagePrompt.Netscape_Compatibility");
162
163 scanForCollections();
164 list.setListData(all_collections);
165
166 prompt = this;
167 setSize(SIZE);
168 //Dictionary.setText(this, "WriteCDImagePrompt.Title");
169 Dictionary.setText(this, "WriteCDImagePrompt.Export");
170 setJMenuBar(new SimpleMenuBar("0")); // need to find an appropriate help page to open at
171 cancel_button.addActionListener(new CancelButtonListener());
172 list.addListSelectionListener(new CollectionListListener());
173 list.clearSelection();
174 list.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
175 ok_button_listener = new OKButtonListener();
176 ok_button.addActionListener(ok_button_listener);
177 ok_button.setEnabled(false);
178 //title.getDocument().addDocumentListener(new DocumentListener());
179
180 // work out the size of the extra images needed for netscape 4
181 // this assumes that they'll be installed (lang pack).
182 //exportcol.pl will crap out if they are not.
183 netscape_size += getFileSize(new File(LocalGreenstone.getDirectoryPath()+File.separator+"images"));
184 }
185
186 /** Destructor. */
187 public void destroy() {
188 all_collections.clear();
189 all_collections = null;
190 cancel_button = null;
191 details_textarea = null;
192 details_label = null;
193 list = null;
194 ok_button = null;
195 prompt = null;
196 if (selected_collections!=null) {
197 selected_collections.clear();
198 selected_collections = null;
199 }
200 title_field = null;
201 title_label = null;
202 }
203
204 /** This method causes the modal prompt to be displayed.
205 * returns true if it has exported the collections that are currently selected */
206 public boolean display() {
207 // Top pane
208 JPanel instructions_pane = new JPanel(new BorderLayout());
209 instructions_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
210 instructions_pane.add(new JScrollPane(instructions_textarea), BorderLayout.CENTER);
211
212 title_label.setBorder(BorderFactory.createEmptyBorder(0,5,0,15));
213
214 JPanel title_pane = new JPanel(new BorderLayout());
215 title_pane.add(title_label, BorderLayout.WEST);
216 title_pane.add(title_field, BorderLayout.CENTER);
217 // instructions_pane.add(title_pane, BorderLayout.SOUTH);
218
219 JPanel netscape_pane = new JPanel(new BorderLayout());
220 netscape_pane.add(netscape_checkbox, BorderLayout.WEST);
221 netscape_pane.add(netscape_label, BorderLayout.CENTER);
222
223 JPanel grid_pane = new JPanel(new GridLayout(2,1));
224 grid_pane.add(title_pane);
225 grid_pane.add(netscape_pane);
226 instructions_pane.add(grid_pane, BorderLayout.SOUTH);
227
228 // Central pane
229 JPanel list_pane = new JPanel(new BorderLayout());
230 list_pane.add(list_label, BorderLayout.NORTH);
231 list_pane.add(new JScrollPane(list), BorderLayout.CENTER);
232 list_pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
233
234 JPanel details_pane = new JPanel(new BorderLayout());
235 details_pane.add(details_label, BorderLayout.NORTH);
236 details_pane.add(new JScrollPane(details_textarea), BorderLayout.CENTER);
237 details_pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
238
239 JPanel central_pane = new JPanel(new GridLayout(2, 1));
240 central_pane.add(list_pane);
241 central_pane.add(details_pane);
242 central_pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
243
244 // Lower pane
245 JPanel estimated_size_pane = new JPanel(new BorderLayout());
246 estimated_size_pane.add(estimated_size_label, BorderLayout.WEST);
247 estimated_size_pane.add(estimated_size_field, BorderLayout.CENTER);
248 estimated_size_pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
249
250 JPanel button_pane = new JPanel(new GridLayout(1, 2));
251 button_pane.add(ok_button);
252 button_pane.add(cancel_button);
253 button_pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
254
255 JPanel lower_pane = new JPanel(new BorderLayout());
256 lower_pane.add(estimated_size_pane, BorderLayout.NORTH);
257 lower_pane.add(button_pane, BorderLayout.SOUTH);
258 lower_pane.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));
259
260 // Final.
261 JPanel content_pane = (JPanel)this.getContentPane();
262 content_pane.setLayout(new BorderLayout());
263 content_pane.add(instructions_pane, BorderLayout.NORTH);
264 content_pane.add(central_pane, BorderLayout.CENTER);
265 content_pane.add(lower_pane, BorderLayout.SOUTH);
266
267 // Center and display.
268 Dimension screen_size = Configuration.screen_size;
269 this.setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
270 this.setVisible(true); // blocks until the dialog is killed
271 return true;
272
273 }
274
275
276 protected long getFileSize(File file)
277 {
278 long file_size = 0;
279
280 // Directory case
281 if (file.isDirectory()) {
282 File files[] = file.listFiles();
283 for (int i = 0; i < files.length; i++) {
284 file_size += getFileSize(files[i]);
285 }
286 }
287 // File case
288 else {
289 file_size = file.length();
290 }
291
292 return file_size;
293 }
294
295 /** This method calls the builcol.pl scripts via a GShell so as to not lock up the processor.
296 * @see org.greenstone.gatherer.Configuration
297 * @see org.greenstone.gatherer.Gatherer
298 * @see org.greenstone.gatherer.collection.Collection
299 * @see org.greenstone.gatherer.gui.BuildOptions
300 * @see org.greenstone.gatherer.shell.GShell
301 * @see org.greenstone.gatherer.shell.GShellListener
302 * @see org.greenstone.gatherer.shell.GShellProgressMonitor
303 * @see org.greenstone.gatherer.util.Utility
304 */
305 public void writeCDImageCollections()
306 {
307 DebugStream.println("WriteCDImagePrompt.writeCDImageCollections()");
308
309 int num_collections = selected_collections.size();
310 if (num_collections == 0) return;
311 cd_title = title_field.getText();
312 cd_title = cd_title.trim();
313 cd_title = cd_title.replaceAll("\"","");
314
315 boolean use_netscape = false;
316 if (netscape_checkbox.isSelected()) {
317 use_netscape = true;
318 }
319
320 // Generate the exportcol.pl command
321 ArrayList command_parts_list = new ArrayList();
322 if (Utility.isWindows() && (!Gatherer.isGsdlRemote)) {
323 command_parts_list.add(Configuration.perl_path);
324 command_parts_list.add("-S");
325 }
326 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "exportcol.pl");
327
328 //if (Gatherer.isGsdlRemote || !use_netscape) {
329 if (!use_netscape) {
330 // now we allow remote users to use the netscape version
331 command_parts_list.add("-nonetscape");
332 }
333
334 command_parts_list.add("-gli");
335 command_parts_list.add("-language");
336 command_parts_list.add(Configuration.getLanguage());
337
338 if (cd_title.equals("")) {
339 command_parts_list.add("-cdname");
340 command_parts_list.add("Greenstone Collections");
341
342 command_parts_list.add("-cddir");
343 command_parts_list.add("exported_collections");
344 }
345 else {
346 command_parts_list.add("-cdname");
347 command_parts_list.add(cd_title);
348
349 String cd_dir = "exported_"+cd_title.replaceAll("\\s","");
350 command_parts_list.add("-cddir");
351 command_parts_list.add(cd_dir);
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
364 // Run the exportcol.pl command
365 String[] command_parts = (String[]) command_parts_list.toArray(new String[0]);
366 GShell process = new GShell(command_parts, GShell.CDIMAGE, 3, this, null, GShell.GSHELL_CDIMAGE);
367 process.start();
368 //process.run();
369 DebugStream.println("WriteCDImagePrompt.writeCDImageCollections().return");
370
371 }
372
373 /** Shows an export complete prompt.
374 * @param success A <strong>boolean</strong> indicating if the collection was successfully deleted.
375 * @see org.greenstone.gatherer.collection.Collection
376 */
377 public void resultPrompt(boolean success, String extra) {
378 args = new String[2];
379 StringBuffer coll_names = new StringBuffer();
380 for (int i=0; i<selected_collections.size();i++) {
381 if (i>0) {
382 coll_names.append(", ");
383 }
384 BasicCollectionConfiguration complete_collection = (BasicCollectionConfiguration)selected_collections.get(i);
385 coll_names.append(complete_collection.getName() + StaticStrings.SPACE_CHARACTER + StaticStrings.OPEN_PARENTHESIS_CHARACTER + complete_collection.getShortName() + StaticStrings.CLOSE_PARENTHESIS_CHARACTER);
386 complete_collection = null;
387 }
388
389 args[0] = coll_names.toString();
390 args[1] = LocalGreenstone.getTmpDirectoryPath();
391 if(cd_title.equals("")) {
392 args[1] += "exported_collections";
393 } else {
394 args[1] += "exported_"+cd_title.replaceAll("\\s","");
395 }
396 String title;
397 String label;
398 if (success) {
399 title = Dictionary.get("WriteCDImagePrompt.Successful_Title");
400 label = Dictionary.get("WriteCDImagePrompt.Successful_Export", args);
401 } else {
402 title = Dictionary.get("WriteCDImagePrompt.Failed_Title");
403 label = Dictionary.get("WriteCDImagePrompt.Failed_Export", args);
404 }
405 SimpleResultDialog result_dialog = new SimpleResultDialog(title, label, extra);
406 result_dialog.setVisible(true); // Blocks
407 result_dialog.dispose();
408 result_dialog = null;
409 }
410
411 /** Method to scan the collect directory retrieving and reloading each collection it finds, while building the list of known collections.
412 * @see org.greenstone.gatherer.Configuration
413 * @see org.greenstone.gatherer.Gatherer
414 * @see org.greenstone.gatherer.util.ArrayTools
415 * @see org.greenstone.gatherer.util.Utility
416 */
417 private void scanForCollections() {
418 // Start at the collect dir.
419 File collect_directory = new File(Gatherer.getCollectDirectoryPath());
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], Utility.CONFIG_FILE);
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 private class NetscapeCheckBoxListener
485 implements ActionListener {
486 public void actionPerformed(ActionEvent e) {
487 if (netscape_checkbox.isSelected()) {
488 total_exported_size += netscape_size;
489 } else {
490 total_exported_size -= netscape_size;
491 }
492 // Update the size field
493 estimated_size_field.setText(Utility.formatFileLength(total_exported_size));
494 }
495 }
496 /** This private class listens for selection events in from the list and then displays the appropriate details for that collection.
497 */
498 private class CollectionListListener
499 implements ListSelectionListener
500 {
501 /** Any implementation of ListSelectionListener must include this method so we can be informed when the list selection changes.
502 * @param event a <strong>ListSelectionEvent</strong> containing all the relevant information garnered from the event itself
503 */
504 public void valueChanged(ListSelectionEvent event)
505 {
506 // Wait for things to settle down a bit
507 if (event.getValueIsAdjusting()) {
508 return;
509 }
510
511 // Can only export when something is ticked
512 ok_button.setEnabled(!list.isNothingTicked());
513
514 if (list.isSelectionEmpty()) {
515 // This only happens when the dialog is first entered
516 Dictionary.setText(details_textarea, "DeleteCollectionPrompt.No_Collection");
517 return;
518 }
519
520 collection = (BasicCollectionConfiguration) ((CheckListEntry) list.getSelectedValue()).getObject();
521 args = new String[3];
522 args[0] = collection.getCreator();
523 args[1] = collection.getMaintainer();
524 args[2] = collection.getDescription();
525 Dictionary.setText(details_textarea, "DeleteCollectionPrompt.Details", args);
526 details_textarea.setCaretPosition(0);
527
528 // Find the size of the "etc", "images" and "index" directories of the collection
529 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection.getShortName());
530 File etc_directory = new File(collection_directory_path + "etc");
531 File images_directory = new File(collection_directory_path + "images");
532 File index_directory = new File(collection_directory_path + "index");
533 long collection_size_built = getFileSize(etc_directory) + getFileSize(images_directory) + getFileSize(index_directory);
534
535 // Add/subtract it from the total, depending on whether the collection has just been ticked/unticked
536 if (((CheckListEntry) list.getSelectedValue()).isSelected()) {
537 total_exported_size += collection_size_built;
538 }
539 else {
540 total_exported_size -= collection_size_built;
541 }
542
543 // Update the size field
544 estimated_size_field.setText(Utility.formatFileLength(total_exported_size));
545 }
546 }
547
548
549 /** The OK button listener implementation. */
550 private class OKButtonListener
551 implements ActionListener {
552 private Component glass_pane;
553 private MouseListener mouse_blocker_listener;
554 private ProgressDialog progress_dialog;
555
556 /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned.
557 * @param event An <strong>ActionEvent</strong> containing all the relevant information garnered from the event itself.
558 * @see org.greenstone.gatherer.Configuration
559 * @see org.greenstone.gatherer.Gatherer
560 * @see org.greenstone.gatherer.util.Utility
561 */
562 public void actionPerformed(ActionEvent event) {
563 ///ystem.err.println("OK Clicked");
564 // Make sure there are some colls specified
565 selected_collections = list.getTicked();
566 error_message = new StringBuffer();
567
568 // Set the cursor to hourglass
569 glass_pane = getGlassPane();
570 mouse_blocker_listener = new MouseAdapter() {};
571 glass_pane.addMouseListener(mouse_blocker_listener);
572 glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
573 glass_pane.setVisible(true);
574
575 // Export the selected collection.
576 ///ystem.err.println("Write CD-ROM/DVD image for named collections");
577 writeCDImageCollections();
578
579 // Show progress dialog
580 ///ystem.err.println("Showing progress dialog");
581 progress_dialog = new ProgressDialog();
582 progress_dialog.setVisible(true);
583 }
584
585 public void processComplete() {
586 ///ystem.err.println("Process complete");
587 // Dispose of progress dialog
588 progress_dialog.setVisible(false);
589 progress_dialog.dispose();
590 progress_dialog = null;
591
592 // unset the cursor
593 glass_pane.setVisible(false);
594 glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
595 glass_pane.removeMouseListener(mouse_blocker_listener);
596 glass_pane = null;
597 mouse_blocker_listener= null;
598
599 if (successful) {
600 resultPrompt(true, error_message.toString());
601 } else {
602 resultPrompt(false, error_message.toString());
603 }
604 error_message = null;
605 }
606
607 private class ProgressDialog
608 extends ModalDialog {
609
610 private Dimension size = new Dimension(400,65);
611
612 public ProgressDialog() {
613 super(Gatherer.g_man, Dictionary.get("WriteCDImagePrompt.Title"), true);
614 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
615 setSize(size);
616 JPanel content_pane = (JPanel) getContentPane();
617 JLabel progress_label = new JLabel();
618 Dictionary.setText(progress_label, "WriteCDImagePrompt.Progress_Label");
619 JProgressBar progress_bar = new JProgressBar();
620 progress_bar.setIndeterminate(true);
621 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
622 content_pane.setLayout(new BorderLayout());
623 content_pane.add(progress_label, BorderLayout.NORTH);
624 content_pane.add(progress_bar, BorderLayout.CENTER);
625 // Position
626 Rectangle frame_bounds = Gatherer.g_man.getBounds();
627 setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2);
628 }
629 }
630 }
631}
Note: See TracBrowser for help on using the repository browser.