update view when the model has been changed by custom code [message #190425] |
Sun, 01 June 2008 23:42 |
Amro Al-Akkad Messages: 33 Registered: July 2009 |
Member |
|
|
hi!
In my model I have two types of connections 'BigLink' and 'Connection'.
The 'BigLink-connections are simple connections between two
ComponentEditParts (nodes).
The 'Connection'-connections are used two connect affixedChildren (source
node and sink node) of an ComponentEditPart with each other.
The goal is two provide the user, two view modes, one where the
'Connection'-connections and their source and target nodes are visible and
of course the ComponentEditParts, and one where only the
'BigLink'-connections and ComponentEditParts are visible. I could
implement an action that switches the view modes by using the setVisible
method.
And further an action that updates the Palette to contain only 'BigLink'
or 'Connection', 'Source' and 'Sink' node.
So, usually when being in the 'Connection' connection view mode, the
'BigLink'-Tool should not be available in the Palette.
When creating a 'Connection' connection, the 'BigLink' should be added in
the background and then setVisible(false).
So, I added some lines, when a 'Connection'-connection is created, that
adds a BigLink between both affected ComponentEditParts:
Component sourceComp = getSource().getParent();
Component sinkComp = getTarget().getParent();
BigLink bigLink = DteFactory.eINSTANCE.createBigLink();
bigLink.setLabel("cocoon");
bigLink.setComponentSource(sourceComp);
bigLink.setComponentTarget(sinkComp);
sourceComp.getBigLinkSource().add(bigLink);
sinkComp.getBigLinkTarget().add(bigLink);
When I save the diagram, and close it, and open it again. The 'BigLink'
connection is available. So, adding it to the model works, but I need to
find out how to update the view and initially blank it out.
I spend a long time trying out some stuff like:
Command command =
CreateConnectionViewAndElementRequest.getCreateCommand(Oidte ElementTypes.BigLink_4002,
fCompEditPartSource, fCompEditPartTarget,
designPipeEditPart.getDiagramPreferencesHint());
command.execute();
, but had no success or better faced exceptions.
My problem is, that I don't exactly know, from which point I have to
execute the command to create a BigLinkEditPart, and when.
I experienced when doing the command in between of a 'Connection'
connection createCommand the edge was placed somewhere in the diagram, but
not between the source and sink node.
So, I could wait, when doing the switch, iterating all ComponentEditParts
and then create the BigLinkEditParts.
Any help would be great?
Amro
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03299 seconds