001package jmri.jmrit.throttle; 002 003import java.awt.event.ActionEvent; 004import java.io.File; 005import javax.swing.AbstractAction; 006 007import jmri.jmrit.throttle.implementation.ThrottleUICore; 008 009/** 010 * Save throttles to XML 011 * 012 * <hr> 013 * This file is part of JMRI. 014 * <p> 015 * JMRI is free software; you can redistribute it and/or modify it under the 016 * terms of version 2 of the GNU General Public License as published by the Free 017 * Software Foundation. See the "COPYING" file for a copy of this license. 018 * <p> 019 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY 020 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 021 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 022 * 023 * @author Lionel Jeanson Copyright 2009 024 */ 025public class StoreDefaultXmlThrottlesLayoutAction extends AbstractAction { 026 027 /** 028 * Constructor 029 * 030 * @param s Name for the action. 031 */ 032 public StoreDefaultXmlThrottlesLayoutAction(String s) { 033 super(s); 034 // disable this ourselves if there is no throttle Manager 035 if (jmri.InstanceManager.getNullableDefault(jmri.ThrottleManager.class) == null) { 036 setEnabled(false); 037 } 038 } 039 040 /** 041 * The action is performed. Let the user choose the file to save to. Write 042 * XML for each ThrottleFrame. 043 * 044 * @param e The event causing the action. 045 */ 046 @Override 047 public void actionPerformed(ActionEvent e) { 048 StoreXmlThrottlesLayoutAction sxta = new StoreXmlThrottlesLayoutAction(); 049 sxta.saveThrottlesLayout(new File(ThrottleUICore.getDefaultThrottleFilename())); 050 } 051 052}