01: /* SwingML
02: * Copyright (C) 2002 SwingML Team
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the
16: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17: * Boston, MA 02111-1307, USA.
18: *
19: * Authors:
20: * Ezequiel Cuellar <ecuellar@crosslogic.com>
21: * Farid Ibrahim <faridibrahim@lycos.com>
22: *
23: */
24:
25: package org.swingml.xml.mapper;
26:
27: import java.awt.*;
28:
29: import org.swingml.*;
30: import org.swingml.model.*;
31: import org.swingml.xml.*;
32: import org.w3c.dom.*;
33:
34: public class JTextFieldMapper extends MapperUtil implements Mapper {
35:
36: public Object getModelToMap(Node aNode, Object aParent,
37: Container aContainer) {
38: JTextFieldModel theModel = new JTextFieldModel();
39: SwingMLModel theContainer = (SwingMLModel) aParent;
40: theContainer.addChild(theModel);
41: theModel.setParent(theContainer);
42:
43: return theModel;
44: }
45:
46: public void mapModel(Node aNode, Object aParent,
47: Container aContainer) {
48: JTextFieldModel theModel = (JTextFieldModel) getModelToMap(
49: aNode, aParent, aContainer);
50: this .mapModelAttributes(aNode, theModel, aParent);
51: super .iterate(aNode, theModel, aContainer);
52: }
53:
54: public void mapModelAttributes(Node aNode, Object aModel,
55: Object aParent) {
56: JTextFieldModel theModel = (JTextFieldModel) aModel;
57: super .mapCommonAttributes(theModel, aNode);
58: Node theResultNode = super .getAttribute(aNode, Constants.COLS);
59: if (theResultNode != null) {
60: theModel.setCols(theResultNode.getNodeValue());
61: }
62: theResultNode = super .getAttribute(aNode, Constants.EDITABLE);
63: if (theResultNode != null) {
64: if (theResultNode.getNodeValue().equalsIgnoreCase(
65: Constants.FALSE)) {
66: theModel.setEditable(false);
67: }
68: }
69: theResultNode = super .getAttribute(aNode, Constants.VISIBLE);
70: if (theResultNode != null) {
71: if (theResultNode.getNodeValue().equalsIgnoreCase(
72: Constants.FALSE)) {
73: theModel.setVisible(false);
74: }
75: }
76: theResultNode = super .getAttribute(aNode, Constants.ENABLED);
77: if (theResultNode != null) {
78: theModel.setEnabled(theResultNode.getNodeValue()
79: .equalsIgnoreCase(Constants.TRUE));
80: }
81: theResultNode = getAttribute(aNode, Constants.RETURNBUTTON);
82: if (null != theResultNode) {
83: theModel.setReturnButton(theResultNode.getNodeValue());
84: }
85:
86: theResultNode = getAttribute(aNode, Constants.AUTO_SELECT);
87: if (null != theResultNode) {
88: theModel.setAutoSelect((new Boolean(theResultNode
89: .getNodeValue())).booleanValue());
90: }
91: }
92: }
|