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: *
022: */
023:
024: package org.swingml.xml.mapper;
025:
026: import java.awt.*;
027:
028: import org.swingml.*;
029: import org.swingml.model.*;
030: import org.swingml.xml.*;
031: import org.w3c.dom.*;
032:
033: public class JInternalFrameMapper extends MapperUtil implements Mapper {
034:
035: public Object getModelToMap(Node aNode, Object aParent,
036: Container aContainer) {
037: SwingMLModel theContainer = (SwingMLModel) aParent;
038: JInternalFrameModel theModel = new JInternalFrameModel();
039: theContainer.addChild(theModel);
040: theModel.setParent(theContainer);
041: return theModel;
042: }
043:
044: public void mapModel(Node aNode, Object aParent,
045: Container aContainer) {
046: JInternalFrameModel theModel = (JInternalFrameModel) this
047: .getModelToMap(aNode, aParent, aContainer);
048: this .mapModelAttributes(aNode, theModel, aParent);
049: this .iterate(aNode, theModel, aContainer);
050: }
051:
052: public void mapModelAttributes(Node aNode, Object aModel,
053: Object aParent) {
054: JInternalFrameModel theModel = (JInternalFrameModel) aModel;
055: super .mapCommonAttributes(theModel, aNode);
056: Node theResultNode = super .getAttribute(aNode, Constants.WIDTH);
057: if (theResultNode != null) {
058: try {
059: theModel.setWidth(Integer.parseInt(theResultNode
060: .getNodeValue()));
061: } catch (NumberFormatException e) {
062: theModel.setWidth(0);
063: }
064: }
065: theResultNode = super .getAttribute(aNode, Constants.HEIGHT);
066: if (theResultNode != null) {
067: try {
068: theModel.setHeight(Integer.parseInt(theResultNode
069: .getNodeValue()));
070: } catch (NumberFormatException e) {
071: theModel.setWidth(0);
072: }
073: }
074: theResultNode = super .getAttribute(aNode, Constants.ROWS);
075: if (theResultNode != null) {
076: try {
077: theModel.setRows(Integer.parseInt(theResultNode
078: .getNodeValue()));
079: } catch (NumberFormatException e) {
080: theModel.setRows(0);
081: }
082: }
083: theResultNode = super .getAttribute(aNode, Constants.COLS);
084: if (theResultNode != null) {
085: try {
086: theModel.setCols(Integer.parseInt(theResultNode
087: .getNodeValue()));
088: } catch (NumberFormatException e) {
089: theModel.setCols(0);
090: }
091: }
092: theResultNode = super .getAttribute(aNode, Constants.LOCATION);
093: if (theResultNode != null) {
094: theModel.setLocation(theResultNode.getNodeValue());
095: }
096: theResultNode = super
097: .getAttribute(aNode, Constants.MAXIMIZABLE);
098: if (theResultNode != null) {
099: if (theResultNode.getNodeValue().equalsIgnoreCase(
100: Constants.FALSE)) {
101: theModel.setMaximizable(false);
102: }
103: }
104: theResultNode = super
105: .getAttribute(aNode, Constants.ICONIFIABLE);
106: if (theResultNode != null) {
107: if (theResultNode.getNodeValue().equalsIgnoreCase(
108: Constants.FALSE)) {
109: theModel.setIconifiable(false);
110: }
111: }
112: theResultNode = super .getAttribute(aNode, Constants.RESIZABLE);
113: if (theResultNode != null) {
114: if (theResultNode.getNodeValue().equalsIgnoreCase(
115: Constants.FALSE)) {
116: theModel.setResizable(false);
117: }
118: }
119: theResultNode = super .getAttribute(aNode, Constants.CLOSABLE);
120: if (theResultNode != null) {
121: if (theResultNode.getNodeValue().equalsIgnoreCase(
122: Constants.FALSE)) {
123: theModel.setClosable(false);
124: }
125: }
126: }
127: }
|