ConexJava-JavaHelp
description
Transcript of ConexJava-JavaHelp
REALIZAR AYUDA CON JAVAHELP
Nils Murrugarra Llerena [email protected]://inf.unitru.edu.pe/~nineil/
Resumen: En este documento veremos la manera de realizar ayudas para programas hechos en Java mediante una librería: JavaHelp, veamos a continuación los pasos que debemos realizar: 1. Descargar de la página de la sun:
http://java.sun.com/products/javahelp/download_binary.html#download el archivo: javahelp-2_0_05.zip
2. Descomprimir y copiar la carpeta jh2.0 a D: 3. Crear el proyecto jhelp en NetBeans 4. Crear un formulario con una pestaña ayuda, donde el nombre del menú sea
menuAyuda con item: itemAyuda donde el contenido sea “ver Ayuda”.
5. En el constructor de la clase agregar el siguiente código: HelpSet hs; HelpBroker hb; String helpHS = "Master.hs";//Archivo q indicara la estructura de la ayuda ClassLoader cl = getMyLoader(); try { URL hsURL = HelpSet.findHelpSet(cl, helpHS); hs = new HelpSet(null, hsURL); } catch (Exception ee) { //Error
System.out.println( "HelpSet " + ee.getMessage()); System.out.println("HelpSet "+ helpHS +" not found"); return; }
hb = hs.createHelpBroker();//Crea interfaz de ayuda
this. itemAyuda.addActionListener(new CSH.DisplayHelpFromSource(hb));//Añade ayuda
6. Crear un método getMyLoader: private ClassLoader getMyLoader() { ClassLoader back; back = this.getClass().getClassLoader(); return back; }
7. Compilemos Al compilar nos saldrán algunos errores.
8. Agreguemos las siguientes librerías import javax.help.*; import java.net.*;
9. Añadir las siguientes rutas al path del sistema: a. D:\jh2.0\javahelp\bin
10. Añadiendo Librería Añadamos las librerías src.jar(de D:\jh2.0), jhindexer.jar(de D:\jh2.0\javahelp\bin) y jhsearch.jar(de D:\jh2.0\javahelp\bin) al proyecto. Vamos al panel de la izquierda en el ítem libraries, add Jar Fólder y añadimos las librerías.
11. Ahora al realizar la compilación todo sale ok. 12. Copiar todo lo que contiene la carpeta Archivos ….. \jHelp\build\classes
dependiendo de la ruta creada en el proyecto. 13. Compilar y Ejecutar, y al pulsar en VerAyuda debemos ver:
14. Analicemos la ayuda, veamos los archivos dentro de la carpeta Archivos
a. Icono Ayuda: Muestra la ayuda, veamos el contenido de MasterTOC.xml:
<!DOCTYPE toc PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 1.0//EN" "http://java.sun.com/products/javahelp/toc_1_0.dtd"> <toc version="1.0"> <tocitem text="Ayuda Compilador Gráfico"> <tocitem text="Inicio" target="index"/> <tocitem text="Requisitos y Advertencias" target="node1"/> <tocitem text="Acerca del Software" target="node2"/> <tocitem text="Utilizando el Software"> <tocitem text="Inicio" target="node3"/> <tocitem text="Comandos" target="node4"/> <tocitem text="Ejecución" target="node5"/> </tocitem> <tocitem text="Escribanos" target="node6"/> </tocitem> </toc> Como se puede apreciar, escojamos una instrucción para nuestro ejemplo: <tocitem text="Escribanos" target="node6"/> , Escribanos viene a ser un nombre q sea añadirá al menú y node6 la página web a donde hará referencia.
b. Icono Índice: Además de mostrar la ayuda, permite realizar búsqueda
en tales, veamos el contenido de MasterIndex.xml: <!DOCTYPE index PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Index Version 1.0//EN"
"http://java.sun.com/products/javahelp/index_1_0.dtd"> <index version="1.0"> <indexitem text="Inicio" target="index"/> <indexitem text="Requisitos y Advertencias" target="node1"/> <indexitem text="Acerca del Software" target="node2"/> <indexitem text="Utilizando el Software" target="node3"/> <indexitem text="Comandos" target="node4"/> <indexitem text="Ejecución" target="node5"/>
<indexitem text="Escribanos" target="node6"/> </index>
Como se puede apreciar, escojamos una instrucción para
nuestro ejemplo: <indexitem text="Escribanos" target="node6"/> , Escribanos viene a ser un nombre q sea añadirá al menú y node6 la página web a donde hará referencia.
c. Icono Búsqueda: Permite realizar búsqueda de texto en el contenido
de cada archivo.
15. Veamos más Archivos
a. Master.jhm: Relaciona un nombre dado con una determinada página web. Veamos su contenido:
<?xml version='1.0' encoding='ISO-8859-1' ?> <!DOCTYPE map PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN" "http://java.sun.com/products/javahelp/map_1_0.dtd"> <map version="1.0"> <mapID target="index" url="master/index.html" /> <mapID target="node1" url="master/node1.html" /> <mapID target="node2" url="master/node2.html" /> <mapID target="node3" url="master/node3.html" /> <mapID target="node4" url="master/node4.html" /> <mapID target="node5" url="master/node5.html" /> <mapID target="node6" url="master/node6.html" /> </map>
b. Master.hs: Define la estructura de toda la interfaz de ayuda. Veamos su contenido:
<!-- views --> <view> <name>TOC</name> <label>Ayuda</label> <type>javax.help.TOCView</type> <data>MasterTOC.xml</data> </view> <view>
<name>Index</name> <label>Índice</label> <type>javax.help.IndexView</type> <data>MasterIndex.xml</data> </view> <view> <name>Search</name> <label>Búsqueda</label> <type>javax.help.SearchView</type> <data engine="com.sun.java.help.search.DefaultSearchEngine"> JavaHelpSearch </data> </view> <view> <name>Favorites</name> <label>Favoritos</label> <type>javax.help.FavoritesView</type> <data>MasterIndex.xml</data> </view> </helpset>
c. Creemos la carpeta JavaHelpSearch para la icono búsqueda, para realizar una búsqueda por contenido de texto debemos de utilizar la función hindexer:
i. Inicio, ejecutar, cmd ii. cd “…….\jHelp\build\classes” , dependiendo de la ruta
donde se este iii. hindexer master iv. En la carpeta “…….\jHelp\build\classes”, se ha creado una
carpeta JavaHelpSearch, la que nos ayudara para realizar la búsqueda por contenido.