Changeset 16134
- Timestamp:
- 2008-06-24T18:54:27+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/gui/CreatePane.java
r15862 r16134 53 53 import org.greenstone.gatherer.shell.GBuildProgressMonitor; 54 54 import org.greenstone.gatherer.shell.GImportProgressMonitor; 55 import org.greenstone.gatherer.shell.GScheduleProgressMonitor; 55 56 import org.greenstone.gatherer.shell.GShell; 56 57 import org.greenstone.gatherer.shell.GShellEvent; … … 93 94 /** This monitor tracks the import processes progress. */ 94 95 private GShellProgressMonitor import_monitor = null; 96 /** This monitor tracks the schedule processes progress. */ 97 private GShellProgressMonitor schedule_monitor = null; 95 98 /** The button for begining the building processes. */ 96 99 private JButton build_button = null; 97 100 /** The button for stopping the building processes. */ 98 101 private JButton cancel_button = null; 102 /** The button for setting up scheduling */ 103 private JButton schedule_button = null; 99 104 /** The button for viewing the collection. */ 100 105 private JButton preview_button = null; … … 186 191 Gatherer.c_man.registerBuildMonitor(build_monitor); 187 192 193 //We only need a schedule monitor for text output. No use for a progress bar! 194 195 //progress_schedule_label = new JLabel(Dictionary.get("CreatePane.Schedule_Progress")); 196 197 schedule_monitor = new GScheduleProgressMonitor(); 198 Gatherer.c_man.registerScheduleMonitor(schedule_monitor); 199 188 200 // And the simple panel 189 201 slower_panel = new JPanel(); … … 222 234 } 223 235 236 BuildSimpleButtonListener bsbl = new BuildSimpleButtonListener(); 224 237 simple_build_button = new GLIButton(Dictionary.get("CreatePane.Build_Collection"), Dictionary.get("CreatePane.Build_Collection_Tooltip")); 225 simple_build_button.addActionListener(b bl);226 238 simple_build_button.addActionListener(bsbl); 239 227 240 simple_cancel_button = new GLIButton(Dictionary.get("CreatePane.Cancel_Build"), Dictionary.get("CreatePane.Cancel_Build_Tooltip")); 228 241 simple_cancel_button.addActionListener(cbl); … … 239 252 240 253 bbl = null; 254 bsbl = null; 241 255 cbl = null; 242 256 //pbl = null; … … 350 364 sargument_configuration_panel = options_pane.buildImport(null); 351 365 sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel); 366 sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel); 352 367 } 353 368 else { … … 469 484 sargument_configuration_panel = options_pane.buildImport(null); 470 485 sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel); 486 sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel); 471 487 } 472 488 else { … … 514 530 DebugStream.println("In CreatePane::processComplete(" + event.getType() + ")..."); 515 531 if(event.getStatus() == GShell.OK) { 516 if(event.getType() == GShell.BUILD) { 532 if(event.getType() == GShell.SCHEDULE) { 533 534 processing = false; 535 build_button.setEnabled(true); 536 cancel_button.setEnabled(false); 537 preview_button.setEnabled(true); 538 //only enable preview if the collection has been built. 539 preview_button.setEnabled(Gatherer.c_man.built()); 540 simple_build_button.setEnabled(true); 541 simple_cancel_button.setEnabled(false); 542 simple_preview_button.setEnabled(Gatherer.c_man.built()); 543 int status = event.getStatus(); 544 document.setSpecialCharacter(OptionsPane.SCHEDULED); 545 options_pane.resetFileEntry(); 546 build_monitor.reset(); 547 import_monitor.reset(); 548 if(Configuration.getMode() >= THRESHOLD) { 549 control_pane.add(button_pane, BorderLayout.SOUTH); 550 card_layout.show(main_pane, CONTROL); 551 } 552 } 553 else if(event.getType() == GShell.BUILD) { 517 554 processing = false; 518 555 build_button.setEnabled(true); 519 556 cancel_button.setEnabled(false); 520 //preview_button.setEnabled(true);557 preview_button.setEnabled(true); 521 558 simple_build_button.setEnabled(true); 522 559 simple_cancel_button.setEnabled(false); … … 539 576 build_button.setEnabled(true); 540 577 // The build may have failed, but a previous index may still be in place 541 //preview_button.setEnabled(Gatherer.c_man.built());578 preview_button.setEnabled(Gatherer.c_man.built()); 542 579 543 580 simple_build_button.setEnabled(true); 544 581 simple_cancel_button.setEnabled(false); 545 //simple_preview_button.setEnabled(Gatherer.c_man.built());582 simple_preview_button.setEnabled(Gatherer.c_man.built()); 546 583 if(event.getStatus() == GShell.CANCELLED) { 547 584 document.setSpecialCharacter(OptionsPane.CANCELLED); … … 573 610 Collection current_collection = Gatherer.c_man.getCollection(); 574 611 if (current_collection != previous_collection && !Gatherer.c_man.isImporting()) { 575 this.options_pane = new OptionsPane(current_collection.import_options, current_collection.build_options );612 this.options_pane = new OptionsPane(current_collection.import_options, current_collection.build_options, current_collection.schedule_options); 576 613 if (previous_collection != null) { 577 614 // clear the log … … 589 626 sargument_configuration_panel = options_pane.buildImport(null); 590 627 sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel); 628 sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel); 591 629 sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel); 592 630 sargument_configuration_scroll.setPreferredSize(ARGUMENT_SIZE); … … 622 660 Collection collection = Gatherer.c_man.getCollection(); 623 661 String collection_name = collection.getName(); 624 if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) { 625 //Only design options have changes, and we want to be smart in the way we handle them. 626 int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired(); 627 if (rebuildTypeRequired == CollectionDesignManager.BUILDCOL) { 628 // Just run the buildcol command. 629 DebugStream.println("Just want to run buildcol.pl"); 630 prepareForBuild(); 631 Gatherer.c_man.buildCollection(isIncremental()); 632 } 633 else if (rebuildTypeRequired == CollectionDesignManager.ALL) { 634 // Do both import and buildcol 635 DebugStream.println("Want to do a complete build"); 662 663 //if button is labelled for Building 664 if(event.getActionCommand().equals(Dictionary.get("CreatePane.Build_Collection"))) { 665 666 if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) { 667 //Only design options have changes, and we want to be smart in the way we handle them. 668 int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired(); 669 if (rebuildTypeRequired == CollectionDesignManager.BUILDCOL) { 670 // Just run the buildcol command. 671 DebugStream.println("Just want to run buildcol.pl"); 672 prepareForBuild(); 673 Gatherer.c_man.buildCollection(isIncremental()); 674 } 675 else if (rebuildTypeRequired == CollectionDesignManager.ALL) { 676 // Do both import and buildcol 677 DebugStream.println("Want to do a complete build"); 678 prepareForBuild(); 679 Gatherer.c_man.importCollection(); //This starts the building process. 680 } 681 else { 682 //Nothing at all needs doing. 683 //This is bad HCI. Maybe should disable the build button in this situation? 684 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CreatePane.Minimal_Build_Not_Required")); 685 } 686 } 687 else { 688 //Do a complete build. 636 689 prepareForBuild(); 637 690 Gatherer.c_man.importCollection(); //This starts the building process. 638 } 639 else { 640 //Nothing at all needs doing. 641 //This is bad HCI. Maybe should disable the build button in this situation? 642 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CreatePane.Minimal_Build_Not_Required")); 643 } 644 } 645 else { 646 //Do a complete build. 647 prepareForBuild(); 648 Gatherer.c_man.importCollection(); //This starts the building process. 649 } 691 } 692 693 } else { //button is labelled for setting up scheduling 694 695 //this needs to be called to configure buttons... but no building is done 696 prepareForBuild(); 697 698 Gatherer.c_man.scheduleBuild(isIncremental()); 699 } 700 650 701 //Re-setting the rebuildTypeRequired is handled by CollectionManager.processComplete(GShellEvent) 651 702 } 652 703 653 704 /** 654 705 * This does some stuff that is needed before a collection can be built. … … 689 740 } 690 741 742 /** I hope this works. Wendy */ 743 private class BuildSimpleButtonListener 744 implements ActionListener { 745 /** 746 * This method checks to see what needs to be done for a build, and starts the process off. 747 * A complete build proccess is started by {@link CollectionManager.importCollection()}, which then imports and builds the collection. 748 * However, this doesn't always happen, as sometimes an incremental build will do :-) 749 * @param event An <strong>ActionEvent</strong> who, thanks to the power of object oriented programming, we don't give two hoots about. 750 * @see org.greenstone.gatherer.Gatherer 751 * @see org.greenstone.gatherer.collection.CollectionManager 752 * @see org.greenstone.gatherer.gui.BuildOptions 753 * @see org.greenstone.gatherer.shell.GShellProgressMonitor 754 */ 755 public void actionPerformed(ActionEvent event) { 756 Collection collection = Gatherer.c_man.getCollection(); 757 String collection_name = collection.getName(); 758 759 //prepareForBuild(); 760 if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) { 761 //Only design options have changes, and we want to be smart in the way we handle them. 762 int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired(); 763 if (rebuildTypeRequired == CollectionDesignManager.BUILDCOL) { 764 // Just run the buildcol command. 765 DebugStream.println("Just want to run buildcol.pl"); 766 prepareForBuild(); 767 Gatherer.c_man.buildCollection(isIncremental()); 768 } 769 else if (rebuildTypeRequired == CollectionDesignManager.ALL) { 770 // Do both import and buildcol 771 DebugStream.println("Want to do a complete build"); 772 prepareForBuild(); 773 Gatherer.c_man.importCollection(); //This starts the building process. 774 } 775 else { 776 //Nothing at all needs doing. 777 //This is bad HCI. Maybe should disable the build button in this situation? 778 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CreatePane.Minimal_Build_Not_Required")); 779 } 780 } 781 else { 782 //Do a complete build. 783 prepareForBuild(); 784 Gatherer.c_man.importCollection(); //This starts the building process. 785 } 786 787 //only schedule in SYSTEM mode - also done in EXPERT mode, but that is handled elsewhere 788 if(Configuration.getMode() == Configuration.SYSTEMS_MODE) { 789 if(Gatherer.c_man.getCollection().schedule_options.getValueEnabled("schedule")) { 790 Gatherer.c_man.getCollection().schedule_options.setValue("action",true,"add"); 791 Gatherer.c_man.getCollection().schedule_options.setValue("email",false, null); 792 Gatherer.c_man.getCollection().schedule_options.setValue("smtp",false, null); 793 Gatherer.c_man.getCollection().schedule_options.setValue("toaddr",false, null); 794 Gatherer.c_man.getCollection().schedule_options.setValue("fromaddr",false, null); 795 Gatherer.c_man.getCollection().schedule_options.setValue("frequency",false, null); 796 Gatherer.c_man.scheduleBuild(isIncremental()); 797 } else { 798 //need to turn off existing scheduling 799 Gatherer.c_man.getCollection().schedule_options.setValue("action",true,"delete"); 800 Gatherer.c_man.scheduleBuild(isIncremental()); 801 802 } 803 } 804 //Re-setting the rebuildTypeRequired is handled by CollectionManager.processComplete(GShellEvent) 805 } 806 807 /** 808 * This does some stuff that is needed before a collection can be built. 809 * For example, buttons are enabled/disabled, and certain flags are set. 810 * This is called from {@link actionPerformed(ActionEvent)} 811 */ 812 private void prepareForBuild() { 813 // First we force the build options to be updated if we haven't already. 814 tree.valueChanged(null); 815 816 // Remember that for lower thresholds the above doesn't work, so try this instead 817 if(Configuration.getMode() < THRESHOLD) { 818 options_pane.update(sargument_configuration_panel); 819 } 820 821 // Now go about building. 822 build_button.setEnabled(false); 823 cancel_button.setEnabled(true); 824 preview_button.setEnabled(false); 825 826 simple_build_button.setEnabled(false); 827 simple_cancel_button.setEnabled(true); 828 simple_preview_button.setEnabled(false); 829 830 document = options_pane.createNewLogDocument(); 831 log_textarea.setDocument(document); 832 options_pane.log_textarea.setDocument(document); 833 // Change the view. 834 processing = true; 835 if(Configuration.getMode() >= THRESHOLD) { 836 progress_pane.add(button_pane, BorderLayout.SOUTH); 837 card_layout.show(main_pane, PROGRESS); 838 } 839 // Reset the stop flag in all the process monitors, just incase. 840 ((GBuildProgressMonitor)build_monitor).reset(); 841 import_monitor.setStop(false); 842 } 843 } 691 844 845 692 846 /** This class serves as the listener for actions on the cancel button. */ 693 847 private class CancelButtonListener … … 739 893 /** The node corresponding to the importing options view. */ 740 894 private OptionTreeNode importing = null; 895 /** The node corresponding to the scheduling options view. */ 896 private OptionTreeNode scheduling = null; 741 897 /** The node corresponding to the log view. */ 742 898 private OptionTreeNode log = null; … … 761 917 importing = new OptionTreeNode(Dictionary.get("CreatePane.Import")); 762 918 importing.setToolTipText(Dictionary.get("CreatePane.Import_Tooltip")); 919 scheduling = new OptionTreeNode(Dictionary.get("CreatePane.Schedule")); 920 scheduling.setToolTipText(Dictionary.get("CreatePane.Schedule_Tooltip")); 921 763 922 log = new OptionTreeNode(Dictionary.get("CreatePane.Log")); 764 923 log.setToolTipText(Dictionary.get("CreatePane.Log_Tooltip")); … … 769 928 model.insertNodeInto(importing, options, 0); 770 929 model.insertNodeInto(building, options, 1); 771 model.insertNodeInto(log, options, 2); 930 model.insertNodeInto(scheduling, options, 2); 931 model.insertNodeInto(log, options, 3); 772 932 // Expand the root node 773 933 expandPath(new TreePath(options)); … … 810 970 right.add(scroll_pane, BorderLayout.CENTER); 811 971 //target_pane.add(previous_pane, BorderLayout.CENTER); 972 } 973 else if(node != null && node.equals(scheduling)) { 974 //build_button.setActionCommand(Dictionary.get("CreatePane.Schedule_Build")); 975 //build_button.setText(Dictionary.get("CreatePane.Schedule_Build")); 976 977 previous_pane = options_pane.buildSchedule(null); 978 scroll_pane = new JScrollPane(previous_pane); 979 right.add(scroll_pane, BorderLayout.CENTER); 812 980 } 813 981 else {
Note:
See TracChangeset
for help on using the changeset viewer.