Package org.sintef.umt.transformer

Examples of org.sintef.umt.transformer.TransformerEngine


        }
        } 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){       
View Full Code Here


        String type = group.getProperty("Type");
        String outputtype = group.getProperty("Outputtype");
        String implementation = group.getProperty("Implementation");
        String direction = group.getProperty("Direction");       
        TransformerEngineFactory trefactory = new TransformerEngineFactory (output, false);
        TransformerEngine tre = trefactory.createTransformer(type, outputtype, implementation, direction);
       
        System.out.println ("Created transformer " + tre);       
        if (tre != null) {
          tre.setOutputDir(outputdir);
          if (xmil == null || xmil.equalsIgnoreCase ("")){
            printError ("No model loaded. Cannot transform.");
            return;
          }
          tre.setInputSource (new java.io.StringReader(xmil));
          tre.setTransformationImpl (implementation);
          tre.setOutputDir(outputdir)
          tre.setOutputFile(outputfile);
          tre.addTransformationResultListener(transformationresultlistener);
          System.out.println ("Doing transformation - with class" + tre.getClass().getName());
          tre.doTransformation ();         
         }
       }
     }
     System.exit(0);
   }
View Full Code Here

TOP

Related Classes of org.sintef.umt.transformer.TransformerEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.