Changeset 8388


Ignore:
Timestamp:
2004-10-20T15:38:07+13:00 (20 years ago)
Author:
kjdon
Message:

attila's fixes for some stuff, and kaths fixes for some stuff

Location:
trunk/gli/src/org/greenstone/gatherer/gems
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java

    r8375 r8388  
    8787    static final private String SET = "set";
    8888    static final private String VALUES = "values";
    89 
     89   // static final public String MAX_LOADED_SETS = 64;
    9090    static public Configuration config = null;
    91     static private MetadataSetManager msm = new MetadataSetManager();
     91    private MetadataSetManager msm = new MetadataSetManager(this);
    9292
    9393    public AddElementActionListener add_element_action_listener = null;
     
    150150    private String current_collection_file = null;
    151151    private String dialog_options[] = null;
    152 
     152   
    153153
    154154    static public void main(String[] args)
     
    179179    // Load configuration file
    180180    try {
     181           
    181182        config = new Configuration(go.gsdl_path, null, go.exec_path, go.perl_path, false, null);
    182183    }
     
    184185        DebugStream.printStackTrace(exception);
    185186    }
    186 
    187     new GEMS();
     187        GEMS gems;
     188    gems = new GEMS();
    188189    }
    189190
     
    238239    JPanel mds_tree_pane = new JPanel();
    239240    mds_tree_pane.setOpaque(false);
    240     mds_tree_pane.setPreferredSize(new Dimension(200,500));
     241    mds_tree_pane.setPreferredSize(new Dimension(250,500));
    241242    mds_tree = new SmarterTree(model);
    242243    mds_tree.setCellRenderer(new MEMTreeCellRenderer());
     
    564565    content_pane.add(button_pane, BorderLayout.SOUTH);
    565566
     567    // initialise the selection
     568    mds_tree.setSelectionRow(0);
    566569    // Display
    567570    setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
     
    573576    {
    574577    // Flush debug
    575         System.out.println("Final exit func");
     578        //System.out.println("Final exit func");
    576579    DebugStream.closeDebugStream();
    577 
     580        if(set_changed == true) {
     581           
     582            int result = JOptionPane.showOptionDialog(self, Dictionary.get("Gems.Menu.Confirm_Exit_Save", Dictionary.get("MEM.Element")), Dictionary.get("Gems.Menu.Confirm_Exit_Save_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]);
     583
     584         //   System.out.println("Exit: "+result);
     585            if(result == 0) {
     586                msm.save();
     587            }
     588           
     589        }
     590       
    578591    System.exit(0);
    579592    }
     
    636649        // Layout (file menu)
    637650        file.add(file_new);
    638         file.add(file_open);
     651        //file.add(file_open);
    639652        file.add(file_save);
    640653            file.add(file_delete);
     
    708721            MetadataSet metadata_set = msm.loadMetadataSet(metadata_set_file_chooser.getSelectedFile());
    709722            // Update tree
    710             model.add(null, metadata_set, GEMSNode.SET);
    711         }
    712                  set_changed = true;
     723                    //only update tree if the metadata_set return is not null(it will be null if set is already
     724                    //opened-Attila - oct 19 0 4
     725                    if(metadata_set != null) {
     726                        model.add(null, metadata_set, GEMSNode.SET);
     727                    }
     728        }
     729               
    713730        return;
    714731        }
     
    723740        // File -> Exit
    724741        if (event_source == file_exit) {
    725                
     742                exit();
     743              /* 
    726744                if(set_changed == true) {
    727745                    int result = JOptionPane.showOptionDialog(self, Dictionary.get("Gems.Menu.Confirm_Exit_Save", Dictionary.get("MEM.Element")), Dictionary.get("Gems.Menu.Confirm_Exit_Save_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]);
    728746       
    729                     System.out.println("Exit: "+result);
     747                 //   System.out.println("Exit: "+result);
    730748                    if(result == 0) {
    731749                        msm.save();
     
    740758                   
    741759                    exit();
    742                 }
     760                }*/
    743761        }
    744762
     
    854872    }
    855873    }
    856 
     874    //callback method
     875     protected void processWindowEvent(WindowEvent evt){
     876       
     877       if(evt.getID() == WindowEvent.WINDOW_CLOSING){
     878           
     879          exit();
     880       }
     881       
     882 
     883   }
     884   //called from MetadataSetManager...I don't think it should be here anymore, but for now it's ok
     885 
     886   public void warn_cant_load_set(){
     887            JOptionPane.showMessageDialog(self, Dictionary.get("Gems.Already_Loaded_Set_Error"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     888     
     889        }
    857890    public void dispose() {
     891       
     892       
     893         //if anything has changed, warn user that they should save
     894        if(set_changed == true) {
     895           
     896            int result = JOptionPane.showOptionDialog(self, Dictionary.get("Gems.Menu.Confirm_Exit_Save", Dictionary.get("MEM.Element")), Dictionary.get("Gems.Menu.Confirm_Exit_Save_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]);
     897         //   System.out.println("Exit: "+result);
     898            if(result == 0) {
     899                msm.save();
     900
     901            }
     902        }
     903        set_changed = false;
    858904    // Destructor
    859905    card_layout = null;
     
    896942    }
    897943    remove_set_action_listener = null;
     944
     945        //close
    898946    super.dispose();
    899947    }
     
    9611009            //LanguageManager languageManager = new LanguageManager(org.w3c.dom.Element());
    9621010           
    963             System.out.println("f");
     1011         
    9641012        // !!! language_box.setRenderer(new LanguageListCellRenderer());
    9651013        Dictionary.setTooltip(language_box, "MEM.Attribute_Language_Tooltip");
     
    10761124        // Name combo box is enabled except when attributes are edited
    10771125        //name.setEnabled((source != edit_attribute));
    1078                 System.out.println("elsed");
     1126                //System.out.println("elsed");
    10791127        name_to_values.clear();
    10801128        name.clear();
     
    11671215        }
    11681216        // Now pritty up the dialog depending on the action type
    1169         if(source == add_attribute || source == popupListener.menuAddAttributeElement || source == popupListener.menuAddAttributeAttribute) {
     1217        if(source == add_attribute || source == popupListener.menuAddAttributeSet || source == popupListener.menuAddAttributeElement || source == popupListener.menuAddAttributeAttribute) {
    11701218            add_type = true;
    11711219            Dictionary.setText(this, "MEM.AddAttribute");
     
    13571405        center_pane.setOpaque(false);
    13581406
    1359         JPanel set_pane = new JPanel();
    1360         set_pane.setOpaque(false);
     1407        JPanel labels_pane = new JPanel();
     1408        labels_pane.setOpaque(false);
    13611409        JLabel set_label = new JLabel();
    13621410        set_label.setOpaque(false);
     
    13651413        set_field.setOpaque(false);
    13661414
    1367         JPanel name_pane = new JPanel();
    1368         name_pane.setOpaque(false);
     1415        JPanel values_pane = new JPanel();
     1416        values_pane.setOpaque(false);
    13691417        JLabel name_label = new JLabel();
    13701418        name_label.setOpaque(false);
     
    13951443
    13961444        // Layout
    1397         set_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
    1398         set_pane.setLayout(new BorderLayout());
    1399         set_pane.add(set_label, BorderLayout.WEST);
    1400         set_pane.add(set_field, BorderLayout.CENTER);
    1401 
    1402         name_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
    1403         name_pane.setLayout(new BorderLayout(5,0));
    1404         name_pane.add(name_label, BorderLayout.WEST);
    1405         name_pane.add(name_field, BorderLayout.CENTER);
    1406 
    1407         center_pane.setLayout(new GridLayout(2,1,0,0));
    1408         center_pane.add(set_pane);
    1409         center_pane.add(name_pane);
     1445        labels_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
     1446        labels_pane.setLayout(new GridLayout(2,1));
     1447        labels_pane.add(set_label);
     1448        labels_pane.add(name_label);
     1449
     1450        values_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
     1451        values_pane.setLayout(new GridLayout(2,1));
     1452        values_pane.add(set_field);
     1453        values_pane.add(name_field);
     1454
     1455        center_pane.setLayout(new BorderLayout(5,5));
     1456        center_pane.add(labels_pane, BorderLayout.WEST);
     1457        center_pane.add(values_pane, BorderLayout.CENTER);
    14101458
    14111459        button_pane.setLayout(new GridLayout(1,2,0,5));
     
    14461494        // Otherwise show an error message and do not proceed.
    14471495        else {
    1448             JOptionPane.showMessageDialog(self, Dictionary.get("MEM.Element_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     1496            JOptionPane.showMessageDialog(self, Dictionary.get("Gems.Element_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
    14491497        }
    14501498        name_str = null;
     
    14651513            // Warn the user that they can't do that dave.
    14661514            else {
     1515                        set_changed = false;
    14671516            JOptionPane.showMessageDialog(self, Dictionary.get("MEM.Cannot_Add_Elements_To_Greenstone_MDS"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
    14681517            }
     
    14711520        source = null;
    14721521    }
    1473 
     1522 
    14741523    public void dispose() {
    14751524        cancel_button = null;
     
    16911740        if(msm.getSet(name_str) == null) {
    16921741            MetadataSet set = msm.addSet(namespace_str, name_str);
     1742            File mds_file = new File(Utility.METADATA_DIR, namespace_str + ".mds");
     1743            set.setFile(mds_file);
    16931744            // Update tree.
    16941745            model.add(null, set, GEMSNode.SET);
     
    20882139    public void actionPerformed(ActionEvent event) {
    20892140        if(current_set != null) {
     2141               
     2142                //If the current_set_filename is dls or dc or ex and in the METADATA_DIR, then do
     2143                //not let anyone remove them --Attila
     2144               // System.out.println(current_set.getName());
     2145               //
     2146               
     2147                File current_set_filename = current_set.getFile();
     2148              //  System.out.println(current_set_filename.toString());
     2149               
     2150                if(current_set_filename.toString().compareTo(new String(Utility.METADATA_DIR+"dls.mds")) == 0 ||
     2151                    current_set_filename.toString().compareTo(new String(Utility.METADATA_DIR+"dc.mds")) == 0 ||
     2152                    current_set_filename.toString().compareTo(new String(Utility.METADATA_DIR+"ex.mds")) == 0){
     2153                 
     2154                    JOptionPane.showMessageDialog(self, Dictionary.get("Gems.Cannot_Delete_Core_Sets_Error"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     2155                    return;
     2156                }
     2157               
     2158               
    20902159        int result = JOptionPane.showOptionDialog(self, Dictionary.get("MEM.Confirm_Removal", Dictionary.get("MEM.Set")), Dictionary.get("MEM.Confirm_Removal_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialog_options, dialog_options[0]);
    20912160        // Remove the currently selected set
     
    23482417        JMenuItem menuRenameSet;
    23492418        JMenuItem menuAddElement;
    2350        
     2419      JMenuItem menuAddAttributeSet;
     2420
    23512421        JMenuItem menuRenameSubfield;
    23522422        JMenuItem menuDeleteSubfield;
     
    23702440        static final public int SET        = 4;
    23712441        PopupListener() {
    2372              setPopup = new JPopupMenu();
    2373              subfieldPopup = new JPopupMenu();
    2374              elementPopup = new JPopupMenu();
    2375              attributePopup = new JPopupMenu();
    2376             
    2377              
    2378              //create the MenuItems
    2379             
    2380              //set related popups
    2381             menuAddSet = new JMenuItem();
     2442        setPopup = new JPopupMenu();
     2443        subfieldPopup = new JPopupMenu();
     2444        elementPopup = new JPopupMenu();
     2445        attributePopup = new JPopupMenu();
     2446       
     2447       
     2448        //create the MenuItems
     2449       
     2450        //set related popups
     2451        menuAddSet = new JMenuItem();
    23822452            Dictionary.setText(menuAddSet,"Gems.Popup.menuAddSet");
    23832453           
    2384              menuRenameSet = new JMenuItem();
    2385              Dictionary.setText(menuRenameSet,"Gems.Popup.menuRenameSet");
    2386              
    2387              menuAddElement =new JMenuItem();
    2388              Dictionary.setText(menuAddElement,"Gems.Popup.menuAddElement");
    2389              
    2390               menuRemoveSet = new JMenuItem();
    2391               Dictionary.setText(menuRemoveSet,"Gems.Popup.menuRemoveSet");
    2392              //subfield related Gems.Popups
     2454        menuRenameSet = new JMenuItem();
     2455        Dictionary.setText(menuRenameSet,"Gems.Popup.menuRenameSet");
     2456       
     2457        menuAddElement =new JMenuItem();
     2458        Dictionary.setText(menuAddElement,"Gems.Popup.menuAddElement");
     2459       
     2460        menuAddAttributeSet = new JMenuItem();
     2461        Dictionary.setText(menuAddAttributeSet, "Gems.Popup.menuAddAttribute");
     2462        menuRemoveSet = new JMenuItem();
     2463        Dictionary.setText(menuRemoveSet,"Gems.Popup.menuRemoveSet");
     2464        //subfield related Gems.Popups
    23932465            menuRenameSubfield = new JMenuItem();
    23942466            Dictionary.setText(menuRenameSubfield,"Gems.Popup.menuRenameSubfield");
    23952467           
    23962468            menuDeleteSubfield=new JMenuItem();
    2397             Dictionary.setText(menuDeleteSubfield,"Gems.Popup.menuDeleteSubfield");
     2469            Dictionary.setText(menuDeleteSubfield,"Gems.Popup.menuRemoveSubfield");
    23982470           
    23992471            menuAddAttributeSubfield=new JMenuItem();
    2400             Dictionary.setText(menuAddAttributeSubfield,"Gems.Popup.menuAddAttributeSubfield");
     2472            Dictionary.setText(menuAddAttributeSubfield,"Gems.Popup.menuAddAttribute");
    24012473           
    24022474            //element related Gems.Popups
     
    24052477           
    24062478            menuDeleteElement=new JMenuItem();
    2407             Dictionary.setText(menuDeleteElement,"Gems.Popup.menuDeleteElement");
     2479            Dictionary.setText(menuDeleteElement,"Gems.Popup.menuRemoveElement");
    24082480           
    24092481            menuAddAttributeElement=new JMenuItem();
    2410             Dictionary.setText(menuAddAttributeElement,"Gems.Popup.menuAddAttributeElement");
     2482            Dictionary.setText(menuAddAttributeElement,"Gems.Popup.menuAddAttribute");
    24112483           
    24122484            menuAddSubfield=new JMenuItem();
     
    24182490           
    24192491            menuDeleteAttribute=new JMenuItem();
    2420             Dictionary.setText(menuDeleteAttribute,"Gems.Popup.menuDeleteAttribute");
     2492            Dictionary.setText(menuDeleteAttribute,"Gems.Popup.menuRemoveAttribute");
    24212493           
    24222494            menuAddAttributeAttribute=new JMenuItem();
    2423             Dictionary.setText(menuAddAttributeAttribute,"Gems.Popup.menuAddAttributeAttribute");
     2495            Dictionary.setText(menuAddAttributeAttribute,"Gems.Popup.menuAddAttribute");
    24242496             
    24252497             //start Associate the menu items with the appropriate popups:
    24262498             //setPopup.add(menuRenameSet);
    2427             setPopup.add(menuAddSet);
    2428              setPopup.add(menuAddElement);
    2429              setPopup.add(menuRemoveSet);
     2499            //setPopup.add(menuAddSet);
     2500        setPopup.add(menuAddAttributeSet);
     2501        setPopup.add(menuAddElement);
     2502        setPopup.add(menuRemoveSet);
    24302503             
    24312504             //subfieldPopup.add(menuRenameSubfield);
     
    24362509             elementPopup.add(menuDeleteElement);
    24372510             elementPopup.add(menuAddAttributeElement);
    2438              elementPopup.add(menuAddSubfield);
     2511             //elementPopup.add(menuAddSubfield);
    24392512             
    24402513             attributePopup.add(menuEditValue);
     
    24472520             menuAddSet.addActionListener(new AddSetActionListener());
    24482521             menuAddElement.addActionListener(new AddElementActionListener());
    2449              
     2522             menuAddAttributeSet.addActionListener(new AddOrEditAttributeActionListener());
    24502523             menuRenameSubfield.addActionListener(this);
    24512524             menuDeleteSubfield.addActionListener(this);
  • trunk/gli/src/org/greenstone/gatherer/gems/MetadataSet.java

    r8270 r8388  
    5757    private Element  root     = null;
    5858    /** The <strong>File</strong> this metadata set was loaded from. */
     59    public String old_filename = null;
    5960    private File     file     = null;
    6061    /** A mapping from metadata elements to the root element of the value trees for that element. */
     
    6263    /** The list of metadata elements which are, of course, children of the root node. */
    6364    private NodeList elements = null;
    64 
     65   
     66    //I realize I should be using getters and setters, but for a quick fix
     67    public boolean set_changed = false;
    6568    private String current_language_code;
    6669    /** The description of this metadata set. Cached as it takes more computation time. */
     
    391394    public String getName() {
    392395    if(current_language_code != null && !Configuration.getLanguage().equals(current_language_code)) {
    393         name = null;
     396       // name = null;
     397            return null;
    394398    }
    395399    if(name == null) {
    396         name = getAttribute(StaticStrings.NAME_ELEMENT, Dictionary.get("MSM.No_Name"));
    397     }
     400           
     401        //name = getAttribute(StaticStrings.NAME_ELEMENT, Dictionary.get("MSM.No_Name"));
     402       return getAttribute(StaticStrings.NAME_ELEMENT, Dictionary.get("MSM.No_Name"));
     403   
     404        }
     405     
    398406    return name;
    399407    }
  • trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java

    r8375 r8388  
    3939import java.io.*;
    4040import java.util.*;
     41import java.util.StringTokenizer;
    4142import javax.swing.*;
    4243import javax.swing.filechooser.*;
     
    6566    /** The name of the hidden, or system, metadata set. */
    6667    static final public String HIDDEN = "hidden";
     68    static final public int MAX_LOADED_SETS = 64;
    6769    static public CollectionManager col_man = null;
    6870    /** A mapping from metadata namespace to metadata set. */
    6971    static private Hashtable mds_hashtable = new Hashtable();
    70 
     72    public GEMS gemsptr;
     73   
    7174    /** The profiler is responsible for remembering what actions a user has requested when importing metadata, so as to prevent the user needlessly re-entering this information for each import. */
    7275    // public MSMProfiler profiler = null;
     
    7477
    7578    /** Constructor. */
    76     public MetadataSetManager() {
     79    public MetadataSetManager(GEMS gemscopy) {
     80        gemsptr = gemscopy;
    7781        col_man = new CollectionManager();
    7882    }
     
    254258     * @return The MetadataSet as named, or null if no such set.
    255259     */
    256     public MetadataSet getSet(String name) {
    257     if(mds_hashtable.containsKey(name)) {
    258         return (MetadataSet) mds_hashtable.get(name);
     260    public MetadataSet getSet(String namespace) {
     261    if(mds_hashtable.containsKey(namespace)) {
     262        return (MetadataSet) mds_hashtable.get(namespace);
    259263    }
    260264//  else if(name.equals(HIDDEN)) {
     
    304308    public MetadataSet loadMetadataSet(File metadata_set_file)
    305309    {
    306     System.err.println("Loading metadata set file " + metadata_set_file + "...");
     310        File[] all_sets = new File[MAX_LOADED_SETS];
     311        MetadataSet tempSet;
     312        int i = 0;
     313        System.err.println("Loading metadata set file " + metadata_set_file + "...");
    307314    MetadataSet metadata_set = new MetadataSet(metadata_set_file);
     315       
     316        //write out existing namespaces to all_sets[]...we use this to determine if a set is
     317        //already loaded-Attila
     318        for(Enumeration keys = mds_hashtable.keys(); keys.hasMoreElements(); ) {
     319        tempSet = (MetadataSet)mds_hashtable.get(keys.nextElement()); 
     320           
     321            all_sets[i] = tempSet.getFile();
     322            i++;
     323    }
     324       
     325        //Now check our metadata.set's namespace to see if it is already loaded in all_sets
     326        for(int p = 0 ; p < i; p++) {
     327 
     328                if(metadata_set.getFile().compareTo(all_sets[p]) == 0) {
     329                   // System.err.println("Not loading set: "+ metadata_set.getNamespace() + " is already loaded.\n");
     330                   // JOptionPane.showMessageDialog(self, Dictionary.get("MEM.Cannot_Add_Elements_To_Greenstone_MDS"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     331                    gemsptr.warn_cant_load_set();
     332                   
     333                    return null;
     334                 }
     335               
     336        }
     337   
     338        //check if this metadata set belongs to a collection
     339        //if so, then change the metadata set's name in the interface to (collection) dublic core...
     340     // System.out.println(new String("asdfd" + metadata_set.getFile().separator));
     341    String sep = new String(metadata_set.getFile().separator);
     342       StringTokenizer st = new StringTokenizer(metadata_set.getFile().toString(), sep);
     343       String colName = new String("");
     344       
     345        while ( st.hasMoreTokens() )
     346        {
     347           if(st.nextToken().compareTo("collect") == 0) {
     348            colName = st.nextToken(); 
     349           // metadata_set.old_filename = metadata_set.getName();
     350           // metadata_set.setName(new String("(" + colName + ") " + metadata_set.getName()) );
     351            break;
     352           }   
     353        }
     354
     355        //Actual set loading code(if it gets this far-Attila
    308356    mds_hashtable.put(metadata_set.getNamespace(), metadata_set);
    309357    return metadata_set;
     
    360408    }
    361409 public void save() {
    362     // Create the correct file to save these sets to...
    363     //File file = new File(Gatherer.self.getCollectionMetadata());
    364     File file = new File("/home/arosmain/gsdl/gli/metadata");
    365      
    366     System.out.println("saving...");
     410     // Create the correct file to save these sets to...
     411     //File file = new File(Gatherer.self.getCollectionMetadata());
     412     //File file = new File(GEMS.config.gsdl_path + "/gli/metadata");
     413     File file = new File(Utility.METADATA_DIR);
     414
     415     
    367416     if (!file.exists()) {
    368         //DebugStream.println("trying to save a collection and the metadata directory does not exist - creating it!");
    369         System.out.println("trying to save a collection and the metadata directory does not exist - creating it!");
    370        
    371          file.mkdir();
    372     }
    373     // And make back ups of all existing metadata set files.
    374     File temp[] = file.listFiles();
    375     for(int i = temp.length - 1; i >= 0; i--) {
    376         if(temp[i].getName().endsWith(".mds") ) {
    377         File backup = new File(temp[i].getAbsolutePath() + "~attela");
    378                
    379                 System.out.println(temp[i].getAbsolutePath()+ "asdf\n backupfile:"+ backup.toString());
     417     //DebugStream.println("trying to save a collection and the metadata directory does not exist - creating it!");
     418     System.out.println("trying to save a collection and the metadata directory does not exist - creating it!");
     419     
     420     file.mkdir();
     421     }
     422     // And make back ups of all existing metadata set files.
     423     File temp[] = file.listFiles();
     424     
     425     //Null ptr exception here? Didnt see it, -Attila
     426     /*for(int i = temp.length - 1; i >= 0; i--) {
     427     // System.out.println("Itter: " + i);
     428     if(temp[i].getName().endsWith(".mds") ) {
     429     File backup = new File(temp[i].getAbsolutePath() + "~bak");
     430               
     431                //System.out.println(temp[i].getAbsolutePath()+ "asdf\n backupfile:"+ backup.toString());
    380432               
    381433               
    382434        //backup.deleteOnExit();
     435               
    383436        if(!temp[i].renameTo(backup)) {
    384             //DebugStream.println("Error in MetadataSetManager.save(): FileRenamedException");
     437            DebugStream.println("Error in MetadataSetManager.save(): FileRenamedException");
    385438                    System.out.println("Error in MetadataSetManager.save(): FileRenamedException");
    386439        }
    387440        }
    388     }
    389     // Now save the latest versions of the metadata sets.
    390     for(Enumeration keys = mds_hashtable.keys(); keys.hasMoreElements(); ) {
    391         String namespace = (String) keys.nextElement();
    392         MetadataSet set = (MetadataSet) mds_hashtable.get(namespace);
     441    }*/
     442     // Now save the latest versions of the metadata sets.
     443     for(Enumeration keys = mds_hashtable.keys(); keys.hasMoreElements(); ) {
     444     String namespace = (String) keys.nextElement();
     445     MetadataSet set = (MetadataSet) mds_hashtable.get(namespace);
    393446            //
    394447            //col_man.loadCollection(GEMS.config.getString("general.open_collection",true));
    395448            //
    396         try {
    397         File mds_file = new File(file, set.getNamespace() + ".mds");
    398                
     449     try {
     450         // this won't work if we have collection metadata open
     451         //File mds_file = new File(file, set.getNamespace() + ".mds");
     452               
     453                //set.setName(set.old_filename);
     454               
     455                //set has not changed(or has been recently saved
     456             
     457                //if(set.set_changed == false){
     458                //  continue;     
     459                //}
     460               
     461         // just use the existing file path
     462         File mds_file = set.getFile();
     463                //System.out.println(mds_file.toString() + "a\n");
    399464               //Saves the DOM obj that set.getDocument returns to mds_file name
    400         Utility.export(set.getDocument(), mds_file);
    401                 //What does setfile do?
    402         set.setFile(mds_file);
     465               // set.getF
     466               // System.out.println(keys.toString());
     467               
     468               
     469                   // System.out.println("::: " + mds_file.toString());
     470         Utility.export(set.getDocument(), mds_file);
     471         //What does setfile do?
     472         //set.setFile(mds_file);
     473         //}
    403474        // Now for each element attempt to save its value tree.
    404475        //NodeList elements = set.getElements();
Note: See TracChangeset for help on using the changeset viewer.