[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: How I can create connections programmatically between nodes, also created programmatically?

Steffen,

I think you are making it more complicated that it needs to be. If you are creating a connection based on an element type and not the actual element, it should be as simple as doing this:

Command cmd = CreateConnectionViewAndElementRequest.getCreateCommand(type, sourceEditPart, targetEditPart, getDiagramPreferencesHint());

If you don't have the source and target editparts at this time because you want everything to be created in one command, then you can use the DeferredCreateConnectionViewAndElementCommand which takes adapters for the source and target that will adapt to the newly created source and/or target views at command execution time.

I hope this helps.

- Cherie



Steffen Mertens wrote:
Hi,
I have the following problem. If I change the type of a function block (node), then I would like to insert further function blocks automatically and connect these new functions blocks with connecting lines between the function blocks.
The creation of funktions blocks is simple and works well.
I would like to connect the nodes with each other and use for it CreateConnectionViewAndElementRequest.


CreateConnectionViewAndElementRequest.ConnectionViewAndElementDescriptor descriptor = new CreateConnectionViewAndElementRequest.ConnectionViewAndElementDescriptor(new CreateElementRequestAdapter(new CreateElementRequest(type)),((IHintedType) type).getSemanticHint(), getDiagramPreferencesHint());
CreateConnectionViewAndElementRequest request = new CreateConnectionViewAndElementRequest(descriptor);
Command cmd = request.getCreateCommand(request,OutputEditPart,InputEditPart);
executeCommand(cmd);


Unfortunately, this doesn't work. Am I on the wrong way? Can anybody help me?
Thank you!
Steffen