1 | public class Help implements Command {↵ | | 1 | public 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 |
|