ReportGuiPackage getInstance(ReportTreeListener listener, ReportTreeModel treeModel) { if (guiPack == null) { guiPack = new ReportGuiPackage(); guiPack.setTreeListener(listener); guiPack.setTreeModel(treeModel); } return guiPack; } /** * Get a JMeterGUIComponent for the specified test element. If the GUI has * already been created, that instance will be returned. Otherwise, if a GUI * component of the same type has been created, and the component is not * marked as an {@link UnsharedComponent}, that shared component will be * returned. Otherwise, a new instance of the component will be created. The * TestElement's GUI_CLASS property will be used to determine the * appropriate type of GUI component to use. * * @param node * the test element which this GUI is being created for * * @return the GUI component corresponding to the specified test element */ public JMeterGUIComponent getGui(TestElement node) { String testClassName = node.getPropertyAsString(TestElement.TEST_CLASS); String guiClassName = node.getPropertyAsString(TestElement.GUI_CLASS); try { Class testClass; if (testClassName.equals("")) { testClass = node.getClass(); } else { testClass = Class.forName(testClassName); } Class guiClass = null; if (!guiClassName.equals("")) { guiClass = Class.forName(guiClassName); } return getGui(node, guiClass, testClass); } catch (ClassNotFoundException e) { log.error("Could not get GUI for " + node, e); return null; } } /** * Get a JMeterGUIComponent for the specified test element. If the GUI has * already been created, that instance will be returned. Otherwise, if a GUI * component of the same type has been created, and the component is not * marked as an {@link UnsharedComponent}, that shared component will be * returned. Otherwise, a new instance of the component will be created. * * @param node * the test element which this GUI is being created for * @param guiClass * the fully qualifed class name of the GUI component which will * be created if it doesn't already exist * @param testClass * the fully qualifed class name of the test elements which have * to be edited by the returned GUI component * * @return the GUI component corresponding to the specified test element */ public JMeterGUIComponent getGui(TestElement node, Class guiClass, Class testClass) { try { JMeterGUIComponent comp = (JMeterGUIComponent) nodesToGui.get(node); if (comp == null) { comp = getGuiFromCache(guiClass, testClass); nodesToGui.put(node, comp); } log.debug("Gui retrieved = " + comp); return comp; } catch (Exception e) { log.error("Problem retrieving gui", e); return null; } } /** * Remove a test element from the tree. This removes the reference to any * associated GUI component. * * @param node * the test element being removed */ public void removeNode(TestElement node) { nodesToGui.remove(node); } /** * Convenience method for grabbing the gui for the current node. * * @return the GUI component associated with the currently selected node */ public JMeterGUIComponent getCurrentGui() { try { updateCurrentNode(); TestElement curNode = treeListener.getCurrentNode().getTestElement(); JMeterGUIComponent comp = getGui(curNode); comp.clearGui(); log.debug("Updating gui to new node"); comp.configure(curNode); currentNodeUpdated = false; return comp; } catch (Exception e) { log.error("Problem retrieving gui", e); return null; } } /** * Find the JMeterTreeNode for a certain TestElement object. * * @param userObject * the test element to search for * @return the tree node associated with the test element */ public ReportTreeNode getNodeOf(TestElement userObject) { return treeModel.getNodeOf(userObject); } /** * Create a TestElement corresponding to the specified GUI class. * * @param guiClass * the fully qualified class name of the GUI component or a * TestBean class for TestBeanGUIs. * @param testClass * the fully qualified class name of the test elements edited by * this GUI component. * @return the test element corresponding to the specified GUI class. */ public TestElement createTestElement(Class guiClass, Class testClass) { try { JMeterGUIComponent comp = getGuiFromCache(guiClass, testClass); comp.clearGui(); TestElement node = comp.createTestElement(); nodesToGui.put(node, comp); return node; } catch (Exception e) { log.error("Problem retrieving gui", e); return null; } } /** * Create a TestElement for a GUI or TestBean class. * <p> * This is a utility method to help actions do with one single String * parameter. * * @param objClass * the fully qualified class name of the GUI component or of the * TestBean subclass for which a TestBeanGUI is wanted. * @return the test element corresponding to the specified GUI class. */ public TestElement createTestElement(String objClass) { JMeterGUIComponent comp; Class c; try { c = Class.forName(objClass); if (TestBean.class.isAssignableFrom(c)) { comp = getGuiFromCache(TestBeanGUI.class, c); } else { comp = getGuiFromCache(c, null); } comp.clearGui(); TestElement node = comp.createTestElement(); nodesToGui.put(node, comp); return node; } catch (NoClassDefFoundError e
GuiPackage getInstance(JMeterTreeListener listener, JMeterTreeModel treeModel) { if (guiPack == null) { guiPack = new GuiPackage(); guiPack.setTreeListener(listener); guiPack.setTreeModel(treeModel); } return guiPack; } /** * Get a JMeterGUIComponent for the specified test element. If the GUI has * already been created, that instance will be returned. Otherwise, if a GUI * component of the same type has been created, and the component is not * marked as an {@link UnsharedComponent}, that shared component will be * returned. Otherwise, a new instance of the component will be created. The * TestElement's GUI_CLASS property will be used to determine the * appropriate type of GUI component to use. * * @param node * the test element which this GUI is being created for * * @return the GUI component corresponding to the specified test element */ public JMeterGUIComponent getGui(TestElement node) { String testClassName = node.getPropertyAsString(TestElement.TEST_CLASS); String guiClassName = node.getPropertyAsString(TestElement.GUI_CLASS); try { Class testClass; if (testClassName.equals("")) { // $NON-NLS-1$ testClass = node.getClass(); } else { testClass = Class.forName(testClassName); } Class guiClass = null; if (!guiClassName.equals("")) { // $NON-NLS-1$ guiClass = Class.forName(guiClassName); } return getGui(node, guiClass, testClass); } catch (ClassNotFoundException e) { log.error("Could not get GUI for " + node, e); return null; } } /** * Get a JMeterGUIComponent for the specified test element. If the GUI has * already been created, that instance will be returned. Otherwise, if a GUI * component of the same type has been created, and the component is not * marked as an {@link UnsharedComponent}, that shared component will be * returned. Otherwise, a new instance of the component will be created. * * @param node * the test element which this GUI is being created for * @param guiClass * the fully qualifed class name of the GUI component which will * be created if it doesn't already exist * @param testClass * the fully qualifed class name of the test elements which have * to be edited by the returned GUI component * * @return the GUI component corresponding to the specified test element */ public JMeterGUIComponent getGui(TestElement node, Class guiClass, Class testClass) { try { JMeterGUIComponent comp = (JMeterGUIComponent) nodesToGui.get(node); if (comp == null) { comp = getGuiFromCache(guiClass, testClass); nodesToGui.put(node, comp); } log.debug("Gui retrieved = " + comp); return comp; } catch (Exception e) { log.error("Problem retrieving gui", e); return null; } } /** * Remove a test element from the tree. This removes the reference to any * associated GUI component. * * @param node * the test element being removed */ public void removeNode(TestElement node) { nodesToGui.remove(node); } /** * Convenience method for grabbing the gui for the current node. * * @return the GUI component associated with the currently selected node */ public JMeterGUIComponent getCurrentGui() { try { updateCurrentNode(); TestElement curNode = treeListener.getCurrentNode().getTestElement(); JMeterGUIComponent comp = getGui(curNode); comp.clearGui(); log.debug("Updating gui to new node"); comp.configure(curNode); currentNodeUpdated = false; return comp; } catch (Exception e) { log.error("Problem retrieving gui", e); return null; } } /** * Find the JMeterTreeNode for a certain TestElement object. * * @param userObject * the test element to search for * @return the tree node associated with the test element */ public JMeterTreeNode getNodeOf(TestElement userObject) { return treeModel.getNodeOf(userObject); } /** * Create a TestElement corresponding to the specified GUI class. * * @param guiClass * the fully qualified class name of the GUI component or a * TestBean class for TestBeanGUIs. * @param testClass * the fully qualified class name of the test elements edited by * this GUI component. * @return the test element corresponding to the specified GUI class. */ public TestElement createTestElement(Class guiClass, Class testClass) { try { JMeterGUIComponent comp = getGuiFromCache(guiClass, testClass); comp.clearGui(); TestElement node = comp.createTestElement(); nodesToGui.put(node, comp); return node; } catch (Exception e) { log.error("Problem retrieving gui", e); return null; } } /** * Create a TestElement for a GUI or TestBean class. * <p> * This is a utility method to help actions do with one single String * parameter. * * @param objClass * the fully qualified class name of the GUI component or of the * TestBean subclass for which a TestBeanGUI is wanted. * @return the test element corresponding to the specified GUI class. */ public TestElement createTestElement(String objClass) { JMeterGUIComponent comp; Class c; try { c = Class.forName(objClass); if (TestBean.class.isAssignableFrom(c)) { comp = getGuiFromCache(TestBeanGUI.class, c); } else { comp = getGuiFromCache(c, null); } comp.clearGui(); TestElement node = comp.createTestElement(); nodesToGui.put(node, comp); return node; } catch (NoClassDefFoundError e
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/gui/ReportGuiPackage.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/gui/GuiPackage.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
ReportGuiPackage getInstance(ReportTreeListener listener, ReportTreeModel treeModel) {
1
GuiPackage getInstance(JMeterTreeListener listener, JMeterTreeModel treeModel) {
2
		if (guiPack == null) {
2
		if (guiPack == null) {
3
			guiPack = new ReportGuiPackage();
3
			guiPack = new GuiPackage();
4
			guiPack.setTreeListener(listener);
4
			guiPack.setTreeListener(listener);
5
			guiPack.setTreeModel(treeModel);
5
			guiPack.setTreeModel(treeModel);
6
		}
6
		}
7
		return guiPack;
7
		return guiPack;
8
	}
8
	}
9
	/**
9
	/**
10
	 * Get a JMeterGUIComponent for the specified test element. If the GUI has
10
	 * Get a JMeterGUIComponent for the specified test element. If the GUI has
11
	 * already been created, that instance will be returned. Otherwise, if a GUI
11
	 * already been created, that instance will be returned. Otherwise, if a GUI
12
	 * component of the same type has been created, and the component is not
12
	 * component of the same type has been created, and the component is not
13
	 * marked as an {@link UnsharedComponent}, that shared component will be
13
	 * marked as an {@link UnsharedComponent}, that shared component will be
14
	 * returned. Otherwise, a new instance of the component will be created. The
14
	 * returned. Otherwise, a new instance of the component will be created. The
15
	 * TestElement's GUI_CLASS property will be used to determine the
15
	 * TestElement's GUI_CLASS property will be used to determine the
16
	 * appropriate type of GUI component to use.
16
	 * appropriate type of GUI component to use.
17
	 * 
17
	 * 
18
	 * @param node
18
	 * @param node
19
	 *            the test element which this GUI is being created for
19
	 *            the test element which this GUI is being created for
20
	 * 
20
	 * 
21
	 * @return the GUI component corresponding to the specified test element
21
	 * @return the GUI component corresponding to the specified test element
22
	 */
22
	 */
23
	public JMeterGUIComponent getGui(TestElement node) {
23
	public JMeterGUIComponent getGui(TestElement node) {
24
		String testClassName = node.getPropertyAsString(TestElement.TEST_CLASS);
24
		String testClassName = node.getPropertyAsString(TestElement.TEST_CLASS);
25
		String guiClassName = node.getPropertyAsString(TestElement.GUI_CLASS);
25
		String guiClassName = node.getPropertyAsString(TestElement.GUI_CLASS);
26
		try {
26
		try {
27
			Class testClass;
27
			Class testClass;
28
			if (testClassName.equals("")) {
28
			if (testClassName.equals("")) { // $NON-NLS-1$
29
				testClass = node.getClass();
29
				testClass = node.getClass();
30
			} else {
30
			} else {
31
				testClass = Class.forName(testClassName);
31
				testClass = Class.forName(testClassName);
32
			}
32
			}
33
			Class guiClass = null;
33
			Class guiClass = null;
34
			if (!guiClassName.equals("")) {
34
			if (!guiClassName.equals("")) { // $NON-NLS-1$
35
				guiClass = Class.forName(guiClassName);
35
				guiClass = Class.forName(guiClassName);
36
			}
36
			}
37
			return getGui(node, guiClass, testClass);
37
			return getGui(node, guiClass, testClass);
38
		} catch (ClassNotFoundException e) {
38
		} catch (ClassNotFoundException e) {
39
			log.error("Could not get GUI for " + node, e);
39
			log.error("Could not get GUI for " + node, e);
40
			return null;
40
			return null;
41
		}
41
		}
42
	}
42
	}
43
	/**
43
	/**
44
	 * Get a JMeterGUIComponent for the specified test element. If the GUI has
44
	 * Get a JMeterGUIComponent for the specified test element. If the GUI has
45
	 * already been created, that instance will be returned. Otherwise, if a GUI
45
	 * already been created, that instance will be returned. Otherwise, if a GUI
46
	 * component of the same type has been created, and the component is not
46
	 * component of the same type has been created, and the component is not
47
	 * marked as an {@link UnsharedComponent}, that shared component will be
47
	 * marked as an {@link UnsharedComponent}, that shared component will be
48
	 * returned. Otherwise, a new instance of the component will be created.
48
	 * returned. Otherwise, a new instance of the component will be created.
49
	 * 
49
	 * 
50
	 * @param node
50
	 * @param node
51
	 *            the test element which this GUI is being created for
51
	 *            the test element which this GUI is being created for
52
	 * @param guiClass
52
	 * @param guiClass
53
	 *            the fully qualifed class name of the GUI component which will
53
	 *            the fully qualifed class name of the GUI component which will
54
	 *            be created if it doesn't already exist
54
	 *            be created if it doesn't already exist
55
	 * @param testClass
55
	 * @param testClass
56
	 *            the fully qualifed class name of the test elements which have
56
	 *            the fully qualifed class name of the test elements which have
57
	 *            to be edited by the returned GUI component
57
	 *            to be edited by the returned GUI component
58
	 * 
58
	 * 
59
	 * @return the GUI component corresponding to the specified test element
59
	 * @return the GUI component corresponding to the specified test element
60
	 */
60
	 */
61
	public JMeterGUIComponent getGui(TestElement node, Class guiClass, Class testClass) {
61
	public JMeterGUIComponent getGui(TestElement node, Class guiClass, Class testClass) {
62
		try {
62
		try {
63
			JMeterGUIComponent comp = (JMeterGUIComponent) nodesToGui.get(node);
63
			JMeterGUIComponent comp = (JMeterGUIComponent) nodesToGui.get(node);
64
			if (comp == null) {
64
			if (comp == null) {
65
				comp = getGuiFromCache(guiClass, testClass);
65
				comp = getGuiFromCache(guiClass, testClass);
66
				nodesToGui.put(node, comp);
66
				nodesToGui.put(node, comp);
67
			}
67
			}
68
			log.debug("Gui retrieved = " + comp);
68
			log.debug("Gui retrieved = " + comp);
69
			return comp;
69
			return comp;
70
		} catch (Exception e) {
70
		} catch (Exception e) {
71
			log.error("Problem retrieving gui", e);
71
			log.error("Problem retrieving gui", e);
72
			return null;
72
			return null;
73
		}
73
		}
74
	}
74
	}
75
	/**
75
	/**
76
	 * Remove a test element from the tree. This removes the reference to any
76
	 * Remove a test element from the tree. This removes the reference to any
77
	 * associated GUI component.
77
	 * associated GUI component.
78
	 * 
78
	 * 
79
	 * @param node
79
	 * @param node
80
	 *            the test element being removed
80
	 *            the test element being removed
81
	 */
81
	 */
82
	public void removeNode(TestElement node) {
82
	public void removeNode(TestElement node) {
83
		nodesToGui.remove(node);
83
		nodesToGui.remove(node);
84
	}
84
	}
85
	/**
85
	/**
86
	 * Convenience method for grabbing the gui for the current node.
86
	 * Convenience method for grabbing the gui for the current node.
87
	 * 
87
	 * 
88
	 * @return the GUI component associated with the currently selected node
88
	 * @return the GUI component associated with the currently selected node
89
	 */
89
	 */
90
	public JMeterGUIComponent getCurrentGui() {
90
	public JMeterGUIComponent getCurrentGui() {
91
		try {
91
		try {
92
			updateCurrentNode();
92
			updateCurrentNode();
93
			TestElement curNode = treeListener.getCurrentNode().getTestElement();
93
			TestElement curNode = treeListener.getCurrentNode().getTestElement();
94
			JMeterGUIComponent comp = getGui(curNode);
94
			JMeterGUIComponent comp = getGui(curNode);
95
			comp.clearGui();
95
			comp.clearGui();
96
			log.debug("Updating gui to new node");
96
			log.debug("Updating gui to new node");
97
			comp.configure(curNode);
97
			comp.configure(curNode);
98
			currentNodeUpdated = false;
98
			currentNodeUpdated = false;
99
			return comp;
99
			return comp;
100
		} catch (Exception e) {
100
		} catch (Exception e) {
101
			log.error("Problem retrieving gui", e);
101
			log.error("Problem retrieving gui", e);
102
			return null;
102
			return null;
103
		}
103
		}
104
	}
104
	}
105
	/**
105
	/**
106
	 * Find the JMeterTreeNode for a certain TestElement object.
106
	 * Find the JMeterTreeNode for a certain TestElement object.
107
	 * 
107
	 * 
108
	 * @param userObject
108
	 * @param userObject
109
	 *            the test element to search for
109
	 *            the test element to search for
110
	 * @return the tree node associated with the test element
110
	 * @return the tree node associated with the test element
111
	 */
111
	 */
112
	public ReportTreeNode getNodeOf(TestElement userObject) {
112
	public JMeterTreeNode getNodeOf(TestElement userObject) {
113
		return treeModel.getNodeOf(userObject);
113
		return treeModel.getNodeOf(userObject);
114
	}
114
	}
115
	/**
115
	/**
116
	 * Create a TestElement corresponding to the specified GUI class.
116
	 * Create a TestElement corresponding to the specified GUI class.
117
	 * 
117
	 * 
118
	 * @param guiClass
118
	 * @param guiClass
119
	 *            the fully qualified class name of the GUI component or a
119
	 *            the fully qualified class name of the GUI component or a
120
	 *            TestBean class for TestBeanGUIs.
120
	 *            TestBean class for TestBeanGUIs.
121
	 * @param testClass
121
	 * @param testClass
122
	 *            the fully qualified class name of the test elements edited by
122
	 *            the fully qualified class name of the test elements edited by
123
	 *            this GUI component.
123
	 *            this GUI component.
124
	 * @return the test element corresponding to the specified GUI class.
124
	 * @return the test element corresponding to the specified GUI class.
125
	 */
125
	 */
126
	public TestElement createTestElement(Class guiClass, Class testClass) {
126
	public TestElement createTestElement(Class guiClass, Class testClass) {
127
		try {
127
		try {
128
			JMeterGUIComponent comp = getGuiFromCache(guiClass, testClass);
128
			JMeterGUIComponent comp = getGuiFromCache(guiClass, testClass);
129
			comp.clearGui();
129
			comp.clearGui();
130
			TestElement node = comp.createTestElement();
130
			TestElement node = comp.createTestElement();
131
			nodesToGui.put(node, comp);
131
			nodesToGui.put(node, comp);
132
			return node;
132
			return node;
133
		} catch (Exception e) {
133
		} catch (Exception e) {
134
			log.error("Problem retrieving gui", e);
134
			log.error("Problem retrieving gui", e);
135
			return null;
135
			return null;
136
		}
136
		}
137
	}
137
	}
138
	/**
138
	/**
139
	 * Create a TestElement for a GUI or TestBean class.
139
	 * Create a TestElement for a GUI or TestBean class.
140
	 * <p>
140
	 * <p>
141
	 * This is a utility method to help actions do with one single String
141
	 * This is a utility method to help actions do with one single String
142
	 * parameter.
142
	 * parameter.
143
	 * 
143
	 * 
144
	 * @param objClass
144
	 * @param objClass
145
	 *            the fully qualified class name of the GUI component or of the
145
	 *            the fully qualified class name of the GUI component or of the
146
	 *            TestBean subclass for which a TestBeanGUI is wanted.
146
	 *            TestBean subclass for which a TestBeanGUI is wanted.
147
	 * @return the test element corresponding to the specified GUI class.
147
	 * @return the test element corresponding to the specified GUI class.
148
	 */
148
	 */
149
	public TestElement createTestElement(String objClass) {
149
	public TestElement createTestElement(String objClass) {
150
		JMeterGUIComponent comp;
150
		JMeterGUIComponent comp;
151
		Class c;
151
		Class c;
152
		try {
152
		try {
153
			c = Class.forName(objClass);
153
			c = Class.forName(objClass);
154
			if (TestBean.class.isAssignableFrom(c)) {
154
			if (TestBean.class.isAssignableFrom(c)) {
155
				comp = getGuiFromCache(TestBeanGUI.class, c);
155
				comp = getGuiFromCache(TestBeanGUI.class, c);
156
			} else {
156
			} else {
157
				comp = getGuiFromCache(c, null);
157
				comp = getGuiFromCache(c, null);
158
			}
158
			}
159
			comp.clearGui();
159
			comp.clearGui();
160
			TestElement node = comp.createTestElement();
160
			TestElement node = comp.createTestElement();
161
			nodesToGui.put(node, comp);
161
			nodesToGui.put(node, comp);
162
			return node;
162
			return node;
163
		} catch (NoClassDefFoundError e
163
		} catch (NoClassDefFoundError e
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0