001: /* SwingML
002: * Copyright (C) 2002 SwingML Team
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: * Ezequiel Cuellar <ecuellar@crosslogic.com>
021: * Farid Ibrahim <faridibrahim@lycos.com>
022: *
023: */
024:
025: package org.swingml.model;
026:
027: import org.swingml.*;
028: import org.swingml.system.*;
029:
030: public class JTextFieldModel extends SwingMLModel {
031:
032: private String button;
033: private String cols;
034: private boolean editable = true;
035: private boolean enabled = true;
036: private boolean autoSelect = true;
037:
038: public JTextFieldModel() {
039: super ();
040: }
041:
042: public String getCols() {
043: return this .cols;
044: }
045:
046: public String getReturnButton() {
047: return button;
048: }
049:
050: public boolean isEditable() {
051: return this .editable;
052: }
053:
054: public boolean isEnabled() {
055: return this .enabled;
056: }
057:
058: public void setCols(String aColumns) {
059: this .cols = aColumns;
060: }
061:
062: public void setEditable(boolean aEditable) {
063: this .editable = aEditable;
064: }
065:
066: public void setEnabled(boolean aEnabled) {
067: this .enabled = aEnabled;
068: }
069:
070: public void setReturnButton(final String s) {
071: button = s;
072: }
073:
074: public void setAutoSelect(boolean select) {
075: this .autoSelect = select;
076: }
077:
078: public boolean shouldAutoSelectOnFocus() {
079: return autoSelect;
080: }
081:
082: public void validate() {
083: if (super .getParent().getLayout() != null
084: && super .getParent().getLayout().equalsIgnoreCase(
085: Constants.BORDERLAYOUT)) {
086: if (super .getOrientation() == null) {
087: SwingMLLogger
088: .getInstance()
089: .log(
090: "Syntax error: The parameter ORIENTATION in the element "
091: + super .getName()
092: + " is required since its parent's LAYOUT is BorderLayout. Add the parameter ORIENTATION to the element "
093: + super .getName()
094: + " or change its parent's LAYOUT to other than BorderLayout.");
095: }
096: }
097: if (super .getParent().getLayout() != null
098: && !super .getParent().getLayout().equalsIgnoreCase(
099: Constants.BORDERLAYOUT)) {
100: if (super .getOrientation() != null) {
101: SwingMLLogger
102: .getInstance()
103: .log(
104: "Syntax error: The parameter ORIENTATION in the element "
105: + super .getName()
106: + " 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 "
107: + super .getName() + ".");
108: }
109: }
110: try {
111: Integer.parseInt(this .cols);
112: } catch (NumberFormatException e) {
113: this .cols = "0";
114: SwingMLLogger.getInstance().log(
115: "Syntax error: The parameter COLS in the element "
116: + super .getName()
117: + " should be a numeric value.");
118: }
119: }
120: }
|