Changeset 10237


Ignore:
Timestamp:
2005-07-13T11:12:11+12:00 (19 years ago)
Author:
mdewsnip
Message:

New code for "incremental" building, by Matthew Whyte.

I've only had time to look at this briefly; I've fixed a few obvious problems but I imagine this will be pretty flaky for a while.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/ArgumentConfiguration.java

    r9642 r10237  
    129129    cancel.addActionListener(this);
    130130    ok.addActionListener(this);
     131    ok.addActionListener(CollectionDesignManager.all_change_listener);
    131132
    132133    // Layout
  • trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java

    r10011 r10237  
    582582        Dictionary.registerText(instructions, "CDM.ClassifierManager.Instructions");
    583583
    584         ClassifierComboboxListener ccl = new ClassifierComboboxListener();
     584        ClassifierComboboxListener ccl = new ClassifierComboboxListener();
    585585        classifier = new GComboBox(getAvailable());
    586586        classifier.setBackgroundNonSelectionColor(Configuration.getColor("coloring.editable_background", false));
     
    630630        // Listeners
    631631        add.addActionListener(new AddListener());
    632         classifier.addItemListener(ccl);
     632        add.addActionListener(CollectionDesignManager.buildcol_change_listener);
     633        classifier.addItemListener(ccl);
    633634        configure.addActionListener(new ConfigureListener());
     635        configure.addActionListener(CollectionDesignManager.buildcol_change_listener);
    634636        remove.addActionListener(new RemoveListener());
     637        remove.addActionListener(CollectionDesignManager.buildcol_change_listener);
    635638        classifier_list.addMouseListener(new ClickListener());
    636639        classifier_list.addListSelectionListener(new ListListener());
    637         ccl = null;
     640        ccl = null;
    638641
    639642        MoveListener ml = new MoveListener();
    640643        //move_bottom_button.addActionListener(ml);
    641644        move_down_button.addActionListener(ml);
     645        move_down_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    642646        //move_top_button.addActionListener(ml);
    643647        move_up_button.addActionListener(ml);
     648        move_up_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    644649
    645650        // Layout
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java

    r9640 r10237  
    5050    /** This listener listens for any event on any of the components in any of the sub-views, and marks the collection as needing saving if any change occurs. */
    5151    static public CDMChangeListener change_listener;
     52    /** These listeners listen to changes in the Design mode so as to allow incremental building */
     53    static public DesignChangeListener all_change_listener;
     54    static public DesignChangeListener buildcol_change_listener;
     55    static public DesignChangeListener collect_cfg_change_listener;
    5256    /** A list of classifiers to use at build time. */
    5357    static public ClassifierManager classifier_manager;
     
    7882    /** The text translation manager. */
    7983    static public TranslationView translation_view;
     84    /** These mark what needs to happen when building a collection where ONLY design options have been changed.
     85        The build requirements of the higher numbers must include doing everything from the lower numbers. */
     86    static final public int ALL = 3;
     87    static final public int BUILDCOL = 2;
     88    static final public int UPDATE_COLLECT_CFG = 1;
     89    static final public int NOTHING = 0;
     90    static private int rebuildTypeRequired = NOTHING; //Rebuild type required if only design options have changed
     91    static protected boolean update_collect_cfg_required = false;
     92
    8093    /** Constructor. Loads a certain collection configuration file, which is parsed into a DOM. This model is then registered with the command information managers, each of whom knows how to, and provides controls to, alter certain commands.
    8194     * @param collect_config_file the File representing a collection configuration file either in its text (G2) or xml (G3) form
     
    8497    DebugStream.println("Initializaing CollectionDesignModule.");
    8598    change_listener = new CDMChangeListener();
     99    all_change_listener = new DesignChangeListener(ALL);
     100    buildcol_change_listener = new DesignChangeListener(BUILDCOL);
     101    collect_cfg_change_listener = new DesignChangeListener(UPDATE_COLLECT_CFG);
    86102    // Parse the collection configuration
    87103    collect_config = new CollectionConfiguration(collect_config_file);
     
    199215     */
    200216    public void save() {
     217    System.err.println("Config file saved. The level of processing needed is: " + CollectionDesignManager.getRebuildTypeRequired()); //debug
    201218    // Release collection as necessary
    202219    String collection_name = Gatherer.c_man.getCollection().getName();
    203220    boolean collection_released = false;
    204     boolean formats_changed = format_manager.formatsChanged();
    205 
    206     if (formats_changed && Gatherer.c_man.built() && LocalLibraryServer.isRunning() == true) {
     221
     222    if (update_collect_cfg_required && Gatherer.c_man.built() && LocalLibraryServer.isRunning() == true) {
    207223        // Release the collection
    208224        LocalLibraryServer.releaseCollection(collection_name);
     
    213229    collect_config.save();
    214230
    215     if (Gatherer.isGsdlRemote) {
    216         if (formats_changed && Gatherer.c_man.built()) {
    217         // upload etc/collect.cfg to server to reflect changes
    218         Utility.zipup(Gatherer.getCollectDirectoryPath(), collection_name, Utility.CONFIG_FILE, null, "", "");
    219         GathererApplet.upload_url_zip(collection_name, "etc", "", null);
    220         }
    221     }
    222 
    223     // Readd collection
     231    if (update_collect_cfg_required && Gatherer.c_man.built() && Gatherer.isGsdlRemote) {
     232        //If the GLI is running as an applet, and Format Features or Cross-Collection Searching have changed,
     233        //upload etc/collect.cfg to the server to immediately reflect these changes.
     234        Utility.zipup(Gatherer.getCollectDirectoryPath(), collection_name, Utility.CONFIG_FILE, null, "", "");
     235        GathererApplet.upload_url_zip(collection_name, "etc", "", null);
     236    }
     237   
     238    // Read collection
    224239    if (collection_released) {
    225240        // Now re-add collection to server to force format commands to be processed
     
    227242    }
    228243
    229     if (formats_changed) {
     244    if (update_collect_cfg_required) {
    230245        // Unset formats changed
    231         format_manager.setFormatsChanged(false);
     246        update_collect_cfg_required = false;
    232247    }
    233248    }
     
    263278    }
    264279
    265 
     280    public static int getRebuildTypeRequired() {
     281    return rebuildTypeRequired;
     282    }
     283    public static void resetRebuildTypeRequired() {
     284    setRebuildTypeRequired(NOTHING);
     285    }
     286    public static void setRebuildTypeRequired(int number) {
     287    rebuildTypeRequired = number;
     288    }
     289
     290    /**
     291     * What exactly does this do?
     292     */
    266293    private class CDMChangeListener
    267294    implements ActionListener, DocumentListener {
    268295
     296    /** Gives notification that an event has happened */
    269297    public void actionPerformed(ActionEvent event) {
    270298        Gatherer.c_man.getCollection().setSaved(false);
  • trunk/gli/src/org/greenstone/gatherer/cdm/FormatManager.java

    r9440 r10237  
    6464    static final private String INVISIBLE_DEFAULT_FORMAT = "";
    6565
    66     /** This flag is set if some change has occured to the format commands. When a collection has been built for previewing, and the greenstone local library server is used, then we have to send commands to remove then add the new collection. */
    67     private boolean formats_changed = false;
    6866    /** The controls used to edit the format commands. */
    6967    private Control controls = null;
     
    106104        add(root, format, target_node);
    107105        Gatherer.c_man.configurationChanged();
    108         formats_changed = true;
    109106    }
    110107    }
     
    115112        controls = null;
    116113    }
    117     }
    118 
    119     /** Have the formats changed since the last save. */
    120     public boolean formatsChanged() {
    121     return formats_changed;
    122114    }
    123115
     
    160152    remove(format);
    161153    Gatherer.c_man.configurationChanged();
    162     formats_changed = true;
    163     }
    164 
    165     /** Set the state of the formats changed flag.
    166      * @param state the new state as a boolean
    167      */
    168     public void setFormatsChanged(boolean state) {
    169     formats_changed = state;
    170154    }
    171155
     
    344328        // Connect
    345329        add_button.addActionListener(new AddListener());
     330        add_button.addActionListener(CollectionDesignManager.collect_cfg_change_listener);
    346331        insert_button.addActionListener(new InsertListener());
     332        insert_button.addActionListener(CollectionDesignManager.collect_cfg_change_listener);
    347333        remove_button.addActionListener(new RemoveListener());
     334        remove_button.addActionListener(CollectionDesignManager.collect_cfg_change_listener);
    348335        replace_button.addActionListener(new ReplaceListener());
     336        replace_button.addActionListener(CollectionDesignManager.collect_cfg_change_listener);
    349337        enabled_checkbox.addActionListener(new EnabledListener());
     338        enabled_checkbox.addActionListener(CollectionDesignManager.collect_cfg_change_listener);
    350339        feature_combobox.addActionListener(new FeatureListener());
    351340        part_combobox.addActionListener(new PartListener());
     
    425414        // This is only necessary if the components have been realized
    426415        if(ready) {
    427         formats_changed = false;
    428416        model.refresh();
    429417        feature_model = buildFeatureModel();
  • trunk/gli/src/org/greenstone/gatherer/cdm/GeneralManager.java

    r9864 r10237  
    266266        browse_listener = null;
    267267        public_checkbox.addActionListener(CollectionDesignManager.change_listener);
     268        public_checkbox.addActionListener(CollectionDesignManager.buildcol_change_listener);
    268269        creator_emailfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
     270        creator_emailfield.getDocument().addDocumentListener(CollectionDesignManager.buildcol_change_listener);
    269271        description_textarea.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
     272        description_textarea.getDocument().addDocumentListener(CollectionDesignManager.buildcol_change_listener);
    270273        icon_textfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
     274        icon_textfield.getDocument().addDocumentListener(CollectionDesignManager.buildcol_change_listener);
    271275        maintainer_emailfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
     276        maintainer_emailfield.getDocument().addDocumentListener(CollectionDesignManager.buildcol_change_listener);
    272277        name_textfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
    273278        name_textfield.getDocument().addDocumentListener(new CollectionTitleUpdater());
     279        name_textfield.getDocument().addDocumentListener(CollectionDesignManager.buildcol_change_listener);
    274280        small_icon_textfield.getDocument().addDocumentListener(CollectionDesignManager.change_listener);
     281        small_icon_textfield.getDocument().addDocumentListener(CollectionDesignManager.buildcol_change_listener);
     282        //Note: unfortunately just loading the General Design panel fires the buildcol_change_listener (even if nothing is changed).
    275283
    276284        // Layout
  • trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java

    r10011 r10237  
    626626        // Listeners
    627627        add_button.addActionListener(new AddListener());
     628        add_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    628629        move_down_button.addActionListener(new MoveListener(false));
     630        move_down_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    629631        move_up_button.addActionListener(new MoveListener(true));
     632        move_up_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    630633        remove_button.addActionListener(new RemoveListener());
     634        remove_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    631635        replace_button.addActionListener(new ReplaceListener());
     636        replace_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    632637        set_default_button.addActionListener(new SetDefaultListener());
     638        set_default_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    633639        name_textfield.getDocument().addDocumentListener(new NameListener());
    634640        level_combobox.addItemListener(new LevelListener());
  • trunk/gli/src/org/greenstone/gatherer/cdm/LanguageManager.java

    r10011 r10237  
    351351        // Set up and connect listeners.
    352352        add_button.addActionListener(new AddListener());
     353        add_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    353354        move_down_button.addActionListener(new MoveListener(false));
     355        move_down_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    354356        move_up_button.addActionListener(new MoveListener(true));
     357        move_up_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    355358        remove_button.addActionListener(new RemoveListener());
     359        remove_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    356360        language_combobox.addActionListener(new SelectorListener());
    357361        set_default_button.addActionListener(new SetDefaultListener());
     362        set_default_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    358363        selected_languages_list.addListSelectionListener(new ListListener());
    359364
  • trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java

    r10079 r10237  
    794794
    795795        // Listeners
    796         add.addActionListener(new AddListener());
     796        add.addActionListener(new AddListener()); //all_change_listener is listening to the ArgumentConfiguration
    797797        configure.addActionListener(new ConfigureListener());
    798798        MoveListener ml = new MoveListener();
    799799        //move_bottom_button.addActionListener(ml);
    800800        move_down_button.addActionListener(ml);
     801        move_down_button.addActionListener(CollectionDesignManager.all_change_listener);
    801802        //move_top_button.addActionListener(ml);
    802803        move_up_button.addActionListener(ml);
     804        move_up_button.addActionListener(CollectionDesignManager.all_change_listener);
    803805        plugin.addItemListener(picl);
    804806        remove.addActionListener(new RemoveListener());
     807        remove.addActionListener(CollectionDesignManager.all_change_listener);
    805808        plugin_list.addMouseListener(new ClickListener());
    806809        plugin_list.addListSelectionListener(new ListListener());
  • trunk/gli/src/org/greenstone/gatherer/cdm/SearchTypeManager.java

    r10011 r10237  
    268268        // Connection
    269269        add_button.addActionListener(new AddActionListener());
     270        add_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    270271        build_type_combobox.addActionListener(new BuildTypeActionListener());
     272        build_type_combobox.addActionListener(CollectionDesignManager.buildcol_change_listener);
    271273        current_search_types_list.addListSelectionListener(new CurrentSearchTypesListSelectionListener());
    272274        enable_advanced_searches_checkbox.addActionListener(new EnableAdvancedSearchesActionListener());
     275        enable_advanced_searches_checkbox.addActionListener(CollectionDesignManager.buildcol_change_listener);
    273276        move_up_button.addActionListener(new MoveListener(true));
     277        move_up_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    274278        move_down_button.addActionListener(new MoveListener(false));
     279        move_down_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    275280        remove_button.addActionListener(new RemoveActionListener());
     281        remove_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    276282        SearchTypesActionDocumentListener stadl = new SearchTypesActionDocumentListener();
    277283        search_type_combobox.addActionListener(stadl);
     284        search_type_combobox.addActionListener(CollectionDesignManager.buildcol_change_listener);
    278285        ((JTextField)search_type_combobox.getEditor().getEditorComponent()).getDocument().addDocumentListener(stadl);
    279286
  • trunk/gli/src/org/greenstone/gatherer/cdm/SubcollectionIndexManager.java

    r10011 r10237  
    314314        // Listeners
    315315        add_button.addActionListener(new AddListener());
     316        add_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    316317        move_down_button.addActionListener(new MoveListener(false));
     318        move_down_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    317319        move_up_button.addActionListener(new MoveListener(true));
     320        move_up_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    318321        remove_button.addActionListener(new RemoveListener());
     322        remove_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    319323        replace_button.addActionListener(new ReplaceListener());
     324        replace_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    320325        set_default_button.addActionListener(new SetDefaultListener());
     326        set_default_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    321327        subcollection_index_name_textfield.getDocument().addDocumentListener(new NameListener());
    322328        subcollection_index_list.addListSelectionListener(new SubcollectionIndexListListener());
  • trunk/gli/src/org/greenstone/gatherer/cdm/SubcollectionManager.java

    r9161 r10237  
    277277        SubCollectionChangeListener cl = new SubCollectionChangeListener();
    278278        add_button.addActionListener(new AddSubCollectionListener());
     279        add_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    279280        remove_button.addActionListener(new RemoveSubCollectionListener());
     281        remove_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    280282        update_button.addActionListener(new UpdateSubCollectionListener());
     283        update_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    281284        exclude_button.addActionListener(cl);
    282285        include_button.addActionListener(cl);
  • trunk/gli/src/org/greenstone/gatherer/cdm/SuperCollectionManager.java

    r9045 r10237  
    5353    private DOMProxyListModel model = null;
    5454    private String current_coll_name = null;
    55 
     55    private boolean superCollectionChanged = false;
    5656
    5757    public SuperCollectionManager(Element supercollections_element) {
     
    157157
    158158    public void loseFocus() {
     159        CollectionDesignManager.collect_cfg_change_listener.maybeSetRebuildRequired(); // !! TO DO: This is crap
    159160        int super_collections_count = 0;
    160161        // Retrieve the current supercollections
  • trunk/gli/src/org/greenstone/gatherer/cdm/TranslationView.java

    r8243 r10237  
    270270        // Connection
    271271        add_button.addActionListener(new AddListener());
     272        add_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    272273        remove_button.addActionListener(new RemoveListener());
     274        remove_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    273275        replace_button.addActionListener(new ReplaceListener());
     276        replace_button.addActionListener(CollectionDesignManager.buildcol_change_listener);
    274277        language_combobox.addActionListener(new LanguageActionListener());
    275278        translation_area.getDocument().addDocumentListener(new TranslationDocumentListener());
  • trunk/gli/src/org/greenstone/gatherer/collection/Collection.java

    r10006 r10237  
    6868    private boolean saved = false;
    6969    /*<i>true</i> if the currently loaded collection has had files added since its last build */
    70     private boolean filesChanged = true;
     70    private boolean filesChanged = false;
    7171    /*<i>true</i> if the currently loaded collection has had metadata added since its last build */
    72     private boolean metadataChanged = true;
     72    private boolean metadataChanged = false;
    7373    /** The document around which this collection class is based. */
    7474    private Document document;
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r10232 r10237  
    133133     * @see org.greenstone.gatherer.util.Utility
    134134     */
    135     private void buildCollection() {
     135    public void buildCollection() {
    136136    DebugStream.println("CollectionManager.buildCollection()");
    137137    building = true;
     
    669669    command_parts_list.add(collection.getName());
    670670
    671     // Run the buildcol.pl command
     671    // Run the import.pl command
    672672    String[] command_parts = (String[]) command_parts_list.toArray(new String[0]);
    673673    GShell shell = new GShell(command_parts, GShell.IMPORT, BUILDING, this, import_monitor, GShell.GSHELL_IMPORT);
     
    992992        collection_built_warning_dialog.dispose();
    993993        collection_built_warning_dialog = null;
     994
     995        //Set nothing as needing rebuilding, as a build has just finished :-)
     996        CollectionDesignManager.resetRebuildTypeRequired();
    994997        }
    995998        else {
  • trunk/gli/src/org/greenstone/gatherer/gui/CreatePane.java

    r9166 r10237  
    4444import javax.swing.text.*;
    4545import javax.swing.tree.*;
     46import org.greenstone.gatherer.DebugStream;
    4647import org.greenstone.gatherer.Configuration;
    4748import org.greenstone.gatherer.Dictionary;
    4849import org.greenstone.gatherer.Gatherer;
     50import org.greenstone.gatherer.GathererApplet;
    4951import org.greenstone.gatherer.cdm.SearchTypeManager;
     52import org.greenstone.gatherer.cdm.CollectionDesignManager;
    5053import org.greenstone.gatherer.collection.Collection;
     54import org.greenstone.gatherer.util.Utility;
    5155import org.greenstone.gatherer.shell.GBasicProgressMonitor;
    5256import org.greenstone.gatherer.shell.GBuildProgressMonitor;
     
    99103    private JButton simple_cancel_button;
    100104    private JButton simple_preview_button;
     105    /** The radio buttons for chnaging the build type (incremental/full) */
     106    private JRadioButton full_build_radio_button;
     107    private JRadioButton incremental_build_radio_button;
     108    private JRadioButton sfull_build_radio_button;
     109    private JRadioButton sincremental_build_radio_button;
    101110    /** The label displaying the number of documents in this collection. */
    102111    private JLabel document_count = null;
     
    187196    sinner_panel = new JPanel();
    188197
     198    //Radio buttons
     199    incremental_build_radio_button = new JRadioButton();
     200    Dictionary.registerBoth(incremental_build_radio_button, "CreatePane.Incremental_Build", "CreatePane.Incremental_Build_Tooltip");
     201    full_build_radio_button = new JRadioButton();
     202    Dictionary.registerBoth(full_build_radio_button, "CreatePane.Full_Build", "CreatePane.Full_Build_Tooltip");
     203    sincremental_build_radio_button = new JRadioButton();
     204    Dictionary.registerBoth(sincremental_build_radio_button, "CreatePane.Incremental_Build", "CreatePane.Incremental_Build_Tooltip");
     205    sfull_build_radio_button = new JRadioButton();
     206    Dictionary.registerBoth(sfull_build_radio_button, "CreatePane.Full_Build", "CreatePane.Full_Build_Tooltip");
     207
    189208    // Buttons
    190209    BuildButtonListener bbl = new BuildButtonListener();
     
    256275    int current_mode = Configuration.getMode();
    257276
     277    //Complete/incremental build options panel
     278    //For some reason I need to create seperate objects for each mode. Is there a better way??
     279    ButtonGroup build_type_group = new ButtonGroup();
     280    build_type_group.add(incremental_build_radio_button);
     281    incremental_build_radio_button.setSelected(true); //Have incremental rebuild on by default
     282    build_type_group.add(full_build_radio_button);
     283    ButtonGroup sbuild_type_group = new ButtonGroup();
     284    sbuild_type_group.add(sincremental_build_radio_button);
     285    sincremental_build_radio_button.setSelected(true);
     286    sbuild_type_group.add(sfull_build_radio_button);
     287    JPanel build_type_pane = new JPanel(new GridLayout(2,1));
     288    build_type_pane.add(full_build_radio_button);
     289    build_type_pane.add(incremental_build_radio_button);
     290    JPanel sbuild_type_pane = new JPanel(new GridLayout(2,1));
     291    sbuild_type_pane.add(sfull_build_radio_button);
     292    sbuild_type_pane.add(sincremental_build_radio_button);
     293   
     294   
     295
    258296    // Build control_pane
    259297    JPanel left = new JPanel();
     
    261299    left.setLayout(new BorderLayout());
    262300    left.add(tree, BorderLayout.CENTER);
     301    left.add(build_type_pane, BorderLayout.SOUTH);
     302    //left.add(full_build_radio_button, BorderLayout.SOUTH);
    263303
    264304    right = new JPanel();
     
    274314    button_pane = new JPanel();
    275315    button_pane.setBorder(BorderFactory.createEmptyBorder(5,10,10,10));
    276     button_pane.setLayout(new GridLayout(1,3));
     316    button_pane.setLayout(new GridLayout(1,4));
    277317    button_pane.add(build_button);
    278318    button_pane.add(cancel_button);
     
    284324
    285325    // Build progress_pane
    286 
    287326    JPanel labels_pane = new JPanel();
    288327    labels_pane.setLayout(new GridLayout(2,1,0,5));
     
    308347
    309348    // Simple panel
    310     sbutton_panel.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
    311     sbutton_panel.setLayout(new GridLayout(3,1));
     349    sbutton_panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
     350    sbutton_panel.setLayout(new GridLayout(1,3));
    312351    sbutton_panel.add(simple_build_button);
    313352    sbutton_panel.add(simple_cancel_button);
    314353    sbutton_panel.add(simple_preview_button);
    315354
    316     JPanel simple_bar_area = new JPanel(new GridLayout(3,1));
     355    JPanel simple_bar_area = new JPanel(new GridLayout(2,1));
    317356    simple_bar_area.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
    318357    simple_bar_area.add(import_monitor.getSharedProgress());
     358    simple_bar_area.add(sbutton_panel);
    319359
    320360    sinner_panel.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
    321361    sinner_panel.setLayout(new BorderLayout());
    322     sinner_panel.add(sbutton_panel, BorderLayout.WEST);
     362    sinner_panel.add(sbuild_type_pane, BorderLayout.WEST);
     363    //sinner_panel.add(full_build_radio_button, BorderLayout.WEST);
    323364    sinner_panel.add(simple_bar_area, BorderLayout.CENTER);
    324365   
     
    383424    tree.clearSelection();
    384425    tree.setSelectionPath(path);
     426
     427    //Disable the full/incremental buttons if the collection has not been built.
     428    if(Gatherer.c_man.built()) {
     429        full_build_radio_button.setEnabled(true);
     430        incremental_build_radio_button.setEnabled(true);
     431        sfull_build_radio_button.setEnabled(true);
     432        sincremental_build_radio_button.setEnabled(true);
     433    }
     434    else {
     435        full_build_radio_button.setEnabled(false);
     436        incremental_build_radio_button.setEnabled(false);
     437        sfull_build_radio_button.setEnabled(false);
     438        sincremental_build_radio_button.setEnabled(false);
     439    }
    385440    }
    386441
     
    388443    public void loseFocus() {
    389444    tree.valueChanged(null);
     445    }
     446
     447    /**
     448     * Check to see if doing an incremental build is chosen.
     449     * If not, the full rebuild option must be chosen.
     450     * @return boolean - true if the collection should be rebuilt incrementally.
     451     */
     452    public boolean isIncremental() {
     453    boolean incremental = false;
     454
     455    //This is horrible. What if the mode is changed, and different options are chosen on different modes??
     456    if(Gatherer.c_man.built()) {
     457        if(Configuration.getMode() >= THRESHOLD) {
     458        incremental = incremental_build_radio_button.isSelected();
     459        }
     460        else {
     461        incremental = sincremental_build_radio_button.isSelected();
     462        }
     463    }
     464    else {
     465        incremental = false; //The collection has not yet been built
     466    }
     467    return incremental;
    390468    }
    391469
     
    587665    private class BuildButtonListener
    588666    implements ActionListener {
    589     /** This method causes a call to be made to CollectionManager.importCollection(), which then imports and builds the collection as necessary.
     667    /**
     668     * This method checks to see what needs to be done for a build, and starts the process off.
     669     * A complete build proccess is started by {@link CollectionManager.importCollection()}, which then imports and builds the collection.
     670     * However, this doesn't always happen, as sometimes an incremental build will do :-)
    590671     * @param event An <strong>ActionEvent</strong> who, thanks to the power of object oriented programming, we don't give two hoots about.
    591672     * @see org.greenstone.gatherer.Gatherer
     
    595676     */
    596677    public void actionPerformed(ActionEvent event) {
     678        Collection collection = Gatherer.c_man.getCollection();
     679        String collection_name = collection.getName();
     680        if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) {
     681        //Only design options have changes, and we want to be smart in the way we handle them.
     682        int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired();
     683
     684        if(rebuildTypeRequired == CollectionDesignManager.UPDATE_COLLECT_CFG && Gatherer.isGsdlRemote) {
     685            //Special case when the GLI is an applet: Upload the collect.cfg to server
     686            //This is already handled by CollectionDesignManager.save()
     687            DebugStream.println("Just want to upload collect.cfg, but this has already been done");
     688        }
     689        else if(rebuildTypeRequired == CollectionDesignManager.BUILDCOL) {
     690            //First upload the collect.cfg file
     691            Utility.zipup(Gatherer.getCollectDirectoryPath(), collection_name, Utility.CONFIG_FILE, null, "", "");
     692            GathererApplet.upload_url_zip(collection_name, "etc", "", null);
     693
     694            //Just run the buildcol command.
     695            DebugStream.println("Just want to run buildcol.pl");
     696            prepareForBuild();
     697            Gatherer.c_man.buildCollection();
     698        }
     699        else if(rebuildTypeRequired == CollectionDesignManager.ALL) {
     700            //Do a usual build.
     701            DebugStream.println("Want to do a complete build");
     702            prepareForBuild();
     703            Gatherer.c_man.importCollection(); //This starts the building process.
     704        }
     705        else {
     706            //Nothing at all needs doing.
     707            //This is bad HCI. Maybe should disable the build button in this situation?
     708            System.err.println("Want to build the collection but nothing needs doing.");
     709        }
     710        }
     711        else {
     712        //Do a complete build.
     713        prepareForBuild();
     714        Gatherer.c_man.importCollection(); //This starts the building process.
     715        }
     716        //Re-setting the rebuildTypeRequired is handled by CollectionManager.processComplete(GShellEvent)
     717    }
     718
     719    /**
     720     * This does some stuff that is needed before a collection can be built.
     721     * For example, buttons are enabled/disabled, and certain flags are set.
     722     * This is called from {@link actionPerformed(ActionEvent)}
     723     */
     724    private void prepareForBuild() {
    597725        // First we force the build options to be updated if we haven't already.
    598726        tree.valueChanged(null);
     
    602730        options_pane.update(sargument_configuration_panel);
    603731        }
    604 
     732       
    605733        // Now go about building.
    606734        build_button.setEnabled(false);
    607735        cancel_button.setEnabled(true);
    608736        preview_button.setEnabled(false);
    609 
     737       
    610738        simple_build_button.setEnabled(false);
    611739        simple_cancel_button.setEnabled(true);
    612740        simple_preview_button.setEnabled(false);
    613 
     741       
    614742        document = options_pane.createNewLogDocument();
    615743        log_textarea.setDocument(document);
     
    628756        Gatherer.c_man.getCollection().import_options.setValue("removeold", true, null);
    629757        }
    630         // Call CollectionManagers method to build collection.
    631         Gatherer.c_man.importCollection();
    632     }
    633     }
     758    }
     759    }
     760   
     761   
    634762    /** This class serves as the listener for actions on the cancel button. */
    635763    private class CancelButtonListener
  • trunk/gli/src/org/greenstone/gatherer/shell/GShell.java

    r10208 r10237  
    4141import java.util.ArrayList;
    4242import java.util.Enumeration;
     43import java.util.regex.*;
    4344import javax.swing.*;
    4445import javax.swing.event.*;
     
    222223    protected void runRemote(String[] args, BufferedOutputStream bos)
    223224    {
     225    System.err.println("The level of design processing needed is: " + CollectionDesignManager.getRebuildTypeRequired()); //Will add smart design processing
    224226    if(hasSignalledStop()) { return; }
    225227    int error_count = 0;
     
    235237       
    236238        //Only upload the parts of the import folder (files/metadata) that has been changed.
    237         if(Gatherer.c_man.getCollection().getFilesChanged()) {
     239        //Or upload the lot if we are doing a complete rebuild.
     240        if(Gatherer.c_man.getCollection().getFilesChanged() || !Gatherer.g_man.create_pane.isIncremental()) {
    238241            // zip up import folder, but exclude metadata
    239242            Utility.zipup(collect_directory_path, col_name, "import", this, "", ".*metadata\\.xml");
     
    246249            System.err.println("Finished uploading files");
    247250        }
    248         if(Gatherer.c_man.getCollection().getMetadataChanged()) {
     251        if(Gatherer.c_man.getCollection().getMetadataChanged() || !Gatherer.g_man.create_pane.isIncremental()) {
    249252            // zip up metadata from import folder
    250253            Utility.zipup(collect_directory_path, col_name, "import", this, ".*metadata\\.xml", "");
     
    311314
    312315        String cols_concat = null;
    313 
    314316        String launch  = Gatherer.cgiBase + "launch";
    315317        launch = launch + "?cmd=" + perl_cmd;
     
    325327            continue;
    326328        }
    327        
    328        
     329               
    329330        if(arg.startsWith(StaticStrings.MINUS_CHARACTER)) {
    330331            String name = arg.substring(1);
     
    376377            fireMessage(type, typeAsString(type) + "> " + line, status, bos);
    377378        }
    378         //System.err.println("Wants to stop (1)."); //debug --Matthew
    379379        }
    380380        stdbr.close();
     
    395395        fireMessage(type, typeAsString(type) + "> " + Dictionary.get("GShell.Success"), status, null);
    396396        }
    397 
    398 
    399397    }
    400398    // Exception
     
    520518    /** Any threaded class must include this method to allow the thread body to be run. */
    521519    public void run() {
    522 
    523520    String col_name = args[args.length-1];     
    524521
     
    623620        }
    624621        else if(type == CDIMAGE) {
    625        
    626622        // download exported files from tmp folder (if gsdl server is remote)           
    627623        if (Gatherer.isGsdlRemote) {
     
    629625            progress.messageOnProgressBar("Downloading CD-ROM data from server");
    630626            }
     627           
     628            //Export directory derrived from -cdname argument
     629            //This needs to be exactly the same as derrived by exportcol.pl - perhaps it should be passed in as an argument?
     630            String cd_dir = "exported_collections";
     631            for(int i=0; i<args.length-1; i++) {
     632            if(args[i] == "-cdname") {
     633                //Remove all spaces
     634                String cdName = args[i+1];
     635                Pattern pattern = Pattern.compile("\\s");
     636                Matcher matcher = pattern.matcher(cdName);
     637                cd_dir = "exported_" + matcher.replaceAll("");
     638            }
     639            }
     640            //DebugStream.println("cd_dir is: " + cd_dir);
    631641
    632642            String tmp_dir = Utility.TMP_DIR;
    633 
    634             // export directory named stored as -cdname argument
    635             String cd_dir = "exported_collections";
    636             for (int i=0; i<args.length-1; i++) {
    637             if (args[i] == "-cddir") {
    638                 cd_dir = args[i+1];
    639                 break;
    640             }
    641             }
    642 
    643             // String user_cd_dir = cd_dir;
    644643            String user_tmp_dir = "/tmp";
    645             String username = System.getProperty("user.name");
    646             if ((username != null) && (username != "")) {
     644
     645            //String username = System.getProperty("user.name");
     646            //if ((username != null) && (username != "")) {
    647647            // user_cd_dir = username + File.separator + cd_dir;
    648             user_tmp_dir = user_tmp_dir + File.separator + username;
    649             }
    650 
    651             String full_local_cd_dir = tmp_dir + cd_dir;
     648            //user_tmp_dir = user_tmp_dir + File.separator + username;
     649            //}
     650
     651            String full_local_cd_dir = tmp_dir + cd_dir; //Need to tell user this!
    652652
    653653            Utility.delete(full_local_cd_dir); // remove current cd-rom dir, if it exists
     
    661661            }
    662662           
     663            //The string needs to start with exportcol.pl> otherwise it won't be displayed in the final dialog
     664            String message = "exportcol.pl>\nThese files have been copied from the server to " + full_local_cd_dir + " and are ready to written to CD-ROM";
     665            fireMessage(type, message, status, bos); //Hopefully this works
    663666            System.err.println("Finished download of /tmp ...");
    664667        }
     
    667670    }
    668671
    669     // We're done.
     672    // We're done. 
    670673    fireProcessComplete(type, status);
    671674    // Close bos
     
    738741    }
    739742    }
     743
     744
    740745    /** Method for firing a process complete event which is called, no surprise here, when the process ends.
    741746     * @param type An <strong>int</strong> indicating the process type.
Note: See TracChangeset for help on using the changeset viewer.