1 | package relcontext.actions;
|
---|
2 |
|
---|
3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
4 | import java.awt.event.ActionEvent;
|
---|
5 | import javax.swing.AbstractAction;
|
---|
6 | import org.openstreetmap.josm.Main;
|
---|
7 | import org.openstreetmap.josm.data.osm.Relation;
|
---|
8 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
9 | import relcontext.ChosenRelation;
|
---|
10 | import relcontext.ChosenRelationListener;
|
---|
11 |
|
---|
12 | public class SelectInRelationPanelAction extends AbstractAction implements ChosenRelationListener {
|
---|
13 | private ChosenRelation rel;
|
---|
14 |
|
---|
15 | public SelectInRelationPanelAction( ChosenRelation rel ) {
|
---|
16 | super();
|
---|
17 | putValue(NAME, tr("Select in relation list"));
|
---|
18 | putValue(SHORT_DESCRIPTION, tr("Select relation in relation list."));
|
---|
19 | putValue(SMALL_ICON, ImageProvider.get("dialogs", "relationlist"));
|
---|
20 | this.rel = rel;
|
---|
21 | rel.addChosenRelationListener(this);
|
---|
22 | setEnabled(rel.get() != null);
|
---|
23 | }
|
---|
24 |
|
---|
25 | public void actionPerformed( ActionEvent e ) {
|
---|
26 | if( rel.get() != null ) {
|
---|
27 | Main.map.relationListDialog.selectRelation(rel.get());
|
---|
28 | Main.map.relationListDialog.unfurlDialog();
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | public void chosenRelationChanged( Relation oldRelation, Relation newRelation ) {
|
---|
33 | setEnabled(newRelation != null);
|
---|
34 | }
|
---|
35 | }
|
---|