Ignore:
Timestamp:
2006-09-09T00:18:24+02:00 (20 years ago)
Author:
imi
Message:
  • added feature "Save" (old save is now "Save as")
  • added feature to rename a layer
  • fixed bug that geo-images pop up more than once
  • fixed bug where you could try to change properties for 0 objects
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java

    r137 r138  
    2424import javax.swing.JRadioButton;
    2525import javax.swing.JSeparator;
     26import javax.swing.SwingUtilities;
    2627import javax.swing.filechooser.FileFilter;
    2728
    2829import org.openstreetmap.josm.Main;
    2930import org.openstreetmap.josm.actions.GpxExportAction;
     31import org.openstreetmap.josm.actions.RenameLayerAction;
    3032import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
    3133import org.openstreetmap.josm.data.coor.EastNorth;
     
    3739import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    3840import org.openstreetmap.josm.gui.MapView;
     41import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    3942import org.openstreetmap.josm.gui.dialogs.LayerList;
    4043import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
     
    7174                                ds.ways.add(w);
    7275                        }
    73                         Main.main.addLayer(new OsmDataLayer(ds, tr("Data Layer"), true));
     76                        Main.main.addLayer(new OsmDataLayer(ds, tr("Data Layer"), null));
    7477                        Main.main.removeLayer(RawGpsLayer.this);
    7578        }
     
    9295        public final Collection<Collection<GpsPoint>> data;
    9396
    94         public RawGpsLayer(Collection<Collection<GpsPoint>> data, String name) {
     97        public RawGpsLayer(Collection<Collection<GpsPoint>> data, String name, File associatedFile) {
    9598                super(name);
     99                this.associatedFile = associatedFile;
    96100                this.data = data;
    97101                Main.pref.listener.add(this);
     102                SwingUtilities.invokeLater(new Runnable(){
     103                        public void run() {
     104                                Main.map.mapView.addLayerChangeListener(new LayerChangeListener(){
     105                                        public void activeLayerChange(Layer oldLayer, Layer newLayer) {}
     106                                        public void layerAdded(Layer newLayer) {}
     107                                        public void layerRemoved(Layer oldLayer) {
     108                                                Main.pref.listener.remove(RawGpsLayer.this);
     109                                        }
     110                                });
     111            }
     112                });
    98113        }
    99114
     
    142157                for (Collection<GpsPoint> c : data)
    143158                        points += c.size();
    144                 return data.size()+" "+trn("track", "tracks", data.size())
     159                String tool = data.size()+" "+trn("track", "tracks", data.size())
    145160                +" "+points+" "+trn("point", "points", points);
     161                if (associatedFile != null)
     162                        tool = "<html>"+tool+"<br>"+associatedFile.getPath()+"</html>";
     163                return tool;
    146164        }
    147165
     
    169187                }
    170188                b.append("</html>");
    171                 return "<html>"+tr("{0} consists of {1} track", "{0} consists of {1} tracks", data.size(), name, data.size())+" ("+trn("{0} point", "{0} points", points, points)+")<br>"+b.toString();
     189                return "<html>"+trn("{0} consists of {1} track", "{0} consists of {1} tracks", data.size(), name, data.size())+" ("+trn("{0} point", "{0} points", points, points)+")<br>"+b.toString();
    172190        }
    173191
     
    257275            }
    258276                });
     277               
    259278                return new Component[]{
    260279                                new JMenuItem(new LayerList.ShowHideLayerAction(this)),
     
    267286                                new JMenuItem(new ConvertToDataLayerAction()),
    268287                                new JSeparator(),
     288                                new JMenuItem(new RenameLayerAction(associatedFile, this)),
     289                                new JSeparator(),
    269290                                new JMenuItem(new LayerListPopup.InfoAction(this))};
    270291    }
     
    274295                        Main.map.repaint();
    275296        }
    276 
    277         @Override public void layerRemoved() {
    278                 Main.pref.listener.remove(this);
    279     }
    280297}
Note: See TracChangeset for help on using the changeset viewer.