Changeset 54 in josm for src


Ignore:
Timestamp:
2006-02-15T20:05:05+01:00 (19 years ago)
Author:
imi
Message:
  • fixed: Saving of new objects with properties in OSM format did not work
  • Open/Save dialogs now remember the "current" directory for the session
  • added a warning before overwriting files
Location:
src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/Main.java

    r51 r54  
    99import java.awt.event.WindowAdapter;
    1010import java.awt.event.WindowEvent;
     11import java.io.File;
    1112import java.util.Arrays;
    1213import java.util.Collection;
     
    7374        public final UndoAction undoAction;
    7475        public final RedoAction redoAction;
     76
     77        /**
     78         * This directory is used for all disc IO access as starting directory. Should
     79         * be set accordingly after the IO action.
     80         */
     81        public File currentDirectory = new File(".");
    7582       
    7683        /**
  • src/org/openstreetmap/josm/actions/OpenAction.java

    r51 r54  
    4343
    4444        public void actionPerformed(ActionEvent e) {
    45                 JFileChooser fc = new JFileChooser("data");
     45                JFileChooser fc = new JFileChooser(Main.main.currentDirectory);
    4646                for (int i = 0; i < ExtensionFileFilter.filters.length; ++i)
    4747                        fc.addChoosableFileFilter(ExtensionFileFilter.filters[i]);
     
    5050                if (fc.showOpenDialog(Main.main) != JFileChooser.APPROVE_OPTION)
    5151                        return;
     52               
     53                Main.main.currentDirectory = fc.getCurrentDirectory();
    5254
    5355                File filename = fc.getSelectedFile();
  • src/org/openstreetmap/josm/actions/SaveAction.java

    r52 r54  
    4242                        return;
    4343
    44                 JFileChooser fc = new JFileChooser("data");
     44                JFileChooser fc = new JFileChooser(Main.main.currentDirectory);
    4545                for (int i = 0; i < ExtensionFileFilter.filters.length; ++i)
    4646                        fc.addChoosableFileFilter(ExtensionFileFilter.filters[i]);
     
    4949                File file = fc.getSelectedFile();
    5050                if (file == null)
     51                        return;
     52                Main.main.currentDirectory = fc.getCurrentDirectory();
     53                if (file.exists() && JOptionPane.YES_OPTION !=
     54                                JOptionPane.showConfirmDialog(Main.main, "File exists. Overwrite?", "Overwrite", JOptionPane.YES_NO_OPTION))
    5155                        return;
    5256
  • src/org/openstreetmap/josm/io/OsmWriter.java

    r53 r54  
    8383         * Create a properties element.
    8484         */
    85         private Element parseProperty(OsmPrimitive osm, Entry<Key, String> entry) {
     85        private Element parseProperty(OsmPrimitive osm, long id, Entry<Key, String> entry) {
    8686                Element e = new Element("property");
    8787                Key key = entry.getKey();
    88                 e.setAttribute("uid", ""+osm.id);
     88                e.setAttribute("uid", ""+id);
    8989                e.setAttribute("key", key.name);
    9090                e.setAttribute("value", entry.getValue());
     
    104104                if (osm.keys != null)
    105105                        for (Entry<Key, String> entry : osm.keys.entrySet())
    106                                 properties.add(parseProperty(osm, entry));
     106                                properties.add(parseProperty(osm, id, entry));
    107107                if (osm.isDeleted())
    108108                        e.setAttribute("action", "delete");
Note: See TracChangeset for help on using the changeset viewer.