01: /*
02: * Copyright (C) 2005 Jeff Tassin
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package com.jeta.swingbuilder.help;
20:
21: import java.awt.event.ActionEvent;
22: import java.awt.event.ActionListener;
23:
24: import javax.help.CSH;
25: import javax.help.HelpBroker;
26:
27: import com.jeta.open.registry.JETARegistry;
28: import com.jeta.swingbuilder.common.ComponentNames;
29:
30: class HelpDelegator implements ActionListener {
31: /** the delegate action handler that actually displays the help */
32: private CSH.DisplayHelpFromSource m_delegate;
33:
34: public HelpDelegator() {
35: m_delegate = new CSH.DisplayHelpFromSource(HelpDelegator
36: .getHelpBroker());
37: }
38:
39: public void actionPerformed(ActionEvent evt) {
40: m_delegate.actionPerformed(evt);
41: }
42:
43: /**
44: * Creates the main help broker for the application and registers with the
45: * component manager
46: */
47: public synchronized static HelpBroker getHelpBroker() {
48: try {
49: HelpFactory factory = (HelpFactory) JETARegistry
50: .lookup(ComponentNames.APPLICATION_HELP_FACTORY);
51: if (factory != null) {
52: return factory.createHelpBroker();
53: } else {
54: return null;
55: }
56: } catch (Exception e) {
57: e.printStackTrace();
58: return null;
59: }
60: }
61:
62: }
|