Changeset 12342 in josm
- Timestamp:
- 2017-06-08T01:09:44+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r12341 r12342 13 13 import java.util.List; 14 14 import java.util.Set; 15 import java.util.concurrent.CopyOnWriteArrayList;16 15 17 16 import javax.swing.ImageIcon; … … 35 34 import org.openstreetmap.josm.io.CachedFile; 36 35 import org.openstreetmap.josm.tools.ImageProvider; 36 import org.openstreetmap.josm.tools.ListenerList; 37 37 import org.openstreetmap.josm.tools.Utils; 38 38 … … 460 460 * (get informed when the list of MapPaint StyleSources changes) 461 461 */ 462 463 462 public interface MapPaintSylesUpdateListener { 463 /** 464 * Called on any style source changes that are not handled by {@link #mapPaintStyleEntryUpdated(int)} 465 */ 464 466 void mapPaintStylesUpdated(); 465 467 466 void mapPaintStyleEntryUpdated(int idx); 467 } 468 469 private static final CopyOnWriteArrayList<MapPaintSylesUpdateListener> listeners 470 = new CopyOnWriteArrayList<>(); 471 468 /** 469 * Called whenever a single style source entry was changed. 470 * @param index The index of the entry. 471 */ 472 void mapPaintStyleEntryUpdated(int index); 473 } 474 475 private static final ListenerList<MapPaintSylesUpdateListener> listeners = ListenerList.createUnchecked(); 476 477 /** 478 * Add a listener that listens to global style changes. 479 * @param listener The listener 480 */ 472 481 public static void addMapPaintSylesUpdateListener(MapPaintSylesUpdateListener listener) { 473 if (listener != null) { 474 listeners.addIfAbsent(listener); 475 } 476 } 477 482 listeners.addListener(listener); 483 } 484 485 /** 486 * Removes a listener that listens to global style changes. 487 * @param listener The listener 488 */ 478 489 public static void removeMapPaintSylesUpdateListener(MapPaintSylesUpdateListener listener) { 479 listeners.remove (listener);490 listeners.removeListener(listener); 480 491 } 481 492 482 493 public static void fireMapPaintSylesUpdated() { 483 for (MapPaintSylesUpdateListener l : listeners) { 484 l.mapPaintStylesUpdated(); 485 } 486 } 487 488 public static void fireMapPaintStyleEntryUpdated(int idx) { 489 for (MapPaintSylesUpdateListener l : listeners) { 490 l.mapPaintStyleEntryUpdated(idx); 491 } 494 listeners.fireEvent(MapPaintSylesUpdateListener::mapPaintStylesUpdated); 495 } 496 497 public static void fireMapPaintStyleEntryUpdated(int index) { 498 listeners.fireEvent(l -> l.mapPaintStyleEntryUpdated(index)); 492 499 } 493 500 }
Note:
See TracChangeset
for help on using the changeset viewer.