1 19 20 24 25 package org.netbeans.modules.j2ee.sun.ws7.nodes; 26 27 import javax.enterprise.deploy.spi.DeploymentManager ; 28 import javax.enterprise.deploy.spi.Target ; 29 import javax.enterprise.deploy.spi.TargetModuleID ; 30 31 import javax.enterprise.deploy.shared.ModuleType ; 32 33 import org.openide.util.Lookup; 34 import org.openide.nodes.AbstractNode; 35 import org.openide.nodes.Node; 36 import org.openide.nodes.Children; 37 import org.openide.util.NbBundle; 38 import org.openide.util.RequestProcessor; 39 40 import java.util.TreeSet ; 41 42 43 47 public class WS70WebModulesChildren extends Children.Keys{ 48 private static final String WAIT_NODE = "wait_node"; private Lookup lookup; 50 51 public WS70WebModulesChildren(Lookup lookup) { 52 this.lookup = lookup; 53 } 54 55 protected Node[] createNodes(Object key){ 56 if (key instanceof WS70WebModule){ 57 WS70WebModule module = (WS70WebModule)key; 58 WS70WebModuleNode node = new WS70WebModuleNode(module); 59 return new Node[]{node}; 60 } 61 if (key instanceof String && key.equals(WAIT_NODE)){ 62 return new Node[]{createWaitNode ()}; 63 } 64 return null; 65 } 66 67 public void updateKeys(){ 68 Target target = (Target )lookup.lookup(Target .class); 69 DeploymentManager dm = (DeploymentManager )lookup.lookup(DeploymentManager .class); 70 TreeSet ts = new TreeSet (); 71 ts.add(WAIT_NODE); 72 setKeys(ts); 73 RequestProcessor.getDefault().post(new Runnable () { 74 public void run () { 75 DeploymentManager manager = (DeploymentManager )lookup.lookup(DeploymentManager .class); 76 Target target = (Target )lookup.lookup(Target .class); 77 TreeSet list = new TreeSet (new WS70WmComparator()); 78 if (target != null){ 79 80 try{ 81 TargetModuleID [] modules = manager.getAvailableModules(ModuleType.WAR, new Target []{target}); 82 for (int i = 0; i < modules.length; i ++){ 83 list.add(new WS70WebModule(manager, modules[i])); 84 } 85 } 86 87 catch (Exception e) { 88 e.printStackTrace(); 89 } 90 } 91 setKeys(list); 92 93 } 94 }, 0); 95 } 96 97 protected void addNotify() { 98 updateKeys(); 99 } 100 101 protected void removeNotify() { 102 setKeys(java.util.Collections.EMPTY_SET); 103 } 104 private Node createWaitNode () { 105 AbstractNode n = new AbstractNode(Children.LEAF); 106 n.setName(NbBundle.getMessage(WS70WebModulesChildren.class, "LBL_WaitNode_DisplayName")); n.setIconBaseWithExtension("org/openide/src/resources/wait.gif"); return n; 109 } 110 public static class WS70WmComparator implements java.util.Comparator { 111 112 public int compare(Object o1, Object o2) { 113 WS70WebModule wm1 = (WS70WebModule) o1; 114 WS70WebModule wm2 = (WS70WebModule) o2; 115 return wm1.getName().compareTo(wm2.getName()); 116 } 117 118 } 119 120 } 121 122 | Popular Tags |