source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/DeleteCurrentRelationAction.java@ 18967

Last change on this file since 18967 was 18967, checked in by GerdP, 4 months ago

fix #23447: Fatal "crash" attempting to delete all "Outer" members & then multipolygon

  • disable the delete action in the relation editor if the relation has the status deleted
  • in DeleteCurrentRelationAction updateEnabledState() now uses getRelaion() instead of getRelationSnapshot(), similar to the actionPerformed() method
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.relation.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7import java.beans.PropertyChangeEvent;
8
9import org.openstreetmap.josm.actions.mapmode.DeleteAction;
10import org.openstreetmap.josm.data.osm.Relation;
11import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor;
12import org.openstreetmap.josm.tools.ImageProvider;
13
14/**
15 * Delete the currently edited relation.
16 * @since 9496
17 */
18public class DeleteCurrentRelationAction extends AbstractRelationEditorAction {
19 private static final long serialVersionUID = 1L;
20
21 /**
22 * Constructs a new {@code DeleteCurrentRelationAction}.
23 * @param editorAccess An interface to access the relation editor contents.
24 */
25 public DeleteCurrentRelationAction(IRelationEditorActionAccess editorAccess) {
26 super(editorAccess);
27 putValue(SHORT_DESCRIPTION, tr("Delete the currently edited relation"));
28 new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this, true);
29 putValue(NAME, tr("Delete"));
30 updateEnabledState();
31 }
32
33 @Override
34 public void actionPerformed(ActionEvent e) {
35 Relation toDelete = getEditor().getRelation();
36 if (toDelete == null)
37 return;
38 DeleteAction.deleteRelation(getLayer(), toDelete);
39 }
40
41 @Override
42 public void updateEnabledState() {
43 Relation r = getEditor().getRelation();
44 setEnabled(r != null && !r.isDeleted());
45 }
46
47 @Override
48 public void propertyChange(PropertyChangeEvent evt) {
49 // Do not call super.
50 if (GenericRelationEditor.RELATION_SNAPSHOT_PROP.equals(evt.getPropertyName())) {
51 updateEnabledState();
52 }
53 }
54}
Note: See TracBrowser for help on using the repository browser.