View Javadoc

1   /*
2    * @(#)$Id: NodeInfoImplJdom.java 719 2009-07-30 11:41:39Z kurmannu $
3    *
4    * Author		:	Ueli Kurmann, igesture@uelikurmann.ch
5    *                  
6    *
7    * Purpose		: 
8    *
9    * -----------------------------------------------------------------------
10   *
11   * Revision Information:
12   *
13   * Date				Who			Reason
14   *
15   * 07.04.2008			ukurmann	Initial Release
16   *
17   * -----------------------------------------------------------------------
18   *
19   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20   *
21   * This software is the proprietary information of ETH Zurich.
22   * Use is subject to license terms.
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   * TODO: untested code
39   * Comment
40   * @version 1.0 07.04.2008
41   * @author Ueli Kurmann
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           // FIXME set controller
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  }