*
* @return The contents tree.
*/
private JScrollPane createContentsTree() throws IOException
{
final ApplicationFiles appFiles = new ApplicationFiles();
// i18n[HelpViewerWindow.help=Help]
final FolderNode root = new FolderNode(s_stringMgr.getString("HelpViewerWindow.help"));
_tree = new JTree(new DefaultTreeModel(root));
_tree.setShowsRootHandles(true);
_tree.addTreeSelectionListener(new ObjectTreeSelectionListener());
// Renderer for tree.
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
SquirrelResources rsrc = _app.getResources();
renderer.setLeafIcon(rsrc.getIcon(SquirrelResources.IImageNames.HELP_TOPIC));
renderer.setOpenIcon(rsrc.getIcon(SquirrelResources.IImageNames.HELP_TOC_OPEN));
renderer.setClosedIcon(rsrc.getIcon(SquirrelResources.IImageNames.HELP_TOC_CLOSED));
_tree.setCellRenderer(renderer);
// First put the Welcome to SQuirreL node.
File file = appFiles.getWelcomeFile();
try
{
// i18n[HelpViewerWindow.welcome=Welcome]
DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.welcome"), file);
root.add(dn);
_nodes.put(dn.getURL().toString(), dn);
}
catch (MalformedURLException ex)
{
// i18n[HelpViewerWindow.error.loadwelcomefile=Error retrieving Welcome file URL for {0}]
String msg =
s_stringMgr.getString("HelpViewerWindow.error.loadwelcomefile",
file.getAbsolutePath());
s_log.error(msg, ex);
}
// Add Help, Licence and Change Log nodes to the tree.
// i18n[HelpViewerWindow.help=Help]
final FolderNode helpRoot = new FolderNode(s_stringMgr.getString("HelpViewerWindow.help"));
root.add(helpRoot);
_nodes.put(helpRoot.getURL().toString(), helpRoot);
// i18n[HelpViewerWindow.licences=Licences]
final FolderNode licenceRoot = new FolderNode(s_stringMgr.getString("HelpViewerWindow.licences"));
root.add(licenceRoot);
_nodes.put(licenceRoot.getURL().toString(), licenceRoot);
// i18n[HelpViewerWindow.changelogs=Change Logs]
final FolderNode changeLogRoot = new FolderNode(s_stringMgr.getString("HelpViewerWindow.changelogs"));
root.add(changeLogRoot);
_nodes.put(changeLogRoot.getURL().toString(), changeLogRoot);
// Add SQuirreL help to the Help node.
file = appFiles.getQuickStartGuideFile();
try
{
// i18n[HelpViewerWindow.squirrel=SQuirreL]
DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.squirrel"), file);
helpRoot.add(dn);
_homeURL = dn.getURL();
_nodes.put(_homeURL.toString(), dn);
}
catch (MalformedURLException ex)
{
// i18n[HelpViewerWindow.error.loadwelcomefile=Error retrieving Help file URL for {0}]
String msg =
s_stringMgr.getString("HelpViewerWindow.error.loadhelpfile",
file.getAbsolutePath());
s_log.error(msg, ex);
}
// Add SQuirreL Licence to the Licence node.
file = appFiles.getLicenceFile();
try
{
// i18n[HelpViewerWindow.squirrel=SQuirreL]
DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.squirrel"), file);
licenceRoot.add(dn);
_nodes.put(dn.getURL().toString(), dn);
}
catch (MalformedURLException ex)
{
// i18n[HelpViewerWindow.error.loadlicencefile=Error retrieving Licence file URL for {0}]
String msg =
s_stringMgr.getString("HelpViewerWindow.error.loadlicencefile",
file.getAbsolutePath());
s_log.error(msg, ex);
}
// Add SQuirreL Change Log to the Licence node.
file = appFiles.getChangeLogFile();
try
{
// i18n[HelpViewerWindow.squirrel=SQuirreL]
DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.squirrel"), file);
changeLogRoot.add(dn);
_nodes.put(dn.getURL().toString(), dn);
}
catch (MalformedURLException ex)
{
// i18n[HelpViewerWindow.error.loadchangelogfile=Error retrieving Change Log file URL for {0}]
String msg =
s_stringMgr.getString("HelpViewerWindow.error.loadchangelogfile",
file.getAbsolutePath());
s_log.error(msg, ex);
}
// Add plugin help, licence and change log documents to the tree.
PluginInfo[] pi = _app.getPluginManager().getPluginInformation();
for (int i = 0; i < pi.length; ++i)
{
try
{
final File dir = pi[i].getPlugin().getPluginAppSettingsFolder();
final String title = pi[i].getDescriptiveName();
// Help document.
try
{
final String fn = pi[i].getHelpFileName();
if (fn != null && fn.length() > 0)
{
DocumentNode dn = new DocumentNode(title, new File(dir, fn));
helpRoot.add(dn);
_nodes.put(dn.getURL().toString(), dn);
}
}
catch (IOException ex)
{
// i18n[HelpViewerWindow.error.loadpluginhelp=Error generating Help entry for plugin {0}]
String msg =
s_stringMgr.getString("HelpViewerWindow.error.loadpluginhelp",
pi[i].getDescriptiveName());
s_log.error(msg, ex);
}
// Licence document.
try
{
final String fn = pi[i].getLicenceFileName();
if (fn != null && fn.length() > 0)
{
DocumentNode dn = new DocumentNode(title, new File(dir, fn));
licenceRoot.add(dn);
_nodes.put(dn.getURL().toString(), dn);
}
}
catch (IOException ex)
{
// i18n[HelpViewerWindow.error.loadpluginlicence=Error generating Licence entry for plugin {0}]
String msg =
s_stringMgr.getString("HelpViewerWindow.error.loadpluginlicence",
pi[i].getDescriptiveName());
s_log.error(msg, ex);
}
try
{
// Change log.
final String fn = pi[i].getChangeLogFileName();
if (fn != null && fn.length() > 0)
{
DocumentNode dn = new DocumentNode(title, new File(dir, fn));
changeLogRoot.add(dn);
_nodes.put(dn.getURL().toString(), dn);
}
}
catch (IOException ex)
{
// i18n[HelpViewerWindow.error.loadchangelog=Error generating Change Log entry for plugin {0}]
String msg =
s_stringMgr.getString("HelpViewerWindow.error.loadchangelog",
pi[i].getDescriptiveName());
s_log.error(msg, ex);
}
}
catch (IOException ex)
{
// i18n[HelpViewerWindow.error.loadpluginsettings=Error retrieving app settings folder for plugin {0}]
String msg =
s_stringMgr.getString("HelpViewerWindow.error.loadpluginsettings",
pi[i].getDescriptiveName());
s_log.error(msg, ex);
}
}
// FAQ.
file = appFiles.getFAQFile();
try
{
// i18n[HelpViewerWindow.faq=FAQ]
DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.faq"), file);
root.add(dn);