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