1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.dialogs.relation.actions;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.event.ActionEvent;
|
---|
7 |
|
---|
8 | import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor.AddAbortException;
|
---|
9 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
10 | import org.openstreetmap.josm.tools.Logging;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Add all objects selected in the current dataset before the first member.
|
---|
14 | * @since 9496
|
---|
15 | */
|
---|
16 | public class AddSelectedAtStartAction extends AddFromSelectionAction {
|
---|
17 | private static final long serialVersionUID = 1L;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Constructs a new {@code AddSelectedAtStartAction}.
|
---|
21 | * @param editorAccess An interface to access the relation editor contents.
|
---|
22 | */
|
---|
23 | public AddSelectedAtStartAction(IRelationEditorActionAccess editorAccess) {
|
---|
24 | super(editorAccess, IRelationEditorUpdateOn.SELECTION_TABLE_CHANGE);
|
---|
25 | putValue(SHORT_DESCRIPTION, tr("Add all objects selected in the current dataset before the first member"));
|
---|
26 | new ImageProvider("dialogs/conflict", "copystartright").getResource().attachImageIcon(this, true);
|
---|
27 | updateEnabledState();
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | protected void updateEnabledState() {
|
---|
32 | setEnabled(getSelectionTableModel().getRowCount() > 0);
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | public void actionPerformed(ActionEvent e) {
|
---|
37 | try {
|
---|
38 | getMemberTableModel().addMembersAtBeginning(filterConfirmedPrimitives(getSelectionTableModel().getSelection()));
|
---|
39 | } catch (AddAbortException ex) {
|
---|
40 | Logging.trace(ex);
|
---|
41 | }
|
---|
42 | }
|
---|
43 | }
|
---|