Ignore:
Timestamp:
2009-06-06T21:39:12+02:00 (15 years ago)
Author:
stoecker
Message:

cleanup in file access

Location:
trunk/src/org/openstreetmap/josm/gui/layer
Files:
5 edited

Legend:

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

    r1638 r1646  
    175175                                namedTrackPoints.waypoints.add(point);
    176176
    177                 MarkerLayer ml = new MarkerLayer(namedTrackPoints, tr("Named Trackpoints from {0}", name), associatedFile, me);
     177                MarkerLayer ml = new MarkerLayer(namedTrackPoints, tr("Named Trackpoints from {0}", name), getAssociatedFile(), me);
    178178                if (ml.data.size() > 0) {
    179179                    Main.main.addLayer(ml);
     
    203203                        Main.pref.put("markers.lastaudiodirectory", fc.getCurrentDirectory().getAbsolutePath());
    204204
    205                     MarkerLayer ml = new MarkerLayer(new GpxData(), tr("Audio markers from {0}", name), associatedFile, me);
     205                    MarkerLayer ml = new MarkerLayer(new GpxData(), tr("Audio markers from {0}", name), getAssociatedFile(), me);
    206206                    File sel[] = fc.getSelectedFiles();
    207207                    if(sel != null) {
     
    270270                new JMenuItem(new ConvertToDataLayerAction()),
    271271                new JSeparator(),
    272                 new JMenuItem(new RenameLayerAction(associatedFile, this)),
     272                new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)),
    273273                new JSeparator(),
    274274                new JMenuItem(new LayerListPopup.InfoAction(this))};
     
    287287            new JMenuItem(new DownloadAlongTrackAction()),
    288288            new JSeparator(),
    289             new JMenuItem(new RenameLayerAction(associatedFile, this)),
     289            new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)),
    290290            new JSeparator(),
    291291            new JMenuItem(new LayerListPopup.InfoAction(this))};
     
    680680            }
    681681            Main.main.addLayer(new OsmDataLayer(ds, tr("Converted from: {0}", GpxLayer.this.name),
    682                         data.storageFile));
     682                        getAssociatedFile()));
    683683            Main.main.removeLayer(GpxLayer.this);
    684684        }
    685685    }
     686
     687    public File getAssociatedFile() { return data.storageFile; }
     688    public void setAssociatedFile(File file) { data.storageFile = file; }
    686689
    687690    /**
     
    932935            double duration = AudioUtil.getCalibratedDuration(wavFile);
    933936            double startTime = lastModified - duration;
    934             startTime = firstStartTime + (startTime - firstStartTime) / 
     937            startTime = firstStartTime + (startTime - firstStartTime) /
    935938                Main.pref.getDouble("audio.calibration", "1.0" /* default, ratio */);
    936939            WayPoint w1 = null;
     
    949952                    if (w2 != null) break;
    950953                }
    951             }   
     954            }
    952955
    953956            if (w1 == null || w2 == null) {
     
    964967                wayPointFromTimeStamp.attr.put("name", name);
    965968                waypoints.add(wayPointFromTimeStamp);
    966             }           
    967         }
    968        
     969            }
     970        }
     971
    969972        // (e) analyse audio for spoken markers here, in due course
    970973
     
    10131016                    name, uri, ml, w.time, offset);
    10141017            /* timeFromAudio intended for future use to shift markers of this type on synchronization */
    1015             if (w == wayPointFromTimeStamp) { 
    1016                 am.timeFromAudio = true; 
     1018            if (w == wayPointFromTimeStamp) {
     1019                am.timeFromAudio = true;
    10171020            }
    10181021            ml.data.add(am);
  • trunk/src/org/openstreetmap/josm/gui/layer/Layer.java

    r1508 r1646  
    6565     * If a file is associated with this layer, this variable should be set to it.
    6666     */
    67     public File associatedFile;
     67    private File associatedFile;
    6868
    6969    /**
     
    120120     */
    121121    public void destroy() {}
     122
     123    public File getAssociatedFile() { return associatedFile; }
     124    public void setAssociatedFile(File file) { associatedFile = file; }
    122125}
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r1640 r1646  
    152152        super(name);
    153153        this.data = data;
    154         this.associatedFile = associatedFile;
     154        this.setAssociatedFile(associatedFile);
    155155    }
    156156
     
    217217        tool += undeletedSize(data.ways)+" "+trn("way", "ways", undeletedSize(data.ways));
    218218        if (data.version != null) tool += ", " + tr("version {0}", data.version);
    219         if (associatedFile != null)
    220             tool = "<html>"+tool+"<br>"+associatedFile.getPath()+"</html>";
     219        File f = getAssociatedFile();
     220        if (f != null)
     221            tool = "<html>"+tool+"<br>"+f.getPath()+"</html>";
    221222        return tool;
    222223    }
     
    307308
    308309        // update the modified flag
    309         if (associatedFile != null && processed != null && !dataAdded)
     310        boolean b = (getAssociatedFile() != null && processed != null);
     311        if (b && !dataAdded)
    310312            return; // do nothing when uploading non-harmful changes.
    311313
    312314        // modified if server changed the data (esp. the id).
    313         uploadedModified = associatedFile != null && processed != null && dataAdded;
     315        uploadedModified = b && dataAdded;
    314316        setModified(uploadedModified);
    315317    }
     
    378380                    new JMenuItem(new LayerListDialog.DeleteLayerAction(this)),
    379381                    new JSeparator(),
    380                     new JMenuItem(new RenameLayerAction(associatedFile, this)),
     382                    new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)),
    381383                    new JSeparator(),
    382384                    new JMenuItem(new LayerListPopup.InfoAction(this))};
     
    391393                new JMenuItem(new ConvertToGpxLayerAction()),
    392394                new JSeparator(),
    393                 new JMenuItem(new RenameLayerAction(associatedFile, this)),
     395                new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)),
    394396                new JSeparator(),
    395397                new JMenuItem(new LayerListPopup.InfoAction(this))};
     
    454456
    455457    public GpxData toGpxData() {
    456         return toGpxData(data, associatedFile);
     458        return toGpxData(data, getAssociatedFile());
    457459    }
    458460
  • trunk/src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java

    r1589 r1646  
    107107        super(name);
    108108        this.fromServer = fromServer;
    109         this.associatedFile = associatedFile;
     109        setAssociatedFile(associatedFile);
    110110        this.data = data;
    111111        Main.pref.listener.add(this);
     
    151151        String tool = data.size()+" "+trn("track", "tracks", data.size())
    152152        +" "+points+" "+trn("point", "points", points);
    153         if (associatedFile != null)
    154             tool = "<html>"+tool+"<br>"+associatedFile.getPath()+"</html>";
     153        File f = getAssociatedFile();
     154        if (f != null)
     155            tool = "<html>"+tool+"<br>"+f.getPath()+"</html>";
    155156        return tool;
    156157    }
     
    242243                new JMenuItem(new ConvertToDataLayerAction()),
    243244                new JSeparator(),
    244                 new JMenuItem(new RenameLayerAction(associatedFile, this)),
     245                new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)),
    245246                new JSeparator(),
    246247                new JMenuItem(new LayerListPopup.InfoAction(this))};
     
    254255                new JMenuItem(new ConvertToDataLayerAction()),
    255256                new JSeparator(),
    256                 new JMenuItem(new RenameLayerAction(associatedFile, this)),
     257                new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)),
    257258                new JSeparator(),
    258259                new JMenuItem(new LayerListPopup.InfoAction(this))};
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r1601 r1646  
    7171
    7272        super(name);
    73         this.associatedFile = associatedFile;
     73        this.setAssociatedFile(associatedFile);
    7474        this.data = new ArrayList<Marker>();
    7575        this.fromLayer = fromLayer;
     
    258258            components.add (moveaudio);
    259259        }
    260         components.add(new JMenuItem(new RenameLayerAction(associatedFile, this)));
     260        components.add(new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)));
    261261        components.add(new JSeparator());
    262262        components.add(new JMenuItem(new LayerListPopup.InfoAction(this)));
Note: See TracChangeset for help on using the changeset viewer.