Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_408534_Test.java94
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java2
2 files changed, 95 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_408534_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_408534_Test.java
new file mode 100644
index 0000000000..a48471f43d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_408534_Test.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2004 - 2012 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.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.command.MoveCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
+
+import java.text.ParseException;
+
+/**
+ * @author Christophe Bouhier
+ */
+public class Bugzilla_408534_Test extends AbstractCDOTest
+{
+ public void testListElementMove() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ Resource resource = transaction.getOrCreateResource(getResourcePath("test.model1"));
+
+ // Add a company with 3 categories.
+ Company company = getModel1Factory().createCompany();
+ addCategory(company);
+ addCategory(company);
+ addCategory(company);
+ resource.getContents().add(company);
+ transaction.commit();
+
+ // Bring the resourceset under an editing domain.
+ ResourceSet resourceSet = transaction.getResourceSet();
+ AdapterFactory adapterFactory = new ReflectiveItemProviderAdapterFactory();
+ CommandStack commandStack = new SaneCommandStack();
+ EditingDomain domain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, resourceSet);
+
+ // Add a notfification adapter.
+ company.eAdapters().add(new AdapterImpl()
+ {
+ @Override
+ public void notifyChanged(Notification msg)
+ {
+ // We expect an object of type Category as the new value.
+ assertInstanceOf(Category.class, msg.getNewValue());
+ }
+ });
+
+ // Move the last element to index = 0;
+ Command moveCommand = new MoveCommand(domain, company.getCategories(), company.getCategories().size() - 1, 0);
+ commandStack.execute(moveCommand); // Notifier should not throw an exception.
+ }
+
+ private void addCategory(Company company) throws ParseException
+ {
+ Category category = getModel1Factory().createCategory();
+ category.setName("Cat" + (company.getCategories().size() + 1));
+ company.getCategories().add(category);
+ }
+
+ /**
+ * @author Caspar De Groot
+ */
+ private static class SaneCommandStack extends BasicCommandStack
+ {
+ @Override
+ protected void handleError(Exception exception)
+ {
+ throw new WrappedException(exception);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java
index 7dd619a5d0..9b9cabd551 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java
@@ -549,7 +549,7 @@ public final class CDOStoreImpl implements CDOStore
InternalCDORevision revision = getRevisionForWriting(cdoObject, delta);
Object result = revision.move(feature, target, source);
- result = convertToEMF(eObject, revision, feature, EStore.NO_INDEX, result);
+ result = convertToEMF(eObject, revision, feature, target, result);
return result;
}
}

Back to the top