Changeset 10386 in josm for trunk/src


Ignore:
Timestamp:
2016-06-15T17:25:04+02:00 (8 years ago)
Author:
Don-vip
Message:

gsoc-core - remove more deprecation warnings

Location:
trunk/src/org/openstreetmap/josm
Files:
10 edited

Legend:

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

    r10345 r10386  
    1717
    1818import org.openstreetmap.josm.Main;
    19 import org.openstreetmap.josm.gui.MapView;
    2019import org.openstreetmap.josm.gui.widgets.AbstractFileChooser;
    2120import org.openstreetmap.josm.io.AllFormatsImporter;
     
    6766                FileImporter importer = importerClass.getConstructor().newInstance();
    6867                importers.add(importer);
    69                 MapView.addLayerChangeListener(importer);
    7068            } catch (ReflectiveOperationException e) {
    7169                if (Main.isDebugEnabled()) {
  • trunk/src/org/openstreetmap/josm/actions/ZoomToAction.java

    r8443 r10386  
    1212import org.openstreetmap.josm.Main;
    1313import org.openstreetmap.josm.data.osm.OsmPrimitive;
    14 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    1514import org.openstreetmap.josm.gui.conflict.pair.nodes.NodeListTable;
    1615import org.openstreetmap.josm.gui.conflict.pair.relation.RelationMemberTable;
    1716import org.openstreetmap.josm.gui.dialogs.relation.MemberTable;
    18 import org.openstreetmap.josm.gui.layer.Layer;
     17import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     18import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     19import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
     20import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
     21import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     22import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    1923import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2024import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTable;
    2125import org.openstreetmap.josm.tools.CheckParameterUtil;
    2226
    23 public class ZoomToAction extends AbstractAction implements LayerChangeListener, ListSelectionListener {
     27public class ZoomToAction extends AbstractAction implements LayerChangeListener, ActiveLayerChangeListener, ListSelectionListener {
    2428
    2529    private final OsmPrimitivesTable table;
     
    98102
    99103    @Override
    100     public void activeLayerChange(Layer oldLayer, Layer newLayer) {
     104    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
    101105        updateEnabledState();
    102106    }
    103107
    104108    @Override
    105     public void layerAdded(Layer newLayer) {
     109    public void layerAdded(LayerAddEvent e) {
    106110        updateEnabledState();
    107111    }
    108112
    109113    @Override
    110     public void layerRemoved(Layer oldLayer) {
     114    public void layerRemoving(LayerRemoveEvent e) {
    111115        updateEnabledState();
    112116    }
     117
     118    @Override
     119    public void layerOrderChanged(LayerOrderChangeEvent e) {
     120        // Do nothing
     121    }
    113122}
  • trunk/src/org/openstreetmap/josm/data/AutosaveTask.java

    r10364 r10386  
    3434import org.openstreetmap.josm.data.preferences.BooleanProperty;
    3535import org.openstreetmap.josm.data.preferences.IntegerProperty;
    36 import org.openstreetmap.josm.gui.MapView;
    37 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    3836import org.openstreetmap.josm.gui.Notification;
    39 import org.openstreetmap.josm.gui.layer.Layer;
     37import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     38import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     39import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
     40import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
    4041import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    4142import org.openstreetmap.josm.gui.util.GuiHelper;
     
    5960 *
    6061 *      The deleted layers dir keeps at most PROP_DELETED_LAYERS files.
     62 *
     63 * @since  3378 (creation)
     64 * @since 10386 (new LayerChangeListener interface)
    6165 */
    6266public class AutosaveTask extends TimerTask implements LayerChangeListener, Listener {
     
    125129            timer = new Timer(true);
    126130            timer.schedule(this, 1000L, PROP_INTERVAL.get() * 1000L);
    127             MapView.addLayerChangeListener(this);
     131            Main.getLayerManager().addLayerChangeListener(this);
    128132            if (Main.isDisplayingMapView()) {
    129133                for (OsmDataLayer l: Main.getLayerManager().getLayersOfType(OsmDataLayer.class)) {
     
    250254
    251255    @Override
    252     public void activeLayerChange(Layer oldLayer, Layer newLayer) {
     256    public void layerOrderChanged(LayerOrderChangeEvent e) {
    253257        // Do nothing
    254258    }
     
    262266
    263267    @Override
    264     public void layerAdded(Layer newLayer) {
    265         if (newLayer instanceof OsmDataLayer) {
    266             registerNewlayer((OsmDataLayer) newLayer);
     268    public void layerAdded(LayerAddEvent e) {
     269        if (e.getAddedLayer() instanceof OsmDataLayer) {
     270            registerNewlayer((OsmDataLayer) e.getAddedLayer());
    267271        }
    268272    }
    269273
    270274    @Override
    271     public void layerRemoved(Layer oldLayer) {
    272         if (oldLayer instanceof OsmDataLayer) {
     275    public void layerRemoving(LayerRemoveEvent e) {
     276        if (e.getRemovedLayer() instanceof OsmDataLayer) {
    273277            synchronized (layersLock) {
    274                 OsmDataLayer osmLayer = (OsmDataLayer) oldLayer;
     278                OsmDataLayer osmLayer = (OsmDataLayer) e.getRemovedLayer();
    275279                osmLayer.data.removeDataSetListener(datasetAdapter);
    276280                Iterator<AutosaveLayerInfo> it = layersInfo.iterator();
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSet.java

    r10378 r10386  
    1818import org.openstreetmap.josm.data.osm.PrimitiveId;
    1919import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
    20 import org.openstreetmap.josm.gui.MapView;
    21 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    22 import org.openstreetmap.josm.gui.layer.Layer;
     20import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     21import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     22import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
     23import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
    2324import org.openstreetmap.josm.tools.CheckParameterUtil;
    2425
     
    2627 * A data set holding histories of OSM primitives.
    2728 * @since 1670
     29 * @since 10386 (new LayerChangeListener interface)
    2830 */
    2931public class HistoryDataSet implements LayerChangeListener {
     
    3941        if (historyDataSet == null) {
    4042            historyDataSet = new HistoryDataSet();
    41             MapView.addLayerChangeListener(historyDataSet);
     43            Main.getLayerManager().addLayerChangeListener(historyDataSet);
    4244        }
    4345        return historyDataSet;
     
    201203    /* ------------------------------------------------------------------------------ */
    202204    @Override
    203     public void activeLayerChange(Layer oldLayer, Layer newLayer) {
     205    public void layerOrderChanged(LayerOrderChangeEvent e) {
    204206        /* irrelevant in this context */
    205207    }
    206208
    207209    @Override
    208     public void layerAdded(Layer newLayer) {
     210    public void layerAdded(LayerAddEvent e) {
    209211        /* irrelevant in this context */
    210212    }
    211213
    212214    @Override
    213     public void layerRemoved(Layer oldLayer) {
     215    public void layerRemoving(LayerRemoveEvent e) {
    214216        if (!Main.isDisplayingMapView()) return;
    215         if (Main.map.mapView.getNumLayers() == 0) {
     217        if (Main.getLayerManager().getLayers().isEmpty()) {
    216218            data.clear();
    217219            fireCacheCleared();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r10378 r10386  
    6262import org.openstreetmap.josm.gui.DefaultNameFormatter;
    6363import org.openstreetmap.josm.gui.MapView;
    64 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    6564import org.openstreetmap.josm.gui.NavigatableComponent;
    6665import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
     
    6968import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
    7069import org.openstreetmap.josm.gui.layer.Layer;
     70import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     71import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     72import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
     73import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
     74import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     75import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    7176import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    7277import org.openstreetmap.josm.gui.util.GuiHelper;
     
    8388
    8489/**
    85  * A dialog showing all known relations, with buttons to add, edit, and
    86  * delete them.
     90 * A dialog showing all known relations, with buttons to add, edit, and delete them.
    8791 *
    8892 * We don't have such dialogs for nodes, segments, and ways, because those
     
    220224    @Override
    221225    public void showNotify() {
    222         MapView.addLayerChangeListener(newAction);
     226        Main.getLayerManager().addLayerChangeListener(newAction);
     227        Main.getLayerManager().addActiveLayerChangeListener(newAction);
    223228        MapView.addZoomChangeListener(this);
    224229        newAction.updateEnabledState();
     
    232237    @Override
    233238    public void hideNotify() {
    234         MapView.removeLayerChangeListener(newAction);
     239        Main.getLayerManager().removeActiveLayerChangeListener(newAction);
     240        Main.getLayerManager().removeLayerChangeListener(newAction);
    235241        MapView.removeZoomChangeListener(this);
    236242        DatasetEventManager.getInstance().removeDatasetListener(this);
     
    345351
    346352    /**
    347      * The action for creating a new relation
    348      *
    349      */
    350     static class NewAction extends AbstractAction implements LayerChangeListener {
     353     * The action for creating a new relation.
     354     */
     355    static class NewAction extends AbstractAction implements LayerChangeListener, ActiveLayerChangeListener {
    351356        NewAction() {
    352357            putValue(SHORT_DESCRIPTION, tr("Create a new relation"));
     
    370375
    371376        @Override
    372         public void activeLayerChange(Layer oldLayer, Layer newLayer) {
     377        public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
    373378            updateEnabledState();
    374379        }
    375380
    376381        @Override
    377         public void layerAdded(Layer newLayer) {
     382        public void layerAdded(LayerAddEvent e) {
    378383            updateEnabledState();
    379384        }
    380385
    381386        @Override
    382         public void layerRemoved(Layer oldLayer) {
     387        public void layerRemoving(LayerRemoveEvent e) {
    383388            updateEnabledState();
     389        }
     390
     391        @Override
     392        public void layerOrderChanged(LayerOrderChangeEvent e) {
     393            // Do nothing
    384394        }
    385395    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java

    r10070 r10386  
    2828import org.openstreetmap.josm.data.osm.RelationMember;
    2929import org.openstreetmap.josm.data.osm.Way;
    30 import org.openstreetmap.josm.gui.MapView;
    31 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    3230import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType;
    3331import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType.Direction;
    34 import org.openstreetmap.josm.gui.layer.Layer;
     32import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     33import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     34import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
     35import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
     36import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     37import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    3538import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3639import org.openstreetmap.josm.gui.util.HighlightHelper;
     
    8285        JPopupMenu menu = super.buildPopupMenu();
    8386        zoomToGap = new ZoomToGapAction();
    84         MapView.addLayerChangeListener(zoomToGap);
     87        Main.getLayerManager().addLayerChangeListener(zoomToGap);
     88        Main.getLayerManager().addActiveLayerChangeListener(zoomToGap);
    8589        getSelectionModel().addListSelectionListener(zoomToGap);
    8690        menu.add(zoomToGap);
     
    137141    public void unlinkAsListener() {
    138142        super.unlinkAsListener();
    139         MapView.removeLayerChangeListener(zoomToGap);
     143        Main.getLayerManager().removeLayerChangeListener(zoomToGap);
     144        Main.getLayerManager().removeActiveLayerChangeListener(zoomToGap);
    140145    }
    141146
     
    189194    }
    190195
    191     private class ZoomToGapAction extends AbstractAction implements LayerChangeListener, ListSelectionListener {
     196    private class ZoomToGapAction extends AbstractAction implements LayerChangeListener, ActiveLayerChangeListener, ListSelectionListener {
    192197
    193198        /**
     
    241246
    242247        @Override
    243         public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    244             updateEnabledState();
    245         }
    246 
    247         @Override
    248         public void layerAdded(Layer newLayer) {
    249             updateEnabledState();
    250         }
    251 
    252         @Override
    253         public void layerRemoved(Layer oldLayer) {
    254             updateEnabledState();
     248        public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
     249            updateEnabledState();
     250        }
     251
     252        @Override
     253        public void layerAdded(LayerAddEvent e) {
     254            updateEnabledState();
     255        }
     256
     257        @Override
     258        public void layerRemoving(LayerRemoveEvent e) {
     259            updateEnabledState();
     260        }
     261
     262        @Override
     263        public void layerOrderChanged(LayerOrderChangeEvent e) {
     264            // Do nothing
    255265        }
    256266    }
  • trunk/src/org/openstreetmap/josm/gui/layer/ValidatorLayer.java

    r10173 r10386  
    2222import org.openstreetmap.josm.data.validation.TestError;
    2323import org.openstreetmap.josm.gui.MapView;
    24 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    2524import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
    2625import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
     26import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     27import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     28import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
     29import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
    2730import org.openstreetmap.josm.tools.ImageProvider;
    2831import org.openstreetmap.josm.tools.MultiMap;
     
    3235 *
    3336 * @author frsantos
     37 *
     38 * @since  3669 (creation)
     39 * @since 10386 (new LayerChangeListener interface)
    3440 */
    3541public class ValidatorLayer extends Layer implements LayerChangeListener {
     
    4248    public ValidatorLayer() {
    4349        super(tr("Validation errors"));
    44         MapView.addLayerChangeListener(this);
     50        Main.getLayerManager().addLayerChangeListener(this);
    4551    }
    4652
     
    143149
    144150    @Override
    145     public void activeLayerChange(Layer oldLayer, Layer newLayer) {
     151    public void layerOrderChanged(LayerOrderChangeEvent e) {
    146152        // Do nothing
    147153    }
    148154
    149155    @Override
    150     public void layerAdded(Layer newLayer) {
     156    public void layerAdded(LayerAddEvent e) {
    151157        // Do nothing
    152158    }
     
    156162     */
    157163    @Override
    158     public void layerRemoved(Layer oldLayer) {
    159         if (oldLayer instanceof OsmDataLayer && Main.isDisplayingMapView() && !Main.main.hasEditLayer()) {
     164    public void layerRemoving(LayerRemoveEvent e) {
     165        if (e.getRemovedLayer() instanceof OsmDataLayer && Main.isDisplayingMapView() && !Main.main.hasEditLayer()) {
    160166            Main.main.removeLayer(this);
    161         } else if (oldLayer == this) {
    162             MapView.removeLayerChangeListener(this);
     167        } else if (e.getRemovedLayer() == this) {
     168            Main.getLayerManager().removeLayerChangeListener(this);
    163169            OsmValidator.errorLayer = null;
    164170        }
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r10364 r10386  
    5151import org.openstreetmap.josm.gui.MapFrame.MapModeChangeListener;
    5252import org.openstreetmap.josm.gui.MapView;
    53 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    5453import org.openstreetmap.josm.gui.NavigatableComponent;
    5554import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     
    6261import org.openstreetmap.josm.gui.layer.JumpToMarkerActions.JumpToPreviousMarker;
    6362import org.openstreetmap.josm.gui.layer.Layer;
     63import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     64import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     65import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
     66import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
     67import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     68import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    6469import org.openstreetmap.josm.gui.util.GuiHelper;
    6570import org.openstreetmap.josm.io.JpgImporter;
     
    889894        mapModeListener.mapModeChange(null, Main.map.mapMode);
    890895
    891         MapView.addLayerChangeListener(new LayerChangeListener() {
     896        Main.getLayerManager().addActiveLayerChangeListener(new ActiveLayerChangeListener() {
    892897            @Override
    893             public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    894                 if (newLayer == GeoImageLayer.this) {
     898            public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
     899                if (Main.getLayerManager().getActiveLayer() == GeoImageLayer.this) {
    895900                    // only in select mode it is possible to click the images
    896901                    Main.map.selectSelectTool(false);
    897902                }
    898903            }
    899 
     904        });
     905
     906        Main.getLayerManager().addLayerChangeListener(new LayerChangeListener() {
    900907            @Override
    901             public void layerAdded(Layer newLayer) {
     908            public void layerAdded(LayerAddEvent e) {
    902909                // Do nothing
    903910            }
    904911
    905912            @Override
    906             public void layerRemoved(Layer oldLayer) {
    907                 if (oldLayer == GeoImageLayer.this) {
     913            public void layerRemoving(LayerRemoveEvent e) {
     914                if (e.getRemovedLayer() == GeoImageLayer.this) {
    908915                    stopLoadThumbs();
    909916                    Main.map.mapView.removeMouseListener(mouseAdapter);
     
    915922                    data = null;
    916923                    // stop listening to layer change events
    917                     MapView.removeLayerChangeListener(this);
    918                 }
     924                    Main.getLayerManager().removeLayerChangeListener(this);
     925                }
     926            }
     927
     928            @Override
     929            public void layerOrderChanged(LayerOrderChangeEvent e) {
     930                // Do nothing
    919931            }
    920932        });
  • trunk/src/org/openstreetmap/josm/gui/widgets/OsmPrimitivesTable.java

    r9497 r10386  
    1010import javax.swing.table.TableColumnModel;
    1111
     12import org.openstreetmap.josm.Main;
    1213import org.openstreetmap.josm.actions.ZoomToAction;
    1314import org.openstreetmap.josm.data.osm.OsmPrimitive;
    14 import org.openstreetmap.josm.gui.MapView;
    1515import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1616
     
    8383        JPopupMenu menu = new JPopupMenu();
    8484        zoomToAction = buildZoomToAction();
    85         MapView.addLayerChangeListener(zoomToAction);
     85        Main.getLayerManager().addLayerChangeListener(zoomToAction);
     86        Main.getLayerManager().addActiveLayerChangeListener(zoomToAction);
    8687        getSelectionModel().addListSelectionListener(zoomToAction);
    8788        menu.add(zoomToAction);
     
    9091
    9192    public void unlinkAsListener() {
    92         MapView.removeLayerChangeListener(zoomToAction);
     93        Main.getLayerManager().removeLayerChangeListener(zoomToAction);
     94        Main.getLayerManager().removeActiveLayerChangeListener(zoomToAction);
    9395    }
    9496
  • trunk/src/org/openstreetmap/josm/io/FileImporter.java

    r10212 r10386  
    1313import org.openstreetmap.josm.actions.ExtensionFileFilter;
    1414import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    15 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    1615import org.openstreetmap.josm.gui.Notification;
    17 import org.openstreetmap.josm.gui.layer.Layer;
    1816import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1917import org.openstreetmap.josm.gui.util.GuiHelper;
     
    2220 * Abstract file importer.
    2321 * @since 1637
     22 * @since 10386 (signature)
    2423 */
    25 public abstract class FileImporter implements Comparable<FileImporter>, LayerChangeListener {
     24public abstract class FileImporter implements Comparable<FileImporter> {
    2625
    2726    /**
     
    182181        this.enabled = enabled;
    183182    }
    184 
    185     @Override
    186     public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    187         // To be overriden by subclasses if their enabled state depends of the active layer nature
    188     }
    189 
    190     @Override
    191     public void layerAdded(Layer newLayer) {
    192         // To be overriden by subclasses if needed
    193     }
    194 
    195     @Override
    196     public void layerRemoved(Layer oldLayer) {
    197         // To be overriden by subclasses if needed
    198     }
    199183}
Note: See TracChangeset for help on using the changeset viewer.