001: package net.sourceforge.squirrel_sql.plugins.laf;
002:
003: /*
004: * Copyright (C) 2001-2006 Colin Bell
005: * colbell@users.sourceforge.net
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: */
021: import java.io.Serializable;
022: import javax.swing.UIManager;
023: import net.sourceforge.squirrel_sql.fw.gui.FontInfo;
024: import net.sourceforge.squirrel_sql.fw.id.IHasIdentifier;
025: import net.sourceforge.squirrel_sql.fw.id.IIdentifier;
026:
027: /**
028: * This JavaBean class represents the user specific
029: * preferences for this plugin.
030: *
031: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
032: */
033: public class LAFPreferences implements Cloneable, Serializable,
034: IHasIdentifier {
035: static final long serialVersionUID = 5458252097202539743L;
036:
037: /** The <CODE>IIdentifier</CODE> that uniquely identifies this object. */
038: private IIdentifier _id;
039: private String _lafClassName;
040: private FontInfo _fiMenu;
041: private FontInfo _fiStatic;
042: private FontInfo _fiStatusBar;
043: private FontInfo _fiOther;
044: private boolean _fiMenuEnabled;
045: private boolean _fiStaticEnabled;
046: private boolean _fiStatusBarEnabled;
047: private boolean _fiOtherEnabled;
048:
049: /**
050: * If<tt>true</tt> allow LAF to set frame and dialog title bars and
051: * borders.
052: * */
053: private boolean _canLAFSetBorders = false;
054:
055: public LAFPreferences() {
056: super ();
057: _lafClassName = UIManager
058: .getCrossPlatformLookAndFeelClassName();
059: }
060:
061: public LAFPreferences(IIdentifier id) {
062: this ();
063: _id = id;
064: }
065:
066: /**
067: * Return a copy of this object.
068: */
069: public Object clone() {
070: try {
071: return super .clone();
072: } catch (CloneNotSupportedException ex) {
073: throw new InternalError(ex.getMessage()); // Impossible.
074: }
075: }
076:
077: public String getLookAndFeelClassName() {
078: return _lafClassName;
079: }
080:
081: public void setLookAndFeelClassName(String data) {
082: _lafClassName = data;
083: }
084:
085: public FontInfo getMenuFontInfo() {
086: return _fiMenu;
087: }
088:
089: public void setMenuFontInfo(FontInfo data) {
090: _fiMenu = data;
091: }
092:
093: public FontInfo getStaticFontInfo() {
094: return _fiStatic;
095: }
096:
097: public void setStaticFontInfo(FontInfo data) {
098: _fiStatic = data;
099: }
100:
101: public FontInfo getStatusBarFontInfo() {
102: return _fiStatusBar;
103: }
104:
105: public void setStatusBarFontInfo(FontInfo data) {
106: _fiStatusBar = data;
107: }
108:
109: public FontInfo getOtherFontInfo() {
110: return _fiOther;
111: }
112:
113: public void setOtherFontInfo(FontInfo data) {
114: _fiOther = data;
115: }
116:
117: public boolean isMenuFontEnabled() {
118: return _fiMenuEnabled;
119: }
120:
121: public void setMenuFontEnabled(boolean data) {
122: _fiMenuEnabled = data;
123: }
124:
125: public boolean isStaticFontEnabled() {
126: return _fiStaticEnabled;
127: }
128:
129: public void setStaticFontEnabled(boolean data) {
130: _fiStaticEnabled = data;
131: }
132:
133: public boolean isStatusBarFontEnabled() {
134: return _fiStatusBarEnabled;
135: }
136:
137: public void setStatusBarFontEnabled(boolean data) {
138: _fiStatusBarEnabled = data;
139: }
140:
141: public boolean isOtherFontEnabled() {
142: return _fiOtherEnabled;
143: }
144:
145: public void setOtherFontEnabled(boolean data) {
146: _fiOtherEnabled = data;
147: }
148:
149: /**
150: * @see IHasIdentifier#getIdentifier()
151: */
152: public IIdentifier getIdentifier() {
153: return null;
154: }
155:
156: /**
157: * Gets the _id.
158: * @return Returns a IIdentifier
159: */
160: public IIdentifier getId() {
161: return _id;
162: }
163:
164: /**
165: * Sets the _id.
166: * @param _id The _id to set
167: */
168: public void setId(IIdentifier _id) {
169: this ._id = _id;
170: }
171:
172: /**
173: * Specifies whether LAF allowed to set frame and dialog title bars and
174: * borders.
175: */
176: public boolean getCanLAFSetBorder() {
177: return _canLAFSetBorders;
178: }
179:
180: /**
181: * Set whether LAF allowed to set frame and dialog title bars and
182: * borders.
183: */
184: public void setCanLAFSetBorder(boolean value) {
185: _canLAFSetBorders = value;
186: }
187:
188: /**
189: * @see java.lang.Object#hashCode()
190: */
191: @Override
192: public int hashCode() {
193: final int PRIME = 31;
194: int result = 1;
195: result = PRIME * result + (_canLAFSetBorders ? 1231 : 1237);
196: result = PRIME * result
197: + ((_fiMenu == null) ? 0 : _fiMenu.hashCode());
198: result = PRIME * result + (_fiMenuEnabled ? 1231 : 1237);
199: result = PRIME * result
200: + ((_fiOther == null) ? 0 : _fiOther.hashCode());
201: result = PRIME * result + (_fiOtherEnabled ? 1231 : 1237);
202: result = PRIME * result
203: + ((_fiStatic == null) ? 0 : _fiStatic.hashCode());
204: result = PRIME * result + (_fiStaticEnabled ? 1231 : 1237);
205: result = PRIME
206: * result
207: + ((_fiStatusBar == null) ? 0 : _fiStatusBar.hashCode());
208: result = PRIME * result + (_fiStatusBarEnabled ? 1231 : 1237);
209: result = PRIME * result + ((_id == null) ? 0 : _id.hashCode());
210: result = PRIME
211: * result
212: + ((_lafClassName == null) ? 0 : _lafClassName
213: .hashCode());
214: return result;
215: }
216:
217: /**
218: * @see java.lang.Object#equals(java.lang.Object)
219: */
220: @Override
221: public boolean equals(Object obj) {
222: if (this == obj)
223: return true;
224: if (obj == null)
225: return false;
226: if (getClass() != obj.getClass())
227: return false;
228: final LAFPreferences other = (LAFPreferences) obj;
229: if (_canLAFSetBorders != other._canLAFSetBorders)
230: return false;
231: if (_fiMenu == null) {
232: if (other._fiMenu != null)
233: return false;
234: } else if (!_fiMenu.equals(other._fiMenu))
235: return false;
236: if (_fiMenuEnabled != other._fiMenuEnabled)
237: return false;
238: if (_fiOther == null) {
239: if (other._fiOther != null)
240: return false;
241: } else if (!_fiOther.equals(other._fiOther))
242: return false;
243: if (_fiOtherEnabled != other._fiOtherEnabled)
244: return false;
245: if (_fiStatic == null) {
246: if (other._fiStatic != null)
247: return false;
248: } else if (!_fiStatic.equals(other._fiStatic))
249: return false;
250: if (_fiStaticEnabled != other._fiStaticEnabled)
251: return false;
252: if (_fiStatusBar == null) {
253: if (other._fiStatusBar != null)
254: return false;
255: } else if (!_fiStatusBar.equals(other._fiStatusBar))
256: return false;
257: if (_fiStatusBarEnabled != other._fiStatusBarEnabled)
258: return false;
259: if (_id == null) {
260: if (other._id != null)
261: return false;
262: } else if (!_id.equals(other._id))
263: return false;
264: if (_lafClassName == null) {
265: if (other._lafClassName != null)
266: return false;
267: } else if (!_lafClassName.equals(other._lafClassName))
268: return false;
269: return true;
270: }
271: }
|