1 package com.explosion.expf.help;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.awt.BorderLayout;
23
24 import javax.help.HelpBroker;
25 import javax.help.HelpSet;
26 import javax.help.JHelpContentViewer;
27 import javax.help.JHelpNavigator;
28 import javax.swing.JLabel;
29 import javax.swing.JPanel;
30 import javax.swing.JSplitPane;
31 import javax.swing.JTabbedPane;
32
33 import com.explosion.expf.Application;
34 import com.explosion.utilities.exception.EnhancedException;
35 import com.explosion.utilities.exception.ExceptionManagerFactory;
36
37 /***
38 * @author Stephen Cowx
39 * Date created:@29-Jan-2003
40 */
41 public class HelpPane extends JSplitPane
42 {
43 private HelpSet apiHS = null;
44 private JHelpContentViewer viewer1 = null;
45 private JHelpNavigator tocNav = null;
46 private JHelpNavigator indexNav = null;
47 private JHelpNavigator searchNav = null;
48
49 private JTabbedPane tabbedPane = new JTabbedPane();
50 private JPanel contentPanel = new JPanel();
51 private String startID = "";
52
53
54 /***
55 * Constructor
56 */
57 public HelpPane(String startID) throws Exception
58 {
59 super(JSplitPane.HORIZONTAL_SPLIT);
60 this.startID = startID;
61 init();
62 }
63
64 /***
65 * This method sets out the look and feel for this component
66 */
67 private void init() throws Exception
68 {
69
70
71
72
73
74
75
76 HelpBroker hb = null;
77 try
78 {
79 hb = Application.getHelpBroker();
80 }
81 catch (Exception e)
82 {
83 ExceptionManagerFactory.getExceptionManager().manageException(e,EnhancedException.getStackTrace(e));
84 }
85
86 if (hb != null)
87 {
88 apiHS = hb.getHelpSet();
89 viewer1 = new JHelpContentViewer(apiHS);
90
91 if (apiHS.getNavigatorView("TOC") != null)
92 tocNav = (JHelpNavigator) apiHS.getNavigatorView("TOC").createNavigator(viewer1.getModel());
93
94 if (apiHS.getNavigatorView("Index") != null)
95 indexNav = (JHelpNavigator) apiHS.getNavigatorView("Index").createNavigator(viewer1.getModel());
96
97 if (apiHS.getNavigatorView("Search") != null)
98 searchNav = (JHelpNavigator) apiHS.getNavigatorView("Search").createNavigator(viewer1.getModel());
99
100 if (!startID.trim().equals(""))
101 viewer1.setCurrentID(startID);
102
103 if (tocNav != null)
104 tabbedPane.addTab("Contents",tocNav);
105
106 if (indexNav != null)
107 tabbedPane.addTab("Index",indexNav);
108
109 if (searchNav != null)
110 tabbedPane.addTab("Search",searchNav);
111
112 tabbedPane.setSelectedIndex(0);
113
114 contentPanel.setLayout(new BorderLayout());
115 contentPanel.setDoubleBuffered(true);
116 contentPanel.add(viewer1, "Center");
117
118 this.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
119 this.setLeftComponent(tabbedPane);
120 this.setRightComponent(contentPanel);
121 this.setResizeWeight(0.2);
122 }
123 else
124 {
125 contentPanel.add(new JLabel("No help could be found for this application."));
126
127 this.add(contentPanel);
128 }
129 }
130
131 }