Line | Hits | Source |
---|---|---|
1 | /******************************************************************************* | |
2 | * InternetCafe is a software solution that helps the management of Cybercafes | |
3 | * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005. | |
4 | * Copyright (C) 2006 Guido Angelo Ingenito | |
5 | ||
6 | * This program is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU General Public License | |
8 | * as published by the Free Software Foundation; either version 2 | |
9 | * of the License, or (at your option) any later version. | |
10 | ||
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | *******************************************************************************/ | |
20 | 0 | |
21 | package ui.help; | |
22 | ||
23 | import java.io.File; | |
24 | import java.net.URL; | |
25 | ||
26 | import javax.help.CSH; | |
27 | import javax.help.HelpBroker; | |
28 | import javax.help.HelpSet; | |
29 | import javax.swing.JMenuItem; | |
30 | 0 | |
31 | 0 | import org.apache.log4j.Logger; |
32 | 0 | |
33 | @SuppressWarnings("serial") //$NON-NLS-1$ | |
34 | 0 | public class HelpMenuItem extends JMenuItem{ |
35 | ||
36 | 0 | private static final transient Logger logger = Logger.getLogger(HelpMenuItem.class.getName()); |
37 | 0 | |
38 | /**The protocol can be one between http, file, etc...**/ | |
39 | 0 | public static final String URL_PROTOCOL="file"; //$NON-NLS-1$ |
40 | 0 | /**The local machine.**/ |
41 | 0 | public static final String URL_HOST="localhost"; //$NON-NLS-1$ |
42 | /**This specifies the default port to use in the protocol.**/ | |
43 | 0 | public static final int URL_PORT=-1; |
44 | 0 | |
45 | public HelpMenuItem(String menuName) { | |
46 | 0 | super(menuName); |
47 | 0 | initialize(); |
48 | 0 | } |
49 | 0 | |
50 | 0 | protected void initialize(){ |
51 | 0 | // 1. create HelpSet and HelpBroker objects |
52 | 0 | File file = new File("help"+File.separatorChar+"InternetCafe.hs"); //$NON-NLS-1$ //$NON-NLS-2$ |
53 | 0 | if(!file.exists()) |
54 | { | |
55 | 0 | logger.debug("The Help Set File named: "+file + " doesn't exists!"); //$NON-NLS-1$ //$NON-NLS-2$ |
56 | 0 | return; |
57 | 0 | }else logger.debug("The Help Set File named: "+file + " exists!"); //$NON-NLS-1$ //$NON-NLS-2$ |
58 | 0 | |
59 | 0 | HelpSet helpSet = getHelpSet(file.getAbsolutePath()); |
60 | 0 | HelpBroker helpBroker = helpSet.createHelpBroker(); |
61 | 0 | // 2. assign help to components |
62 | 0 | CSH.setHelpIDString(this, getName()); |
63 | 0 | // 3. handle events |
64 | 0 | this.addActionListener(new CSH.DisplayHelpFromSource(helpBroker)); |
65 | 0 | } |
66 | ||
67 | 0 | /** |
68 | 0 | * find the helpset file and create a HelpSet object |
69 | */ | |
70 | public HelpSet getHelpSet(String helpsetfile) { | |
71 | 0 | HelpSet helpSet = null; |
72 | try { | |
73 | 0 | URL hsURL = new URL(URL_PROTOCOL,URL_HOST,URL_PORT,helpsetfile); |
74 | 0 | helpSet = new HelpSet(this.getClass().getClassLoader(), hsURL); |
75 | 0 | } catch(Exception ex) { |
76 | 0 | ex.printStackTrace(); |
77 | 0 | logger.error("HelpSet: "+ex.getMessage()); //$NON-NLS-1$ |
78 | 0 | logger.error("HelpSet: "+ helpsetfile + " not found"); //$NON-NLS-1$ //$NON-NLS-2$ |
79 | 0 | } |
80 | 0 | return helpSet; |
81 | 0 | } |
82 | } | |
83 | 0 |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |