Changeset 1087 in josm for trunk/src


Ignore:
Timestamp:
2008-11-19T03:18:28+01:00 (11 years ago)
Author:
framm
Message:
  • fixed some NPEs when users go crazy ointhe keyboard with no data loaded
Location:
trunk/src/org/openstreetmap/josm/actions
Files:
3 edited

Legend:

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

    r1084 r1087  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     5
     6import java.util.Collection;
    57
    68import java.awt.event.ActionEvent;
     
    911import org.openstreetmap.josm.Main;
    1012import org.openstreetmap.josm.tools.Shortcut;
     13import org.openstreetmap.josm.data.osm.DataSet;
     14import org.openstreetmap.josm.data.osm.OsmPrimitive;
     15import org.openstreetmap.josm.data.SelectionChangedListener;
    1116
    12 public final class DeleteAction extends JosmAction {
     17public final class DeleteAction extends JosmAction implements SelectionChangedListener {
    1318
    1419        public DeleteAction() {
    1520                super(tr("Delete"), "dialogs/delete", tr("Delete selected objects."),
    1621                Shortcut.registerShortcut("system:delete", tr("Edit: {0}", tr("Delete")), KeyEvent.VK_DELETE, Shortcut.GROUP_DIRECT), true);
    17                 setEnabled(true);
     22        DataSet.selListeners.add(this);
     23                setEnabled(false);
    1824        }
    1925
     
    2228                        .doActionPerformed(e);
    2329        }
     30    public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
     31        setEnabled(! newSelection.isEmpty());
     32    }
    2433}
  • trunk/src/org/openstreetmap/josm/actions/ZoomInAction.java

    r1084 r1087  
    1919
    2020        public void actionPerformed(ActionEvent e) {
     21        if (Main.map == null) return;
    2122                double zoom = Main.map.mapView.getScale();
    2223                Main.map.mapView.zoomTo(Main.map.mapView.getCenter(), zoom * .9);
  • trunk/src/org/openstreetmap/josm/actions/ZoomOutAction.java

    r1084 r1087  
    1919
    2020        public void actionPerformed(ActionEvent e) {
     21        if (Main.map == null) return;
    2122                double zoom = Main.map.mapView.getScale();
    2223                Main.map.mapView.zoomTo(Main.map.mapView.getCenter(), zoom /.9);
Note: See TracChangeset for help on using the changeset viewer.