1 19 20 package org.netbeans.modules.j2ee.oc4j.nodes; 21 22 import java.util.Vector ; 23 import javax.enterprise.deploy.shared.ModuleType ; 24 import javax.enterprise.deploy.spi.TargetModuleID ; 25 import org.netbeans.modules.j2ee.oc4j.OC4JDeploymentManager; 26 import org.netbeans.modules.j2ee.oc4j.nodes.actions.Refreshable; 27 import org.netbeans.modules.j2ee.oc4j.util.OC4JPluginUtils; 28 import org.openide.ErrorManager; 29 import org.openide.nodes.Children; 30 import org.openide.nodes.Node; 31 import org.openide.util.Lookup; 32 import org.openide.util.RequestProcessor; 33 34 39 public class OC4JJ2EEApplicationsChildren extends Children.Keys implements Refreshable { 40 41 private Lookup lookup; 42 private final static Node WAIT_NODE = OC4JItemNode.createWaitNode(); 43 44 OC4JJ2EEApplicationsChildren(Lookup lookup) { 45 this.lookup = lookup; 46 } 47 48 public void updateKeys(){ 49 setKeys(new Object [] {WAIT_NODE}); 50 51 RequestProcessor.getDefault().post(new Runnable () { 52 Vector keys = new Vector (); 53 OC4JDeploymentManager dm = lookup.lookup(OC4JDeploymentManager.class); 54 55 public void run() { 56 57 try { 58 for(TargetModuleID id:dm.getRunningModules(ModuleType.EAR, dm.getTargets())) { 59 String name = OC4JPluginUtils.getName(id); 60 if(name.contains("system") || name.contains("default") || 61 name.contains("ascontrol")) { 62 keys.add(new OC4JItemNode(lookup, id, OC4JItemNode.ItemType.J2EE_APPLICATION_SYSTEM)); 63 } else { 64 keys.add(new OC4JItemNode(lookup, id, OC4JItemNode.ItemType.J2EE_APPLICATION)); 65 } 66 } 67 } catch (Exception ex) { 68 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 69 } 70 71 setKeys(keys); 72 } 73 }, 0); 74 } 75 76 protected void addNotify() { 77 updateKeys(); 78 } 79 80 protected void removeNotify() { 81 setKeys(java.util.Collections.EMPTY_SET); 82 } 83 84 protected org.openide.nodes.Node[] createNodes(Object key) { 85 if (key instanceof OC4JItemNode){ 86 return new Node[]{(OC4JItemNode)key}; 87 } 88 89 if (key instanceof String && key.equals(WAIT_NODE)){ 90 return new Node[]{WAIT_NODE}; 91 } 92 93 return null; 94 } 95 } | Popular Tags |