001: /* SwingML
002: * Copyright (C) 2002 Robert Morris.
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the
016: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017: * Boston, MA 02111-1307, USA.
018: *
019: * Authors:
020: * Robert Morris <robertj@morris.net>
021: *
022: */
023: package org.swingml.model;
024:
025: import java.util.*;
026:
027: import org.swingml.*;
028: import org.swingml.system.*;
029:
030: public class GridBagPanelModel extends GridBagBaseModel {
031:
032: private int m_bevelType = -1;
033: private String m_border = null;
034: private List m_children = null;
035: private int m_currentRow = 0;
036: private String m_orientation = null;
037: private String m_text = null;
038: private String m_title = null;
039:
040: public GridBagPanelModel() {
041: super ();
042: }
043:
044: public void addChild(Object aChild) {
045: if (aChild instanceof GridBagRowModel) {
046: GridBagRowModel theRowModel = (GridBagRowModel) aChild;
047: theRowModel.setValues(this );
048: theRowModel.setRow(this .m_currentRow);
049: this .m_currentRow++;
050: }
051: this .getChildren().add(aChild);
052: }
053:
054: public int getBevelType() {
055: return this .m_bevelType;
056: }
057:
058: public String getBorder() {
059: return this .m_border;
060: }
061:
062: public List getChildren() {
063: if (this .m_children == null) {
064: this .m_children = new Vector();
065: }
066:
067: return this .m_children;
068: }
069:
070: public String getLayout() {
071: return null;
072: }
073:
074: public String getOrientation() {
075: return this .m_orientation;
076: }
077:
078: public String getText() {
079: return this .m_text;
080: }
081:
082: public String getTitle() {
083: return this .m_title;
084: }
085:
086: public void setBevelType(int aBevelType) {
087: this .m_bevelType = aBevelType;
088: }
089:
090: public void setBorder(String aBorder) {
091: this .m_border = aBorder;
092: }
093:
094: public void setChildren(List aChildren) {
095: this .m_children = aChildren;
096: }
097:
098: public void setOrientation(String anOrientation) {
099: this .m_orientation = anOrientation;
100: }
101:
102: public void setTitle(String aTitle) {
103: this .m_title = aTitle;
104: }
105:
106: public void validate() {
107: if (super .getParent().getLayout() != null
108: && super .getParent().getLayout().equalsIgnoreCase(
109: Constants.BORDERLAYOUT)) {
110: if (this .getOrientation() == null) {
111: SwingMLLogger
112: .getInstance()
113: .log(
114: "Syntax error: The parameter ORIENTATION in the element "
115: + this .m_name
116: + " is required since its parent's LAYOUT is BorderLayout. Add the parameter ORIENTATION to the element "
117: + this .m_name
118: + " or change its parent's LAYOUT to other than BorderLayout.");
119: }
120: }
121: if (super .getParent().getLayout() != null
122: && !super .getParent().getLayout().equalsIgnoreCase(
123: Constants.BORDERLAYOUT)) {
124: if (this .getOrientation() != null) {
125: SwingMLLogger
126: .getInstance()
127: .log(
128: "Syntax error: The parameter ORIENTATION in the element "
129: + this .m_name
130: + " 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 "
131: + this .m_name + ".");
132: }
133: }
134: if (this .getBorder() != null) {
135: if (this .getBorder()
136: .equalsIgnoreCase(Constants.BEVELBORDER)) {
137: if (this .getBevelType() == -1) {
138: SwingMLLogger
139: .getInstance()
140: .log(
141: "Syntax error: The parameter BEVELTYPE in the element "
142: + this .m_name
143: + " is required since the since its BORDER is BevelBorder. Add the parameter BEVELTYPE to the element "
144: + this .m_name
145: + " or change its BORDER to other than BevelBorder");
146: }
147: }
148: if (!this .getBorder().equalsIgnoreCase(
149: Constants.BEVELBORDER)) {
150: if (this .getBevelType() != -1) {
151: SwingMLLogger
152: .getInstance()
153: .log(
154: "Syntax error: The parameter BEVELTYPE in element "
155: + this .m_name
156: + " should be used only when its BORDER type is BevelBorder. Change its BORDER to BevelBorder or delete the parameter BEVELTYPE from the element "
157: + this .m_name + ".");
158: }
159: }
160: }
161: if (super .getParent() instanceof JTabbedPaneModel
162: && this .getText() == null) {
163: SwingMLLogger
164: .getInstance()
165: .log(
166: "Syntax error: The parameter TEXT is missing in the element "
167: + this .m_name
168: + ". Add the TEXT parameter to name the TAB.");
169: }
170: if (super .getParent() instanceof JSplitPaneModel
171: && this .getOrientation() != null) {
172: SwingMLLogger
173: .getInstance()
174: .log(
175: "Syntax error: The parameters ORIENTATION in the element "
176: + this .m_name
177: + " is not allowed since its parent's layout is a JSplitPane. Remove the parameter ORIENTATION or put this element into a different container.");
178: }
179: }
180: }
|