Changeset 319 in josm


Ignore:
Timestamp:
2007-09-04T10:21:49+02:00 (17 years ago)
Author:
imi
Message:
  • removed MinML2 dependency (use javax.xml)
  • fixed reorder action (thanks Robert)
  • added backup files before saving (thanks Dave)
  • added search for last modifying user (thanks Dave)
  • fixed import of plugin list and added author field (thanks Shaun)
Files:
1 added
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • build.xml

    r164 r319  
    55                <include name="gettext-commons-0.9.jar"/>
    66                <include name="metadata-extractor-2.3.1.jar"/>
    7                 <include name="MinML2.jar"/>
    87        </fileset>
    98
  • src/org/openstreetmap/josm/actions/ReorderAction.java

    r301 r319  
    1 // License: GPL. Copyright 2007 by Immanuel Scholz and others
     1//License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.actions;
    33
     
    1010import java.util.Iterator;
    1111import java.util.LinkedList;
     12import java.util.HashMap;
    1213
    1314import javax.swing.JOptionPane;
     
    2728        public ReorderAction() {
    2829                super(tr("Reorder Segments"), "reorder", tr("Try to reorder segments of a way so that they are in a line. May try to flip segments around to match a line."), KeyEvent.VK_R, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK, true);
    29     }
    30        
     30        }
     31
    3132        /**
    3233         * This method first sorts all the segments in a way, then makes sure that all
     
    3839                        if (osm instanceof Way)
    3940                                ways.add((Way)osm);
    40                
     41
    4142                if (ways.size() < 1) {
    4243                        JOptionPane.showMessageDialog(Main.parent, tr("Please select at least one way."));
    4344                        return;
    4445                }
    45                
     46
    4647                if (ways.size() > 1) {
    4748                        int answer = JOptionPane.showConfirmDialog(Main.parent,
    48                                 trn(null, "You selected more than one way. Reorder the segments of {0} ways?", ways.size(), ways.size()),
    49                                 tr("Reorder segments"), JOptionPane.OK_CANCEL_OPTION);
     49                                        trn(null, "You selected more than one way. Reorder the segments of {0} ways?", ways.size(), ways.size()),
     50                                        tr("Reorder segments"), JOptionPane.OK_CANCEL_OPTION);
    5051                        if (answer != JOptionPane.OK_OPTION)
    5152                                return;
     
    7576         * the segments are facing the same direction as the first one.
    7677         * @param way The way to reorder
    77     * @return The command needed to reorder the way
    78     */
    79     public static Command reorderWay(Way way) {
    80             final LinkedList<Segment> sel = new LinkedList<Segment>(sortSegments(new LinkedList<Segment>(way.segments), false));       
    81 
    82             Collection<Command> c = new LinkedList<Command>();
    83 
    84             boolean direction = false;
    85             // work out the "average" direction of the way, we use this to direct the rest of the segments
    86             int dirCounter = 0;
    87             for(int i = 0; i < sel.size() - 1; i++)
    88             {
    89                 Segment firstSegment = sel.get(i);
    90                 Segment secondSegment = sel.get(i+1);
    91                 if ( firstSegment.to == secondSegment.from || firstSegment.to == secondSegment.to ) // direction = true when 'from' is the first node in the Way
    92                         dirCounter++;
    93                 else
    94                         dirCounter--;
    95             }
    96             if ( dirCounter <= 0 )
    97                 direction = false;
    98             else
    99                 direction = true;
    100            
    101             Node lastNode = null;
    102 
    103             // we need to calculate what the first node in the way is, we work from there
    104             Segment firstSegment = sel.getFirst();
    105             Segment secondSegment = sel.get(1);
    106             if (firstSegment.to == secondSegment.from || firstSegment.to == secondSegment.to)
    107                 lastNode = firstSegment.from;
    108             else
    109                 lastNode = firstSegment.to;
    110            
    111             // go through each segment and flip them if required
    112             for (Segment s : sel) {
    113                 Segment snew = new Segment(s);
    114                 boolean segDirection = s.from == lastNode;
    115                 // segDirection = true when the 'from' node occurs before the 'to' node in the Way
    116                 if (direction != segDirection)
    117                 {                       
    118                         // reverse the segment's direction
    119                         Node n = snew.from;
    120                         snew.from = snew.to;
    121                         snew.to = n;
    122                         c.add(new ChangeCommand(s, snew));
    123                 }       
    124                
    125                 if (direction) // if its facing forwards,
    126                         lastNode = snew.to; // our next node is the 'to' one
    127                 else
    128                         lastNode = snew.from; // otherwise its the 'from' one
    129             }
    130 
    131             LinkedList<Segment> segments = new LinkedList<Segment>();
    132            
    133             // Now we recreate the segment list, in the correct order of the direction
    134             for (Segment s : sel)
    135                 if (!direction)
    136                         segments.addFirst(s);
    137                 else
    138                         segments.addLast(s);
    139                
    140             // Check if the new segment list is actually different from the old one
    141             // before we go and add a change command for it
    142             for(int i = 0; i < segments.size(); i++)
    143                 if (way.segments.get(i) != segments.get(i))
    144                 {
    145                         Way newWay = new Way(way);
    146                         newWay.segments.clear();
    147                         newWay.segments.addAll(segments);
    148                         c.add(new ChangeCommand(way, newWay));
    149                         break;
    150                 }
    151            
    152             // Check we've got some change commands before we add a sequence command
     78        * @return The command needed to reorder the way
     79        */
     80        public static Command reorderWay(Way way) {
     81                final LinkedList<Segment> sel = new LinkedList<Segment>(sortSegments(new LinkedList<Segment>(way.segments), false));   
     82
     83                Collection<Command> c = new LinkedList<Command>();
     84
     85                boolean direction = false;
     86                // work out the "average" direction of the way, we use this to direct the rest of the segments
     87                int dirCounter = 0;
     88                for(int i = 0; i < sel.size() - 1; i++)
     89                {
     90                        Segment firstSegment = sel.get(i);
     91                        Segment secondSegment = sel.get(i+1);
     92                        if ( firstSegment.to == secondSegment.from || firstSegment.to == secondSegment.to ) // direction = true when 'from' is the first node in the Way
     93                                dirCounter++;
     94                        else
     95                                dirCounter--;
     96                }
     97                if ( dirCounter <= 0 )
     98                        direction = false;
     99                else
     100                        direction = true;
     101
     102                Node lastNode = null;
     103
     104                // we need to calculate what the first node in the way is, we work from there
     105                Segment firstSegment = sel.getFirst();
     106                Segment secondSegment = sel.get(1);
     107                if (firstSegment.to == secondSegment.from || firstSegment.to == secondSegment.to)
     108                        lastNode = firstSegment.from;
     109                else
     110                        lastNode = firstSegment.to;
     111
     112                // go through each segment and flip them if required
     113                for (Segment s : sel) {
     114                        Segment snew = new Segment(s);
     115                        boolean segDirection = s.from == lastNode;
     116                        // segDirection = true when the 'from' node occurs before the 'to' node in the Way
     117                        if (direction != segDirection)
     118                        {                       
     119                                // reverse the segment's direction
     120                                Node n = snew.from;
     121                                snew.from = snew.to;
     122                                snew.to = n;
     123                                c.add(new ChangeCommand(s, snew));
     124                        }       
     125
     126                        if (direction) // if its facing forwards,
     127                                lastNode = snew.to; // our next node is the 'to' one
     128                        else
     129                                lastNode = snew.from; // otherwise its the 'from' one
     130                }
     131
     132                LinkedList<Segment> segments = new LinkedList<Segment>();
     133
     134                // Now we recreate the segment list, in the correct order of the direction
     135                for (Segment s : sel)
     136                        if (!direction)
     137                                segments.addFirst(s);
     138                        else
     139                                segments.addLast(s);
     140
     141                // Check if the new segment list is actually different from the old one
     142                // before we go and add a change command for it
     143                for(int i = 0; i < segments.size(); i++)
     144                        if (way.segments.get(i) != segments.get(i))
     145                        {
     146                                Way newWay = new Way(way);
     147                                newWay.segments.clear();
     148                                newWay.segments.addAll(segments);
     149                                c.add(new ChangeCommand(way, newWay));
     150                                break;
     151                        }
     152
     153                // Check we've got some change commands before we add a sequence command
    153154                if (c.size() != 0) {
    154155                        NameVisitor v = new NameVisitor();
     
    157158                }
    158159                return null;
    159     }
     160        }
    160161
    161162        /**
     
    168169         */
    169170        public static LinkedList<Segment> sortSegments(LinkedList<Segment> segments, boolean strict) {
    170                
     171
    171172                LinkedList<Segment> sortedSegments = new LinkedList<Segment>();
    172                
     173
    173174                while (!segments.isEmpty()) {
    174175                        LinkedList<Segment> pivotList = new LinkedList<Segment>();
    175                         pivotList.add(segments.getFirst());
    176                         segments.removeFirst();
     176                        pivotList.add(firstSegment(segments));
     177                        segments.remove(pivotList.getLast());
    177178                        boolean found;
    178179                        do {
    179180                                found = false;
     181                                //try working forwards first
    180182                                for (Iterator<Segment> it = segments.iterator(); it.hasNext();) {
    181183                                        Segment ls = it.next();
    182184                                        if (ls.incomplete)
    183185                                                continue; // incomplete segments are never added to a new way
    184                                         if (ls.from == pivotList.getLast().to || (!strict && (ls.to == pivotList.getLast().to || ls.from == pivotList.getLast().from || ls.to == pivotList.getLast().from))) {
     186                                        if (ls.from == pivotList.getLast().to) {
    185187                                                pivotList.addLast(ls);
    186188                                                it.remove();
    187189                                                found = true;
    188                                         } else if (ls.to == pivotList.getFirst().from || (!strict && (ls.from == pivotList.getFirst().from || ls.to == pivotList.getFirst().to || ls.from == pivotList.getFirst().to))) {
    189                                                 pivotList.addFirst(ls);
    190                                                 it.remove();
    191                                                 found = true;
     190                                        }
     191                                }
     192                                if(!found){
     193                                        for (Iterator<Segment> it = segments.iterator(); it.hasNext();) {
     194                                                Segment ls = it.next();
     195                                                if (ls.incomplete)
     196                                                        continue; // incomplete segments are never added to a new way
     197                                                if (ls.from == pivotList.getLast().to || (!strict && (ls.to == pivotList.getLast().to || ls.from == pivotList.getLast().from || ls.to == pivotList.getLast().from))) {
     198                                                        pivotList.addLast(ls);
     199                                                        it.remove();
     200                                                        found = true;
     201                                                } else if (ls.to == pivotList.getFirst().from || (!strict && (ls.from == pivotList.getFirst().from || ls.to == pivotList.getFirst().to || ls.from == pivotList.getFirst().to))) {
     202                                                        pivotList.addFirst(ls);
     203                                                        it.remove();
     204                                                        found = true;
     205                                                }
    192206                                        }
    193207                                }
     
    195209                        sortedSegments.addAll(pivotList);
    196210                }
    197             return sortedSegments;
    198         }
     211                return sortedSegments;
     212        }
     213
     214        /**
     215         * This method searches for a good segment to start a reorder from.
     216         * In most cases this will be a segment with a start node that occurs only
     217         * once in the way. In cases with loops, this could be any odd number. If no nodes
     218         * are referenced an odd number of times, then any segment is a good start point.
     219         */
     220        public static Segment firstSegment(Collection<Segment> segments) {
     221                HashMap<Node, Integer> refCount = new HashMap<Node, Integer>(segments.size()*2);
     222                //loop through all segments and count up how many times each node is referenced
     223                for (Segment seg : segments) {
     224                        if (!refCount.containsKey(seg.from))
     225                                refCount.put(seg.from, 0);
     226                        refCount.put(seg.from,refCount.get(seg.from)+1);
     227
     228                        if (!refCount.containsKey(seg.to))
     229                                refCount.put(seg.to, 0);
     230                        refCount.put(seg.to,refCount.get(seg.to)+1);
     231                }
     232
     233                //now look for start nodes that are referenced only once
     234                for (Segment seg : segments)
     235                        if (refCount.get(seg.from) == 1)
     236                                return seg;
     237                //now look for start nodes that are referenced only (2n+1)
     238                for (Segment seg : segments)
     239                        if (refCount.get(seg.from) % 2 == 1)
     240                                return seg;
     241                //now look for end nodes that are referenced only once
     242                for (Segment seg : segments)
     243                        if (refCount.get(seg.to) == 1)
     244                                return seg;
     245                //now look for end nodes that are referenced only (2n+1)
     246                for (Segment seg : segments)
     247                        if (refCount.get(seg.to) % 2 == 1)
     248                                return seg;
     249
     250                return segments.iterator().next();
     251        }   
    199252}
  • src/org/openstreetmap/josm/actions/SaveActionBase.java

    r299 r319  
    1 // License: GPL. Copyright 2007 by Immanuel Scholz and others
     1//License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.actions;
    33
     
    77import java.io.File;
    88import java.io.FileOutputStream;
     9import java.io.FileInputStream;
     10import java.io.FileNotFoundException;
    911import java.io.IOException;
    1012
     
    3739                        return;
    3840
    39                
     41
    4042                File file = getFile(layer);
    4143                if (file == null)
     
    4850                Main.parent.repaint();
    4951        }
    50        
     52
    5153        protected abstract File getFile(OsmDataLayer layer);
    5254
     
    5759         */
    5860        public boolean checkSaveConditions(OsmDataLayer layer) {
    59         if (Main.map == null) {
    60                 JOptionPane.showMessageDialog(Main.parent, tr("No document open so nothing to save."));
    61                 return false;
    62         }
    63         if (isDataSetEmpty(layer) && JOptionPane.NO_OPTION == JOptionPane.showConfirmDialog(Main.parent,tr("The document contains no data. Save anyway?"), tr("Empty document"), JOptionPane.YES_NO_OPTION))
    64                 return false;
    65         if (!Main.map.conflictDialog.conflicts.isEmpty()) {
    66                 int answer = JOptionPane.showConfirmDialog(Main.parent,
    67                                 tr("There are unresolved conflicts. Conflicts will not be saved and handled as if you rejected all. Continue?"),tr("Conflicts"), JOptionPane.YES_NO_OPTION);
    68                 if (answer != JOptionPane.YES_OPTION)
    69                         return false;
    70         }
    71         return true;
    72     }
     61                if (Main.map == null) {
     62                        JOptionPane.showMessageDialog(Main.parent, tr("No document open so nothing to save."));
     63                        return false;
     64                }
     65                if (isDataSetEmpty(layer) && JOptionPane.NO_OPTION == JOptionPane.showConfirmDialog(Main.parent,tr("The document contains no data. Save anyway?"), tr("Empty document"), JOptionPane.YES_NO_OPTION))
     66                        return false;
     67                if (!Main.map.conflictDialog.conflicts.isEmpty()) {
     68                        int answer = JOptionPane.showConfirmDialog(Main.parent,
     69                                        tr("There are unresolved conflicts. Conflicts will not be saved and handled as if you rejected all. Continue?"),tr("Conflicts"), JOptionPane.YES_NO_OPTION);
     70                        if (answer != JOptionPane.YES_OPTION)
     71                                return false;
     72                }
     73                return true;
     74        }
    7375
    7476        public static File openFileDialog() {
    75         JFileChooser fc = createAndOpenFileChooser(false, false);
    76         if (fc == null)
    77                 return null;
    78    
    79         File file = fc.getSelectedFile();
    80    
    81         String fn = file.getPath();
    82         if (fn.indexOf('.') == -1) {
    83                 FileFilter ff = fc.getFileFilter();
    84                 if (ff instanceof ExtensionFileFilter)
    85                         fn = "." + ((ExtensionFileFilter)ff).defaultExtension;
    86                 else
    87                         fn += ".osm";
    88                 file = new File(fn);
    89         }
    90         return file;
    91     }
    92        
     77                JFileChooser fc = createAndOpenFileChooser(false, false);
     78                if (fc == null)
     79                        return null;
     80
     81                File file = fc.getSelectedFile();
     82
     83                String fn = file.getPath();
     84                if (fn.indexOf('.') == -1) {
     85                        FileFilter ff = fc.getFileFilter();
     86                        if (ff instanceof ExtensionFileFilter)
     87                                fn = "." + ((ExtensionFileFilter)ff).defaultExtension;
     88                        else
     89                                fn += ".osm";
     90                        file = new File(fn);
     91                }
     92                return file;
     93        }
     94
     95        private static void copy(File src, File dst) throws IOException {
     96                FileInputStream srcStream;
     97                FileOutputStream dstStream;
     98                try {
     99                        srcStream = new FileInputStream(src);
     100                        dstStream = new FileOutputStream(dst);
     101                } catch (FileNotFoundException e) {
     102                        JOptionPane.showMessageDialog(Main.parent, tr("Could not back up file.")+"\n"+e.getMessage());
     103                        return;
     104                }
     105                byte buf[] = new byte[1<<16];
     106                int len;
     107                while ((len = srcStream.read(buf)) != -1) {
     108                        dstStream.write(buf, 0, len);
     109                }
     110                srcStream.close();
     111                dstStream.close();
     112        }
     113
    93114        public static void save(File file, OsmDataLayer layer) {
    94             try {
     115                File tmpFile = null;
     116                try {
    95117                        if (ExtensionFileFilter.filters[ExtensionFileFilter.GPX].acceptName(file.getPath())) {
    96118                                GpxExportAction.exportGpx(file, layer);
    97119                        } else if (ExtensionFileFilter.filters[ExtensionFileFilter.OSM].acceptName(file.getPath())) {
     120                                // use a tmp file because if something errors out in the
     121                                // process of writing the file, we might just end up with
     122                                // a truncated file.  That can destroy lots of work.
     123                                if (file.exists()) {
     124                                        tmpFile = new File(file.getPath() + "~");
     125                                        copy(file, tmpFile);
     126                                }
    98127                                OsmWriter.output(new FileOutputStream(file), new OsmWriter.All(layer.data, false));
     128                                if (!Main.pref.getBoolean("save.keepbackup"))
     129                                        tmpFile.delete();
    99130                        } else if (ExtensionFileFilter.filters[ExtensionFileFilter.CSV].acceptName(file.getPath())) {
    100131                                JOptionPane.showMessageDialog(Main.parent, tr("CSV output not supported yet."));
     
    109140                        JOptionPane.showMessageDialog(Main.parent, tr("An error occurred while saving.")+"\n"+e.getMessage());
    110141                }
    111     }
    112        
     142                try {
     143                        // if the file save failed, then the tempfile will not
     144                        // be deleted.  So, restore the backup if we made one.
     145                        if (tmpFile != null && tmpFile.exists()) {
     146                                copy(tmpFile, file);
     147                        }
     148                } catch (IOException e) {
     149                        e.printStackTrace();
     150                        JOptionPane.showMessageDialog(Main.parent, tr("An error occurred while restoring backup file.")+"\n"+e.getMessage());
     151                }
     152        }
     153
    113154        /**
    114155         * Check the data set if it would be empty on save. It is empty, if it contains
  • src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r298 r319  
    9494                        if (osm.keys == null)
    9595                                return s.equals("");
     96                        String search = caseSensitive ? s : s.toLowerCase();
    9697                        for (Entry<String, String> e : osm.keys.entrySet()) {
    9798                                String key = caseSensitive ? e.getKey() : e.getKey().toLowerCase();
    9899                                String value = caseSensitive ? e.getValue() : e.getValue().toLowerCase();
    99                                 String search = caseSensitive ? s : s.toLowerCase();
    100100                                if (key.indexOf(search) != -1 || value.indexOf(search) != -1)
     101                                        return true;
     102                        }
     103                        if (osm.user != null) {
     104                                String name = osm.user.name;
     105                                if (!caseSensitive)
     106                                        name = name.toLowerCase();
     107                                if (name.indexOf(search) != -1)
    101108                                        return true;
    102109                        }
  • src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

    r315 r319  
    66import java.awt.Graphics2D;
    77import java.awt.Point;
    8 import java.awt.Polygon;
    98import java.awt.Rectangle;
    109import java.awt.geom.GeneralPath;
  • src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java

    r317 r319  
    1 // License: GPL. Copyright 2007 by Immanuel Scholz and others
     1//License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.gui.layer;
    33
     
    104104                                                throw new IOException(tr("No time for point {0} x {1}",p.latlon.lat(),p.latlon.lon()));
    105105                                        Date d = null;
    106                     try {
    107                         d = DateParser.parse(p.time);
    108                     } catch (ParseException e) {
    109                         throw new IOException(tr("Cannot read time \"{0}\" from point {1} x {2}",p.time,p.latlon.lat(),p.latlon.lon()));
    110                     }
     106                                        try {
     107                                                d = DateParser.parse(p.time);
     108                                        } catch (ParseException e) {
     109                                                throw new IOException(tr("Cannot read time \"{0}\" from point {1} x {2}",p.time,p.latlon.lat(),p.latlon.lon()));
     110                                        }
    111111                                        gps.add(new TimedPoint(d, p.eastNorth));
    112112                                }
     
    130130                                ImageEntry e = new ImageEntry();
    131131                                try {
    132                         e.time = ExifReader.readTime(f);
    133                 } catch (ParseException e1) {
    134                         continue;
    135                 }
     132                                        e.time = ExifReader.readTime(f);
     133                                } catch (ParseException e1) {
     134                                        continue;
     135                                }
    136136                                if (e.time == null)
    137137                                        continue;
     
    163163        private static final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    164164        private MouseAdapter mouseAdapter;
    165     private int currentImage;
    166    
     165        private int currentImage;
     166
    167167        public static final class GpsTimeIncorrect extends Exception {
    168168                public GpsTimeIncorrect(String message, Throwable cause) {
     
    218218                                        Rectangle r = new Rectangle(p.x-e.icon.getIconWidth()/2, p.y-e.icon.getIconHeight()/2, e.icon.getIconWidth(), e.icon.getIconHeight());
    219219                                        if (r.contains(ev.getPoint())) {
    220                                             //                                          showImage(e);
    221                                             showImage(i-1);
     220                                                showImage(i-1);
    222221                                                break;
    223222                                        }
     
    236235        }
    237236
    238     //  private void showImage(final ImageEntry e) {
    239237        private void showImage(int i) {
    240             currentImage = i;
     238                currentImage = i;
    241239                final JPanel p = new JPanel(new BorderLayout());
    242240                final ImageEntry e = data.get(currentImage);
     
    273271                cent.addActionListener(new ActionListener(){
    274272                        public void actionPerformed(ActionEvent ev) {
    275                             final ImageEntry e = data.get(currentImage);
    276                             if (cent.getModel().isSelected())
    277                                 Main.map.mapView.zoomTo(e.pos, Main.map.mapView.getScale());
    278                         }
    279                     });
     273                                final ImageEntry e = data.get(currentImage);
     274                                if (cent.getModel().isSelected())
     275                                        Main.map.mapView.zoomTo(e.pos, Main.map.mapView.getScale());
     276                        }
     277                });
    280278
    281279                ActionListener nextprevAction = new ActionListener(){
    282280                        public void actionPerformed(ActionEvent ev) {                       
    283                             p.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    284                             if (ev.getActionCommand().equals("Next")) {
    285                                 currentImage++;
    286                                 if(currentImage>=data.size()-1) next.setEnabled(false);
    287                                 prev.setEnabled(true);
    288                             } else {
    289                                 currentImage--;
    290                                 if(currentImage<=0) prev.setEnabled(false);
    291                                 next.setEnabled(true);
    292                             }
    293                            
    294                             final ImageEntry e = data.get(currentImage);
    295                             if (scale.getModel().isSelected())
    296                                 ((JLabel)vp.getView()).setIcon(loadScaledImage(e.image, Math.max(vp.getWidth(), vp.getHeight())));
    297                             else
    298                                 ((JLabel)vp.getView()).setIcon(new ImageIcon(e.image.getPath()));
    299                             dlg.setTitle(e.image+" ("+e.coor.toDisplayString()+")");
    300                             if (cent.getModel().isSelected())
    301                                 Main.map.mapView.zoomTo(e.pos, Main.map.mapView.getScale());
    302                             p.setCursor(Cursor.getDefaultCursor());
    303                         }
    304                     };
     281                                p.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
     282                                if (ev.getActionCommand().equals("Next")) {
     283                                        currentImage++;
     284                                        if(currentImage>=data.size()-1) next.setEnabled(false);
     285                                        prev.setEnabled(true);
     286                                } else {
     287                                        currentImage--;
     288                                        if(currentImage<=0) prev.setEnabled(false);
     289                                        next.setEnabled(true);
     290                                }
     291
     292                                final ImageEntry e = data.get(currentImage);
     293                                if (scale.getModel().isSelected())
     294                                        ((JLabel)vp.getView()).setIcon(loadScaledImage(e.image, Math.max(vp.getWidth(), vp.getHeight())));
     295                                else
     296                                        ((JLabel)vp.getView()).setIcon(new ImageIcon(e.image.getPath()));
     297                                dlg.setTitle(e.image+" ("+e.coor.toDisplayString()+")");
     298                                if (cent.getModel().isSelected())
     299                                        Main.map.mapView.zoomTo(e.pos, Main.map.mapView.getScale());
     300                                p.setCursor(Cursor.getDefaultCursor());
     301                        }
     302                };
    305303                next.setActionCommand("Next");
    306304                prev.setActionCommand("Previous");
     
    453451        private void sync(File f) {
    454452                Date exifDate;
    455         try {
    456                 exifDate = ExifReader.readTime(f);
    457         } catch (ParseException e) {
    458                 JOptionPane.showMessageDialog(Main.parent, tr("The date in file \"{0}\" could not be parsed.", f.getName()));
    459                 return;
    460         }
     453                try {
     454                        exifDate = ExifReader.readTime(f);
     455                } catch (ParseException e) {
     456                        JOptionPane.showMessageDialog(Main.parent, tr("The date in file \"{0}\" could not be parsed.", f.getName()));
     457                        return;
     458                }
    461459                if (exifDate == null) {
    462460                        JOptionPane.showMessageDialog(Main.parent, tr("There is no EXIF time within the file \"{0}\".", f.getName()));
     
    489487                                gpstimezone = Long.valueOf(time)*60*60*1000;
    490488                                Main.pref.put("tagimages.delta", ""+delta);
    491                 Main.pref.put("tagimages.gpstimezone", time);
     489                                Main.pref.put("tagimages.gpstimezone", time);
    492490                                calculatePosition();
    493491                                return;
  • src/org/openstreetmap/josm/gui/preferences/CsvPreference.java

    r298 r319  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import javax.swing.Box;
    76import javax.swing.JLabel;
    87import javax.swing.JTextField;
     
    3130                gui.connection.add(new JLabel(tr("CSV import specification (empty: read from first line in data)")), GBC.eol());
    3231                gui.connection.add(csvImportString, GBC.eop().fill(GBC.HORIZONTAL));
    33                 gui.connection.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
    3432    }
    3533
  • src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java

    r298 r319  
    103103                settings.add(new ServerAccessPreference());
    104104                settings.add(new CsvPreference());
     105                settings.add(new FilePreferences());
    105106                settings.add(new ProjectionPreference());
    106107                settings.add(new TaggingPresetPreference());
  • src/org/openstreetmap/josm/io/IncompleteDownloader.java

    r301 r319  
    1010import java.io.InputStreamReader;
    1111import java.io.StringReader;
     12import java.util.ArrayList;
    1213import java.util.Collection;
    13 import java.util.ArrayList;
     14
     15import javax.swing.JOptionPane;
     16import javax.xml.parsers.ParserConfigurationException;
     17import javax.xml.parsers.SAXParserFactory;
    1418
    1519import org.openstreetmap.josm.Main;
     20import org.openstreetmap.josm.command.ChangeCommand;
     21import org.openstreetmap.josm.command.Command;
     22import org.openstreetmap.josm.command.SequenceCommand;
    1623import org.openstreetmap.josm.data.osm.DataSet;
    1724import org.openstreetmap.josm.data.osm.Node;
     
    2027import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;
    2128import org.xml.sax.Attributes;
     29import org.xml.sax.InputSource;
    2230import org.xml.sax.SAXException;
    23 
    24 import javax.swing.JOptionPane;
    25 import org.openstreetmap.josm.command.ChangeCommand;
    26 import org.openstreetmap.josm.command.Command;
    27 import org.openstreetmap.josm.command.SequenceCommand;
    28 
    29 import uk.co.wilson.xml.MinML2;
     31import org.xml.sax.helpers.DefaultHandler;
    3032
    3133/**
     
    8082        }
    8183
    82         private static class SegmentParser extends MinML2 {
     84        private static class SegmentParser extends DefaultHandler {
    8385                public long from, to;
    8486                @Override public void startElement(String ns, String lname, String qname, Attributes a) {
     
    133135                                segBuilder.append(line+"\n");
    134136                        SegmentParser segmentParser = new SegmentParser();
    135                         segmentParser.parse(new StringReader(segBuilder.toString()));
     137                        try {
     138                        SAXParserFactory.newInstance().newSAXParser().parse(new InputSource(new StringReader(segBuilder.toString())), segmentParser);
     139                } catch (ParserConfigurationException e1) {
     140                        e1.printStackTrace(); // broken SAXException chaining
     141                        throw new SAXException(e1);
     142                }
    136143                        if (segmentParser.from == 0 || segmentParser.to == 0)
    137144                                throw new SAXException("Invalid segment response.");
  • src/org/openstreetmap/josm/io/OsmIdReader.java

    r298 r319  
    1111import java.util.Map;
    1212
     13import javax.xml.parsers.ParserConfigurationException;
     14import javax.xml.parsers.SAXParserFactory;
     15
    1316import org.xml.sax.Attributes;
     17import org.xml.sax.InputSource;
    1418import org.xml.sax.SAXException;
    15 
    16 import uk.co.wilson.xml.MinML2;
     19import org.xml.sax.helpers.DefaultHandler;
    1720
    1821/**
     
    2124 * @author Imi
    2225 */
    23 public class OsmIdReader extends MinML2 {
     26public class OsmIdReader extends DefaultHandler {
    2427
    2528        private boolean cancel;
     
    4144        this.in = new InputStreamReader(in, "UTF-8");
    4245                try {
    43                 parse(this.in);
     46                SAXParserFactory.newInstance().newSAXParser().parse(new InputSource(this.in), this);
     47        } catch (ParserConfigurationException e) {
     48                if (!cancel) {
     49                        e.printStackTrace(); // broken SAXException chaining
     50                        throw new SAXException(e);
     51                }
    4452        } catch (SAXException e) {
    4553                if (!cancel)
  • src/org/openstreetmap/josm/io/OsmReader.java

    r298 r319  
    1515import java.util.Map;
    1616import java.util.Map.Entry;
     17
     18import javax.xml.parsers.ParserConfigurationException;
     19import javax.xml.parsers.SAXParserFactory;
    1720
    1821import org.openstreetmap.josm.Main;
     
    3134import org.openstreetmap.josm.tools.DateParser;
    3235import org.xml.sax.Attributes;
     36import org.xml.sax.InputSource;
    3337import org.xml.sax.SAXException;
    34 
    35 import uk.co.wilson.xml.MinML2;
     38import org.xml.sax.helpers.DefaultHandler;
    3639
    3740/**
     
    103106        private HashSet<String> allowedVersions = new HashSet<String>();
    104107
    105         private class Parser extends MinML2 {
     108        private class Parser extends DefaultHandler {
    106109                /**
    107110                 * The current osm primitive to be read.
     
    296299
    297300                // phase 1: Parse nodes and read in raw segments and ways
    298                 osm.new Parser().parse(new InputStreamReader(source, "UTF-8"));
     301                InputSource inputSource = new InputSource(new InputStreamReader(source, "UTF-8"));
     302                try {
     303                SAXParserFactory.newInstance().newSAXParser().parse(inputSource, osm.new Parser());
     304        } catch (ParserConfigurationException e1) {
     305                e1.printStackTrace(); // broken SAXException chaining
     306                throw new SAXException(e1);
     307        }
    299308                if (pleaseWaitDlg != null) {
    300309                        pleaseWaitDlg.progress.setValue(0);
  • src/org/openstreetmap/josm/io/RawGpsReader.java

    r298 r319  
    1414import java.util.Stack;
    1515
     16import javax.xml.parsers.ParserConfigurationException;
     17import javax.xml.parsers.SAXParserFactory;
     18
    1619import org.openstreetmap.josm.data.coor.LatLon;
    1720import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint;
     
    1922import org.openstreetmap.josm.gui.layer.markerlayer.MarkerProducers;
    2023import org.xml.sax.Attributes;
     24import org.xml.sax.InputSource;
    2125import org.xml.sax.SAXException;
    22 
    23 import uk.co.wilson.xml.MinML2;
     26import org.xml.sax.helpers.DefaultHandler;
    2427
    2528/**
     
    4649        public Collection<Marker> markerData = new ArrayList<Marker>();
    4750
    48         private class Parser extends MinML2 {
     51        private class Parser extends DefaultHandler {
    4952                /**
    5053                 * Current track to be read. The last entry is the current trkpt.
     
    127130                this.relativeMarkerPath = relativeMarkerPath;
    128131                Parser parser = new Parser();
    129                 parser.parse(new InputStreamReader(source, "UTF-8"));
     132                InputSource inputSource = new InputSource(new InputStreamReader(source, "UTF-8"));
     133                try {
     134                        SAXParserFactory.newInstance().newSAXParser().parse(inputSource, parser);
     135        } catch (ParserConfigurationException e) {
     136                e.printStackTrace(); // broken SAXException chaining
     137                throw new SAXException(e);
     138        }
    130139        }
    131140}
  • src/org/openstreetmap/josm/plugins/PluginDownloader.java

    r300 r319  
    6565        }
    6666
    67         private static final Pattern wiki = Pattern.compile("^</td></tr><tr><td><a class=\"ext-link\" href=\"([^\"]*)\"><span class=\"icon\">([^<]*)</span></a></td><td>[^<]*</td><td>([^<]*)</td><td>(.*)");
     67        private static final Pattern wiki = Pattern.compile("^</td></tr><tr><td><a class=\"ext-link\" href=\"([^\"]*)\"><span class=\"icon\">([^<]*)</span></a></td><td>([^<]*)</td><td>([^<].*)</td><td>(.*)");
    6868
    6969        public static int downloadDescription() {
     
    109109                        b.append("    <name>"+escape(m.group(2))+"</name>\n");
    110110                        b.append("    <resource>"+escape(m.group(1))+"</resource>\n");
    111                         b.append("    <description>"+escape(m.group(3))+"</description>\n");
    112                         b.append("    <version>"+escape(m.group(4))+"</version>\n");
     111                        b.append("    <author>"+escape(m.group(3))+"</author>\n");
     112                        b.append("    <description>"+escape(m.group(4))+"</description>\n");
     113                        b.append("    <version>"+escape(m.group(5))+"</version>\n");
    113114                        b.append("  </plugin>\n");
    114115                }
  • src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r298 r319  
    1414import java.util.concurrent.BlockingQueue;
    1515
     16import javax.xml.parsers.SAXParserFactory;
     17
    1618import org.xml.sax.Attributes;
     19import org.xml.sax.InputSource;
    1720import org.xml.sax.SAXException;
    18 
    19 import uk.co.wilson.xml.MinML2;
     21import org.xml.sax.helpers.DefaultHandler;
    2022
    2123/**
     
    4749        }
    4850
    49         private class Parser extends MinML2 {
     51        private class Parser extends DefaultHandler {
    5052                Stack<Object> current = new Stack<Object>();
    5153                String characters = "";
     
    169171                        @Override public void run() {
    170172                                try {
    171                                         parser.parse(in);
     173                                SAXParserFactory.newInstance().newSAXParser().parse(new InputSource(in), parser);
    172174                                } catch (Exception e) {
    173175                                        try {
Note: See TracChangeset for help on using the changeset viewer.