Index: /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarAllowedChildSymbolsControl.cs
===================================================================
--- /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarAllowedChildSymbolsControl.cs	(revision 7147)
+++ /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarAllowedChildSymbolsControl.cs	(revision 7148)
@@ -66,7 +66,9 @@
     private void RegisterGrammarEvents() {
       grammar.Changed += new EventHandler(Grammar_Changed);
+      grammar.ReadOnlyChanged += new EventHandler(Grammar_ReadOnlyChanged);
     }
     private void DeregisterGrammarEvents() {
       grammar.Changed -= new EventHandler(Grammar_Changed);
+      grammar.ReadOnlyChanged -= new EventHandler(Grammar_ReadOnlyChanged);
     }
 
@@ -78,4 +80,9 @@
     }
 
+    private void Grammar_ReadOnlyChanged(object sender, EventArgs e) {
+      if (InvokeRequired) Invoke((MethodInvoker)BuildAllowedChildSymbolsTree);
+      else BuildAllowedChildSymbolsTree();
+    }
+
     private void OnGrammarChanged() {
       if (Grammar == null) {
@@ -90,6 +97,10 @@
 
     private void BuildAllowedChildSymbolsTree() {
+      if (Symbol == null) {
+        symbolicExpressionTreeChart.Tree = null;
+        return;
+      }
+
       var tree = new SymbolicExpressionTree(new SymbolicExpressionTreeNode(Symbol));
-
       symbolicExpressionTreeChart.SuspendRepaint = true;
       if (Grammar.GetMaximumSubtreeCount(Symbol) > 0) {
@@ -146,4 +157,5 @@
 
     private void symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
+      if (Grammar.ReadOnly) return;
       if ((Control.ModifierKeys & Keys.Control) == 0)
         selectedSymbolicExpressionTreeNodes.Clear();
@@ -162,4 +174,5 @@
 
     private void symbolicExpressionTreeChart_KeyDown(object sender, KeyEventArgs e) {
+      if (Grammar.ReadOnly) return;
       if (e.KeyCode == Keys.Delete) {
         var root = symbolicExpressionTreeChart.Tree.Root;
@@ -179,4 +192,6 @@
     private void symbolicExpressionTreeChart_DragEnter(object sender, DragEventArgs e) {
       validDragOperation = false;
+      if (Grammar.ReadOnly) return;
+
       var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
       var symbol = data as ISymbol;
@@ -258,20 +273,20 @@
           decreaseMaximumSubtreeCountRectangle = new RectangleF(visualRootNode.X + visualRootNode.Width + spacing, visualRootNode.Y + size + 2 * spacing, size, size);
 
-          pen.Color = Grammar.GetMaximumSubtreeCount(rootNode.Symbol) == Grammar.GetMinimumSubtreeCount(rootNode.Symbol) ? Color.LightGray : Color.Black;
+          pen.Color = Grammar.ReadOnly || Grammar.GetMaximumSubtreeCount(rootNode.Symbol) == Grammar.GetMinimumSubtreeCount(rootNode.Symbol) ? Color.LightGray : Color.Black;
           graphics.DrawString("+", font, pen.Brush, increaseMinimumSubtreeCountRectangle, stringFormat);
           graphics.DrawRectangle(pen, Rectangle.Round(increaseMinimumSubtreeCountRectangle));
           if (pen.Color == Color.LightGray) increaseMinimumSubtreeCountRectangle = RectangleF.Empty;
 
-          pen.Color = Grammar.GetMinimumSubtreeCount(rootNode.Symbol) == rootNode.Symbol.MinimumArity ? Color.LightGray : Color.Black;
+          pen.Color = Grammar.ReadOnly || Grammar.GetMinimumSubtreeCount(rootNode.Symbol) == rootNode.Symbol.MinimumArity ? Color.LightGray : Color.Black;
           graphics.DrawString("-", font, pen.Brush, decreaseMinimumSubtreeCountRectangle, stringFormat);
           graphics.DrawRectangle(pen, Rectangle.Round(decreaseMinimumSubtreeCountRectangle));
           if (pen.Color == Color.LightGray) decreaseMinimumSubtreeCountRectangle = RectangleF.Empty;
 
-          pen.Color = Grammar.GetMaximumSubtreeCount(rootNode.Symbol) == rootNode.Symbol.MaximumArity ? Color.LightGray : Color.Black;
+          pen.Color = Grammar.ReadOnly || Grammar.GetMaximumSubtreeCount(rootNode.Symbol) == rootNode.Symbol.MaximumArity ? Color.LightGray : Color.Black;
           graphics.DrawRectangle(pen, Rectangle.Round(increaseMaximumSubtreeCountRectangle));
           graphics.DrawString("+", font, pen.Brush, increaseMaximumSubtreeCountRectangle, stringFormat);
           if (pen.Color == Color.LightGray) increaseMaximumSubtreeCountRectangle = RectangleF.Empty;
 
-          pen.Color = Grammar.GetMaximumSubtreeCount(rootNode.Symbol) == Grammar.GetMinimumSubtreeCount(rootNode.Symbol) ? Color.LightGray : Color.Black;
+          pen.Color = Grammar.ReadOnly || Grammar.GetMaximumSubtreeCount(rootNode.Symbol) == Grammar.GetMinimumSubtreeCount(rootNode.Symbol) ? Color.LightGray : Color.Black;
           graphics.DrawRectangle(pen, Rectangle.Round(decreaseMaximumSubtreeCountRectangle));
           graphics.DrawString("-", font, pen.Brush, decreaseMaximumSubtreeCountRectangle, stringFormat);
@@ -282,5 +297,5 @@
 
     private void allowedChildSymbolsControl_MouseDown(object sender, MouseEventArgs e) {
-      if (Grammar == null) return;
+      if (Grammar == null || Grammar.ReadOnly) return;
       if (symbolicExpressionTreeChart.Tree == null) return;
 
Index: /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs	(revision 7147)
+++ /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs	(revision 7148)
@@ -162,4 +162,5 @@
       this.symbolsTreeView.TabIndex = 0;
       this.symbolsTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.symbolsTreeView_AfterCheck);
+      this.symbolsTreeView.BeforeCheck += new System.Windows.Forms.TreeViewCancelEventHandler(symbolsTreeView_BeforeCheck);
       this.symbolsTreeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.symbolsTreeView_ItemDrag);
       this.symbolsTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.symbolsTreeView_AfterSelect);
Index: /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs	(revision 7147)
+++ /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs	(revision 7148)
@@ -54,9 +54,22 @@
     }
 
+    private Color treeViewBackColor = Color.Empty;
     protected override void SetEnabledStateOfControls() {
       base.SetEnabledStateOfControls();
-      addButton.Enabled = Content != null && !Content.ReadOnly;
-      removeButton.Enabled = Content != null && !Content.ReadOnly && symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol);
-      copyButton.Enabled = Content != null && !Content.ReadOnly && symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol);
+      if (Content == null || Content.ReadOnly || ReadOnly || Locked) {
+        addButton.Enabled = false;
+        removeButton.Enabled = false;
+        copyButton.Enabled = false;
+        treeViewBackColor = symbolsTreeView.BackColor;
+        symbolsTreeView.BackColor = Color.FromArgb(255,240,240,240);
+      } else {
+        addButton.Enabled = true;
+        if (symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol)) {
+          removeButton.Enabled = true;
+          copyButton.Enabled = true;
+        }
+        treeViewBackColor = Color.Empty;
+        symbolsTreeView.BackColor = treeViewBackColor;
+      }
     }
 
@@ -112,5 +125,7 @@
     #endregion
 
+    private bool internalTreeViewUpdateInProgress = false;
     private void UpdateSymbolsTreeView() {
+      internalTreeViewUpdateInProgress = true;
       var symbols = Content.Symbols.ToList();
       foreach (var treeNode in IterateTreeNodes().ToList()) {
@@ -125,4 +140,5 @@
 
       RebuildImageList();
+      internalTreeViewUpdateInProgress = false;
     }
 
@@ -148,7 +164,5 @@
     private void symbolsTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
       if (e.Action != TreeViewAction.Unknown) UpdateSymbolDetailsViews();
-
-      removeButton.Enabled = symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol);
-      copyButton.Enabled = symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol);
+      SetEnabledStateOfControls();
     }
 
@@ -164,4 +178,10 @@
         Content.FinishedGrammarManipulation();
       }
+    }
+
+    private void symbolsTreeView_BeforeCheck(object sender, TreeViewCancelEventArgs e) {
+      if (internalTreeViewUpdateInProgress) return;      
+      if (Content == null || Content.ReadOnly) e.Cancel = true;
+      if (ReadOnly || Locked) e.Cancel = true;
     }
 
@@ -183,5 +203,5 @@
     private void symbolsTreeView_DragEnter(object sender, DragEventArgs e) {
       validDragOperation = false;
-      if (Content == null) return;
+      if (Content == null || Content.ReadOnly || ReadOnly || Locked) return;
 
       var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
@@ -230,5 +250,5 @@
       Point coordinates = new Point(e.X, e.Y);
       TreeNode node = symbolsTreeView.GetNodeAt(coordinates);
-      if (e.Button == System.Windows.Forms.MouseButtons.Left && node == null) {
+      if (e.Button == MouseButtons.Left && node == null) {
         symbolsTreeView.SelectedNode = null;
         symbolDetailsViewHost.Content = null;
@@ -238,5 +258,5 @@
 
     private void symbolsTreeView_KeyDown(object sender, KeyEventArgs e) {
-      if (ReadOnly) return;
+      if (Content == null || Content.ReadOnly || ReadOnly || Locked) return;
       if (symbolsTreeView.SelectedNode == null) return;
       if (e.KeyCode != Keys.Delete) return;
