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: * Robert J. Morris <robertj@morris.net>
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.system.*;
32: import org.swingml.xml.*;
33: import org.w3c.dom.*;
34:
35: public class JTabbedPaneMapper extends MapperUtil implements Mapper {
36:
37: public Object getModelToMap(Node aNode, Object aParent,
38: Container aContainer) {
39: JTabbedPaneModel theModel = new JTabbedPaneModel();
40: SwingMLModel theContainer = (SwingMLModel) aParent;
41: theContainer.addChild(theModel);
42: theModel.setParent(theContainer);
43: return theModel;
44: }
45:
46: public void mapModel(Node aNode, Object aParent,
47: Container aContainer) {
48: JTabbedPaneModel theModel = (JTabbedPaneModel) this
49: .getModelToMap(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: JTabbedPaneModel theModel = (JTabbedPaneModel) aModel;
57: super .mapCommonAttributes(theModel, aNode);
58:
59: Node theResultNode = super .getAttribute(aNode,
60: Constants.CURRENT);
61: if (theResultNode != null) {
62: int theCurrent = 0;
63: try {
64: theCurrent = new Integer(theResultNode.getNodeValue())
65: .intValue();
66: } catch (Exception e) {
67: theCurrent = 0;
68: SwingMLLogger
69: .getInstance()
70: .log(
71: ILogCapable.ERROR,
72: "Syntax Error: A non-integer value was specified for the CURRENT attribute in the TABBEDPANE tag: ["
73: + theModel.getName()
74: + "]. Defaulted to 0.");
75: SwingMLLogger.getInstance().log(ILogCapable.ERROR, e);
76: }
77: theModel.setCurrent(theCurrent);
78: }
79: }
80: }
|