KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > registry > ui > StructureTypeTreeNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.registry.ui;
21
22 import javax.swing.tree.*;
23
24 import org.openide.ErrorManager;
25
26 import java.net.URLClassLoader JavaDoc;
27
28
29 /**
30  *
31  * @author David Botterill
32  */

33 public class StructureTypeTreeNode extends DefaultMutableTreeNode {
34     private URLClassLoader JavaDoc urlClassLoader;
35     private String JavaDoc packageName;
36
37     /** Creates a new instance of TypeTreeNode */
38     public StructureTypeTreeNode(Object JavaDoc userObject,URLClassLoader JavaDoc inClassLoader,String JavaDoc inPackageName) {
39         super(userObject);
40         urlClassLoader = inClassLoader;
41         packageName = inPackageName;
42         
43     }
44     /**
45      * This method will use the parameter name of the child to update the value of this Structure.
46      * @param inData - the TypeNodeData of the child that called this method.
47      * @param inChildParameterName - the name of the field to be updated.
48      */

49     public void updateValueOfChild(TypeNodeData inData) {
50         TypeNodeData data = (TypeNodeData)this.getUserObject();
51         try {
52             ReflectionHelper.setStructureValue(data,inData,urlClassLoader,packageName);
53         } catch(WebServiceReflectionException wsfe) {
54             Throwable JavaDoc cause = wsfe.getCause();
55             ErrorManager.getDefault().notify(cause);
56             ErrorManager.getDefault().log(this.getClass().getName() +
57             ": Error trying to update Children of a Structure on: " + data.getParameterType().getFormalName() + "WebServiceReflectionException=" + cause);
58             
59         }
60         /**
61          * If this node is a member of a structure type, update it's parent.
62          */

63         DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) this.getParent();
64         if(null != parentNode && parentNode instanceof ArrayTypeTreeNode) {
65             ((ArrayTypeTreeNode)parentNode).updateValueOfChildren();
66         } else if(null != parentNode && parentNode instanceof StructureTypeTreeNode) {
67             /**
68              * This type should be a JavaStructureMember
69              */

70             ((StructureTypeTreeNode)parentNode).updateValueOfChild(data);
71         }
72         
73     }
74     
75 }
76
Popular Tags