Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » CanonicalEditPolicy vs. Connection Label Edit Parts
CanonicalEditPolicy vs. Connection Label Edit Parts [message #514040] Fri, 12 February 2010 09:35 Go to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Dear GMF folks,

I hope I understand what the idea of the CanonicalEditPolicy is: It
keeps the diagram and the semantical model in synchrony, i.e. it adds or
removes graphical items in the diagram, when the model changes.

How does that fit to labels that are attached to connections? They have
an own EditPart (in contrast to node labels) and the user interface
gives options to "Delete from Diagram". This action seems to be
irreversibel, as there is no way to re-create such feature label. Once
removed, such feature is only accessible via the properties view. If you
change it there, the label in the diagram will still be deleted. No way
to get it back. Only workaround is to remove the whole diagram file and
and re-initialize the diagram from the semantic model.
So how does this fit to the idea of a perfectly synchronized diagram and
model? Any way to force such synchronization, e.g. by disabling such
delete option?

Cheers,
Hauke
Re: CanonicalEditPolicy vs. Connection Label Edit Parts [message #515129 is a reply to message #514040] Wed, 17 February 2010 19:42 Go to previous message
Christoph Wienands is currently offline Christoph WienandsFriend
Messages: 55
Registered: July 2009
Member
Hello Hauke,

> How does that fit to labels that are attached to connections? They have an
> own EditPart (in contrast to node labels) and the user interface gives
> options to "Delete from Diagram". This action seems to be irreversibel, as
> there is no way to re-create such feature label. Once removed, such
> feature is only accessible via the properties view. If you change it
> there, the label in the diagram will still be deleted. No way to get it
> back. Only workaround is to remove the whole diagram file and and
> re-initialize the diagram from the semantic model.
> So how does this fit to the idea of a perfectly synchronized diagram and
> model? Any way to force such synchronization, e.g. by disabling such
> delete option?

In case you are still struggling with the label issue, here some information
for a potential workaround. Jan Koenlein describes to some extent the
implementation of a semi-canonical behavior at
http://code.google.com/p/gmftools/wiki/SemiCanonicalDiagramE ditPolicy

At the end of the article he refers to an AddConnectionsAction. This action
will register a context menu entry for GMF diagram nodes 'Add Connections'.
The action needs to be registered in the plugin.xml along the lines:

<extension point="org.eclipse.ui.popupMenus">
<objectContribution
id="de.itemis.gmf.runtime.extensions.addConnectionsContribution "
objectClass="org.eclipse.gef.GraphicalEditPart">
<action
class=" de.itemis.gmf.runtime.extensions.actions.AddConnectionsActio n "
enablesFor="+"
id=" de.itemis.gmf.runtime.extensions.actions.addConnectionsActio n "
label="Add Connections" menubarPath="additions">
</action>
</objectContribution>
</extension>

So in order to get your diagram label back, you would first have to delete a
connection from the diagram, then you could add it again using 'Add
Connections'. Now, there might be a problem because as long as you use the
default generated by GMF, there will be a CANONICAL_ROLE registered in the
XXXModelEditPart, which disables the 'Delete from diagram' item, which in
turn means you can't remove the link in the first place.

However, maybe that article gives you some more ideas. For example you could
try registering the default XXXModelCanonicalEditPolicy under the
SemiCanonicalDiagramEditPolicy.SEMI_CANONICAL_ROLE instead of the default
CANONICAL_ROLE. Then you'll get the 'Delete from diagram' context menu entry
while still using the default canonical edit policy (I mean trying because
now there could be unintended side effects).

Christoph
Previous Topic:Direct Edit with non-letter character
Next Topic:Why PropertySheetPage doesn't work for my GMF plugin?
Goto Forum:
  


Current Time: Tue Sep 29 11:43:30 GMT 2020

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

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

Back to the top