source: osm/applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectMembersAction.java@ 30145

Last change on this file since 30145 was 30145, checked in by donvip, 11 years ago

[josm-plugins] global replacement of Main.map.mapview.getEditLayer() by Main.main.getEditLayer() (avoids NPEs)

File size: 1.0 KB
Line 
1package relcontext.actions;
2
3import static org.openstreetmap.josm.tools.I18n.tr;
4import java.awt.event.ActionEvent;
5import javax.swing.AbstractAction;
6import org.openstreetmap.josm.Main;
7import org.openstreetmap.josm.data.osm.Relation;
8import org.openstreetmap.josm.tools.ImageProvider;
9import relcontext.ChosenRelation;
10import relcontext.ChosenRelationListener;
11
12public class SelectMembersAction extends AbstractAction implements ChosenRelationListener {
13 private ChosenRelation rel;
14
15 public SelectMembersAction( ChosenRelation rel ) {
16 super(tr("Select members"));
17 putValue(SMALL_ICON, ImageProvider.get("selectall"));
18 this.rel = rel;
19 rel.addChosenRelationListener(this);
20 setEnabled(rel.get() != null);
21 }
22
23 public void actionPerformed( ActionEvent e ) {
24 Main.main.getEditLayer().data.setSelected(rel.get() == null ? null : rel.get().getMemberPrimitives());
25 }
26
27 public void chosenRelationChanged( Relation oldRelation, Relation newRelation ) {
28 setEnabled(newRelation != null);
29 }
30}
Note: See TracBrowser for help on using the repository browser.