source: osm/applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ClearChosenRelationAction.java@ 36287

Last change on this file since 36287 was 36217, checked in by GerdP, 7 months ago

fix #23521: fix some memory leaks

  • dispose dialogs
  • either avoid to create clones of ways or relations or use setNodes(null) / setMembers(null)
  • replaces most ChangeCommand instances by better specialized alternatives
  • add some comments
  • fix some checkstyle / sonar issues
File size: 1.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package relcontext.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7
8import javax.swing.AbstractAction;
9import javax.swing.Action;
10
11import org.openstreetmap.josm.data.osm.Relation;
12import org.openstreetmap.josm.tools.ImageProvider;
13
14import relcontext.ChosenRelation;
15import relcontext.ChosenRelationListener;
16
17public class ClearChosenRelationAction extends AbstractAction implements ChosenRelationListener {
18 private final transient ChosenRelation rel;
19
20 public ClearChosenRelationAction(ChosenRelation rel) {
21 super();
22 // putValue(Action.NAME, "X");
23 putValue(Action.SMALL_ICON, ImageProvider.get("relcontext", "clear"));
24 putValue(Action.SHORT_DESCRIPTION, tr("Clear the chosen relation"));
25 this.rel = rel;
26 rel.addChosenRelationListener(this);
27 setEnabled(false);
28 }
29
30 @Override
31 public void actionPerformed(ActionEvent e) {
32 rel.clear();
33 }
34
35 @Override
36 public void chosenRelationChanged(Relation oldRelation, Relation newRelation) {
37 setEnabled(newRelation != null);
38 }
39}
Note: See TracBrowser for help on using the repository browser.