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.LocationEditFrame;
009
010/**
011 * Swing action to create and register a TrackCopyFrame object.
012 *
013 * @author Bob Jacobsen Copyright (C) 2001
014 * @author Daniel Boudreau Copyright (C) 2011
015 */
016public class TrackCopyAction extends AbstractAction {
017
018    public TrackCopyAction() {
019        super(Bundle.getMessage("MenuItemCopyTrack"));
020    }
021    
022    public TrackCopyAction(LocationEditFrame lef) {
023        this();
024        _lef = lef;
025    }
026
027    private LocationEditFrame _lef = null;
028    TrackCopyFrame f = null;
029
030    @Override
031    public void actionPerformed(ActionEvent e) {
032        // create a copy track frame
033        if (f == null || !f.isVisible()) {
034            f = new TrackCopyFrame(_lef);
035        }
036        f.setExtendedState(Frame.NORMAL);
037        f.setVisible(true); // this also brings the frame into focus
038    }
039}
040
041