Index: trunk/sources/HeuristicLab 3.3.sln
===================================================================
--- trunk/sources/HeuristicLab 3.3.sln	(revision 2798)
+++ trunk/sources/HeuristicLab 3.3.sln	(revision 2799)
@@ -136,4 +136,10 @@
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Routing.TSP.Views-3.3", "HeuristicLab.Routing.TSP.Views\3.3\HeuristicLab.Routing.TSP.Views-3.3.csproj", "{DF2E61C4-A76D-4315-9D0B-53A077B1AC2C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.CodeEditor-3.2", "HeuristicLab.CodeEditor\3.2\HeuristicLab.CodeEditor-3.2.csproj", "{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HeuristicLab.SharpDevelop", "HeuristicLab.SharpDevelop", "{F94E41E4-F25F-4302-8486-0BEF121CF5C8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.SharpDevelop-3.1.1.5327", "HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327\HeuristicLab.SharpDevelop-3.1.1.5327.csproj", "{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}"
 EndProject
 Global
@@ -589,4 +595,28 @@
 		{DF2E61C4-A76D-4315-9D0B-53A077B1AC2C}.Release|x64.ActiveCfg = Release|Any CPU
 		{DF2E61C4-A76D-4315-9D0B-53A077B1AC2C}.Release|x86.ActiveCfg = Release|Any CPU
+		{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}.Debug|x64.ActiveCfg = Debug|x64
+		{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}.Debug|x64.Build.0 = Debug|x64
+		{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}.Debug|x86.ActiveCfg = Debug|x86
+		{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}.Debug|x86.Build.0 = Debug|x86
+		{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}.Release|Any CPU.Build.0 = Release|Any CPU
+		{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}.Release|x64.ActiveCfg = Release|x64
+		{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}.Release|x64.Build.0 = Release|x64
+		{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}.Release|x86.ActiveCfg = Release|x86
+		{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}.Release|x86.Build.0 = Release|x86
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Debug|x64.ActiveCfg = Debug|x64
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Debug|x64.Build.0 = Debug|x64
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Debug|x86.ActiveCfg = Debug|x86
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Debug|x86.Build.0 = Debug|x86
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Release|Any CPU.Build.0 = Release|Any CPU
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Release|x64.ActiveCfg = Release|x64
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Release|x64.Build.0 = Release|x64
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Release|x86.ActiveCfg = Release|x86
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1}.Release|x86.Build.0 = Release|x86
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
@@ -597,4 +627,5 @@
 		{BA3315A3-9D7C-4F5F-99F4-1C9B88FD32AE} = {07BCBC57-3E15-4582-B306-C046E516C49C}
 		{27D3A83C-DEEA-49DA-955E-65D3D703B2F1} = {07BCBC57-3E15-4582-B306-C046E516C49C}
+		{F94E41E4-F25F-4302-8486-0BEF121CF5C8} = {07BCBC57-3E15-4582-B306-C046E516C49C}
 		{99AD3658-DB36-4E26-B4CC-6FEAACC5C88C} = {7F485A48-A80F-4454-9A9B-7B126B43861C}
 		{678E2145-8152-4E19-9646-07D439D00301} = {99AD3658-DB36-4E26-B4CC-6FEAACC5C88C}
@@ -604,4 +635,5 @@
 		{96AEBBEE-4203-45F3-BCF5-7B73BF256BDA} = {0A3CE05D-4FCD-40A4-9001-D57627554BBC}
 		{BB994448-2B21-4564-BB2E-38D8FFF8CF18} = {0A3CE05D-4FCD-40A4-9001-D57627554BBC}
+		{4ABA047D-46DD-4608-9E4A-41C5F92FDBB1} = {F94E41E4-F25F-4302-8486-0BEF121CF5C8}
 	EndGlobalSection
 EndGlobal
Index: trunk/sources/HeuristicLab 3.3/Files.txt
===================================================================
--- trunk/sources/HeuristicLab 3.3/Files.txt	(revision 2798)
+++ trunk/sources/HeuristicLab 3.3/Files.txt	(revision 2799)
@@ -6,4 +6,5 @@
 HeuristicLab.Charting\3.3:HeuristicLab.Charting-3.3.dll 
 HeuristicLab.Charting.Data\3.3:HeuristicLab.Charting.Data-3.3.dll 
+HeuristicLab.CodeEditor\3.2:HeuristicLab.CodeEditor-3.2.dll
 HeuristicLab.Collections\3.3:HeuristicLab.Collections-3.3.dll 
 HeuristicLab.Common\3.2:HeuristicLab.Common-3.2.dll  
@@ -51,2 +52,10 @@
 HeuristicLab.ExtLibs\HeuristicLab.WinFormsUI\2.3.1\HeuristicLab.WinFormsUI-2.3.1:HeuristicLab.WinFormsUI-2.3.1.dll
 HeuristicLab.ExtLibs\HeuristicLab.WinFormsUI\2.3.1\HeuristicLab.WinFormsUI-2.3.1:WeifenLuo.WinFormsUI.Docking License.txt
+
+HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327:HeuristicLab.SharpDevelop-3.1.1.5327.dll
+HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327:ICSharpCode.NRefactory.dll
+HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327:ICSharpCode.SharpDevelop.Dom.dll
+HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327:ICSharpCode.TextEditor.dll
+HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327:Mono.Cecil.dll
+HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327:Mono License.txt
+HeuristicLab.ExtLibs\HeuristicLab.SharpDevelop\3.1.1.5327:SharpDevelop License.txt
Index: trunk/sources/HeuristicLab.Operators.Programmable/3.3/HeuristicLab.Operators.Programmable-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.Operators.Programmable/3.3/HeuristicLab.Operators.Programmable-3.3.csproj	(revision 2798)
+++ trunk/sources/HeuristicLab.Operators.Programmable/3.3/HeuristicLab.Operators.Programmable-3.3.csproj	(revision 2799)
@@ -85,4 +85,5 @@
   </ItemGroup>
   <ItemGroup>
+    <None Include="HeuristicLabOperatorsProgrammablePlugin.cs.frame" />
     <Compile Include="HeuristicLabOperatorsProgrammablePlugin.cs" />
     <Compile Include="ProgrammableOperator.cs" />
@@ -100,4 +101,12 @@
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\HeuristicLab.CodeEditor\3.2\HeuristicLab.CodeEditor-3.2.csproj">
+      <Project>{489CFE09-FDF7-4C89-BAB5-BD09CADD61AD}</Project>
+      <Name>HeuristicLab.CodeEditor-3.2</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
+      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
+      <Name>HeuristicLab.Collections-3.3</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.Core.Views\3.3\HeuristicLab.Core.Views-3.3.csproj">
       <Project>{E226881D-315F-423D-B419-A766FE0D8685}</Project>
@@ -153,5 +162,6 @@
 set Outdir=$(Outdir)
 
-call PreBuildEvent.cmd</PreBuildEvent>
+call PreBuildEvent.cmd
+SubWCRev "%25ProjectDir%25\" "%25ProjectDir%25\HeuristicLabOperatorsProgrammablePlugin.cs.frame" "%25ProjectDir%25\HeuristicLabOperatorsProgrammablePlugin.cs"</PreBuildEvent>
   </PropertyGroup>
 </Project>
Index: trunk/sources/HeuristicLab.Operators.Programmable/3.3/HeuristicLabOperatorsProgrammablePlugin.cs
===================================================================
--- trunk/sources/HeuristicLab.Operators.Programmable/3.3/HeuristicLabOperatorsProgrammablePlugin.cs	(revision 2798)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using HeuristicLab.PluginInfrastructure;
-
-namespace HeuristicLab.Operators.Programmable {
-  [ClassInfo(Name = "HeuristicLab.Operators.Programmable-3.3")]
-  [PluginFile(Filename = "HeuristicLab.Operators.Programmable-3.3.dll", Filetype = PluginFileType.Assembly)]
-  [Dependency(Dependency = "HeuristicLab.Core-3.3")]
-  [Dependency(Dependency = "HeuristicLab.Core.Views-3.3")]
-  [Dependency(Dependency = "HeuristicLab.Data-3.3")]
-  [Dependency(Dependency = "HeuristicLab.MainForm-3.2")]
-  [Dependency(Dependency = "HeuristicLab.MainForm.WindowsForms-3.2")]
-  [Dependency(Dependency = "HeuristicLab.Operators-3.3")]
-  [Dependency(Dependency = "HeuristicLab.Persistence-3.3")]
-  public class HeuristicLabOperatorsProgrammablePlugin : PluginBase {
-  }
-}
Index: trunk/sources/HeuristicLab.Operators.Programmable/3.3/HeuristicLabOperatorsProgrammablePlugin.cs.frame
===================================================================
--- trunk/sources/HeuristicLab.Operators.Programmable/3.3/HeuristicLabOperatorsProgrammablePlugin.cs.frame	(revision 2799)
+++ trunk/sources/HeuristicLab.Operators.Programmable/3.3/HeuristicLabOperatorsProgrammablePlugin.cs.frame	(revision 2799)
@@ -0,0 +1,39 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.Operators.Programmable {
+  [Plugin("HeuristicLab.Operators.Programmable", "3.3.0.$WCREV$")]
+  [PluginFile("HeuristicLab.Operators.Programmable-3.3.dll", PluginFileType.Assembly)]
+  [PluginDependency("HeuristicLab.CodeEditor-3.2")]
+  [PluginDependency("HeuristicLab.Collections", "3.3")]
+  [PluginDependency("HeuristicLab.Core", "3.3")]
+  [PluginDependency("HeuristicLab.Core.Views", "3.3")]  
+  [PluginDependency("HeuristicLab.Data", "3.3")]
+  [PluginDependency("HeuristicLab.Operators", "3.3")]
+  [PluginDependency("HeuristicLab.Persistence", "3.3")]
+  public class HeuristicLabOperatorsProgrammablePlugin : PluginBase {
+  }
+}
Index: trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs
===================================================================
--- trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs	(revision 2798)
+++ trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs	(revision 2799)
@@ -34,23 +34,25 @@
 using HeuristicLab.Data;
 using System.Data.Linq;
+using System.Xml.XPath;
+using HeuristicLab.PluginInfrastructure;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 
 namespace HeuristicLab.Operators.Programmable {
-  public class ProgrammableOperator : OperatorBase {
+
+  public class ProgrammableOperator : Operator {
+
+    #region Fields & Properties
+
     private MethodInfo executeMethod;
-
+    public CompilerErrorCollection CompileErrors { get; private set; }
+    public string CompilationUnitCode { get; private set; }
+    
     [Storable]
-    private string myDescription;
-    public override string Description {
-      get { return myDescription; }
-    }
-
-    [Storable]
-    private string myCode;    
+    private string code;
     public string Code {
-      get { return myCode; }
+      get { return code; }
       set {
-        if (value != myCode) {
-          myCode = value;
+        if (value != code) {
+          code = value;
           executeMethod = null;
           OnCodeChanged();
@@ -61,86 +63,225 @@
     private object syncRoot = new object();
 
-    public ProgrammableOperator() {
-      myCode = "Result.Data = true;";
-      myDescription = "An operator that can be programmed for arbitrary needs.";
-      AddVariableInfo(new VariableInfo("Result", "A computed variable", typeof(BoolData), VariableKind.New | VariableKind.Out));
-      executeMethod = null;
+    private static object initLock = new object();
+    private static Dictionary<string, List<Assembly>> defaultPluginDict;
+    private static Dictionary<Assembly, bool> defaultAssemblyDict;
+
+    public readonly Dictionary<string, List<Assembly>> Plugins;
+
+    protected Dictionary<Assembly, bool> Assemblies;
+
+    [Storable]
+    private IEnumerable<string> _persistedAssemblyNames {      
+      get {        
+        return Assemblies.Keys.Select(a => a.FullName);
+      }
+      set {
+        var selectedAssemblyNames = new HashSet<string>(value);        
+        foreach (var a in Assemblies.Keys.ToList()) {
+          Assemblies[a] = selectedAssemblyNames.Contains(a.FullName);
+        }      
+      }
+    }
+
+    public IEnumerable<Assembly> AvailableAssemblies {
+      get { return Assemblies.Keys; }
+    }
+
+    public IEnumerable<Assembly> SelectedAssemblies {
+      get { return Assemblies.Where(kvp => kvp.Value).Select(kvp => kvp.Key); }
+    }
+
+    [Storable]
+    private HashSet<string> namespaces;
+    public IEnumerable<string> Namespaces {
+      get { return namespaces; }
+    }
+
+    #endregion
+
+    #region Extended Accessors
+
+    public void SelectAssembly(Assembly a) {
+      if (a != null && Assemblies.ContainsKey(a))
+        Assemblies[a] = true;
+    }
+
+    public void UnselectAssembly(Assembly a) {
+      if (a != null && Assemblies.ContainsKey(a))
+        Assemblies[a] = false;
+    }
+
+    public void SelectNamespace(string ns) {
+      namespaces.Add(ns);
+    }
+
+    public void UnselectNamespace(string ns) {
+      namespaces.Remove(ns);
     }
 
     public void SetDescription(string description) {
       if (description == null)
-        throw new NullReferenceException("description must not be null");
-
-      if (description != myDescription) {
-        myDescription = description;
-        OnDescriptionChanged();
-      }
-    }
-
-    public virtual void Compile() {
-      CodeNamespace ns = new CodeNamespace("HeuristicLab.Operators.Programmable.CustomOperators");
-      CodeTypeDeclaration typeDecl = new CodeTypeDeclaration("Operator");
-      typeDecl.IsClass = true;
-      typeDecl.TypeAttributes = TypeAttributes.Public;
-
-      CodeMemberMethod method = new CodeMemberMethod();
-      method.Name = "Execute";
-      method.ReturnType = new CodeTypeReference(typeof(IOperation));
-      method.Attributes = MemberAttributes.Public | MemberAttributes.Static;
-      method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IOperator), "op"));
-      method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IScope), "scope"));
-      foreach (IVariableInfo info in VariableInfos)
-        method.Parameters.Add(new CodeParameterDeclarationExpression(info.DataType, info.FormalName));
-      string code = myCode + "\r\n" + "return null;";
-      method.Statements.Add(new CodeSnippetStatement(code));
-      typeDecl.Members.Add(method);
-
-      ns.Types.Add(typeDecl);
-      ns.Imports.Add(new CodeNamespaceImport("System"));
-      ns.Imports.Add(new CodeNamespaceImport("System.Collections.Generic"));
-      ns.Imports.Add(new CodeNamespaceImport("System.Text"));
-      ns.Imports.Add(new CodeNamespaceImport("System.Linq"));
-      ns.Imports.Add(new CodeNamespaceImport("System.Data.Linq"));
-      ns.Imports.Add(new CodeNamespaceImport("HeuristicLab.Core"));
-      foreach (IVariableInfo variableInfo in VariableInfos)
-        ns.Imports.Add(new CodeNamespaceImport(variableInfo.DataType.Namespace));
-
-      CodeCompileUnit unit = new CodeCompileUnit();
-      unit.Namespaces.Add(ns);
+        throw new NullReferenceException("description must not be null");            
+      Description = description;              
+    }
+
+    public IEnumerable<string> GetAllNamespaces(bool selectedAssembliesOnly) {
+      var namespaces = new HashSet<string>();
+      foreach (var a in Assemblies) {
+        if (!selectedAssembliesOnly || a.Value) {
+          foreach (var t in a.Key.GetTypes()) {
+            if (t.IsPublic) {
+              foreach (string ns in GetNamespaceHierachy(t.Namespace)) {
+                namespaces.Add(ns);
+              }
+            }
+          }
+        }
+      }
+      return namespaces;
+    }
+
+    private IEnumerable<string> GetNamespaceHierachy(string ns) {
+      for (int i = ns.Length; i != -1; i = ns.LastIndexOf('.', i - 1)) {
+        yield return ns.Substring(0, i);
+      }
+    }
+
+    #endregion
+
+    #region Construction & Initialization
+
+    public ProgrammableOperator() {      
+      code = "";
+      Description = "An operator that can be programmed for arbitrary needs.";
+      executeMethod = null;
+      ProgrammableOperator.StaticInitialize();
+      Assemblies = defaultAssemblyDict;
+      Plugins = defaultPluginDict;
+      namespaces = new HashSet<string>(DiscoverNamespaces());
+    }
+
+    private static void StaticInitialize() {
+      lock (initLock) {
+        if (defaultPluginDict != null || defaultAssemblyDict != null) return;
+        defaultAssemblyDict = DiscoverAssemblies();
+        defaultPluginDict = GroupAssemblies(defaultAssemblyDict.Keys);
+      }
+    }
+
+    private static Dictionary<string, List<Assembly>> GroupAssemblies(IEnumerable<Assembly> assemblies) {
+      var plugins = new Dictionary<string, List<Assembly>>();
+      var locationTable = assemblies.ToDictionary(a => a.Location, a => a);
+      foreach (var plugin in ApplicationManager.Manager.Plugins) {
+        var aList = new List<Assembly>();
+        foreach (var aName in from file in plugin.Files
+                              where file.Type == PluginFileType.Assembly
+                              select file.Name) {
+          Assembly a;
+          locationTable.TryGetValue(aName, out a);
+          if (a != null) {
+            aList.Add(a);
+            locationTable.Remove(aName);
+          }
+        }
+        plugins[plugin.Name] = aList;
+      }
+      plugins["other"] = locationTable.Values.ToList();
+      return plugins;
+    }
+
+    protected static List<Assembly> defaultAssemblies = new List<Assembly>() {      
+      typeof(System.Linq.Enumerable).Assembly,  // add reference to version 3.5 of System.dll
+      typeof(System.Collections.Generic.List<>).Assembly,
+      typeof(System.Text.StringBuilder).Assembly,      
+      typeof(System.Data.Linq.DataContext).Assembly,
+      typeof(HeuristicLab.Core.Item).Assembly,      
+      typeof(HeuristicLab.Data.IntData).Assembly,            
+    };
+
+    protected static Dictionary<Assembly, bool> DiscoverAssemblies() {
+      var assemblies = new Dictionary<Assembly, bool>();
+      foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) {
+        try {
+          if (File.Exists(a.Location)) {
+            assemblies.Add(a, false);
+          }
+        }
+        catch (NotSupportedException) {
+          // NotSupportedException is thrown while accessing 
+          // the Location property of the anonymously hosted
+          // dynamic methods assembly, which is related to
+          // LINQ queries
+        }
+      }
+      foreach (var a in defaultAssemblies) {
+        if (assemblies.ContainsKey(a)) {
+          assemblies[a] = true;
+        } else {
+          assemblies.Add(a, true);
+        }
+      }
+      return assemblies;
+    }
+
+    protected static List<string> DiscoverNamespaces() {
+      return new List<string>() {
+        "System",
+        "System.Collections.Generic",
+        "System.Text",
+        "System.Linq",
+        "System.Data.Linq",
+        "HeuristicLab.Core",
+        "HeuristicLab.Data",
+      };
+    }
+
+    #endregion
+
+    #region Compilation
+
+    private static CSharpCodeProvider codeProvider =
+      new CSharpCodeProvider(
+        new Dictionary<string, string>() {
+          { "CompilerVersion", "v3.5" },  // support C# 3.0 syntax
+        });
+
+    private CompilerResults DoCompile() {
       CompilerParameters parameters = new CompilerParameters();
       parameters.GenerateExecutable = false;
       parameters.GenerateInMemory = true;
       parameters.IncludeDebugInformation = false;
-      Assembly[] loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
-      foreach (Assembly loadedAssembly in loadedAssemblies)
-        parameters.ReferencedAssemblies.Add(loadedAssembly.Location);
-      parameters.ReferencedAssemblies.Add(typeof(Enumerable).Assembly.Location); // add reference to version 3.5 of System.dll
-      parameters.ReferencedAssemblies.Add(typeof(DataContext).Assembly.Location); // add reference System.Data.Linq.Dll
-      CodeDomProvider provider = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", "v3.5" } });  // support C# 3.0 syntax
-      CompilerResults results = provider.CompileAssemblyFromDom(parameters, unit);
-
+      parameters.ReferencedAssemblies.AddRange(SelectedAssemblies.Select(a => a.Location).ToArray());
+      var unit = CreateCompilationUnit();
+      var writer = new StringWriter();
+      codeProvider.GenerateCodeFromCompileUnit(
+        unit,
+        writer,
+        new CodeGeneratorOptions() {
+          BracingStyle = "C",
+          ElseOnClosing = true,
+          IndentString = "  ",
+        });
+      CompilationUnitCode = writer.ToString();
+      return codeProvider.CompileAssemblyFromDom(parameters, unit);
+    }
+
+    public virtual void Compile() {
+      var results = DoCompile();
       executeMethod = null;
       if (results.Errors.HasErrors) {
-        StringWriter writer = new StringWriter();
-        CodeGeneratorOptions options = new CodeGeneratorOptions();
-        options.BlankLinesBetweenMembers = false;
-        options.ElseOnClosing = true;
-        options.IndentString = "  ";
-        provider.GenerateCodeFromCompileUnit(unit, writer, options);
-        writer.Flush();
-        string[] source = writer.ToString().Split(new string[] { "\r\n" }, StringSplitOptions.None);
-        StringBuilder builder = new StringBuilder();
-        for (int i = 0; i < source.Length; i++)
-          builder.AppendLine((i + 3).ToString("###") + "     " + source[i]);
-        builder.AppendLine();
-        builder.AppendLine();
-        builder.AppendLine();
+        CompileErrors = results.Errors;
+        StringBuilder sb = new StringBuilder();
         foreach (CompilerError error in results.Errors) {
-          builder.Append("Line " + error.Line.ToString());
-          builder.Append(", Column " + error.Column.ToString());
-          builder.AppendLine(": " + error.ErrorText);
-        }
-        throw new Exception("Compile Errors:\n\n" + builder.ToString());
+          sb.Append(error.Line).Append(':')
+            .Append(error.Column).Append(": ")
+            .AppendLine(error.ErrorText);
+        }
+        throw new Exception(string.Format(
+          "Compilation of \"{0}\" failed:{1}{2}",
+          Name, Environment.NewLine,
+          sb.ToString()));
       } else {
+        CompileErrors = null;
         Assembly assembly = results.CompiledAssembly;
         Type[] types = assembly.GetTypes();
@@ -149,13 +290,82 @@
     }
 
-    public override IItem Clone(ICloner cloner) {
-      ProgrammableOperator clone = (ProgrammableOperator)base.Clone(cloner);
-      clone.myDescription = Description;
-      clone.myCode = Code;
-      clone.executeMethod = executeMethod;
-      return clone;
-    }
-
-    public override IOperation Apply(IScope scope) {
+    private CodeCompileUnit CreateCompilationUnit() {
+      CodeNamespace ns = new CodeNamespace("HeuristicLab.Operators.Programmable.CustomOperators");
+      ns.Types.Add(CreateType());
+      ns.Imports.AddRange(
+        GetSelectedAndValidNamespaces()
+        .Select(n => new CodeNamespaceImport(n))
+        .ToArray());
+      CodeCompileUnit unit = new CodeCompileUnit();
+      unit.Namespaces.Add(ns);
+      return unit;
+    }
+
+    public IEnumerable<string> GetSelectedAndValidNamespaces() {
+      var possibleNamespaces = new HashSet<string>(GetAllNamespaces(true));
+      foreach (var ns in Namespaces)
+        if (possibleNamespaces.Contains(ns))
+          yield return ns;
+    }
+
+    public static readonly Regex SafeTypeNameCharRegex = new Regex("[_a-zA-Z0-9]+");
+    public static readonly Regex SafeTypeNameRegex = new Regex("[_a-zA-Z][_a-zA-Z0-9]*");
+
+    public string CompiledTypeName {
+      get {
+        var sb = new StringBuilder();
+        foreach (string s in SafeTypeNameCharRegex.Matches(Name).Cast<Match>().Select(m => m.Value)) {
+          sb.Append(s);
+        }
+        return SafeTypeNameRegex.Match(sb.ToString()).Value;
+      }
+    }
+
+    private CodeTypeDeclaration CreateType() {
+      CodeTypeDeclaration typeDecl = new CodeTypeDeclaration(CompiledTypeName) {
+        IsClass = true,
+        TypeAttributes = TypeAttributes.Public,
+      };
+      typeDecl.Members.Add(CreateMethod());
+      return typeDecl;
+    }
+
+    public string Signature {
+      get {
+        var sb = new StringBuilder()
+        .Append("public static IOperation Execute(IOperator op, IScope scope");        
+        foreach (IParameter param in Parameters) {
+          sb.Append(String.Format(", {0} {1}", param.DataType.Name, param.Name));
+        }        
+        return sb.Append(")").ToString();
+      }
+    }
+
+    private static Regex lineSplitter = new Regex(@"\r\n|\r|\n");
+
+    private CodeMemberMethod CreateMethod() {
+      CodeMemberMethod method = new CodeMemberMethod();
+      method.Name = "Execute";
+      method.ReturnType = new CodeTypeReference(typeof(HeuristicLab.Core.IExecutionSequence));
+      method.Attributes = MemberAttributes.Public | MemberAttributes.Static;
+      method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IOperator), "op"));
+//      method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IScope), "scope"));
+      foreach (var param in Parameters)
+        method.Parameters.Add(new CodeParameterDeclarationExpression(param.DataType, param.Name));
+      string[] codeLines = lineSplitter.Split(code);
+      for (int i = 0; i < codeLines.Length; i++) {
+        codeLines[i] = string.Format("#line {0} \"ProgrammableOperator\"{1}{2}", i + 1, "\r\n", codeLines[i]);
+      }
+      method.Statements.Add(new CodeSnippetStatement(
+        string.Join("\r\n", codeLines) +
+        "\r\nreturn null;"));
+      return method;
+    }
+
+    #endregion
+
+    #region HeuristicLab interfaces
+    
+    public override IExecutionSequence Apply() {
       lock (syncRoot) {
         if (executeMethod == null) {
@@ -164,34 +374,9 @@
       }
 
-      // collect parameters
-      object[] parameters = new object[VariableInfos.Count + 2];
-      parameters[0] = this;
-      parameters[1] = scope;
-      int i = 2;
-      foreach (IVariableInfo info in VariableInfos) {
-        if ((info.Kind & VariableKind.New) == VariableKind.New) {
-          parameters[i] = GetVariableValue(info.FormalName, scope, false, false);
-          if (parameters[i] == null) {
-            IItem value = (IItem)Activator.CreateInstance(info.DataType);
-            if (info.Local) {
-              AddVariable(new Variable(info.ActualName, value));
-            } else {
-              scope.AddVariable(new Variable(scope.TranslateName(info.FormalName), value));
-            }
-            parameters[i] = value;
-          }
-        } else
-          parameters[i] = GetVariableValue(info.FormalName, scope, true);
-        i++;
-      }
-
-      return (IOperation)executeMethod.Invoke(null, parameters);
-    }
-
-    public event EventHandler DescriptionChanged;
-    protected virtual void OnDescriptionChanged() {
-      if (DescriptionChanged != null)
-        DescriptionChanged(this, new EventArgs());
-    }
+      var parameters = new List<object>() { this };      
+      parameters.AddRange(Parameters.Select(p => (object)p.ActualValue));
+      return (IExecutionSequence)executeMethod.Invoke(null, parameters.ToArray());
+    }
+    
     public event EventHandler CodeChanged;
     protected virtual void OnCodeChanged() {
@@ -199,4 +384,23 @@
         CodeChanged(this, new EventArgs());
     }
+
+    #endregion
+
+    #region Cloning        
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      ProgrammableOperator clone = (ProgrammableOperator)base.Clone(cloner);
+      clone.Description = Description;
+      clone.code = Code;
+      clone.executeMethod = executeMethod;
+      clone.Assemblies = Assemblies.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
+      clone.namespaces = namespaces;
+      clone.CompilationUnitCode = CompilationUnitCode;
+      clone.CompileErrors = CompileErrors;
+      return clone;
+    }
+    
+    #endregion
+   
   }
 }
Index: trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.Designer.cs	(revision 2798)
+++ trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.Designer.cs	(revision 2799)
@@ -45,24 +45,165 @@
     /// </summary>
     private void InitializeComponent() {
-      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProgrammableOperatorView));
+      System.Windows.Forms.SplitContainer splitContainer1;
+      System.Windows.Forms.SplitContainer splitContainer2;
+      System.Windows.Forms.GroupBox groupBox1;
+      System.Windows.Forms.GroupBox groupBox2;
+      this.assembliesTreeView = new System.Windows.Forms.TreeView();
+      this.groupBox3 = new System.Windows.Forms.GroupBox();
+      this.showCodeButton = new System.Windows.Forms.Button();
+      this.codeEditor = new HeuristicLab.CodeEditor.CodeEditor();
+      this.compileButton = new System.Windows.Forms.Button();
       this.tabControl = new System.Windows.Forms.TabControl();
       this.codeTabPage = new System.Windows.Forms.TabPage();
-      this.infoTextBox = new System.Windows.Forms.TextBox();
-      this.compileButton = new System.Windows.Forms.Button();
-      this.codeTextBox = new System.Windows.Forms.TextBox();
       this.variableInfosTabPage = new System.Windows.Forms.TabPage();
       this.removeVariableInfoButton = new System.Windows.Forms.Button();
       this.addVariableInfoButton = new System.Windows.Forms.Button();
-      this.operatorBaseVariableInfosView = new HeuristicLab.Core.Views.OperatorBaseVariableInfosView();
+      //this.operatorBaseVariableInfosView = new HeuristicLab.Core.OperatorBaseVariableInfosView();
       this.variablesTabPage = new System.Windows.Forms.TabPage();
-      this.operatorBaseVariablesView = new HeuristicLab.Core.Views.OperatorBaseVariablesView();
+      //this.operatorBaseVariablesView = new HeuristicLab.Core.OperatorBaseVariablesView();
+      this.constraintsTabPage = new System.Windows.Forms.TabPage();
+      //this.constrainedItemBaseView = new HeuristicLab.Core.ConstrainedItemBaseView();
       this.descriptionTabPage = new System.Windows.Forms.TabPage();
-      this.descriptionTextBox = new System.Windows.Forms.TextBox();
+      //this.descriptionTextBox = new System.Windows.Forms.TextBox();
+      this.namespacesTreeView = new System.Windows.Forms.TreeView();
+      splitContainer1 = new System.Windows.Forms.SplitContainer();
+      splitContainer2 = new System.Windows.Forms.SplitContainer();
+      groupBox1 = new System.Windows.Forms.GroupBox();
+      groupBox2 = new System.Windows.Forms.GroupBox();
+      splitContainer1.Panel1.SuspendLayout();
+      splitContainer1.Panel2.SuspendLayout();
+      splitContainer1.SuspendLayout();
+      splitContainer2.Panel1.SuspendLayout();
+      splitContainer2.Panel2.SuspendLayout();
+      splitContainer2.SuspendLayout();
+      groupBox1.SuspendLayout();
+      groupBox2.SuspendLayout();
+      this.groupBox3.SuspendLayout();
       this.tabControl.SuspendLayout();
       this.codeTabPage.SuspendLayout();
       this.variableInfosTabPage.SuspendLayout();
       this.variablesTabPage.SuspendLayout();
+      this.constraintsTabPage.SuspendLayout();
       this.descriptionTabPage.SuspendLayout();
       this.SuspendLayout();
+      // 
+      // splitContainer1
+      // 
+      splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
+      splitContainer1.Location = new System.Drawing.Point(3, 3);
+      splitContainer1.Name = "splitContainer1";
+      splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
+      // 
+      // splitContainer1.Panel1
+      // 
+      splitContainer1.Panel1.Controls.Add(splitContainer2);
+      // 
+      // splitContainer1.Panel2
+      // 
+      splitContainer1.Panel2.Controls.Add(this.groupBox3);
+      splitContainer1.Size = new System.Drawing.Size(693, 457);
+      splitContainer1.SplitterDistance = 85;
+      splitContainer1.TabIndex = 6;
+      // 
+      // splitContainer2
+      // 
+      splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
+      splitContainer2.Location = new System.Drawing.Point(0, 0);
+      splitContainer2.Name = "splitContainer2";
+      // 
+      // splitContainer2.Panel1
+      // 
+      splitContainer2.Panel1.Controls.Add(groupBox1);
+      // 
+      // splitContainer2.Panel2
+      // 
+      splitContainer2.Panel2.Controls.Add(groupBox2);
+      splitContainer2.Size = new System.Drawing.Size(693, 85);
+      splitContainer2.SplitterDistance = 340;
+      splitContainer2.TabIndex = 2;
+      // 
+      // groupBox1
+      // 
+      groupBox1.Controls.Add(this.assembliesTreeView);
+      groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
+      groupBox1.Location = new System.Drawing.Point(0, 0);
+      groupBox1.Name = "groupBox1";
+      groupBox1.Size = new System.Drawing.Size(340, 85);
+      groupBox1.TabIndex = 0;
+      groupBox1.TabStop = false;
+      groupBox1.Text = "Assemblies";
+      // 
+      // assembliesTreeView
+      // 
+      this.assembliesTreeView.CheckBoxes = true;
+      this.assembliesTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.assembliesTreeView.Location = new System.Drawing.Point(3, 16);
+      this.assembliesTreeView.Name = "assembliesTreeView";
+      this.assembliesTreeView.Size = new System.Drawing.Size(334, 66);
+      this.assembliesTreeView.TabIndex = 1;
+      this.assembliesTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.assembliesTreeView_AfterCheck);
+      // 
+      // groupBox2
+      // 
+      groupBox2.Controls.Add(this.namespacesTreeView);
+      groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
+      groupBox2.Location = new System.Drawing.Point(0, 0);
+      groupBox2.Name = "groupBox2";
+      groupBox2.Size = new System.Drawing.Size(349, 85);
+      groupBox2.TabIndex = 0;
+      groupBox2.TabStop = false;
+      groupBox2.Text = "Namespaces";
+      // 
+      // namespacesTreeView
+      // 
+      this.namespacesTreeView.CheckBoxes = true;
+      this.namespacesTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.namespacesTreeView.Location = new System.Drawing.Point(3, 16);
+      this.namespacesTreeView.Name = "namespacesTreeView";
+      this.namespacesTreeView.PathSeparator = ".";
+      this.namespacesTreeView.Size = new System.Drawing.Size(343, 66);
+      this.namespacesTreeView.TabIndex = 2;
+      this.namespacesTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.namespacesTreeView_AfterCheck);
+      // 
+      // groupBox3
+      // 
+      this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+                  | System.Windows.Forms.AnchorStyles.Left)
+                  | System.Windows.Forms.AnchorStyles.Right)));
+      this.groupBox3.Controls.Add(this.showCodeButton);
+      this.groupBox3.Controls.Add(this.codeEditor);
+      this.groupBox3.Controls.Add(this.compileButton);
+      this.groupBox3.Location = new System.Drawing.Point(3, 2);
+      this.groupBox3.Name = "groupBox3";
+      this.groupBox3.Size = new System.Drawing.Size(687, 363);
+      this.groupBox3.TabIndex = 7;
+      this.groupBox3.TabStop = false;
+      this.groupBox3.Text = "Code";
+      // 
+      // showCodeButton
+      // 
+      this.showCodeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+      this.showCodeButton.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
+      this.showCodeButton.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.ControlDark;
+      this.showCodeButton.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.GradientActiveCaption;
+      this.showCodeButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+      this.showCodeButton.Location = new System.Drawing.Point(467, 333);
+      this.showCodeButton.Name = "showCodeButton";
+      this.showCodeButton.Size = new System.Drawing.Size(133, 23);
+      this.showCodeButton.TabIndex = 4;
+      this.showCodeButton.Text = "Show Generated Code";
+      this.showCodeButton.UseVisualStyleBackColor = true;
+      this.showCodeButton.Click += new System.EventHandler(this.showCodeButton_Click);
+      // 
+      // compileButton
+      // 
+      this.compileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+      this.compileButton.Location = new System.Drawing.Point(606, 334);
+      this.compileButton.Name = "compileButton";
+      this.compileButton.Size = new System.Drawing.Size(75, 23);
+      this.compileButton.TabIndex = 3;
+      this.compileButton.Text = "&Compile";
+      this.compileButton.UseVisualStyleBackColor = true;
+      this.compileButton.Click += new System.EventHandler(this.compileButton_Click);
       // 
       // tabControl
@@ -71,4 +212,5 @@
       this.tabControl.Controls.Add(this.variableInfosTabPage);
       this.tabControl.Controls.Add(this.variablesTabPage);
+      this.tabControl.Controls.Add(this.constraintsTabPage);
       this.tabControl.Controls.Add(this.descriptionTabPage);
       this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -76,69 +218,27 @@
       this.tabControl.Name = "tabControl";
       this.tabControl.SelectedIndex = 0;
-      this.tabControl.Size = new System.Drawing.Size(435, 351);
+      this.tabControl.Size = new System.Drawing.Size(707, 489);
       this.tabControl.TabIndex = 0;
       // 
       // codeTabPage
       // 
-      this.codeTabPage.Controls.Add(this.infoTextBox);
-      this.codeTabPage.Controls.Add(this.compileButton);
-      this.codeTabPage.Controls.Add(this.codeTextBox);
+      this.codeTabPage.Controls.Add(splitContainer1);
       this.codeTabPage.Location = new System.Drawing.Point(4, 22);
       this.codeTabPage.Name = "codeTabPage";
       this.codeTabPage.Padding = new System.Windows.Forms.Padding(3);
-      this.codeTabPage.Size = new System.Drawing.Size(427, 325);
+      this.codeTabPage.Size = new System.Drawing.Size(699, 463);
       this.codeTabPage.TabIndex = 5;
       this.codeTabPage.Text = "Code";
       this.codeTabPage.UseVisualStyleBackColor = true;
       // 
-      // infoTextBox
-      // 
-      this.infoTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
-                  | System.Windows.Forms.AnchorStyles.Right)));
-      this.infoTextBox.BackColor = System.Drawing.SystemColors.ControlLight;
-      this.infoTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
-      this.infoTextBox.Location = new System.Drawing.Point(6, 253);
-      this.infoTextBox.Multiline = true;
-      this.infoTextBox.Name = "infoTextBox";
-      this.infoTextBox.ReadOnly = true;
-      this.infoTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
-      this.infoTextBox.Size = new System.Drawing.Size(334, 66);
-      this.infoTextBox.TabIndex = 2;
-      this.infoTextBox.Text = resources.GetString("infoTextBox.Text");
-      // 
-      // compileButton
-      // 
-      this.compileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-      this.compileButton.Location = new System.Drawing.Point(346, 296);
-      this.compileButton.Name = "compileButton";
-      this.compileButton.Size = new System.Drawing.Size(75, 23);
-      this.compileButton.TabIndex = 1;
-      this.compileButton.Text = "&Compile";
-      this.compileButton.UseVisualStyleBackColor = true;
-      this.compileButton.Click += new System.EventHandler(this.compileButton_Click);
-      // 
-      // codeTextBox
-      // 
-      this.codeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
-                  | System.Windows.Forms.AnchorStyles.Left)
-                  | System.Windows.Forms.AnchorStyles.Right)));
-      this.codeTextBox.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-      this.codeTextBox.Location = new System.Drawing.Point(3, 3);
-      this.codeTextBox.Multiline = true;
-      this.codeTextBox.Name = "codeTextBox";
-      this.codeTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
-      this.codeTextBox.Size = new System.Drawing.Size(421, 244);
-      this.codeTextBox.TabIndex = 0;
-      this.codeTextBox.Validated += new System.EventHandler(this.codeTextBox_Validated);
-      // 
       // variableInfosTabPage
       // 
       this.variableInfosTabPage.Controls.Add(this.removeVariableInfoButton);
       this.variableInfosTabPage.Controls.Add(this.addVariableInfoButton);
-      this.variableInfosTabPage.Controls.Add(this.operatorBaseVariableInfosView);
+      //this.variableInfosTabPage.Controls.Add(this.operatorBaseVariableInfosView);
       this.variableInfosTabPage.Location = new System.Drawing.Point(4, 22);
       this.variableInfosTabPage.Name = "variableInfosTabPage";
       this.variableInfosTabPage.Padding = new System.Windows.Forms.Padding(3);
-      this.variableInfosTabPage.Size = new System.Drawing.Size(427, 325);
+      this.variableInfosTabPage.Size = new System.Drawing.Size(699, 463);
       this.variableInfosTabPage.TabIndex = 1;
       this.variableInfosTabPage.Text = "Variable Infos";
@@ -149,5 +249,5 @@
       this.removeVariableInfoButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
       this.removeVariableInfoButton.Enabled = false;
-      this.removeVariableInfoButton.Location = new System.Drawing.Point(84, 299);
+      this.removeVariableInfoButton.Location = new System.Drawing.Point(87, 434);
       this.removeVariableInfoButton.Name = "removeVariableInfoButton";
       this.removeVariableInfoButton.Size = new System.Drawing.Size(75, 23);
@@ -155,10 +255,10 @@
       this.removeVariableInfoButton.Text = "&Remove";
       this.removeVariableInfoButton.UseVisualStyleBackColor = true;
-      this.removeVariableInfoButton.Click += new System.EventHandler(this.removeVariableInfoButton_Click);
+      //this.removeVariableInfoButton.Click += new System.EventHandler(this.removeVariableInfoButton_Click);
       // 
       // addVariableInfoButton
       // 
       this.addVariableInfoButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
-      this.addVariableInfoButton.Location = new System.Drawing.Point(3, 299);
+      this.addVariableInfoButton.Location = new System.Drawing.Point(6, 434);
       this.addVariableInfoButton.Name = "addVariableInfoButton";
       this.addVariableInfoButton.Size = new System.Drawing.Size(75, 23);
@@ -166,9 +266,9 @@
       this.addVariableInfoButton.Text = "&Add...";
       this.addVariableInfoButton.UseVisualStyleBackColor = true;
-      this.addVariableInfoButton.Click += new System.EventHandler(this.addVariableInfoButton_Click);
+      ///this.addVariableInfoButton.Click += new System.EventHandler(this.addVariableInfoButton_Click);
       // 
       // operatorBaseVariableInfosView
       // 
-      this.operatorBaseVariableInfosView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+      /*this.operatorBaseVariableInfosView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                   | System.Windows.Forms.AnchorStyles.Left)
                   | System.Windows.Forms.AnchorStyles.Right)));
@@ -177,15 +277,16 @@
       this.operatorBaseVariableInfosView.Name = "operatorBaseVariableInfosView";
       this.operatorBaseVariableInfosView.Operator = null;
-      this.operatorBaseVariableInfosView.Size = new System.Drawing.Size(421, 290);
+      this.operatorBaseVariableInfosView.Size = new System.Drawing.Size(690, 425);
       this.operatorBaseVariableInfosView.TabIndex = 0;
       this.operatorBaseVariableInfosView.SelectedVariableInfosChanged += new System.EventHandler(this.operatorBaseVariableInfosView_SelectedVariableInfosChanged);
+       */
       // 
       // variablesTabPage
       // 
-      this.variablesTabPage.Controls.Add(this.operatorBaseVariablesView);
+      //this.variablesTabPage.Controls.Add(this.operatorBaseVariablesView);
       this.variablesTabPage.Location = new System.Drawing.Point(4, 22);
       this.variablesTabPage.Name = "variablesTabPage";
       this.variablesTabPage.Padding = new System.Windows.Forms.Padding(3);
-      this.variablesTabPage.Size = new System.Drawing.Size(427, 325);
+      this.variablesTabPage.Size = new System.Drawing.Size(699, 463);
       this.variablesTabPage.TabIndex = 2;
       this.variablesTabPage.Text = "Local Variables";
@@ -194,11 +295,32 @@
       // operatorBaseVariablesView
       // 
-      this.operatorBaseVariablesView.Caption = "Operator";
+      /*this.operatorBaseVariablesView.Caption = "Operator";
       this.operatorBaseVariablesView.Dock = System.Windows.Forms.DockStyle.Fill;
       this.operatorBaseVariablesView.Location = new System.Drawing.Point(3, 3);
       this.operatorBaseVariablesView.Name = "operatorBaseVariablesView";
       this.operatorBaseVariablesView.Operator = null;
-      this.operatorBaseVariablesView.Size = new System.Drawing.Size(421, 319);
-      this.operatorBaseVariablesView.TabIndex = 0;
+      this.operatorBaseVariablesView.Size = new System.Drawing.Size(693, 457);
+      this.operatorBaseVariablesView.TabIndex = 0; */
+      // 
+      // constraintsTabPage
+      // 
+      //this.constraintsTabPage.Controls.Add(this.constrainedItemBaseView);
+      this.constraintsTabPage.Location = new System.Drawing.Point(4, 22);
+      this.constraintsTabPage.Name = "constraintsTabPage";
+      this.constraintsTabPage.Padding = new System.Windows.Forms.Padding(3);
+      this.constraintsTabPage.Size = new System.Drawing.Size(699, 463);
+      this.constraintsTabPage.TabIndex = 3;
+      this.constraintsTabPage.Text = "Constraints";
+      this.constraintsTabPage.UseVisualStyleBackColor = true;
+      // 
+      // constrainedItemBaseView
+      // 
+      /*this.constrainedItemBaseView.Caption = "Constrained Item";
+      this.constrainedItemBaseView.ConstrainedItem = null;
+      this.constrainedItemBaseView.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.constrainedItemBaseView.Location = new System.Drawing.Point(3, 3);
+      this.constrainedItemBaseView.Name = "constrainedItemBaseView";
+      this.constrainedItemBaseView.Size = new System.Drawing.Size(693, 457);
+      this.constrainedItemBaseView.TabIndex = 0; */
       // 
       // descriptionTabPage
@@ -208,5 +330,5 @@
       this.descriptionTabPage.Name = "descriptionTabPage";
       this.descriptionTabPage.Padding = new System.Windows.Forms.Padding(3);
-      this.descriptionTabPage.Size = new System.Drawing.Size(427, 325);
+      this.descriptionTabPage.Size = new System.Drawing.Size(699, 463);
       this.descriptionTabPage.TabIndex = 4;
       this.descriptionTabPage.Text = "Description";
@@ -215,5 +337,5 @@
       // descriptionTextBox
       // 
-      this.descriptionTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
+      /*this.descriptionTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
       this.descriptionTextBox.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
       this.descriptionTextBox.Location = new System.Drawing.Point(3, 3);
@@ -221,7 +343,22 @@
       this.descriptionTextBox.Name = "descriptionTextBox";
       this.descriptionTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
-      this.descriptionTextBox.Size = new System.Drawing.Size(421, 319);
+      this.descriptionTextBox.Size = new System.Drawing.Size(693, 457);
       this.descriptionTextBox.TabIndex = 0;
-      this.descriptionTextBox.Validated += new System.EventHandler(this.descriptionTextBox_Validated);
+      this.descriptionTextBox.Validated += new System.EventHandler(this.descriptionTextBox_Validated); */
+      // 
+      // codeEditor
+      // 
+      this.codeEditor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+                  | System.Windows.Forms.AnchorStyles.Left)
+                  | System.Windows.Forms.AnchorStyles.Right)));
+      this.codeEditor.Location = new System.Drawing.Point(6, 19);
+      this.codeEditor.Name = "codeEditor";
+      this.codeEditor.Prefix = "using System;\r\nusing HeuristicLab.Common.Resources;\r\n\r\npublic class Operator {\r\n " +
+          " public static void Apply(int arg) {";
+      this.codeEditor.Size = new System.Drawing.Size(675, 309);
+      this.codeEditor.Suffix = "\n    return null;\n  }\n}";
+      this.codeEditor.TabIndex = 0;
+      this.codeEditor.UserCode = "\n\n\n";
+      this.codeEditor.TextEditorValidated += new System.EventHandler(this.codeEditor_Validated);
       // 
       // ProgrammableOperatorView
@@ -231,10 +368,19 @@
       this.Controls.Add(this.tabControl);
       this.Name = "ProgrammableOperatorView";
-      this.Size = new System.Drawing.Size(435, 351);
+      this.Size = new System.Drawing.Size(707, 489);
+      splitContainer1.Panel1.ResumeLayout(false);
+      splitContainer1.Panel2.ResumeLayout(false);
+      splitContainer1.ResumeLayout(false);
+      splitContainer2.Panel1.ResumeLayout(false);
+      splitContainer2.Panel2.ResumeLayout(false);
+      splitContainer2.ResumeLayout(false);
+      groupBox1.ResumeLayout(false);
+      groupBox2.ResumeLayout(false);
+      this.groupBox3.ResumeLayout(false);
       this.tabControl.ResumeLayout(false);
       this.codeTabPage.ResumeLayout(false);
-      this.codeTabPage.PerformLayout();
       this.variableInfosTabPage.ResumeLayout(false);
       this.variablesTabPage.ResumeLayout(false);
+      this.constraintsTabPage.ResumeLayout(false);
       this.descriptionTabPage.ResumeLayout(false);
       this.descriptionTabPage.PerformLayout();
@@ -247,15 +393,21 @@
     private System.Windows.Forms.TabControl tabControl;
     private System.Windows.Forms.TabPage codeTabPage;
-    private System.Windows.Forms.TextBox codeTextBox;
     private System.Windows.Forms.TabPage variableInfosTabPage;
-    private HeuristicLab.Core.Views.OperatorBaseVariableInfosView operatorBaseVariableInfosView;
+    //private HeuristicLab.Core.OperatorBaseVariableInfosView operatorBaseVariableInfosView;
     private System.Windows.Forms.TabPage variablesTabPage;
-    private HeuristicLab.Core.Views.OperatorBaseVariablesView operatorBaseVariablesView;
+    //private HeuristicLab.Core.OperatorBaseVariablesView operatorBaseVariablesView;
+    private System.Windows.Forms.TabPage constraintsTabPage;
+    //private HeuristicLab.Core.ConstrainedItemBaseView constrainedItemBaseView;
     private System.Windows.Forms.TabPage descriptionTabPage;
     private System.Windows.Forms.TextBox descriptionTextBox;
-    private System.Windows.Forms.Button compileButton;
     private System.Windows.Forms.Button removeVariableInfoButton;
     private System.Windows.Forms.Button addVariableInfoButton;
-    private System.Windows.Forms.TextBox infoTextBox;
+    private System.Windows.Forms.TreeView assembliesTreeView;
+    private System.Windows.Forms.TreeView namespacesTreeView;
+    private System.Windows.Forms.GroupBox groupBox3;
+    private HeuristicLab.CodeEditor.CodeEditor codeEditor;
+    private System.Windows.Forms.Button compileButton;
+    private System.Windows.Forms.Button showCodeButton;
+
 
   }
Index: trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.cs
===================================================================
--- trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.cs	(revision 2798)
+++ trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.cs	(revision 2799)
@@ -26,16 +26,20 @@
 using System.Data;
 using System.Text;
+using System.Linq;
 using System.Windows.Forms;
 using HeuristicLab.Core;
 using HeuristicLab.Operators;
+using System.CodeDom.Compiler;
+using System.Reflection;
+using HeuristicLab.CodeEditor;
 using HeuristicLab.Core.Views;
-using HeuristicLab.MainForm;
 
 namespace HeuristicLab.Operators.Programmable {
-  [Content(typeof(ProgrammableOperator), true)]
-  public partial class ProgrammableOperatorView : ItemViewBase {
+
+  public partial class ProgrammableOperatorView : NamedItemView {
+
     public ProgrammableOperator ProgrammableOperator {
-      get { return (ProgrammableOperator)Item; }
-      set { base.Item = value; }
+      get { return (ProgrammableOperator)base.Content; }
+      set { base.Content = (NamedItem)value; }
     }
 
@@ -43,4 +47,5 @@
       InitializeComponent();
     }
+
     public ProgrammableOperatorView(ProgrammableOperator programmableOperator)
       : this() {
@@ -48,72 +53,104 @@
     }
 
-    protected override void RemoveItemEvents() {
-      operatorBaseVariableInfosView.Operator = null;
-      operatorBaseVariablesView.Operator = null;
+    protected override void DeregisterContentEvents() {      
+      //operatorBaseVariableInfosView.Operator = null;
+      //operatorBaseVariablesView.Operator = null;
+      //constrainedItemBaseView.ConstrainedItem = null;
       ProgrammableOperator.CodeChanged -= new EventHandler(ProgrammableOperator_CodeChanged);
       ProgrammableOperator.DescriptionChanged -= new EventHandler(ProgrammableOperator_DescriptionChanged);
-      base.RemoveItemEvents();
-    }
-
-    protected override void AddItemEvents() {
-      base.AddItemEvents();
-      operatorBaseVariableInfosView.Operator = ProgrammableOperator;
-      operatorBaseVariablesView.Operator = ProgrammableOperator;
+      base.DeregisterContentEvents();            
+    }
+
+
+    protected override void RegisterContentEvents() {
+      base.RegisterContentEvents();
+      //operatorBaseVariableInfosView.Operator = ProgrammableOperator;
+      //operatorBaseVariablesView.Operator = ProgrammableOperator;
+      //constrainedItemBaseView.ConstrainedItem = ProgrammableOperator;
       ProgrammableOperator.CodeChanged += new EventHandler(ProgrammableOperator_CodeChanged);
       ProgrammableOperator.DescriptionChanged += new EventHandler(ProgrammableOperator_DescriptionChanged);
     }
 
-    protected override void UpdateControls() {
-      base.UpdateControls();
+
+    protected override void OnContentChanged() {
+      base.OnContentChanged();    
       if (ProgrammableOperator == null) {
-        codeTextBox.Text = "";
-        codeTextBox.Enabled = false;
+        codeEditor.Text = "";
+        codeEditor.Enabled = false;
         addVariableInfoButton.Enabled = false;
         removeVariableInfoButton.Enabled = false;
         descriptionTextBox.Text = "";
         descriptionTextBox.Enabled = false;
-      } else {
-        codeTextBox.Text = ProgrammableOperator.Code;
-        codeTextBox.Enabled = true;
+        codeEditor.Prefix = @"using System
+
+public class Operator {
+  public static IOperation Execute(IOperator op, IScope scope, parameters ...) {
+";
+        codeEditor.Suffix = @"
+    return null;
+  }
+}";
+        assembliesTreeView.Nodes.Clear();
+      } else {
+        codeEditor.Enabled = true;
         addVariableInfoButton.Enabled = true;
-        removeVariableInfoButton.Enabled = operatorBaseVariableInfosView.SelectedVariableInfos.Count > 0;
+        //removeVariableInfoButton.Enabled = operatorBaseVariableInfosView.SelectedVariableInfos.Count > 0;
         descriptionTextBox.Text = ProgrammableOperator.Description;
         descriptionTextBox.Enabled = true;
-      }
-    }
-
+        codeEditor.Prefix = GetGeneratedPrefix();
+        codeEditor.Suffix = @"
+    return null;
+  }
+}";
+        codeEditor.UserCode = ProgrammableOperator.Code;
+        if (codeEditor.UserCode == "")
+          codeEditor.UserCode = "\n\n\n";
+        InitializeAssemblyList();
+        InitializeNamespacesList();
+        foreach (var a in ProgrammableOperator.SelectedAssemblies) {
+          codeEditor.AddAssembly(a);
+        }
+        codeEditor.ScrollAfterPrefix();
+      }
+    }
+
+
+    private string GetGeneratedPrefix() {
+      StringBuilder prefix = new StringBuilder();
+      foreach (var ns in ProgrammableOperator.GetSelectedAndValidNamespaces()) {
+        prefix.Append("using ").Append(ns).AppendLine(";");
+      }
+      prefix.AppendLine();
+      prefix.Append("public class ").Append(ProgrammableOperator.CompiledTypeName).AppendLine(" {");
+      prefix.Append("  ").Append(ProgrammableOperator.Signature).AppendLine(" {");
+      return prefix.ToString();
+    }
+
+    private void codeEditor_Validated(object sender, EventArgs e) {
+      ProgrammableOperator.Code = codeEditor.UserCode;
+    }
+    
+    /*
     private void operatorBaseVariableInfosView_SelectedVariableInfosChanged(object sender, EventArgs e) {
       removeVariableInfoButton.Enabled = operatorBaseVariableInfosView.SelectedVariableInfos.Count > 0;
     }
-
-    #region Validated Events
-    private void codeTextBox_Validated(object sender, EventArgs e) {
-      ProgrammableOperator.Code = codeTextBox.Text;
-    }
+    
     private void descriptionTextBox_Validated(object sender, EventArgs e) {
       ProgrammableOperator.SetDescription(descriptionTextBox.Text);
     }
-    #endregion
-
-    #region Click Events
-    private void compileButton_Click(object sender, EventArgs e) {
-      try {
-        ProgrammableOperator.Compile();
-        MessageBox.Show("Compilation successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
-      }
-      catch (Exception ex) {
-        HeuristicLab.Core.Views.Auxiliary.ShowErrorMessageBox(ex);
-      }
-    }
+
     private void addVariableInfoButton_Click(object sender, EventArgs e) {
       AddVariableInfoDialog dialog = new AddVariableInfoDialog();
       if (dialog.ShowDialog(this) == DialogResult.OK) {
-        if (ProgrammableOperator.GetVariableInfo(dialog.VariableInfo.FormalName) != null)
-          HeuristicLab.Core.Views.Auxiliary.ShowErrorMessageBox("A variable info with the same formal name already exists.");
-        else
+        if (ProgrammableOperator.GetVariableInfo(dialog.VariableInfo.FormalName) != null) {
+          Auxiliary.ShowErrorMessageBox("A variable info with the same formal name already exists.");
+        } else {
           ProgrammableOperator.AddVariableInfo(dialog.VariableInfo);
+          Recompile();
+        }
       }
       dialog.Dispose();
     }
+
     private void removeVariableInfoButton_Click(object sender, EventArgs e) {
       IVariableInfo[] selected = new IVariableInfo[operatorBaseVariableInfosView.SelectedVariableInfos.Count];
@@ -121,10 +158,27 @@
       for (int i = 0; i < selected.Length; i++)
         ProgrammableOperator.RemoveVariableInfo(selected[i].FormalName);
-    }
-    #endregion
+      Recompile();
+    } */
+
+    private void Recompile() {
+      this.Enabled = false;
+      try {
+        ProgrammableOperator.Compile();
+        MessageBox.Show("Compilation successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
+      } catch (Exception ex) {
+        Auxiliary.ShowErrorMessageBox(ex);
+      }
+      OnContentChanged();
+      codeEditor.ShowCompileErrors(ProgrammableOperator.CompileErrors, "ProgrammableOperator");
+      this.Enabled = true;
+    }
+
+    private void compileButton_Click(object sender, EventArgs e) {
+      Recompile();
+    }
 
     #region ProgrammableOperator Events
     private void ProgrammableOperator_CodeChanged(object sender, EventArgs e) {
-      codeTextBox.Text = ProgrammableOperator.Code;
+      codeEditor.Text = ProgrammableOperator.Code;
     }
     private void ProgrammableOperator_DescriptionChanged(object sender, EventArgs e) {
@@ -132,4 +186,136 @@
     }
     #endregion
+
+    private void assembliesTreeView_AfterCheck(object sender, TreeViewEventArgs e) {
+      if (initializing)
+        return;
+      Assembly a = e.Node.Tag as Assembly;
+      if (a == null && e.Node.Nodes.Count > 0) {
+        foreach (TreeNode n in e.Node.Nodes)
+          n.Checked = e.Node.Checked;
+        return;
+      } else {
+        if (e.Node.Checked) {
+          ProgrammableOperator.SelectAssembly(a);
+          codeEditor.AddAssembly(a);
+        } else {
+          ProgrammableOperator.UnselectAssembly(a);
+          codeEditor.RemoveAssembly(a);
+        }
+      }
+      InitializeNamespacesList();
+      codeEditor.Prefix = GetGeneratedPrefix();
+    }
+
+    private bool initializing = false;
+    private void InitializeAssemblyList() {
+      initializing = true;
+      assembliesTreeView.Enabled = false;
+      namespacesTreeView.Enabled = false;
+      assembliesTreeView.BeginUpdate();
+      assembliesTreeView.Nodes.Clear();
+      var selectedAssemblies = new HashSet<Assembly>(ProgrammableOperator.SelectedAssemblies);
+      foreach (var p in ProgrammableOperator.Plugins) {
+        var node = assembliesTreeView.Nodes.Add(p.Key);
+        node.Tag = p;
+        foreach (var a in p.Value) {
+          var aNode = node.Nodes.Add(a.GetName().Name);
+          aNode.Tag = a;
+          if (selectedAssemblies.Contains(a))
+            aNode.Checked = true;
+        }
+        if (node.Nodes.Count == 1 && node.Nodes[0].Name == node.Nodes[0].Name) {
+          node.Tag = node.Nodes[0].Tag;
+          node.Nodes.Clear();
+        } else if (node.Nodes.Count > 0 && node.Nodes.Cast<TreeNode>().All(n => n.Checked)) {
+          node.Checked = true;
+        }
+      }
+      assembliesTreeView.EndUpdate();
+      assembliesTreeView.Enabled = true;
+      namespacesTreeView.Enabled = true;
+      initializing = false;
+    }
+
+    private void InitializeNamespacesList() {
+      initializing = true;
+      namespacesTreeView.Enabled = false;
+      namespacesTreeView.BeginUpdate();
+      TreeNode oldTree = new TreeNode("root");
+      CloneTreeNodeCollection(oldTree, namespacesTreeView.Nodes);
+      namespacesTreeView.Nodes.Clear();
+      var selectedNamespaces = new HashSet<string>(ProgrammableOperator.Namespaces);
+      foreach (var ns in ProgrammableOperator.GetAllNamespaces(true))
+        AddNamespace(namespacesTreeView.Nodes, ns, selectedNamespaces.Contains(ns), oldTree);
+      codeEditor.Prefix = GetGeneratedPrefix();
+      namespacesTreeView.EndUpdate();
+      namespacesTreeView.Enabled = true;
+      initializing = false;
+    }
+
+    private void CloneTreeNodeCollection(TreeNode root, TreeNodeCollection nodes) {
+      foreach (TreeNode n in nodes) {
+        TreeNode newNode = root.Nodes.Add(n.Text, n.Text);
+        newNode.Checked = n.Checked;
+        CloneTreeNodeCollection(newNode, n.Nodes);
+        if (n.IsExpanded)
+          newNode.Expand();
+      }
+    }
+
+    private bool AddNamespace(TreeNodeCollection parentNodes, string ns, bool isSelected, TreeNode oldTree) {
+      int dotIndex = ns.IndexOf('.');
+      string prefix = ns;
+      if (dotIndex != -1)
+        prefix = ns.Substring(0, dotIndex);
+      TreeNode node = GetOrCreateNode(parentNodes, prefix);
+      TreeNode oldNode = MaybeGetNode(oldTree, prefix);
+      bool isNew = oldNode == null;
+      if (dotIndex != -1 && dotIndex + 1 < ns.Length) {
+        isNew = AddNamespace(node.Nodes, ns.Substring(dotIndex + 1, ns.Length - (dotIndex + 1)), isSelected, oldNode);
+      } else {
+        node.Checked = isSelected;
+      }
+      if (isNew || oldNode != null && oldNode.IsExpanded)
+        node.Expand();
+      if (isNew)
+        namespacesTreeView.SelectedNode = node;
+      return isNew;
+    }
+
+    private static TreeNode MaybeGetNode(TreeNode parentNode, string key) {
+      if (parentNode == null)
+        return null;
+      if (parentNode.Nodes.ContainsKey(key))
+        return parentNode.Nodes[key];
+      return null;
+    }
+
+    private static TreeNode GetOrCreateNode(TreeNodeCollection parentNodes, string key) {
+      TreeNode node = null;
+      if (parentNodes.ContainsKey(key)) {
+        node = parentNodes[key];
+      } else {
+        node = parentNodes.Add(key, key);
+      }
+      return node;
+    }
+
+    private void namespacesTreeView_AfterCheck(object sender, TreeViewEventArgs e) {
+      if (initializing)
+        return;
+      if (e.Node.Checked) {
+        ProgrammableOperator.SelectNamespace(e.Node.FullPath);
+      } else {
+        ProgrammableOperator.UnselectNamespace(e.Node.FullPath);
+      }
+      codeEditor.Prefix = GetGeneratedPrefix();
+    }
+
+    private void showCodeButton_Click(object sender, EventArgs e) {
+      new CodeViewer(ProgrammableOperator.CompilationUnitCode).ShowDialog(this);
+    }
+
+
   }
 }
Index: trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.resx
===================================================================
--- trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.resx	(revision 2798)
+++ trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.resx	(revision 2799)
@@ -118,6 +118,15 @@
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <data name="infoTextBox.Text" xml:space="preserve">
-    <value>All variables corresponding to declared variable infos can be accessed directly using their formal names. Additionally there are two special variables: "op" referring to the programmable operator itself (this) and "scope" referring to the scope the operator is applied on.</value>
-  </data>
+  <metadata name="splitContainer1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
+  </metadata>
+  <metadata name="splitContainer2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
+  </metadata>
+  <metadata name="groupBox1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
+  </metadata>
+  <metadata name="groupBox2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
+  </metadata>
 </root>
Index: trunk/sources/HeuristicLab.Operators.Programmable/3.3/Properties/AssemblyInfo.frame
===================================================================
--- trunk/sources/HeuristicLab.Operators.Programmable/3.3/Properties/AssemblyInfo.frame	(revision 2798)
+++ trunk/sources/HeuristicLab.Operators.Programmable/3.3/Properties/AssemblyInfo.frame	(revision 2799)
@@ -33,5 +33,5 @@
 [assembly: AssemblyCompany("")]
 [assembly: AssemblyProduct("HeuristicLab")]
-[assembly: AssemblyCopyright("(c) 2002-2008 HEAL")]
+[assembly: AssemblyCopyright("(c) 2002-2010 HEAL")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
