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 LocationsByCarTypeFrame object.
012 *
013 * @author Daniel Boudreau Copyright (C) 2009
014 */
015public class ModifyLocationsAction extends AbstractAction {
016
017    public ModifyLocationsAction(Location location) {
018        super(Bundle.getMessage("TitleModifyLocation"));
019        _location = location;
020    }
021
022    public ModifyLocationsAction() {
023        super(Bundle.getMessage("TitleModifyLocations"));
024    }
025
026    Location _location;
027    LocationsByCarTypeFrame f;
028
029    @Override
030    public void actionPerformed(ActionEvent e) {
031        // create a frame
032        if (f == null || !f.isVisible()) {
033            f = new LocationsByCarTypeFrame();
034            f.initComponents(_location);
035        }
036        f.setExtendedState(Frame.NORMAL);
037        f.setVisible(true); // this also brings the frame into focus
038    }
039}
040
041