01: package org.swingml.treetablebrowser.ext;
02:
03: import java.awt.*;
04:
05: import org.swingml.*;
06: import org.swingml.xml.*;
07: import org.w3c.dom.*;
08:
09: public class TreeTableBrowserMapper extends MapperUtil implements
10: Mapper {
11:
12: public Object getModelToMap(Node aNode, Object aParent,
13: Container aContainer) {
14: TreeTableBrowserModel m = new TreeTableBrowserModel(null,
15: aContainer);
16: SwingMLModel theContainer = (SwingMLModel) aParent;
17: theContainer.addChild(m);
18: m.setParent(theContainer);
19: return m;
20: }
21:
22: public void mapModel(Node aNode, Object aParent,
23: Container aContainer) {
24: TreeTableBrowserModel theTreeTableModel = (TreeTableBrowserModel) this
25: .getModelToMap(aNode, aParent, aContainer);
26: this .mapModelAttributes(aNode, theTreeTableModel, aParent);
27: super .iterate(aNode, theTreeTableModel, aContainer);
28: }
29:
30: public void mapModelAttributes(Node aNode, Object aModel,
31: Object aParent) {
32: TreeTableBrowserModel treeTableBrowserModel = (TreeTableBrowserModel) aModel;
33: super .mapCommonAttributes(treeTableBrowserModel, aNode);
34: Node attributeNode = super .getAttribute(aNode, Constants.NAME);
35: if (attributeNode != null) {
36: treeTableBrowserModel.setName(attributeNode.getNodeValue());
37: }
38:
39: attributeNode = super .getAttribute(aNode, Constants.EXPAND_TO);
40: if (attributeNode != null) {
41: treeTableBrowserModel.setExpandToNodeName(attributeNode
42: .getNodeValue());
43: }
44:
45: attributeNode = super .getAttribute(aNode, Constants.POST_STYLE);
46: if (attributeNode != null) {
47: treeTableBrowserModel.setPostStyle(attributeNode
48: .getNodeValue());
49: } else {
50: treeTableBrowserModel.setPostStyle(Constants.POST_ALL);
51: }
52:
53: attributeNode = super
54: .getAttribute(aNode, Constants.POST_COLUMN);
55: if (attributeNode != null) {
56: try {
57: treeTableBrowserModel.setPostColumns(attributeNode
58: .getNodeValue());
59: } catch (Exception e) {
60: treeTableBrowserModel.setPostColumn(0);
61: }
62: }
63:
64: attributeNode = getAttribute(aNode, Constants.HEIGHT);
65: if (null != attributeNode) {
66: int i;
67: try {
68: i = Integer.parseInt(attributeNode.getNodeValue());
69: } catch (Exception e) {
70: i = 0;
71: }
72: treeTableBrowserModel.setHeight(i);
73: }
74:
75: attributeNode = getAttribute(aNode, Constants.WIDTH);
76: if (null != attributeNode) {
77: int i;
78: try {
79: i = Integer.parseInt(attributeNode.getNodeValue());
80: } catch (Exception e) {
81: i = 0;
82: }
83: treeTableBrowserModel.setWidth(i);
84: }
85: }
86: }
|