| [32395] | 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| [25670] | 2 | package relcontext.actions;
|
|---|
| 3 |
|
|---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| [32395] | 5 |
|
|---|
| [25670] | 6 | import java.awt.event.ActionEvent;
|
|---|
| [36102] | 7 | import java.util.Collections;
|
|---|
| [32395] | 8 |
|
|---|
| [25670] | 9 | import javax.swing.AbstractAction;
|
|---|
| [32395] | 10 |
|
|---|
| [25670] | 11 | import org.openstreetmap.josm.data.osm.Relation;
|
|---|
| [33530] | 12 | import org.openstreetmap.josm.gui.MainApplication;
|
|---|
| [25670] | 13 | import org.openstreetmap.josm.tools.ImageProvider;
|
|---|
| [32395] | 14 |
|
|---|
| [25670] | 15 | import relcontext.ChosenRelation;
|
|---|
| 16 | import relcontext.ChosenRelationListener;
|
|---|
| 17 |
|
|---|
| 18 | public class SelectMembersAction extends AbstractAction implements ChosenRelationListener {
|
|---|
| [36102] | 19 | private final ChosenRelation rel;
|
|---|
| [25670] | 20 |
|
|---|
| [32395] | 21 | public SelectMembersAction(ChosenRelation rel) {
|
|---|
| [25670] | 22 | super(tr("Select members"));
|
|---|
| 23 | putValue(SMALL_ICON, ImageProvider.get("selectall"));
|
|---|
| 24 | this.rel = rel;
|
|---|
| 25 | rel.addChosenRelationListener(this);
|
|---|
| [25711] | 26 | setEnabled(rel.get() != null);
|
|---|
| [25670] | 27 | }
|
|---|
| 28 |
|
|---|
| [32395] | 29 | @Override
|
|---|
| 30 | public void actionPerformed(ActionEvent e) {
|
|---|
| [36102] | 31 | MainApplication.getLayerManager().getEditLayer().data.setSelected(
|
|---|
| 32 | rel.get() == null ? Collections.emptyList() : rel.get().getMemberPrimitives());
|
|---|
| [25670] | 33 | }
|
|---|
| 34 |
|
|---|
| [32395] | 35 | @Override
|
|---|
| 36 | public void chosenRelationChanged(Relation oldRelation, Relation newRelation) {
|
|---|
| [25670] | 37 | setEnabled(newRelation != null);
|
|---|
| 38 | }
|
|---|
| 39 | }
|
|---|