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.setup.Setup; 009import jmri.jmrit.operations.trains.TrainSwitchLists; 010 011/** 012 * Swing action to preview or print a switch list for a location. 013 * 014 * @author Daniel Boudreau Copyright (C) 2013 015 * 016 */ 017public class PrintSwitchListAction extends AbstractAction { 018 019 public PrintSwitchListAction(Location location, boolean isPreview) { 020 super(isPreview? Bundle.getMessage("MenuItemPreview") : Bundle.getMessage("MenuItemPrint")); 021 this.location = location; 022 this.isPreview = isPreview; 023 // The switch list must be accessed from the Trains window if running in consolidated mode 024 setEnabled(Setup.isSwitchListRealTime()); 025 } 026 027 Location location; 028 boolean isPreview; 029 030 @Override 031 public void actionPerformed(ActionEvent e) { 032 TrainSwitchLists ts = new TrainSwitchLists(); 033 ts.buildSwitchList(location); 034 ts.printSwitchList(location, isPreview); 035 } 036} 037 038