001package jmri.jmrit.operations.locations.tools;
002
003import java.awt.Frame;
004import java.awt.event.ActionEvent;
005
006import javax.swing.AbstractAction;
007
008import jmri.jmrit.operations.locations.Location;
009
010/**
011 * Swing action to create and register a LocationCopyFrame object.
012 *
013 * @author Bob Jacobsen Copyright (C) 2001
014 * @author Daniel Boudreau Copyright (C) 2014
015 */
016public class LocationCopyAction extends AbstractAction {
017
018    public LocationCopyAction(Location location) {
019        super(Bundle.getMessage("MenuItemCopyLocation"));
020        _location = location;
021    }
022
023    LocationCopyFrame f = null;
024    Location _location;
025
026    @Override
027    public void actionPerformed(ActionEvent e) {
028        // create a copy track frame
029        if (f == null || !f.isVisible()) {
030            f = new LocationCopyFrame(_location);
031        }
032        f.setExtendedState(Frame.NORMAL);
033        f.setVisible(true); // this also brings the frame into focus
034    }
035}
036
037