Friday, January 25, 2008

Creating Children You Didn't Know Existed

To numb the impact of Jeff's departure, I buried myself in work today. I've been mulling over a hard problem that's seems to have come up rather frequently of late. Given that it's also one of our few plan items, it seemed like high time to tackle it. Suppose you have a nice simple model of a file system where you have an abstract base class, Resource, that has a name attribute, and two concrete derived classes, File and Folder, where Folder contains an unbounded number of resources as follows:

Notice that the two properties "Child Creation Extenders" and "Extensible Provider Factory" are new; Dave's still needs to review the changes so goodness knows the names might change before this is committed. Notice too that I've set the "Extensible Provider Factory" property to true in anticipation of making the editing support for this model extensible.

When I generate the usual EMF edit support, I end up with the following editor, where I can create files and folders in a hierarchical structure and give them names.

Now suppose someone else came along and wanted to add support for symbolic links to this model. They could do it with a new model that extends the resource model as follows:

Notice that I'm setting the "Child Creation Extenders" properties to true, since I'll want to be able to create links in the base editor for the resource model.

With another click of the mouse, the code is generated and I can bring up the same editor as before, but now the menu is extended to include the ability to create links:

And of course we can edit links to make them reference other resources:

So there you have it. The item providers for a base model can make themselves extensible and then the item providers for a derived model can generate extensions for the base model, thereby integrating themselves with the editor for an unmodified base model. Extension points are the most wonderful thing!

Well, my office is starting to feel like a prison.

It's time to put an end to this week.

1 comment:

Caillo Lisa said...

This is another testimony on how Chief Dr Lucky cured my HIV disease. Do you need a cure for your HIV disease? Do you want to be cured from your cancer disease? Or you want to be free from any type of disease. Kindly visit his website . He just cured my HIV disease and I’m very grateful to him, he is the only herbalist that can cure you.  
WhatsApp number : +2348132777335 
Via Email :
Thank you all for reading,
God bless"