Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Notot2013-04-08 04:08:25 -0400
committerCedric Notot2013-04-08 04:08:25 -0400
commitb9969fc7e014f87d6d1b2ed6f6cabe3125c0e1ae (patch)
treeff7f0d57b41f2cdb4523a3893cff05f5efd12409
parentc754c46423087a5809db3c54f73efbcf18c0b629 (diff)
downloadorg.eclipse.emf.compare-cno/bugMultiDiag.tar.gz
org.eclipse.emf.compare-cno/bugMultiDiag.tar.xz
org.eclipse.emf.compare-cno/bugMultiDiag.zip
bug in displaying related diagrams in multi-diagram case.cno/bugMultiDiag
-rw-r--r--plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramContentMergeViewer.java26
-rw-r--r--plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramMergeViewer.java85
2 files changed, 65 insertions, 46 deletions
diff --git a/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramContentMergeViewer.java b/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramContentMergeViewer.java
index da91b9c62..76d807b15 100644
--- a/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramContentMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramContentMergeViewer.java
@@ -133,7 +133,7 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
void removeDecorators(Diff difference);
/**
- * It removes all the displayed decorators.
+ * It removes all the displayed decorators from cash.
*/
void removeAll();
}
@@ -395,6 +395,7 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
// The selected difference is a good candidate and decorators exist for it
if (decorators != null && !decorators.isEmpty()) {
revealDecorators((List<? extends AbstractDecorator>)decorators);
+ // removeAll();
}
}
@@ -1811,25 +1812,24 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
getRightMergeViewer().getGraphicalViewer().flush();
getAncestorMergeViewer().getGraphicalViewer().flush();
- if (left instanceof IDiagramDiffAccessor) {
- IDiagramDiffAccessor input = (IDiagramDiffAccessor)left;
+ if (left instanceof IDiagramNodeAccessor) {
- // initialization: reset the current difference selection hiding potential visible phantoms
if (fCurrentSelectedDiff != null && fCurrentSelectedDiff.getState() != DifferenceState.MERGED) {
fDecoratorsManager.hideDecorators(fCurrentSelectedDiff);
}
+ fCurrentSelectedDiff = null;
- Diff diff = input.getDiff(); // equivalent to getInput().getTarget()
- fCurrentSelectedDiff = diff;
+ if (left instanceof IDiagramDiffAccessor) {
+ IDiagramDiffAccessor input = (IDiagramDiffAccessor)left;
- if (diff.getState() != DifferenceState.MERGED) {
- fDecoratorsManager.revealDecorators(diff);
- }
- } else if (left instanceof IDiagramNodeAccessor) {
- if (fCurrentSelectedDiff != null && fCurrentSelectedDiff.getState() != DifferenceState.MERGED) {
- fDecoratorsManager.hideDecorators(fCurrentSelectedDiff);
+ Diff diff = input.getDiff(); // equivalent to getInput().getTarget()
+ fCurrentSelectedDiff = diff;
+
+ if (diff.getState() != DifferenceState.MERGED) {
+ fDecoratorsManager.revealDecorators(diff);
+ }
}
- fCurrentSelectedDiff = null;
+
}
updateToolItems();
diff --git a/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramMergeViewer.java b/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramMergeViewer.java
index 5df17917b..385b5cdae 100644
--- a/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramMergeViewer.java
@@ -186,25 +186,43 @@ class DiagramMergeViewer extends AbstractGraphicalMergeViewer {
public void setInput(final Object input) {
if (input instanceof IDiagramNodeAccessor) {
Diagram diagram = ((IDiagramNodeAccessor)input).getOwnedDiagram();
- initEditingDomain(diagram);
- EditPart editPart = null;
- View view = ((IDiagramNodeAccessor)input).getOwnedView();
- if (view != null) {
- editPart = getEditPart(view);
- }
- fGraphicalViewer.deselectAll();
- // Selection only on matches.
- if (!(input instanceof IDiagramDiffAccessor) && editPart != null) {
- while (editPart != null && !editPart.isSelectable()) {
- editPart = editPart.getParent();
+ if (diagram != null) {
+ initEditingDomain(diagram);
+ EditPart editPart = null;
+ View view = ((IDiagramNodeAccessor)input).getOwnedView();
+ if (view != null) {
+ editPart = getEditPart(view);
+ if (editPart == null) {
+ editPart = initializeEditParts(view);
+ }
}
-
- if (editPart != null) {
- setSelection(new StructuredSelection(editPart));
- fGraphicalViewer.reveal(editPart);
+ fGraphicalViewer.deselectAll();
+ // Selection only on matches.
+ if (!(input instanceof IDiagramDiffAccessor) && editPart != null) {
+ setSelection(editPart);
}
+ } else {
+ fGraphicalViewer.setContents((EditPart)null);
}
+ currentDiag = diagram;
+ }
+ }
+
+ /**
+ * Set the selection of the first selectable object from the given edit part.
+ *
+ * @param editPart
+ * The edit part.
+ */
+ private void setSelection(EditPart editPart) {
+ EditPart ep = editPart;
+ while (ep != null && !ep.isSelectable()) {
+ ep = ep.getParent();
+ }
+ if (ep != null) {
+ setSelection(new StructuredSelection(ep));
+ fGraphicalViewer.reveal(ep);
}
}
@@ -226,30 +244,31 @@ class DiagramMergeViewer extends AbstractGraphicalMergeViewer {
}
/**
- * Get the editpart from the given view.
+ * Return the editpart from the given view.
*
* @param view
* The view.
* @return The editpart.
*/
public EditPart getEditPart(final EObject view) {
- final EditPart editPart = (EditPart)fGraphicalViewer.getEditPartRegistry().get(view);
- if (editPart == null) {
- Diagram diagram = null;
- if (view instanceof Diagram) {
- diagram = (Diagram)view;
- } else if (view instanceof View) {
- diagram = ((View)view).getDiagram();
- }
- if (diagram != null && !diagram.equals(currentDiag)) {
- currentDiag = diagram;
- fGraphicalViewer.getEditPartRegistry().clear();
- final DiagramRootEditPart rootEditPart = new DiagramRootEditPart(diagram.getMeasurementUnit());
- fGraphicalViewer.setRootEditPart(rootEditPart);
- fGraphicalViewer.setContents(diagram);
- rootEditPart.getZoomManager().setZoomAnimationStyle(ZoomManager.ANIMATE_NEVER);
- rootEditPart.getZoomManager().setZoom(ZOOM_FACTOR);
- }
+ return (EditPart)fGraphicalViewer.getEditPartRegistry().get(view);
+ }
+
+ private EditPart initializeEditParts(final EObject view) {
+ Diagram diagram = null;
+ if (view instanceof Diagram) {
+ diagram = (Diagram)view;
+ } else if (view instanceof View) {
+ diagram = ((View)view).getDiagram();
+ }
+
+ if (diagram != null) {
+ // fGraphicalViewer.getEditPartRegistry().clear();
+ final DiagramRootEditPart rootEditPart = new DiagramRootEditPart(diagram.getMeasurementUnit());
+ rootEditPart.getZoomManager().setZoomAnimationStyle(ZoomManager.ANIMATE_NEVER);
+ rootEditPart.getZoomManager().setZoom(ZOOM_FACTOR);
+ fGraphicalViewer.setRootEditPart(rootEditPart);
+ fGraphicalViewer.setContents(diagram);
}
return (EditPart)fGraphicalViewer.getEditPartRegistry().get(view);
}

Back to the top