Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Goubet2013-06-10 07:31:18 +0000
committerLaurent Goubet2013-06-10 07:44:27 +0000
commitf3b3c6e9524eeb9121f1afcdec640c6b902743ba (patch)
tree960866461a05c24dc0cacbae8220f440a193a917
parenta1829c994e64ff809c4220d7f1f47533b494cef8 (diff)
downloadorg.eclipse.emf.compare-f3b3c6e9524eeb9121f1afcdec640c6b902743ba.tar.gz
org.eclipse.emf.compare-f3b3c6e9524eeb9121f1afcdec640c6b902743ba.tar.xz
org.eclipse.emf.compare-f3b3c6e9524eeb9121f1afcdec640c6b902743ba.zip
[410073] Cache the groups instead of recomputing them every single time.
Since groups lack a proper implementation of equals(), recomputing them prevents the structure viewer from preserving its expanded state. That is not a major hindrance per se, but it also causes concurrent modification exceptions in the current state of the dual command stack. Bug: 410073 Change-Id: Ib29d00be0f734e6db7fb743e509657aff6c2cd88
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/groups/StructureMergeViewerGrouper.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/groups/StructureMergeViewerGrouper.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/groups/StructureMergeViewerGrouper.java
index 5d8e19f8a..e2ed6a97e 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/groups/StructureMergeViewerGrouper.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/groups/StructureMergeViewerGrouper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Obeo.
+ * Copyright (c) 2012, 2013 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -45,6 +45,12 @@ public final class StructureMergeViewerGrouper {
private EventBus eventBus;
/**
+ * Caches the result of {@link #getGroups(Comparison)}. We need the groups to be identical between calls
+ * in order for the viewer to be able to keep its expanded state.
+ */
+ private Iterable<? extends IDifferenceGroup> filteredGroups;
+
+ /**
* Constructs the difference grouper.
*
* @param eventBus
@@ -68,9 +74,10 @@ public final class StructureMergeViewerGrouper {
return ImmutableList.of();
}
- final Iterable<? extends IDifferenceGroup> groups = provider.getGroups(comparison);
- final Iterable<? extends IDifferenceGroup> filteredGroups = Iterables.filter(groups,
- new NonEmptyGroup());
+ if (filteredGroups == null) {
+ final Iterable<? extends IDifferenceGroup> groups = provider.getGroups(comparison);
+ filteredGroups = Iterables.filter(groups, new NonEmptyGroup());
+ }
return filteredGroups;
}
@@ -83,6 +90,7 @@ public final class StructureMergeViewerGrouper {
public void setProvider(IDifferenceGroupProvider provider) {
if (this.provider != provider) {
this.provider = provider;
+ filteredGroups = null;
eventBus.post(provider);
refreshViewers();
}

Back to the top