View Javadoc

1   /*
2    * $Id: TransformerProcessor.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.tools.visualizer.processor;
12  
13  import org.mule.tools.visualizer.config.ColorRegistry;
14  import org.mule.tools.visualizer.config.GraphEnvironment;
15  import org.mule.tools.visualizer.util.MuleTag;
16  
17  import com.oy.shared.lm.graph.Graph;
18  import com.oy.shared.lm.graph.GraphNode;
19  
20  import java.util.Iterator;
21  import java.util.List;
22  
23  import org.jdom.Element;
24  
25  public class TransformerProcessor extends TagProcessor
26  {
27      public TransformerProcessor(GraphEnvironment environment)
28      {
29          super(environment);
30      }
31  
32      public void process(Graph graph, Element currentElement, GraphNode parent)
33      {
34          if (!getEnvironment().getConfig().isShowTransformers())
35          {
36              return;
37          }
38  
39          Element transformers = currentElement.getChild(MuleTag.ELEMENT_TRANSFORMERS);
40          if (transformers == null)
41          {
42              return;
43          }
44  
45          List agentsElement = transformers.getChildren(MuleTag.ELEMENT_TRANSFORMER);
46          for (Iterator iter = agentsElement.iterator(); iter.hasNext();)
47          {
48              Element connector = (Element) iter.next();
49              GraphNode connectorNode = graph.addNode();
50              connectorNode.getInfo().setFillColor(ColorRegistry.COLOR_TRANSFORMER);
51              String name = connector.getAttributeValue(MuleTag.ATTRIBUTE_NAME);
52              String returnClass = connector.getAttributeValue(MuleTag.ATTRIBUTE_RETURN_CLASS);
53              connectorNode.getInfo().setHeader(name + ", return: " + returnClass);
54  
55              StringBuffer caption = new StringBuffer();
56  
57              String className = connector.getAttributeValue(MuleTag.ATTRIBUTE_CLASS_NAME);
58              caption.append(MuleTag.ATTRIBUTE_CLASS_NAME + " :" + className + "\n");
59  
60              appendProperties(connector, caption);
61              appendDescription(connector, caption);
62              connectorNode.getInfo().setCaption(caption.toString());
63          }
64      }
65  }