[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: Create Connection between two Nodes programmatically (newbie)

Nobody a clue how to get this done?

Any advise is appreciated...
And sorry for posting twice, but this is quite important for me.

Thanks again

Kai Schulte wrote:
Hello all!
I guess this is really a newbie question, but sadly I can`t get it to work on my own. :(


I want to create a connection between to 2 Nodes which are created briefly before.
Node creation works fine, but i`m stuck with the connection part


My Code to create a Node looks like this:

CreationTool tool = new CreationTool( GridConfigurationElementTypes.Building_2003);
CreateViewAndElementRequest req =
(CreateViewAndElementRequest)tool.createCreateRequest();
CreateViewAndOptionallyElementCommand createCmd =
new CeateViewAndOptionallyElementCommand(
req.getViewAndElementDescriptor().getElementAdapter(),
(GridConfigurationEditPart) selection.getFirstElement(),
null, req.getViewAndElementDescriptor()
.getPreferencesHint());
ICommandProxy cmdProxy = new ICommandProxy(createCmd);
cmdProxy.execute();


This is executed for nodes and then I tried to create a connection like this:

Command createCMD3 = CreateConnectionViewAndElementRequest
    .getCreateCommand(
    GridConfigurationElementTypes.BuildingSmartMeterRelation_4001,
    sourceEditPart, targetEditPart);        createCMD3.execute();

The part which I do not know, is how to get the sourceEditPart and targetEditPart.
I would guess it is fairly simple...


Hope someone can help me!

Thanks,
Kai