Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8991


Ignore:
Timestamp:
12/03/12 16:07:28 (12 years ago)
Author:
bburlacu
Message:

#1763: Fixed bug when displaying an invalid tree. Simplified operation set and renamed actions (delete -> remove, edit -> change).

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.Designer.cs

    r8980 r8991  
    4848    private void InitializeComponent() {
    4949      this.insertNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    50       this.editNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    51       this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    52       this.copyNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    53       this.copySubtreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     50      this.changeNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5451      this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    55       this.cutNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    56       this.cutSubtreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    57       this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    58       this.deleteNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    59       this.deleteSubtreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     52      this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     53      this.removeNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     54      this.removeSubtreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    6055      this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    6156      this.treeStatusLabel = new System.Windows.Forms.Label();
    6257      this.treeStatusValue = new System.Windows.Forms.Label();
     58      this.toolStripSeparator = new System.Windows.Forms.ToolStripSeparator();
     59      this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    6360      this.SuspendLayout();
    6461      //
     
    6663      //
    6764      this.insertNodeToolStripMenuItem.Name = "insertNodeToolStripMenuItem";
    68       this.insertNodeToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
     65      this.insertNodeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
    6966      this.insertNodeToolStripMenuItem.Text = "Insert Node";
    7067      this.insertNodeToolStripMenuItem.Click += new System.EventHandler(this.insertNodeToolStripMenuItem_Click);
    7168      //
    72       // editNodeToolStripMenuItem
     69      // changeNodeToolStripMenuItem
    7370      //
    74       this.editNodeToolStripMenuItem.Name = "editNodeToolStripMenuItem";
    75       this.editNodeToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
    76       this.editNodeToolStripMenuItem.Text = "Edit";
    77       this.editNodeToolStripMenuItem.Click += new System.EventHandler(this.editNodeToolStripMenuItem_Click);
     71      this.changeNodeToolStripMenuItem.Name = "editNodeToolStripMenuItem";
     72      this.changeNodeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
     73      this.changeNodeToolStripMenuItem.Text = "Change Node";
     74      this.changeNodeToolStripMenuItem.Click += new System.EventHandler(this.changeNodeToolStripMenuItem_Click);
    7875      //
    7976      // copyToolStripMenuItem
    8077      //
    81       this.copyToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
    82             this.copyNodeToolStripMenuItem,
    83             this.copySubtreeToolStripMenuItem});
    8478      this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
    85       this.copyToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
     79      this.copyToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
    8680      this.copyToolStripMenuItem.Text = "Copy";
    87       //
    88       // copyNodeToolStripMenuItem
    89       //
    90       this.copyNodeToolStripMenuItem.Name = "copyNodeToolStripMenuItem";
    91       this.copyNodeToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
    92       this.copyNodeToolStripMenuItem.Text = "Node";
    93       this.copyNodeToolStripMenuItem.Click += new System.EventHandler(this.copyNodeToolStripMenuItem_Click);
    94       //
    95       // copySubtreeToolStripMenuItem
    96       //
    97       this.copySubtreeToolStripMenuItem.Name = "copySubtreeToolStripMenuItem";
    98       this.copySubtreeToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
    99       this.copySubtreeToolStripMenuItem.Text = "Subtree";
    100       this.copySubtreeToolStripMenuItem.Click += new System.EventHandler(this.copySubtreeToolStripMenuItem_Click);
     81      this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click);
    10182      //
    10283      // cutToolStripMenuItem
    10384      //
    104       this.cutToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
    105             this.cutNodeToolStripMenuItem,
    106             this.cutSubtreeToolStripMenuItem});
    10785      this.cutToolStripMenuItem.Name = "cutToolStripMenuItem";
    108       this.cutToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
     86      this.cutToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
    10987      this.cutToolStripMenuItem.Text = "Cut";
     88      this.cutToolStripMenuItem.Click += new System.EventHandler(this.cutToolStripMenuItem_Click);
    11089      //
    111       // cutNodeToolStripMenuItem
     90      // removeToolStripMenuItem
    11291      //
    113       this.cutNodeToolStripMenuItem.Name = "cutNodeToolStripMenuItem";
    114       this.cutNodeToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
    115       this.cutNodeToolStripMenuItem.Text = "Node";
    116       this.cutNodeToolStripMenuItem.Click += new System.EventHandler(this.cutNodeToolStripMenuItem_Click);
     92      this.removeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
     93            this.removeNodeToolStripMenuItem,
     94            this.removeSubtreeToolStripMenuItem});
     95      this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
     96      this.removeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
     97      this.removeToolStripMenuItem.Text = "Remove";
     98      this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeSubtreeToolStripMenuItem_Click);
    11799      //
    118       // cutSubtreeToolStripMenuItem
     100      // removeNodeToolStripMenuItem
    119101      //
    120       this.cutSubtreeToolStripMenuItem.Name = "cutSubtreeToolStripMenuItem";
    121       this.cutSubtreeToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
    122       this.cutSubtreeToolStripMenuItem.Text = "Subtree";
    123       this.cutSubtreeToolStripMenuItem.Click += new System.EventHandler(this.cutSubtreeToolStripMenuItem_Click);
     102      this.removeNodeToolStripMenuItem.Name = "removeNodeToolStripMenuItem";
     103      this.removeNodeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
     104      this.removeNodeToolStripMenuItem.Text = "Node";
     105      this.removeNodeToolStripMenuItem.Click += new System.EventHandler(this.removeNodeToolStripMenuItem_Click);
    124106      //
    125       // deleteToolStripMenuItem
     107      // removeSubtreeToolStripMenuItem
    126108      //
    127       this.deleteToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
    128             this.deleteNodeToolStripMenuItem,
    129             this.deleteSubtreeToolStripMenuItem});
    130       this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
    131       this.deleteToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
    132       this.deleteToolStripMenuItem.Text = "Delete";
    133       //
    134       // deleteNodeToolStripMenuItem
    135       //
    136       this.deleteNodeToolStripMenuItem.Name = "deleteNodeToolStripMenuItem";
    137       this.deleteNodeToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
    138       this.deleteNodeToolStripMenuItem.Text = "Node";
    139       this.deleteNodeToolStripMenuItem.Click += new System.EventHandler(this.deleteNodeToolStripMenuItem_Click);
    140       //
    141       // deleteSubtreeToolStripMenuItem
    142       //
    143       this.deleteSubtreeToolStripMenuItem.Name = "deleteSubtreeToolStripMenuItem";
    144       this.deleteSubtreeToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
    145       this.deleteSubtreeToolStripMenuItem.Text = "Subtree";
    146       this.deleteSubtreeToolStripMenuItem.Click += new System.EventHandler(this.deleteSubtreeToolStripMenuItem_Click);
     109      this.removeSubtreeToolStripMenuItem.Name = "removeSubtreeToolStripMenuItem";
     110      this.removeSubtreeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
     111      this.removeSubtreeToolStripMenuItem.Text = "Subtree";
     112      this.removeSubtreeToolStripMenuItem.Click += new System.EventHandler(this.removeSubtreeToolStripMenuItem_Click);
    147113      //
    148114      // pasteToolStripMenuItem
    149115      //
    150116      this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
    151       this.pasteToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
     117      this.pasteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
    152118      this.pasteToolStripMenuItem.Text = "Paste";
    153119      this.pasteToolStripMenuItem.Click += new System.EventHandler(this.pasteToolStripMenuItem_Clicked);
    154       // 
    155       // contextMenuStrip 
    156       // 
     120      //
     121      // contextMenuStrip
     122      //
    157123      this.contextMenuStrip.Opened += this.contextMenuStrip_Opened;
    158124      this.contextMenuStrip.Items.AddRange(new ToolStripItem[] { insertNodeToolStripMenuItem,
    159                                                                  editNodeToolStripMenuItem,
    160                                                                  copyToolStripMenuItem,
    161                                                                  cutToolStripMenuItem,
    162                                                                  deleteToolStripMenuItem,
    163                                                                  pasteToolStripMenuItem });
     125                                                                 changeNodeToolStripMenuItem,
     126                                                                 copyToolStripMenuItem,
     127                                                                 cutToolStripMenuItem,
     128                                                                 removeToolStripMenuItem,
     129                                                                 pasteToolStripMenuItem });
    164130      //
    165131      // treeStatusLabel
     
    184150      this.treeStatusValue.Text = "Valid";
    185151      //
     152      // toolStripSeparator
     153      //
     154      this.toolStripSeparator.Name = "toolStripSeparator";
     155      this.toolStripSeparator.Size = new System.Drawing.Size(149, 6);
     156      //
    186157      // InteractiveSymbolicExpressionTreeChart
    187158      //
     
    199170
    200171    private ToolStripMenuItem insertNodeToolStripMenuItem;
    201     private ToolStripMenuItem editNodeToolStripMenuItem;
    202     private ToolStripMenuItem copyToolStripMenuItem;
    203     private ToolStripMenuItem copyNodeToolStripMenuItem;
    204     private ToolStripMenuItem copySubtreeToolStripMenuItem;
     172    private ToolStripMenuItem changeNodeToolStripMenuItem;
    205173    private ToolStripMenuItem cutToolStripMenuItem;
    206     private ToolStripMenuItem cutNodeToolStripMenuItem;
    207     private ToolStripMenuItem cutSubtreeToolStripMenuItem;
    208174    private ToolStripMenuItem pasteToolStripMenuItem;
    209     private ToolStripMenuItem deleteToolStripMenuItem;
    210     private ToolStripMenuItem deleteNodeToolStripMenuItem;
    211     private ToolStripMenuItem deleteSubtreeToolStripMenuItem;
     175    private ToolStripMenuItem removeToolStripMenuItem;
     176    private ToolStripMenuItem removeNodeToolStripMenuItem;
     177    private ToolStripMenuItem removeSubtreeToolStripMenuItem;
    212178
    213179    #endregion
    214180    private Label treeStatusLabel;
    215181    private Label treeStatusValue;
     182    private ToolStripSeparator toolStripSeparator;
     183    private ToolStripMenuItem copyToolStripMenuItem;
    216184  }
    217185}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs

    r8981 r8991  
    3232    private ISymbolicExpressionTreeNode tempNode; // node in clipboard (to be cut/copy/pasted etc)
    3333    private VisualSymbolicExpressionTreeNode currSelected; // currently selected node
    34     private enum EditOp { NoOp, CopyNode, CopySubtree, CutNode, CutSubtree, DeleteNode, DeleteSubtree }
     34    private enum EditOp { NoOp, CopyNode, CopySubtree, CutNode, CutSubtree, RemoveNode, RemoveSubtree }
    3535    private enum TreeState { Valid, Invalid }
    3636    private EditOp lastOp = EditOp.NoOp;
     
    6363        treeStatusValue.ForeColor = Color.Red;
    6464        treeState = TreeState.Invalid;
    65         Repaint();
     65        Tree = Tree; // reinitialize the dictionaries and repaint
    6666      }
    6767      foreach (var node in originalNodes.Keys) {
     
    8181      if (currSelected == null) {
    8282        insertNodeToolStripMenuItem.Visible = false;
    83         editNodeToolStripMenuItem.Visible = false;
     83        changeNodeToolStripMenuItem.Visible = false;
    8484        copyToolStripMenuItem.Visible = false;
    8585        cutToolStripMenuItem.Visible = false;
    86         deleteToolStripMenuItem.Visible = false;
     86        removeToolStripMenuItem.Visible = false;
    8787        pasteToolStripMenuItem.Visible = false;
    8888      } else {
    8989        var node = currSelected.SymbolicExpressionTreeNode;
    90         editNodeToolStripMenuItem.Visible = (node is SymbolicExpressionTreeTerminalNode);
    91         insertNodeToolStripMenuItem.Visible = !editNodeToolStripMenuItem.Visible;
     90        insertNodeToolStripMenuItem.Visible = true;
     91        changeNodeToolStripMenuItem.Visible = true;
     92        changeNodeToolStripMenuItem.Enabled = (node is SymbolicExpressionTreeTerminalNode);
     93        insertNodeToolStripMenuItem.Enabled = !changeNodeToolStripMenuItem.Enabled;
    9294        copyToolStripMenuItem.Visible = true;
    9395        cutToolStripMenuItem.Visible = true;
    94         deleteToolStripMenuItem.Visible = true;
    95         pasteToolStripMenuItem.Visible = tempNode != null && insertNodeToolStripMenuItem.Visible;
     96        removeToolStripMenuItem.Visible = true;
     97        pasteToolStripMenuItem.Visible = true;
     98        pasteToolStripMenuItem.Enabled = tempNode != null && insertNodeToolStripMenuItem.Enabled;
    9699      }
    97100    }
     
    175178    }
    176179
    177     private void editNodeToolStripMenuItem_Click(object sender, EventArgs e) {
     180    private void changeNodeToolStripMenuItem_Click(object sender, EventArgs e) {
    178181      if (currSelected == null) return;
    179182
     
    212215    }
    213216
    214     private void cutNodeToolStripMenuItem_Click(object sender, EventArgs e) {
    215       lastOp = EditOp.CutNode;
    216       tempNode = currSelected.SymbolicExpressionTreeNode;
    217       var visualNode = GetVisualSymbolicExpressionTreeNode(tempNode);
    218       visualNode.LineColor = Color.LightGray;
    219       visualNode.TextColor = Color.LightGray;
    220       Repaint();
    221     }
    222 
    223     private void cutSubtreeToolStripMenuItem_Click(object sender, EventArgs e) {
     217    private void cutToolStripMenuItem_Click(object sender, EventArgs e) {
    224218      lastOp = EditOp.CutSubtree;
    225219      tempNode = currSelected.SymbolicExpressionTreeNode;
     
    238232    }
    239233
    240     private void copyNodeToolStripMenuItem_Click(object sender, EventArgs e) {
    241       lastOp = EditOp.CopyNode;
    242       tempNode = currSelected.SymbolicExpressionTreeNode;
    243       currSelected.LineColor = Color.LightGray;
    244       currSelected.TextColor = Color.LightGray;
    245       Repaint();
    246     }
    247 
    248     private void copySubtreeToolStripMenuItem_Click(object sender, EventArgs e) {
     234    private void copyToolStripMenuItem_Click(object sender, EventArgs e) {
    249235      lastOp = EditOp.CopySubtree;
    250236      tempNode = currSelected.SymbolicExpressionTreeNode;
     
    262248    }
    263249
    264     private void deleteNodeToolStripMenuItem_Click(object sender, EventArgs e) {
    265       lastOp = EditOp.DeleteNode;
     250    private void removeNodeToolStripMenuItem_Click(object sender, EventArgs e) {
     251      lastOp = EditOp.RemoveNode;
    266252      var node = currSelected.SymbolicExpressionTreeNode;
    267253      var parent = node.Parent;
     
    276262        }
    277263      }
     264      OnSymbolicExpressionTreeChanged(sender, e);
    278265      currSelected = null; // because the currently selected node was just deleted
    279       OnSymbolicExpressionTreeChanged(sender, e);
    280     }
    281 
    282     private void deleteSubtreeToolStripMenuItem_Click(object sender, EventArgs e) {
    283       lastOp = EditOp.DeleteSubtree;
     266    }
     267
     268    private void removeSubtreeToolStripMenuItem_Click(object sender, EventArgs e) {
     269      lastOp = EditOp.RemoveSubtree;
    284270      var node = currSelected.SymbolicExpressionTreeNode;
    285271      var parent = node.Parent;
     
    287273        return; // the operation makes no sense as it would result in the deletion of the entire tree
    288274      parent.RemoveSubtree(parent.IndexOfSubtree(node));
     275      OnSymbolicExpressionTreeChanged(sender, e);
    289276      currSelected = null; // because the currently selected node was just deleted
    290       OnSymbolicExpressionTreeChanged(sender, e);
    291277    }
    292278
Note: See TracChangeset for help on using the changeset viewer.