class Help implements Command { private static final Logger log = LoggingManager.getLoggerForClass(); private static final Set commands = new HashSet(); private static final String HELP_DOCS = "file:///" // $NON-NLS-1$ + JMeterUtils.getJMeterHome() + "/printable_docs/usermanual/"; // $NON-NLS-1$ private static final String HELP_PAGE = HELP_DOCS + "component_reference.html"; // $NON-NLS-1$ public static final String HELP_FUNCTIONS = HELP_DOCS + "functions.html"; // $NON-NLS-1$ private static JDialog helpWindow; private static HtmlPane helpDoc; private static JScrollPane scroller; private static String currentPage; static { commands.add(ActionNames.HELP); helpDoc = new HtmlPane(); scroller = new JScrollPane(helpDoc); helpDoc.setEditable(false); try { helpDoc.setPage(HELP_PAGE); currentPage = HELP_PAGE; } catch (IOException err) { String msg = "Couldn't load help file " + err.toString(); log.error(msg); currentPage = "";// Avoid NPE in resetPage() // $NON-NLS-1$ } } /** * @see org.apache.jmeter.gui.action.Command#doAction(ActionEvent) */ public void doAction(ActionEvent e) { if (helpWindow == null) { helpWindow = new JDialog(new Frame(),// independent frame to // allow it to be overlaid // by the main frame JMeterUtils.getResString("help"),//$NON-NLS-1$ false); helpWindow.getContentPane().setLayout(new GridLayout(1, 1)); ComponentUtil.centerComponentInWindow(helpWindow, 60); } helpWindow.getContentPane().removeAll(); helpWindow.getContentPane().add(scroller); helpWindow.show(); if (e.getSource() instanceof String[]) { String[] source = (String[]) e.getSource(); resetPage(source[0]); helpDoc.scrollToReference(source[1]); } else { resetPage(HELP_PAGE); helpDoc.scrollToReference(GuiPackage.getInstance().getTreeListener().getCurrentNode().getDocAnchor()); } } private void resetPage(String source) { if (!currentPage.equals(source)) { try { helpDoc.setPage(source); currentPage = source; } catch (IOException err) { log.error(err.toString()); JMeterUtils.reportErrorToUser("Problem loading a help page - see log for details"); currentPage = ""; // $NON-NLS-1$ } } } /** * @see org.apache.jmeter.gui.action.Command#getActionNames() */ public Set getActionNames() { return commands; }
class ReportHelp implements Command { private static final Logger log = LoggingManager.getLoggerForClass(); public static final String HELP = "help"; private static final Set commands = new HashSet(); public static final String HELP_DOCS = "file:///" + JMeterUtils.getJMeterHome() + "/printable_docs/usermanual/"; public static final String HELP_PAGE = HELP_DOCS + "component_reference.html"; public static final String HELP_FUNCTIONS = HELP_DOCS + "functions.html"; private static JDialog helpWindow; private static HtmlPane helpDoc; private static JScrollPane scroller; private static String currentPage; static { commands.add(HELP); helpDoc = new HtmlPane(); scroller = new JScrollPane(helpDoc); helpDoc.setEditable(false); try { helpDoc.setPage(HELP_PAGE); currentPage = HELP_PAGE; } catch (IOException err) { String msg = "Couldn't load help file " + err.toString(); log.error(msg); currentPage = "";// Avoid NPE in resetPage() } } /** * @see org.apache.jmeter.gui.action.Command#doAction(ActionEvent) */ public void doAction(ActionEvent e) { if (helpWindow == null) { helpWindow = new JDialog(new Frame(),// independent frame to // allow it to be overlaid // by the main frame JMeterUtils.getResString("help"),//$NON-NLS-1$ false); helpWindow.getContentPane().setLayout(new GridLayout(1, 1)); ComponentUtil.centerComponentInWindow(helpWindow, 60); } helpWindow.getContentPane().removeAll(); helpWindow.getContentPane().add(scroller); helpWindow.show(); if (e.getSource() instanceof String[]) { String[] source = (String[]) e.getSource(); resetPage(source[0]); helpDoc.scrollToReference(source[1]); } else { resetPage(HELP_PAGE); helpDoc.scrollToReference(ReportGuiPackage.getInstance().getTreeListener().getCurrentNode().getDocAnchor()); } } private void resetPage(String source) { if (!currentPage.equals(source)) { try { helpDoc.setPage(source); currentPage = source; } catch (IOException err) { log.error(err.toString()); JMeterUtils.reportErrorToUser("Problem loading a help page - see log for details"); currentPage = ""; } } } /** * @see org.apache.jmeter.gui.action.Command#getActionNames() */ public Set getActionNames() { return commands; }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/gui/action/Help.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/report/gui/action/ReportHelp.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
class Help implements Command {
1
class ReportHelp implements Command {
2
	private static final Logger log = LoggingManager.getLoggerForClass();
2
	private static final Logger log = LoggingManager.getLoggerForClass();
3
	public static final String HELP = "help";
3
	private static final Set commands = new HashSet();
4
	private static final Set commands = new HashSet();
4
	private static final String HELP_DOCS = "file:///"  // $NON-NLS-1$
5
	public static final String HELP_DOCS = "file:///" 
5
		+ JMeterUtils.getJMeterHome() 
6
+ JMeterUtils.getJMeterHome() 
6
		+ "/printable_docs/usermanual/"; // $NON-NLS-1$
7
+ "/printable_docs/usermanual/";
7
	private
8
 static final String HELP_PAGE = HELP_DOCS + "component_reference.html"; // $NON-NLS-1$
8
	public static final String HELP_PAGE = HELP_DOCS + "component_reference.html";
9
	public static final String HELP_FUNCTIONS = HELP_DOCS + "functions.html"; // $NON-NLS-1$
9
	public static final String HELP_FUNCTIONS = HELP_DOCS + "functions.html";
10
	private static JDialog helpWindow;
10
	private static JDialog helpWindow;
11
	private static HtmlPane helpDoc;
11
	private static HtmlPane helpDoc;
12
	private static JScrollPane scroller;
12
	private static JScrollPane scroller;
13
	private static String currentPage;
13
	private static String currentPage;
14
	static {
14
	static {
15
		commands.add(ActionNames.HELP);
15
		commands.add(HELP);
16
		helpDoc = new HtmlPane();
16
		helpDoc = new HtmlPane();
17
		scroller = new JScrollPane(helpDoc);
17
		scroller = new JScrollPane(helpDoc);
18
		helpDoc.setEditable(false);
18
		helpDoc.setEditable(false);
19
		try {
19
		try {
20
			helpDoc.setPage(HELP_PAGE);
20
			helpDoc.setPage(HELP_PAGE);
21
			currentPage = HELP_PAGE;
21
			currentPage = HELP_PAGE;
22
		} catch (IOException err) {
22
		} catch (IOException err) {
23
			String msg = "Couldn't load help file " + err.toString();
23
			String msg = "Couldn't load help file " + err.toString();
24
			log.error(msg);
24
			log.error(msg);
25
			currentPage = "";// Avoid NPE in resetPage() // $NON-NLS-1$
25
			currentPage = "";// Avoid NPE in resetPage()
26
		}
26
		}
27
	}
27
	}
28
	/**
28
	/**
29
	 * @see org.apache.jmeter.gui.action.Command#doAction(ActionEvent)
29
	 * @see org.apache.jmeter.gui.action.Command#doAction(ActionEvent)
30
	 */
30
	 */
31
	public void doAction(ActionEvent e) {
31
	public void doAction(ActionEvent e) {
32
		if (helpWindow == null) {
32
		if (helpWindow == null) {
33
			helpWindow = new JDialog(new Frame(),// independent frame to
33
			helpWindow = new JDialog(new Frame(),// independent frame to
34
													// allow it to be overlaid
34
													// allow it to be overlaid
35
													// by the main frame
35
													// by the main frame
36
					JMeterUtils.getResString("help"),//$NON-NLS-1$
36
					JMeterUtils.getResString("help"),//$NON-NLS-1$
37
					false);
37
					false);
38
			helpWindow.getContentPane().setLayout(new GridLayout(1, 1));
38
			helpWindow.getContentPane().setLayout(new GridLayout(1, 1));
39
			ComponentUtil.centerComponentInWindow(helpWindow, 60);
39
			ComponentUtil.centerComponentInWindow(helpWindow, 60);
40
		}
40
		}
41
		helpWindow.getContentPane().removeAll();
41
		helpWindow.getContentPane().removeAll();
42
		helpWindow.getContentPane().add(scroller);
42
		helpWindow.getContentPane().add(scroller);
43
		helpWindow.show();
43
		helpWindow.show();
44
		if (e.getSource() instanceof String[]) {
44
		if (e.getSource() instanceof String[]) {
45
			String[] source = (String[]) e.getSource();
45
			String[] source = (String[]) e.getSource();
46
			resetPage(source[0]);
46
			resetPage(source[0]);
47
			helpDoc.scrollToReference(source[1]);
47
			helpDoc.scrollToReference(source[1]);
48
		} else {
48
		} else {
49
			resetPage(HELP_PAGE);
49
			resetPage(HELP_PAGE);
50
			helpDoc.scrollToReference(GuiPackage.getInstance().getTreeListener().getCurrentNode().getDocAnchor());
50
			helpDoc.scrollToReference(ReportGuiPackage.getInstance().getTreeListener().getCurrentNode().getDocAnchor());
51
		}
51
		}
52
	}
52
	}
53
	private void resetPage(String source) {
53
	private void resetPage(String source) {
54
		if (!currentPage.equals(source)) {
54
		if (!currentPage.equals(source)) {
55
			try {
55
			try {
56
				helpDoc.setPage(source);
56
				helpDoc.setPage(source);
57
				currentPage = source;
57
				currentPage = source;
58
			} catch (IOException err) {
58
			} catch (IOException err) {
59
				log.error(err.toString());
59
				log.error(err.toString());
60
				JMeterUtils.reportErrorToUser("Problem loading a help page - see log for details");
60
				JMeterUtils.reportErrorToUser("Problem loading a help page - see log for details");
61
				currentPage = ""; // $NON-NLS-1$
61
				currentPage = "";
62
			}
62
			}
63
		}
63
		}
64
	}
64
	}
65
	/**
65
	/**
66
	 * @see org.apache.jmeter.gui.action.Command#getActionNames()
66
	 * @see org.apache.jmeter.gui.action.Command#getActionNames()
67
	 */
67
	 */
68
	public Set getActionNames() {
68
	public Set getActionNames() {
69
		return commands;
69
		return commands;
70
	}
70
	}
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