| Summary: | Edges are not properly synchronized with semantic element | ||
|---|---|---|---|
| Product: | [Modeling] GMF-Tooling | Reporter: | Jan Koehnlein <jan> |
| Component: | Core | Assignee: | Artem Tikhomirov <tikhomirov.artem> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | borlander, brian.jakubik, chris.waniek, Holger.Schill, troygnichols, y.yu |
| Version: | unspecified | ||
| Target Milestone: | 2.4 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Jan Koehnlein
In 2.3 R2 the generated ModelCanonicalEditPolicy does not extend the org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalConnectionEditPolicy any more. I really do not get it why this has been done. Even out of the comment on the method refreshSemantic in ModelCanonicalEditPolicy I do not get it.
In the way the class ModelCanonicalEditPolicy is generated we have a refreshproblem for new created Edges and orphaned.
In org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalConnectionEditPolicy.refreshSemanticConnections() you could see what I mean.
makeViewsMutable(viewDescriptors);
// now refresh all the connection containers to update the editparts
HashSet<EditPart> ends = new HashSet<EditPart>();
ListIterator<IAdaptable> li = viewDescriptors.listIterator();
while (li.hasNext()) {
IAdaptable adaptable = li.next();
Edge edge = (Edge)adaptable.getAdapter(Edge.class);
EditPart sourceEP = getEditPartFor(edge.getSource(), edge);
if (sourceEP != null) {
ends.add(sourceEP);
}
EditPart targetEP = getEditPartFor(edge.getTarget(), edge);
if (targetEP != null) {
ends.add(targetEP);
}
}
for(EditPart end : ends) {
end.refresh();
}
[GMF Restructure] Bug 319140 : product GMF and component Generation was the original product and component for this bug (In reply to comment #2) > [GMF Restructure] Bug 319140 : product GMF and component > Generation was the original product and component for this bug I had a similar problem as Jan Koehnlein. After looking at the comment Holger Schill, I think the problem can be solved this way: 1) Change the CanonicalEditPolicy to CanonicalConnectionEditPolicy in the generated code; 2) Implement the 3 missing methods to allow semantic queries. Here I use the Problem Frames diagram we developed (http://sead1.open.ac.uk/pf) to illustrate the solution, you may change the semantic queries according to your own meta-models: @Override protected List<EObject> getSemanticConnectionsList() { View viewObject = (View) getHost().getModel(); LinkedList<EObject> result = new LinkedList<EObject>(); List<ProblemLinkDescriptor> childDescriptors = ProblemDiagramUpdater .getContainedLinks(viewObject); for (ProblemNodeDescriptor d : childDescriptors) { result.add(d.getModelElement()); } return result; } @Override protected EObject getSourceElement(EObject relationship) { if (relationship instanceof Link) { Link l = (Link) relationship; return l.getFrom(); } return null; } @Override protected EObject getTargetElement(EObject relationship) { if (relationship instanceof Link) { Link l = (Link) relationship; return l.getTo(); } return null; } I think the changes have to be done in the GMF-Tooling templates. Otherwise GMF-Tooling is not useable. The cause of the trouble was the difference in #refreshOnActivate() method implementation in CanonicalConnectionEditPolicy and regular CanonicalEditPolicy. Former "cheats" on GEF, forcing activation of child edit parts (which is the job done by GEF at appropriate moment of time, *after* editpolicies are activated). Post-commit notification listeners installed from EditParts' activate() method are responsible to refresh diagram according to changes CanonicalEditPolicy otherwise perfectly did. I've added edit part activation logic prior to canonical refresh, although I believe there should be alternative approach, which doesn't require one to intervene with regular GEF approach. *** Bug 335955 has been marked as a duplicate of this bug. *** version -> 2.4 Rollback, Set target to 2.4 instead of accidenatlly set Version |