Changeset 6089
- Timestamp:
- 2003-12-02T17:21:46+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/ExportCollectionPrompt.java
r6061 r6089 67 67 extends ModalDialog 68 68 implements GShellListener { 69 70 private OKButtonListener ok_button_listener; 69 71 private ArrayList all_collections = null; 70 72 private ArrayList selected_collections = null; … … 111 113 */ 112 114 public ExportCollectionPrompt() { 113 super(Gatherer.g_man );115 super(Gatherer.g_man, true); 114 116 cancel_button = new JButton(); 115 117 cancel_button.setMnemonic(KeyEvent.VK_C); … … 149 151 150 152 prompt = this; 151 setModal(true);152 153 setSize(SIZE); 153 154 Dictionary.setText(this, "ExportCollectionPrompt.Title"); … … 158 159 list.clearSelection(); 159 160 list.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 160 ok_button.addActionListener(new OKButtonListener()); 161 ok_button_listener = new OKButtonListener(); 162 ok_button.addActionListener(ok_button_listener); 161 163 ok_button.setEnabled(false); 162 164 //title.getDocument().addDocumentListener(new DocumentListener()); … … 290 292 Gatherer.println(""); 291 293 GShell process = new GShell(args, GShell.EXPORT, 3, this, null, GShell.GSHELL_EXPORT); 292 //process.addGShellListener(this); - already added as listener293 process.run(); // Don't bother threading this... yet294 process.start(); 295 //process.run(); 294 296 Gatherer.println("ExportCollectionPrompt.exportCollection().return"); 295 297 } … … 316 318 args[1] += "exported_"+cd_title.replaceAll("\\s",""); 317 319 } 320 ResultDialog result_dialog = new ResultDialog(success, extra); 321 result_dialog.setVisible(true); // Blocks 322 result_dialog.dispose(); 323 result_dialog = null; 324 /* 318 325 if (success) { 319 326 JOptionPane.showMessageDialog(prompt,Dictionary.get("ExportCollectionPrompt.Successful_Export", args)+"\n\n"+Dictionary.get("ExportCollectionPrompt.Output")+"\n"+extra, Dictionary.get("ExportCollectionPrompt.Successful_Title"),JOptionPane.INFORMATION_MESSAGE); … … 322 329 JOptionPane.showMessageDialog(prompt,Dictionary.get("ExportCollectionPrompt.Failed_Export", args)+"\n\n"+Dictionary.get("ExportCollectionPrompt.Output")+"\n"+extra, Dictionary.get("ExportCollectionPrompt.Failed_Title"),JOptionPane.WARNING_MESSAGE); 323 330 } 331 */ 324 332 } 325 333 … … 381 389 */ 382 390 public synchronized void processComplete(GShellEvent event) { 391 successful = false; 383 392 if(event.getStatus() == GShell.OK) { 384 393 if(event.getType() == GShell.EXPORT) { … … 386 395 } 387 396 } 388 else { 389 successful = false; 390 } 397 ok_button_listener.processComplete(); 391 398 } 392 399 … … 433 440 private class OKButtonListener 434 441 implements ActionListener { 442 private Component glass_pane; 443 private MouseListener mouse_blocker_listener; 444 private ProgressDialog progress_dialog; 445 435 446 /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned. 436 447 * @param event An <strong>ActionEvent</strong> containing all the relevant information garnered from the event itself. … … 440 451 */ 441 452 public void actionPerformed(ActionEvent event) { 442 // make sure there are some colls specified 453 ///ystem.err.println("OK Clicked"); 454 // Make sure there are some colls specified 443 455 selected_collections = list.getSelected(); 444 456 error_message = new StringBuffer(); 445 457 446 // set the cursor to hourglass447 Componentglass_pane = getGlassPane();448 MouseListenermouse_blocker_listener = new MouseAdapter() {};458 // Set the cursor to hourglass 459 glass_pane = getGlassPane(); 460 mouse_blocker_listener = new MouseAdapter() {}; 449 461 glass_pane.addMouseListener(mouse_blocker_listener); 450 462 glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); … … 452 464 453 465 // Export the selected collection. 466 ///ystem.err.println("Export collections"); 454 467 exportCollections(); 455 468 469 // Show progress dialog 470 ///ystem.err.println("Showing progress dialog"); 471 progress_dialog = new ProgressDialog(); 472 progress_dialog.setVisible(true); 473 } 474 475 public void processComplete() { 476 ///ystem.err.println("Process complete"); 477 // Dispose of progress dialog 478 progress_dialog.setVisible(false); 479 progress_dialog.dispose(); 480 progress_dialog = null; 481 456 482 // unset the cursor 457 483 glass_pane.setVisible(false); … … 460 486 glass_pane = null; 461 487 mouse_blocker_listener= null; 462 488 463 489 if (successful) { 464 490 resultPrompt(true, error_message.toString()); … … 468 494 error_message = null; 469 495 } 496 497 private class ProgressDialog 498 extends ModalDialog { 499 500 private Dimension size = new Dimension(400,65); 501 502 public ProgressDialog() { 503 super(Gatherer.g_man, Dictionary.get("ExportCollectionPrompt.Title"), true); 504 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); 505 setSize(size); 506 JPanel content_pane = (JPanel) getContentPane(); 507 JLabel progress_label = new JLabel(); 508 Dictionary.setText(progress_label, "ExportCollectionPrompt.Progress_Label"); 509 JProgressBar progress_bar = new JProgressBar(); 510 progress_bar.setIndeterminate(true); 511 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 512 content_pane.setLayout(new BorderLayout()); 513 content_pane.add(progress_label, BorderLayout.NORTH); 514 content_pane.add(progress_bar, BorderLayout.CENTER); 515 // Position 516 Rectangle frame_bounds = Gatherer.g_man.getBounds(); 517 setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2); 518 } 519 } 470 520 } 471 521 … … 504 554 } 505 555 } 556 557 private class ResultDialog 558 extends ModalDialog { 559 560 private Dimension size = new Dimension(400,300); 561 private ResultDialog self; 562 563 public ResultDialog(boolean success, String extra) { 564 super(Gatherer.g_man, Dictionary.get("ExportCollectionPrompt.Successful_Title"), true); 565 566 this.self = this; 567 568 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); 569 setSize(size); 570 571 JPanel content_pane = (JPanel) getContentPane(); 572 JLabel result_label = new JLabel(); 573 if(success) { 574 Dictionary.registerText(result_label, "ExportCollectionPrompt.Successful_Export"); 575 } 576 else { 577 Dictionary.registerText(result_label, "ExportCollectionPrompt.Failed_Export"); 578 } 579 580 JPanel button_pane = new JPanel(); 581 JButton close_button = new JButton("Close"); 582 close_button.addActionListener(new CloseButtonListener()); 583 584 JPanel output_pane = new JPanel(); 585 JLabel output_label = new JLabel(); 586 Dictionary.registerText(output_label, "ExportCollectionPrompt.Output"); 587 588 JTextArea output_textarea = new JTextArea(extra); 589 output_textarea.setCaretPosition(0); 590 output_textarea.setEditable(false); 591 output_textarea.setLineWrap(true); 592 output_textarea.setWrapStyleWord(true); 593 594 button_pane.setLayout(new BorderLayout()); 595 button_pane.add(close_button, BorderLayout.EAST); 596 597 output_pane.setBorder(BorderFactory.createEmptyBorder(5,0,5,0)); 598 output_pane.setLayout(new BorderLayout()); 599 output_pane.add(output_label, BorderLayout.NORTH); 600 output_pane.add(new JScrollPane(output_textarea), BorderLayout.CENTER); 601 602 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 603 content_pane.setLayout(new BorderLayout()); 604 content_pane.add(result_label, BorderLayout.NORTH); 605 content_pane.add(output_pane, BorderLayout.CENTER); 606 content_pane.add(button_pane, BorderLayout.SOUTH); 607 608 // Position 609 Rectangle frame_bounds = Gatherer.g_man.getBounds(); 610 setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2); 611 } 612 613 private class CloseButtonListener 614 implements ActionListener { 615 public void actionPerformed(ActionEvent event) { 616 self.setVisible(false); 617 } 618 } 619 } 506 620 } 621 622 623 624
Note:
See TracChangeset
for help on using the changeset viewer.