source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/DuplicateRelationAction.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: 1.6 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.GraphicsEnvironment;
7import java.awt.event.ActionEvent;
8
9import org.openstreetmap.josm.data.osm.Relation;
10import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
11import org.openstreetmap.josm.tools.ImageProvider;
12
13/**
14 * Creates a new relation with a copy of the current editor state.
15 * @since 9496
16 */
17public class DuplicateRelationAction extends AbstractRelationEditorAction {
18 private static final long serialVersionUID = 1L;
19
20 /**
21 * Constructs a new {@code DuplicateRelationAction}.
22 * @param editorAccess An interface to access the relation editor contents.
23 */
24 public DuplicateRelationAction(IRelationEditorActionAccess editorAccess) {
25 super(editorAccess);
26 putValue(SHORT_DESCRIPTION, tr("Create a copy of this relation and open it in another editor window"));
27 // FIXME provide an icon
28 new ImageProvider("duplicate").getResource().attachImageIcon(this, true);
29 putValue(NAME, tr("Duplicate"));
30 setEnabled(true);
31 }
32
33 @Override
34 public void actionPerformed(ActionEvent e) {
35 Relation copy = new Relation();
36 getTagModel().applyToPrimitive(copy);
37 editorAccess.getMemberTableModel().applyToRelation(copy);
38 if (!GraphicsEnvironment.isHeadless()) {
39 RelationEditor.getEditor(getLayer(), copy, editorAccess.getMemberTableModel().getSelectedMembers()).setVisible(true);
40 }
41 }
42
43 @Override
44 protected void updateEnabledState() {
45 // Do nothing
46 }
47}
Note: See TracBrowser for help on using the repository browser.