* Install the look and feel
*/
public static void installLaf()
{
try {
SynthLookAndFeel synth = new SynthLookAndFeel();
XProject currentProject = XProjectManager.getCurrentProject();
String synthConfigFile = currentProject.getStartupParam( "SynthConfigFile" );
String synthResourceLoader = currentProject.getStartupParam( "SynthResourceLoader" );
if (( synthResourceLoader == null ) || ( synthResourceLoader.length() == 0 ))
synthResourceLoader = "net.xoetrope.optional.laf.synth.SynthStub";
SynthLafInstaller.class.getClassLoader().getResource( synthResourceLoader );
Class resourceLoader = null;
try {
SynthClassLoader scl = new SynthClassLoader( SynthLafInstaller.class.getClassLoader());
resourceLoader = scl.findClass( synthResourceLoader );
String s = currentProject.getStartupParam( "SynthImageConveter" );
if (( s != null ) && ( s.length() > 0 ))
scl.setConvertClassName( s );
s = currentProject.getStartupParam( "SynthOverwriteImages" );
if (( s != null ) && ( s.length() > 0 ))
scl.setOverwriteImages( Boolean.parseBoolean( s ));
}
catch ( Throwable e ) {
resourceLoader = Class.forName( synthResourceLoader.trim() );
}
//loadStubClass( "net.xoetrope.optional.laf.synth.SynthStub" );
BufferedInputStream bis = null;
// Does the file need processing?
int pos;
if (( pos = synthConfigFile.indexOf( ".xsynth" )) > 0 ) {
String outputFile = synthConfigFile.substring( 0, pos ) + ".synth";
// Try to find a preprocessor for the file, at runtime this load should fail as the preprocessor
// will not be present.
try {
FilePreprocessor processor = (FilePreprocessor)Class.forName( "net.xoetrope.optional.laf.synth.SynthPreprocessor" ).newInstance();
DebugLogger.trace( currentProject.findResourceAsString( synthConfigFile ));
bis = currentProject.getBufferedInputStream ( synthConfigFile );
String processedStr = processor.process( bis );
ByteArrayInputStream bais = new ByteArrayInputStream( processedStr.getBytes() );
bis = new BufferedInputStream( bais );
// Save the config file
outputFile = getOutputPath( currentProject, "resources", synthConfigFile.substring( 0, pos ), ".synth" );
FileWriter fw = new FileWriter( outputFile );
fw.write ( processedStr );
fw.flush();
fw.close();
}
catch ( Exception e )
{
// Assume that the file has previously been processed
bis = currentProject.getBufferedInputStream ( outputFile );
}
}
else
bis = currentProject.getBufferedInputStream ( synthConfigFile );
DebugLogger.log( "Synth config file: " + currentProject.findResourceAsString( synthConfigFile ));
synth.load( bis, resourceLoader );
UIManager.setLookAndFeel( synth );
}
catch ( Exception ex ) {
ex.printStackTrace();
}