View Javadoc

1   /*
2    * $Id: FileCleanerPostRenderer.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  package org.mule.tools.visualizer.postrenderers;
11  
12  import org.mule.tools.visualizer.components.PostRenderer;
13  import org.mule.tools.visualizer.config.GraphEnvironment;
14  
15  import com.oy.shared.lm.graph.Graph;
16  
17  import java.io.File;
18  import java.io.FilenameFilter;
19  import java.util.Map;
20  
21  public class FileCleanerPostRenderer implements PostRenderer
22  {
23  
24      public void postRender(GraphEnvironment env, Map context, Graph graph)
25      {
26          if (!env.getConfig().isKeepDotFiles())
27          {
28              File[] dotFiles = env.getConfig().getOutputDirectory().listFiles(new FilenameFilter()
29              {
30                  public boolean accept(File dir, String name)
31                  {
32                      return name.endsWith(".dot") | name.endsWith(".cmapx");
33                  }
34              });
35              for (int x = 0; x < dotFiles.length; x++)
36              {
37                  dotFiles[x].delete();
38              }
39          }
40      }
41  
42  }