Need to force unique naming

18 views
Skip to first unread message

vorp

unread,
Jun 23, 2015, 9:12:59 PM6/23/15
to authoring-to...@googlegroups.com
I'm running into some issues with my customizations of the Graph Editor example in which I want to lay down an initial set of modules but allow the user to add additional ones.
The user can create a subgraph of nodes with a single right-click action.
But when a new document is created an initial subgraph of nodes needs to be laid down automatically.
I need to keep uniqueness in the module id's but what I'm finding is that my initial set of modules are not acknowledged in the validation classes.
I am adding my initial nodes via a DocumentRegistry_ActiveDocumentChanged callback inside my Editor subclass.
I create a hierarchy of nodes, finally usingCircuitEditingContext.Insert on the parent.
I've tried wrapping this whole "startup" process in a Transaction but nothing I do gets them into the validator list (specifically m_names of UniqueNamer).
Thus, when the user creates a new set of nodes, the first set is named exactly like this 'starter' set (no validation - modules have duplicate names/ids).
However, all node sets created after are fine since the user-activated node creation IS validated.
I've been trying to figure out what I'm missing for hours now but I'm clearly not understanding what I need to understand.
But so far it hasn't helped.

If anyone can shed more light on why my attempts might be failing, I'd be in your debt.

-Len
 

Ron2

unread,
Jun 24, 2015, 2:20:31 PM6/24/15
to authoring-to...@googlegroups.com, l...@lenwhite.com
Hi Len,

Sorry to hear you've been having trouble with your validator class. Using a DOM Validator can be tricky. Are you using ATF's UniqueIdValidator?

It sounds like the DomNode ChildInserted event is not being used by your validator. When debugging, when CircuitEditingContext.Insert() is about to be called, you can set a breakpoint in DomNode where the ChildInserting and ChildInserted events are raised. The method in DomNode.cs is InsertItem(), at line 1472 in my version; you can search on 'DiagnosticChildInserted'. You should see your validator receiving the ChildInserting and/or ChildInserted events.

What should happen is that you are inserting the startup elements in a transaction, and UniqueIdValidator sees the child inserting event and then queues those DomNodes to be uniquely named. In the transaction ending event, the newly added DomNodes should be renamed if necessary. 

--Ron

vorp

unread,
Jun 24, 2015, 8:28:38 PM6/24/15
to authoring-to...@googlegroups.com, rona...@gmail.com, l...@lenwhite.com
Thanks, Ron.
Turns out I just need to wrap my main Insert in a DoTransaction and validation started working normally.
Thought I had tried that earlier but I guess I missed it.
Thanks for the help!
Reply all
Reply to author
Forward
0 new messages