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.cars.CarsTableFrame;
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) 2009
016 */
017public class ShowCarsByLocationAction extends AbstractAction {
018
019    public ShowCarsByLocationAction(boolean showAllCars, Location location, Track track) {
020        super(Bundle.getMessage("MenuItemShowCars"));
021        this.showAllCars = showAllCars;
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 showAllCars = 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 CarsTableFrame(showAllCars, locationName, trackName);
039    }
040}