Changeset 14247 in josm


Ignore:
Timestamp:
2018-09-12T00:54:12+02:00 (10 days ago)
Author:
Don-vip
Message:

remove stuff deprecated in June. RIP SelectionChangedListener

Location:
trunk
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r14219 r14247  
    7777    }
    7878
    79     /**
    80      * Asynchronously launches the download task for a given bounding box.
    81      * @param newLayer true, if the data is to be downloaded into a new layer. If false, the task
    82      * selects one of the existing layers as download layer, preferably the active layer.
    83      *
    84      * @param downloadArea the area to download
    85      * @param progressMonitor the progressMonitor
    86      * @return the future representing the asynchronous task
    87      * @deprecated Use {@link #download(DownloadParams, Bounds, ProgressMonitor)}
    88      */
    89     @Deprecated
    90     public Future<?> download(boolean newLayer, Bounds downloadArea, ProgressMonitor progressMonitor) {
    91         return download(new BoundingBoxDownloader(downloadArea),
    92                 new DownloadParams().withNewLayer(newLayer), downloadArea, progressMonitor);
    93     }
    94 
    9579    @Override
    9680    public Future<?> download(DownloadParams settings, Bounds downloadArea, ProgressMonitor progressMonitor) {
    9781        return download(new BoundingBoxDownloader(downloadArea), settings, downloadArea, progressMonitor);
    98     }
    99 
    100     /**
    101      * Asynchronously launches the download task for a given bounding box.
    102      *
    103      * @param reader the reader used to parse OSM data (see {@link OsmServerReader#parseOsm})
    104      * @param newLayer newLayer true, if the data is to be downloaded into a new layer. If false, the task
    105      * selects one of the existing layers as download layer, preferably the active layer.
    106      * @param downloadArea the area to download
    107      * @param progressMonitor the progressMonitor
    108      * @return the future representing the asynchronous task
    109      * @deprecated Use {@link #download(OsmServerReader, DownloadParams, Bounds, ProgressMonitor)}
    110      */
    111     @Deprecated
    112     public Future<?> download(OsmServerReader reader, boolean newLayer, Bounds downloadArea, ProgressMonitor progressMonitor) {
    113         return download(new DownloadTask(new DownloadParams().withNewLayer(newLayer), reader, progressMonitor, zoomAfterDownload),
    114                 downloadArea);
    11582    }
    11683
     
    389356        /**
    390357         * Constructs a new {@code DownloadTask}.
    391          * @param newLayer if {@code true}, force download to a new layer
    392          * @param reader OSM data reader
    393          * @param progressMonitor progress monitor
    394          * @deprecated Use {@code DownloadTask(DownloadParams, OsmServerReader, ProgressMonitor)}
    395          */
    396         @Deprecated
    397         public DownloadTask(boolean newLayer, OsmServerReader reader, ProgressMonitor progressMonitor) {
    398             this(new DownloadParams().withNewLayer(newLayer), reader, progressMonitor);
    399         }
    400 
    401         /**
    402          * Constructs a new {@code DownloadTask}.
    403          * @param newLayer if {@code true}, force download to a new layer
    404          * @param reader OSM data reader
    405          * @param progressMonitor progress monitor
    406          * @param zoomAfterDownload If true, the map view will zoom to download area after download
    407          * @deprecated Use {@code DownloadTask(DownloadParams, OsmServerReader, ProgressMonitor, boolean)}
    408          */
    409         @Deprecated
    410         public DownloadTask(boolean newLayer, OsmServerReader reader, ProgressMonitor progressMonitor, boolean zoomAfterDownload) {
    411             this(new DownloadParams().withNewLayer(newLayer), reader, progressMonitor, zoomAfterDownload);
    412         }
    413 
    414         /**
    415          * Constructs a new {@code DownloadTask}.
    416358         * @param settings download settings
    417359         * @param reader OSM data reader
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r14222 r14247  
    2929import org.openstreetmap.josm.data.DataSource;
    3030import org.openstreetmap.josm.data.ProjectionBounds;
    31 import org.openstreetmap.josm.data.SelectionChangedListener;
    3231import org.openstreetmap.josm.data.conflict.ConflictCollection;
    3332import org.openstreetmap.josm.data.coor.EastNorth;
     
    4847import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent;
    4948import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent;
    50 import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
    5149import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
    5250import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
     
    178176        // the listener, projection change listeners are managed as WeakReferences.
    179177        ProjectionRegistry.addProjectionChangeListener(this);
    180         addSelectionListener((DataSelectionListener) e -> fireSelectionChange(e.getSelection()));
    181178    }
    182179
     
    541538    public void removeSelectionListener(DataSelectionListener listener) {
    542539        selectionListeners.removeListener(listener);
    543     }
    544 
    545     /*---------------------------------------------------
    546      *   OLD SELECTION HANDLING
    547      *---------------------------------------------------*/
    548 
    549     /**
    550      * A list of listeners to selection changed events. The list is static, as listeners register
    551      * themselves for any dataset selection changes that occur, regardless of the current active
    552      * dataset. (However, the selection does only change in the active layer)
    553      * @deprecated to be removed
    554      */
    555     @Deprecated
    556     private static final Collection<SelectionChangedListener> selListeners = new CopyOnWriteArrayList<>();
    557 
    558     /**
    559      * Adds a new selection listener.
    560      * @param listener The selection listener to add
    561      * @see #addSelectionListener(DataSelectionListener)
    562      * @see SelectionEventManager#removeSelectionListener(SelectionChangedListener)
    563      * @deprecated Use {@link SelectionEventManager#addSelectionListener(DataSelectionListener)} instead
    564      */
    565     @Deprecated
    566     public static void addSelectionListener(SelectionChangedListener listener) {
    567         ((CopyOnWriteArrayList<SelectionChangedListener>) selListeners).addIfAbsent(listener);
    568     }
    569 
    570     /**
    571      * Removes a selection listener.
    572      * @param listener The selection listener to remove
    573      * @see #removeSelectionListener(DataSelectionListener)
    574      * @see SelectionEventManager#removeSelectionListener(SelectionChangedListener)
    575      * @deprecated Use {@link SelectionEventManager#removeSelectionListener(DataSelectionListener)} instead
    576      */
    577     @Deprecated
    578     public static void removeSelectionListener(SelectionChangedListener listener) {
    579         selListeners.remove(listener);
    580     }
    581 
    582     /**
    583      * @deprecated to be removed
    584      * @param currentSelection current selection
    585      */
    586     @Deprecated
    587     private static void fireSelectionChange(Collection<? extends OsmPrimitive> currentSelection) {
    588         for (SelectionChangedListener l : selListeners) {
    589             l.selectionChanged(currentSelection);
    590         }
    591540    }
    592541
  • trunk/src/org/openstreetmap/josm/data/osm/event/SelectionEventManager.java

    r13925 r14247  
    99import java.util.stream.Stream;
    1010
    11 import org.openstreetmap.josm.data.SelectionChangedListener;
    1211import org.openstreetmap.josm.data.osm.DataIntegrityProblemException;
    1312import org.openstreetmap.josm.data.osm.DataSelectionListener;
    1413import org.openstreetmap.josm.data.osm.DataSet;
    15 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
    1614import org.openstreetmap.josm.gui.MainApplication;
    1715import org.openstreetmap.josm.gui.layer.MainLayerManager;
     
    4644    private interface ListenerInfo {
    4745        void fire(SelectionChangeEvent event);
    48     }
    49 
    50     /**
    51      * @deprecated to be removed
    52      */
    53     @Deprecated
    54     private static class OldListenerInfo implements ListenerInfo {
    55         private final SelectionChangedListener listener;
    56 
    57         OldListenerInfo(SelectionChangedListener listener) {
    58             this.listener = listener;
    59         }
    60 
    61         @Override
    62         public void fire(SelectionChangeEvent event) {
    63             listener.selectionChanged(event.getSelection());
    64         }
    65 
    66         @Override
    67         public int hashCode() {
    68             return Objects.hash(listener);
    69         }
    70 
    71         @Override
    72         public boolean equals(Object o) {
    73             if (this == o) return true;
    74             if (o == null || getClass() != o.getClass()) return false;
    75             OldListenerInfo that = (OldListenerInfo) o;
    76             return Objects.equals(listener, that.listener);
    77         }
    78 
    79         @Override
    80         public String toString() {
    81             return "OldListenerInfo [listener=" + listener + ']';
    82         }
    8346    }
    8447
     
    12891
    12992    /**
    130      * Registers a new {@code SelectionChangedListener}.
    131      *
    132      * It is preferred to add a DataSelectionListener - that listener will receive more information about the event.
    133      * @param listener listener to add
    134      * @param fireMode Set this to IN_EDT_CONSOLIDATED if you want the event to be fired in the EDT thread.
    135      *                 Set it to IMMEDIATELY if you want the event to fire in the thread that caused the selection update.
    136      * @deprecated Use {@link #addSelectionListener(DataSelectionListener)} or {@link #addSelectionListenerForEdt(DataSelectionListener)}
    137      */
    138     @Deprecated
    139     public void addSelectionListener(SelectionChangedListener listener, FireMode fireMode) {
    140         if (fireMode == FireMode.IN_EDT) {
    141             throw new UnsupportedOperationException("IN_EDT mode not supported, you probably want to use IN_EDT_CONSOLIDATED.");
    142         } else if (fireMode == FireMode.IN_EDT_CONSOLIDATED) {
    143             inEDTListeners.addIfAbsent(new OldListenerInfo(listener));
    144         } else {
    145             immedatelyListeners.addIfAbsent(new OldListenerInfo(listener));
    146         }
    147     }
    148 
    149     /**
    15093     * Adds a selection listener that gets notified for selections immediately.
    15194     * @param listener The listener to add.
     
    164107    public void addSelectionListenerForEdt(DataSelectionListener listener) {
    165108        inEDTListeners.addIfAbsent(new DataListenerInfo(listener));
    166     }
    167 
    168     /**
    169      * Unregisters a {@code SelectionChangedListener}.
    170      * @param listener listener to remove
    171      * @deprecated use {@link #removeSelectionListener(DataSelectionListener)}
    172      */
    173     @Deprecated
    174     public void removeSelectionListener(SelectionChangedListener listener) {
    175         remove(new OldListenerInfo(listener));
    176109    }
    177110
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r13990 r14247  
    6767import javax.script.ScriptEngine;
    6868import javax.script.ScriptEngineManager;
    69 import javax.xml.parsers.DocumentBuilder;
    70 import javax.xml.parsers.ParserConfigurationException;
    71 import javax.xml.parsers.SAXParser;
    72 import javax.xml.validation.SchemaFactory;
    7369
    7470import org.openstreetmap.josm.spi.preferences.Config;
    75 import org.w3c.dom.Document;
    76 import org.xml.sax.InputSource;
    77 import org.xml.sax.SAXException;
    78 import org.xml.sax.helpers.DefaultHandler;
    7971
    8072/**
     
    13301322        }
    13311323        return null;
    1332     }
    1333 
    1334     /**
    1335      * Returns the W3C XML Schema factory implementation. Robust method dealing with ContextClassLoader problems.
    1336      * @return the W3C XML Schema factory implementation
    1337      * @deprecated Use {@link XmlUtils#newXmlSchemaFactory}
    1338      * @since 13715
    1339      */
    1340     @Deprecated
    1341     public static SchemaFactory newXmlSchemaFactory() {
    1342         return XmlUtils.newXmlSchemaFactory();
    1343     }
    1344 
    1345     /**
    1346      * Returns a new secure DOM builder, supporting XML namespaces.
    1347      * @return a new secure DOM builder, supporting XML namespaces
    1348      * @throws ParserConfigurationException if a parser cannot be created which satisfies the requested configuration.
    1349      * @deprecated Use {@link XmlUtils#newSafeDOMBuilder}
    1350      * @since 10404
    1351      */
    1352     @Deprecated
    1353     public static DocumentBuilder newSafeDOMBuilder() throws ParserConfigurationException {
    1354         return XmlUtils.newSafeDOMBuilder();
    1355     }
    1356 
    1357     /**
    1358      * Parse the content given {@link InputStream} as XML.
    1359      * This method uses a secure DOM builder, supporting XML namespaces.
    1360      *
    1361      * @param is The InputStream containing the content to be parsed.
    1362      * @return the result DOM document
    1363      * @throws ParserConfigurationException if a parser cannot be created which satisfies the requested configuration.
    1364      * @throws IOException if any IO errors occur.
    1365      * @throws SAXException for SAX errors.
    1366      * @deprecated Use {@link XmlUtils#parseSafeDOM}
    1367      * @since 10404
    1368      */
    1369     @Deprecated
    1370     public static Document parseSafeDOM(InputStream is) throws ParserConfigurationException, IOException, SAXException {
    1371         return XmlUtils.parseSafeDOM(is);
    1372     }
    1373 
    1374     /**
    1375      * Returns a new secure SAX parser, supporting XML namespaces.
    1376      * @return a new secure SAX parser, supporting XML namespaces
    1377      * @throws ParserConfigurationException if a parser cannot be created which satisfies the requested configuration.
    1378      * @throws SAXException for SAX errors.
    1379      * @deprecated Use {@link XmlUtils#newSafeSAXParser}
    1380      * @since 8287
    1381      */
    1382     @Deprecated
    1383     public static SAXParser newSafeSAXParser() throws ParserConfigurationException, SAXException {
    1384         return XmlUtils.newSafeSAXParser();
    1385     }
    1386 
    1387     /**
    1388      * Parse the content given {@link org.xml.sax.InputSource} as XML using the specified {@link org.xml.sax.helpers.DefaultHandler}.
    1389      * This method uses a secure SAX parser, supporting XML namespaces.
    1390      *
    1391      * @param is The InputSource containing the content to be parsed.
    1392      * @param dh The SAX DefaultHandler to use.
    1393      * @throws ParserConfigurationException if a parser cannot be created which satisfies the requested configuration.
    1394      * @throws SAXException for SAX errors.
    1395      * @throws IOException if any IO errors occur.
    1396      * @deprecated Use {@link XmlUtils#parseSafeSAX}
    1397      * @since 8347
    1398      */
    1399     @Deprecated
    1400     public static void parseSafeSAX(InputSource is, DefaultHandler dh) throws ParserConfigurationException, SAXException, IOException {
    1401         XmlUtils.parseSafeSAX(is, dh);
    14021324    }
    14031325
  • trunk/test/unit/org/openstreetmap/josm/data/osm/event/SelectionEventManagerTest.java

    r13925 r14247  
    1212import org.junit.Test;
    1313import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
    14 import org.openstreetmap.josm.data.SelectionChangedListener;
    1514import org.openstreetmap.josm.data.osm.DataSelectionListener;
    1615import org.openstreetmap.josm.data.osm.OsmPrimitive;
    17 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
    1816import org.openstreetmap.josm.gui.MainApplication;
    1917import org.openstreetmap.josm.gui.util.GuiHelper;
     
    2725 * @since 12048
    2826 */
    29 @SuppressWarnings("deprecation")
    3027public class SelectionEventManagerTest {
    31     private final class SelectionListener implements SelectionChangedListener, DataSelectionListener {
     28    private final class SelectionListener implements DataSelectionListener {
    3229        private Collection<? extends OsmPrimitive> newSelection;
    3330        private final String name;
     
    3532        SelectionListener(String name) {
    3633            this.name = name;
    37         }
    38 
    39         @Override
    40         public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    41             this.newSelection = newSelection;
    4234        }
    4335
     
    6557        assertEquals(testData1.layer, MainApplication.getLayerManager().getEditLayer());
    6658
    67         SelectionListener listener1 = new SelectionListener("IMMEDIATELY");
    68         SelectionListener listener2 = new SelectionListener("IN_EDT_CONSOLIDATED");
    6959        SelectionListener listener3 = new SelectionListener("normal");
    7060        SelectionListener listener4 = new SelectionListener("edt");
    7161        SelectionEventManager instance = SelectionEventManager.getInstance();
    72         instance.addSelectionListener(listener1, FireMode.IMMEDIATELY);
    73         instance.addSelectionListener(listener2, FireMode.IN_EDT_CONSOLIDATED);
    7462        instance.addSelectionListener(listener3);
    7563        instance.addSelectionListenerForEdt(listener4);
    76         List<SelectionListener> listeners = Arrays.asList(listener1, listener2, listener3, listener4);
     64        List<SelectionListener> listeners = Arrays.asList(listener3, listener4);
    7765        assertSelectionEquals(listeners, null);
    7866
     
    9987
    10088        // removal
    101         instance.removeSelectionListener((SelectionChangedListener) listener1);
    102         instance.removeSelectionListener((SelectionChangedListener) listener2);
    103         instance.removeSelectionListener((DataSelectionListener) listener3);
    104         instance.removeSelectionListener((DataSelectionListener) listener4);
     89        instance.removeSelectionListener(listener3);
     90        instance.removeSelectionListener(listener4);
    10591
    10692        // no event triggered now
Note: See TracChangeset for help on using the changeset viewer.