Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Refreshing diagram issue after deleting a connection
Refreshing diagram issue after deleting a connection [message #182822] Mon, 14 April 2008 07:05 Go to next message
BLANC Philippe is currently offline BLANC PhilippeFriend
Messages: 89
Registered: July 2009
Member
Hi,
My editor code is generated with GMF 2.0.
I have an element named Context and a connection between two Contexts
named Extends. When an Extends connection is built, I would like to
execute a personal command (SeesImplicitConnectionUpdateCommand extends
AbstractTransactionalCommand).
Here is the architecture of the generated code :

ContextExtendsEditPart
|
|
uses
|
|
v
ContextExtendsItemSemanticEditPolicy (extends EventBBaseItemSemanticPolicy)


ContextItemSemanticEditPolicy (extends EventBBaseItemSemanticPolicy)
^
|
|
uses
|
|
ContextEditPart


The creation of my Extends link is generated in the
ContextItemSemanticEditPolicy class (in the method
getCompleteRelationshipCommand).
So, I have modified this method to call mine as below :

======================
/**
* @generated NOT
*/
protected Command getCompleteCreateRelationshipCommand(
CreateRelationshipRequest req) {
if
(com.clearsy.eventB.model.diagram.providers.EventBElementTyp es.MachineSees_4002
== req.getElementType()) {
return getGEFWrapper(new
com.clearsy.eventB.model.diagram.edit.commands.MachineSeesCr eateCommand(
req, req.getSource(), req.getTarget()));
}
if
(com.clearsy.eventB.model.diagram.providers.EventBElementTyp es.ContextExtends_4003
== req.getElementType()) {
CompoundCommand compound = new CompoundCommand();
// Add Extends connection
compound.add(getGEFWrapper(new
com.clearsy.eventB.model.diagram.edit.commands.ContextExtend sCreateCommand(
req, req.getSource(), req.getTarget())));
// Update Sees connections
compound.add(getGEFWrapper(new
SeesImplicitConnectionUpdateCommand(getEditingDomain())));
return compound;
}
return null;
}



With this code, my command is correctly executed. However, I have to
refresh my diagram to see deleted connections. Can somebody help me please ?


The connections are deleted as below :

Context selectedContext = ...;
....
Context contextToDelete = ...;
.....
selectedContext.getExtends().remove(contextToDelete);
Re: Refreshing diagram issue after deleting a connection [message #182832 is a reply to message #182822] Mon, 14 April 2008 08:06 Go to previous messageGo to next message
BLANC Philippe is currently offline BLANC PhilippeFriend
Messages: 89
Registered: July 2009
Member
I think it is a Canonical semantic issue.
In "getMODELSemanticChildren" method of my MODELDiagramUpdater class,
the link is not handled. Do I have to add it ?
Here is my code :


=============================

public static List getEventBModelRoot_1000SemanticChildren(View view) {
if (!view.isSetElement()) {
return Collections.EMPTY_LIST;
}
com.clearsy.eventB.EventBModelRoot modelElement =
(com.clearsy.eventB.EventBModelRoot) view
.getElement();
List result = new LinkedList();
for (Iterator it = modelElement.getOwnedContexts().iterator(); it
.hasNext();) {
com.clearsy.eventB.Context childElement = (com.clearsy.eventB.Context) it
.next();
int visualID =
com.clearsy.eventB.model.diagram.part.EventBVisualIDRegistry
.getNodeVisualID(view, childElement);
if (visualID ==
com.clearsy.eventB.model.diagram.edit.parts.ContextEditPart. VISUAL_ID) {
result
.add(new com.clearsy.eventB.model.diagram.part.EventBNodeDescriptor(
childElement, visualID));
continue;
}
}
for (Iterator it = modelElement.getOwnedMachines().iterator(); it
.hasNext();) {
com.clearsy.eventB.Machine childElement = (com.clearsy.eventB.Machine) it
.next();
int visualID =
com.clearsy.eventB.model.diagram.part.EventBVisualIDRegistry
.getNodeVisualID(view, childElement);
if (visualID ==
com.clearsy.eventB.model.diagram.edit.parts.MachineEditPart. VISUAL_ID) {
result
.add(new com.clearsy.eventB.model.diagram.part.EventBNodeDescriptor(
childElement, visualID));
continue;
}
}
return result;
}
Re: Refreshing diagram issue after deleting a connection [message #182846 is a reply to message #182832] Mon, 14 April 2008 09:26 Go to previous message
BLANC Philippe is currently offline BLANC PhilippeFriend
Messages: 89
Registered: July 2009
Member
I have solved my problem with a previous post, but I don't know if it is
a correct solution : can somebody give me its point of view about this ?



////////////////
//Re: Refreshing the Editor, when property changes
////////////////
We put the following code in the handleNotificationEvent-method of the
corresponding XXXEditPart:

//this handle the correct diagram refresh
EObject modelElement = this.getDiagramView().getElement();
List editPolicies = CanonicalEditPolicy
..getRegisteredEditPolicies(modelElement);

for (Iterator it = editPolicies.iterator(); it.hasNext();) {
CanonicalEditPolicy nextEditPolicy = (CanonicalEditPolicy) it.next();
nextEditPolicy.refresh();
}
refresh();
Previous Topic:How can i caluclate the size of the compartment?
Next Topic:Cannot generate inherited field
Goto Forum:
  


Current Time: Fri Apr 26 07:09:41 GMT 2024

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

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

Back to the top