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