01: package org.swingml.treetablebrowser.ext;
02:
03: import java.awt.*;
04: import java.net.*;
05:
06: import org.swingml.*;
07: import org.swingml.xml.*;
08: import org.w3c.dom.*;
09:
10: public class TreeTableBrowserTreeMapper extends MapperUtil implements
11: Mapper {
12:
13: public Object getModelToMap(Node aNode, Object aParent,
14: Container aContainer) {
15: TreeTableBrowserTreeModel theTreeTableTreeModel = new TreeTableBrowserTreeModel(
16: aContainer);
17: SwingMLModel theContainer = (SwingMLModel) aParent;
18: theContainer.addChild(theTreeTableTreeModel);
19: theTreeTableTreeModel.setParent(theContainer);
20: return theTreeTableTreeModel;
21: }
22:
23: public void mapModel(Node aNode, Object aParent,
24: Container aContainer) {
25: TreeTableBrowserTreeModel theTreeTableTreeModel = (TreeTableBrowserTreeModel) this
26: .getModelToMap(aNode, aParent, aContainer);
27: this .mapModelAttributes(aNode, theTreeTableTreeModel, aParent);
28: super .iterate(aNode, theTreeTableTreeModel, aContainer);
29: }
30:
31: public void mapModelAttributes(Node aNode, Object aModel,
32: Object aParent) {
33: TreeTableBrowserTreeModel model = (TreeTableBrowserTreeModel) aModel;
34: super .mapCommonAttributes(model, aNode);
35: Node n = null;
36: n = super .getAttribute(aNode, Constants.OPEN_ICON);
37: if (n != null) {
38: try {
39: URL url = URLHandler.handle(n.getNodeValue());
40: model.setOpenFolderIcon(url.toString());
41: } catch (Exception e) { /* Ignore Exceptions, default will be used */
42: }
43: }
44: n = super .getAttribute(aNode, Constants.CLOSED_ICON);
45: if (n != null) {
46: try {
47: URL url = URLHandler.handle(n.getNodeValue());
48: model.setClosedFolderIcon(url.toString());
49: } catch (Exception e) { /* Ignore Exceptions, default will be used */
50: }
51: }
52: n = super .getAttribute(aNode, Constants.LEAF_ICON);
53: if (n != null) {
54: try {
55: URL url = URLHandler.handle(n.getNodeValue());
56: model.setLeafIcon(url.toString());
57: } catch (Exception e) { /* Ignore Exceptions, default will be used */
58: }
59: }
60: }
61: }
|