Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Goubet2013-06-24 02:59:15 -0400
committerLaurent Goubet2013-06-24 03:29:32 -0400
commit738c3a03988748beee5d7aae013dfff82522193f (patch)
tree7bb65409324ac9711343440c9ac106cb3b71554d
parente8c43e5d86be0e8b40b0b89b9f09f7442f0f205f (diff)
downloadorg.eclipse.emf.compare-738c3a03988748beee5d7aae013dfff82522193f.tar.gz
org.eclipse.emf.compare-738c3a03988748beee5d7aae013dfff82522193f.tar.xz
org.eclipse.emf.compare-738c3a03988748beee5d7aae013dfff82522193f.zip
[411464] Dot not use a view for the traversal's sets.
This also adds to the storage traversal API to make it more clear that its wrapped set is not immutable. Bug: 411464 Change-Id: Iab69d01ac3c82a060af85a98b8d21cb493b8b899
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ComparisonScopeBuilder.java4
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/IdenticalResourceMinimizer.java18
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ProjectModelResolver.java7
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/logical/IModelMinimizer.java3
-rw-r--r--plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/StorageTraversal.java13
5 files changed, 27 insertions, 18 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ComparisonScopeBuilder.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ComparisonScopeBuilder.java
index da6bc1211..c0b693fba 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ComparisonScopeBuilder.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ComparisonScopeBuilder.java
@@ -254,8 +254,8 @@ public final class ComparisonScopeBuilder {
private IComparisonScope createMinimizedScope(SynchronizationModel syncModel, IProgressMonitor monitor) {
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
// Minimize the traversals to non-read-only resources with no binary identical counterparts.
- SynchronizationModel minimizedModel = minimizer.minimize(syncModel, subMonitor.newChild(10));
- return createScope(minimizedModel, subMonitor.newChild(90));
+ minimizer.minimize(syncModel, subMonitor.newChild(10));
+ return createScope(syncModel, subMonitor.newChild(90));
}
/**
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/IdenticalResourceMinimizer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/IdenticalResourceMinimizer.java
index b84d07648..165b9bacc 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/IdenticalResourceMinimizer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/IdenticalResourceMinimizer.java
@@ -44,7 +44,7 @@ public class IdenticalResourceMinimizer implements IModelMinimizer {
* @see org.eclipse.emf.compare.ide.ui.logical.IModelMinimizer#minimize(org.eclipse.emf.compare.ide.ui.logical.SynchronizationModel,
* org.eclipse.core.runtime.IProgressMonitor)
*/
- public SynchronizationModel minimize(SynchronizationModel syncModel, IProgressMonitor monitor) {
+ public void minimize(SynchronizationModel syncModel, IProgressMonitor monitor) {
SubMonitor progess = SubMonitor.convert(monitor, EMFCompareIDEUIMessages
.getString("EMFSynchronizationModel.minimizing"), 100); //$NON-NLS-1$
@@ -65,13 +65,13 @@ public class IdenticalResourceMinimizer implements IModelMinimizer {
final IStorage origin = removeLikeNamedStorageFrom(left, originCopy);
if (origin != null && equals(left, right, origin)) {
- leftTraversal.getStorages().remove(left);
- rightTraversal.getStorages().remove(right);
- originTraversal.getStorages().remove(origin);
+ leftTraversal.removeStorage(left);
+ rightTraversal.removeStorage(right);
+ originTraversal.removeStorage(origin);
}
} else if (right != null && equals(left, right)) {
- leftTraversal.getStorages().remove(left);
- rightTraversal.getStorages().remove(right);
+ leftTraversal.removeStorage(left);
+ rightTraversal.removeStorage(right);
} else if (right == null) {
// This file has no match. remove it if read only
if (left.isReadOnly()) {
@@ -85,7 +85,7 @@ public class IdenticalResourceMinimizer implements IModelMinimizer {
for (IStorage right : rightCopy) {
// These have no match on left. Remove if read only
if (right.isReadOnly()) {
- rightTraversal.getStorages().remove(right);
+ rightTraversal.removeStorage(right);
}
subMonitor.worked(1);
}
@@ -94,12 +94,10 @@ public class IdenticalResourceMinimizer implements IModelMinimizer {
for (IStorage origin : originCopy) {
// These have no match on left and right. Remove if read only
if (origin.isReadOnly()) {
- originTraversal.getStorages().remove(origin);
+ originTraversal.removeStorage(origin);
}
subMonitor.worked(1);
}
-
- return new SynchronizationModel(leftTraversal, rightTraversal, originTraversal);
}
/**
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ProjectModelResolver.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ProjectModelResolver.java
index 14afddb6b..a0f88fd8e 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ProjectModelResolver.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ProjectModelResolver.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.compare.ide.ui.internal.logical;
import static com.google.common.collect.Sets.difference;
import static com.google.common.collect.Sets.intersection;
+import static com.google.common.collect.Sets.newLinkedHashSet;
import static org.eclipse.emf.compare.ide.ui.internal.util.PlatformElementUtil.adaptAs;
import static org.eclipse.emf.compare.ide.utils.ResourceUtil.createURIFor;
import static org.eclipse.emf.compare.ide.utils.ResourceUtil.hasContentType;
@@ -158,9 +159,9 @@ public class ProjectModelResolver extends LogicalModelResolver {
}
logCoherenceThreats(startingPoints, intersection);
- final Set<IStorage> actualLeft = difference(leftTraversal, intersection);
- final Set<IStorage> actualRight = difference(rightTraversal, intersection);
- final Set<IStorage> actualOrigin = difference(originTraversal, intersection);
+ final Set<IStorage> actualLeft = newLinkedHashSet(difference(leftTraversal, intersection));
+ final Set<IStorage> actualRight = newLinkedHashSet(difference(rightTraversal, intersection));
+ final Set<IStorage> actualOrigin = newLinkedHashSet(difference(originTraversal, intersection));
return new SynchronizationModel(new StorageTraversal(actualLeft), new StorageTraversal(actualRight),
new StorageTraversal(actualOrigin));
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/logical/IModelMinimizer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/logical/IModelMinimizer.java
index 6351170d9..1085ee54a 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/logical/IModelMinimizer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/logical/IModelMinimizer.java
@@ -34,7 +34,6 @@ public interface IModelMinimizer {
* The traversal, if any, corresponding to the common ancestor of left and right sides.
* @param monitor
* Monitor on which to report progress to the user.
- * @return The minimized model.
*/
- SynchronizationModel minimize(SynchronizationModel syncModel, IProgressMonitor monitor);
+ void minimize(SynchronizationModel syncModel, IProgressMonitor monitor);
}
diff --git a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/StorageTraversal.java b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/StorageTraversal.java
index e59261541..af0240638 100644
--- a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/StorageTraversal.java
+++ b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/StorageTraversal.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.compare.ide.utils;
import com.google.common.annotations.Beta;
import com.google.common.collect.Lists;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -53,7 +54,17 @@ public class StorageTraversal implements IAdaptable {
* @return The set of resources that are part of this traversal.
*/
public Set<? extends IStorage> getStorages() {
- return storages;
+ return new LinkedHashSet<IStorage>(storages);
+ }
+
+ /**
+ * Removes the given storage from this traversal.
+ *
+ * @param storage
+ * The storage to be removed.
+ */
+ public void removeStorage(IStorage storage) {
+ storages.remove(storage);
}
/**

Back to the top