source: osm/applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/EditChosenRelationAction.java@ 32398

Last change on this file since 32398 was 32398, checked in by donvip, 8 years ago

checkstyle

File size: 1.4 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;
9
10import org.openstreetmap.josm.Main;
11import org.openstreetmap.josm.data.osm.Relation;
12import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
13import org.openstreetmap.josm.tools.ImageProvider;
14
15import relcontext.ChosenRelation;
16import relcontext.ChosenRelationListener;
17
18/**
19 * Opens an editor for chosen relation.
20 *
21 * @author Zverik
22 */
23public class EditChosenRelationAction extends AbstractAction implements ChosenRelationListener {
24 private ChosenRelation rel;
25
26 public EditChosenRelationAction(ChosenRelation rel) {
27 putValue(SMALL_ICON, ImageProvider.get("dialogs/mappaint", "pencil"));
28 putValue(SHORT_DESCRIPTION, tr("Open relation editor for the chosen relation"));
29 this.rel = rel;
30 rel.addChosenRelationListener(this);
31 setEnabled(rel.get() != null);
32 }
33
34 @Override
35 public void actionPerformed(ActionEvent e) {
36 Relation relation = rel.get();
37 if (relation == null) return;
38 RelationEditor.getEditor(Main.getLayerManager().getEditLayer(), relation, null).setVisible(true);
39 }
40
41 @Override
42 public void chosenRelationChanged(Relation oldRelation, Relation newRelation) {
43 setEnabled(newRelation != null);
44 }
45}
Note: See TracBrowser for help on using the repository browser.