1 19 package org.netbeans.modules.j2ee.sun.bridge.apis; 20 21 import java.util.logging.Level ; 22 23 import javax.swing.Action ; 24 import org.netbeans.modules.j2ee.sun.util.ContainerChildFactory; 25 import org.openide.nodes.AbstractNode; 26 import org.openide.nodes.Children; 27 import org.openide.nodes.Node; 28 import org.openide.util.RequestProcessor; 29 import org.openide.util.actions.SystemAction; 30 import org.openide.util.NbBundle; 31 32 37 public class AppserverMgmtContainerNode extends AppserverMgmtNode implements RefreshCookie { 38 39 public static final class WaitNode extends AbstractNode { 40 public WaitNode() { 41 super(Children.LEAF); 42 setIconBase("org/netbeans/modules/java/navigation/resources/wait"); setDisplayName(NbBundle.getMessage(AppserverMgmtContainerNode.class,"WAITNODE")); setName(getClass().getName()); 45 } 46 } 48 51 public AppserverMgmtContainerNode(final AppserverMgmtController controller, final String type) { 52 super(controller, getChildren(controller, type), type); 53 } 54 58 public AppserverMgmtContainerNode(final AppserverMgmtController controller, final Children children, final String nodeType) { 59 super(controller, children, nodeType); 60 61 } 62 63 70 public Action [] getActions(boolean flag) { 71 return new SystemAction[] { 72 SystemAction.get(RefreshAction.class) 73 }; 74 } 75 76 79 static Children getChildren(final AppserverMgmtController controller, final String type){ 80 return new ContainerChildren(controller, type); 81 } 82 83 84 88 public void refresh(){ 89 setChildren(new ContainerChildren(getAppserverMgmtController(), getNodeType())); 90 ContainerChildren ch = (ContainerChildren)getChildren(); 91 ch.updateKeys(); 92 } 93 94 95 99 public static class ContainerChildren extends Children.Keys { 100 String type; 101 ContainerChildFactory cfactory; 102 public ContainerChildren(AppserverMgmtController controller, String type) { 103 if(controller == null) { 104 getLogger().log(Level.FINE, "Controller for child factory " + 105 "is null"); 106 getLogger().log(Level.FINE, "Type: " + type); 107 } 108 this.type = type; 109 this.cfactory = new ContainerChildFactory(controller); 110 } 111 protected void addNotify() { 112 113 Node n[]= new Node[1]; 114 n[0]=new WaitNode(); 115 setKeys(n); 116 RequestProcessor.getDefault().post(new Runnable () { 117 public void run() { 118 try { 119 setKeys(cfactory.getChildrenObject(type)); 120 } catch (RuntimeException e) { 121 getLogger().log(Level.FINE, e.getMessage(), e); 122 } 123 } 124 }); 125 126 } 127 protected void removeNotify() { 128 setKeys(java.util.Collections.EMPTY_SET); 129 } 130 public void updateKeys() { 131 refresh(); 132 } 133 protected org.openide.nodes.Node[] createNodes(Object obj) { 134 try { 135 return new Node[] { (Node)obj }; 136 } catch(RuntimeException rex) { 137 getLogger().log(Level.FINE, rex.getMessage(), rex); 138 return new Node[] {}; 139 } catch(Exception e) { 140 getLogger().log(Level.FINE, e.getMessage(), e); 141 return new Node[] {}; 142 } 143 } 144 } 145 } 146 | Popular Tags |