source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/DuplicateRelationAction.java

Last change on this file was 17153, checked in by Klumbumbus, 4 years ago

see #17809 - Don't promote spelling FIXME, deprecate Fixme in favor of fixme

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 new ImageProvider("duplicate").getResource().attachImageIcon(this, true);
28 putValue(NAME, tr("Duplicate"));
29 setEnabled(true);
30 }
31
32 @Override
33 public void actionPerformed(ActionEvent e) {
34 Relation copy = new Relation();
35 getTagModel().applyToPrimitive(copy);
36 editorAccess.getMemberTableModel().applyToRelation(copy);
37 if (!GraphicsEnvironment.isHeadless()) {
38 RelationEditor.getEditor(getLayer(), copy, editorAccess.getMemberTableModel().getSelectedMembers()).setVisible(true);
39 }
40 }
41
42 @Override
43 protected void updateEnabledState() {
44 // Do nothing
45 }
46}
Note: See TracBrowser for help on using the repository browser.