1 18 19 package org.apache.jmeter.gui.action; 20 21 import java.awt.event.ActionEvent ; 22 import java.util.HashSet ; 23 import java.util.Set ; 24 25 import org.apache.jmeter.gui.GuiPackage; 26 import org.apache.jmeter.gui.tree.JMeterTreeNode; 27 import org.apache.jorphan.logging.LoggingManager; 28 import org.apache.log.Logger; 29 30 33 public class EnableComponent implements Command 34 { 35 private static Logger log = LoggingManager.getLoggerForClass(); 36 37 public static final String ENABLE = "enable"; 38 public static final String DISABLE = "disable"; 39 40 private static Set commands = new HashSet (); 41 static 42 { 43 commands.add(ENABLE); 44 commands.add(DISABLE); 45 } 46 47 50 public void doAction(ActionEvent e) 51 { 52 JMeterTreeNode[] nodes = 53 GuiPackage.getInstance().getTreeListener().getSelectedNodes(); 54 55 if (e.getActionCommand().equals(ENABLE)) 56 { 57 log.debug("enabling currently selected gui objects"); 58 enableComponents(nodes,true); 59 } 60 else if (e.getActionCommand().equals(DISABLE)) 61 { 62 log.debug("disabling currently selected gui objects"); 63 enableComponents(nodes,false); 64 } 65 } 66 67 private void enableComponents(JMeterTreeNode[] nodes, boolean enable) 68 { 69 GuiPackage pack = GuiPackage.getInstance(); 70 for(int i=0;i<nodes.length;i++) 71 { 72 nodes[i].setEnabled(enable); 73 pack.getGui(nodes[i].getTestElement()).setEnabled(enable); 74 } 75 } 76 77 80 public Set getActionNames() 81 { 82 return commands; 83 } 84 } 85 | Popular Tags |