1 19 20 package org.apache.jmeter.module.nodes; 21 22 import java.util.ArrayList ; 23 import java.util.Collection ; 24 import javax.swing.Action ; 25 import org.apache.jmeter.module.actions.ProcessesCleanupAction; 26 import org.apache.jmeter.module.integration.JMeterIntegrationEngine; 27 import org.apache.jmeter.module.loadgenerator.spi.impl.ProcessDescriptor; 28 import org.openide.nodes.AbstractNode; 29 import org.openide.nodes.Children; 30 import org.openide.nodes.Node; 31 import org.openide.util.Lookup; 32 33 37 public class RuntimeNode extends AbstractNode { 38 private static class RuntimeChildren extends Children.Array { 39 public Node findChild(String string) { 40 Node retValue; 41 42 retValue = super.findChild(string); 43 return retValue; 44 } 45 46 public Node[] getNodes(boolean b) { 47 if (b) { 48 Node[] nodes = super.getNodes(b); 49 remove(nodes); 50 processNodes(); 51 } 52 return super.getNodes(b); 53 } 54 55 private void processNodes() { 56 Collection <Node> nodes = new ArrayList <Node>(); 57 try { 58 for(ProcessDescriptor process : JMeterIntegrationEngine.getDefault().getProcesses() ) { 59 final String processName = process.getScriptPath(); 60 final String displayName = process.getDisplayName(); 61 final boolean running = process.isRunning(); 62 63 nodes.add(new ProcessNode(process) { 64 public String getDisplayName() { 65 return displayName + " " + (running ? "(running)" : "(finished)"); 66 } 67 68 public String getName() { 69 return processName; 70 } 71 }); 72 } 73 } catch (Exception e) { 74 e.printStackTrace(); 75 } 76 add(nodes.toArray(new Node[]{})); 77 } 78 } 79 80 public RuntimeNode(Children children) { 81 super(children); 82 setName("Load Generator"); 83 } 84 85 public RuntimeNode(Children children, Lookup lookup) { 86 super(children, lookup); 87 setName("Load Generator"); 88 } 89 90 public static RuntimeNode getInstance() { 91 Children chldrn = new RuntimeChildren(); 92 return new RuntimeNode(chldrn); 100 } 101 102 public Action [] getActions(boolean b) { 103 return new Action []{ProcessesCleanupAction.findObject(ProcessesCleanupAction.class, true)}; 104 } 105 } 106 | Popular Tags |