01: /*
02: * SwingML Copyright (C) 2002 SwingML Team
03: *
04: * This library is free software; you can redistribute it and/or modify it under
05: * the terms of the GNU Lesser General Public License as published by the Free
06: * Software Foundation; either version 2 of the License, or (at your option) any
07: * later version.
08: *
09: * This library is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12: * details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with this library; if not, write to the Free Software Foundation, Inc.,
16: * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: * Authors: Ezequiel Cuellar <ecuellar@crosslogic.com> Marcelo W. Lopez Cremona
19: * <marcelo_java@argentina.com>
20: *
21: */
22:
23: package org.swingml.xml.mapper;
24:
25: import java.awt.*;
26:
27: import org.swingml.*;
28: import org.swingml.model.*;
29: import org.swingml.xml.*;
30: import org.w3c.dom.*;
31:
32: public class IconMapper extends MapperUtil implements Mapper {
33:
34: public Object getModelToMap(Node aNode, Object aParent,
35: Container aContainer) {
36: IconModel theModel = new IconModel();
37: SwingMLModel theContainer = (SwingMLModel) aParent;
38: theContainer.addChild(theModel);
39: theModel.setParent(theContainer);
40: return theModel;
41: }
42:
43: public void mapModel(Node aNode, Object aParent,
44: Container aContainer) {
45: IconModel theModel = (IconModel) this .getModelToMap(aNode,
46: aParent, aContainer);
47: this .mapModelAttributes(aNode, theModel, aParent);
48:
49: // call iterate to look for listeners
50: super .iterate(aNode, theModel, aContainer);
51: }
52:
53: public void mapModelAttributes(Node aNode, Object aModel,
54: Object aParent) {
55: IconModel theModel = (IconModel) aModel;
56: super .mapCommonAttributes(theModel, aNode);
57: Node theResultNode = super.getAttribute(aNode,
58: Constants.LOCATION);
59: if (theResultNode != null) {
60: theModel.setIcon(theResultNode.getNodeValue());
61: }
62: }
63: }
|