[9665] | 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;
|
---|
[12620] | 10 | import org.openstreetmap.josm.tools.Logging;
|
---|
[9665] | 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 {
|
---|
[14027] | 17 | private static final long serialVersionUID = 1L;
|
---|
[9665] | 18 |
|
---|
| 19 | /**
|
---|
| 20 | * Constructs a new {@code AddSelectedAtStartAction}.
|
---|
| 21 | * @param memberTableModel member table model
|
---|
| 22 | * @param selectionTableModel selection table model
|
---|
| 23 | * @param editor relation editor
|
---|
| 24 | */
|
---|
[14027] | 25 | public AddSelectedAtStartAction(IRelationEditorActionAccess editorAccess) {
|
---|
| 26 | super(editorAccess, IRelationEditorUpdateOn.SELECTION_TABLE_CHANGE);
|
---|
[9665] | 27 | putValue(SHORT_DESCRIPTION, tr("Add all objects selected in the current dataset before the first member"));
|
---|
[13130] | 28 | new ImageProvider("dialogs/conflict", "copystartright").getResource().attachImageIcon(this, true);
|
---|
[9665] | 29 | updateEnabledState();
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | @Override
|
---|
| 33 | protected void updateEnabledState() {
|
---|
[14027] | 34 | setEnabled(getSelectionTableModel().getRowCount() > 0);
|
---|
[9665] | 35 | }
|
---|
| 36 |
|
---|
| 37 | @Override
|
---|
| 38 | public void actionPerformed(ActionEvent e) {
|
---|
| 39 | try {
|
---|
[14027] | 40 | getMemberTableModel().addMembersAtBeginning(filterConfirmedPrimitives(getSelectionTableModel().getSelection()));
|
---|
[9665] | 41 | } catch (AddAbortException ex) {
|
---|
[12620] | 42 | Logging.trace(ex);
|
---|
[9665] | 43 | }
|
---|
| 44 | }
|
---|
| 45 | }
|
---|