Ignore:
Timestamp:
2009-12-13T10:00:16+01:00 (15 years ago)
Author:
guggis
Message:

'Rebuilding because of JOSM trac ticket #4156; Enabled state management in UploadAction'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadDataGuiPlugin.java

    r13497 r19082  
    1111import java.awt.event.ActionEvent;
    1212import java.awt.event.KeyEvent;
     13
    1314import org.openstreetmap.josm.Main;
    1415import org.openstreetmap.josm.actions.JosmAction;
    15 import org.openstreetmap.josm.gui.MapFrame;
     16import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
     17import org.openstreetmap.josm.gui.layer.GpxLayer;
    1618import org.openstreetmap.josm.gui.layer.Layer;
    1719import org.openstreetmap.josm.plugins.Plugin;
     
    2931    }
    3032
    31     class UploadAction extends JosmAction {
    32 
     33    class UploadAction extends JosmAction{
    3334        public UploadAction(){
    3435            super(tr("Upload Traces"), "UploadAction", tr("Uploads traces to openstreetmap.org"),
     
    4041            go.setVisible(true);
    4142        }
     43
     44        @Override
     45                protected void updateEnabledState() {
     46            if(Main.map == null
     47                    || Main.map.mapView == null
     48                    || Main.map.mapView.getActiveLayer() == null
     49                    || !(Main.map.mapView.getActiveLayer() instanceof GpxLayer)) {               
     50                setEnabled(false);
     51            } else {
     52                setEnabled(true);
     53            }
     54
     55                }               
    4256    }
    4357}
Note: See TracChangeset for help on using the changeset viewer.