01: /*
02: * TocOpen.java - List of page for the help topic
03: * Copyright (C) 2003 Alexandre THOMAS
04: * alexthomas@free.fr
05: * http://helpgui.sourceforge.net
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2
10: * of the License, or any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20: */
21:
22: package salomeTMF_plug.helpgui.parser;
23:
24: import java.io.IOException;
25:
26: import javax.xml.parsers.ParserConfigurationException;
27: import javax.xml.parsers.SAXParser;
28: import javax.xml.parsers.SAXParserFactory;
29:
30: import org.objectweb.salome_tmf.api.Util;
31: import org.xml.sax.SAXException;
32: import org.xml.sax.helpers.DefaultHandler;
33:
34: import salomeTMF_plug.helpgui.gui.HelpView;
35: import salomeTMF_plug.helpgui.gui.MainPanel;
36:
37: /**
38: * Aible to to load a toc and construct the tree
39: *
40: * @author Alexandre THOMAS
41: */
42: public class TocOpen {
43:
44: //Temporary
45: StringBuffer XMLFile = new StringBuffer();
46:
47: /** View of data */
48: HelpView helpView;
49:
50: ////////////////////////////////////////////////////////////////////
51:
52: /** Constructor */
53: public TocOpen(HelpView helpView) {
54: this .helpView = helpView;
55: }
56:
57: public boolean load(String path, boolean plugin, String pluginName)
58: throws IOException {
59: // Use an instance of ourselves as the SAX event handler
60: DefaultHandler handler = new XMLParser(helpView, plugin,
61: pluginName);
62:
63: // Use the default (non-validating) parser
64: SAXParserFactory factory = SAXParserFactory.newInstance();
65: try {
66: // Parse the input
67: SAXParser saxParser;
68: saxParser = factory.newSAXParser();
69: Util.log("[helpgui:TocOpen] : try to load : " + path
70: + "/toc.xml");
71: saxParser.parse(path + "/toc.xml", handler);
72:
73: } catch (ParserConfigurationException e) {
74: e.printStackTrace();
75: return false;
76: } catch (SAXException e) {
77: e.printStackTrace();
78: throw new IOException(e.getMessage());
79: }
80:
81: return true;
82: }
83:
84: /** Load the toc.xml file and create the tree */
85: public boolean load() throws IOException {
86: return load(MainPanel.helpPath + "/" + MainPanel.helpDir + "/"
87: + MainPanel.lang, false, null);
88: }
89:
90: }
|