KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbcore > ui > logicalview > ejb > session > SessionChildren


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.j2ee.ejbcore.ui.logicalview.ejb.session;
21
22 import java.beans.PropertyChangeEvent JavaDoc;
23 import java.beans.PropertyChangeListener JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.util.Collections JavaDoc;
26 import java.util.List JavaDoc;
27 import javax.swing.SwingUtilities JavaDoc;
28 import org.netbeans.api.java.classpath.ClassPath;
29 import org.netbeans.modules.j2ee.dd.api.ejb.Session;
30 import org.netbeans.modules.j2ee.ejbcore.api.methodcontroller.SessionMethodController;
31 import org.openide.nodes.Children;
32 import org.openide.nodes.Node;
33
34
35 /**
36  * @author Chris Webster
37  * @author Martin Adamek
38  */

39
40 public final class SessionChildren extends Children.Keys<SessionChildren.Key> implements PropertyChangeListener JavaDoc {
41     
42     public enum Key {REMOTE, LOCAL};
43     
44     private final Session session;
45     private final ClassPath classPath;
46     private final SessionMethodController controller;
47     
48     public SessionChildren(Session session, ClassPath classPath) {
49         this.classPath = classPath;
50         this.session = session;
51         //TODO: RETOUCHE
52
controller = new SessionMethodController(null, session);
53     }
54     
55     protected void addNotify() {
56         super.addNotify();
57         updateKeys();
58         session.addPropertyChangeListener(this);
59         classPath.addPropertyChangeListener(this);
60     }
61     
62     private void updateKeys() {
63         SwingUtilities.invokeLater(new Runnable JavaDoc() {
64             public void run() {
65                 List JavaDoc<Key> keys = new ArrayList JavaDoc<Key>();
66                 if (session.getRemote() != null) { keys.add(Key.REMOTE); }
67                 if (session.getLocal()!=null) { keys.add(Key.LOCAL); }
68                 setKeys(keys);
69             }
70         });
71     }
72     
73     protected void removeNotify() {
74         session.removePropertyChangeListener(this);
75         classPath.removePropertyChangeListener(this);
76         setKeys(Collections.<Key>emptyList());
77         super.removeNotify();
78     }
79     
80     protected Node[] createNodes(Key key) {
81 // if (Key.LOCAL.equals(key)) {
82
// Children c = new MethodChildren(controller, controller.getLocalInterfaces(), true);
83
// MethodsNode n = new MethodsNode(model, jar, srcPath, c, true);
84
// n.setIconBaseWithExtension("org/netbeans/modules/j2ee/ejbcore/resources/LocalMethodContainerIcon.gif");
85
// n.setDisplayName(NbBundle.getMessage(EjbViewController.class, "LBL_LocalMethods"));
86
// return new Node[] { n };
87
// }
88
// if (Key.REMOTE.equals(key)) {
89
// Children c = new MethodChildren(controller, controller.getRemoteInterfaces(), false);
90
// MethodsNode n = new MethodsNode(model, jar, srcPath, c, false);
91
// n.setIconBaseWithExtension("org/netbeans/modules/j2ee/ejbcore/resources/RemoteMethodContainerIcon.gif");
92
// n.setDisplayName(NbBundle.getMessage(EjbViewController.class, "LBL_RemoteMethods"));
93
// return new Node[] { n };
94
// }
95
return null;
96     }
97     
98     public void propertyChange(PropertyChangeEvent JavaDoc propertyChangeEvent) {
99         SwingUtilities.invokeLater(new Runnable JavaDoc() {
100             public void run() {
101                 updateKeys();
102             }
103         });
104     }
105     
106 }
107
Popular Tags