Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP/FunctionView.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP/FunctionView.cs	(revision 645)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP/FunctionView.cs	(revision 654)
@@ -38,9 +38,26 @@
     private IFunctionTree selectedBranch;
     private IVariable selectedVariable;
+    private IFunctionTreeNameGenerator nameGenerator;
+    private IFunctionTreeNameGenerator[] allNameGenerators;
 
-    // private FunctionNameVisitor functionNameVisitor;
     public FunctionTreeView() {
+      nameGenerator = new DefaultFunctionTreeNameGenerator();
       InitializeComponent();
-      // functionNameVisitor = new FunctionNameVisitor();
+
+      DiscoveryService discoveryService = new DiscoveryService();
+      allNameGenerators = discoveryService.GetInstances<IFunctionTreeNameGenerator>();
+
+      foreach(IFunctionTreeNameGenerator generator in allNameGenerators) {
+        ToolStripButton button = new ToolStripButton(generator.Name, null,
+          delegate(object source, EventArgs args) {
+            this.nameGenerator = generator;
+            foreach(ToolStripButton otherButton in representationContextMenu.Items) otherButton.Checked = false;
+            ((ToolStripButton)source).Checked = true;
+            UpdateControls();
+          });
+        if(generator is DefaultFunctionTreeNameGenerator) button.Checked = true;
+        else button.Checked = false;
+        representationContextMenu.Items.Add(button);
+      }
     }
 
@@ -53,9 +70,31 @@
     protected override void UpdateControls() {
       funTreeView.Nodes.Clear();
-      //functionNameVisitor.Visit(functionTree);
       TreeNode rootNode = new TreeNode();
       rootNode.Name = functionTree.Function.Name;
-      //rootNode.Text = functionNameVisitor.Name;
+      rootNode.Text = nameGenerator.GetName(functionTree);
       rootNode.Tag = functionTree;
+      treeNodeContextMenu.Items.Clear();
+      DiscoveryService discoveryService = new DiscoveryService();
+      IFunctionTreeExporter[] exporters = discoveryService.GetInstances<IFunctionTreeExporter>();
+      if(exporters.Length>0)
+        treeNodeContextMenu.Items.Add(new ToolStripSeparator());
+      foreach(IFunctionTreeExporter exporter in exporters) {
+        string result;
+        // register a menu item for the exporter
+        ToolStripItem item = new ToolStripButton("Copy to clip-board (" + exporter.Name + ")", null,
+          delegate(object source, EventArgs args) {
+            TreeNode node = funTreeView.SelectedNode;
+            if(node == null || node.Tag == null) return;
+            Clipboard.SetText(exporter.Export((IFunctionTree)node.Tag));
+          });
+        // try to export the whole tree 
+        if(exporter.TryExport(functionTree, out result)) {
+          // if it worked enable the context-menu item
+          item.Enabled = true;
+        } else {
+          item.Enabled = false;
+        }
+        treeNodeContextMenu.Items.Add(item);
+      }
       rootNode.ContextMenuStrip = treeNodeContextMenu;
       funTreeView.Nodes.Add(rootNode);
@@ -69,7 +108,6 @@
     private void CreateTree(TreeNode rootNode, IFunctionTree functionTree) {
       TreeNode node = new TreeNode();
-      // functionNameVisitor.Visit(functionTree);
       node.Name = functionTree.Function.Name;
-      // node.Text = functionNameVisitor.Name;
+      node.Text = nameGenerator.GetName(functionTree);
       node.Tag = functionTree;
       node.ContextMenuStrip = treeNodeContextMenu;
@@ -88,5 +126,5 @@
         IFunctionTree selectedBranch = (IFunctionTree)funTreeView.SelectedNode.Tag;
         UpdateVariablesList(selectedBranch);
-        templateTextBox.Text = selectedBranch.Function.Name;
+        templateTextBox.Text = nameGenerator.GetName(selectedBranch);
         this.selectedBranch = selectedBranch;
         editButton.Enabled = true;
@@ -122,6 +160,5 @@
       if(funTreeView.SelectedNode != null && funTreeView.SelectedNode.Tag != null) {
         TreeNode node = funTreeView.SelectedNode;
-        // functionNameVisitor.Visit(selectedBranch);
-        // node.Text = functionNameVisitor.Name;
+        node.Text = nameGenerator.GetName(functionTree);
       }
     }
@@ -129,21 +166,4 @@
     protected virtual void editButton_Click(object sender, EventArgs e) {
       PluginManager.ControlManager.ShowControl(selectedBranch.Function.CreateView());
-    }
-
-    private void copyToClipboardMenuItem_Click(object sender, EventArgs e) {
-      TreeNode node = funTreeView.SelectedNode;
-      if(node == null || node.Tag == null) return;
-
-      //ModelAnalyzerExporter visitor = new ModelAnalyzerExporter();
-      //visitor.Visit((IFunctionTree)node.Tag);
-      //Clipboard.SetText(visitor.ModelAnalyzerPrefix);
-    }
-
-    private void copyToClipboardSExpressionToolStripMenuItem_Click(object sender, EventArgs e) {
-      TreeNode node = funTreeView.SelectedNode;
-      if(node == null || node.Tag == null) return;
-
-      //string sexp = ((IFunctionTree)node.Tag).ToString();
-      //Clipboard.SetText(sexp);
     }
 
@@ -154,142 +174,4 @@
       }
     }
-
-    //private class FunctionNameVisitor : IFunctionVisitor {
-    //  string name;
-    //  IFunctionTree currentBranch;
-
-    //  public string Name {
-    //    get { return name; }
-    //  }
-
-    //  public void Visit(IFunctionTree tree) {
-    //    currentBranch = tree;
-    //    tree.Function.Accept(this);
-    //  }
-
-    //  #region IFunctionVisitor Members
-    //  public void Visit(IFunction function) {
-    //    name = function.Name;
-    //  }
-
-    //  public void Visit(Addition addition) {
-    //    name = "+";
-    //  }
-
-    //  public void Visit(Constant constant) {
-    //    name = ((ConstrainedDoubleData)(currentBranch.GetLocalVariable(HeuristicLab.Functions.Constant.VALUE).Value)).Data + "";
-    //  }
-
-    //  public void Visit(Cosinus cosinus) {
-    //    name = "Sin";
-    //  }
-
-    //  public void Visit(Differential diff) {
-    //    string timeOffset = "";
-    //    int sampleOffset = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.OFFSET).Value).Data;
-    //    int variableIndex = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.INDEX).Value).Data;
-    //    double weight = ((ConstrainedDoubleData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.WEIGHT).Value).Data;
-    //    if(sampleOffset < 0) {
-    //      timeOffset = "(t" + sampleOffset + ")";
-    //    } else if(sampleOffset > 0) {
-    //      timeOffset = "(t+" + sampleOffset + ")";
-    //    } else {
-    //      timeOffset = "";
-    //    }
-    //    name = "Diff" + variableIndex + timeOffset + " * " + weight;
-    //  }
-
-    //  public void Visit(Division division) {
-    //    name = "/";
-    //  }
-
-    //  public void Visit(Exponential exponential) {
-    //    name = "Exp";
-    //  }
-
-    //  public void Visit(Logarithm logarithm) {
-    //    name = "Log";
-    //  }
-
-    //  public void Visit(Multiplication multiplication) {
-    //    name = "*";
-    //  }
-
-    //  public void Visit(Power power) {
-    //    name = "Pow";
-    //  }
-
-    //  public void Visit(Signum signum) {
-    //    name = "Sign";
-    //  }
-
-    //  public void Visit(Sinus sinus) {
-    //    name = "Sin";
-    //  }
-
-    //  public void Visit(Sqrt sqrt) {
-    //    name = "Sqrt";
-    //  }
-
-    //  public void Visit(Subtraction substraction) {
-    //    name = "-";
-    //  }
-
-    //  public void Visit(Tangens tangens) {
-    //    name = "Tan";
-    //  }
-
-    //  public void Visit(Variable variable) {
-    //    string timeOffset = "";
-    //    int sampleOffset = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Variable.OFFSET).Value).Data;
-    //    int variableIndex = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Variable.INDEX).Value).Data;
-    //    double weight = ((ConstrainedDoubleData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Variable.WEIGHT).Value).Data;
-    //    if(sampleOffset < 0) {
-    //      timeOffset = "(t" + sampleOffset + ")";
-    //    } else if(sampleOffset > 0) {
-    //      timeOffset = "(t+" + sampleOffset + ")";
-    //    } else {
-    //      timeOffset = "";
-    //    }
-    //    name = "Var" + variableIndex + timeOffset + " * " + weight;
-    //  }
-
-    //  public void Visit(And and) {
-    //    name = "And";
-    //  }
-
-    //  public void Visit(Average average) {
-    //    name = "Avg";
-    //  }
-
-    //  public void Visit(IfThenElse ifThenElse) {
-    //    name = "IFTE";
-    //  }
-
-    //  public void Visit(Not not) {
-    //    name = "Not";
-    //  }
-
-    //  public void Visit(Or or) {
-    //    name = "Or";
-    //  }
-
-    //  public void Visit(Xor xor) {
-    //    name = "Xor";
-    //  }
-
-    //  public void Visit(Equal equal) {
-    //    name = "eq?";
-    //  }
-
-    //  public void Visit(LessThan lessThan) {
-    //    name = "<";
-    //  }
-
-    //  public void Visit(GreaterThan greaterThan) {
-    //    name = ">";
-    //  }
-    //  #endregion
-    //}
   }
 }
