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

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

See #16388: New mechanism for plugins to register relation editor actions.

File size: 1.7 KB
RevLine 
[9665]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 {
[14027]18 private static final long serialVersionUID = 1L;
[9665]19
20 /**
21 * Constructs a new {@code DuplicateRelationAction}.
22 * @param memberTableModel member table model
23 * @param tagEditorModel tag editor model
24 * @param layer OSM data layer
25 */
[14027]26 public DuplicateRelationAction(IRelationEditorActionAccess editorAccess) {
27 super(editorAccess);
[9665]28 putValue(SHORT_DESCRIPTION, tr("Create a copy of this relation and open it in another editor window"));
29 // FIXME provide an icon
[13130]30 new ImageProvider("duplicate").getResource().attachImageIcon(this, true);
[9665]31 putValue(NAME, tr("Duplicate"));
32 setEnabled(true);
33 }
34
35 @Override
36 public void actionPerformed(ActionEvent e) {
37 Relation copy = new Relation();
[14027]38 getTagModel().applyToPrimitive(copy);
39 editorAccess.getMemberTableModel().applyToRelation(copy);
[9665]40 if (!GraphicsEnvironment.isHeadless()) {
[14027]41 RelationEditor.getEditor(getLayer(), copy, editorAccess.getMemberTableModel().getSelectedMembers()).setVisible(true);
[9665]42 }
43 }
44
45 @Override
46 protected void updateEnabledState() {
47 // Do nothing
48 }
49}
Note: See TracBrowser for help on using the repository browser.