001package jmri.jmrit; 002 003import java.awt.event.ActionEvent; 004 005import javax.swing.AbstractAction; 006import javax.swing.JPanel; 007 008import jmri.InstanceManager; 009import jmri.util.swing.JmriJOptionPane; 010 011/** 012 * Provide an action to allow Logixs to be loaded disabled when panel file is 013 * loaded 014 * 015 * @author Dave Duchamp Copyright (C) 2007 016 */ 017public class LogixLoadAction extends AbstractAction { 018 019 public LogixLoadAction(String s, JPanel who) { 020 super(s); 021 _who = who; 022 } 023 024 JPanel _who; 025 026 @Override 027 public void actionPerformed(ActionEvent e) { 028 // Set option to force Logixs to be loaded disabled 029 030 Object[] options = {"Disable", 031 "Enable"}; // TODO I18N 032 033 int retval = JmriJOptionPane.showOptionDialog(_who, Bundle.getMessage("LogixDisabledMessage"), Bundle.getMessage("DebugOption"), 034 JmriJOptionPane.DEFAULT_OPTION, 035 JmriJOptionPane.QUESTION_MESSAGE, null, options, options[0]); 036 if (retval != 0) { // not array position 0 for Disable or Dialog closed 037 InstanceManager.getDefault(jmri.LogixManager.class).setLoadDisabled(false); 038 log.info("Requested load Logixs enabled via Debug menu."); 039 } else { 040 InstanceManager.getDefault(jmri.LogixManager.class).setLoadDisabled(true); 041 log.info("Requested load Logixs diabled via Debug menu."); 042 } 043 044 } 045 046 private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogixLoadAction.class); 047 048}