View Javadoc

1   /*
2    * $Id: NodeHiderPostProcessor.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.postprocessors;
12  
13  import org.mule.tools.visualizer.components.PostProcessor;
14  import org.mule.tools.visualizer.config.GraphEnvironment;
15  
16  import com.oy.shared.lm.graph.Graph;
17  import com.oy.shared.lm.graph.GraphNode;
18  
19  public class NodeHiderPostProcessor implements PostProcessor
20  {
21  
22      public void postProcess(Graph graph, GraphEnvironment env)
23      {
24          if (env.getConfig().getMappings().size() > 0)
25          {
26              GraphNode[] nodes = graph.getNodes();
27              for (int i = 0; i < nodes.length; i++)
28              {
29                  GraphNode node = nodes[i];
30                  boolean hide = Boolean.valueOf(
31                      env.getConfig().getMappings().getProperty(node.getInfo().getHeader() + ".hide", "false"))
32                      .booleanValue();
33  
34                  boolean hideWhenCombined = Boolean.valueOf(
35                      env.getConfig().getMappings().getProperty(
36                          node.getInfo().getHeader() + ".hideWhenCombined", "false")).booleanValue();
37                  if (hide || (env.isDoingCombinedGeneration() && hideWhenCombined))
38                  {
39                      env.log("Hiding node '" + node.getInfo().getHeader() + "'");
40                      graph.removeNode(node);
41                  }
42              }
43          }
44      }
45  
46  }