Ignore:
Timestamp:
21.07.2009 19:52:53 (3 years ago)
Author:
Gubaer
Message:

JosmAction is now a LayerChangeListener and a SelectionChangeListener
updated all JosmActions
fixed #3018: Make sure tools menu entries (and actions) are deactivated when no layer

File:
1 edited

Legend:

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

    r1814 r1820  
    1515import org.openstreetmap.josm.Main; 
    1616import org.openstreetmap.josm.command.AddCommand; 
     17import org.openstreetmap.josm.data.coor.LatLon; 
    1718import org.openstreetmap.josm.data.osm.Node; 
    18 import org.openstreetmap.josm.data.coor.LatLon; 
    19 import org.openstreetmap.josm.gui.layer.Layer; 
    20 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener; 
    2119import org.openstreetmap.josm.tools.GBC; 
    2220import org.openstreetmap.josm.tools.Shortcut; 
     
    2624 * and when ok is pressed, a new node is created at the specified position. 
    2725 */ 
    28 public final class AddNodeAction extends JosmAction implements LayerChangeListener { 
     26public final class AddNodeAction extends JosmAction { 
    2927 
    3028    public AddNodeAction() { 
     
    3230                Shortcut.registerShortcut("addnode", tr("Edit: {0}", tr("Add Node...")), KeyEvent.VK_D, Shortcut.GROUP_EDIT, 
    3331                        Shortcut.SHIFT_DEFAULT), true); 
    34         Layer.listeners.add(this); 
    35         refreshEnabled(); 
    36     } 
    37  
    38     protected void refreshEnabled() { 
    39         setEnabled(Main.map != null 
    40                 && Main.map.mapView != null 
    41                 && Main.map.mapView.getEditLayer() != null); 
    4232    } 
    4333 
     
    8373    } 
    8474 
    85     public void activeLayerChange(Layer oldLayer, Layer newLayer) { 
    86         refreshEnabled(); 
     75    @Override 
     76    protected void updateEnabledState() { 
     77        setEnabled(getEditLayer() != null); 
    8778    } 
    8879 
    89     public void layerAdded(Layer newLayer) { 
    90         refreshEnabled(); 
     80} 
    9181 
    92     } 
    93  
    94     public void layerRemoved(Layer oldLayer) { 
    95         refreshEnabled(); 
    96     } 
    97 } 
Note: See TracChangeset for help on using the changeset viewer.