KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > standalone > Help


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.help.standalone;
12
13 import java.io.*;
14 import java.util.ArrayList JavaDoc;
15
16 import org.eclipse.help.internal.standalone.*;
17
18 /**
19  * This is a standalone help system. It takes care of launching the Eclipse with
20  * its help system implementation, and controling it. This class can be
21  * instantiated and used in a Java program, or can be launched from command line
22  * to execute single help action.
23  *
24  * Usage as a Java component:
25  * <ul>
26  * <li>create an instantance of this class and then hold onto this instance for
27  * the duration of your application</li>
28  * <li>call start()</li>
29  * <li>call displayHelp(...) or displayContext(..) any number of times</li>
30  * <li>at the end, call shutdown().</li>
31  * </ul>
32  */

33 public class Help {
34     private StandaloneHelp help;
35
36     /**
37      * Constructs help system
38      *
39      * @param options
40      * array of String options and their values
41      * <p>
42      * Option <code>-eclipseHome dir</code> specifies Eclipse
43      * installation directory. This directory is a parent to
44      * "plugins" directory and eclipse executable. The option must be
45      * provided, when current directory from which infocenter is
46      * launched, is not the same as Eclipse installation directory.
47      * <p>
48      * Option <code>-host helpServerHost</code> specifies host name
49      * of the interface that help server will use. It overrides host
50      * name specified in the application server plugin preferences.
51      * <p>
52      * Option <code>-port helpServerPort</code> specifies port
53      * number that help server will use. It overrides port number
54      * specified in the application server plugin preferences.
55      * <p>
56      * Option <code>-dir rtl</code> sets right-to-left rendering
57      * direction of help UI in the browser.
58      * <p>
59      * Additionally, most options accepted by Eclipse execuable are
60      * supported.
61      */

62     public Help(String JavaDoc[] options) {
63         help = new StandaloneHelp(options);
64     }
65     /**
66      * This contstructs the stand alone help.
67      *
68      * @param pluginsDir
69      * directory containing Eclipse plugins
70      * @deprecated use Help#Help(String[])
71      */

72     public Help(String JavaDoc pluginsDir) {
73         File plugins = new File(pluginsDir);
74         String JavaDoc install = plugins.getParent();
75         ArrayList JavaDoc options = new ArrayList JavaDoc(2);
76         if (install != null) {
77             options = new ArrayList JavaDoc(2);
78             options.add("-eclipseHome"); //$NON-NLS-1$
79
options.add(install);
80         }
81         String JavaDoc[] args = new String JavaDoc[options.size()];
82         options.toArray(args);
83         help = new StandaloneHelp(args);
84     }
85     /**
86      * Starts the stand alone help system.
87      */

88     public void start() throws Exception JavaDoc {
89         help.start();
90     }
91     /**
92      * Shuts-down the stand alone help system.
93      */

94     public void shutdown() throws Exception JavaDoc {
95         help.shutdown();
96     }
97     /**
98      * Displays help.
99      */

100     public void displayHelp() throws Exception JavaDoc {
101         help.displayHelp();
102     }
103
104     /**
105      * Displays specified help resource.
106      *
107      * @param href
108      * the href of the table of contents
109      */

110     public void displayHelp(String JavaDoc href) throws Exception JavaDoc {
111         help.displayHelp(href);
112     }
113
114     /**
115      * Displays context sensitive help.
116      *
117      * @param contextId
118      * context id
119      * @param x
120      * x coordinate
121      * @param y
122      * y coordinate
123      */

124     public void displayContext(String JavaDoc contextId, int x, int y) throws Exception JavaDoc {
125         help.displayContext(contextId, x, y);
126     }
127
128     /**
129      * Displays context sensitive help in infopop.
130      *
131      * @param contextId
132      * context id
133      * @param x
134      * x coordinate
135      * @param y
136      * y coordinate
137      */

138     public void displayContextInfopop(String JavaDoc contextId, int x, int y)
139             throws Exception JavaDoc {
140         help.displayContextInfopop(contextId, x, y);
141     }
142
143     /**
144      * Controls standalone help system from command line.
145      *
146      * @param args
147      * array of String containing options Options are:
148      * <code>-command start | shutdown | (displayHelp [href]) [-eclipsehome eclipseInstallPath] [-host helpServerHost] [-port helpServerPort] [-dir rtl] [platform options] [-vmargs JavaVMarguments]</code>
149      * where
150      * <ul>
151      * <li><code>href</code> is the URL of the help resource to
152      * display,</li>
153      * <li><code>eclipseInstallPath</code> specifies Eclipse
154      * installation directory; it must be provided, when current
155      * directory is not the same as Eclipse installation directory,
156      * </li>
157      * <li><code>helpServerHost</code> specifies host name of the
158      * interface that help server will use, it overrides host name
159      * specified the application server plugin preferences</li>
160      * <li><code>helpServerPort</code> specifies port number that
161      * help server will use, it overrides port number specified the
162      * application server plugin preferences.</li>
163      * <li><code>-dir rtl</code> sets right-to-left rendering
164      * direction of help UI in the browser.
165      * <li><code>platform options</code> are other options that
166      * are supported by Eclipse Executable.</li>
167      * <ul>
168      */

169     public static void main(String JavaDoc[] args) {
170         StandaloneHelp.main(args);
171     }
172 }
173
Popular Tags