Changeset 4759


Ignore:
Timestamp:
11/09/10 15:58:12 (8 years ago)
Author:
epitzer
Message:

navigate execution contexts show active scopes (#47)

Location:
branches/HeuristicLab.DebugEngine
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DebugEngine/DebugEngineView.Designer.cs

    r4753 r4759  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
    4748      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DebugEngineView));
    4849      this.label1 = new System.Windows.Forms.Label();
     
    5051      this.logView = new HeuristicLab.Core.Views.LogView();
    5152      this.splitContainer1 = new System.Windows.Forms.SplitContainer();
    52       this.splitContainer2 = new System.Windows.Forms.SplitContainer();
    5353      this.executionStackTreeView = new System.Windows.Forms.TreeView();
    5454      this.label2 = new System.Windows.Forms.Label();
     55      this.splitContainer2 = new System.Windows.Forms.SplitContainer();
    5556      this.label3 = new System.Windows.Forms.Label();
    5657      this.scopeTreeView = new System.Windows.Forms.TreeView();
    5758      this.stepButton = new System.Windows.Forms.Button();
    5859      this.updateButton = new System.Windows.Forms.Button();
     60      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
     61      this.parentButton = new System.Windows.Forms.Button();
     62      this.operationTextBox = new System.Windows.Forms.TextBox();
     63      this.label4 = new System.Windows.Forms.Label();
    5964      this.splitContainer1.Panel1.SuspendLayout();
    6065      this.splitContainer1.Panel2.SuspendLayout();
     
    8186      this.executionTimeTextBox.Name = "executionTimeTextBox";
    8287      this.executionTimeTextBox.ReadOnly = true;
    83       this.executionTimeTextBox.Size = new System.Drawing.Size(366, 20);
     88      this.executionTimeTextBox.Size = new System.Drawing.Size(496, 20);
    8489      this.executionTimeTextBox.TabIndex = 1;
    8590      //
     
    9297      this.logView.Name = "logView";
    9398      this.logView.ReadOnly = false;
    94       this.logView.Size = new System.Drawing.Size(515, 175);
     99      this.logView.Size = new System.Drawing.Size(339, 255);
    95100      this.logView.TabIndex = 2;
    96101      //
    97102      // splitContainer1
    98103      //
    99       this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    100                   | System.Windows.Forms.AnchorStyles.Left)
    101                   | System.Windows.Forms.AnchorStyles.Right)));
    102       this.splitContainer1.Location = new System.Drawing.Point(3, 32);
     104      this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
     105      this.splitContainer1.Location = new System.Drawing.Point(0, 0);
    103106      this.splitContainer1.Name = "splitContainer1";
    104107      this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
     
    106109      // splitContainer1.Panel1
    107110      //
    108       this.splitContainer1.Panel1.Controls.Add(this.splitContainer2);
     111      this.splitContainer1.Panel1.Controls.Add(this.executionStackTreeView);
     112      this.splitContainer1.Panel1.Controls.Add(this.label2);
    109113      //
    110114      // splitContainer1.Panel2
    111115      //
    112116      this.splitContainer1.Panel2.Controls.Add(this.logView);
    113       this.splitContainer1.Size = new System.Drawing.Size(515, 341);
    114       this.splitContainer1.SplitterDistance = 162;
     117      this.splitContainer1.Size = new System.Drawing.Size(339, 492);
     118      this.splitContainer1.SplitterDistance = 233;
    115119      this.splitContainer1.TabIndex = 3;
    116       //
    117       // splitContainer2
    118       //
    119       this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
    120       this.splitContainer2.Location = new System.Drawing.Point(0, 0);
    121       this.splitContainer2.Name = "splitContainer2";
    122       //
    123       // splitContainer2.Panel1
    124       //
    125       this.splitContainer2.Panel1.Controls.Add(this.executionStackTreeView);
    126       this.splitContainer2.Panel1.Controls.Add(this.label2);
    127       //
    128       // splitContainer2.Panel2
    129       //
    130       this.splitContainer2.Panel2.Controls.Add(this.label3);
    131       this.splitContainer2.Panel2.Controls.Add(this.scopeTreeView);
    132       this.splitContainer2.Size = new System.Drawing.Size(515, 162);
    133       this.splitContainer2.SplitterDistance = 258;
    134       this.splitContainer2.TabIndex = 0;
    135120      //
    136121      // executionStackTreeView
     
    142127      this.executionStackTreeView.Name = "executionStackTreeView";
    143128      this.executionStackTreeView.ShowNodeToolTips = true;
    144       this.executionStackTreeView.Size = new System.Drawing.Size(252, 143);
     129      this.executionStackTreeView.Size = new System.Drawing.Size(333, 214);
    145130      this.executionStackTreeView.TabIndex = 2;
    146131      this.executionStackTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.executionStackTreeView_NodeMouseDoubleClick);
     
    155140      this.label2.Text = "Execution Stack";
    156141      //
     142      // splitContainer2
     143      //
     144      this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     145                  | System.Windows.Forms.AnchorStyles.Left)
     146                  | System.Windows.Forms.AnchorStyles.Right)));
     147      this.splitContainer2.Location = new System.Drawing.Point(3, 32);
     148      this.splitContainer2.Name = "splitContainer2";
     149      //
     150      // splitContainer2.Panel1
     151      //
     152      this.splitContainer2.Panel1.Controls.Add(this.splitContainer1);
     153      //
     154      // splitContainer2.Panel2
     155      //
     156      this.splitContainer2.Panel2.Controls.Add(this.label4);
     157      this.splitContainer2.Panel2.Controls.Add(this.operationTextBox);
     158      this.splitContainer2.Panel2.Controls.Add(this.label3);
     159      this.splitContainer2.Panel2.Controls.Add(this.scopeTreeView);
     160      this.splitContainer2.Size = new System.Drawing.Size(678, 492);
     161      this.splitContainer2.SplitterDistance = 339;
     162      this.splitContainer2.TabIndex = 0;
     163      //
    157164      // label3
    158165      //
    159166      this.label3.AutoSize = true;
    160       this.label3.Location = new System.Drawing.Point(3, 0);
     167      this.label3.Location = new System.Drawing.Point(3, 26);
    161168      this.label3.Name = "label3";
    162169      this.label3.Size = new System.Drawing.Size(63, 13);
     
    169176                  | System.Windows.Forms.AnchorStyles.Left)
    170177                  | System.Windows.Forms.AnchorStyles.Right)));
    171       this.scopeTreeView.Location = new System.Drawing.Point(3, 16);
     178      this.scopeTreeView.Location = new System.Drawing.Point(3, 42);
    172179      this.scopeTreeView.Name = "scopeTreeView";
    173180      this.scopeTreeView.ShowNodeToolTips = true;
    174       this.scopeTreeView.Size = new System.Drawing.Size(247, 143);
     181      this.scopeTreeView.Size = new System.Drawing.Size(329, 447);
    175182      this.scopeTreeView.TabIndex = 0;
    176183      this.scopeTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.scopeTreeView_NodeMouseDoubleClick);
     
    180187      this.stepButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    181188      this.stepButton.Image = ((System.Drawing.Image)(resources.GetObject("stepButton.Image")));
    182       this.stepButton.Location = new System.Drawing.Point(494, 3);
     189      this.stepButton.Location = new System.Drawing.Point(624, 3);
    183190      this.stepButton.Name = "stepButton";
    184191      this.stepButton.Size = new System.Drawing.Size(24, 24);
    185192      this.stepButton.TabIndex = 4;
     193      this.toolTip.SetToolTip(this.stepButton, "Step");
    186194      this.stepButton.UseVisualStyleBackColor = true;
    187195      this.stepButton.Click += new System.EventHandler(this.stepButton_Click);
     
    191199      this.updateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    192200      this.updateButton.Image = ((System.Drawing.Image)(resources.GetObject("updateButton.Image")));
    193       this.updateButton.Location = new System.Drawing.Point(464, 3);
     201      this.updateButton.Location = new System.Drawing.Point(654, 3);
    194202      this.updateButton.Name = "updateButton";
    195203      this.updateButton.Size = new System.Drawing.Size(24, 24);
    196204      this.updateButton.TabIndex = 5;
     205      this.toolTip.SetToolTip(this.updateButton, "Refresh/Reset View");
    197206      this.updateButton.UseVisualStyleBackColor = true;
    198207      this.updateButton.Click += new System.EventHandler(this.updateButton_Click);
    199208      //
     209      // parentButton
     210      //
     211      this.parentButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     212      this.parentButton.Image = ((System.Drawing.Image)(resources.GetObject("parentButton.Image")));
     213      this.parentButton.Location = new System.Drawing.Point(594, 3);
     214      this.parentButton.Name = "parentButton";
     215      this.parentButton.Size = new System.Drawing.Size(24, 24);
     216      this.parentButton.TabIndex = 6;
     217      this.toolTip.SetToolTip(this.parentButton, "Go to parent ExecutionContext");
     218      this.parentButton.UseVisualStyleBackColor = true;
     219      this.parentButton.Click += new System.EventHandler(this.parentButton_Click);
     220      //
     221      // operationTextBox
     222      //
     223      this.operationTextBox.Location = new System.Drawing.Point(65, 3);
     224      this.operationTextBox.Name = "operationTextBox";
     225      this.operationTextBox.ReadOnly = true;
     226      this.operationTextBox.Size = new System.Drawing.Size(267, 20);
     227      this.operationTextBox.TabIndex = 2;
     228      //
     229      // label4
     230      //
     231      this.label4.AutoSize = true;
     232      this.label4.Location = new System.Drawing.Point(3, 6);
     233      this.label4.Name = "label4";
     234      this.label4.Size = new System.Drawing.Size(56, 13);
     235      this.label4.TabIndex = 3;
     236      this.label4.Text = "Operation:";
     237      //
    200238      // DebugEngineView
    201239      //
    202240      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     241      this.Controls.Add(this.parentButton);
     242      this.Controls.Add(this.splitContainer2);
    203243      this.Controls.Add(this.updateButton);
    204244      this.Controls.Add(this.stepButton);
    205       this.Controls.Add(this.splitContainer1);
    206245      this.Controls.Add(this.executionTimeTextBox);
    207246      this.Controls.Add(this.label1);
    208247      this.Name = "DebugEngineView";
    209       this.Size = new System.Drawing.Size(521, 376);
     248      this.Size = new System.Drawing.Size(684, 527);
    210249      this.splitContainer1.Panel1.ResumeLayout(false);
     250      this.splitContainer1.Panel1.PerformLayout();
    211251      this.splitContainer1.Panel2.ResumeLayout(false);
    212252      this.splitContainer1.ResumeLayout(false);
    213253      this.splitContainer2.Panel1.ResumeLayout(false);
    214       this.splitContainer2.Panel1.PerformLayout();
    215254      this.splitContainer2.Panel2.ResumeLayout(false);
    216255      this.splitContainer2.Panel2.PerformLayout();
     
    234273    private System.Windows.Forms.Button stepButton;
    235274    private System.Windows.Forms.Button updateButton;
     275    private System.Windows.Forms.ToolTip toolTip;
     276    private System.Windows.Forms.Button parentButton;
     277    private System.Windows.Forms.Label label4;
     278    private System.Windows.Forms.TextBox operationTextBox;
    236279
    237280  }
  • branches/HeuristicLab.DebugEngine/DebugEngineView.cs

    r4753 r4759  
    2424using System.Drawing;
    2525using System.Windows.Forms;
     26using HeuristicLab.Common.Resources;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Core.Views;
     
    4950    public DebugEngineView() {
    5051      InitializeComponent();
     52      updateButton.Image = VS2008ImageLibrary.Refresh;
     53      stepButton.Image = VS2008ImageLibrary.MoveNext;
     54      parentButton.Image = VS2008ImageLibrary.ArrowUp;
    5155    }
    5256
     
    117121        Invoke(new Action(UpdateView));
    118122      } else {
    119         executionStackTreeView.BeginUpdate();
    120         executionStackTreeView.Nodes.Clear();
    121         AddOperations(executionStackTreeView.Nodes, Content.ExecutionStack.ToArray());
    122         executionStackTreeView.ExpandAll();
    123         if (executionStackTreeView.Nodes.Count > 0)
    124           executionStackTreeView.TopNode = executionStackTreeView.Nodes[0];
    125         executionStackTreeView.EndUpdate();
    126 
    127 
    128         scopeTreeView.BeginUpdate();
    129         scopeTreeView.Nodes.Clear();
    130         if (Content.CurrentOperation != null) {
    131           AddScope(scopeTreeView.Nodes, Content.CurrentOperation.Scope);
    132         }
    133         scopeTreeView.ExpandAll();
    134         if (scopeTreeView.Nodes.Count > 0)
    135           scopeTreeView.TopNode = scopeTreeView.Nodes[0];
    136         scopeTreeView.EndUpdate();
    137       }
     123        UpdateExecutionStack();
     124        SetOperation(Content.CurrentOperation);
     125      }
     126    }
     127
     128    private void SetOperation(IOperation operation) {
     129      IAtomicOperation atomicOperation = operation as IAtomicOperation;
     130      operationTextBox.Text = "<none>";
     131      toolTip.SetToolTip(operationTextBox, null);
     132      if (atomicOperation != null && atomicOperation.Operator != null) {
     133        operationTextBox.Text = string.Format("Atomic {0}", atomicOperation.Operator.Name);
     134        toolTip.SetToolTip(operationTextBox, TypeName(atomicOperation.Operator));
     135      }
     136      OperationCollection operationCollection = operation as OperationCollection;
     137      if (operationCollection != null)
     138        operationTextBox.Text = string.Format("Collection {0}", operationCollection.Count);
     139      IExecutionContext context = operation as IExecutionContext;
     140      IScope scope = null;
     141      if (context != null) {
     142        scope = context.Scope;
     143        while (scope != null && scope.Parent != null)
     144          scope = scope.Parent;
     145      }
     146      UpdateScope(scope);
     147      if (context != null)
     148        parentButton.Enabled = context.Parent != null;
     149      scopeTreeView.Tag = context;
     150    }
     151
     152    private void UpdateExecutionStack() {
     153      executionStackTreeView.BeginUpdate();
     154      executionStackTreeView.Nodes.Clear();
     155      AddOperations(executionStackTreeView.Nodes, Content.ExecutionStack.ToArray());
     156      executionStackTreeView.ExpandAll();
     157      if (executionStackTreeView.Nodes.Count > 0)
     158        executionStackTreeView.TopNode = executionStackTreeView.Nodes[0];
     159      executionStackTreeView.EndUpdate();
     160    }
     161
     162    private void UpdateScope(IScope scope) {
     163      scopeTreeView.BeginUpdate();
     164      scopeTreeView.Nodes.Clear();
     165      if (scope != null) {
     166        AddScope(scopeTreeView.Nodes, scope);
     167      }
     168      scopeTreeView.ExpandAll();
     169      if (scopeTreeView.Nodes.Count > 0)
     170        scopeTreeView.TopNode = scopeTreeView.Nodes[0];
     171      scopeTreeView.EndUpdate();
    138172    }
    139173
     
    151185          node.Tag = atom;
    152186          node.ToolTipText = TypeName(atom);
     187          node.ImageKey = "AtomicOperation";
    153188          if (atom.Operator.Breakpoint)
    154189            node.ForeColor = Color.Red;
     
    158193            paramNode.Tag = param;
    159194            paramNode.ToolTipText = string.Format("{0} = {1}", TypeName(param), typeName);
     195            paramNode.ImageKey = "Parameter";
    160196          }
    161197        } else if (op is OperationCollection) {
     
    164200          node.Tag = op;
    165201          node.ToolTipText = TypeName(ops);
     202          node.ImageKey = "OperationCollection";
    166203          AddOperations(node.Nodes, ops);
    167204        }
     
    170207
    171208    private string GetApproximateValue(IParameter param, ref string typeName) {
    172       string value = "<none>";
     209      string valueString = "<none>";
     210      IExecutionContext context = Content.CurrentOperation as IExecutionContext;
     211      IExecutionContext originalContext = param.ExecutionContext;
     212      object value = null;
    173213      try {
    174         IExecutionContext context = Content.CurrentOperation as IExecutionContext;
    175         IExecutionContext oldContext = param.ExecutionContext;
    176         if (context != null) {
     214        try {
    177215          param.ExecutionContext = context;
    178         }
    179         value = param.ActualValue.ToString();
    180         typeName = TypeName(param.ActualValue);
    181         if (context != oldContext) {
    182           param.ExecutionContext = oldContext;
    183           value = string.Format("~ {0}", value);
     216          value = param.ActualValue;
     217        } finally {
     218          param.ExecutionContext = originalContext;
    184219        }
    185220      } catch (Exception) { }
    186       return value;
     221      if (value != null) {
     222        valueString = value.ToString();
     223        if (context != originalContext)
     224          valueString = " ~ " + valueString;
     225        typeName = TypeName(value);
     226      }
     227      return valueString;
    187228    }
    188229
    189230    private void AddScope(TreeNodeCollection nodes, IScope scope) {
    190231      TreeNode node = nodes.Add(scope.Name);
     232      if (Content.CurrentOperation != null && Content.CurrentOperation.Scope == scope) {
     233        node.ForeColor = Color.Red;
     234        node.BackColor = Color.LightGray;
     235      }
    191236      foreach (var var in scope.Variables) {
    192237        TreeNode varNode = node.Nodes.Add(string.Format("{0}={1}", var.Name, var.Value.ToString()));
     
    230275        MainFormManager.MainForm.ShowContent((IItem)e.Node.Tag);
    231276    }
     277
     278    private void parentButton_Click(object sender, EventArgs e) {
     279      IExecutionContext context = scopeTreeView.Tag as IExecutionContext;
     280      if (context != null) {
     281        SetOperation(context.Parent as IOperation);
     282      }
     283    }
    232284  }
    233285}
  • branches/HeuristicLab.DebugEngine/HeuristicLab.DebugEngine.csproj

    r4744 r4759  
    114114    <Reference Include="System.Xml.Linq" />
    115115    <Reference Include="System.Data.DataSetExtensions" />
    116     <Reference Include="Microsoft.CSharp" />
    117116    <Reference Include="System.Data" />
    118117    <Reference Include="System.Xml" />
Note: See TracChangeset for help on using the changeset viewer.