Changeset 4567 in josm


Ignore:
Timestamp:
2011-11-02T15:44:20+01:00 (13 years ago)
Author:
stoecker
Message:

fix #6875 - patch by Larry0ua - Data Layer can be changed after selecting another layer

Location:
trunk
Files:
12 edited

Legend:

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

    r4489 r4567  
    278278            final MapFrame mapFrame = new MapFrame(contentPanePrivate);
    279279            setMapFrame(mapFrame);
    280             mapFrame.selectMapMode((MapMode)mapFrame.getDefaultButtonAction());
     280            mapFrame.selectMapMode((MapMode)mapFrame.getDefaultButtonAction(), layer);
    281281            mapFrame.setVisible(true);
    282282            mapFrame.initializeDialogsPane();
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r4488 r4567  
    288288        return button;
    289289    }
    290    
     290
    291291    public void validateToolBarToggle() {
    292292        toolBarToggle.removeAll();
     
    320320    /**
    321321     * Change the operating map mode for the view. Will call unregister on the
    322      * old MapMode and register on the new one.
     322     * old MapMode and register on the new one. Now this function also verifies
     323     * if new map mode is correct mode for current layer and does not change mode
     324     * in such cases.
    323325     * @param mapMode   The new mode to set.
    324326     */
    325327    public void selectMapMode(MapMode newMapMode) {
     328        selectMapMode(newMapMode, mapView.getActiveLayer());
     329    }
     330
     331    /**
     332     * Another version of the selectMapMode for changing layer action.
     333     * Pass newly selected layer to this method.
     334     * @param newMapMode
     335     * @param newLayer
     336     */
     337    public void selectMapMode(MapMode newMapMode, Layer newLayer) {
     338        if (newMapMode == null || !newMapMode.layerIsSupported(newLayer))
     339            return;
     340
    326341        MapMode oldMapMode = this.mapMode;
    327342        if (newMapMode == oldMapMode)
     
    332347        this.mapMode = newMapMode;
    333348        newMapMode.enterMode();
    334         lastMapMode.put(mapView.getActiveLayer(), newMapMode);
     349        lastMapMode.put(newLayer, newMapMode);
    335350        fireMapModeChanged(oldMapMode, newMapMode);
    336351    }
     
    474489            modeChanged = newMapMode != mapMode;
    475490            if (newMapMode != null) {
    476                 selectMapMode(newMapMode);
    477             } // it would be nice to select first supported mode when layer is first selected, but it don't work well with for example editgpx layer
     491                selectMapMode(newMapMode, newLayer); // it would be nice to select first supported mode when layer is first selected, but it don't work well with for example editgpx layer
     492            } else {
     493                mapMode.exitMode(); // if new mode is null - simply exit from previous mode
     494            }
    478495        }
    479496        if (!modeChanged && mapMode != null) {
Note: See TracChangeset for help on using the changeset viewer.