| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
package org.xmlhammer.gui.help; |
| 23 |
|
|
| 24 |
|
import java.awt.BorderLayout; |
| 25 |
|
import java.awt.Dimension; |
| 26 |
|
import java.awt.FlowLayout; |
| 27 |
|
import java.awt.Font; |
| 28 |
|
import java.awt.event.ActionEvent; |
| 29 |
|
import java.awt.event.ActionListener; |
| 30 |
|
import java.awt.event.MouseEvent; |
| 31 |
|
import java.net.URISyntaxException; |
| 32 |
|
import java.net.URL; |
| 33 |
|
|
| 34 |
|
import javax.help.DefaultHelpModel; |
| 35 |
|
import javax.help.HelpSet; |
| 36 |
|
import javax.help.IndexItem; |
| 37 |
|
import javax.help.InvalidHelpSetContextException; |
| 38 |
|
import javax.help.JHelpContentViewer; |
| 39 |
|
import javax.help.JHelpIndexNavigator; |
| 40 |
|
import javax.help.JHelpSearchNavigator; |
| 41 |
|
import javax.help.JHelpTOCNavigator; |
| 42 |
|
import javax.help.Map; |
| 43 |
|
import javax.help.SearchTOCItem; |
| 44 |
|
import javax.help.TOCItem; |
| 45 |
|
import javax.help.TOCView; |
| 46 |
|
import javax.help.Map.ID; |
| 47 |
|
import javax.help.event.HelpModelEvent; |
| 48 |
|
import javax.help.event.HelpModelListener; |
| 49 |
|
import javax.help.plaf.basic.BasicContentViewerUI; |
| 50 |
|
import javax.help.plaf.basic.BasicSearchCellRenderer; |
| 51 |
|
import javax.help.plaf.basic.BasicTOCCellRenderer; |
| 52 |
|
import javax.swing.Box; |
| 53 |
|
import javax.swing.DefaultButtonModel; |
| 54 |
|
import javax.swing.Icon; |
| 55 |
|
import javax.swing.ImageIcon; |
| 56 |
|
import javax.swing.JButton; |
| 57 |
|
import javax.swing.JComponent; |
| 58 |
|
import javax.swing.JLabel; |
| 59 |
|
import javax.swing.JPanel; |
| 60 |
|
import javax.swing.JToolBar; |
| 61 |
|
import javax.swing.JTree; |
| 62 |
|
import javax.swing.border.EmptyBorder; |
| 63 |
|
import javax.swing.border.EtchedBorder; |
| 64 |
|
import javax.swing.event.AncestorEvent; |
| 65 |
|
import javax.swing.event.AncestorListener; |
| 66 |
|
import javax.swing.tree.DefaultMutableTreeNode; |
| 67 |
|
import javax.swing.tree.TreePath; |
| 68 |
|
|
| 69 |
|
import org.apache.log4j.Logger; |
| 70 |
|
import org.bounce.CardPanel; |
| 71 |
|
import org.bounce.ResizingFlowLayout; |
| 72 |
|
import org.bounce.RunnableAction; |
| 73 |
|
import org.bounce.event.DoubleClickListener; |
| 74 |
|
import org.bounce.image.ImageLoader; |
| 75 |
|
import org.xmlhammer.gui.util.ExternalApplicationLauncher; |
| 76 |
|
import org.xmlhammer.gui.util.HistoryList; |
| 77 |
|
|
| 78 |
7859 |
public class HelpPanel extends JPanel { |
| 79 |
|
private static final long serialVersionUID = -2000362072449326907L; |
| 80 |
|
|
| 81 |
22 |
private static final ImageIcon CLOSE_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/etool16/close.gif"); |
| 82 |
22 |
private static final ImageIcon CLOSE_OVER_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/etool16/close_over.gif"); |
| 83 |
|
|
| 84 |
22 |
private static final ImageIcon TOC_LEAF_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/obj16/searchhit_obj.gif"); |
| 85 |
22 |
private static final ImageIcon TOC_TOPIC_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/obj16/container_obj.gif"); |
| 86 |
|
|
| 87 |
22 |
private static final ImageIcon ALL_TOPICS_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/etool16/alltopics_co.gif"); |
| 88 |
22 |
private static final ImageIcon SEARCH_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/etool16/helpsearch_co.gif"); |
| 89 |
22 |
private static final ImageIcon HELP_VIEW_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/view16/help_view.gif"); |
| 90 |
22 |
private static final ImageIcon INDEX_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/etool16/index_co.gif"); |
| 91 |
|
|
| 92 |
528 |
private HistoryList<HistoryItem> historyList = null; |
| 93 |
|
|
| 94 |
528 |
private HelpSet helpset = null; |
| 95 |
|
|
| 96 |
528 |
private JHelpContentViewer contextViewer = null; |
| 97 |
528 |
private JHelpContentViewer basicViewer = null; |
| 98 |
|
|
| 99 |
528 |
private JHelpSearchNavigator searchNavigator = null; |
| 100 |
528 |
private JHelpTOCNavigator tocNavigator = null; |
| 101 |
528 |
private JHelpIndexNavigator indexNavigator = null; |
| 102 |
|
|
| 103 |
528 |
private CardPanel<JComponent> cardPanel = null; |
| 104 |
|
|
| 105 |
528 |
private PreviousAction previousAction = null; |
| 106 |
528 |
private NextAction nextAction = null; |
| 107 |
|
|
| 108 |
528 |
private JButton closeButton = null; |
| 109 |
|
|
| 110 |
|
public HelpPanel() { |
| 111 |
528 |
super(new BorderLayout()); |
| 112 |
|
|
| 113 |
528 |
setMinimumSize(new Dimension(0, 0)); |
| 114 |
528 |
historyList = new HistoryList<HistoryItem>(); |
| 115 |
528 |
cardPanel = new CardPanel<JComponent>(); |
| 116 |
528 |
JToolBar toolbar = new JToolBar(); |
| 117 |
528 |
toolbar.setRollover( true); |
| 118 |
528 |
toolbar.setFloatable( false); |
| 119 |
528 |
JLabel label = new JLabel("Help", HELP_VIEW_ICON, JLabel.HORIZONTAL); |
| 120 |
528 |
label.setFont(label.getFont().deriveFont(Font.PLAIN)); |
| 121 |
528 |
toolbar.add(label); |
| 122 |
528 |
toolbar.add(Box.createHorizontalGlue()); |
| 123 |
|
|
| 124 |
528 |
nextAction = new NextAction(); |
| 125 |
528 |
previousAction = new PreviousAction(); |
| 126 |
528 |
toolbar.add(new HomeAction()); |
| 127 |
528 |
toolbar.addSeparator(); |
| 128 |
528 |
toolbar.add(previousAction); |
| 129 |
528 |
toolbar.add(nextAction); |
| 130 |
528 |
toolbar.addSeparator(); |
| 131 |
528 |
closeButton = toolbar.add(new CloseAction()); |
| 132 |
528 |
closeButton.setRolloverIcon(CLOSE_OVER_ICON); |
| 133 |
|
|
| 134 |
528 |
HelpSet set = getHelpSet(); |
| 135 |
|
|
| 136 |
528 |
if (getHelpSet() != null) { |
| 137 |
|
try { |
| 138 |
528 |
contextViewer = new JHelpContentViewer(set); |
| 139 |
528 |
contextViewer.setUI(new ContentViewerUI(contextViewer)); |
| 140 |
528 |
contextViewer.getModel().addHelpModelListener(new HelpModelListener() { |
| 141 |
528 |
public void idChanged(HelpModelEvent event) { |
| 142 |
2398 |
putHistory(event.getID(), contextViewer); |
| 143 |
2398 |
} |
| 144 |
|
}); |
| 145 |
528 |
cardPanel.add(contextViewer); |
| 146 |
528 |
basicViewer = new JHelpContentViewer(set); |
| 147 |
528 |
basicViewer.setUI(new ContentViewerUI(basicViewer)); |
| 148 |
528 |
basicViewer.getModel().addHelpModelListener(new HelpModelListener() { |
| 149 |
528 |
public void idChanged(HelpModelEvent event) { |
| 150 |
0 |
putHistory(event.getID(), basicViewer); |
| 151 |
0 |
} |
| 152 |
|
}); |
| 153 |
528 |
cardPanel.add(basicViewer); |
| 154 |
|
|
| 155 |
528 |
searchNavigator = (JHelpSearchNavigator)set.getNavigatorView("Search").createNavigator(new DefaultHelpModel(set)); |
| 156 |
528 |
searchNavigator.updateUI(); |
| 157 |
528 |
JTree tree = getTree(searchNavigator); |
| 158 |
528 |
tree.setCellRenderer(new BasicSearchCellRenderer(set.getCombinedMap())); |
| 159 |
120 |
tree.updateUI(); |
| 160 |
120 |
tree.addMouseListener(new DoubleClickListener() { |
| 161 |
120 |
public void doubleClicked(MouseEvent event) { |
| 162 |
0 |
TreePath path = ((JTree)event.getSource()).getSelectionPath(); |
| 163 |
|
|
| 164 |
0 |
if (path != null) { |
| 165 |
0 |
SearchTOCItem item = (SearchTOCItem)((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject(); |
| 166 |
|
|
| 167 |
0 |
ID id = item.getID(); |
| 168 |
|
|
| 169 |
0 |
if (item.getID() == null && item.getURL() != null) { |
| 170 |
0 |
Map map = getHelpSet().getLocalMap(); |
| 171 |
0 |
id = map.getClosestID(item.getURL()); |
| 172 |
|
} |
| 173 |
|
|
| 174 |
0 |
if (id != null) { |
| 175 |
0 |
putHistory(id, basicViewer); |
| 176 |
0 |
historyList.setEnabled(false); |
| 177 |
|
|
| 178 |
|
try { |
| 179 |
0 |
basicViewer.setCurrentID(id); |
| 180 |
0 |
cardPanel.show(basicViewer); |
| 181 |
0 |
} catch (InvalidHelpSetContextException e) { |
| 182 |
0 |
Logger.getLogger(getClass()).debug(null, e); |
| 183 |
|
} finally { |
| 184 |
0 |
historyList.setEnabled(true); |
| 185 |
0 |
} |
| 186 |
|
|
| 187 |
0 |
cardPanel.show(basicViewer); |
| 188 |
|
} |
| 189 |
|
} |
| 190 |
0 |
} |
| 191 |
|
}); |
| 192 |
120 |
cardPanel.add(searchNavigator); |
| 193 |
|
|
| 194 |
120 |
indexNavigator = (JHelpIndexNavigator)set.getNavigatorView("Index").createNavigator(new DefaultHelpModel(set)); |
| 195 |
120 |
tree = getTree(indexNavigator); |
| 196 |
120 |
tree.addMouseListener(new DoubleClickListener() { |
| 197 |
120 |
public void doubleClicked(MouseEvent event) { |
| 198 |
0 |
TreePath path = ((JTree)event.getSource()).getSelectionPath(); |
| 199 |
|
|
| 200 |
0 |
if (path != null) { |
| 201 |
0 |
IndexItem item = (IndexItem)((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject(); |
| 202 |
|
|
| 203 |
0 |
ID id = item.getID(); |
| 204 |
|
|
| 205 |
0 |
if (item.getID() == null && item.getURL() != null) { |
| 206 |
0 |
Map map = getHelpSet().getLocalMap(); |
| 207 |
0 |
id = map.getClosestID(item.getURL()); |
| 208 |
|
} |
| 209 |
|
|
| 210 |
0 |
if (id != null) { |
| 211 |
0 |
putHistory(id, basicViewer); |
| 212 |
0 |
historyList.setEnabled(false); |
| 213 |
|
|
| 214 |
|
try { |
| 215 |
0 |
basicViewer.setCurrentID(id); |
| 216 |
0 |
} catch (InvalidHelpSetContextException e) { |
| 217 |
0 |
Logger.getLogger(getClass()).debug(null, e); |
| 218 |
|
} finally { |
| 219 |
0 |
historyList.setEnabled(true); |
| 220 |
0 |
} |
| 221 |
|
|
| 222 |
0 |
cardPanel.show(basicViewer); |
| 223 |
|
} |
| 224 |
|
} |
| 225 |
0 |
} |
| 226 |
|
}); |
| 227 |
120 |
cardPanel.add(indexNavigator); |
| 228 |
|
|
| 229 |
120 |
tocNavigator = (JHelpTOCNavigator)set.getNavigatorView("TOC").createNavigator(new DefaultHelpModel(set)); |
| 230 |
120 |
tree = getTree(tocNavigator); |
| 231 |
120 |
tree.setCellRenderer(new TOCCellRenderer(getHelpSet().getCombinedMap())); |
| 232 |
120 |
tree.addMouseListener(new DoubleClickListener() { |
| 233 |
120 |
public void doubleClicked(MouseEvent event) { |
| 234 |
0 |
TreePath path = ((JTree)event.getSource()).getSelectionPath(); |
| 235 |
|
|
| 236 |
0 |
if (path != null) { |
| 237 |
0 |
TOCItem item = (TOCItem)((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject(); |
| 238 |
|
|
| 239 |
0 |
putHistory(item.getID(), basicViewer); |
| 240 |
0 |
historyList.setEnabled(false); |
| 241 |
|
|
| 242 |
|
try { |
| 243 |
0 |
basicViewer.setCurrentID(item.getID()); |
| 244 |
0 |
} catch (InvalidHelpSetContextException e) { |
| 245 |
0 |
Logger.getLogger(getClass()).debug(null, e); |
| 246 |
|
} finally { |
| 247 |
0 |
historyList.setEnabled(true); |
| 248 |
0 |
} |
| 249 |
|
|
| 250 |
0 |
cardPanel.show(basicViewer); |
| 251 |
|
} |
| 252 |
0 |
} |
| 253 |
|
}); |
| 254 |
|
|
| 255 |
120 |
cardPanel.add(tocNavigator); |
| 256 |
|
|
| 257 |
|
|
| 258 |
|
|
| 259 |
|
|
| 260 |
120 |
JPanel main = new JPanel(new BorderLayout()); |
| 261 |
120 |
main.setBorder(new EmptyBorder(2, 5, 0, 5)); |
| 262 |
120 |
main.add(cardPanel, BorderLayout.CENTER); |
| 263 |
|
|
| 264 |
120 |
JPanel panel = new JPanel(new BorderLayout()); |
| 265 |
120 |
setBorder(new EtchedBorder()); |
| 266 |
|
|
| 267 |
|
|
| 268 |
|
|
| 269 |
|
|
| 270 |
120 |
panel.add(main, BorderLayout.CENTER); |
| 271 |
|
|
| 272 |
120 |
JPanel buttonPanel = new JPanel(); |
| 273 |
120 |
buttonPanel.setLayout(new ResizingFlowLayout(FlowLayout.LEFT)); |
| 274 |
|
|
| 275 |
120 |
buttonPanel.setBorder(new EmptyBorder(5, 0, 5, 0)); |
| 276 |
120 |
JButton tocButton = new JButton("TOC", ALL_TOPICS_ICON); |
| 277 |
120 |
tocButton.addActionListener(new ActionListener() { |
| 278 |
120 |
public void actionPerformed(ActionEvent event) { |
| 279 |
0 |
showTOC(); |
| 280 |
0 |
} |
| 281 |
|
}); |
| 282 |
120 |
tocButton.setFont(tocButton.getFont().deriveFont(Font.PLAIN)); |
| 283 |
|
|
| 284 |
120 |
buttonPanel.add(tocButton); |
| 285 |
120 |
JButton searchButton = new JButton("Search", SEARCH_ICON); |
| 286 |
120 |
searchButton.addActionListener(new ActionListener() { |
| 287 |
120 |
public void actionPerformed(ActionEvent event) { |
| 288 |
0 |
showSearch(); |
| 289 |
0 |
} |
| 290 |
|
}); |
| 291 |
120 |
searchButton.setFont(searchButton.getFont().deriveFont(Font.PLAIN)); |
| 292 |
120 |
buttonPanel.add(searchButton); |
| 293 |
|
|
| 294 |
120 |
JButton indexButton = new JButton("Index", INDEX_ICON); |
| 295 |
120 |
indexButton.addActionListener(new ActionListener() { |
| 296 |
120 |
public void actionPerformed(ActionEvent event) { |
| 297 |
0 |
showIndex(); |
| 298 |
0 |
} |
| 299 |
|
}); |
| 300 |
120 |
indexButton.setFont(indexButton.getFont().deriveFont(Font.PLAIN)); |
| 301 |
120 |
buttonPanel.add(indexButton); |
| 302 |
120 |
panel.add(buttonPanel, BorderLayout.SOUTH); |
| 303 |
120 |
main.add(toolbar, BorderLayout.NORTH); |
| 304 |
|
|
| 305 |
|
|
| 306 |
|
|
| 307 |
120 |
add(panel, BorderLayout.CENTER); |
| 308 |
|
|
| 309 |
120 |
historyList.reset(); |
| 310 |
|
|
| 311 |
|
|
| 312 |
120 |
putHistory(null, cardPanel.selected()); |
| 313 |
408 |
} catch (Exception e) { |
| 314 |
408 |
Logger.getLogger(getClass()).debug(null, e); |
| 315 |
120 |
} |
| 316 |
|
} |
| 317 |
|
|
| 318 |
528 |
this.addAncestorListener(new AncestorListener() { |
| 319 |
0 |
public void ancestorAdded(AncestorEvent event) {} |
| 320 |
|
|
| 321 |
0 |
public void ancestorMoved(AncestorEvent event) {} |
| 322 |
|
|
| 323 |
528 |
public void ancestorRemoved(AncestorEvent event) { |
| 324 |
0 |
((DefaultButtonModel)closeButton.getModel()).setRollover(false); |
| 325 |
0 |
} |
| 326 |
|
}); |
| 327 |
528 |
} |
| 328 |
|
|
| 329 |
|
public void showID(String id) { |
| 330 |
4234 |
showID(id, false); |
| 331 |
4234 |
} |
| 332 |
|
|
| 333 |
|
public void addCloseActionListener(ActionListener listener) { |
| 334 |
528 |
closeButton.addActionListener(listener); |
| 335 |
528 |
} |
| 336 |
|
|
| 337 |
|
public void removeCloseActionListener(ActionListener listener) { |
| 338 |
0 |
closeButton.removeActionListener(listener); |
| 339 |
0 |
} |
| 340 |
|
|
| 341 |
|
public void showContext() { |
| 342 |
0 |
if (!contextViewer.isVisible()) { |
| 343 |
0 |
putHistory(contextViewer.getModel().getCurrentID(), contextViewer); |
| 344 |
0 |
cardPanel.show(contextViewer); |
| 345 |
|
} |
| 346 |
0 |
} |
| 347 |
|
|
| 348 |
|
public void showContents() { |
| 349 |
0 |
Map.ID id = getHelpSet().getHomeID(); |
| 350 |
|
|
| 351 |
0 |
if (basicViewer.getModel().getCurrentID() == null || !basicViewer.getModel().getCurrentID().equals(id)) { |
| 352 |
0 |
putHistory(id, basicViewer); |
| 353 |
0 |
historyList.setEnabled(false); |
| 354 |
|
|
| 355 |
|
try { |
| 356 |
0 |
basicViewer.setCurrentID(id); |
| 357 |
0 |
} catch (InvalidHelpSetContextException e) { |
| 358 |
0 |
Logger.getLogger(getClass()).debug(null, e); |
| 359 |
|
} finally { |
| 360 |
0 |
historyList.setEnabled(true); |
| 361 |
0 |
} |
| 362 |
|
} |
| 363 |
|
|
| 364 |
0 |
cardPanel.show(basicViewer); |
| 365 |
0 |
} |
| 366 |
|
|
| 367 |
|
public void showQuickStart() { |
| 368 |
0 |
Map.ID id = Map.ID.create("quick-start", getHelpSet()); |
| 369 |
|
|
| 370 |
0 |
if (basicViewer.getModel().getCurrentID() == null || !basicViewer.getModel().getCurrentID().equals(id)) { |
| 371 |
0 |
putHistory(id, basicViewer); |
| 372 |
0 |
historyList.setEnabled(false); |
| 373 |
|
|
| 374 |
|
try { |
| 375 |
0 |
basicViewer.setCurrentID(id); |
| 376 |
0 |
} catch (InvalidHelpSetContextException e) { |
| 377 |
0 |
Logger.getLogger(getClass()).debug(null, e); |
| 378 |
|
} finally { |
| 379 |
0 |
historyList.setEnabled(true); |
| 380 |
0 |
} |
| 381 |
|
} |
| 382 |
|
|
| 383 |
0 |
cardPanel.show(basicViewer); |
| 384 |
0 |
} |
| 385 |
|
|
| 386 |
|
public void showSearch() { |
| 387 |
0 |
if (cardPanel.selected() != searchNavigator) { |
| 388 |
0 |
putHistory(null, searchNavigator); |
| 389 |
0 |
cardPanel.show(searchNavigator); |
| 390 |
|
} |
| 391 |
0 |
} |
| 392 |
|
|
| 393 |
|
public void showIndex() { |
| 394 |
0 |
if (cardPanel.selected() != indexNavigator) { |
| 395 |
0 |
putHistory(null, indexNavigator); |
| 396 |
0 |
cardPanel.show(indexNavigator); |
| 397 |
|
} |
| 398 |
0 |
} |
| 399 |
|
|
| 400 |
|
public void showTOC() { |
| 401 |
0 |
if (cardPanel.selected() != tocNavigator) { |
| 402 |
0 |
putHistory(null, tocNavigator); |
| 403 |
0 |
cardPanel.show(tocNavigator); |
| 404 |
|
} |
| 405 |
0 |
} |
| 406 |
|
|
| 407 |
|
public void show(HistoryItem item) { |
| 408 |
0 |
cardPanel.show(item.getCard()); |
| 409 |
0 |
historyList.setEnabled(false); |
| 410 |
|
|
| 411 |
|
try { |
| 412 |
0 |
if (item.getCard() == contextViewer) { |
| 413 |
0 |
contextViewer.setCurrentID(item.getID()); |
| 414 |
0 |
} else if (item.getCard() == basicViewer) { |
| 415 |
0 |
basicViewer.setCurrentID(item.getID()); |
| 416 |
|
} |
| 417 |
0 |
} catch (InvalidHelpSetContextException e) { |
| 418 |
0 |
Logger.getLogger(getClass()).debug(null, e); |
| 419 |
|
} finally { |
| 420 |
0 |
historyList.setEnabled(true); |
| 421 |
0 |
} |
| 422 |
0 |
} |
| 423 |
|
|
| 424 |
|
private void updateActions() { |
| 425 |
6632 |
previousAction.setEnabled(historyList.hasPrevious()); |
| 426 |
6632 |
nextAction.setEnabled(historyList.hasNext()); |
| 427 |
6632 |
} |
| 428 |
|
|
| 429 |
|
|
| 430 |
|
|
| 431 |
|
|
| 432 |
|
|
| 433 |
|
public void showID(String idString, boolean showViewer) { |
| 434 |
4234 |
ID id = Map.ID.create(idString, getHelpSet()); |
| 435 |
|
|
| 436 |
4234 |
if (contextViewer != null) { |
| 437 |
|
try { |
| 438 |
4234 |
historyList.setEnabled(false); |
| 439 |
4234 |
contextViewer.setCurrentID(id); |
| 440 |
|
|
| 441 |
4234 |
if (contextViewer.isVisible() && contextViewer.getModel().getCurrentID().equals(id)) { |
| 442 |
4234 |
putHistory(id, contextViewer); |
| 443 |
|
} |
| 444 |
|
|
| 445 |
4234 |
if (showViewer) { |
| 446 |
0 |
showContext(); |
| 447 |
|
} |
| 448 |
0 |
} catch (InvalidHelpSetContextException e) { |
| 449 |
0 |
Logger.getLogger(getClass()).debug("Cannot set ID", e); |
| 450 |
|
} finally { |
| 451 |
4234 |
historyList.setEnabled(true); |
| 452 |
4234 |
} |
| 453 |
|
} |
| 454 |
4234 |
} |
| 455 |
|
|
| 456 |
|
private HelpSet getHelpSet() { |
| 457 |
5410 |
if (helpset == null) { |
| 458 |
|
try { |
| 459 |
528 |
URL url = getClass().getResource("/help/jhelpset.hs"); |
| 460 |
|
|
| 461 |
528 |
Logger.getLogger(getClass()).debug("HelpSet URL: " + url); |
| 462 |
|
|
| 463 |
528 |
if (url != null) { |
| 464 |
528 |
helpset = new HelpSet(getClass().getClassLoader(), url); |
| 465 |
|
} |
| 466 |
0 |
} catch (Exception e) { |
| 467 |
0 |
Logger.getLogger(getClass()).debug(null, e); |
| 468 |
528 |
} |
| 469 |
|
} |
| 470 |
|
|
| 471 |
5410 |
return helpset; |
| 472 |
|
} |
| 473 |
|
|
| 474 |
|
private JTree getTree(JComponent comp) { |
| 475 |
2568 |
JTree tree = null; |
| 476 |
|
|
| 477 |
2568 |
if (comp instanceof JTree) { |
| 478 |
360 |
tree = (JTree)comp; |
| 479 |
|
} |
| 480 |
|
|
| 481 |
4368 |
for (int i = 0; i < comp.getComponentCount() && tree == null; i++) { |
| 482 |
1800 |
if (comp.getComponent(i) instanceof JComponent) { |
| 483 |
1800 |
tree = getTree((JComponent)comp.getComponent(i)); |
| 484 |
|
} |
| 485 |
|
} |
| 486 |
|
|
| 487 |
2568 |
return tree; |
| 488 |
|
} |
| 489 |
|
|
| 490 |
|
private void putHistory(ID id, JComponent card) { |
| 491 |
6752 |
if (card != null && id != null) { |
| 492 |
6632 |
historyList.put(new HistoryItem(id, card)); |
| 493 |
6632 |
updateActions(); |
| 494 |
|
} |
| 495 |
6149 |
} |
| 496 |
603 |
|
| 497 |
603 |
private class HistoryItem { |
| 498 |
6029 |
private ID id = null; |
| 499 |
6632 |
private JComponent card = null; |
| 500 |
603 |
|
| 501 |
6632 |
public HistoryItem(ID id, JComponent card) { |
| 502 |
6632 |
this.id = id; |
| 503 |
6029 |
this.card = card; |
| 504 |
6029 |
} |
| 505 |
0 |
|
| 506 |
|
public ID getID() { |
| 507 |
0 |
return id; |
| 508 |
|
} |
| 509 |
0 |
|
| 510 |
|
public JComponent getCard() { |
| 511 |
0 |
return card; |
| 512 |
|
} |
| 513 |
0 |
|
| 514 |
|
public String toString() { |
| 515 |
0 |
return "["+card.getClass().getName()+"] "+id; |
| 516 |
|
} |
| 517 |
|
} |
| 518 |
|
|
| 519 |
|
private class NextAction extends RunnableAction { |
| 520 |
48 |
private static final long serialVersionUID = 3258134648029526321L; |
| 521 |
48 |
|
| 522 |
480 |
public NextAction() { |
| 523 |
528 |
super("Next"); |
| 524 |
48 |
|
| 525 |
528 |
putValue(SHORT_DESCRIPTION, "Next Help Item"); |
| 526 |
480 |
putValue(SMALL_ICON, new ImageIcon( getClass().getResource( "/org/xmlhammer/gui/icons/elcl16/forward_nav.gif"))); |
| 527 |
480 |
} |
| 528 |
0 |
|
| 529 |
0 |
public void run() { |
| 530 |
0 |
show(historyList.next()); |
| 531 |
0 |
updateActions(); |
| 532 |
0 |
} |
| 533 |
|
} |
| 534 |
|
|
| 535 |
|
private class PreviousAction extends RunnableAction { |
| 536 |
48 |
private static final long serialVersionUID = 3258134648029526321L; |
| 537 |
48 |
|
| 538 |
480 |
public PreviousAction() { |
| 539 |
528 |
super("Previous"); |
| 540 |
48 |
|
| 541 |
528 |
putValue(SHORT_DESCRIPTION, "Next Help Item"); |
| 542 |
480 |
putValue(SMALL_ICON, new ImageIcon( getClass().getResource( "/org/xmlhammer/gui/icons/elcl16/backward_nav.gif"))); |
| 543 |
480 |
} |
| 544 |
0 |
|
| 545 |
0 |
public void run() { |
| 546 |
0 |
show(historyList.previous()); |
| 547 |
0 |
updateActions(); |
| 548 |
0 |
} |
| 549 |
|
} |
| 550 |
|
|
| 551 |
|
private class HomeAction extends RunnableAction { |
| 552 |
48 |
private static final long serialVersionUID = 3258134648029526321L; |
| 553 |
48 |
|
| 554 |
480 |
public HomeAction() { |
| 555 |
528 |
super("Home"); |
| 556 |
48 |
|
| 557 |
528 |
putValue(SHORT_DESCRIPTION, "Index Page"); |
| 558 |
480 |
putValue(SMALL_ICON, new ImageIcon( getClass().getResource( "/org/xmlhammer/gui/icons/elcl16/home_nav.gif"))); |
| 559 |
480 |
} |
| 560 |
0 |
|
| 561 |
0 |
public void run() { |
| 562 |
0 |
showContents(); |
| 563 |
0 |
} |
| 564 |
|
} |
| 565 |
|
|
| 566 |
|
private class CloseAction extends RunnableAction { |
| 567 |
48 |
private static final long serialVersionUID = 3258134648029526321L; |
| 568 |
48 |
|
| 569 |
480 |
public CloseAction() { |
| 570 |
528 |
super("Close"); |
| 571 |
48 |
|
| 572 |
528 |
putValue(SHORT_DESCRIPTION, "Close Help View"); |
| 573 |
480 |
putValue(SMALL_ICON, CLOSE_ICON); |
| 574 |
480 |
} |
| 575 |
|
|
| 576 |
0 |
public void run() { |
| 577 |
|
|
| 578 |
0 |
} |
| 579 |
|
} |
| 580 |
|
|
| 581 |
|
private class TOCCellRenderer extends BasicTOCCellRenderer { |
| 582 |
0 |
private static final long serialVersionUID = 6850877407883209757L; |
| 583 |
0 |
|
| 584 |
0 |
public TOCCellRenderer(Map map1, TOCView tocview) { |
| 585 |
0 |
super(map1, tocview); |
| 586 |
0 |
} |
| 587 |
0 |
|
| 588 |
120 |
public TOCCellRenderer(Map map1) { |
| 589 |
120 |
super(map1); |
| 590 |
120 |
} |
| 591 |
0 |
|
| 592 |
|
public Icon getLeafIcon() { |
| 593 |
121 |
return TOC_LEAF_ICON; |
| 594 |
|
} |
| 595 |
0 |
|
| 596 |
|
public Icon getOpenIcon() { |
| 597 |
240 |
return TOC_TOPIC_ICON; |
| 598 |
|
} |
| 599 |
0 |
|
| 600 |
|
public Icon getClosedIcon() { |
| 601 |
2174 |
return TOC_TOPIC_ICON; |
| 602 |
|
} |
| 603 |
|
} |
|