}
} catch (Exception ex) {
}
TransformerEngineFactory trefactory = new TransformerEngineFactory (output);
TransformerEngine tre = trefactory.createTransformer(type, outputtype, implementation, direction);
if (tre != null) {
// TODO : Generelisize through usage of interface.... 'IReverseTransformer'
if (tre instanceof DefaultReverseTransformer) {
tre.setOutputDir(gendir);
tre.addTransformationResultListener (new TransformationResultListener(){
public void notifyNewResult (Object result)
{
System.out.println ("Reverse transformation ....");
if (result instanceof String) {
tab.setForegroundAt(RESULT_TAB_INDEX, Color.red);
tab.setEnabledAt(RESULT_TAB_INDEX, true);
fileviewer.setTextOutput ((String)result, "Reverse transformation result");
pimviewer.openHutnReader((String)result);
}
}
public void notifyStarting ()
{}
public void notifyFinished ()
{}
});
tre.setTransformationImpl(implementation);
tre.doTransformation();
} else {
tre.setOutputDir(gendir);
tre.addTransformationResultListener (fileviewer);
tre.addTransformationResultListener (new TransformationResultListener(){
public void notifyNewResult (Object result)
{
tab.setForegroundAt(RESULT_TAB_INDEX, Color.red);
tab.setEnabledAt(RESULT_TAB_INDEX, true);
}
public void notifyStarting ()
{
// output.setColors(Color.black, Color.white);
}
public void notifyFinished ()
{
// output.setColors(Color.white, Color.black);
}
});
String buffer = pimviewer.getHutnBuffer ();
if (buffer == null || buffer.equalsIgnoreCase ("")){
// File inputfile = pimviewer.getHutnFile();
// if (inputfile == null) {
JOptionPane.showMessageDialog (UMTMain.this, "No model loaded.");
return;
}
// System.out.println (buffer);
if (_transformationcontext == null) {
tre.setInputSource (new StringReader(buffer));
} else {
XMLUtility xmlutil = new XMLUtility();
String nodename = _transformationcontext.getNodeName();
String nodeid = _transformationcontext.getAttribute("id");
Document owner = _transformationcontext.getOwnerDocument();
Element docel = owner.getDocumentElement();
StringWriter swriter = new StringWriter ();
XMLUtility.writeNode(_transformationcontext, swriter, 0);
String xmlbuffer = swriter.toString();
// System.out.println (xmlbuffer);
// tre.setInputSource(new StringReader(buffer));
tre.setContext (nodename, nodeid);
tre.setInputSource (new StringReader(xmlbuffer));
}
tre.setTransformationImpl (implementation);
tre.doTransformation ();
_workcontext.setState(WorkContext.STATE_PERFORMED_ACTION);
}
}
} catch (Exception ex){