source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorAction.java @ 12933

Last change on this file since 12933 was 12933, checked in by Don-vip, 2 months ago

fix #15368 - Button that selects the relation from relation editor

File size: 1.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.relation.actions;
3
4import javax.swing.AbstractAction;
5import javax.swing.event.ListSelectionEvent;
6import javax.swing.event.ListSelectionListener;
7import javax.swing.event.TableModelEvent;
8import javax.swing.event.TableModelListener;
9
10import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor;
11import org.openstreetmap.josm.gui.dialogs.relation.MemberTable;
12import org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel;
13import org.openstreetmap.josm.gui.layer.OsmDataLayer;
14
15/**
16 * Abstract superclass of relation editor actions.
17 * @since 9496
18 */
19public abstract class AbstractRelationEditorAction extends AbstractAction implements TableModelListener, ListSelectionListener {
20    protected final MemberTable memberTable;
21    protected final MemberTableModel memberTableModel;
22    protected final transient OsmDataLayer layer;
23    protected final transient IRelationEditor editor;
24
25    protected AbstractRelationEditorAction(MemberTable memberTable, MemberTableModel memberTableModel, String actionMapKey) {
26        this(memberTable, memberTableModel, actionMapKey, null, null);
27    }
28
29    protected AbstractRelationEditorAction(MemberTable memberTable, MemberTableModel memberTableModel, String actionMapKey,
30            OsmDataLayer layer, IRelationEditor editor) {
31        this.memberTable = memberTable;
32        this.memberTableModel = memberTableModel;
33        this.layer = layer;
34        this.editor = editor;
35        if (actionMapKey != null) {
36            this.memberTable.getActionMap().put(actionMapKey, this);
37        }
38    }
39
40    @Override
41    public void tableChanged(TableModelEvent e) {
42        updateEnabledState();
43    }
44
45    @Override
46    public void valueChanged(ListSelectionEvent e) {
47        updateEnabledState();
48    }
49
50    protected abstract void updateEnabledState();
51}
Note: See TracBrowser for help on using the repository browser.