001: /*
002: * SwingML Copyright (C) 2002 SwingML Team
003: *
004: * This library is free software; you can redistribute it and/or modify it under
005: * the terms of the GNU Lesser General Public License as published by the Free
006: * Software Foundation; either version 2 of the License, or (at your option) any
007: * later version.
008: *
009: * This library is distributed in the hope that it will be useful, but WITHOUT
010: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012: * details.
013: *
014: * You should have received a copy of the GNU Lesser General Public License
015: * along with this library; if not, write to the Free Software Foundation, Inc.,
016: * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017: *
018: * Authors: Ezequiel Cuellar <ecuellar@crosslogic.com> Alessandro Dibella
019: * <alessandro.dibella@fuurou.org>
020: */
021:
022: package org.swingml.model;
023:
024: import org.swingml.*;
025: import org.swingml.system.*;
026:
027: public class JPanelModel extends SwingMLModel {
028:
029: private int bevelType = -1;
030: private String border = null;
031: private boolean collapsable = false;
032: private boolean collapsed = false;
033: private int cols = -1;
034: private String externalLookAndFeel = null;
035: private String lookAndFeel = null;
036: private int rows = -1;
037: private String title = null;
038: private String windowTitle = null;
039:
040: public JPanelModel() {
041: super ();
042: }
043:
044: public int getBevelType() {
045: return this .bevelType;
046: }
047:
048: public String getBorder() {
049: return this .border;
050: }
051:
052: public int getCols() {
053: return this .cols;
054: }
055:
056: public String getExternalLookAndFeel() {
057: return this .externalLookAndFeel;
058: }
059:
060: public String getLookAndFeel() {
061: return this .lookAndFeel;
062: }
063:
064: public int getRows() {
065: return this .rows;
066: }
067:
068: public String getTitle() {
069: return this .title;
070: }
071:
072: public String getWindowTitle() {
073: return this .windowTitle;
074: }
075:
076: public boolean isCollapsable() {
077: return collapsable;
078: }
079:
080: public boolean isCollapsed() {
081: return collapsed;
082: }
083:
084: public void setBevelType(int aBevelType) {
085: this .bevelType = aBevelType;
086: }
087:
088: public void setBorder(String aBorder) {
089: this .border = aBorder;
090: }
091:
092: public void setCollapsable(boolean collapsable) {
093: this .collapsable = collapsable;
094: }
095:
096: public void setCollapsed(boolean collapsed) {
097: this .collapsed = collapsed;
098: }
099:
100: public void setCols(int aCols) {
101: this .cols = aCols;
102: }
103:
104: public void setExternalLookAndFeel(String aLaf) {
105: this .externalLookAndFeel = aLaf;
106: }
107:
108: public void setLookAndFeel(String aLookAndFeel) {
109: this .lookAndFeel = aLookAndFeel;
110: }
111:
112: public void setRows(int aRows) {
113: this .rows = aRows;
114: }
115:
116: public void setTitle(String aTitle) {
117: this .title = aTitle;
118: }
119:
120: public void setWindowTitle(String aTitle) {
121: this .windowTitle = aTitle;
122: }
123:
124: public void validate() {
125: if (super .getParent().getLayout() != null
126: && super .getParent().getLayout().equalsIgnoreCase(
127: Constants.BORDERLAYOUT)) {
128: if (super .getOrientation() == null) {
129: SwingMLLogger
130: .getInstance()
131: .log(
132: "Syntax error: The parameter ORIENTATION in the element "
133: + super .getName()
134: + " is required since its parent's LAYOUT is BorderLayout. Add the parameter ORIENTATION to the element "
135: + super .getName()
136: + " or change its parent's LAYOUT to other than BorderLayout.");
137: }
138: }
139: if (super .getParent().getLayout() != null
140: && !super .getParent().getLayout().equalsIgnoreCase(
141: Constants.BORDERLAYOUT)) {
142: if (super .getOrientation() != null) {
143: SwingMLLogger
144: .getInstance()
145: .log(
146: "Syntax error: The parameter ORIENTATION in the element "
147: + super .getName()
148: + " should be used only when its parent's LAYOUT is BorderLayout. Change its parent's LAYOUT to BorderLayout or delete the parameter ORIENTATION from the element "
149: + super .getName() + ".");
150: }
151: }
152: if (this .border.equalsIgnoreCase(Constants.BEVELBORDER)) {
153: if (this .bevelType == -1) {
154: SwingMLLogger
155: .getInstance()
156: .log(
157: "Syntax error: The parameter BEVELTYPE in the element "
158: + super .getName()
159: + " is required since the since its BORDER is BevelBorder. Add the parameter BEVELTYPE to the element "
160: + super .getName()
161: + " or change its BORDER to other than BevelBorder");
162: }
163: }
164: if (!this .border.equalsIgnoreCase(Constants.BEVELBORDER)) {
165: if (this .bevelType != -1) {
166: SwingMLLogger
167: .getInstance()
168: .log(
169: "Syntax error: The parameter BEVELTYPE in element "
170: + super .getName()
171: + " should be used only when its BORDER type is BevelBorder. Change its BORDER to BevelBorder or delete the parameter BEVELTYPE from the element "
172: + super .getName() + ".");
173: }
174: }
175: if (this .border.equals("") && this .title != null) {
176: SwingMLLogger
177: .getInstance()
178: .log(
179: "Syntax error: The TITLE will not be shown in the element "
180: + super .getName()
181: + " because it doesn't have a border. Add the BORDER parameter to the element "
182: + super .getName() + ".");
183: }
184: if (super .getParent() instanceof JTabbedPaneModel
185: && super .getText() == null) {
186: SwingMLLogger
187: .getInstance()
188: .log(
189: "Syntax error: The parameter TEXT is missing in the element "
190: + super .getName()
191: + ". Add the TEXT parameter to name the TAB.");
192: }
193: if (this .getLayout().equalsIgnoreCase(Constants.GRIDLAYOUT)) {
194: if (this .rows == 0 || this .cols == 0) {
195: SwingMLLogger
196: .getInstance()
197: .log(
198: "Syntax error: The value of the parameter ROWS or COLS in the element "
199: + super .getName()
200: + " should be numeric and greater than 0");
201: }
202: if (this .rows == -1 || this .cols == -1) {
203: SwingMLLogger
204: .getInstance()
205: .log(
206: "Syntax error: The parameter ROWS or COLS in the element "
207: + super .getName()
208: + " should be used since the parent's layout is GridLayout. Add the parameter ROWS or COLS.");
209: }
210: }
211: if (!this .getLayout().equalsIgnoreCase(Constants.GRIDLAYOUT)) {
212: if (this .rows != -1 || this .cols != -1) {
213: SwingMLLogger
214: .getInstance()
215: .log(
216: "Syntax error: The parameters ROWS or COLS in the element "
217: + super .getName()
218: + " are not allowed since its parent's layout is not GridLayout. Remove the parameter ROWS or COLS.");
219: }
220: }
221: if (super .getParent() instanceof JSplitPaneModel
222: && super .getOrientation() != null) {
223: SwingMLLogger
224: .getInstance()
225: .log(
226: "Syntax error: The parameters ORIENTATION in the element "
227: + super .getName()
228: + " is not allowed since its parent's layout is a JSplitPane. Remove the parameter ORIENTATION or put this element into a different container.");
229: }
230:
231: if (externalLookAndFeel != null
232: && externalLookAndFeel.length() > 0
233: && !lookAndFeel.equalsIgnoreCase(Constants.EXTERNAL)) {
234: SwingMLLogger
235: .getInstance()
236: .log(
237: "Syntax error: An EXT-LAF was supplied but the LAF attribute was not set to External.");
238: }
239:
240: if (lookAndFeel != null
241: && lookAndFeel.equalsIgnoreCase(Constants.EXTERNAL)
242: && (externalLookAndFeel == null || externalLookAndFeel
243: .length() == 0)) {
244: SwingMLLogger
245: .getInstance()
246: .log(
247: "Syntax error: The LAF attribute was set to External, but no value was supplied for EXT-LAF. Defaulting to METAL.");
248: this.setLookAndFeel(Constants.METAL);
249: }
250: }
251: }
|