/* SwingML
* Copyright (C) 2002 Robert Morris.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Robert Morris <robertj@morris.net>
*
*/
package org.swingml.model;
import java.util.*;
import org.swingml.*;
import org.swingml.system.*;
public class GridBagPanelModel extends GridBagBaseModel {
private int m_bevelType = -1;
private String m_border = null;
private List m_children = null;
private int m_currentRow = 0;
private String m_orientation = null;
private String m_text = null;
private String m_title = null;
public GridBagPanelModel () {
super();
}
public void addChild (Object aChild) {
if (aChild instanceof GridBagRowModel) {
GridBagRowModel theRowModel = (GridBagRowModel) aChild;
theRowModel.setValues(this);
theRowModel.setRow(this.m_currentRow);
this.m_currentRow++;
}
this.getChildren().add(aChild);
}
public int getBevelType () {
return this.m_bevelType;
}
public String getBorder () {
return this.m_border;
}
public List getChildren () {
if (this.m_children == null) {
this.m_children = new Vector();
}
return this.m_children;
}
public String getLayout () {
return null;
}
public String getOrientation () {
return this.m_orientation;
}
public String getText () {
return this.m_text;
}
public String getTitle () {
return this.m_title;
}
public void setBevelType (int aBevelType) {
this.m_bevelType = aBevelType;
}
public void setBorder (String aBorder) {
this.m_border = aBorder;
}
public void setChildren (List aChildren) {
this.m_children = aChildren;
}
public void setOrientation (String anOrientation) {
this.m_orientation = anOrientation;
}
public void setTitle (String aTitle) {
this.m_title = aTitle;
}
public void validate () {
if (super.getParent().getLayout() != null && super.getParent().getLayout().equalsIgnoreCase(Constants.BORDERLAYOUT)) {
if (this.getOrientation() == null) {
SwingMLLogger.getInstance().log(
"Syntax error: The parameter ORIENTATION in the element " + this.m_name
+ " is required since its parent's LAYOUT is BorderLayout. Add the parameter ORIENTATION to the element " + this.m_name
+ " or change its parent's LAYOUT to other than BorderLayout.");
}
}
if (super.getParent().getLayout() != null && !super.getParent().getLayout().equalsIgnoreCase(Constants.BORDERLAYOUT)) {
if (this.getOrientation() != null) {
SwingMLLogger.getInstance().log(
"Syntax error: The parameter ORIENTATION in the element " + this.m_name
+ " 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 "
+ this.m_name + ".");
}
}
if (this.getBorder() != null) {
if (this.getBorder().equalsIgnoreCase(Constants.BEVELBORDER)) {
if (this.getBevelType() == -1) {
SwingMLLogger.getInstance().log(
"Syntax error: The parameter BEVELTYPE in the element " + this.m_name
+ " is required since the since its BORDER is BevelBorder. Add the parameter BEVELTYPE to the element " + this.m_name
+ " or change its BORDER to other than BevelBorder");
}
}
if (!this.getBorder().equalsIgnoreCase(Constants.BEVELBORDER)) {
if (this.getBevelType() != -1) {
SwingMLLogger.getInstance().log(
"Syntax error: The parameter BEVELTYPE in element " + this.m_name
+ " should be used only when its BORDER type is BevelBorder. Change its BORDER to BevelBorder or delete the parameter BEVELTYPE from the element " + this.m_name
+ ".");
}
}
}
if (super.getParent() instanceof JTabbedPaneModel && this.getText() == null) {
SwingMLLogger.getInstance().log("Syntax error: The parameter TEXT is missing in the element " + this.m_name + ". Add the TEXT parameter to name the TAB.");
}
if (super.getParent() instanceof JSplitPaneModel && this.getOrientation() != null) {
SwingMLLogger.getInstance().log(
"Syntax error: The parameters ORIENTATION in the element " + this.m_name
+ " is not allowed since its parent's layout is a JSplitPane. Remove the parameter ORIENTATION or put this element into a different container.");
}
}
}
|