001package jmri.jmrit.mastbuilder; 002 003import java.awt.event.ActionEvent; 004import javax.swing.AbstractAction; 005import org.slf4j.Logger; 006import org.slf4j.LoggerFactory; 007 008/** 009 * Swing action to create and register a MastBuilder object 010 * 011 * @author Bob Jacobsen Copyright (C) 2003 012 */ 013public class MastBuilderAction extends AbstractAction { 014 015 public MastBuilderAction(String s) { 016 super(s); 017 018 // disable ourself if there is no command Station object available 019 if (jmri.InstanceManager.getNullableDefault(jmri.CommandStation.class) == null) { 020 setEnabled(false); 021 } 022 } 023 024 public MastBuilderAction() { 025 this(Bundle.getMessage("MastBuilderTitle")); 026 } 027 028 @Override 029 public void actionPerformed(ActionEvent e) { 030 // create a MastBuilderPane 031 MastBuilderPane f = new MastBuilderPane(); 032 try { 033 f.initComponents(); 034 } catch (Exception ex) { 035 log.error("Exception: {}", ex.toString()); 036 } 037 f.setVisible(true); 038 } 039 040 private final static Logger log = LoggerFactory.getLogger(MastBuilderAction.class); 041 042}