Changeset 1379 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2009-02-08T11:34:23+01:00 (16 years ago)
Author:
stoecker
Message:

apply #2127. patch by xeen

Location:
trunk/src/org/openstreetmap/josm
Files:
6 edited

Legend:

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

    r1169 r1379  
    1515import org.openstreetmap.josm.data.osm.WaySegment;
    1616import org.openstreetmap.josm.gui.MapFrame;
     17import org.openstreetmap.josm.gui.layer.Layer;
     18import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1719import org.openstreetmap.josm.tools.ImageProvider;
    1820import org.openstreetmap.josm.tools.Shortcut;
     
    129131        return tr("Click to delete. Shift: delete way segment. Alt: don't delete unused nodes when deleting a way. Ctrl: delete referring objects.");
    130132    }
     133   
     134    @Override public boolean layerIsSupported(Layer l) {
     135        return l instanceof OsmDataLayer;
     136    }
    131137}
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r1317 r1379  
    5050import org.openstreetmap.josm.gui.MapView;
    5151import org.openstreetmap.josm.gui.layer.MapViewPaintable;
     52import org.openstreetmap.josm.gui.layer.Layer;
     53import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    5254import org.openstreetmap.josm.tools.ImageProvider;
    5355import org.openstreetmap.josm.tools.Pair;
     
    647649        return rv.toString();
    648650    }
     651   
     652    @Override public boolean layerIsSupported(Layer l) {
     653        return l instanceof OsmDataLayer;
     654    }
    649655}
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java

    r1313 r1379  
    2929import org.openstreetmap.josm.gui.MapView;
    3030import org.openstreetmap.josm.gui.layer.MapViewPaintable;
     31import org.openstreetmap.josm.gui.layer.Layer;
     32import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3133import org.openstreetmap.josm.tools.ImageProvider;
    3234import org.openstreetmap.josm.tools.Shortcut;
     
    257259        }
    258260    }
     261               
     262                @Override public boolean layerIsSupported(Layer l) {
     263                                return l instanceof OsmDataLayer;
     264                }
    259265}
  • trunk/src/org/openstreetmap/josm/actions/mapmode/MapMode.java

    r1180 r1379  
    1010import org.openstreetmap.josm.Main;
    1111import org.openstreetmap.josm.actions.JosmAction;
     12import org.openstreetmap.josm.gui.layer.Layer;
    1213import org.openstreetmap.josm.gui.MapFrame;
    1314import org.openstreetmap.josm.tools.ImageProvider;
     
    7172            Main.map.selectMapMode(this);
    7273    }
     74   
     75    // By default, all tools will work with all layers. Can be overwritten to require
     76    // a special type of layer
     77    public boolean layerIsSupported(Layer l) {
     78        return true;
     79    }
    7380
    7481    public void mouseReleased(MouseEvent e) {}
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r1313 r1379  
    3232import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor;
    3333import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
     34import org.openstreetmap.josm.gui.layer.Layer;
     35import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3436import org.openstreetmap.josm.gui.MapFrame;
    3537import org.openstreetmap.josm.gui.MapView;
     
    395397        }
    396398    }
     399   
     400    @Override public boolean layerIsSupported(Layer l) {
     401        return l instanceof OsmDataLayer;
     402    }
    397403}
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r1265 r1379  
    1515import java.awt.image.BufferedImage;
    1616import java.util.ArrayList;
     17import java.util.Enumeration;
    1718import java.util.Collection;
    1819import java.util.Collections;
    1920import java.util.LinkedList;
    2021
     22import javax.swing.AbstractButton;
    2123import javax.swing.JComponent;
    2224import javax.swing.JOptionPane;
     
    2527import org.openstreetmap.josm.actions.AutoScaleAction;
    2628import org.openstreetmap.josm.actions.JosmAction;
     29import org.openstreetmap.josm.actions.mapmode.MapMode;
    2730import org.openstreetmap.josm.actions.MoveAction;
    2831import org.openstreetmap.josm.data.Bounds;
     
    357360                l.activeLayerChange(old, layer);
    358361        }
     362       
     363        /* This only makes the buttons look disabled. Disabling the actions as well requires
     364         * the user to re-select the tool after i.e. moving a layer. While testing I found
     365         * that I switch layers and actions at the same time and it was annoying to mind the
     366         * order. This way it works as visual clue for new users */
     367        for (Enumeration e = Main.map.toolGroup.getElements() ; e.hasMoreElements() ;) {
     368            AbstractButton x=(AbstractButton)e.nextElement();
     369            x.setEnabled(((MapMode)x.getAction()).layerIsSupported(layer));
     370        }
    359371        repaint();
    360372    }
Note: See TracChangeset for help on using the changeset viewer.