01: package net.sourceforge.squirrel_sql.fw.gui.action;
02:
03: /*
04: * Copyright (C) 2001-2003 Colin Bell
05: * colbell@users.sourceforge.net
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: */
21: import java.awt.event.ActionEvent;
22:
23: import javax.swing.JDesktopPane;
24: import javax.swing.JInternalFrame;
25:
26: import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
27: import net.sourceforge.squirrel_sql.fw.gui.MaximizeInternalFramePositioner;
28: import net.sourceforge.squirrel_sql.fw.util.StringManager;
29: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
30:
31: /**
32: * This class will cascade all internal frames owned by a
33: * <CODE>JDesktopPane</CODE>.
34: *
35: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
36: */
37: public class MaximizeInternalFramesAction extends BaseAction implements
38: IHasJDesktopPane {
39: /** Internationalized strings for this class. */
40: private static final StringManager s_stringMgr = StringManagerFactory
41: .getStringManager(CascadeInternalFramesAction.class);
42:
43: /**
44: * The <CODE>JDesktopPane</CODE> that owns the internal frames to be
45: * cascaded.
46: */
47: private JDesktopPane _desktop;
48:
49: /**
50: * Default constructor.
51: */
52: public MaximizeInternalFramesAction() {
53: this (null);
54: }
55:
56: /**
57: * Constructor specifying the <CODE>JDesktopPane</CODE> that owns the
58: * internal frames to be maximized.
59: *
60: * @param desktop the <CODE>JDesktopPane</CODE> that owns the
61: * internal frames to be maximized.
62: */
63: public MaximizeInternalFramesAction(JDesktopPane desktop) {
64: super (s_stringMgr
65: .getString("MaximizeInternalFramesAction.title"));
66: setJDesktopPane(desktop);
67: }
68:
69: /**
70: * Set the <CODE>JDesktopPane</CODE> that owns the internal frames to be
71: * maximized.
72: *
73: * @param desktop the <CODE>JDesktopPane</CODE> that owns the
74: * internal frames to be maximized.
75: */
76: public void setJDesktopPane(JDesktopPane value) {
77: _desktop = value;
78: }
79:
80: /**
81: * Maximize the internal frames.
82: *
83: * @param evt Specifies the event being proceessed.
84: */
85: public void actionPerformed(ActionEvent evt) {
86: if (_desktop != null) {
87: MaximizeInternalFramePositioner pos = new MaximizeInternalFramePositioner();
88: JInternalFrame[] children = GUIUtils
89: .getOpenNonToolWindows(_desktop.getAllFrames());
90: for (int i = children.length - 1; i >= 0; --i) {
91: pos.positionInternalFrame(children[i]);
92: }
93: }
94: }
95: }
|