1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.ximtec.igesture.tool.explorer;
28
29 import java.util.ArrayList;
30 import java.util.List;
31
32 import org.jdom.Element;
33 import org.sigtec.graphix.widget.BasicAction;
34 import org.ximtec.igesture.tool.explorer.core.ExplorerTreeView;
35
36
37
38
39
40
41
42
43 public class NodeInfoImplJdom extends Element {
44
45 private static final String ACTION = "action";
46 private static final String ACTIONS = "actions";
47 private static final String TYPE = "type";
48 private static final String VIEW = "view";
49 private static final String CHILD = "child";
50 private static final String PROPERTY_NAME = "propertyName";
51
52
53 public NodeInfoImplJdom(NodeInfoImpl nodeInfo) {
54
55 }
56
57
58 @SuppressWarnings("unchecked")
59 public static NodeInfoImpl unmarshall(Element element) {
60
61 String propertyName = element.getChildText(PROPERTY_NAME);
62
63 StringBuilder childrenList = new StringBuilder();
64 for (Element childElement : ((List<Element>)element.getChildren(CHILD))) {
65 childrenList.append(childElement.getText());
66 childrenList.append(NodeInfoImpl.CHILD_DELIMITER);
67 }
68
69
70 String view = element.getChildText(VIEW);
71 String type = element.getChildText(TYPE);
72
73 try {
74 Class< ? extends ExplorerTreeView> viewClass = (Class< ? extends ExplorerTreeView>)Class.forName(view);
75 Class< ? > typeClass = Class.forName(type);
76
77
78 Element actions = element.getChild(ACTIONS);
79 List<Class< ? extends BasicAction>> actionList = new ArrayList<Class< ? extends BasicAction>>();
80 for(Element actionElement: ((List<Element>)actions.getChildren(ACTION))){
81 actionList.add((Class< ? extends BasicAction>)Class.forName(actionElement.getText()));
82 }
83
84 return new NodeInfoImpl(null, typeClass, propertyName, childrenList.toString(), viewClass, actionList,
85 "");
86 }
87 catch (ClassNotFoundException e) {
88 e.printStackTrace();
89 }
90 return null;
91 }
92
93 }