Changeset 15609 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2019-12-23T22:41:07+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AbstractUploadAction.java
r15513 r15609 12 12 * Abstract super-class of all upload actions. 13 13 * Listens to layer change events to update its enabled state. 14 * @since xxx14 * @since 15513 15 15 */ 16 16 public abstract class AbstractUploadAction extends JosmAction { -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r15497 r15609 11 11 import java.util.HashSet; 12 12 import java.util.Iterator; 13 import java.util.LinkedHashSet; 13 14 import java.util.LinkedList; 14 15 import java.util.List; … … 43 44 import org.openstreetmap.josm.data.osm.event.DataChangedEvent; 44 45 import org.openstreetmap.josm.data.osm.event.DataSetListener; 46 import org.openstreetmap.josm.data.osm.event.DataSourceAddedEvent; 47 import org.openstreetmap.josm.data.osm.event.DataSourceRemovedEvent; 45 48 import org.openstreetmap.josm.data.osm.event.FilterChangedEvent; 46 49 import org.openstreetmap.josm.data.osm.event.NodeMovedEvent; … … 166 169 private final Collection<DataSource> dataSources = new LinkedList<>(); 167 170 171 /** 172 * A list of listeners that listen to DataSource changes on this layer 173 */ 174 private final ListenerList<DataSourceListener> dataSourceListeners = ListenerList.create(); 175 168 176 private final ConflictCollection conflicts = new ConflictCollection(); 169 177 … … 226 234 .collect(Collectors.toList())); 227 235 } 236 DataSourceAddedEvent addedEvent = new DataSourceAddedEvent(this, 237 new LinkedHashSet<>(dataSources), copyFrom.dataSources.stream()); 228 238 for (DataSource source : copyFrom.dataSources) { 229 239 dataSources.add(new DataSource(source)); 230 240 } 241 dataSourceListeners.fireEvent(d -> d.dataSourceChange(addedEvent)); 231 242 version = copyFrom.version; 232 243 uploadPolicy = copyFrom.uploadPolicy; … … 272 283 */ 273 284 public synchronized boolean addDataSources(Collection<DataSource> sources) { 285 DataSourceAddedEvent addedEvent = new DataSourceAddedEvent(this, 286 new LinkedHashSet<>(dataSources), sources.stream()); 274 287 boolean changed = dataSources.addAll(sources); 275 288 if (changed) { … … 277 290 cachedDataSourceBounds = null; 278 291 } 292 dataSourceListeners.fireEvent(d -> d.dataSourceChange(addedEvent)); 279 293 return changed; 280 294 } … … 573 587 public void removeHighlightUpdateListener(HighlightUpdateListener listener) { 574 588 highlightUpdateListeners.removeListener(listener); 589 } 590 591 /** 592 * Adds a listener that gets notified whenever the data sources change 593 * 594 * @param listener The listener 595 * @see #removeDataSourceListener 596 * @see #getDataSources 597 * @since 15609 598 */ 599 public void addDataSourceListener(DataSourceListener listener) { 600 dataSourceListeners.addListener(listener); 601 } 602 603 /** 604 * Removes a listener that gets notified whenever the data sources change 605 * 606 * @param listener The listener 607 * @see #addDataSourceListener 608 * @see #getDataSources 609 * @since 15609 610 */ 611 public void removeDataSourceListener(DataSourceListener listener) { 612 dataSourceListeners.removeListener(listener); 575 613 } 576 614 … … 1085 1123 synchronized (from) { 1086 1124 if (!from.dataSources.isEmpty()) { 1087 if (dataSources.addAll(from.dataSources)) { 1125 DataSourceAddedEvent addedEvent = new DataSourceAddedEvent( 1126 this, new LinkedHashSet<>(dataSources), from.dataSources.stream()); 1127 DataSourceRemovedEvent clearEvent = new DataSourceRemovedEvent( 1128 this, new LinkedHashSet<>(from.dataSources), from.dataSources.stream()); 1129 if (from.dataSources.stream().filter(dataSource -> !dataSources.contains(dataSource)) 1130 .map(dataSources::add).filter(Boolean.TRUE::equals).count() > 0) { 1088 1131 cachedDataSourceArea = null; 1089 1132 cachedDataSourceBounds = null; … … 1092 1135 from.cachedDataSourceArea = null; 1093 1136 from.cachedDataSourceBounds = null; 1137 dataSourceListeners.fireEvent(d -> d.dataSourceChange(addedEvent)); 1138 from.dataSourceListeners.fireEvent(d -> d.dataSourceChange(clearEvent)); 1094 1139 } 1095 1140 }
Note:
See TracChangeset
for help on using the changeset viewer.