1 19 20 package org.netbeans.modules.j2ee.deployment.impl.ui; 21 22 import java.awt.Component ; 23 import javax.swing.Action ; 24 import javax.swing.JFrame ; 25 import javax.swing.SwingUtilities ; 26 import org.openide.nodes.*; 27 import org.openide.util.HelpCtx; 28 import org.netbeans.modules.j2ee.deployment.impl.*; 29 import org.netbeans.modules.j2ee.deployment.impl.ui.actions.*; 30 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; 31 32 import org.openide.windows.WindowManager; 33 34 import org.openide.util.RequestProcessor; 35 import org.openide.util.Utilities; 36 37 38 39 45 public class InstanceNode extends AbstractNode implements ServerInstance.StateListener { 46 47 private static int cursorChangeCounter = 0; 48 49 protected ServerInstance instance; 50 51 private boolean running; 52 53 public InstanceNode(ServerInstance instance, boolean addStateListener) { 54 super(new InstanceChildren(instance)); 55 this.instance = instance; 56 setIconBase(instance.getServer().getIconBase()); 57 getCookieSet().add(instance); 58 if (addStateListener) { 59 instance.addStateListener(this); 60 } 61 } 62 63 public HelpCtx getHelpCtx() { 64 return HelpCtx.DEFAULT_HELP; 65 } 66 67 public org.openide.nodes.Node.Cookie getCookie(Class type) { 68 if (ServerInstance.class.isAssignableFrom(type)) { 69 return instance; 70 } 71 return super.getCookie(type); 72 } 73 74 76 public void stateChanged(int oldState, int newState) { 77 if (instance.getServerState() != ServerInstance.STATE_WAITING 78 && instance.getServerState() != ServerInstance.STATE_SUSPENDED) { 79 setChildren(new InstanceChildren(instance)); 80 getChildren().getNodes(true); 81 } else if (instance.getServerState() == ServerInstance.STATE_SUSPENDED) { 82 setChildren(Children.LEAF); 83 } 84 } 85 86 public static class InstanceChildren extends Children.Keys { 87 ServerInstance serverInstance; 88 public InstanceChildren(ServerInstance inst) { 89 this.serverInstance = inst; 90 } 91 protected void addNotify() { 92 setKeys(serverInstance.getTargets()); 93 } 94 protected void removeNotify() { 95 setKeys(java.util.Collections.EMPTY_SET); 96 } 97 protected org.openide.nodes.Node[] createNodes(Object obj) { 98 ServerTarget child = (ServerTarget) obj; 99 return new Node[] { serverInstance.getServer(). 101 getNodeProvider().createTargetNode(child) }; 102 } 103 } 104 105 } 106 | Popular Tags |