index > Visual Studio Team System - Domain-Specific Language Tools > How to know if OnShapeInserted was initiated by a loading process...

How to know if OnShapeInserted was initiated by a loading process...


Hi everybody:
I would like to know if it is possible to know if it was the user how inserted the shape or it was a programmatic event (like loading the model) when overriding OnShapeInserted.

The final goal is to open a Window to ask some properties to the user to initialize the Shape/DomainElement but only when the user is doing it for the first time.

As a semi-workaround, I am firing this window if the setting are empty. But this is not exactly the same behaviour (the loading model could be incomplete).

The ideal solution should be to detect such case.

By the way, OnCreated (Shape) was removed, wasn?? it? Looking for other methods to override in Shape I only found OnShapeInserted as a good candidate for interception. I found references to OnCreate in this forum (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=120170&SiteID=1), however June-06 version do not expose OnCreate() anymore.

DSL Tools are finally getting very very good. Congrats to all the team!
Thanks you in advance.




Pedro J. Molina, Capgemini Spain
Pedro J. Molina

To look for the loading scenario, you can check if the transaction is marked as a serialization transaction

(Transaction.IsSerializing)




Gareth Jones - Developer - DSL Tools & Software Factories Platform [MSFT]
GarethJ - MSFT
GarethJ - MSFT wrote:

To look for the loading scenario, you can check if the transaction is marked as a serialization transaction

(Transaction.IsSerializing)



Thanks Gareth. I have tried to obtain the current transaction in the following form:

public override void OnShapeInserted()
Pedro J. Molina

My apologies Pedro - I shoudl have checked more carefully before replying.

So on closer inspection, OnShapeInserted is actually hooked to an IMS event. IMS events happen after the transaction has fired, so you won't be able to find anything out about the transaction at this time.

Here's another approach.

How about overriding MergeConfigure on your domain class instead? This will get called the first time the item is added from a merge operation (such as being dragged from the toolbox).




Gareth Jones - Developer - DSL Tools & Software Factories Platform [MSFT]
GarethJ - MSFT
Thanks Gareth. Now I got it working.



Pedro J. Molina, Capgemini Spain
Pedro J. Molina
reply 5

You can use google to search for other answers

 

More Articles

Zoom feature
Change a connector's from and to endpoints at runtime
DSL and VS 2005 Release Candidate 1 ?
Infopath as editor
Drop-down list to edit 1-* relationships
How to categorize properties?
Dynamically Create Links OnAttributeChange Event`s
Controlling Font
Popup dialog in DSL
Documentation for Microsoft.VisualStudio.Modeling
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

unable to find common parent for view fi…
Designer and File Associations
Shapes that are not directly related to …
Next CTP
Nested Shapes
embedding relationship
How to set formatting to the strings dis…
use case template dropped?
How to make Multiple Views
Programmatically creating diagrams
How to Use Path Syntax and Element Merge…
Nested Diagram
DSL Tools November CTP and VS SDK Decemb…
Embedding Relationships and Inheritence
Starting with DSL Tools

Hot Articles

Designer code templates - where are they?
How to Limit Number of Connectors Betwee…
How to Add context menu to shapes
Have problem for the DSL walk-through st…
Problem loading different models in Dire…
Inherited classes and their compartment …
Can we host DSL designer in a custom hos…
Catch On Properties Change Event
How to get a programmatic reference on t…
Add shapes and connectors to diagram pro…
Where do I place text for a captionId?
Process to create report at design time
DSL Toolkit - March version
What to use instead of GetDisplayPropert…
Problem with the VS SDK March 2006

Recommend Articles

Domain model designer toolbox items disa…
Extending right-click menu for DSL class
Problem starting new DSL-project
bidirectional connectors
Opening an existing DSL in a fresh insta…
CMDS: Missing package guid for commands …
GAC support in Templating Engine (Featur…
TextDecorators in SwimLaneShapes
Project type
Open a new Document
Creating A connector to CompartMent Items
TextTemplatingFileGenerator now fails to…
Replacing a null value....
IsSerializing property
2 problems with V1 release