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

Last change on this file since 14030 was 14030, checked in by michael2402, 6 years ago

See #16388: Fix Checkstyle / Test issues.

File size: 2.0 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.tools.ImageProvider;
9
10/**
11 * Selects members in the relation editor which refer to primitives in the current selection of the context layer.
12 * @since 9496
13 */
14public class SelectedMembersForSelectionAction extends AddFromSelectionAction {
15 private static final long serialVersionUID = 1L;
16
17 /**
18 * Constructs a new {@code SelectedMembersForSelectionAction}.
19 * @param editorAccess An interface to access the relation editor contents.
20 */
21 public SelectedMembersForSelectionAction(IRelationEditorActionAccess editorAccess) {
22 super(editorAccess, IRelationEditorUpdateOn.SELECTION_TABLE_CHANGE, IRelationEditorUpdateOn.MEMBER_TABLE_CHANGE);
23 putValue(SHORT_DESCRIPTION, tr("Select relation members which refer to objects in the current selection"));
24 new ImageProvider("dialogs/relation", "selectmembers").getResource().attachImageIcon(this, true);
25 updateEnabledState();
26 }
27
28 @Override
29 protected void updateEnabledState() {
30 boolean enabled = getSelectionTableModel().getRowCount() > 0
31 && !editorAccess.getMemberTableModel().getChildPrimitives(getLayer().data.getSelected()).isEmpty();
32
33 if (enabled) {
34 putValue(SHORT_DESCRIPTION, tr("Select relation members which refer to {0} objects in the current selection",
35 editorAccess.getMemberTableModel().getChildPrimitives(getLayer().data.getSelected()).size()));
36 } else {
37 putValue(SHORT_DESCRIPTION, tr("Select relation members which refer to objects in the current selection"));
38 }
39 setEnabled(enabled);
40 }
41
42 @Override
43 public void actionPerformed(ActionEvent e) {
44 editorAccess.getMemberTableModel().selectMembersReferringTo(getLayer().data.getSelected());
45 }
46}
Note: See TracBrowser for help on using the repository browser.