001package jmri.jmrit.simpleprog; 002 003import java.awt.event.ActionEvent; 004import javax.swing.Icon; 005import jmri.AddressedProgrammerManager; 006import jmri.GlobalProgrammerManager; 007import jmri.InstanceManager; 008import jmri.util.swing.JmriAbstractAction; 009import jmri.util.swing.WindowInterface; 010 011/** 012 * Swing action to create and register a SimpleProgAction object 013 * 014 * @author Bob Jacobsen Copyright (C) 2001, 2008 015 */ 016public class SimpleProgAction extends JmriAbstractAction { 017 018 public SimpleProgAction(String s, WindowInterface wi) { 019 super(s, wi); 020 } 021 022 public SimpleProgAction(String s, Icon i, WindowInterface wi) { 023 super(s, i, wi); 024 } 025 026 public SimpleProgAction(String s) { 027 super(s); 028 029 // disable ourself if programming is not possible 030 boolean enabled = false; 031 if (InstanceManager.getList(GlobalProgrammerManager.class).size() > 0) { 032 enabled = true; 033 } 034 if (InstanceManager.getList(AddressedProgrammerManager.class).size() > 0) { 035 enabled = true; 036 } 037 038 setEnabled(enabled); 039 } 040 041 public SimpleProgAction() { 042 this(Bundle.getMessage("MenuItemSingleCVProgrammer")); 043 } 044 045 @Override 046 public void actionPerformed(ActionEvent e) { 047 048 // create a SimpleProgFrame 049 SimpleProgFrame f = new SimpleProgFrame(); 050 f.setVisible(true); 051 052 } 053 054 // never invoked, because we overrode actionPerformed above 055 @Override 056 public jmri.util.swing.JmriPanel makePanel() { 057 throw new IllegalArgumentException("Should not be invoked"); 058 } 059}