source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/AddSelectedAfterSelection.java @ 14030

Last change on this file since 14030 was 14030, checked in by michael2402, 8 months ago

See #16388: Fix Checkstyle / Test issues.

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