Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-07-04 14:11:47 -0400
committerEike Stepper2011-07-04 14:11:47 -0400
commit2b575fea99ad1273b69d2d19bd23dda463545aea (patch)
tree293667d7e0c40627a879b07eeb548830518a2e2d /plugins
parent22e2e5aa618a465dc9f62ef09659680580e63145 (diff)
downloadcdo-2b575fea99ad1273b69d2d19bd23dda463545aea.tar.gz
cdo-2b575fea99ad1273b69d2d19bd23dda463545aea.tar.xz
cdo-2b575fea99ad1273b69d2d19bd23dda463545aea.zip
[350027] Fix index for moves from left to right
https://bugs.eclipse.org/bugs/show_bug.cgi?id=350027
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_350027_Test.java40
3 files changed, 48 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java
index d54d03bae4..3f195af859 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java
@@ -17,9 +17,9 @@ import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
+import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.ecore.EClass;
@@ -168,6 +168,12 @@ public class CDOMoveFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOM
--oldPosition;
}
+ // Index fix for moves from left to right.
+ if (oldPosition < newPosition)
+ {
+ --index;
+ }
+
if (index < newPosition && newPosition > 0)
{
--newPosition;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
index c364711fc8..db2c53897b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
@@ -230,5 +230,6 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_343471_Test.class);
testClasses.add(Bugzilla_349793_Test.class);
testClasses.add(Bugzilla_349804_Test.class);
+ testClasses.add(Bugzilla_350027_Test.class);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_350027_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_350027_Test.java
new file mode 100644
index 0000000000..79d25af8c5
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_350027_Test.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDOMoveFeatureDeltaImpl;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+
+/**
+ * Fix index for moves from left to right.
+ * <p>
+ * See bug 350027
+ *
+ * @author Cyril Jaquier
+ */
+@CleanRepositoriesBefore
+public class Bugzilla_350027_Test extends AbstractCDOTest
+{
+ public void testMoveFromLeftToRight() throws Exception
+ {
+ // ABCD (before move)
+ // ACDB (after move from 1 => 3)
+ CDOMoveFeatureDeltaImpl move = new CDOMoveFeatureDeltaImpl(getModel1Package().getAddress_Name(), 3, 1);
+
+ // This simulates the removal of D which is at position 3 before the move
+ move.adjustAfterRemoval(3);
+
+ // We should end up with ACB which correspond to a move from 1 => 2
+ assertEquals(1, move.getOldPosition());
+ assertEquals(2, move.getNewPosition());
+ }
+}

Back to the top