001package apps.gui3.dp3; 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.jmrit.roster.rostergroup.RosterGroupSelector; 010import jmri.util.swing.JmriAbstractAction; 011import jmri.util.swing.JmriPanel; 012import jmri.util.swing.WindowInterface; 013 014/** 015 * AbstractAction for the DP3 window so that further windows can be opened 016 * 017 * @author Kevin Dickerson Copyright (C) 2011 018 */ 019public class DecoderPro3Action extends JmriAbstractAction { 020 021 DecoderPro3Window mainFrame; 022 boolean allowQuit = true; 023 024 public DecoderPro3Action(String s, WindowInterface wi) { 025 super(s, wi); 026 } 027 028 public DecoderPro3Action(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 DecoderPro3Window} should 037 * quit the application; false otherwise 038 */ 039 public DecoderPro3Action(String pName, boolean allowQuit) { 040 super(pName); 041 this.allowQuit = allowQuit; 042 } 043 044 @Override 045 public void actionPerformed(ActionEvent event) { 046 mainFrame = new DecoderPro3Window(DecoderPro3.getMenuFile(), DecoderPro3.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 if (wi instanceof RosterGroupSelector) { 053 mainFrame.setSelectedRosterGroup(((RosterGroupSelector) wi).getSelectedRosterGroup()); 054 } 055 mainFrame.setVisible(true); 056 mainFrame.setAllowQuit(allowQuit); 057 mainFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 058 } 059 060 // never invoked, because we overrode actionPerformed above 061 @Override 062 public JmriPanel makePanel() { 063 throw new IllegalArgumentException("Should not be invoked"); 064 } 065}