Changeset 10364 in josm for trunk


Ignore:
Timestamp:
2016-06-12T20:46:23+02:00 (8 years ago)
Author:
stoecker
Message:

gsoc-core - patch by Michael Zangl - see #12953 - remove deprecation usage

Location:
trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/SelectCommand.java

    r9989 r10364  
    3838    @Override
    3939    public void undoCommand() {
    40         Main.map.mapView.getEditLayer().data.setSelected(oldSelection);
     40        Main.getLayerManager().getEditLayer().data.setSelected(oldSelection);
    4141    }
    4242
    4343    @Override
    4444    public boolean executeCommand() {
    45         oldSelection = Main.map.mapView.getEditLayer().data.getSelected();
    46         Main.map.mapView.getEditLayer().data.setSelected(newSelection);
     45        oldSelection = Main.getLayerManager().getEditLayer().data.getSelected();
     46        Main.getLayerManager().getEditLayer().data.setSelected(newSelection);
    4747        return true;
    4848    }
  • trunk/src/org/openstreetmap/josm/command/conflict/ConflictAddCommand.java

    r9371 r10364  
    6262    @Override
    6363    public void undoCommand() {
    64         if (Main.isDisplayingMapView() && !Main.map.mapView.hasLayer(getLayer())) {
     64        if (Main.isDisplayingMapView() && !Main.getLayerManager().containsLayer(getLayer())) {
    6565            Main.warn(tr("Layer ''{0}'' does not exist any more. Cannot remove conflict for object ''{1}''.",
    6666                    getLayer().getName(),
  • trunk/src/org/openstreetmap/josm/command/conflict/ConflictResolveCommand.java

    r9371 r10364  
    7171
    7272        if (Main.isDisplayingMapView()) {
    73             if (!Main.map.mapView.hasLayer(getLayer())) {
     73            if (!Main.getLayerManager().containsLayer(getLayer())) {
    7474                Main.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
    7575                        this.toString(),
     
    7979            }
    8080
    81             Main.map.mapView.setActiveLayer(getLayer());
     81            Main.getLayerManager().setActiveLayer(getLayer());
    8282        }
    8383        reconstituteConflicts();
  • trunk/src/org/openstreetmap/josm/command/conflict/RelationMemberConflictResolverCommand.java

    r9371 r10364  
    7575    public void undoCommand() {
    7676        OsmDataLayer layer = getLayer();
    77         if (!Main.map.mapView.hasLayer(layer)) {
     77        if (!Main.getLayerManager().containsLayer(layer)) {
    7878            Main.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
    7979                    this.toString(),
     
    8383        }
    8484
    85         Main.map.mapView.setActiveLayer(layer);
     85        Main.getLayerManager().setActiveLayer(layer);
    8686        OsmDataLayer editLayer = Main.main.getEditLayer();
    8787
  • trunk/src/org/openstreetmap/josm/data/AutosaveTask.java

    r10300 r10364  
    127127            MapView.addLayerChangeListener(this);
    128128            if (Main.isDisplayingMapView()) {
    129                 for (OsmDataLayer l: Main.map.mapView.getLayersOfType(OsmDataLayer.class)) {
     129                for (OsmDataLayer l: Main.getLayerManager().getLayersOfType(OsmDataLayer.class)) {
    130130                    registerNewlayer(l);
    131131                }
  • trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java

    r10345 r10364  
    7070        @Override
    7171        public void actionPerformed(ActionEvent e) {
    72             Collection<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
     72            Collection<ImageryLayer> layers = Main.getLayerManager().getLayersOfType(ImageryLayer.class);
    7373            if (layers.isEmpty()) {
    7474                setEnabled(false);
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r10340 r10364  
    417417    public static void addEditLayerChangeListener(EditLayerChangeListener listener, boolean initialFire) {
    418418        if (listener != null) {
    419             boolean doFire = initialFire && Main.isDisplayingMapView() && Main.map.mapView.getEditLayer() != null;
     419            boolean doFire = initialFire && Main.isDisplayingMapView() && Main.getLayerManager().getEditLayer() != null;
    420420            if (doFire) {
    421421                Main.getLayerManager().addAndFireActiveLayerChangeListener(new EditLayerChangeAdapter(listener));
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java

    r10210 r10364  
    891891    protected final <P extends OsmPrimitive> OsmDataLayer findLayerFor(P primitive) {
    892892        if (primitive != null) {
    893             Iterable<OsmDataLayer> layers = Main.map.mapView.getLayersOfType(OsmDataLayer.class);
     893            Iterable<OsmDataLayer> layers = Main.getLayerManager().getLayersOfType(OsmDataLayer.class);
    894894            // Find layer with same dataset
    895895            for (OsmDataLayer layer : layers) {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/layer/DuplicateAction.java

    r10346 r10364  
    5757
    5858        List<String> layerNames = new ArrayList<>();
    59         for (Layer l: Main.map.mapView.getAllLayers()) {
     59        for (Layer l: Main.getLayerManager().getLayers()) {
    6060            layerNames.add(l.getName());
    6161        }
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r10175 r10364  
    300300            drawHelper.readPreferences(getName());
    301301            drawHelper.drawAll(g, mv, visibleSegments);
    302             if (Main.map.mapView.getActiveLayer() == this) {
     302            if (Main.getLayerManager().getActiveLayer() == this) {
    303303                drawHelper.drawColorBar(g, mv);
    304304            }
  • trunk/src/org/openstreetmap/josm/gui/layer/Layer.java

    r10181 r10364  
    171171        long memoryBytesRequired = 50L * 1024L * 1024L; // assumed minimum JOSM memory footprint
    172172        if (Main.map != null && Main.map.mapView != null) {
    173             for (Layer layer: Main.map.mapView.getAllLayers()) {
     173            for (Layer layer: Main.getLayerManager().getLayers()) {
    174174                memoryBytesRequired += layer.estimateMemoryUsage();
    175175            }
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r10308 r10364  
    181181                // If none, we'll zoom to the bounding box of the layer with the photos.
    182182                boolean boundingBoxedLayerFound = false;
    183                 for (Layer l: Main.map.mapView.getAllLayers()) {
     183                for (Layer l: Main.getLayerManager().getLayers()) {
    184184                    if (l != yLayer) {
    185185                        BoundingXYVisitor bbox = new BoundingXYVisitor();
     
    557557    public void actionPerformed(ActionEvent arg0) {
    558558        // Construct the list of loaded GPX tracks
    559         Collection<Layer> layerLst = Main.map.mapView.getAllLayers();
     559        Collection<Layer> layerLst = Main.getLayerManager().getLayers();
    560560        GpxDataWrapper defaultItem = null;
    561561        for (Layer cur : layerLst) {
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r10173 r10364  
    784784    private void clearOtherCurrentPhotos() {
    785785        for (GeoImageLayer layer:
    786                  Main.map.mapView.getLayersOfType(GeoImageLayer.class)) {
     786                 Main.getLayerManager().getLayersOfType(GeoImageLayer.class)) {
    787787            if (layer != this) {
    788788                layer.clearCurrentPhoto(false);
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackAction.java

    r10228 r10364  
    116116            return null;
    117117        }
    118         List<AbstractTileSourceLayer> targetLayers = Main.map.mapView.getLayersOfType(AbstractTileSourceLayer.class);
     118        List<AbstractTileSourceLayer> targetLayers = Main.getLayerManager().getLayersOfType(AbstractTileSourceLayer.class);
    119119        if (targetLayers.isEmpty()) {
    120120            if (!GraphicsEnvironment.isHeadless()) {
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r10300 r10364  
    449449            return;
    450450        Marker m = null;
    451         Layer l = Main.map.mapView.getActiveLayer();
     451        Layer l = Main.getLayerManager().getActiveLayer();
    452452        if (l != null) {
    453453            m = getAdjacentMarker(startMarker, next, l);
    454454        }
    455455        if (m == null) {
    456             for (Layer layer : Main.map.mapView.getAllLayers()) {
     456            for (Layer layer : Main.getLayerManager().getLayers()) {
    457457                m = getAdjacentMarker(startMarker, next, layer);
    458458                if (m != null) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java

    r10179 r10364  
    7070
    7171        private static boolean mapHasGpxorMarkerLayer() {
    72             for (Layer layer : Main.map.mapView.getAllLayers()) {
     72            for (Layer layer : Main.getLayerManager().getLayers()) {
    7373                if (layer instanceof GpxLayer || layer instanceof MarkerLayer) {
    7474                    return true;
  • trunk/src/org/openstreetmap/josm/io/NoteImporter.java

    r9797 r10364  
    3838        try (InputStream is = Compression.getUncompressedFileInputStream(file)) {
    3939            final NoteLayer layer = loadLayer(is, file, file.getName(), progressMonitor);
    40             if (Main.map == null || !Main.map.mapView.hasLayer(layer)) {
     40            if (Main.map == null || !Main.getLayerManager().containsLayer(layer)) {
    4141                GuiHelper.runInEDT(new Runnable() {
    4242                    @Override
     
    6969        List<NoteLayer> noteLayers = null;
    7070        if (Main.map != null) {
    71             noteLayers = Main.map.mapView.getLayersOfType(NoteLayer.class);
     71            noteLayers = Main.getLayerManager().getLayersOfType(NoteLayer.class);
    7272        }
    7373        final NoteLayer layer;
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r10212 r10364  
    249249             * been disabled! */
    250250            if (Main.isDisplayingMapView()) {
    251                 for (Layer l : Main.map.mapView.getLayersOfType(ImageryLayer.class)) {
     251                for (Layer l : Main.getLayerManager().getLayersOfType(ImageryLayer.class)) {
    252252                    if (((ImageryLayer) l).getInfo().isBlacklisted()) {
    253253                        Main.info(tr("Removed layer {0} because it is not allowed by the configured API.", l.getName()));
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java

    r10116 r10364  
    9595        final ImageryInfo imgInfo = buildImageryInfo();
    9696        if (Main.isDisplayingMapView()) {
    97             for (ImageryLayer layer : Main.map.mapView.getLayersOfType(ImageryLayer.class)) {
     97            for (ImageryLayer layer : Main.getLayerManager().getLayersOfType(ImageryLayer.class)) {
    9898                if (layer.getInfo().equals(imgInfo)) {
    9999                    Main.info("Imagery layer already exists: "+imgInfo);
  • trunk/src/org/openstreetmap/josm/io/session/MarkerSessionExporter.java

    r9983 r10364  
    4444    public Collection<Layer> getDependencies() {
    4545        Layer gpxLayer = layer.fromLayer;
    46         if (gpxLayer != null && Main.map.mapView.hasLayer(gpxLayer))
     46        if (gpxLayer != null && Main.getLayerManager().containsLayer(gpxLayer))
    4747            return Collections.singleton(gpxLayer);
    4848        return Collections.emptySet();
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r10340 r10364  
    124124                Main.main.createMapFrame(null, null);
    125125            } else {
    126                 for (Layer l: Main.map.mapView.getAllLayers()) {
     126                for (Layer l: Main.getLayerManager().getLayers()) {
    127127                    Main.map.mapView.removeLayer(l);
    128128                }
  • trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java

    r10188 r10364  
    4747    @Test
    4848    public void testActionPerformedEnabled() {
    49         assertTrue(Main.map.mapView.getLayersOfType(TMSLayer.class).isEmpty());
     49        assertTrue(Main.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
    5050        new AddImageryLayerAction(new ImageryInfo("foo_tms", "http://bar", "tms", null, null)).actionPerformed(null);
    51         List<TMSLayer> tmsLayers = Main.map.mapView.getLayersOfType(TMSLayer.class);
     51        List<TMSLayer> tmsLayers = Main.getLayerManager().getLayersOfType(TMSLayer.class);
    5252        assertEquals(1, tmsLayers.size());
    5353
     
    5555            new AddImageryLayerAction(new ImageryInfo("wms.openstreetmap.fr", "http://wms.openstreetmap.fr/wms?",
    5656                    "wms_endpoint", null, null)).actionPerformed(null);
    57             List<WMSLayer> wmsLayers = Main.map.mapView.getLayersOfType(WMSLayer.class);
     57            List<WMSLayer> wmsLayers = Main.getLayerManager().getLayersOfType(WMSLayer.class);
    5858            assertEquals(1, wmsLayers.size());
    5959
     
    6969    @Test
    7070    public void testActionPerformedDisabled() {
    71         assertTrue(Main.map.mapView.getLayersOfType(TMSLayer.class).isEmpty());
     71        assertTrue(Main.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
    7272        new AddImageryLayerAction(new ImageryInfo()).actionPerformed(null);
    73         assertTrue(Main.map.mapView.getLayersOfType(TMSLayer.class).isEmpty());
     73        assertTrue(Main.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
    7474    }
    7575}
  • trunk/test/unit/org/openstreetmap/josm/command/conflict/ConflictAddCommandTest.java

    r9943 r10364  
    5151    @Test
    5252    public void testExecuteUndoCommand() {
    53         OsmDataLayer layer = Main.map.mapView.getEditLayer();
     53        OsmDataLayer layer = Main.getLayerManager().getEditLayer();
    5454        Conflict<Node> conflict = new Conflict<>(new Node(), new Node());
    5555        ConflictAddCommand cmd = new ConflictAddCommand(layer, conflict);
     
    6767    @Test
    6868    public void testGetDescriptionIcon() {
    69         OsmDataLayer layer = Main.map.mapView.getEditLayer();
     69        OsmDataLayer layer = Main.getLayerManager().getEditLayer();
    7070        Conflict<Node> conflict = new Conflict<>(new Node(), new Node());
    7171        assertNotNull(new ConflictAddCommand(layer, conflict).getDescriptionIcon());
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayerTest.java

    r9669 r10364  
    4949                        gpxLayer).run();
    5050                assertEquals(2, Main.map.mapView.getNumLayers());
    51                 GeoImageLayer layer = Main.map.mapView.getLayersOfType(GeoImageLayer.class).iterator().next();
     51                GeoImageLayer layer = Main.getLayerManager().getLayersOfType(GeoImageLayer.class).iterator().next();
    5252                try {
    5353                    assertEquals(gpxLayer, layer.getGpxLayer());
  • trunk/test/unit/org/openstreetmap/josm/io/NoteImporterTest.java

    r10054 r10364  
    2323    public void testTicket12531() {
    2424        if (Main.map != null) {
    25             for (Layer l: Main.map.mapView.getAllLayers()) {
     25            for (Layer l: Main.getLayerManager().getLayers()) {
    2626                Main.map.mapView.removeLayer(l);
    2727            }
  • trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java

    r9732 r10364  
    9595            newHandler("https://localhost?url=" + Utils.encodeUrl(url)).handle();
    9696        } finally {
    97             for (OsmDataLayer layer : Main.map.mapView.getLayersOfType(OsmDataLayer.class)) {
     97            for (OsmDataLayer layer : Main.getLayerManager().getLayersOfType(OsmDataLayer.class)) {
    9898                Main.main.removeLayer(layer);
    9999            }
  • trunk/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java

    r10218 r10364  
    139139    public void testReadNotes() throws IOException, IllegalDataException {
    140140        if (Main.isDisplayingMapView()) {
    141             for (NoteLayer nl : Main.map.mapView.getLayersOfType(NoteLayer.class)) {
     141            for (NoteLayer nl : Main.getLayerManager().getLayersOfType(NoteLayer.class)) {
    142142                Main.map.mapView.removeLayer(nl);
    143143            }
Note: See TracChangeset for help on using the changeset viewer.