Ignore:
Timestamp:
2018-06-13T00:05:31+02:00 (18 months ago)
Author:
Don-vip
Message:

fix #13467 - use DataSelectionListener everywhere. Deprecate SelectionChangedListener

Location:
trunk/src/org/openstreetmap/josm/data
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/SelectionChangedListener.java

    r12098 r13925  
    3030     * Informs the listener that the selection in the dataset has changed.
    3131     * @param newSelection The new selection.
     32     * @deprecated use {@link DataSelectionListener} instead
    3233     */
     34    @Deprecated
    3335    void selectionChanged(Collection<? extends OsmPrimitive> newSelection);
    3436}
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r13916 r13925  
    548548     * themselves for any dataset selection changes that occur, regardless of the current active
    549549     * dataset. (However, the selection does only change in the active layer)
    550      */
     550     * @deprecated to be removed
     551     */
     552    @Deprecated
    551553    private static final Collection<SelectionChangedListener> selListeners = new CopyOnWriteArrayList<>();
    552554
     
    556558     * @see #addSelectionListener(DataSelectionListener)
    557559     * @see SelectionEventManager#removeSelectionListener(SelectionChangedListener)
    558      */
     560     * @deprecated Use {@link SelectionEventManager#addSelectionListener(DataSelectionListener)} instead
     561     */
     562    @Deprecated
    559563    public static void addSelectionListener(SelectionChangedListener listener) {
    560564        ((CopyOnWriteArrayList<SelectionChangedListener>) selListeners).addIfAbsent(listener);
     
    566570     * @see #removeSelectionListener(DataSelectionListener)
    567571     * @see SelectionEventManager#removeSelectionListener(SelectionChangedListener)
    568      */
     572     * @deprecated Use {@link SelectionEventManager#removeSelectionListener(DataSelectionListener)} instead
     573     */
     574    @Deprecated
    569575    public static void removeSelectionListener(SelectionChangedListener listener) {
    570576        selListeners.remove(listener);
    571577    }
    572578
     579    /**
     580     * @deprecated to be removed
     581     * @param currentSelection current selection
     582     */
     583    @Deprecated
    573584    private static void fireSelectionChange(Collection<? extends OsmPrimitive> currentSelection) {
    574585        for (SelectionChangedListener l : selListeners) {
  • trunk/src/org/openstreetmap/josm/data/osm/OsmData.java

    r13916 r13925  
    1111import org.openstreetmap.josm.data.DataSource;
    1212import org.openstreetmap.josm.data.ProjectionBounds;
    13 import org.openstreetmap.josm.data.SelectionChangedListener;
    1413import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
    1514import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     
    398397    /**
    399398     * Sets the current selection to the primitives in <code>selection</code>
    400      * and notifies all {@link SelectionChangedListener}.
     399     * and notifies all {@link DataSelectionListener}.
    401400     *
    402401     * @param selection the selection
     
    406405    /**
    407406     * Sets the current selection to the primitives in <code>osm</code>
    408      * and notifies all {@link SelectionChangedListener}.
     407     * and notifies all {@link DataSelectionListener}.
    409408     *
    410409     * @param osm the primitives to set. <code>null</code> values are ignored for now, but this may be removed in the future.
     
    414413    /**
    415414     * Adds the primitives in <code>selection</code> to the current selection
    416      * and notifies all {@link SelectionChangedListener}.
     415     * and notifies all {@link DataSelectionListener}.
    417416     *
    418417     * @param selection the selection
     
    422421    /**
    423422     * Adds the primitives in <code>osm</code> to the current selection
    424      * and notifies all {@link SelectionChangedListener}.
     423     * and notifies all {@link DataSelectionListener}.
    425424     *
    426425     * @param osm the primitives to add
     
    449448     * @param listener The listener.
    450449     * @see #removeSelectionListener(DataSelectionListener)
    451      * @see SelectionEventManager#addSelectionListener(SelectionChangedListener,
    452      *      org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode)
     450     * @see SelectionEventManager#addSelectionListener(DataSelectionListener)
    453451     *      To add a global listener.
    454452     */
  • trunk/src/org/openstreetmap/josm/data/osm/event/SelectionEventManager.java

    r13434 r13925  
    4848    }
    4949
     50    /**
     51     * @deprecated to be removed
     52     */
     53    @Deprecated
    5054    private static class OldListenerInfo implements ListenerInfo {
    5155        private final SelectionChangedListener listener;
     
    130134     * @param fireMode Set this to IN_EDT_CONSOLIDATED if you want the event to be fired in the EDT thread.
    131135     *                 Set it to IMMEDIATELY if you want the event to fire in the thread that caused the selection update.
    132      */
     136     * @deprecated Use {@link #addSelectionListener(DataSelectionListener)} or {@link #addSelectionListenerForEdt(DataSelectionListener)}
     137     */
     138    @Deprecated
    133139    public void addSelectionListener(SelectionChangedListener listener, FireMode fireMode) {
    134140        if (fireMode == FireMode.IN_EDT) {
     
    163169     * Unregisters a {@code SelectionChangedListener}.
    164170     * @param listener listener to remove
    165      */
     171     * @deprecated use {@link #removeSelectionListener(DataSelectionListener)}
     172     */
     173    @Deprecated
    166174    public void removeSelectionListener(SelectionChangedListener listener) {
    167175        remove(new OldListenerInfo(listener));
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java

    r13082 r13925  
    1010
    1111import org.openstreetmap.josm.Main;
    12 import org.openstreetmap.josm.data.SelectionChangedListener;
     12import org.openstreetmap.josm.data.osm.DataSelectionListener;
    1313import org.openstreetmap.josm.data.osm.DataSet;
    1414import org.openstreetmap.josm.data.osm.Node;
     
    2323import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent;
    2424import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent;
     25import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
    2526import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
    2627import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
     
    3940 * @since 4623
    4041 */
    41 public final class MultipolygonCache implements DataSetListener, LayerChangeListener, ProjectionChangeListener, SelectionChangedListener {
     42public final class MultipolygonCache implements DataSetListener, LayerChangeListener, ProjectionChangeListener, DataSelectionListener {
    4243
    4344    private static final MultipolygonCache INSTANCE = new MultipolygonCache();
     
    4950    private MultipolygonCache() {
    5051        Main.addProjectionChangeListener(this);
    51         DataSet.addSelectionListener(this);
     52        SelectionEventManager.getInstance().addSelectionListener(this);
    5253        MainApplication.getLayerManager().addLayerChangeListener(this);
    5354    }
     
    294295
    295296    @Override
    296     public synchronized void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
     297    public synchronized void selectionChanged(SelectionChangeEvent event) {
    297298
    298299        for (Iterator<PolyData> it = selectedPolyData.iterator(); it.hasNext();) {
     
    303304        DataSet ds = null;
    304305        Collection<Map<Relation, Multipolygon>> maps = null;
    305         for (OsmPrimitive p : newSelection) {
     306        for (OsmPrimitive p : event.getSelection()) {
    306307            if (p instanceof Way && p.getDataSet() != null) {
    307308                if (ds == null) {
Note: See TracChangeset for help on using the changeset viewer.