View | Details | Raw Unified | Return to bug 57561
Collapse All | Expand All

(-)bin/jmeter.properties (+9 lines)
Lines 1074-1079 Link Here
1074
# Size of compiled scripts cache
1074
# Size of compiled scripts cache
1075
#jsr223.compiled_scripts_cache_size=100
1075
#jsr223.compiled_scripts_cache_size=100
1076
1076
1077
#module controller configuration 
1078
#true - allows to change automatically module controller`s name to target element`s name
1079
#false (by default) - autochange disabled
1080
#module_controller.name_autochange.defaultEnabled=true
1081
1082
#allows to configure default prefix used in name autochange functionality
1083
#module_controller.name_autochange.defaultPrefix=<custom prefix>
1084
#module_controller.name_autochange.defaultPrefix=[MC]
1085
1077
#---------------------------------------------------------------------------
1086
#---------------------------------------------------------------------------
1078
# Classpath configuration
1087
# Classpath configuration
1079
#---------------------------------------------------------------------------
1088
#---------------------------------------------------------------------------
(-)src/components/org/apache/jmeter/control/ModuleController.java (+25 lines)
Lines 30-35 Link Here
30
import org.apache.jmeter.testelement.property.CollectionProperty;
30
import org.apache.jmeter.testelement.property.CollectionProperty;
31
import org.apache.jmeter.testelement.property.JMeterProperty;
31
import org.apache.jmeter.testelement.property.JMeterProperty;
32
import org.apache.jmeter.testelement.property.NullProperty;
32
import org.apache.jmeter.testelement.property.NullProperty;
33
import org.apache.jmeter.util.JMeterUtils;
33
import org.apache.jorphan.collections.HashTree;
34
import org.apache.jorphan.collections.HashTree;
34
import org.apache.jorphan.collections.ListedHashTree;
35
import org.apache.jorphan.collections.ListedHashTree;
35
36
Lines 51-56 Link Here
51
    private static final long serialVersionUID = 240L;
52
    private static final long serialVersionUID = 240L;
52
53
53
    private static final String NODE_PATH = "ModuleController.node_path";// $NON-NLS-1$
54
    private static final String NODE_PATH = "ModuleController.node_path";// $NON-NLS-1$
55
    
56
    private static final String NAME_AUTOCHANGE = "ModuleController.name_autochange";// $NON-NLS-1$
57
    
58
    private static final String NAME_PREFIX = "ModuleController.name_prefix";// $NON-NLS-1$
54
59
55
    private transient JMeterTreeNode selectedNode = null;
60
    private transient JMeterTreeNode selectedNode = null;
56
61
Lines 61-66 Link Here
61
     */
66
     */
62
    public ModuleController() {
67
    public ModuleController() {
63
        super();
68
        super();
69
        this.setNameAutochangeEnabled(
70
        		JMeterUtils.getPropDefault("module_controller.name_autochange.defaultEnabled", false));
71
        this.setNamePrefix(
72
        		JMeterUtils.getPropDefault("module_controller.name_autochange.defaultPrefix", ""));
64
    }
73
    }
65
74
66
    @Override
75
    @Override
Lines 203-206 Link Here
203
            cloneChildren((JMeterTreeNode) to.getLastChild(), child);
212
            cloneChildren((JMeterTreeNode) to.getLastChild(), child);
204
        }
213
        }
205
    }
214
    }
215
216
	public boolean isNameAutochangeEnabled() {
217
		return getPropertyAsBoolean(NAME_AUTOCHANGE);
218
	}
219
220
	public void setNameAutochangeEnabled(boolean enableNameAutochange) {
221
		setProperty(NAME_AUTOCHANGE, enableNameAutochange);
222
	}
223
224
	public String getNamePrefix() {
225
		return getPropertyAsString(NAME_PREFIX);
226
	}
227
228
	public void setNamePrefix(String namePrefix) {
229
		setProperty(NAME_PREFIX, namePrefix);
230
	}    
206
}
231
}
(-)src/components/org/apache/jmeter/control/gui/ModuleControllerGui.java (-10 / +84 lines)
Lines 23-39 Link Here
23
import java.awt.FlowLayout;
23
import java.awt.FlowLayout;
24
import java.awt.event.ActionEvent;
24
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionListener;
25
import java.awt.event.ActionListener;
26
import java.awt.event.MouseAdapter;
27
import java.awt.event.MouseEvent;
26
import java.util.Collection;
28
import java.util.Collection;
27
import java.util.Iterator;
29
import java.util.Iterator;
28
30
31
import javax.swing.BorderFactory;
29
import javax.swing.Box;
32
import javax.swing.Box;
30
import javax.swing.BoxLayout;
33
import javax.swing.BoxLayout;
31
import javax.swing.ImageIcon;
34
import javax.swing.ImageIcon;
32
import javax.swing.JButton;
35
import javax.swing.JButton;
36
import javax.swing.JCheckBox;
33
import javax.swing.JLabel;
37
import javax.swing.JLabel;
34
import javax.swing.JMenu;
38
import javax.swing.JMenu;
35
import javax.swing.JPanel;
39
import javax.swing.JPanel;
36
import javax.swing.JPopupMenu;
40
import javax.swing.JPopupMenu;
41
import javax.swing.JTextField;
37
import javax.swing.JTree;
42
import javax.swing.JTree;
38
import javax.swing.tree.DefaultMutableTreeNode;
43
import javax.swing.tree.DefaultMutableTreeNode;
39
import javax.swing.tree.DefaultTreeCellRenderer;
44
import javax.swing.tree.DefaultTreeCellRenderer;
Lines 47-53 Link Here
47
import org.apache.jmeter.gui.GuiPackage;
52
import org.apache.jmeter.gui.GuiPackage;
48
import org.apache.jmeter.gui.action.ActionNames;
53
import org.apache.jmeter.gui.action.ActionNames;
49
import org.apache.jmeter.gui.tree.JMeterTreeNode;
54
import org.apache.jmeter.gui.tree.JMeterTreeNode;
55
import org.apache.jmeter.gui.util.HorizontalPanel;
50
import org.apache.jmeter.gui.util.MenuFactory;
56
import org.apache.jmeter.gui.util.MenuFactory;
57
import org.apache.jmeter.gui.util.VerticalPanel;
51
import org.apache.jmeter.testelement.TestElement;
58
import org.apache.jmeter.testelement.TestElement;
52
import org.apache.jmeter.testelement.TestPlan;
59
import org.apache.jmeter.testelement.TestPlan;
53
import org.apache.jmeter.threads.AbstractThreadGroup;
60
import org.apache.jmeter.threads.AbstractThreadGroup;
Lines 98-103 Link Here
98
     * Helps navigating test plan
105
     * Helps navigating test plan
99
     */
106
     */
100
    private JButton expandButton;
107
    private JButton expandButton;
108
    
109
    /**
110
     * allows to change automatically module controller`s name to target element`s name
111
     */
112
    private JCheckBox nameAutochangeEnabled;
113
    
114
    /**
115
     * provides prefix for name field in case of using name autochange 
116
     */
117
    private JTextField nameAutochangePrefix;
101
118
102
    /**
119
    /**
103
     * Initializes the gui panel for the ModuleController instance.
120
     * Initializes the gui panel for the ModuleController instance.
Lines 105-115 Link Here
105
    public ModuleControllerGui() {
122
    public ModuleControllerGui() {
106
		moduleToRunTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
123
		moduleToRunTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
107
		moduleToRunTreeNodes = new JTree(moduleToRunTreeModel);
124
		moduleToRunTreeNodes = new JTree(moduleToRunTreeModel);
125
	
126
		//test element name replacer (called after selecting module to run in module controller tree)
127
		MouseAdapter ml = new MouseAdapter() {
128
			public void mouseClicked(MouseEvent e) {
129
				if(!nameAutochangeEnabled.isSelected()){
130
					return;
131
				}
132
				TreePath selPath = moduleToRunTreeNodes.getPathForLocation(e.getX(),
133
						e.getY());
134
				if (selPath != null) {
135
					Object[] nodesOnPath = selPath.getPath();
136
					//do not allow to reference test plan
137
					if (nodesOnPath.length > 1) {						
138
						JMeterTreeNode tn = (JMeterTreeNode) ((DefaultMutableTreeNode)selPath.getLastPathComponent()).getUserObject();
139
						//prevent also changing name if thread group is selected
140
						if(!(tn.getTestElement() instanceof AbstractThreadGroup)){
141
							setElementName(nameAutochangePrefix.getText() + tn.getName());
142
						}
143
					}
144
				}
145
			}
146
		};
147
		moduleToRunTreeNodes.addMouseListener(ml);		
108
		moduleToRunTreeNodes.setCellRenderer(new ModuleControllerCellRenderer());
148
		moduleToRunTreeNodes.setCellRenderer(new ModuleControllerCellRenderer());
109
		
149
		
110
        warningLabel = new JLabel(""); // $NON-NLS-1$
150
        warningLabel = new JLabel(""); // $NON-NLS-1$
111
        init();
151
        init();
112
    }
152
    }
153
	
154
	private void setElementName(String name)
155
	{
156
		this.namePanel.setName(name);
157
	}
113
158
114
    /** {@inheritDoc}} */
159
    /** {@inheritDoc}} */
115
    @Override
160
    @Override
Lines 120-132 Link Here
120
    @Override
165
    @Override
121
    public void configure(TestElement el) {
166
    public void configure(TestElement el) {
122
        super.configure(el);
167
        super.configure(el);
123
        ModuleController controller = (ModuleController) el;
168
        if(el instanceof ModuleController){
124
        this.selected = controller.getSelectedNode();
169
	        ModuleController controller = (ModuleController) el;
125
        if (selected == null && controller.getNodePath() != null) {
170
	        this.selected = controller.getSelectedNode();
126
            warningLabel.setText(JMeterUtils.getResString("module_controller_warning") // $NON-NLS-1$
171
	        if (selected == null && controller.getNodePath() != null) {
127
                    + renderPath(controller.getNodePath()));
172
	            warningLabel.setText(JMeterUtils.getResString("module_controller_warning") // $NON-NLS-1$
128
        } else {
173
	                    + renderPath(controller.getNodePath()));
129
            warningLabel.setText(""); // $NON-NLS-1$
174
	        } else {
175
	            warningLabel.setText(""); // $NON-NLS-1$
176
	        }
177
	        nameAutochangeEnabled.setSelected(controller.isNameAutochangeEnabled());
178
	        nameAutochangePrefix.setText(controller.getNamePrefix());
130
        }
179
        }
131
        reinitialize();
180
        reinitialize();
132
    }
181
    }
Lines 178-183 Link Here
178
                ((ModuleController) element).setSelectedNode(selected);
227
                ((ModuleController) element).setSelectedNode(selected);
179
            }
228
            }
180
        }
229
        }
230
        if(element instanceof ModuleController){
231
        	ModuleController mc = (ModuleController) element;
232
        	mc.setNameAutochangeEnabled(nameAutochangeEnabled.isSelected());
233
        	mc.setNamePrefix(nameAutochangePrefix.getText());
234
        }
181
    }
235
    }
182
236
183
    /** {@inheritDoc}} */
237
    /** {@inheritDoc}} */
Lines 206-219 Link Here
206
        MenuFactory.addFileMenu(menu);
260
        MenuFactory.addFileMenu(menu);
207
        return menu;
261
        return menu;
208
    }
262
    }
209
263
    
264
    
210
    private void init() {
265
    private void init() {
211
        setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
266
        setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
212
        setBorder(makeBorder());
267
        setBorder(makeBorder());
213
        add(makeTitlePanel());
268
        add(makeTitlePanel());
269
        add(getNameAutochangePanel());
214
270
215
        JPanel modulesPanel = new JPanel();
271
        JPanel modulesPanel = new JPanel();        
216
        
217
        expandButton = new JButton(JMeterUtils.getResString("expand")); //$NON-NLS-1$
272
        expandButton = new JButton(JMeterUtils.getResString("expand")); //$NON-NLS-1$
218
        expandButton.addActionListener(this);
273
        expandButton.addActionListener(this);
219
        modulesPanel.add(expandButton);
274
        modulesPanel.add(expandButton);
Lines 231-236 Link Here
231
        add(treePanel);
286
        add(treePanel);
232
    }
287
    }
233
288
289
	private VerticalPanel getNameAutochangePanel() {
290
		VerticalPanel nameAutochangePanel = new VerticalPanel();
291
        nameAutochangeEnabled = new JCheckBox(
292
        		JMeterUtils.getResString("module_controller_name_autochange_enabled"));
293
        nameAutochangeEnabled.setSelected(
294
        		JMeterUtils.getPropDefault("module_controller.name_autochange.defaultEnabled", false));
295
        nameAutochangePanel.add(nameAutochangeEnabled);
296
        
297
        HorizontalPanel hp = new HorizontalPanel();
298
        hp.add(new JLabel(JMeterUtils.getResString("module_controller_name_autochange_prefix")));
299
        nameAutochangePrefix = new JTextField(
300
        		JMeterUtils.getPropDefault("module_controller.name_autochange.defaultPrefix", ""));
301
        hp.add(nameAutochangePrefix);
302
        
303
        nameAutochangePanel.add(hp);
304
        nameAutochangePanel.setBorder(BorderFactory.createEtchedBorder());
305
		return nameAutochangePanel;
306
	}
307
234
    /**
308
    /**
235
     * Recursively traverse module to run tree in order to find JMeterTreeNode element given by testPlanPath
309
     * Recursively traverse module to run tree in order to find JMeterTreeNode element given by testPlanPath
236
     * in a DefaultMutableTreeNode tree
310
     * in a DefaultMutableTreeNode tree
(-)src/core/org/apache/jmeter/resources/messages.properties (+2 lines)
Lines 661-666 Link Here
661
module_controller_module_to_run=Module To Run 
661
module_controller_module_to_run=Module To Run 
662
module_controller_title=Module Controller
662
module_controller_title=Module Controller
663
module_controller_warning=Could not find module: 
663
module_controller_warning=Could not find module: 
664
module_controller_name_autochange_enabled=Enable name autochange
665
module_controller_name_autochange_prefix=Prefix:
664
monitor_equation_active=Active:  (busy/max) > 25%
666
monitor_equation_active=Active:  (busy/max) > 25%
665
monitor_equation_dead=Dead:  no response
667
monitor_equation_dead=Dead:  no response
666
monitor_equation_healthy=Healthy:  (busy/max) < 25%
668
monitor_equation_healthy=Healthy:  (busy/max) < 25%

Return to bug 57561