001package apps.gui3.lccpro; 002 003import java.awt.Dimension; 004import java.awt.event.ActionEvent; 005import javax.swing.Icon; 006import javax.swing.WindowConstants; 007import jmri.InstanceManager; 008import jmri.UserPreferencesManager; 009import jmri.util.swing.JmriAbstractAction; 010import jmri.util.swing.JmriPanel; 011import jmri.util.swing.WindowInterface; 012 013/** 014 * AbstractAction for the LccPro window so that further windows can be opened 015 * 016 * @author Kevin Dickerson Copyright (C) 2011 017 * @author Bob Jacobsen Copyright (C) 2024 018 */ 019public class LccProAction extends JmriAbstractAction { 020 021 LccProWindow mainFrame; 022 boolean allowQuit = true; 023 024 public LccProAction(String s, WindowInterface wi) { 025 super(s, wi); 026 } 027 028 public LccProAction(String s, Icon i, WindowInterface wi) { 029 super(s, i, wi); 030 } 031 032 /** 033 * Method for opening a new window via the classic JMRI interface 034 * 035 * @param pName the action name 036 * @param allowQuit true if closing the {@link LccProWindow} should 037 * quit the application; false otherwise 038 */ 039 public LccProAction(String pName, boolean allowQuit) { 040 super(pName); 041 this.allowQuit = allowQuit; 042 } 043 044 @Override 045 public void actionPerformed(ActionEvent event) { 046 mainFrame = new LccProWindow(LccPro.getMenuFile(), LccPro.getToolbarFile()); 047 UserPreferencesManager p = InstanceManager.getDefault(jmri.UserPreferencesManager.class); 048 if (!p.hasProperties(mainFrame.getWindowFrameRef())) { 049 mainFrame.setSize(new Dimension(1024, 600)); 050 mainFrame.setPreferredSize(new Dimension(1024, 600)); 051 } 052 053 mainFrame.setVisible(true); 054 mainFrame.setAllowQuit(allowQuit); 055 mainFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 056 } 057 058 // never invoked, because we overrode actionPerformed above 059 @Override 060 public JmriPanel makePanel() { 061 throw new IllegalArgumentException("Should not be invoked"); 062 } 063}