001package jmri.jmrit.operations.locations.tools;
002
003import java.awt.event.ActionEvent;
004
005import javax.swing.AbstractAction;
006
007import jmri.jmrit.operations.locations.Location;
008import jmri.jmrit.operations.locations.Track;
009import jmri.jmrit.operations.rollingstock.engines.gui.EnginesTableFrame;
010
011/**
012 * Swing action to create and register a CarsTableFrame object.
013 *
014 * @author Bob Jacobsen Copyright (C) 2001
015 * @author Daniel Boudreau Copyright (C) 2025
016 */
017public class ShowLocosByLocationAction extends AbstractAction {
018
019    public ShowLocosByLocationAction(boolean showAllLocos, Location location, Track track) {
020        super(Bundle.getMessage("MenuItemShowLocos"));
021        this.showAllLocos = showAllLocos;
022        if (location != null) {
023            this.locationName = location.getName();
024        }
025        if (track != null) {
026            this.trackName = track.getName();
027        }
028
029    }
030
031    boolean showAllLocos = true;
032    String locationName = null;
033    String trackName = null;
034
035    @Override
036    public void actionPerformed(ActionEvent e) {
037        // create a car table frame
038        new EnginesTableFrame(showAllLocos, locationName, trackName);
039    }
040}