Ignore:
Timestamp:
2009-01-12T11:40:15+13:00 (15 years ago)
Author:
kjdon
Message:

updated the rtl-gli branch with files from trunk. Result of a merge 14807:18318, and fixed some conflicts. I think this is the last commit following merging the files. Haven't tried to compile yet... here goes...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/CreatePane.java

    r18297 r18364  
    5353import org.greenstone.gatherer.shell.GBuildProgressMonitor;
    5454import org.greenstone.gatherer.shell.GImportProgressMonitor;
     55import org.greenstone.gatherer.shell.GScheduleProgressMonitor;
    5556import org.greenstone.gatherer.shell.GShell;
    5657import org.greenstone.gatherer.shell.GShellEvent;
     
    6162import org.greenstone.gatherer.util.Utility;
    6263
     64import org.greenstone.gatherer.collection.CollectionManager;
    6365
    6466/** 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>
     
    9395    /** This monitor tracks the import processes progress. */
    9496    private GShellProgressMonitor import_monitor = null;
     97    /** This monitor tracks the schedule processes progress. */
     98    private GShellProgressMonitor schedule_monitor = null;
    9599    /** The button for begining the building processes. */
    96100    private JButton build_button = null;
    97101    /** The button for stopping the building processes. */
    98102    private JButton cancel_button = null;
     103    /** The button for setting up scheduling */
     104    private JButton schedule_button = null;
    99105    /** The button for viewing the collection. */
    100106    private JButton preview_button = null;
     
    149155    public String homepage = null;
    150156
    151 
    152157    /** The constructor creates important helper classes, and initializes all the components.
    153158     * @see org.greenstone.gatherer.collection.CollectionManager
     
    194199    Gatherer.c_man.registerBuildMonitor(build_monitor);
    195200
     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
    196208    // And the simple panel
    197209    slower_panel = new JPanel();
     
    238250    }
    239251   
     252    BuildSimpleButtonListener bsbl = new BuildSimpleButtonListener();
    240253    simple_build_button = new GLIButton(Dictionary.get("CreatePane.Build_Collection"), Dictionary.get("CreatePane.Build_Collection_Tooltip"));
    241     simple_build_button.addActionListener(bbl);
    242    
     254    simple_build_button.addActionListener(bsbl);
     255
    243256    simple_cancel_button = new GLIButton(Dictionary.get("CreatePane.Cancel_Build"), Dictionary.get("CreatePane.Cancel_Build_Tooltip"));
    244257    simple_cancel_button.addActionListener(cbl);
     
    255268   
    256269    bbl = null;
     270    bsbl = null;
    257271    cbl = null;
    258272    //pbl = null;
     
    375389        sargument_configuration_panel = options_pane.buildImport(null);
    376390        sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel);
     391        // if(CollectionManager.canDoScheduling()) {
     392        //  sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel);
     393        // }
    377394    }
    378395    else {
     
    498515        sargument_configuration_panel = options_pane.buildImport(null);
    499516        sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel);
     517        //  if(CollectionManager.canDoScheduling()) {
     518        //  sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel);
     519        //}
    500520        }
    501521        else {
     
    545565    DebugStream.println("In CreatePane::processComplete(" + event.getType() + ")...");
    546566    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) {
    548589        processing = false;
    549590        build_button.setEnabled(true);
    550591        cancel_button.setEnabled(false);
    551         //preview_button.setEnabled(true);
     592        preview_button.setEnabled(true);
    552593        simple_build_button.setEnabled(true);
    553594        simple_cancel_button.setEnabled(false);
     
    570611        build_button.setEnabled(true);
    571612        // 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());
    573614
    574615        simple_build_button.setEnabled(true);
    575616        simple_cancel_button.setEnabled(false);
    576         //simple_preview_button.setEnabled(Gatherer.c_man.built());
     617        simple_preview_button.setEnabled(Gatherer.c_man.built());
    577618        if(event.getStatus() == GShell.CANCELLED) {
    578619        document.setSpecialCharacter(OptionsPane.CANCELLED);
     
    604645    Collection current_collection = Gatherer.c_man.getCollection();
    605646    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);
    607648        if (previous_collection != null) {
    608649        // clear the log
     
    620661        sargument_configuration_panel = options_pane.buildImport(null);
    621662        sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel);
     663        //if(CollectionManager.canDoScheduling()) {
     664        //sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel);
     665        //}
    622666        sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel);
    623667            sargument_configuration_scroll.setComponentOrientation(Dictionary.getOrientation());
     
    654698        Collection collection = Gatherer.c_man.getCollection();
    655699        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            }
    664724        }
    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.
    668727            prepareForBuild();
    669728            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       
    682739        //Re-setting the rebuildTypeRequired is handled by CollectionManager.processComplete(GShellEvent)
    683740    }
    684 
     741       
    685742    /**
    686743     * This does some stuff that is needed before a collection can be built.
     
    721778    }
    722779   
     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    }
    723885   
     886
    724887    /** This class serves as the listener for actions on the cancel button. */
    725888    private class CancelButtonListener
     
    771934    /** The node corresponding to the importing options view. */
    772935    private OptionTreeNode importing = null;
     936    /** The node corresponding to the scheduling options view. */
     937    private OptionTreeNode scheduling = null;
    773938    /** The node corresponding to the log view. */
    774939    private OptionTreeNode log       = null;
     
    793958        importing = new OptionTreeNode(Dictionary.get("CreatePane.Import"));
    794959        importing.setToolTipText(Dictionary.get("CreatePane.Import_Tooltip"));
     960        scheduling = new OptionTreeNode(Dictionary.get("CreatePane.Schedule"));
     961        scheduling.setToolTipText(Dictionary.get("CreatePane.Schedule_Tooltip"));
     962
    795963        log = new OptionTreeNode(Dictionary.get("CreatePane.Log"));
    796964        log.setToolTipText(Dictionary.get("CreatePane.Log_Tooltip"));
     
    801969        model.insertNodeInto(importing, options, 0);
    802970        model.insertNodeInto(building, options, 1);
    803         model.insertNodeInto(log, options, 2);
     971        model.insertNodeInto(scheduling, options, 2);
     972        model.insertNodeInto(log, options, 3);
    804973        // Expand the root node
    805974        expandPath(new TreePath(options));
     
    8311000        scroll_pane = null;
    8321001        }
     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        }
    8331006        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
    8341011        previous_pane = options_pane.buildBuild(null);
    8351012        scroll_pane = new JScrollPane(previous_pane);
     
    8381015        }
    8391016        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
    8401020        previous_pane = options_pane.buildImport(null);
    8411021        scroll_pane = new JScrollPane(previous_pane);
    8421022        right.add(scroll_pane, BorderLayout.CENTER);
    8431023        //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);
    8441032        }
    8451033        else {
Note: See TracChangeset for help on using the changeset viewer.