1 19 20 package org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.session; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import java.util.ArrayList ; 25 import java.util.Collections ; 26 import java.util.List ; 27 import javax.swing.SwingUtilities ; 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 39 40 public final class SessionChildren extends Children.Keys<SessionChildren.Key> implements PropertyChangeListener { 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 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 () { 64 public void run() { 65 List <Key> keys = new ArrayList <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 return null; 96 } 97 98 public void propertyChange(PropertyChangeEvent propertyChangeEvent) { 99 SwingUtilities.invokeLater(new Runnable () { 100 public void run() { 101 updateKeys(); 102 } 103 }); 104 } 105 106 } 107 | Popular Tags |