{
boolean success = true;
try
{
ToolPlugin plugin;
InputStream configStream = _classLoader.getResourceAsStream(CONFIGURATION_FILENAME);
if (configStream == null)
{
System.err.println("Cannot find the configuration file '" + CONFIGURATION_FILENAME + "' in the tests/config directory");
exitApplication(1);
}
/** Parse the configuration document **/
Document configDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(configStream);
Element configRoot = configDoc.getDocumentElement();
/** Retrieve and parse the look-and-feel node **/
Node lookAndFeelNode = getChildNode(configRoot, LOOK_AND_FEEL_NODE);
if ( lookAndFeelNode != null )
{
/** Set the tool title **/
String title = getChildNode(lookAndFeelNode, TITLE_NODE).getFirstChild().getNodeValue();
if (title != null)
{
this.setTitle(title);
}
/** Set the frame properties **/
Node frameProperties = getChildNode(lookAndFeelNode, FRAME_PROPERTIES_NODE);
if ( frameProperties != null )
{
int width = Integer.parseInt( frameProperties.getAttributes().getNamedItem(WIDTH_ATTRIBUTE).getNodeValue() );
int height = Integer.parseInt( frameProperties.getAttributes().getNamedItem(HEIGHT_ATTRIBUTE).getNodeValue() );
this.setSize(width, height);
}
}
/** Retrieve the plugin configuration nodes **/
Node pluginConfigs = getChildNode(configRoot, PLUGIN_CONFIGURATIONS_NODE);
/** Retrieve the tool plugin information classes for the JARs in the tool lib directory **/
ToolPluginInformation[] plugins = _classLoader.getToolsInformation();
for (int pluginCount=0;pluginCount<plugins.length;pluginCount++)
{
String[] pluginClassname = plugins[pluginCount].getClassnames();
for (int classnameCount=0;classnameCount<pluginClassname.length;classnameCount++)
{
/** Instantiate plugin and add to list **/
plugin = (ToolPlugin) _classLoader.loadClass(pluginClassname[classnameCount]).newInstance();
plugin.setToolsFramework(this);
/** Call initialisers **/
plugin.initialisePlugin(_menuBar, _desktop, plugins[pluginCount].getIcon16(), plugins[pluginCount].getIcon32());
/** Retrieve the tool properties and then override any locally defined properties **/
Properties toolProps = plugins[pluginCount].getProperties();
Properties localProps = getLocalPluginProperties(pluginConfigs, pluginClassname[classnameCount]);
if ( localProps != null )
{
toolProps.putAll( localProps );
}
try
{
plugin.initialise( toolProps );
_plugins.add(plugin);
}
catch (Throwable e)
{
e.printStackTrace();
System.err.println("Error initialising plugin " + plugin.getName());
}
/** See if this plugin has a settings panel, if it does ensure we enable all setting functionality **/
if ( plugin.createSettingsPanel() != null )
{
_hasSettings = true;
}
}
}