1 19 20 package org.apache.jmeter.module.nodes; 21 22 import java.awt.Component ; 23 import java.awt.Image ; 24 import java.beans.PropertyChangeEvent ; 25 import java.beans.PropertyChangeListener ; 26 import java.util.ArrayList ; 27 import java.util.Arrays ; 28 import java.util.List ; 29 import javax.swing.Action ; 30 import org.apache.jmeter.gui.JMeterGUIComponent; 31 import org.apache.jmeter.module.cookies.JMeterCookie; 32 import org.apache.jmeter.module.cookies.JMeterVisualizerCookie; 33 import org.apache.jmeter.module.exceptions.InitializationException; 34 import org.apache.jmeter.module.integration.JMeterIntegrationEngine; 35 import org.apache.jmeter.reporters.ResultCollector; 36 import org.apache.jmeter.testelement.TestElement; 37 import org.apache.jorphan.collections.HashTree; 38 import org.openide.nodes.AbstractNode; 39 import org.openide.util.actions.SystemAction; 40 41 45 public class JMeterElementNode extends AbstractNode { 46 private List <TestElement> elements; 47 private TestElement rootElement; 48 private String testPlan; 49 private JMeterIntegrationEngine integration; 50 51 private Component customizer; 52 53 public JMeterElementNode(final TestElement root, final HashTree tree) { 54 super(new JMeterElementChildren(tree)); 55 try { 56 integration = JMeterIntegrationEngine.getDefault(); 57 rootElement = root; 58 } catch (InitializationException e) { 59 integration = null; 60 rootElement = null; 61 } 62 getCookieSet().add(new JMeterCookie(root)); 63 if (root instanceof ResultCollector) { 64 getCookieSet().add(new JMeterVisualizerCookie(root)); 65 } 66 } 67 68 public String getName() { 69 return rootElement != null ? rootElement.getPropertyAsString(TestElement.NAME) : "..."; 70 } 71 72 public String getDisplayName() { 73 return getName(); 74 } 75 76 public Component getCustomizer() { 77 customizer.addPropertyChangeListener("ancestor", new PropertyChangeListener () { 78 public void propertyChange(PropertyChangeEvent evt) { 79 if (evt.getNewValue() == null) { 80 final String oldName = rootElement.getPropertyAsString(TestElement.NAME); 81 ((JMeterGUIComponent)customizer).modifyTestElement(rootElement); 82 fireDisplayNameChange(oldName, rootElement.getPropertyAsString(TestElement.NAME)); 83 customizer.removePropertyChangeListener("ancestor", this); 84 } 85 } 86 }); 87 ((JMeterGUIComponent)customizer).configure(rootElement); 88 return customizer; 89 } 90 91 public boolean hasCustomizer() { 92 customizer = integration.getElementCustomizer(rootElement); 93 if (customizer == null) { 94 customizer = super.getCustomizer(); 95 } 96 97 return customizer != null; 98 } 99 100 public Image getOpenedIcon(int i) { 101 return integration.getElementIcon(rootElement); 102 } 103 104 public Image getIcon(int i) { 105 return integration.getElementIcon(rootElement); 106 } 107 } 108 | Popular Tags |