001package jmri.jmrit.throttle; 002 003import java.awt.event.ActionEvent; 004import java.io.File; 005import javax.swing.AbstractAction; 006 007/** 008 * Save throttles to XML 009 * 010 * @author Lionel Jeanson Copyright 2009 011 */ 012public class StoreDefaultXmlThrottlesLayoutAction extends AbstractAction { 013 014 /** 015 * Constructor 016 * 017 * @param s Name for the action. 018 */ 019 public StoreDefaultXmlThrottlesLayoutAction(String s) { 020 super(s); 021 // disable this ourselves if there is no throttle Manager 022 if (jmri.InstanceManager.getNullableDefault(jmri.ThrottleManager.class) == null) { 023 setEnabled(false); 024 } 025 } 026 027 /** 028 * The action is performed. Let the user choose the file to save to. Write 029 * XML for each ThrottleFrame. 030 * 031 * @param e The event causing the action. 032 */ 033 @Override 034 public void actionPerformed(ActionEvent e) { 035 StoreXmlThrottlesLayoutAction sxta = new StoreXmlThrottlesLayoutAction(); 036 sxta.saveThrottlesLayout(new File(ThrottleFrame.getDefaultThrottleFilename())); 037 } 038 039}