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.
Use and misuse of statistics
3 years ago