[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[News.eclipse.technology.gmf] Re: Building a diagram programmatically
|
As it mentioned below "override CreationEditPolicy.getCreateCommand(request)
for the editpolicy which will be installed on your EditPart " by Alex, which
role should be used according to REQ_CREATE?
"Alex Shatalin" <vano@xxxxxxxxxxx> дÈëÏûÏ¢ÐÂÎÅ:drd6fb$mlu$1@xxxxxxxxxxxxxxxxxxxx
> Hi, Nikolay!
> Concerning creation several domain and notation model elements I can
> suggest you to try to understand how it works now by debugging the code
> generated by GMF. ;-) Here are some ideas which will help you understand
> key points in the generated + runtime code:
>
> For the creation/deletion of domain model elements, we have a separate
> EditPolicy - *ItemSemanticEditPolicy. This EditPolicy contains methods
> "getCreateCommand(CreateElementRequest req)" and
> "getDestroyElementCommand(DestroyElementRequest req)". It is important
> that getCreateCommand method should exists in an EditPolicy which
> corresponds with the an element (installed for the corresponding EditPart)
> there you would like to create new one. For example, if you have to create
> something on diagram, getCreateCommand of diagram's
> *ItemSemanticEditPolicy have to be modified in accordance.
> getDestroyElementCommand() should be located in an EditPolicy corresponds
> to the element you would like to destroy. In case of node on the diagram,
> on pressing "del" on this node, getDestroyElementCommand() of
> *ItemSemanticEditPolicy installed on Node editpart will be called.
>
> Concerning creation of view (notation) model elements, it is not so
> clear for me. I can see that CreationEditPolicy of an element will
> redirect control from getCommand() method to
> getCreateElementAndViewCommand() one. In getCreateElementAndViewCommand()
> first of all, semanticCommand will be created. This command will be
> created in accordance with the logic which I've described above. In other
> words, this command will wrap command returned by corresponding
> *ItemSemanticEditPolicy. On the next step, viewCommand will be created by
> calling getCreateCommand(request). AFAIU, viewCommand will wrap all
> command which should create notation model elements. You can see that
> getCreateCommand() method of this editpolicy just creates new
> CreateCommand() for each CreateViewRequest.ViewDescriptor from the
> request. So, to achieve your goal you have to put several
> CreateViewRequest.ViewDescriptor into the create request.
>
> Finally, I think you have two options: either override
> CreationEditPolicy.getCreateCommand(request) for the editpolicy which will
> be installed on your EditPart or by putting several ViewDescriptors into
> CreateViewRequest and it is a bit more tricky - you have to override
> CreateUnspecifiedTypeRequest.createRequests() finally for the specific
> palette tool.
>
> I'm not sure that there is no other ways to achieve this goal in
> runtime, but I hope runtime team will correct me if I've missed something.
>
> --
> Alex Shatalin
>