Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Notot2013-05-31 14:49:32 +0000
committerCedric Notot2013-06-04 12:34:53 +0000
commit11157e280c60f69d239adaa53bb6cfec0caacf61 (patch)
tree1816feb4016772e892dc059a6832f06854469117
parent7ea0cf3634e927db1d311916a3ba9bac0b9ea877 (diff)
downloadorg.eclipse.emf.compare-11157e280c60f69d239adaa53bb6cfec0caacf61.tar.gz
org.eclipse.emf.compare-11157e280c60f69d239adaa53bb6cfec0caacf61.tar.xz
org.eclipse.emf.compare-11157e280c60f69d239adaa53bb6cfec0caacf61.zip
[409514] ConcurrentModificationException selecting a diagram difference
-rw-r--r--plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramContentMergeViewer.java103
1 files changed, 25 insertions, 78 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 506b0c340..b8034848c 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
@@ -435,7 +435,7 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
}
/**
- * It manages the display of the given decorators.
+ * It manages the display of the given decorators.<br>
*
* @param decorators
* The decorators to handle.
@@ -466,23 +466,11 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
protected void handleDecorator(AbstractDecorator decorator, boolean isAdd, boolean isMain) {
IFigure layer = decorator.getLayer();
IFigure figure = decorator.getFigure();
- EditPart editpart = decorator.getEditPart();
- if (editpart == null) {
- if (isAdd && !layer.getChildren().contains(figure)) {
- handleAddDecorator(decorator, layer, figure, isMain);
- } else if (layer.getChildren().contains(figure)) {
- handleDeleteDecorator(decorator, layer, figure, isMain);
- }
- } else {
- if (isAdd && !editpart.isActive()) {
- editpart.activate();
- handleAddDecorator(decorator, layer, figure, isMain);
- } else if (editpart.isActive()) {
- editpart.deactivate();
- handleDeleteDecorator(decorator, layer, figure, isMain);
- }
+ if (isAdd) {
+ handleAddDecorator(decorator, layer, figure, isMain);
+ } else if (layer.getChildren().contains(figure)) {
+ handleDeleteDecorator(decorator, layer, figure);
}
-
}
/**
@@ -500,7 +488,12 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
*/
protected void handleAddDecorator(AbstractDecorator decorator, IFigure parent, IFigure toAdd,
boolean isMain) {
- parent.add(toAdd);
+ if (decorator.getEditPart() != null) {
+ decorator.getEditPart().activate();
+ }
+ if (!parent.getChildren().contains(toAdd)) {
+ parent.add(toAdd);
+ }
}
/**
@@ -512,13 +505,14 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
* The parent figure which has to get the figure to hide (<code>toDelete</code>)
* @param toDelete
* The figure to hide.
- * @param isMain
- * It indicates if the given decorator to hide is considered as the main one (the one
- * directly linked to the selected difference).
*/
- protected void handleDeleteDecorator(AbstractDecorator decorator, IFigure parent, IFigure toDelete,
- boolean isMain) {
- parent.remove(toDelete);
+ protected void handleDeleteDecorator(AbstractDecorator decorator, IFigure parent, IFigure toDelete) {
+ if (decorator.getEditPart() != null) {
+ decorator.getEditPart().deactivate();
+ }
+ if (parent.getChildren().contains(toDelete)) {
+ parent.remove(toDelete);
+ }
}
/**
@@ -740,7 +734,8 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
/**
* Get the decorator dependencies of this one. The dependencies are the decorator ancestors plus
- * the extremities of an edge decorator.
+ * the extremities of an edge decorator.<br>
+ * DO NOT CALL in an iterate of {@link PhantomManager#fPhantomRegistry}
*
* @return The list of found decorators.
*/
@@ -922,7 +917,9 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.<br>
+ * DO NOT CALL on a phantom within an iteration on the phantom registry.
+ * {@link PhantomManager#fPhantomRegistry}
*
* @see org.eclipse.emf.compare.diagram.ide.ui.internal.contentmergeviewer.diagram.DiagramContentMergeViewer.AbstractDecoratorManager#handleDecorator(org.eclipse.emf.compare.diagram.ide.ui.internal.contentmergeviewer.diagram.DiagramContentMergeViewer.AbstractDecoratorManager.AbstractDecorator,
* boolean)
@@ -949,16 +946,6 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
}
}
- @Override
- protected void handleDeleteDecorator(AbstractDecorator decorator, IFigure parent, IFigure toDelete,
- boolean isMain) {
- super.handleDeleteDecorator(decorator, parent, toDelete, isMain);
- // Re-initialize the highlight of the figure
- if (isMain) {
- decorator.getDecoratorFigure().unhighlight();
- }
- }
-
/**
* It checks that the given view graphically exists.
*
@@ -1231,42 +1218,6 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
}
/**
- * Get all the ancestor matches from the given difference.
- *
- * @param difference
- * The difference.
- * @return the list of ancestor matches.
- */
- private List<Match> getMatchAncestors(Diff difference) {
- List<Match> result = new ArrayList<Match>();
- EObject match = difference.getMatch();
- while (match != null) {
- if (match instanceof Match) {
- result.add((Match)match);
- }
- match = match.eContainer();
- }
- return result;
- }
-
- /**
- * Get all the differences above the given one.
- *
- * @param difference
- * The difference.
- * @return the list of parent differences.
- */
- private List<Diff> getDiffAncestors(Diff difference) {
- List<Diff> result = new ArrayList<Diff>();
- Iterator<Match> matches = getMatchAncestors(difference).iterator();
- while (matches.hasNext()) {
- Match match = matches.next();
- result.addAll(match.getDifferences());
- }
- return result;
- }
-
- /**
* It checks that the given edge is linked to graphical objects subjected to coordinate changes, on
* the given side.
*
@@ -1402,9 +1353,7 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
*/
public void hideAll() {
for (Phantom phantom : fPhantomRegistry.values()) {
- if (phantom.getFigure().getParent() != null) {
- handleDecorator(phantom, false, true);
- }
+ handleDeleteDecorator(phantom, phantom.getLayer(), phantom.getFigure());
}
}
}
@@ -1630,9 +1579,7 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer {
*/
public void hideAll() {
for (Marker marker : fMarkerRegistry.values()) {
- if (marker.getFigure().getParent() != null) {
- handleDecorator(marker, false, true);
- }
+ handleDeleteDecorator(marker, marker.getLayer(), marker.getFigure());
}
}

Back to the top