KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > java > eventfiring > MyListener


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 /*
21  * MyListener.java
22  *
23  * Created on September 8, 2000, 11:35 AM
24  */

25
26 package org.netbeans.test.java.eventfiring;
27
28 import org.openide.nodes.Node.Handle;
29
30 /**
31  *
32  * @author jbecicka
33  * @version
34  */

35 public class MyListener extends org.openide.nodes.AbstractNode implements org.openide.cookies.ConnectionCookie.Listener {
36
37     public static final String JavaDoc RESULT_KEY = "ResultKey";
38     static MyListener me = null;
39     public MyListener(){
40         super(org.openide.nodes.Children.LEAF);
41         getCookieSet().add(this);
42         me=this;
43     }
44
45     public void notify (org.openide.cookies.ConnectionCookie.Event ev) {
46         System.setProperty(RESULT_KEY,System.getProperty(RESULT_KEY)+"\nJavaConnection: "+getTextFromType(ev.getType()));
47     }
48     
49     public Handle getHandle() {
50         return new org.netbeans.test.java.eventfiring.MyListener.NodeHandle();
51     }
52     // Note that this class should be static and is serializable:
53
private static class NodeHandle implements Handle {
54         public NodeHandle () {
55         }
56         public org.openide.nodes.Node getNode() throws java.io.IOException JavaDoc {
57             if (me!=null) return me;
58             else return new MyListener ();
59         }
60     }
61     String JavaDoc getTextFromType(org.openide.cookies.ConnectionCookie.Type type){
62         
63         //int jct = ((org.netbeans.modules.java.JavaConnections.Type) type).getFilter();
64
String JavaDoc result="";
65         for (int i=1,j=0; i<=0x200000; i<<=1,j++){
66             //result+=(i&jct)!=0?tab[j]:"";
67
}
68         return result;
69     }
70     
71     String JavaDoc[] tab= {
72         " TYPE_FIELDS_ADD",
73         " TYPE_FIELDS_REMOVE",
74         " TYPE_FIELDS_CHANGE",
75         "",
76         " TYPE_METHODS_ADD",
77         " TYPE_METHODS_REMOVE",
78         " TYPE_METHODS_CHANGE",
79         "",
80         " TYPE_CLASSES_ADD",
81         " TYPE_CLASSES_REMOVE",
82         " TYPE_CLASSES_CHANGE",
83         "",
84         " TYPE_CONSTRUCTORS_ADD",
85         " TYPE_CONSTRUCTORS_REMOVE",
86         " TYPE_CONSTRUCTORS_CHANGE",
87         "",
88         " TYPE_INITIALIZERS_ADD",
89         " TYPE_INITIALIZERS_REMOVE",
90         " TYPE_INITIALIZERS_CHANGE",
91     };
92 }
93
Popular Tags