|Re: Creating diagram from modelset? [message #1712303 is a reply to message #1712285]
||Thu, 22 October 2015 17:54
|| Christian W. Damus
Registered: July 2009
As you now have an UmlModel, you can ask it for its "root object" using
the lookupRoot() method. But, that has problems (IMHO): the return
result of this method is EObject, not Package (or, at least, Element).
And, it just gets whatever is the first element of the *.uml resource's
contents list, hoping that this is some kind of UML element. In
practice, it usually is, but ...
Better would be to do
which might be null or might not. This is what the
UmlModel::lookupRoot() method should be doing, too.
On the subject of initial population of a diagram, well, that's very
complicated. Some diagrams (especially the behavior diagrams) rely
heavily on their EditParts to sensibly configure the layout of the
views (regions in state machines being a particularly good example of
this), so it is probably not feasible to do this without actually
automating an actual diagram editor instance. In any case, you might
have a look at the (confusingly named) "Diagram Template" component in
the Papyrus Extras, which purports to address the initial diagram
population use case.
On 2015-10-22 16:06:30 +0000, Patrik Nandorf said:
> OK, I managed to get the models using getModel().
> However when I use UmlModel umlModel = UmlUtils.getUmlModel(ms); i the
> a UmlModel (obviously) but how got i the the actual UML2 model Model
> I guess I could use the modelset to find the resource for the actual
> .uml model and load it but I guess there is a better way?
|Re: Creating diagram from modelset? [message #1712358 is a reply to message #1712336]
||Fri, 23 October 2015 09:31
| Camille Letavernier
Registered: February 2011
Indeed, it is much easier to manipulate diagrams programatically when you can manipulate the actual EditParts. The easiest way for that being to actually open a Papyrus editor. However, GMF also supports an "Offscreen" mode, where you can load the EditPart hierarchy without actually rendering anything. We barely use that in Papyrus, so I can't give a detailed example, but the entry point would be "OffscreenEditPartFactory".
Something like this:
Then rely on Drag/Drop requests to populate this edit part, without actually rendering the diagram or opening an editor.
As I said, we barely use this in Papyrus, so you may encounter a few exceptions, but I would expect them to be quite easily fixed (If they occur at all), so please feel free to report any issue you'd have with this approach
Powered by FUDForum
. Page generated in 0.03436 seconds