Ignore:
Timestamp:
2016-06-19T16:08:56+02:00 (8 years ago)
Author:
donvip
Message:

fix #josm12953 - Replace most uses of MapView.getActiveLayer and similar methods (patch by michael2402, modified) - gsoc-core

Location:
applications/editors/josm/plugins/cadastre-fr
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/build.xml

    r32054 r32329  
    44    <property name="commit.message" value="Changed constructor for Plugin"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="9759"/>
     6    <property name="plugin.main.version" value="10279"/>
    77   
    88    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java

    r32212 r32329  
    576576    private static void checkLayerDuplicates(WMSLayer wmsLayer) throws DuplicateLayerException {
    577577        if (Main.map != null) {
    578             for (Layer l : Main.map.mapView.getAllLayers()) {
     578            for (Layer l : Main.getLayerManager().getLayers()) {
    579579                if (l instanceof WMSLayer && l.getName().equals(wmsLayer.getName()) && (!l.equals(wmsLayer))) {
    580580                    Main.info("Try to grab into a new layer when "+wmsLayer.getName()+" is already opened.");
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java

    r32164 r32329  
    456456    public static void addWMSLayer(WMSLayer wmsLayer) {
    457457        if (Main.map != null && Main.map.mapView != null) {
    458             int wmsNewLayerPos = Main.map.mapView.getAllLayers().size();
    459             for(Layer l : Main.map.mapView.getLayersOfType(WMSLayer.class)) {
     458            int wmsNewLayerPos = Main.getLayerManager().getLayers().size();
     459            for(Layer l : Main.getLayerManager().getLayersOfType(WMSLayer.class)) {
    460460                int wmsPos = Main.map.mapView.getLayerPos(l);
    461461                if (wmsPos < wmsNewLayerPos) wmsNewLayerPos = wmsPos;
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java

    r29714 r32329  
    22package cadastre_fr;
    33
     4import static org.openstreetmap.josm.tools.I18n.marktr;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    5 import static org.openstreetmap.josm.tools.I18n.marktr;
    66
    77import java.awt.event.ActionEvent;
     
    1212import org.openstreetmap.josm.Main;
    1313import org.openstreetmap.josm.actions.JosmAction;
    14 import org.openstreetmap.josm.gui.layer.Layer;
    1514
    1615public class MenuActionGrabPlanImage extends JosmAction implements Runnable {
     
    3635        if (wmsLayer == null || Main.map == null || Main.map.mapView == null) return;
    3736        if (!rasterImageGeoreferencer.isRunning()) return;
    38         for (Layer l : Main.map.mapView.getAllLayersAsList())
    39             if (l == wmsLayer)
    40                 return;
     37        if (Main.getLayerManager().containsLayer(wmsLayer))
     38                return;
    4139        JOptionPane.showMessageDialog(Main.parent, tr("Georeferencing interrupted"));
    4240        rasterImageGeoreferencer.actionInterrupted();
    4341    }
    4442
    45     public void actionPerformed(ActionEvent ae) {
     43    @Override
     44        public void actionPerformed(ActionEvent ae) {
    4645        if (Main.map != null) {
    4746            if (CadastrePlugin.isCadastreProjection()) {
     
    5857    }
    5958
    60     public void run() {
     59    @Override
     60        public void run() {
    6161        // wait until plan image is fully loaded and joined into one single image
    6262        boolean loadedFromCache = downloadWMSPlanImage.waitFinished();
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java

    r32211 r32329  
    6969                    // check if the selected cache is not already displayed
    7070                    if (Main.map != null) {
    71                         for (Layer l : Main.map.mapView.getAllLayers()) {
     71                        for (Layer l : Main.getLayerManager().getLayers()) {
    7272                            if (l instanceof WMSLayer && l.getName().equals(location)) {
    7373                                JOptionPane.showMessageDialog(Main.parent, tr("The location {0} is already on screen. Cache not loaded.", filename), tr("Error"), JOptionPane.ERROR_MESSAGE);
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java

    r32060 r32329  
    106106            Main.pref.put("cadastrewms.codeDepartement", codeDepartement);
    107107            if (Main.map != null) {
    108                 for (Layer l : Main.map.mapView.getAllLayers()) {
     108                for (Layer l : Main.getLayerManager().getLayers()) {
    109109                    if (l instanceof WMSLayer && l.getName().equalsIgnoreCase(location)) {
    110110                        return null;
     
    118118            CadastrePlugin.addWMSLayer(wmsLayer);
    119119            Main.info("Add new layer with Location:" + inputTown.getText());
    120         } else if (existingLayers != null && existingLayers.size() > 0 && Main.map.mapView.getActiveLayer() instanceof WMSLayer) {
    121             wmsLayer = (WMSLayer)Main.map.mapView.getActiveLayer();
     120        } else if (existingLayers != null && existingLayers.size() > 0 && Main.getLayerManager().getActiveLayer() instanceof WMSLayer) {
     121            wmsLayer = (WMSLayer)Main.getLayerManager().getActiveLayer();
    122122        }
    123123
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java

    r29595 r32329  
    4141    @Override public void enterMode() {
    4242        if (Main.map != null) {
    43             if (Main.map.mapView.getActiveLayer() instanceof WMSLayer) {
    44                 modifiedLayer = (WMSLayer)Main.map.mapView.getActiveLayer();
     43            if (Main.getLayerManager().getActiveLayer() instanceof WMSLayer) {
     44                modifiedLayer = (WMSLayer)Main.getLayerManager().getActiveLayer();
    4545                super.enterMode();
    4646                Main.map.mapView.addMouseListener(this);
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java

    r30737 r32329  
    2727        ArrayList<WMSLayer> existingWMSlayers = new ArrayList<>();
    2828        if (Main.map != null) {
    29             Layer activeLayer = Main.map.mapView.getActiveLayer();
     29            Layer activeLayer = Main.getLayerManager().getActiveLayer();
    3030            if (activeLayer instanceof WMSLayer)
    3131                return (WMSLayer) activeLayer;
    32             for (Layer l : Main.map.mapView.getAllLayers()) {
     32            for (Layer l : Main.getLayerManager().getLayers()) {
    3333                if (l instanceof WMSLayer) {
    3434                    existingWMSlayers.add((WMSLayer)l);
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java

    r32211 r32329  
    160160        grabThread.setGrabber(grabber);
    161161        // if it is the first layer, use the communeBBox as grab bbox (and not divided)
    162         if (Main.map.mapView.getAllLayers().size() == 1 ) {
     162        if (Main.getLayerManager().getLayers().size() == 1 ) {
    163163            final Bounds bounds = this.getCommuneBBox().toBounds();
    164164            GuiHelper.runInEDTAndWait(new Runnable() {
Note: See TracChangeset for help on using the changeset viewer.