Changeset 1844 in josm for trunk/src


Ignore:
Timestamp:
2009-07-25T18:44:11+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3018 : Make sure tools menu entries (and actions) are deactivated when no layer
Didn't apply the patch. Fixed it with slight modification in DrawAction. Applied patch for ReverseAction, though.

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
4 edited

Legend:

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

    r1834 r1844  
    120120    @Override
    121121    protected void updateEnabledState() {
    122         if (getCurrentDataSet() == null) {
     122        if (getCurrentDataSet() == null || Main.pasteBuffer == null) {
    123123            setEnabled(false);
    124124            return;
    125         }
    126         if (Main.pasteBuffer == null) {
    127             setEnabled(false);
    128125        }
    129126        setEnabled(
  • trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java

    r1820 r1844  
    1818import org.openstreetmap.josm.corrector.ReverseWayTagCorrector;
    1919import org.openstreetmap.josm.corrector.UserCancelException;
    20 import org.openstreetmap.josm.data.SelectionChangedListener;
    2120import org.openstreetmap.josm.data.osm.DataSet;
    2221import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2322import org.openstreetmap.josm.data.osm.Way;
    24 import org.openstreetmap.josm.gui.layer.Layer;
    25 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;
    2623import org.openstreetmap.josm.tools.Shortcut;
    2724
    28 public final class ReverseWayAction extends JosmAction implements SelectionChangedListener, LayerChangeListener {
     25public final class ReverseWayAction extends JosmAction {
    2926
    3027    public ReverseWayAction() {
    3128        super(tr("Reverse Ways"), "wayflip", tr("Reverse the direction of all selected ways."),
    3229                Shortcut.registerShortcut("tools:reverse", tr("Tool: {0}", tr("Reverse Ways")), KeyEvent.VK_R, Shortcut.GROUP_EDIT), true);
    33         DataSet.selListeners.add(this);
    34         Layer.listeners.add(this);
    35         refreshEnabled();
    3630    }
    3731
     
    9387    }
    9488
    95     protected void refreshEnabled() {
     89    @Override
     90    protected void updateEnabledState() {
    9691        setEnabled(getNumWaysInSelection() > 0);
    9792    }
    98 
    99     public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    100         refreshEnabled();
    101     }
    102 
    103     public void layerAdded(Layer newLayer) {
    104         refreshEnabled();
    105 
    106     }
    107 
    108     public void layerRemoved(Layer oldLayer) {
    109         refreshEnabled();
    110     }
    111 
    112     public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    113         refreshEnabled();
    114     }
    11593}
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r1842 r1844  
    3131import java.util.Map;
    3232import java.util.Set;
     33import java.util.logging.Logger;
    3334
    3435import javax.swing.JComponent;
     
    6263 */
    6364public class DrawAction extends MapMode implements MapViewPaintable, SelectionChangedListener, AWTEventListener {
     65    static private final Logger logger = Logger.getLogger(DrawAction.class.getName());
     66
    6467    final private Cursor cursorCrosshair;
    6568    final private Cursor cursorJoinNode;
     
    239242        } catch (SecurityException ex) {
    240243        }
     244
     245        // when exiting we let everybody know about the currently selected
     246        // primitives
     247        //
     248        DataSet.fireSelectionChanged(getCurrentDataSet().getSelected());
    241249    }
    242250
     
    274282     */
    275283    private void finishDrawing() {
     284        // let everybody else know about the current selection
     285        //
     286        DataSet.fireSelectionChanged(getCurrentDataSet().getSelected());
    276287        lastUsedNode = null;
    277288        wayIsFinished = true;
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r1842 r1844  
    1818import java.util.List;
    1919import java.util.TreeSet;
     20import java.util.logging.Logger;
    2021
    2122import javax.swing.JOptionPane;
     
    5960 */
    6061public class SelectAction extends MapMode implements SelectionEnded {
     62    static private final Logger logger = Logger.getLogger(SelectAction.class.getName());
    6163
    6264    /**
Note: See TracChangeset for help on using the changeset viewer.