Nodes removed from a SubGraph cannot be found

Hi,

I’ve just discovered that when I remove nodes from my custom Subgraph
using and dragging the node or nodes out of the SubGraph, the GoView.Document.FindNode method will not find the node (or nodes) just dragged out of the SubGraph.

I call the FindNode method as part of my cleanup code once the drag out has been performed. FindNode seems to work fine when nodes are added to a Subgraph. However, removing nodes from a SubGraph seems to create a problem for FindNode.

Am I overlooking something regarding the removal of nodes from a SubGraph? Do I need to postpone the cleanup code until the GoView (or SubGraph) performs a particular task?

Thoughts, suggestions?

Thanks.

R. Houston

How are you calling FindNode?

Here’s a little (hopefully helpful) background as part of my answer to your question.

I override OnParentChanged inside each of my node classes. As nodes are dragged into or out of the SubGraph OnParentChanged for each node is called. Inside OnParentChanged I do some local tasks then I invoke a delegate which calls a routine called ParentageChanged in my main program (main form) that performs cleanup based on which nodes were dragged into or out of the SubGraph. In that routine, I call FindNode like this:
dim thisObj as GoObject = GoView.Document.FindNode(, false, true, true).

When nodes are added to the SubGraph FindNode finds the nodes and the cleanup performed in ParentageChanged occurs normally. When nodes are removed (dragged out) of the SubGraph, FindNode does not find the nodes and the cleanup performed by ParentageChanged fails.

I think I understand the sequence of events a little better but I’m still not sure how to address the problem.

The problem begins when dragging nodes out of the SubGraph. I have lifted your SubGraphDraggingTool.vb from SubGraphApp and made it my dragging tool. Inside the DoDragging method, the following block of code is key:

If (Not sg Is Nothing) Then
’ adding to a subgraph

Else ’ adding at top-level
UnhighlightSubGraph()
MyBase.DoDragging(evttype)

 If (evttype = GoInputState.Finish) Then

Me.View.Document.Layers.Default.AddCollection(Me.Selection, True)
Me.View.Selection.Clear()
Me.View.Selection.AddRange(Me.EffectiveSelection)
End If
Return ’ DoDragging already done
End If

At the point where evttype = Finished is true, the next line of code executed is:

Me.View.Document.Layers.Default.AddCollection(Me.Selection, True)

As it turns out, this line of code also initiates the OnParentChanged method inside my node class. But, because dragging out of the SubGraph has not yet completed, the Clear and AddRange methods have
not yet been called, I don’t believe the GoView.Document ‘sees’ the moved nodes yet. This is why FindNode fails to find the nodes.

What can I do about this ordering of events? Is there a way to delay firing the OnParentChanged event somehow until the complete highlighted block of code has executed? Is there another workaround?

Thoughts?

Thanks for your help.

R. Houston

I think you’ve highlighted exactly where your document-searching code should go: right after the code that you bolded.

Maybe.

I still need to work around the fact that AddCollection initiates the OnParentChanged in each of my node classes. This is where I get into trouble.

I did some thinking about this last night and decided that it’s probably best that I modify my code (not yours) to account for my somewhat better understanding of the way GoDiagrams works. Had I known then what I now know I probably wouldn’t have coded my ParentageChanged method the way I did, so its best that it change. Just to be clear, my goal will be to rewrite my ParentageChanged method to not call FindNode and I have some ideas on how best to do this.

These are my thoughts anyway. Your comments, suggestions are always welcomed.

As always, thanks for your time!

R. Houston