- Timestamp:
- 2009-01-12T11:40:15+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/CreatePane.java
r18297 r18364 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; … … 61 62 import org.greenstone.gatherer.util.Utility; 62 63 64 import org.greenstone.gatherer.collection.CollectionManager; 63 65 64 66 /** This class provides a GUI view showing some statistics on your current collection, and options for building it. As the collection is built this initial view is replaced with one showing progress bars and a message log of the creation process. This log can be later accessed via the options tree located in the center of the initial pane. This class is also responsible for creating the GShellProgressMonitors that are then attatched to external shell processes, and calling the methods in the CollectionManager for actually importing and building the collection. <br><BR> … … 93 95 /** This monitor tracks the import processes progress. */ 94 96 private GShellProgressMonitor import_monitor = null; 97 /** This monitor tracks the schedule processes progress. */ 98 private GShellProgressMonitor schedule_monitor = null; 95 99 /** The button for begining the building processes. */ 96 100 private JButton build_button = null; 97 101 /** The button for stopping the building processes. */ 98 102 private JButton cancel_button = null; 103 /** The button for setting up scheduling */ 104 private JButton schedule_button = null; 99 105 /** The button for viewing the collection. */ 100 106 private JButton preview_button = null; … … 149 155 public String homepage = null; 150 156 151 152 157 /** The constructor creates important helper classes, and initializes all the components. 153 158 * @see org.greenstone.gatherer.collection.CollectionManager … … 194 199 Gatherer.c_man.registerBuildMonitor(build_monitor); 195 200 201 //We only need a schedule monitor for text output. No use for a progress bar! 202 203 //progress_schedule_label = new JLabel(Dictionary.get("CreatePane.Schedule_Progress")); 204 205 schedule_monitor = new GScheduleProgressMonitor(); 206 Gatherer.c_man.registerScheduleMonitor(schedule_monitor); 207 196 208 // And the simple panel 197 209 slower_panel = new JPanel(); … … 238 250 } 239 251 252 BuildSimpleButtonListener bsbl = new BuildSimpleButtonListener(); 240 253 simple_build_button = new GLIButton(Dictionary.get("CreatePane.Build_Collection"), Dictionary.get("CreatePane.Build_Collection_Tooltip")); 241 simple_build_button.addActionListener(b bl);242 254 simple_build_button.addActionListener(bsbl); 255 243 256 simple_cancel_button = new GLIButton(Dictionary.get("CreatePane.Cancel_Build"), Dictionary.get("CreatePane.Cancel_Build_Tooltip")); 244 257 simple_cancel_button.addActionListener(cbl); … … 255 268 256 269 bbl = null; 270 bsbl = null; 257 271 cbl = null; 258 272 //pbl = null; … … 375 389 sargument_configuration_panel = options_pane.buildImport(null); 376 390 sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel); 391 // if(CollectionManager.canDoScheduling()) { 392 // sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel); 393 // } 377 394 } 378 395 else { … … 498 515 sargument_configuration_panel = options_pane.buildImport(null); 499 516 sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel); 517 // if(CollectionManager.canDoScheduling()) { 518 // sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel); 519 //} 500 520 } 501 521 else { … … 545 565 DebugStream.println("In CreatePane::processComplete(" + event.getType() + ")..."); 546 566 if(event.getStatus() == GShell.OK) { 547 if(event.getType() == GShell.BUILD) { 567 if(event.getType() == GShell.SCHEDULE) { 568 569 processing = false; 570 build_button.setEnabled(true); 571 cancel_button.setEnabled(false); 572 //preview_button.setEnabled(true); 573 //only enable preview if the collection has been built. 574 preview_button.setEnabled(Gatherer.c_man.built()); 575 simple_build_button.setEnabled(true); 576 simple_cancel_button.setEnabled(false); 577 simple_preview_button.setEnabled(Gatherer.c_man.built()); 578 int status = event.getStatus(); 579 document.setSpecialCharacter(OptionsPane.SCHEDULED); 580 options_pane.resetFileEntry(); 581 build_monitor.reset(); 582 import_monitor.reset(); 583 if(Configuration.getMode() >= THRESHOLD) { 584 control_pane.add(button_pane, BorderLayout.SOUTH); 585 card_layout.show(main_pane, CONTROL); 586 } 587 } 588 else if(event.getType() == GShell.BUILD) { 548 589 processing = false; 549 590 build_button.setEnabled(true); 550 591 cancel_button.setEnabled(false); 551 //preview_button.setEnabled(true);592 preview_button.setEnabled(true); 552 593 simple_build_button.setEnabled(true); 553 594 simple_cancel_button.setEnabled(false); … … 570 611 build_button.setEnabled(true); 571 612 // The build may have failed, but a previous index may still be in place 572 //preview_button.setEnabled(Gatherer.c_man.built());613 preview_button.setEnabled(Gatherer.c_man.built()); 573 614 574 615 simple_build_button.setEnabled(true); 575 616 simple_cancel_button.setEnabled(false); 576 //simple_preview_button.setEnabled(Gatherer.c_man.built());617 simple_preview_button.setEnabled(Gatherer.c_man.built()); 577 618 if(event.getStatus() == GShell.CANCELLED) { 578 619 document.setSpecialCharacter(OptionsPane.CANCELLED); … … 604 645 Collection current_collection = Gatherer.c_man.getCollection(); 605 646 if (current_collection != previous_collection && !Gatherer.c_man.isImporting()) { 606 this.options_pane = new OptionsPane(current_collection.import_options, current_collection.build_options );647 this.options_pane = new OptionsPane(current_collection.import_options, current_collection.build_options, current_collection.schedule_options); 607 648 if (previous_collection != null) { 608 649 // clear the log … … 620 661 sargument_configuration_panel = options_pane.buildImport(null); 621 662 sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel); 663 //if(CollectionManager.canDoScheduling()) { 664 //sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel); 665 //} 622 666 sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel); 623 667 sargument_configuration_scroll.setComponentOrientation(Dictionary.getOrientation()); … … 654 698 Collection collection = Gatherer.c_man.getCollection(); 655 699 String collection_name = collection.getName(); 656 if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) { 657 //Only design options have changes, and we want to be smart in the way we handle them. 658 int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired(); 659 if (rebuildTypeRequired == CollectionDesignManager.BUILDCOL) { 660 // Just run the buildcol command. 661 DebugStream.println("Just want to run buildcol.pl"); 662 prepareForBuild(); 663 Gatherer.c_man.buildCollection(isIncremental()); 700 701 //if button is labelled for Building 702 if(event.getActionCommand().equals(Dictionary.get("CreatePane.Build_Collection"))) { 703 704 if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) { 705 //Only design options have changes, and we want to be smart in the way we handle them. 706 int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired(); 707 if (rebuildTypeRequired == CollectionDesignManager.BUILDCOL) { 708 // Just run the buildcol command. 709 DebugStream.println("Just want to run buildcol.pl"); 710 prepareForBuild(); 711 Gatherer.c_man.buildCollection(isIncremental()); 712 } 713 else if (rebuildTypeRequired == CollectionDesignManager.ALL) { 714 // Do both import and buildcol 715 DebugStream.println("Want to do a complete build"); 716 prepareForBuild(); 717 Gatherer.c_man.importCollection(); //This starts the building process. 718 } 719 else { 720 //Nothing at all needs doing. 721 //This is bad HCI. Maybe should disable the build button in this situation? 722 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CreatePane.Minimal_Build_Not_Required")); 723 } 664 724 } 665 else if (rebuildTypeRequired == CollectionDesignManager.ALL) { 666 // Do both import and buildcol 667 DebugStream.println("Want to do a complete build"); 725 else { 726 //Do a complete build. 668 727 prepareForBuild(); 669 728 Gatherer.c_man.importCollection(); //This starts the building process. 670 } 671 else { 672 //Nothing at all needs doing. 673 //This is bad HCI. Maybe should disable the build button in this situation? 674 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CreatePane.Minimal_Build_Not_Required")); 675 } 676 } 677 else { 678 //Do a complete build. 679 prepareForBuild(); 680 Gatherer.c_man.importCollection(); //This starts the building process. 681 } 729 } 730 731 } else { //button is labelled for setting up scheduling 732 733 //this needs to be called to configure buttons... but no building is done 734 prepareForBuild(); 735 736 Gatherer.c_man.scheduleBuild(isIncremental()); 737 } 738 682 739 //Re-setting the rebuildTypeRequired is handled by CollectionManager.processComplete(GShellEvent) 683 740 } 684 741 685 742 /** 686 743 * This does some stuff that is needed before a collection can be built. … … 721 778 } 722 779 780 /** I hope this works. Wendy */ 781 private class BuildSimpleButtonListener 782 implements ActionListener { 783 /** 784 * This method checks to see what needs to be done for a build, and starts the process off. 785 * A complete build proccess is started by {@link CollectionManager.importCollection()}, which then imports and builds the collection. 786 * However, this doesn't always happen, as sometimes an incremental build will do :-) 787 * @param event An <strong>ActionEvent</strong> who, thanks to the power of object oriented programming, we don't give two hoots about. 788 * @see org.greenstone.gatherer.Gatherer 789 * @see org.greenstone.gatherer.collection.CollectionManager 790 * @see org.greenstone.gatherer.gui.BuildOptions 791 * @see org.greenstone.gatherer.shell.GShellProgressMonitor 792 */ 793 public void actionPerformed(ActionEvent event) { 794 Collection collection = Gatherer.c_man.getCollection(); 795 String collection_name = collection.getName(); 796 797 //prepareForBuild(); 798 if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) { 799 //Only design options have changes, and we want to be smart in the way we handle them. 800 int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired(); 801 if (rebuildTypeRequired == CollectionDesignManager.BUILDCOL) { 802 // Just run the buildcol command. 803 DebugStream.println("Just want to run buildcol.pl"); 804 prepareForBuild(); 805 Gatherer.c_man.buildCollection(isIncremental()); 806 } 807 else if (rebuildTypeRequired == CollectionDesignManager.ALL) { 808 // Do both import and buildcol 809 DebugStream.println("Want to do a complete build"); 810 prepareForBuild(); 811 Gatherer.c_man.importCollection(); //This starts the building process. 812 } 813 else { 814 //Nothing at all needs doing. 815 //This is bad HCI. Maybe should disable the build button in this situation? 816 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CreatePane.Minimal_Build_Not_Required")); 817 } 818 } 819 else { 820 //Do a complete build. 821 prepareForBuild(); 822 Gatherer.c_man.importCollection(); //This starts the building process. 823 } 824 825 // have commented this out for now - scheduling currently not 826 // available except in expert mode 827 //only schedule in SYSTEM mode - also done in EXPERT mode, but that is handled elsewhere 828 /* if(Configuration.getMode() == Configuration.SYSTEMS_MODE) { 829 if(Gatherer.c_man.getCollection().schedule_options.getValueEnabled("schedule")) { 830 Gatherer.c_man.getCollection().schedule_options.setValue("action",true,"add"); 831 Gatherer.c_man.getCollection().schedule_options.setValue("email",false, null); 832 Gatherer.c_man.getCollection().schedule_options.setValue("smtp",false, null); 833 Gatherer.c_man.getCollection().schedule_options.setValue("toaddr",false, null); 834 Gatherer.c_man.getCollection().schedule_options.setValue("fromaddr",false, null); 835 Gatherer.c_man.getCollection().schedule_options.setValue("frequency",false, null); 836 Gatherer.c_man.scheduleBuild(isIncremental()); 837 } else { 838 //need to turn off existing scheduling 839 Gatherer.c_man.getCollection().schedule_options.setValue("action",true,"delete"); 840 Gatherer.c_man.scheduleBuild(isIncremental()); 841 842 } 843 } 844 */ 845 //Re-setting the rebuildTypeRequired is handled by CollectionManager.processComplete(GShellEvent) 846 } 847 848 /** 849 * This does some stuff that is needed before a collection can be built. 850 * For example, buttons are enabled/disabled, and certain flags are set. 851 * This is called from {@link actionPerformed(ActionEvent)} 852 */ 853 private void prepareForBuild() { 854 // First we force the build options to be updated if we haven't already. 855 tree.valueChanged(null); 856 857 // Remember that for lower thresholds the above doesn't work, so try this instead 858 if(Configuration.getMode() < THRESHOLD) { 859 options_pane.update(sargument_configuration_panel); 860 } 861 862 // Now go about building. 863 build_button.setEnabled(false); 864 cancel_button.setEnabled(true); 865 preview_button.setEnabled(false); 866 867 simple_build_button.setEnabled(false); 868 simple_cancel_button.setEnabled(true); 869 simple_preview_button.setEnabled(false); 870 871 document = options_pane.createNewLogDocument(); 872 log_textarea.setDocument(document); 873 options_pane.log_textarea.setDocument(document); 874 // Change the view. 875 processing = true; 876 if(Configuration.getMode() >= THRESHOLD) { 877 progress_pane.add(button_pane, BorderLayout.SOUTH); 878 card_layout.show(main_pane, PROGRESS); 879 } 880 // Reset the stop flag in all the process monitors, just incase. 881 ((GBuildProgressMonitor)build_monitor).reset(); 882 import_monitor.setStop(false); 883 } 884 } 723 885 886 724 887 /** This class serves as the listener for actions on the cancel button. */ 725 888 private class CancelButtonListener … … 771 934 /** The node corresponding to the importing options view. */ 772 935 private OptionTreeNode importing = null; 936 /** The node corresponding to the scheduling options view. */ 937 private OptionTreeNode scheduling = null; 773 938 /** The node corresponding to the log view. */ 774 939 private OptionTreeNode log = null; … … 793 958 importing = new OptionTreeNode(Dictionary.get("CreatePane.Import")); 794 959 importing.setToolTipText(Dictionary.get("CreatePane.Import_Tooltip")); 960 scheduling = new OptionTreeNode(Dictionary.get("CreatePane.Schedule")); 961 scheduling.setToolTipText(Dictionary.get("CreatePane.Schedule_Tooltip")); 962 795 963 log = new OptionTreeNode(Dictionary.get("CreatePane.Log")); 796 964 log.setToolTipText(Dictionary.get("CreatePane.Log_Tooltip")); … … 801 969 model.insertNodeInto(importing, options, 0); 802 970 model.insertNodeInto(building, options, 1); 803 model.insertNodeInto(log, options, 2); 971 model.insertNodeInto(scheduling, options, 2); 972 model.insertNodeInto(log, options, 3); 804 973 // Expand the root node 805 974 expandPath(new TreePath(options)); … … 831 1000 scroll_pane = null; 832 1001 } 1002 if(node != null && node.equals(log)) { 1003 build_button.setActionCommand(Dictionary.get("CreatePane.Build_Collection")); 1004 build_button.setText(Dictionary.get("CreatePane.Build_Collection")); 1005 } 833 1006 if(node != null && node.equals(building)) { 1007 build_button.setActionCommand(Dictionary.get("CreatePane.Build_Collection")); 1008 build_button.setText(Dictionary.get("CreatePane.Build_Collection")); 1009 1010 834 1011 previous_pane = options_pane.buildBuild(null); 835 1012 scroll_pane = new JScrollPane(previous_pane); … … 838 1015 } 839 1016 else if(node != null && node.equals(importing)) { 1017 build_button.setActionCommand(Dictionary.get("CreatePane.Build_Collection")); 1018 build_button.setText(Dictionary.get("CreatePane.Build_Collection")); 1019 840 1020 previous_pane = options_pane.buildImport(null); 841 1021 scroll_pane = new JScrollPane(previous_pane); 842 1022 right.add(scroll_pane, BorderLayout.CENTER); 843 1023 //target_pane.add(previous_pane, BorderLayout.CENTER); 1024 } 1025 else if(node != null && node.equals(scheduling) && CollectionManager.canDoScheduling()) { 1026 build_button.setActionCommand(Dictionary.get("CreatePane.Schedule_Build")); 1027 build_button.setText(Dictionary.get("CreatePane.Schedule_Build")); 1028 1029 previous_pane = options_pane.buildSchedule(null); 1030 scroll_pane = new JScrollPane(previous_pane); 1031 right.add(scroll_pane, BorderLayout.CENTER); 844 1032 } 845 1033 else {
Note:
See TracChangeset
for help on using the changeset viewer.