Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-06-14 11:38:57 -0400
committerGerrit Code Review @ Eclipse.org2016-06-21 07:13:44 -0400
commitda232baf5ed359e641090de829fee43273d3bf48 (patch)
tree62ca1fac82911b261e40fccd894e09497f2bc660
parent7f883ab42bf8285670e342ebcc34b8b1fdeec4bc (diff)
downloadorg.eclipse.papyrus-da232baf5ed359e641090de829fee43273d3bf48.tar.gz
org.eclipse.papyrus-da232baf5ed359e641090de829fee43273d3bf48.tar.xz
org.eclipse.papyrus-da232baf5ed359e641090de829fee43273d3bf48.zip
Bug 495312: [Table 2] Reordering model-elements duplicates them in
hierarchical synced table https://bugs.eclipse.org/bugs/show_bug.cgi?id=495312 The rows duplicated was managed by an add object into the table even if the row of element was already in the table. For the initial order, this is managed as specified in the 'node' attribute of the 'activity' node (and not like sub elements of it (as model explorer did)). Care to your used feature: For activity nodes, this are displayes as ownedElements and as ownedNodes (2 differents attributes). Change-Id: I51c7b593d4cb91b97f71a0110325a731e376a596 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractTreeAxisManagerForEventList.java2
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/bugs/bug495312/MoveElementInSynchronizedTable.di2
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/bugs/bug495312/MoveElementInSynchronizedTable.notation38
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/bugs/bug495312/MoveElementInSynchronizedTable.uml9
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/bugs/MoveElementInSynchronizedTableTest.java276
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/tests/AllTests.java6
7 files changed, 333 insertions, 3 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractTreeAxisManagerForEventList.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractTreeAxisManagerForEventList.java
index f08fb40fd8f..23a5a2ce7f6 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractTreeAxisManagerForEventList.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractTreeAxisManagerForEventList.java
@@ -704,7 +704,7 @@ public abstract class AbstractTreeAxisManagerForEventList extends AbstractAxisMa
}
// case 3 - the notifier is a known element
- if (this.managedElements.containsKey(notifier)) {
+ if (this.managedElements.containsKey(notifier) && !this.managedElements.containsKey(newValue)) {
final Set<ITreeItemAxis> itemAxisRepresentations = this.managedElements.get(notifier);
// we need to add a child for each representation of its parent in the table
for (final ITreeItemAxis curr : itemAxisRepresentations) {
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/META-INF/MANIFEST.MF
index 3efddfbe533..744c0cb129e 100644
--- a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/META-INF/MANIFEST.MF
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.nattable.common;bundle-version="1.2.0",
org.eclipse.papyrus.infra.ui;bundle-version="1.2.0",
org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.core;bundle-version="1.2.0"
+ org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.gmfdiag.commands
Export-Package: org.eclipse.papyrus.uml.nattable.tests,
org.eclipse.papyrus.uml.nattable.tests.tests
Bundle-Vendor: %Bundle-Vendor
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/bugs/bug495312/MoveElementInSynchronizedTable.di b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/bugs/bug495312/MoveElementInSynchronizedTable.di
new file mode 100644
index 00000000000..bf9abab340f
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/bugs/bug495312/MoveElementInSynchronizedTable.di
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/bugs/bug495312/MoveElementInSynchronizedTable.notation b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/bugs/bug495312/MoveElementInSynchronizedTable.notation
new file mode 100644
index 00000000000..552e5a586f6
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/bugs/bug495312/MoveElementInSynchronizedTable.notation
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nattable:Table xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:configuration="http://www.eclipse.org/papyrus/infra/viewpoints/configuration" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:nattable="http://www.eclipse.org/papyrus/nattable/model" xmlns:nattableaxis="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis" xmlns:nattableaxisconfiguration="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration" xmlns:nattableaxisprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider" xmlns:nattableconfiguration="http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration" xmlns:nattablelabelprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattablecontentprovider" xmlns:nattablestyle="http://www.eclipse.org/papyrus/nattable/model/table/nattablestyle" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis http://www.eclipse.org/papyrus/nattable/model#//nattableaxis http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model#//nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattablecontentprovider http://www.eclipse.org/papyrus/nattable/model#//nattablelabelprovider http://www.eclipse.org/papyrus/nattable/model/table/nattablestyle http://www.eclipse.org/papyrus/nattable/model#//nattablestyle" xmi:id="_yBjG4DRvEeaB7KmLyE7Tdg" name="GenericTreeTable0" currentRowAxisProvider="_yBjG4zRvEeaB7KmLyE7Tdg" currentColumnAxisProvider="_yBjG4TRvEeaB7KmLyE7Tdg">
+ <context xmi:type="uml:Model" href="MoveElementInSynchronizedTable.uml#_tj-IUDRvEeaB7KmLyE7Tdg"/>
+ <owner xmi:type="uml:Model" href="MoveElementInSynchronizedTable.uml#_tj-IUDRvEeaB7KmLyE7Tdg"/>
+ <prototype xmi:type="configuration:PapyrusSyncTable" href="platform:/plugin/org.eclipse.papyrus.uml.nattable/configs/genericTreeTable.configuration#_P3J1cEr7EeSVGbM3cmVSqQ"/>
+ <tableConfiguration xmi:type="nattableconfiguration:TableConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable/configs/genericTreeTable.nattableconfiguration#/"/>
+ <columnAxisProvidersHistory xmi:type="nattableaxisprovider:SlaveObjectAxisProvider" xmi:id="_yBjG4TRvEeaB7KmLyE7Tdg" description="This axis provider provides available columns according to the rows of the table (features of the object displayed on the other axis)" name="UML Feature axis provider">
+ <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_yBjG4jRvEeaB7KmLyE7Tdg">
+ <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable/configs/genericTreeTable.nattableconfiguration#//@columnHeaderAxisConfiguration/@axisManagers.0"/>
+ <element xmi:type="ecore:EAttribute" href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement/name"/>
+ </axis>
+ </columnAxisProvidersHistory>
+ <rowAxisProvidersHistory xmi:type="nattableaxisprovider:MasterObjectAxisProvider" xmi:id="_yBjG4zRvEeaB7KmLyE7Tdg" description="This axis provider manages the rows, according to the wanted hierarchy" name="HierarchicalRowAxisManager" disconnectSlave="true"/>
+ <localRowHeaderAxisConfiguration xmi:type="nattableaxisconfiguration:LocalTableHeaderAxisConfiguration" xmi:id="_zA8uYDRvEeaB7KmLyE7Tdg" indexStyle="NUMERIC">
+ <styles xmi:type="nattablestyle:IntValueStyle" xmi:id="_zA9VcDRvEeaB7KmLyE7Tdg" name="rowLabelWidth" intValue="222"/>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:TreeFillingConfiguration" xmi:id="_JfZuEDSUEea90_Bat7Mf2Q" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_JfZuETSUEea90_Bat7Mf2Q" alias="">
+ <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//Element/ownedElement"/>
+ </axisUsedAsAxisProvider>
+ <labelProvider xmi:type="nattablelabelprovider:FeatureLabelProviderConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable/configs/genericTreeTable.nattableconfiguration#//@rowHeaderAxisConfiguration/@ownedLabelConfigurations.1"/>
+ </ownedAxisConfigurations>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:TreeFillingConfiguration" xmi:id="_JfZuEjSUEea90_Bat7Mf2Q" depth="1" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_JfZuEzSUEea90_Bat7Mf2Q">
+ <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//Activity/ownedNode"/>
+ </axisUsedAsAxisProvider>
+ <labelProvider xmi:type="nattablelabelprovider:FeatureLabelProviderConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable/configs/genericTreeTable.nattableconfiguration#//@rowHeaderAxisConfiguration/@ownedLabelConfigurations.1"/>
+ </ownedAxisConfigurations>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:TreeFillingConfiguration" xmi:id="_JfZuFDSUEea90_Bat7Mf2Q" depth="2" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_JfZuFTSUEea90_Bat7Mf2Q" alias="">
+ <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//Element/ownedElement"/>
+ </axisUsedAsAxisProvider>
+ <labelProvider xmi:type="nattablelabelprovider:FeatureLabelProviderConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable/configs/genericTreeTable.nattableconfiguration#//@rowHeaderAxisConfiguration/@ownedLabelConfigurations.1"/>
+ </ownedAxisConfigurations>
+ <axisManagerConfigurations xmi:type="nattableaxisconfiguration:AxisManagerConfiguration" xmi:id="_JfX44DSUEea90_Bat7Mf2Q" localSpecificConfigurations="_JfZuEDSUEea90_Bat7Mf2Q _JfZuEjSUEea90_Bat7Mf2Q _JfZuFDSUEea90_Bat7Mf2Q">
+ <axisManager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable/configs/genericTreeTable.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/>
+ </axisManagerConfigurations>
+ </localRowHeaderAxisConfiguration>
+</nattable:Table>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/bugs/bug495312/MoveElementInSynchronizedTable.uml b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/bugs/bug495312/MoveElementInSynchronizedTable.uml
new file mode 100644
index 00000000000..e1716b8209c
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/bugs/bug495312/MoveElementInSynchronizedTable.uml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_tj-IUDRvEeaB7KmLyE7Tdg" name="RootElement">
+ <packagedElement xmi:type="uml:Activity" xmi:id="_uXDLEDRvEeaB7KmLyE7Tdg" name="Activity1" node="_vDASIDRvEeaB7KmLyE7Tdg _v2j2ADRvEeaB7KmLyE7Tdg _wkujkDRvEeaB7KmLyE7Tdg _xFJJADRvEeaB7KmLyE7Tdg">
+ <node xmi:type="uml:AcceptEventAction" xmi:id="_vDASIDRvEeaB7KmLyE7Tdg" name="AcceptEventAction1"/>
+ <node xmi:type="uml:AcceptEventAction" xmi:id="_v2j2ADRvEeaB7KmLyE7Tdg" name="AcceptEventAction2"/>
+ <node xmi:type="uml:AcceptEventAction" xmi:id="_wkujkDRvEeaB7KmLyE7Tdg" name="AcceptEventAction3"/>
+ <node xmi:type="uml:AcceptEventAction" xmi:id="_xFJJADRvEeaB7KmLyE7Tdg" name="AcceptEventAction4"/>
+ </packagedElement>
+</uml:Model>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/bugs/MoveElementInSynchronizedTableTest.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/bugs/MoveElementInSynchronizedTableTest.java
new file mode 100644
index 00000000000..d119495154c
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/bugs/MoveElementInSynchronizedTableTest.java
@@ -0,0 +1,276 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST 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:
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.nattable.tests.bugs;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
+import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.nattable.common.editor.NatTableEditor;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TreeFillingConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderPackage;
+import org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.TableUtils;
+import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture;
+import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * This class allows to test the delete row elements action.
+ */
+@PluginResource("resources/bugs/bug495312/MoveElementInSynchronizedTable.di") //$NON-NLS-1$
+public class MoveElementInSynchronizedTableTest extends AbstractPapyrusTest {
+
+ /**
+ * The activity name in the model.
+ */
+ private static final String ACTIVITY_NAME = "Activity1"; //$NON-NLS-1$
+
+ /**
+ * The first accept event action name in the model.
+ */
+ private static final String ACCEPT_EVENT_ACTION_1 = "AcceptEventAction1"; //$NON-NLS-1$
+
+ /**
+ * The second accept event action name in the model.
+ */
+ private static final String ACCEPT_EVENT_ACTION_2 = "AcceptEventAction2"; //$NON-NLS-1$
+
+ /**
+ * The third accept event action name in the model.
+ */
+ private static final String ACCEPT_EVENT_ACTION_3 = "AcceptEventAction3"; //$NON-NLS-1$
+
+ /**
+ * The fourth accept event action name in the model.
+ */
+ private static final String ACCEPT_EVENT_ACTION_4 = "AcceptEventAction4"; //$NON-NLS-1$
+
+ /**
+ * The table name.
+ */
+ private static final String TABLE_NAME = "GenericTreeTable0"; //$NON-NLS-1$
+
+ /**
+ * The papyrus fixture.
+ */
+ @Rule
+ public final PapyrusEditorFixture fixture = new PapyrusEditorFixture();
+
+ /**
+ * The current model.
+ */
+ public Model model = null;
+
+ /**
+ * The nattable model manager.
+ */
+ public INattableModelManager currentManager = null;
+
+ /**
+ * Constructor.
+ */
+ public MoveElementInSynchronizedTableTest() {
+ super();
+ }
+
+ /**
+ * Initialize.
+ */
+ @Before
+ public void init() {
+ // Get the model
+ model = (Model) fixture.getModel();
+ Assert.assertNotNull("RootModel is null", model); //$NON-NLS-1$
+
+ // Get the table and open it
+ final Table mainTable = TableUtils.getNotationFirstTable(fixture.getModelSet(), TABLE_NAME);
+ fixture.getPageManager().openPage(mainTable);
+ fixture.flushDisplayEvents();
+
+ // Get the table and its manager
+ final IPageManager pageManager = fixture.getPageManager();
+ final List<Object> pages = pageManager.allPages();
+ pageManager.openPage(pages.get(0));
+ final IEditorPart part = fixture.getEditor().getActiveEditor();
+ Assert.assertTrue(part instanceof NatTableEditor);
+ final NatTableEditor editor = (NatTableEditor) part;
+ currentManager = (INattableModelManager) editor.getAdapter(INattableModelManager.class);
+ Assert.assertTrue("The table manage must be a tree table manager", currentManager instanceof TreeNattableModelManager); //$NON-NLS-1$
+
+ ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
+ fixture.flushDisplayEvents();
+ }
+
+ /**
+ * This allows to test the move of an accept event action of the activity.
+ *
+ * @throws Exception
+ * The caught exception.
+ */
+ @Test
+ public void testMoveElementInSynchronizedTable() throws Exception {
+ checkInitialContent();
+
+ // Get the editing domain
+ final TransactionalEditingDomain editingDomain = fixture.getEditingDomain();
+ Assert.assertNotNull("The editing domain cannot be null", editingDomain); //$NON-NLS-1$
+
+ // Destroy the row element
+ final IAxisManager axisManager = currentManager.getRowAxisManager();
+ Assert.assertNotNull(axisManager);
+
+ // Get the activity
+ final EObject activity = model.getPackagedElement(ACTIVITY_NAME);
+
+ List<EObject> nodes = new ArrayList<EObject>((List<EObject>) activity.eGet(UMLPackage.eINSTANCE.getActivity_OwnedNode()));
+ EObject second = nodes.remove(1);
+ nodes.add(2, second);
+
+ final IEditCommandRequest request = new SetRequest(editingDomain, activity, UMLPackage.eINSTANCE.getActivity_OwnedNode(), nodes);
+ final IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(activity);
+
+ // Execute the command
+ editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(commandProvider.getEditCommand(request)));
+ fixture.flushDisplayEvents();
+
+ checkAfterMove();
+
+ undo(editingDomain);
+ checkInitialContent();
+
+ redo(editingDomain);
+ checkAfterMove();
+ }
+
+ /**
+ * This allows to undo the previous command.
+ *
+ * @param editingDomain
+ * The current editing domain.
+ * @throws Exception
+ * The caught exception.
+ */
+ protected void undo(final TransactionalEditingDomain editingDomain) throws Exception {
+ editingDomain.getCommandStack().undo();
+ ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
+ fixture.flushDisplayEvents();
+ }
+
+ /**
+ * This allows to redo the previous command.
+ *
+ * @param editingDomain
+ * The current editing domain.
+ * @throws Exception
+ * The caught exception.
+ */
+ protected void redo(final TransactionalEditingDomain editingDomain) throws Exception {
+ editingDomain.getCommandStack().redo();
+ ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
+ fixture.flushDisplayEvents();
+ }
+
+ /**
+ * This allows to test the initial content of the table (size and row elements).
+ *
+ * @throws Exception
+ * The caught exception.
+ */
+ protected void checkInitialContent() throws Exception {
+ final List<Object> rowElements = currentManager.getRowElementsList();
+ Assert.assertEquals("The table content size is not the correct one", 7, rowElements.size()); //$NON-NLS-1$
+
+ checkTableContent(false);
+ }
+
+ /**
+ * This allows to test the content of the table (size and row elements) when the class is removed.
+ *
+ * @throws Exception
+ * The caught exception.
+ */
+ protected void checkAfterMove() throws Exception {
+ final List<Object> rowElements = currentManager.getRowElementsList();
+ Assert.assertEquals("The table content size is not the correct one", 7, rowElements.size()); //$NON-NLS-1$
+
+ checkTableContent(true);
+ }
+
+ /**
+ * This allows to check the table content with/without attribute, operation and parameter.
+ *
+ * @param hasMove
+ * Boolean to determinate if the move action was done.
+ * @throws Exception
+ * The caught exception.
+ */
+ protected void checkTableContent(final boolean hasMove) throws Exception {
+ int index = 0;
+
+ final List<Object> rowElements = currentManager.getRowElementsList();
+
+ final IAxis firstRow = (IAxis) rowElements.get(index++);
+ final Object firstRowRepresentedElement = firstRow.getElement();
+ Assert.assertTrue("The first row must be a tree filling configuration", firstRowRepresentedElement instanceof TreeFillingConfiguration); //$NON-NLS-1$
+
+ final IAxis secondRow = (IAxis) rowElements.get(index++);
+ final Object secondRowRepresentedElement = secondRow.getElement();
+ Assert.assertEquals("The first element must be a class", UMLPackage.eINSTANCE.getActivity(), ((EObject) secondRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the first element is not corresponding to the activity", ACTIVITY_NAME, ((org.eclipse.uml2.uml.Activity) secondRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis thirdRow = (IAxis) rowElements.get(index++);
+ final Object thirdRowRepresentedElement = thirdRow.getElement();
+ Assert.assertTrue("The third row must be a tree filling configuration", thirdRowRepresentedElement instanceof TreeFillingConfiguration); //$NON-NLS-1$
+
+ final IAxis fourthRow = (IAxis) rowElements.get(index++);
+ final Object fourthRowRepresentedElement = fourthRow.getElement();
+ Assert.assertEquals("The second element must be an accept event action", UMLPackage.eINSTANCE.getAcceptEventAction(), ((EObject) fourthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the second element is not corresponding to the first accept event action", ACCEPT_EVENT_ACTION_1, ((org.eclipse.uml2.uml.AcceptEventAction) fourthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis fifthRow = (IAxis) rowElements.get(index++);
+ final Object fifthRowRepresentedElement = fifthRow.getElement();
+ Assert.assertEquals("The third element must be an accept event action", UMLPackage.eINSTANCE.getAcceptEventAction(), ((EObject) fifthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the third element is not corresponding to the second accept event action", hasMove ? ACCEPT_EVENT_ACTION_3 : ACCEPT_EVENT_ACTION_2, ((org.eclipse.uml2.uml.AcceptEventAction) fifthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis sixthRow = (IAxis) rowElements.get(index++);
+ final Object sixthRowRepresentedElement = sixthRow.getElement();
+ Assert.assertEquals("The fourth element must be an accept event action", UMLPackage.eINSTANCE.getAcceptEventAction(), ((EObject) sixthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the fourth element is not corresponding to the third accept event action", hasMove ? ACCEPT_EVENT_ACTION_2 : ACCEPT_EVENT_ACTION_3, ((org.eclipse.uml2.uml.AcceptEventAction) sixthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis seventhRow = (IAxis) rowElements.get(index++);
+ final Object seventhRowRepresentedElement = seventhRow.getElement();
+ Assert.assertEquals("The fifth element must be an accept event action", UMLPackage.eINSTANCE.getAcceptEventAction(), ((EObject) seventhRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the fifth element is not corresponding to the fourth accept event action", ACCEPT_EVENT_ACTION_4, ((org.eclipse.uml2.uml.AcceptEventAction) seventhRowRepresentedElement).getName()); //$NON-NLS-1$
+ }
+} \ No newline at end of file
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/tests/AllTests.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/tests/AllTests.java
index 083bdb1726f..7be80d40627 100644
--- a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/tests/AllTests.java
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/tests/AllTests.java
@@ -13,6 +13,7 @@ package org.eclipse.papyrus.uml.nattable.tests.tests;
import org.eclipse.papyrus.uml.nattable.tests.bugs.DeleteRowElementTest;
+import org.eclipse.papyrus.uml.nattable.tests.bugs.MoveElementInSynchronizedTableTest;
import org.eclipse.papyrus.uml.nattable.tests.tests.configs.GenericTreeTableConfigurationTest;
import org.eclipse.papyrus.uml.nattable.tests.tests.configs.GenericTreeTableNattableConfigurationTest;
import org.junit.runner.RunWith;
@@ -25,7 +26,10 @@ import org.junit.runners.Suite.SuiteClasses;
GenericTreeTableNattableConfigurationTest.class,
// Delete row elements
- DeleteRowElementTest.class
+ DeleteRowElementTest.class,
+
+ // Bug 495312: Move Elements,
+ MoveElementInSynchronizedTableTest.class
})
public class AllTests {

Back to the top