Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » update view when the model has been changed by custom code
update view when the model has been changed by custom code [message #190425] Sun, 01 June 2008 19:42 Go to next message
Eclipse UserFriend
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
Re: update diagram when the model has been changed by custom code [message #190432 is a reply to message #190425] Sun, 01 June 2008 22:27 Go to previous messageGo to next message
Eclipse UserFriend
Sorry! I had to correct the subject, what I like to update is the diagram.
Re: update view when the model has been changed by custom code [message #190526 is a reply to message #190425] Mon, 02 June 2008 10:15 Go to previous messageGo to next message
Eclipse UserFriend
Hello Amro Al-Akkad,

I'm suggesting you to customize GraphicalNodeEditPolicy/*ItemSemanticEditPolicies
installed for source/target EditParts of your links to support this situation.
In particular:
1. *ItemSemanticEditPolicy installed for (target) EditPart of 'Connection'-connection
link (affixedChildren) have to retorn command creating not only 'Connection'-connection
link in domain model, but BigLink in addition. I think "'Connection'-connectionCreateCommand"
class is responsible for returning Create domain model link command for in
your environment.
2. Source/target EditParts of 'Connection'-connection link (affixedChildren)
should have "GraphicalNodeEditPolicy" attached - see superclass of the generated
<affixedChildren>EditPart - ShapeNodeEditPart.createDefaultEditPolicies().
I'm suggesting to attach own implementation of this EditPolicy instead of
default one in <affixedChildren>EditPart.createDefaultEditPolicies() method.
Your subclass should be responsible for creating additional notation model
edge + setting visible to "false" for it. As an example you can use all the
connection-creating methods from the original GraphicalNodeEditPolicy.

I think this should help - in this case you'll not only create domain model
connection, but in addition you'll create corresponding notation model element
+ attach it to the semantic model one created before + set corresponding
visibility property to "false".

-----------------
Alex Shatalin
Re: update view when the model has been changed by custom code [message #192216 is a reply to message #190526] Wed, 11 June 2008 23:47 Go to previous message
Eclipse UserFriend
Thanks, Alex!

I got it somehow workin'! `:)

Cheers,
Amro
Previous Topic:Eclipse distro with just GMF runtime (not including Java JDT)
Next Topic:moving child figure within compartment only
Goto Forum:
  


Current Time: Tue Jul 08 13:40:14 EDT 2025

Powered by FUDForum. Page generated in 0.03825 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top