/// <summary> Insert a node and set its values </summary> public RemoteTreeNode InsertNode(int index, params object[] values) { RemoteTreeNode newNode = InsertNode(index); GetChild(index).SetValues(values); return(newNode); }
void UpdateThread(Thread thread) { RemoteTreeNode node = (RemoteTreeNode)threadToTreeNode[thread]; if (node == null) { node = RootNode.AppendNode(); threadToTreeNode.Add(thread, node); } bool current = interpreter.HasCurrentThread && interpreter.CurrentThread.ID == thread.ID; string location; if (thread.IsStopped) { try { location = thread.GetBacktrace().Frames[0].SourceAddress.Name; } catch { location = ""; } } else { location = ""; } node.SetValue(ColumnSelected, current ? Pixmaps.Arrow : Pixmaps.Empty); node.SetValue(ColumnID, thread.ID); node.SetValue(ColumnPID, thread.PID); node.SetValue(ColumnTID, String.Format("{0:x}", thread.TID)); node.SetValue(ColumnName, thread.Name); node.SetValue(ColumnState, thread.State.ToString()); node.SetValue(ColumnLocation, location); }
internal void NotifyNodeRemoved(RemoteTreeNode node) { referenceToNode.Remove(node.Reference); for(int i = 0; i < node.ChildCount; i++) { NotifyNodeRemoved(node.GetChild(i)); } }
internal void NotifyNodeRemoved(RemoteTreeNode node) { referenceToNode.Remove(node.Reference); for (int i = 0; i < node.ChildCount; i++) { NotifyNodeRemoved(node.GetChild(i)); } }
public RemoteTreeNode GetNode(RemoteTreePath path) { RemoteTreeNode current = RootNode; foreach (int index in path.Indices) { current = current.GetChild(index); } return(current); }
public void CollapseNode(RemoteTreeNodeRef nodeRef) { RemoteTreeNode node = GetNode(nodeRef); // There might be a race condition and the node might have been just removed if (node != null) { node.SetValue(ColumnUpdateChilds, false); } }
void RemoveThread(Thread thread) { RemoteTreeNode node = (RemoteTreeNode)threadToTreeNode[thread]; if (node != null) { node.Remove(); } threadToTreeNode.Remove(thread); }
public void ExpandNode(RemoteTreeNodeRef nodeRef) { RemoteTreeNode node = GetNode(nodeRef); // There might be a race condition and the node might have been just removed if (node != null) { node.SetValue(ColumnUpdateChilds, true); UpdateNodeRecursive(node, (AbstractVariable)node.Tag); } }
void RemoveBreakpoint(SourceBreakpoint breakpoint) { RemoteTreeNode node = (RemoteTreeNode)breakpointToTreeNode[breakpoint]; if (node != null) { node.Remove(); } breakpointToTreeNode.Remove(breakpoint); }
/// <summary> Insert a new node so that it is located at the given index </summary> public RemoteTreeNode InsertNode(int index) { remoteTreeStore.AddModification(new RemoteTreeModification.InsertNode(this.Path, index)); RemoteTreeNode newNode = new RemoteTreeNode(remoteTreeStore, this); childs.Insert(index, newNode); // Must create the reference only once the node is in the tree so that we can get the path newNode.SetValue(0, new RemoteTreeNodeRef()); remoteTreeStore.NotifyNodeAdded(newNode); return(newNode); }
void UpdateBreakpoint(SourceBreakpoint breakpoint) { RemoteTreeNode node = (RemoteTreeNode)breakpointToTreeNode[breakpoint]; if (node == null) { node = RootNode.AppendNode(); breakpointToTreeNode.Add(breakpoint, node); } node.SetValue(ColumnLocation, new SourceCodeLocation(breakpoint.Location)); node.SetValue(ColumnImage, breakpoint.IsEnabled && breakpoint.IsActivated ? Pixmaps.Breakpoint : Pixmaps.BreakpointDisabled); node.SetValue(ColumnID, breakpoint.Index); node.SetValue(ColumnEnabled, breakpoint.IsEnabled ? "Yes" : "No"); node.SetValue(ColumnActivated, breakpoint.IsActivated ? "Yes" : "No"); node.SetValue(ColumnThreadGroup, breakpoint.ThreadGroup != null ? breakpoint.ThreadGroup.Name : "global"); node.SetValue(ColumnName, breakpoint.Name); }
void UpdateNodeRecursive(RemoteTreeNode node, AbstractVariable variable) { bool abort = false; UpdateNodeRecursive(node, variable, ref abort); }
/// <summary> Insert a new node so that it is located at the given index </summary> public RemoteTreeNode InsertNode(int index) { remoteTreeStore.AddModification(new RemoteTreeModification.InsertNode(this.Path, index)); RemoteTreeNode newNode = new RemoteTreeNode(remoteTreeStore, this); childs.Insert(index, newNode); // Must create the reference only once the node is in the tree so that we can get the path newNode.SetValue(0, new RemoteTreeNodeRef()); remoteTreeStore.NotifyNodeAdded(newNode); return newNode; }
public RemoteTreeNode(RemoteTreeStore remoteTreeStore, RemoteTreeNode parent) { this.remoteTreeStore = remoteTreeStore; this.parent = parent; }
internal void NotifyNodeAdded(RemoteTreeNode node) { referenceToNode.Add(node.Reference, node); }
void UpdateNodeRecursive(RemoteTreeNode node, AbstractVariable variable, ref bool abort) { // Get full name of the node string fullNamePrefix; if (node != RootNode && node.Parent != RootNode) { fullNamePrefix = (string)node.Parent.GetValue(ColumnFullName) + "."; } else { fullNamePrefix = String.Empty; } string fullName = fullNamePrefix + variable.Name; // Update the node itself node.Tag = variable; node.SetValue(ColumnFullName, fullName); node.SetValue(ColumnImage, variable.Image); node.SetValue(ColumnName, variable.Name); node.SetValue(ColumnValue, variable.Value); node.SetValue(ColumnType, variable.Type); // Recursively update the childs of this node bool updateChilds = node.GetValue(ColumnUpdateChilds) != null && (bool)node.GetValue(ColumnUpdateChilds); if (!variable.HasChildNodes) { // Does not have childs node.Clear(); } else if (!updateChilds) { // Has childs but do not update them if (node.ChildCount == 0) { // Placeholder so that the item is expandable node.AppendNode(); } } else { // Update childs AbstractVariable[] variables; try { variables = ((AbstractVariable)node.Tag).ChildNodes; } catch { variables = new AbstractVariable[] { new ErrorVariable(String.Empty, "Can not get child nodes") }; } Console.WriteLine("{0} current nodes, {1} new variables", node.ChildCount, variables.Length); // Iterate over the current tree nodes and update them // Try to do it with minimal number of changes to the tree for(int i = 0; i < node.ChildCount; /* no-op */ ) { if (abort) return; string childNodeName = (string)node.GetChild(i).GetValue(ColumnName); // Update 'i'th node to 'i'th variable // Find a variable with the same name as this node // (includes the case where there are no variables left) int varIndex = -1; for(int j = i; j < variables.Length; j++) { if (variables[j].Name == childNodeName) { varIndex = j; break; } } Console.WriteLine("Looking for variable '{0}': index = {1}", childNodeName, varIndex); // Not found - remove this node if (varIndex == -1) { node.GetChild(i).Remove(); continue; } // Insert the variables before the match while(i < varIndex) { UpdateNodeRecursive(node.InsertNode(i), variables[i], ref abort); i++; } // Update the match UpdateNodeRecursive(node.GetChild(i), variables[i], ref abort); i++; } // Add any variables left over for(int i = node.ChildCount; i < variables.Length; i++) { RemoteTreeNode newNode = node.AppendNode(); UpdateNodeRecursive(newNode, variables[i], ref abort); } } }
void UpdateNodeRecursive(RemoteTreeNode node, AbstractVariable variable, ref bool abort) { // Get full name of the node string fullNamePrefix; if (node != RootNode && node.Parent != RootNode) { fullNamePrefix = (string)node.Parent.GetValue(ColumnFullName) + "."; } else { fullNamePrefix = String.Empty; } string fullName = fullNamePrefix + variable.Name; // Update the node itself node.Tag = variable; node.SetValue(ColumnFullName, fullName); node.SetValue(ColumnImage, variable.Image); node.SetValue(ColumnName, variable.Name); node.SetValue(ColumnValue, variable.Value); node.SetValue(ColumnType, variable.Type); // Recursively update the childs of this node bool updateChilds = node.GetValue(ColumnUpdateChilds) != null && (bool)node.GetValue(ColumnUpdateChilds); if (!variable.HasChildNodes) { // Does not have childs node.Clear(); } else if (!updateChilds) { // Has childs but do not update them if (node.ChildCount == 0) { // Placeholder so that the item is expandable node.AppendNode(); } } else { // Update childs AbstractVariable[] variables; try { variables = ((AbstractVariable)node.Tag).ChildNodes; } catch { variables = new AbstractVariable[] { new ErrorVariable(String.Empty, "Can not get child nodes") }; } Console.WriteLine("{0} current nodes, {1} new variables", node.ChildCount, variables.Length); // Iterate over the current tree nodes and update them // Try to do it with minimal number of changes to the tree for (int i = 0; i < node.ChildCount; /* no-op */) { if (abort) { return; } string childNodeName = (string)node.GetChild(i).GetValue(ColumnName); // Update 'i'th node to 'i'th variable // Find a variable with the same name as this node // (includes the case where there are no variables left) int varIndex = -1; for (int j = i; j < variables.Length; j++) { if (variables[j].Name == childNodeName) { varIndex = j; break; } } Console.WriteLine("Looking for variable '{0}': index = {1}", childNodeName, varIndex); // Not found - remove this node if (varIndex == -1) { node.GetChild(i).Remove(); continue; } // Insert the variables before the match while (i < varIndex) { UpdateNodeRecursive(node.InsertNode(i), variables[i], ref abort); i++; } // Update the match UpdateNodeRecursive(node.GetChild(i), variables[i], ref abort); i++; } // Add any variables left over for (int i = node.ChildCount; i < variables.Length; i++) { RemoteTreeNode newNode = node.AppendNode(); UpdateNodeRecursive(newNode, variables[i], ref abort); } } }
public RemoteTreeStore() { this.rootNode = new RemoteTreeNode(this, null); }
public void UpdateTree(ref bool abort) { StackFrame[] callstack; int currentFrameIndex; try { callstack = interpreter.CurrentThread.GetBacktrace().Frames; currentFrameIndex = interpreter.CurrentThread.GetBacktrace().CurrentFrameIndex; } catch { RootNode.Clear(); return; } // Adjust the number of rows to match the callstack length while (RootNode.ChildCount > callstack.Length) { // Delete first row RootNode.GetChild(0).Remove(); } while (RootNode.ChildCount < callstack.Length) { // Add extra row RootNode.PrependNode(); } // Update the values of the rows (in reverse order) for (int i = callstack.Length - 1; i >= 0; i--) { if (abort) { return; } StackFrame frame = callstack[i]; // Get the name string name; if (frame.Method != null) { if (frame.Method.IsLoaded) { long offset = frame.TargetAddress - frame.Method.StartAddress; if (offset >= 0) { name = String.Format("{0}+0x{1:x}", frame.Method.Name, offset); } else { name = String.Format("{0}-0x{1:x}", frame.Method.Name, -offset); } } else { name = String.Format("{0}", frame.Method.Name); } } else if (frame.Name != null) { name = frame.Name.ToString(); } else { name = string.Empty; } // Get the source file string source; try { source = frame.SourceAddress.Name; } catch { source = string.Empty; } RemoteTreeNode node = RootNode.GetChild(i); node.SetValue(ColumnSelected, i == currentFrameIndex ? Pixmaps.Arrow : Pixmaps.Empty); node.SetValue(ColumnLevel, "#" + frame.Level); node.SetValue(ColumnAddress, frame.TargetAddress.ToString()); node.SetValue(ColumnName, name); node.SetValue(ColumnSource, source); } }