- Timestamp:
- 2010-02-10T15:23:17+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSet.java
r2936 r2961 7 7 import java.util.concurrent.CopyOnWriteArrayList; 8 8 9 import org.openstreetmap.josm.Main; 9 10 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 10 11 import org.openstreetmap.josm.data.osm.PrimitiveId; 11 12 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 13 import org.openstreetmap.josm.gui.MapView; 14 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 15 import org.openstreetmap.josm.gui.layer.Layer; 12 16 import org.openstreetmap.josm.tools.CheckParameterUtil; 13 17 … … 17 21 * 18 22 */ 19 public class HistoryDataSet {23 public class HistoryDataSet implements LayerChangeListener{ 20 24 //private final static Logger logger = Logger.getLogger(HistoryDataSet.class.getName()); 21 25 … … 31 35 if (historyDataSet == null) { 32 36 historyDataSet = new HistoryDataSet(); 37 MapView.addLayerChangeListener(historyDataSet); 33 38 } 34 39 return historyDataSet; … … 57 62 for (HistoryDataSetListener l : listeners) { 58 63 l.historyUpdated(this, id); 64 } 65 } 66 67 protected void fireCacheCleared() { 68 for (HistoryDataSetListener l : listeners) { 69 l.historyDataSetCleared(this); 59 70 } 60 71 } … … 151 162 fireHistoryUpdated(null); 152 163 } 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 } 153 177 } -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSetListener.java
r2512 r2961 5 5 6 6 public 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 */ 7 14 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); 8 22 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/HistoryDialog.java
r2928 r2961 43 43 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 44 44 import org.openstreetmap.josm.gui.SideButton; 45 import org.openstreetmap.josm.gui.help.HelpUtil; 45 46 import org.openstreetmap.josm.gui.history.HistoryBrowserDialogManager; 46 47 import org.openstreetmap.josm.gui.history.HistoryLoadTask; … … 71 72 build(); 72 73 DataSet.selListeners.add(model); 74 75 HelpUtil.setHelpContext(this, HelpUtil.ht("/Dialog/HistoryDialog")); 73 76 } 74 77 … … 146 149 } 147 150 151 /* ----------------------------------------------------------------------------- */ 152 /* interface HistoryDataSetListener */ 153 /* ----------------------------------------------------------------------------- */ 148 154 public void historyUpdated(HistoryDataSet source, PrimitiveId primitiveId) { 155 model.refresh(); 156 } 157 158 public void historyDataSetCleared(HistoryDataSet source) { 149 159 model.refresh(); 150 160 } … … 317 327 protected List<OsmPrimitive> filterPrimitivesWithUnloadedHistory(Collection<OsmPrimitive> primitives) { 318 328 ArrayList<OsmPrimitive> ret = new ArrayList<OsmPrimitive>(primitives.size()); 329 HistoryDataSet hds = HistoryDataSet.getInstance(); 319 330 for (OsmPrimitive p: primitives) { 320 if (HistoryDataSet.getInstance().getHistory(p.getPrimitiveId()) == null) { 331 if (hds.getHistory(p.getPrimitiveId()) == null) { 332 // reload if the history is not in the cache yet 333 ret.add(p); 334 } else if (!p.isNew() && hds.getHistory(p.getPrimitiveId()).getByVersion(p.getUniqueId()) == null) { 335 // reload if the history object of the selected object is not in the cache 336 // yet 321 337 ret.add(p); 322 338 } -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialog.java
r2936 r2961 108 108 } 109 109 110 public void unlinkAsListener() { 111 getHistoryBrowser().getModel().unlinkAsListener(); 112 } 113 114 /* ---------------------------------------------------------------------------------- */ 115 /* interface HistoryDataSetListener */ 116 /* ---------------------------------------------------------------------------------- */ 110 117 public void historyUpdated(HistoryDataSet source, PrimitiveId primitiveId) { 111 118 if (primitiveId == null || primitiveId.equals(browser.getHistory().getPrimitmiveId())) { … … 114 121 } 115 122 116 public void unlinkAsListener() {117 getHistoryBrowser().getModel().unlinkAsListener();123 public void historyDataSetCleared(HistoryDataSet source) { 124 closeAction.run(); 118 125 } 126 119 127 120 128 class CloseAction extends AbstractAction {
Note:
See TracChangeset
for help on using the changeset viewer.