Ignore:
Timestamp:
2005-08-24T15:14:01+12:00 (19 years ago)
Author:
kjdon
Message:

fixes to make the config file save only if it has changed

Location:
trunk/gli/src/org/greenstone/gatherer/cdm
Files:
9 edited

Legend:

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

    r10370 r10556  
    809809            ac.destroy();
    810810            ac = null;
     811            // cos I can't be bothered checking every argument to see if it has changed or not, we'll asasume that the configuration has changed if someone has clicked configure
     812            Gatherer.c_man.configurationChanged();
    811813            }
    812814        }
     
    832834           ac.destroy();
    833835           ac = null;
     836           // cos I can't be bothered checking every argument to see if it has changed or not, we'll asasume that the configuration has changed if someone has clicked configure
     837           Gatherer.c_man.configurationChanged();
    834838        }
    835839        }
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java

    r10530 r10556  
    9090    static final public int NOTHING = 0;
    9191    static private int rebuildTypeRequired = NOTHING; //Rebuild type required if only design options have changed
    92     static protected boolean update_collect_cfg_required = false;
     92    static public boolean update_collect_cfg_required = false;
    9393
    9494    /** 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.
     
    214214
    215215
     216    public void save() {
     217    save(false);
     218    }
    216219    /** Cause the current collection configuration to be written out to disk.
    217220     */
    218     public void save()
     221    public void save(boolean force_save)
    219222    {
     223   
     224    general_manager.loseFocus();
     225    if (!update_collect_cfg_required && !force_save) {
     226        DebugStream.println("Asked to save the config file, but don't need to");
     227        return;
     228    }
     229
     230    DebugStream.println("Saving the collection config file");
     231   
    220232    // Release collection as necessary
    221233    String collection_name = Gatherer.c_man.getCollection().getName();
    222234    boolean collection_released = false;
    223235
    224     if (update_collect_cfg_required && Gatherer.c_man.built() && LocalLibraryServer.isRunning() == true) {
     236    if (Gatherer.c_man.built() && LocalLibraryServer.isRunning() == true) {
    225237        // Release the collection
    226238        LocalLibraryServer.releaseCollection(collection_name);
     
    228240    }
    229241
    230     general_manager.loseFocus();
    231242    collect_config.save();
    232243
     
    237248    }
    238249
    239     if (update_collect_cfg_required) {
    240         // Unset formats changed
    241         update_collect_cfg_required = false;
    242     }
     250    // Unset formats changed
     251    update_collect_cfg_required = false;
     252   
    243253    }
    244254
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionMeta.java

    r10345 r10556  
    2727package org.greenstone.gatherer.cdm;
    2828
     29import org.greenstone.gatherer.Gatherer;
    2930import org.greenstone.gatherer.Configuration;
    3031import org.greenstone.gatherer.util.Codec;
     
    161162     */
    162163    public void setValue(String raw_value) {
     164    // we need to check if the value has changed
     165    String current_value = XMLTools.getValue(element);
     166    String new_value = Codec.transform(raw_value, Codec.TEXT_TO_DOM);
     167    if (!current_value.equals(new_value)) {
    163168    // Only raw html text can be given to setValue so we need to encode it
    164     XMLTools.setValue(element, Codec.transform(raw_value, Codec.TEXT_TO_DOM));
    165     text = null; // Reset text
    166     // And determine if this makes the metadata assigned
    167     setAssigned(raw_value != null && raw_value.length() > 0);
     169        XMLTools.setValue(element, new_value);
     170        text = null; // Reset text
     171        // And determine if this makes the metadata assigned
     172        setAssigned(raw_value != null && raw_value.length() > 0);
     173        Gatherer.c_man.configurationChanged();
     174    }
    168175    }
    169176
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionMetaManager.java

    r10345 r10556  
    5656    if(!contains(metadata)) {
    5757        Element element = metadata.getElement();
    58         // Locate where we should insert this new subcollection.
     58        // Locate where we should insert this new metadata.
    5959        Node target_node = CollectionConfiguration.findInsertionPoint(element);
    6060        add(root, metadata, target_node);
    61         Gatherer.c_man.configurationChanged();
    62     }
    63     Gatherer.c_man.configurationChanged();
     61        if (!metadata.getValue(CollectionMeta.TEXT).equals("")) {
     62        // if just adding an empty metadata, the configuration hasn't changed.
     63        Gatherer.c_man.configurationChanged();
     64        }
     65    }
     66    //Gatherer.c_man.configurationChanged();
    6467    }
    6568
  • trunk/gli/src/org/greenstone/gatherer/cdm/GeneralManager.java

    r10552 r10556  
    355355        collection_extra_collectionmeta = CollectionDesignManager.collectionmeta_manager.getMetadatum(CollectionConfiguration.COLLECTIONMETADATA_COLLECTIONEXTRA_STR);
    356356        collection_name_collectionmeta = CollectionDesignManager.collectionmeta_manager.getMetadatum(CollectionConfiguration.COLLECTIONMETADATA_COLLECTIONNAME_STR);
     357       
    357358        creator_collectionmeta = new CollectionMeta(CollectionDesignManager.collect_config.getCreator());
    358359        icon_collection_collectionmeta = CollectionDesignManager.collectionmeta_manager.getMetadatum(CollectionConfiguration.COLLECTIONMETADATA_ICONCOLLECTION_STR);
  • trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java

    r10370 r10556  
    972972                ac.destroy();
    973973                ac = null;
     974                // cos I can't be bothered checking every argument to see if it has changed or not, we'll asasume that the configuration has changed if someone has clicked configure
     975                Gatherer.c_man.configurationChanged();
    974976            }
    975977            }
     
    996998            ac.destroy();
    997999            ac = null;
     1000            // cos I can't be bothered checking every argument to see if it has changed or not, we'll asasume that the configuration has changed if someone has clicked configure
     1001            Gatherer.c_man.configurationChanged();
    9981002            }
    9991003        }
  • trunk/gli/src/org/greenstone/gatherer/cdm/SearchTypeManager.java

    r10528 r10556  
    222222        }
    223223        } else {
    224         build_type.setValue((String)build_type_combobox.getSelectedItem());
     224        //build_type.setValue((String)build_type_combobox.getSelectedItem());
    225225        build_type.setAssigned(isSearchTypeEnabled());
    226226
     
    427427        Gatherer.g_man.wait(true);
    428428        boolean advanced_search_enabled = enable_advanced_searches_checkbox.isSelected();
     429       
    429430        model.root.setAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE, (advanced_search_enabled ? CollectionConfiguration.TRUE_STR : CollectionConfiguration.FALSE_STR));
    430431        CollectionDesignManager.index_manager.setMGPPEnabled(advanced_search_enabled);
    431432        validateControls(advanced_search_enabled);
    432         build_type.setAssigned(advanced_search_enabled);
     433        if ((!build_type.isAssigned() && advanced_search_enabled) ||
     434            (build_type.isAssigned() && !advanced_search_enabled)) {
     435           
     436            build_type.setAssigned(advanced_search_enabled);
     437            Gatherer.c_man.configurationChanged();
     438        }
     439        if (build_type.isAssigned() && build_type.getValue(true).equals("")) {
     440            build_type.setValue((String)build_type_combobox.getSelectedItem());
     441        }
    433442        Gatherer.g_man.wait(false);
    434443        }
     
    439448
    440449        public void actionPerformed(ActionEvent event) {
    441         build_type.setValue((String)build_type_combobox.getSelectedItem());
    442         }
    443 
     450        if (!build_type.getValue(CollectionMeta.TEXT).equals((String)build_type_combobox.getSelectedItem())) {
     451            build_type.setValue((String)build_type_combobox.getSelectedItem());
     452        }
     453        }
     454       
    444455    }
    445456    /** Listenes for actions on the Remove button, and if detected removes the currently selected search types. */
  • trunk/gli/src/org/greenstone/gatherer/cdm/SuperCollectionManager.java

    r10237 r10556  
    7575    if(!contains(supercollection)) {
    7676        add(getSize(), supercollection);
    77     }
     77        Gatherer.c_man.configurationChanged();
     78    }
     79   
    7880    }
    7981
     
    103105
    104106    private void removeSuperCollection(SuperCollection supercollection) {
    105     remove(supercollection);
     107    if(contains(supercollection)) {
     108        remove(supercollection);
     109        Gatherer.c_man.configurationChanged();
     110    }
    106111    }
    107112
     
    162167        ArrayList supercollections = children();
    163168        // Now iterate through the checklist, and for each checked box found ensure the Supercollection exists, and ensure its assigned. Remove any supercollections altered in this way from the temporary array list
     169        // we ignore the current coll at the moment
    164170        int size = collection_checklist_model.size();
    165171        for(int i = 0; i < size; i++) {
     
    167173        if(entry.isSelected()) {
    168174            String collection_name = (String) entry.getProperty();
    169             SuperCollection supercollection = getSuperCollection(collection_name);
    170             // Create the supercollection element if necessary
    171             if(supercollection == null) {
    172             Element supercollection_element = root.getOwnerDocument().createElement(StaticStrings.COLLECTION_ELEMENT);
    173             supercollection = new SuperCollection(supercollection_element);
    174             supercollection.setName(collection_name);
    175             addSuperCollection(supercollection);
     175            if (!collection_name.equals(current_coll_name)) {
     176            SuperCollection supercollection = getSuperCollection(collection_name);
     177            // Create the supercollection element if necessary
     178            if(supercollection == null) {
     179                Element supercollection_element = root.getOwnerDocument().createElement(StaticStrings.COLLECTION_ELEMENT);
     180                supercollection = new SuperCollection(supercollection_element);
     181                supercollection.setName(collection_name);
     182                addSuperCollection(supercollection);
     183            }
     184            else {
     185                supercollections.remove(supercollection);
     186            }
     187            supercollection.setAssigned(true);
     188            super_collections_count++;
    176189            }
    177             else {
    178             supercollections.remove(supercollection);
    179             }
    180             supercollection.setAssigned(true);
    181             super_collections_count++;
    182         }
    183         }
     190        }
     191        }
     192        if (super_collections_count > 0) {
     193        // we have some super colls, add in the current collection
     194        SuperCollection supercollection = getSuperCollection(current_coll_name);
     195        // Create the supercollection element if necessary
     196        if(supercollection == null) {
     197            Element supercollection_element = root.getOwnerDocument().createElement(StaticStrings.COLLECTION_ELEMENT);
     198            supercollection = new SuperCollection(supercollection_element);
     199            supercollection.setName(current_coll_name);
     200            addSuperCollection(supercollection);
     201        }
     202        else {
     203            supercollections.remove(supercollection);
     204        }
     205        model.root.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.TRUE_STR);
     206        } else {
     207        // current collection is the only one - don't bother adding it, because assigned is false, and we don't want to update the config file for an unassigned item.
     208        model.root.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.FALSE_STR);
     209        }
     210       
    184211        // Any collections left in the temporary list have been unselected, so delete them
    185212        for(int j = supercollections.size(); j > 0; j--) {
     
    187214        removeSuperCollection(supercollection);
    188215        }
    189         // Now we only assign supercollections if more than one is selected
    190         model.root.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, (super_collections_count > 1 ? StaticStrings.TRUE_STR : StaticStrings.FALSE_STR));
    191     }
    192 
    193 
     216    }
     217
     218   
    194219    private void buildModel()
    195220    {
  • trunk/gli/src/org/greenstone/gatherer/cdm/TranslationView.java

    r10237 r10556  
    3636import org.greenstone.gatherer.DebugStream;
    3737import org.greenstone.gatherer.Dictionary;
     38import org.greenstone.gatherer.Gatherer;
    3839import org.greenstone.gatherer.gui.GLIButton;
    3940
     
    377378            translation_text = null;
    378379            remove_button.setEnabled(true);
     380            Gatherer.c_man.configurationChanged();
    379381        }
    380382        add_button.setEnabled(false);
     
    396398            // If a remove occured then enable add
    397399            add_button.setEnabled(true);
     400            Gatherer.c_man.configurationChanged();
    398401        }
    399402        // Either way disable replace and remove
     
    419422            metadata = null;
    420423            remove_button.setEnabled(true);
     424            Gatherer.c_man.configurationChanged();
    421425        }
    422426        // Either way disable replace
Note: See TracChangeset for help on using the changeset viewer.