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