001package jmri.jmrit.operations.automation;
002
003import java.awt.Frame;
004import java.awt.event.ActionEvent;
005
006import javax.swing.AbstractAction;
007
008/**
009 * Action to reset an automation
010 *
011 * @author Daniel Boudreau Copyright (C) 2016
012 */
013public class AutomationCopyAction extends AbstractAction {
014
015    private Automation _automation;
016    
017    public AutomationCopyAction() {
018        super(Bundle.getMessage("MenuCopyAutomation"));
019    }
020
021    public AutomationCopyAction(Automation automation) {
022        super(Bundle.getMessage("MenuCopyAutomation"));
023        _automation = automation;
024    }
025
026    AutomationCopyFrame f = null;
027
028    @Override
029    public void actionPerformed(ActionEvent e) {
030        // create a copy train frame
031        if (f == null || !f.isVisible()) {
032            f = new AutomationCopyFrame(_automation);
033        }
034        f.setExtendedState(Frame.NORMAL);
035        f.setVisible(true); // this also brings the frame into focus
036    }
037}