01: package net.sourceforge.squirrel_sql.client.gui.mainframe;
02:
03: /*
04: * Copyright (C) 2001-2004 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.Rectangle;
22:
23: import net.sourceforge.squirrel_sql.fw.gui.WindowState;
24: import net.sourceforge.squirrel_sql.fw.util.beanwrapper.RectangleWrapper;
25:
26: import net.sourceforge.squirrel_sql.client.gui.WindowManager;
27:
28: /**
29: * This bean describes the state of the main window.
30: *
31: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
32: */
33: public class MainFrameWindowState extends WindowState {
34: // JASON: Messages height should be stored with this.
35: public interface IPropertyNames {
36: String ALIASES_WINDOW_STATE = "aliasesWindowState";
37: String DRIVERS_WINDOW_STATE = "driversWindowState";
38: }
39:
40: private WindowState _driversWindowState = new WindowState();
41: private WindowState _aliasesWindowState = new WindowState();
42:
43: private WindowManager _mgr;
44:
45: public MainFrameWindowState() {
46: super ();
47: _driversWindowState.setBounds(new RectangleWrapper(
48: new Rectangle(5, 5, 250, 250)));
49: _aliasesWindowState.setBounds(new RectangleWrapper(
50: new Rectangle(400, 5, 250, 250)));
51: }
52:
53: public MainFrameWindowState(WindowManager mgr) {
54: super (mgr.getMainFrame());
55: _mgr = mgr;
56: }
57:
58: /**
59: * This bean is about to be written out to XML so load its values from its
60: * window.
61: */
62: public void aboutToBeWritten() {
63: super .aboutToBeWritten();
64: refresh();
65: }
66:
67: public WindowState getAliasesWindowState() {
68: refresh();
69: return _aliasesWindowState;
70: }
71:
72: public WindowState getDriversWindowState() {
73: refresh();
74: return _driversWindowState;
75: }
76:
77: public void setAliasesWindowState(WindowState value) {
78: _aliasesWindowState = value;
79: }
80:
81: public void setDriversWindowState(WindowState value) {
82: _driversWindowState = value;
83: }
84:
85: private void refresh() {
86: if (_aliasesWindowState == null) {
87: _aliasesWindowState = new WindowState();
88: }
89: if (_driversWindowState == null) {
90: _driversWindowState = new WindowState();
91: }
92:
93: if (_mgr != null) {
94: _aliasesWindowState.copyFrom(_mgr.getAliasesWindowState());
95: _driversWindowState.copyFrom(_mgr.getDriversWindowState());
96: }
97: }
98: }
|