Ignore:
Timestamp:
2010-02-10T15:23:17+01:00 (14 years ago)
Author:
Gubaer
Message:

fixed #4392: exception in version history dialog on re-downloading a changed element

Location:
trunk/src/org/openstreetmap/josm/data/osm/history
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSet.java

    r2936 r2961  
    77import java.util.concurrent.CopyOnWriteArrayList;
    88
     9import org.openstreetmap.josm.Main;
    910import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1011import org.openstreetmap.josm.data.osm.PrimitiveId;
    1112import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
     13import org.openstreetmap.josm.gui.MapView;
     14import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
     15import org.openstreetmap.josm.gui.layer.Layer;
    1216import org.openstreetmap.josm.tools.CheckParameterUtil;
    1317
     
    1721 *
    1822 */
    19 public class HistoryDataSet {
     23public class HistoryDataSet implements LayerChangeListener{
    2024    //private final static Logger logger = Logger.getLogger(HistoryDataSet.class.getName());
    2125
     
    3135        if (historyDataSet == null) {
    3236            historyDataSet = new HistoryDataSet();
     37            MapView.addLayerChangeListener(historyDataSet);
    3338        }
    3439        return  historyDataSet;
     
    5762        for (HistoryDataSetListener l : listeners) {
    5863            l.historyUpdated(this, id);
     64        }
     65    }
     66
     67    protected void fireCacheCleared() {
     68        for (HistoryDataSetListener l : listeners) {
     69            l.historyDataSetCleared(this);
    5970        }
    6071    }
     
    151162        fireHistoryUpdated(null);
    152163    }
     164
     165    /* ------------------------------------------------------------------------------ */
     166    /* interface LayerChangeListener                                                  */
     167    /* ------------------------------------------------------------------------------ */
     168    public void activeLayerChange(Layer oldLayer, Layer newLayer) {/* irrelevant in this context */}
     169    public void layerAdded(Layer newLayer) {/* irrelevant in this context */}
     170    public void layerRemoved(Layer oldLayer) {
     171        if (Main.map == null || Main.map.mapView == null) return;
     172        if (Main.map.mapView.getNumLayers() == 0) {
     173            data.clear();
     174            fireCacheCleared();
     175        }
     176    }
    153177}
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSetListener.java

    r2512 r2961  
    55
    66public interface HistoryDataSetListener {
     7    /**
     8     * Fired by a {@see HistoryDataSet} if the cached history of an OSM primitive with
     9     * id <code>id</code> is updated
     10     *
     11     * @param source the data set firing the event
     12     * @param id the id of the updated primitive
     13     */
    714    void historyUpdated(HistoryDataSet source, PrimitiveId id);
     15
     16    /**
     17     * Fired by a {@see HistoryDataSet} if the history cached is cleared.
     18     *
     19     * @param source the history data set firing the event
     20     */
     21    void historyDataSetCleared(HistoryDataSet source);
    822}
Note: See TracChangeset for help on using the changeset viewer.