Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus')
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/Activator.java116
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/bugs/MoveElementsTreeTableTest.java1360
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/ContentsAndExpandWithCategories_0_1_2_Tests.java370
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/OpenTableTest.java118
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/TableFillingAndExpandTest.java280
5 files changed, 1122 insertions, 1122 deletions
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/Activator.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/Activator.java
index f5016e66db2..0d26d393dfb 100644
--- a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/Activator.java
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/Activator.java
@@ -1,58 +1,58 @@
-package org.eclipse.papyrus.uml.nattable.clazz.config.tests;
-
-import org.eclipse.papyrus.infra.core.log.LogHelper;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.nattable.clazz.config.tests"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- public static LogHelper log;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- log = new LogHelper(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
+package org.eclipse.papyrus.uml.nattable.clazz.config.tests;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.nattable.clazz.config.tests"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ public static LogHelper log;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/bugs/MoveElementsTreeTableTest.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/bugs/MoveElementsTreeTableTest.java
index 6908ae6eda6..0f92a725376 100644
--- a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/bugs/MoveElementsTreeTableTest.java
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/bugs/MoveElementsTreeTableTest.java
@@ -1,680 +1,680 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST.
- *
- * 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.clazz.config.tests.bugs;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.command.UnexecutableCommand;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.command.MoveCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
-import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
-import org.eclipse.papyrus.infra.nattable.common.editor.NatTableEditor;
-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.tree.CollapseAndExpandActionsEnum;
-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.papyrus.junit.utils.rules.ShowView;
-import org.eclipse.papyrus.uml.nattable.clazz.config.tests.Activator;
-import org.eclipse.papyrus.views.modelexplorer.CustomCommonViewer;
-import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
-import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
-import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.navigator.dnd.NavigatorDnDService;
-import org.eclipse.ui.navigator.CommonDropAdapter;
-import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
-import org.eclipse.ui.navigator.CommonViewer;
-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 sort in the Hierarchical NatTable
- */
-@SuppressWarnings("restriction")
-@PluginResource("resources/bugs/bug471903/MoveElementsTreeTableTest.di") //$NON-NLS-1$
-@ShowView(value = "org.eclipse.papyrus.views.modelexplorer.modelexplorer") //$NON-NLS-1$
-public class MoveElementsTreeTableTest extends AbstractPapyrusTest {
-
- /**
- * The first class name in the model.
- */
- private static final String FIRST_CLASS = "Class1"; //$NON-NLS-1$
-
- /**
- * The second class name in the model.
- */
- private static final String SECOND_CLASS = "Class2"; //$NON-NLS-1$
-
- /**
- * The third class name in the model.
- */
- private static final String THIRD_CLASS = "Class3"; //$NON-NLS-1$
-
- /**
- * The fourth class name in the model.
- */
- private static final String FOURTH_CLASS = "Class4"; //$NON-NLS-1$
-
- /**
- * The first package name in the model.
- */
- private static final String FIRST_PACKAGE = "Package1"; //$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 model explorer part.
- */
- public IViewPart modelExplorerPart = null;
-
- /**
- * The model explorer view.
- */
- public ModelExplorerView modelExplorerView = null;
-
- /**
- * The nattable model manager.
- */
- public INattableModelManager currentManager = null;
-
- /**
- * Constructor.
- */
- public MoveElementsTreeTableTest() {
- 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
- Table mainTable = TableUtils.getNotationFirstTable(fixture.getModelSet(), TABLE_NAME);
- fixture.getPageManager().openPage(mainTable);
- fixture.flushDisplayEvents();
-
- // Get the model explorer part and view
- IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- modelExplorerPart = activeWorkbenchWindow.getActivePage().findView(ModelExplorerPageBookView.VIEW_ID); // $NON-NLS-1$
- Assert.assertNotNull("The ModelExplorer view is not open", modelExplorerPart); //$NON-NLS-1$
- Assert.assertTrue("The ModelExplorer is not a common navigator", modelExplorerPart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
- modelExplorerView = (ModelExplorerView) ((ModelExplorerPageBookView) modelExplorerPart).getActiveView();
- Assert.assertNotNull("The model explorer view cannot be null", modelExplorerView); //$NON-NLS-1$
-
- // 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$
-
- // Expand the table
- ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
- }
-
- /**
- * This allows to test the move in the same parent.
- *
- * @throws Exception
- * The exception
- */
- @Test
- public void testSimpleMoveSameParent() throws Exception {
- // Check the initial table content
- checkInitialTable(currentManager.getRowElementsList());
-
- // Get the editing domain
- TransactionalEditingDomain editingDomain = fixture.getEditingDomain();
- Assert.assertNotNull("The editing domain cannot be null", editingDomain); //$NON-NLS-1$
-
- // Get the first class
- final EObject firstClass = model.getPackagedElement(FIRST_CLASS);
-
- // Create the move command
- Command moveCommand = MoveCommand.create(editingDomain, model, UMLPackage.eINSTANCE.getPackage_PackagedElement(), firstClass, 4);
-
- // Execute the command
- editingDomain.getCommandStack().execute(moveCommand);
- fixture.flushDisplayEvents();
-
- // Check the table content
- checkSimpleMoveSameParentTable(currentManager.getRowElementsList());
-
- // Undo the command
- editingDomain.getCommandStack().undo();
- fixture.flushDisplayEvents();
-
- // check the table content
- checkInitialTable(currentManager.getRowElementsList());
-
- // Redo the command
- editingDomain.getCommandStack().redo();
- fixture.flushDisplayEvents();
-
- // Check the table content
- checkSimpleMoveSameParentTable(currentManager.getRowElementsList());
- }
-
- /**
- * This allows to test the move in the same parent.
- *
- * @throws Exception
- * The exception
- */
- @Test
- public void testMultipleMoveSameParent() throws Exception {
- // Check the initial table content
- checkInitialTable(currentManager.getRowElementsList());
-
- // Get the editing domain
- TransactionalEditingDomain editingDomain = fixture.getEditingDomain();
- Assert.assertNotNull("The editing domain cannot be null", editingDomain); //$NON-NLS-1$
-
- // Get the first class
- final EObject firstClass = model.getPackagedElement(FIRST_CLASS);
- final EObject secondClass = model.getPackagedElement(SECOND_CLASS);
-
- // Create the move command
- final CompoundCommand multipleMoveCommand = new CompoundCommand();
- multipleMoveCommand.append(MoveCommand.create(editingDomain, model, UMLPackage.eINSTANCE.getPackage_PackagedElement(), firstClass, 4));
- multipleMoveCommand.append(MoveCommand.create(editingDomain, model, UMLPackage.eINSTANCE.getPackage_PackagedElement(), secondClass, 4));
-
- // Execute the command
- editingDomain.getCommandStack().execute(multipleMoveCommand);
- fixture.flushDisplayEvents();
-
- // Check the table content
- checkMultipleMoveSameParentTable(currentManager.getRowElementsList());
-
- // Undo the command
- editingDomain.getCommandStack().undo();
- fixture.flushDisplayEvents();
-
- // check the table content
- checkInitialTable(currentManager.getRowElementsList());
-
- // Redo the command
- editingDomain.getCommandStack().redo();
- fixture.flushDisplayEvents();
-
- // Check the table content
- checkMultipleMoveSameParentTable(currentManager.getRowElementsList());
- }
-
- /**
- * This allows to test the move in a sub element of its current parent.
- *
- * @throws Exception
- * The exception
- */
- @Test
- public void testSimpleMoveSubElementParent() throws Exception {
- // Check the initial table content
- checkInitialTable(currentManager.getRowElementsList());
-
- // Get the editing domain
- TransactionalEditingDomain editingDomain = fixture.getEditingDomain();
- Assert.assertNotNull("The editing domain cannot be null", editingDomain); //$NON-NLS-1$
-
- // Get the first class
- final EObject firstClass = model.getPackagedElement(FIRST_CLASS);
- final EObject firstPackage = model.getPackagedElement(FIRST_PACKAGE);
-
- // Get the move command
- final Command moveCommand = getDropElementsCommand(Arrays.asList(firstClass), firstPackage);
-
- // Execute the command
- editingDomain.getCommandStack().execute(moveCommand);
- fixture.flushDisplayEvents();
- // Expand the table
- ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
- fixture.flushDisplayEvents();
-
- // Check the table content
- checkSimpleMoveSubElementsParentTable(currentManager.getRowElementsList());
-
- // Undo the command
- editingDomain.getCommandStack().undo();
- fixture.flushDisplayEvents();
-
- // check the table content
- checkInitialTable(currentManager.getRowElementsList());
-
- // Redo the command
- editingDomain.getCommandStack().redo();
- fixture.flushDisplayEvents();
- ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
- fixture.flushDisplayEvents();
-
- // Check the table content
- checkSimpleMoveSubElementsParentTable(currentManager.getRowElementsList());
- }
-
- /**
- * This allows to test the move in a sub element of its current parent.
- *
- * @throws Exception
- * The exception
- */
- @Test
- public void testMultipleMoveSubElementParent() throws Exception {
- // Check the initial table content
- checkInitialTable(currentManager.getRowElementsList());
-
- // Get the editing domain
- TransactionalEditingDomain editingDomain = fixture.getEditingDomain();
- Assert.assertNotNull("The editing domain cannot be null", editingDomain); //$NON-NLS-1$
-
- // Get the first class
- final EObject firstClass = model.getPackagedElement(FIRST_CLASS);
- final EObject secondClass = model.getPackagedElement(SECOND_CLASS);
- final EObject firstPackage = model.getPackagedElement(FIRST_PACKAGE);
-
- // Get the move command
- final List<EObject> classes = new ArrayList<EObject>(2);
- classes.add(firstClass);
- classes.add(secondClass);
- final Command moveCommand = getDropElementsCommand(classes, firstPackage);
-
- // Execute the command
- editingDomain.getCommandStack().execute(moveCommand);
- fixture.flushDisplayEvents();
- // Expand the table
- ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
- fixture.flushDisplayEvents();
-
- // Check the table content
- checkMultipleMoveSubElementsParentTable(currentManager.getRowElementsList());
-
- // Undo the command
- editingDomain.getCommandStack().undo();
- fixture.flushDisplayEvents();
-
- // check the table content
- checkInitialTable(currentManager.getRowElementsList());
-
- // Redo the command
- editingDomain.getCommandStack().redo();
- fixture.flushDisplayEvents();
- ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
- fixture.flushDisplayEvents();
-
- // Check the table content
- checkMultipleMoveSubElementsParentTable(currentManager.getRowElementsList());
- }
-
- /**
- * Get the drop elements command from sources Elements to a target element.
- *
- * @param sourceElements
- * The source elements to drag and drop.
- * @param targetElement
- * The target element where drop the source elements.
- * @return The command corresponding to the drag and drop.
- * @throws Exception
- * The exception.
- */
- public Command getDropElementsCommand(final List<EObject> sourceElements, final EObject targetElement) throws Exception {
- Command command = UnexecutableCommand.INSTANCE;
-
- // Create the target element and select and reveal the first class
- Object target = findSemanticModelElementItem(targetElement);
- selectAndReveal(sourceElements);
- fixture.flushDisplayEvents();
-
- // Get the DnD service
- final CommonViewer viewer = modelExplorerView.getCommonViewer();
- NavigatorDnDService dndService = (NavigatorDnDService) viewer.getNavigatorContentService().getDnDService();
- Assert.assertNotNull("Impossible to find dnd service", dndService); //$NON-NLS-1$
-
- // Manage the drop gtom the papyris drop assistant
- CommonDropAdapter commonDropAdapter = ((CustomCommonViewer) modelExplorerView.getCommonViewer()).getDropAdapter();
- CommonDropAdapterAssistant[] commonDropAdapterAssistants = dndService.findCommonDropAdapterAssistants(target, (IStructuredSelection) viewer.getSelection());
- for (CommonDropAdapterAssistant assistant : commonDropAdapterAssistants) {
- // try to adapt to a Papyrus drop assistant. If not, send a warning
- if (assistant instanceof org.eclipse.papyrus.views.modelexplorer.dnd.CommonDropAdapterAssistant) {
- org.eclipse.papyrus.views.modelexplorer.dnd.CommonDropAdapterAssistant papyrusAssistant = (org.eclipse.papyrus.views.modelexplorer.dnd.CommonDropAdapterAssistant) assistant;
- Field currentOperationField = ViewerDropAdapter.class.getDeclaredField("currentOperation"); //$NON-NLS-1$
- Assert.assertNotNull(currentOperationField);
- currentOperationField.setAccessible(true);
- currentOperationField.set(commonDropAdapter, DND.DROP_MOVE);
- Field currentLocationField = ViewerDropAdapter.class.getDeclaredField("currentLocation"); //$NON-NLS-1$
- Assert.assertNotNull(currentLocationField);
- currentLocationField.setAccessible(true);
- currentLocationField.set(commonDropAdapter, ViewerDropAdapter.LOCATION_ON);
- LocalSelectionTransfer.getTransfer().setSelection(modelExplorerView.getCommonViewer().getSelection());
- command = papyrusAssistant.getDrop(target);
- }
- }
-
- return command;
- }
-
- /**
- * Retrieves the Model Element Item for the given EObject
- *
- * @param objectToFind
- * object represented by the searched item
- * @return the {@link ModelElementItem} that corresponds to the diagram
- * @throws Exception
- * exception thrown in case of issue
- */
- protected EObjectTreeElement findSemanticModelElementItem(final EObject objectToFind) throws Exception {
- selectAndReveal(Arrays.asList(objectToFind));
- IStructuredSelection selection = (IStructuredSelection) modelExplorerPart.getSite().getSelectionProvider().getSelection();
- Assert.assertEquals("One and only one object should be selected", 1, selection.size()); //$NON-NLS-1$
- Object selectedElement = selection.getFirstElement();
- Assert.assertTrue("Selection should be a model item element", selectedElement instanceof EObjectTreeElement); //$NON-NLS-1$
- Assert.assertTrue("Selection should be linked to a EObject", ((EObjectTreeElement) selectedElement).getEObject() instanceof EObject); //$NON-NLS-1$
- Assert.assertTrue("Selection should be linked to the Object: " + objectToFind, ((EObjectTreeElement) selectedElement).getEObject().equals(objectToFind)); //$NON-NLS-1$
- return (EObjectTreeElement) selectedElement;
- }
-
- /**
- * Selects and reveal the specified list of elements
- *
- * @param newElements
- * the list of objects to select
- * @throws Exception
- * exception thrown in case element could not be selected
- */
- protected static void selectAndReveal(final List<EObject> newElements) throws Exception {
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- try {
- // Retrieve model explorer
- ModelExplorerView modelExplorerView = null;
-
- ModelExplorerPageBookView bookViewPart = (ModelExplorerPageBookView) NavigatorUtils.findViewPart(ModelExplorerPageBookView.VIEW_ID);
- if (bookViewPart != null) {
- modelExplorerView = (ModelExplorerView) bookViewPart.getActiveView();
- }
-
- // Set selection on new element in the model explorer
- if ((modelExplorerView != null) && (newElements != null)) {
- List<EObject> semanticElementList = new ArrayList<EObject>();
- semanticElementList.addAll(newElements);
- modelExplorerView.revealSemanticElement(semanticElementList);
- } else {
- throw new Exception("Impossible to find the model explorer required to select: " + newElements); //$NON-NLS-1$
- }
- } catch (Exception ex) {
- Activator.log.error(ex);
- }
- }
- });
- }
-
- /**
- * Check the initial table content display.
- *
- * @param rowElements
- * the row elements
- * @throws Exception
- * The exception
- */
- private void checkInitialTable(final List<?> rowElements) throws Exception {
- Assert.assertEquals("The initial table does not contains the correct number of rows", 6, rowElements.size()); //$NON-NLS-1$
-
- final IAxis firstRow = (IAxis) rowElements.get(0);
- 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(1);
- final Object secondRowRepresentedElement = secondRow.getElement();
- Assert.assertEquals("The first element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) secondRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the first element is not corresponding to the first class", FIRST_CLASS, ((org.eclipse.uml2.uml.Class) secondRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis thirdRow = (IAxis) rowElements.get(2);
- final Object thirdRowRepresentedElement = thirdRow.getElement();
- Assert.assertEquals("The second element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) thirdRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the second element is not corresponding to the second class", SECOND_CLASS, ((org.eclipse.uml2.uml.Class) thirdRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis fourthRow = (IAxis) rowElements.get(3);
- final Object fourthRowRepresentedElement = fourthRow.getElement();
- Assert.assertEquals("The third element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) fourthRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the third element is not corresponding to the third class", THIRD_CLASS, ((org.eclipse.uml2.uml.Class) fourthRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis fifthRow = (IAxis) rowElements.get(4);
- final Object fifthRowRepresentedElement = fifthRow.getElement();
- Assert.assertEquals("The fourth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) fifthRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the fourth element is not corresponding to the fourth class", FOURTH_CLASS, ((org.eclipse.uml2.uml.Class) fifthRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis sixthRow = (IAxis) rowElements.get(5);
- final Object sixthColumnRepresentedElement = sixthRow.getElement();
- Assert.assertEquals("The fifth element must be a package", UMLPackage.eINSTANCE.getPackage(), ((EObject) sixthColumnRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the fifth element is not corresponding to the first package", FIRST_PACKAGE, ((org.eclipse.uml2.uml.Package) sixthColumnRepresentedElement).getName()); //$NON-NLS-1$
- }
-
- /**
- * Check the initial table content display.
- *
- * @param rowElements
- * the row elements
- * @throws Exception
- * The exception
- */
- private void checkSimpleMoveSameParentTable(final List<?> rowElements) throws Exception {
- Assert.assertEquals("The initial table does not contains the correct number of rows", 6, rowElements.size()); //$NON-NLS-1$
-
- final IAxis firstRow = (IAxis) rowElements.get(0);
- 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(1);
- final Object secondRowRepresentedElement = secondRow.getElement();
- Assert.assertEquals("The first element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) secondRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the first element is not corresponding to the second class", SECOND_CLASS, ((org.eclipse.uml2.uml.Class) secondRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis thirdRow = (IAxis) rowElements.get(2);
- final Object thirdRowRepresentedElement = thirdRow.getElement();
- Assert.assertEquals("The second element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) thirdRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the second element is not corresponding to the third class", THIRD_CLASS, ((org.eclipse.uml2.uml.Class) thirdRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis fourthRow = (IAxis) rowElements.get(3);
- final Object fourthRowRepresentedElement = fourthRow.getElement();
- Assert.assertEquals("The third element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) fourthRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the third element is not corresponding to the fourth class", FOURTH_CLASS, ((org.eclipse.uml2.uml.Class) fourthRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis fifthRow = (IAxis) rowElements.get(4);
- final Object fifthRowRepresentedElement = fifthRow.getElement();
- Assert.assertEquals("The fourth element must be a package", UMLPackage.eINSTANCE.getPackage(), ((EObject) fifthRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the fourth element is not corresponding to the first package", FIRST_PACKAGE, ((org.eclipse.uml2.uml.Package) fifthRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis sixthRow = (IAxis) rowElements.get(5);
- final Object sixthColumnRepresentedElement = sixthRow.getElement();
- Assert.assertEquals("The fifth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) sixthColumnRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the fifth element is not corresponding to the first class", FIRST_CLASS, ((org.eclipse.uml2.uml.Class) sixthColumnRepresentedElement).getName()); //$NON-NLS-1$
- }
-
- /**
- * Check the initial table content display.
- *
- * @param rowElements
- * the row elements
- * @throws Exception
- * The exception
- */
- private void checkMultipleMoveSameParentTable(final List<?> rowElements) throws Exception {
- Assert.assertEquals("The initial table does not contains the correct number of rows", 6, rowElements.size()); //$NON-NLS-1$
-
- final IAxis firstRow = (IAxis) rowElements.get(0);
- 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(1);
- final Object secondRowRepresentedElement = secondRow.getElement();
- Assert.assertEquals("The first element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) secondRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the first element is not corresponding to the third class", THIRD_CLASS, ((org.eclipse.uml2.uml.Class) secondRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis thirdRow = (IAxis) rowElements.get(2);
- final Object thirdRowRepresentedElement = thirdRow.getElement();
- Assert.assertEquals("The second element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) thirdRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the second element is not corresponding to the fourth class", FOURTH_CLASS, ((org.eclipse.uml2.uml.Class) thirdRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis fourthRow = (IAxis) rowElements.get(3);
- final Object fourthRowRepresentedElement = fourthRow.getElement();
- Assert.assertEquals("The third element must be a package", UMLPackage.eINSTANCE.getPackage(), ((EObject) fourthRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the third element is not corresponding to the first package", FIRST_PACKAGE, ((org.eclipse.uml2.uml.Package) fourthRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis fifthRow = (IAxis) rowElements.get(4);
- final Object fifthRowRepresentedElement = fifthRow.getElement();
- Assert.assertEquals("The fourth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) fifthRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the fourth element is not corresponding to the first class", FIRST_CLASS, ((org.eclipse.uml2.uml.Class) fifthRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis sixthRow = (IAxis) rowElements.get(5);
- final Object sixthColumnRepresentedElement = sixthRow.getElement();
- Assert.assertEquals("The fifth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) sixthColumnRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the fifth element is not corresponding to the second class", SECOND_CLASS, ((org.eclipse.uml2.uml.Class) sixthColumnRepresentedElement).getName()); //$NON-NLS-1$
- }
-
- /**
- * Check the initial table content display.
- *
- * @param rowElements
- * the row elements
- * @throws Exception
- * The exception
- */
- private void checkSimpleMoveSubElementsParentTable(final List<?> rowElements) throws Exception {
- Assert.assertEquals("The initial table does not contains the correct number of rows", 7, rowElements.size()); //$NON-NLS-1$
-
- final IAxis firstRow = (IAxis) rowElements.get(0);
- 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(1);
- final Object secondRowRepresentedElement = secondRow.getElement();
- Assert.assertEquals("The first element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) secondRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the first element is not corresponding to the second class", SECOND_CLASS, ((org.eclipse.uml2.uml.Class) secondRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis thirdRow = (IAxis) rowElements.get(2);
- final Object thirdRowRepresentedElement = thirdRow.getElement();
- Assert.assertEquals("The second element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) thirdRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the second element is not corresponding to the third class", THIRD_CLASS, ((org.eclipse.uml2.uml.Class) thirdRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis fourthRow = (IAxis) rowElements.get(3);
- final Object fourthRowRepresentedElement = fourthRow.getElement();
- Assert.assertEquals("The third element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) fourthRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the third element is not corresponding to the fourth class", FOURTH_CLASS, ((org.eclipse.uml2.uml.Class) fourthRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis fifthRow = (IAxis) rowElements.get(4);
- final Object fifthRowRepresentedElement = fifthRow.getElement();
- Assert.assertEquals("The fourth element must be a package", UMLPackage.eINSTANCE.getPackage(), ((EObject) fifthRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the fourth element is not corresponding to the first package", FIRST_PACKAGE, ((org.eclipse.uml2.uml.Package) fifthRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis sixthRow = (IAxis) rowElements.get(5);
- final Object sixthRowRepresentedElement = sixthRow.getElement();
- Assert.assertTrue("The sixth row must be a tree filling configuration", sixthRowRepresentedElement instanceof TreeFillingConfiguration); //$NON-NLS-1$
-
- final IAxis seventhRow = (IAxis) rowElements.get(6);
- final Object seventhColumnRepresentedElement = seventhRow.getElement();
- Assert.assertEquals("The fifth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) seventhColumnRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the fifth element is not corresponding to the first class", FIRST_CLASS, ((org.eclipse.uml2.uml.Class) seventhColumnRepresentedElement).getName()); //$NON-NLS-1$
- }
-
- /**
- * Check the initial table content display.
- *
- * @param rowElements
- * the row elements
- * @throws Exception
- * The exception
- */
- private void checkMultipleMoveSubElementsParentTable(final List<?> rowElements) throws Exception {
- Assert.assertEquals("The initial table does not contains the correct number of rows", 7, rowElements.size()); //$NON-NLS-1$
-
- final IAxis firstRow = (IAxis) rowElements.get(0);
- 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(1);
- final Object secondRowRepresentedElement = secondRow.getElement();
- Assert.assertEquals("The first element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) secondRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the first element is not corresponding to the third class", THIRD_CLASS, ((org.eclipse.uml2.uml.Class) secondRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis thirdRow = (IAxis) rowElements.get(2);
- final Object thirdRowRepresentedElement = thirdRow.getElement();
- Assert.assertEquals("The second element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) thirdRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the second element is not corresponding to the fourth class", FOURTH_CLASS, ((org.eclipse.uml2.uml.Class) thirdRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis fourthRow = (IAxis) rowElements.get(3);
- final Object fourthRowRepresentedElement = fourthRow.getElement();
- Assert.assertEquals("The third element must be a package", UMLPackage.eINSTANCE.getPackage(), ((EObject) fourthRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the third element is not corresponding to the first package", FIRST_PACKAGE, ((org.eclipse.uml2.uml.Package) fourthRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis sixthRow = (IAxis) rowElements.get(4);
- final Object sixthRowRepresentedElement = sixthRow.getElement();
- Assert.assertTrue("The sixth row must be a tree filling configuration", sixthRowRepresentedElement instanceof TreeFillingConfiguration); //$NON-NLS-1$
-
- final IAxis fifthRow = (IAxis) rowElements.get(5);
- final Object fifthRowRepresentedElement = fifthRow.getElement();
- Assert.assertEquals("The fourth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) fifthRowRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the fourth element is not corresponding to the first class", FIRST_CLASS, ((org.eclipse.uml2.uml.Class) fifthRowRepresentedElement).getName()); //$NON-NLS-1$
-
- final IAxis seventhRow = (IAxis) rowElements.get(6);
- final Object seventhColumnRepresentedElement = seventhRow.getElement();
- Assert.assertEquals("The fifth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) seventhColumnRepresentedElement).eClass()); //$NON-NLS-1$
- Assert.assertEquals("The name of the fifth element is not corresponding to the second class", SECOND_CLASS, ((org.eclipse.uml2.uml.Class) seventhColumnRepresentedElement).getName()); //$NON-NLS-1$
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST.
+ *
+ * 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.clazz.config.tests.bugs;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.MoveCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ViewerDropAdapter;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
+import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
+import org.eclipse.papyrus.infra.nattable.common.editor.NatTableEditor;
+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.tree.CollapseAndExpandActionsEnum;
+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.papyrus.junit.utils.rules.ShowView;
+import org.eclipse.papyrus.uml.nattable.clazz.config.tests.Activator;
+import org.eclipse.papyrus.views.modelexplorer.CustomCommonViewer;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
+import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.navigator.dnd.NavigatorDnDService;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
+import org.eclipse.ui.navigator.CommonViewer;
+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 sort in the Hierarchical NatTable
+ */
+@SuppressWarnings("restriction")
+@PluginResource("resources/bugs/bug471903/MoveElementsTreeTableTest.di") //$NON-NLS-1$
+@ShowView(value = "org.eclipse.papyrus.views.modelexplorer.modelexplorer") //$NON-NLS-1$
+public class MoveElementsTreeTableTest extends AbstractPapyrusTest {
+
+ /**
+ * The first class name in the model.
+ */
+ private static final String FIRST_CLASS = "Class1"; //$NON-NLS-1$
+
+ /**
+ * The second class name in the model.
+ */
+ private static final String SECOND_CLASS = "Class2"; //$NON-NLS-1$
+
+ /**
+ * The third class name in the model.
+ */
+ private static final String THIRD_CLASS = "Class3"; //$NON-NLS-1$
+
+ /**
+ * The fourth class name in the model.
+ */
+ private static final String FOURTH_CLASS = "Class4"; //$NON-NLS-1$
+
+ /**
+ * The first package name in the model.
+ */
+ private static final String FIRST_PACKAGE = "Package1"; //$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 model explorer part.
+ */
+ public IViewPart modelExplorerPart = null;
+
+ /**
+ * The model explorer view.
+ */
+ public ModelExplorerView modelExplorerView = null;
+
+ /**
+ * The nattable model manager.
+ */
+ public INattableModelManager currentManager = null;
+
+ /**
+ * Constructor.
+ */
+ public MoveElementsTreeTableTest() {
+ 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
+ Table mainTable = TableUtils.getNotationFirstTable(fixture.getModelSet(), TABLE_NAME);
+ fixture.getPageManager().openPage(mainTable);
+ fixture.flushDisplayEvents();
+
+ // Get the model explorer part and view
+ IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ modelExplorerPart = activeWorkbenchWindow.getActivePage().findView(ModelExplorerPageBookView.VIEW_ID); // $NON-NLS-1$
+ Assert.assertNotNull("The ModelExplorer view is not open", modelExplorerPart); //$NON-NLS-1$
+ Assert.assertTrue("The ModelExplorer is not a common navigator", modelExplorerPart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
+ modelExplorerView = (ModelExplorerView) ((ModelExplorerPageBookView) modelExplorerPart).getActiveView();
+ Assert.assertNotNull("The model explorer view cannot be null", modelExplorerView); //$NON-NLS-1$
+
+ // 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$
+
+ // Expand the table
+ ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
+ }
+
+ /**
+ * This allows to test the move in the same parent.
+ *
+ * @throws Exception
+ * The exception
+ */
+ @Test
+ public void testSimpleMoveSameParent() throws Exception {
+ // Check the initial table content
+ checkInitialTable(currentManager.getRowElementsList());
+
+ // Get the editing domain
+ TransactionalEditingDomain editingDomain = fixture.getEditingDomain();
+ Assert.assertNotNull("The editing domain cannot be null", editingDomain); //$NON-NLS-1$
+
+ // Get the first class
+ final EObject firstClass = model.getPackagedElement(FIRST_CLASS);
+
+ // Create the move command
+ Command moveCommand = MoveCommand.create(editingDomain, model, UMLPackage.eINSTANCE.getPackage_PackagedElement(), firstClass, 4);
+
+ // Execute the command
+ editingDomain.getCommandStack().execute(moveCommand);
+ fixture.flushDisplayEvents();
+
+ // Check the table content
+ checkSimpleMoveSameParentTable(currentManager.getRowElementsList());
+
+ // Undo the command
+ editingDomain.getCommandStack().undo();
+ fixture.flushDisplayEvents();
+
+ // check the table content
+ checkInitialTable(currentManager.getRowElementsList());
+
+ // Redo the command
+ editingDomain.getCommandStack().redo();
+ fixture.flushDisplayEvents();
+
+ // Check the table content
+ checkSimpleMoveSameParentTable(currentManager.getRowElementsList());
+ }
+
+ /**
+ * This allows to test the move in the same parent.
+ *
+ * @throws Exception
+ * The exception
+ */
+ @Test
+ public void testMultipleMoveSameParent() throws Exception {
+ // Check the initial table content
+ checkInitialTable(currentManager.getRowElementsList());
+
+ // Get the editing domain
+ TransactionalEditingDomain editingDomain = fixture.getEditingDomain();
+ Assert.assertNotNull("The editing domain cannot be null", editingDomain); //$NON-NLS-1$
+
+ // Get the first class
+ final EObject firstClass = model.getPackagedElement(FIRST_CLASS);
+ final EObject secondClass = model.getPackagedElement(SECOND_CLASS);
+
+ // Create the move command
+ final CompoundCommand multipleMoveCommand = new CompoundCommand();
+ multipleMoveCommand.append(MoveCommand.create(editingDomain, model, UMLPackage.eINSTANCE.getPackage_PackagedElement(), firstClass, 4));
+ multipleMoveCommand.append(MoveCommand.create(editingDomain, model, UMLPackage.eINSTANCE.getPackage_PackagedElement(), secondClass, 4));
+
+ // Execute the command
+ editingDomain.getCommandStack().execute(multipleMoveCommand);
+ fixture.flushDisplayEvents();
+
+ // Check the table content
+ checkMultipleMoveSameParentTable(currentManager.getRowElementsList());
+
+ // Undo the command
+ editingDomain.getCommandStack().undo();
+ fixture.flushDisplayEvents();
+
+ // check the table content
+ checkInitialTable(currentManager.getRowElementsList());
+
+ // Redo the command
+ editingDomain.getCommandStack().redo();
+ fixture.flushDisplayEvents();
+
+ // Check the table content
+ checkMultipleMoveSameParentTable(currentManager.getRowElementsList());
+ }
+
+ /**
+ * This allows to test the move in a sub element of its current parent.
+ *
+ * @throws Exception
+ * The exception
+ */
+ @Test
+ public void testSimpleMoveSubElementParent() throws Exception {
+ // Check the initial table content
+ checkInitialTable(currentManager.getRowElementsList());
+
+ // Get the editing domain
+ TransactionalEditingDomain editingDomain = fixture.getEditingDomain();
+ Assert.assertNotNull("The editing domain cannot be null", editingDomain); //$NON-NLS-1$
+
+ // Get the first class
+ final EObject firstClass = model.getPackagedElement(FIRST_CLASS);
+ final EObject firstPackage = model.getPackagedElement(FIRST_PACKAGE);
+
+ // Get the move command
+ final Command moveCommand = getDropElementsCommand(Arrays.asList(firstClass), firstPackage);
+
+ // Execute the command
+ editingDomain.getCommandStack().execute(moveCommand);
+ fixture.flushDisplayEvents();
+ // Expand the table
+ ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
+ fixture.flushDisplayEvents();
+
+ // Check the table content
+ checkSimpleMoveSubElementsParentTable(currentManager.getRowElementsList());
+
+ // Undo the command
+ editingDomain.getCommandStack().undo();
+ fixture.flushDisplayEvents();
+
+ // check the table content
+ checkInitialTable(currentManager.getRowElementsList());
+
+ // Redo the command
+ editingDomain.getCommandStack().redo();
+ fixture.flushDisplayEvents();
+ ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
+ fixture.flushDisplayEvents();
+
+ // Check the table content
+ checkSimpleMoveSubElementsParentTable(currentManager.getRowElementsList());
+ }
+
+ /**
+ * This allows to test the move in a sub element of its current parent.
+ *
+ * @throws Exception
+ * The exception
+ */
+ @Test
+ public void testMultipleMoveSubElementParent() throws Exception {
+ // Check the initial table content
+ checkInitialTable(currentManager.getRowElementsList());
+
+ // Get the editing domain
+ TransactionalEditingDomain editingDomain = fixture.getEditingDomain();
+ Assert.assertNotNull("The editing domain cannot be null", editingDomain); //$NON-NLS-1$
+
+ // Get the first class
+ final EObject firstClass = model.getPackagedElement(FIRST_CLASS);
+ final EObject secondClass = model.getPackagedElement(SECOND_CLASS);
+ final EObject firstPackage = model.getPackagedElement(FIRST_PACKAGE);
+
+ // Get the move command
+ final List<EObject> classes = new ArrayList<EObject>(2);
+ classes.add(firstClass);
+ classes.add(secondClass);
+ final Command moveCommand = getDropElementsCommand(classes, firstPackage);
+
+ // Execute the command
+ editingDomain.getCommandStack().execute(moveCommand);
+ fixture.flushDisplayEvents();
+ // Expand the table
+ ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
+ fixture.flushDisplayEvents();
+
+ // Check the table content
+ checkMultipleMoveSubElementsParentTable(currentManager.getRowElementsList());
+
+ // Undo the command
+ editingDomain.getCommandStack().undo();
+ fixture.flushDisplayEvents();
+
+ // check the table content
+ checkInitialTable(currentManager.getRowElementsList());
+
+ // Redo the command
+ editingDomain.getCommandStack().redo();
+ fixture.flushDisplayEvents();
+ ((TreeNattableModelManager) currentManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
+ fixture.flushDisplayEvents();
+
+ // Check the table content
+ checkMultipleMoveSubElementsParentTable(currentManager.getRowElementsList());
+ }
+
+ /**
+ * Get the drop elements command from sources Elements to a target element.
+ *
+ * @param sourceElements
+ * The source elements to drag and drop.
+ * @param targetElement
+ * The target element where drop the source elements.
+ * @return The command corresponding to the drag and drop.
+ * @throws Exception
+ * The exception.
+ */
+ public Command getDropElementsCommand(final List<EObject> sourceElements, final EObject targetElement) throws Exception {
+ Command command = UnexecutableCommand.INSTANCE;
+
+ // Create the target element and select and reveal the first class
+ Object target = findSemanticModelElementItem(targetElement);
+ selectAndReveal(sourceElements);
+ fixture.flushDisplayEvents();
+
+ // Get the DnD service
+ final CommonViewer viewer = modelExplorerView.getCommonViewer();
+ NavigatorDnDService dndService = (NavigatorDnDService) viewer.getNavigatorContentService().getDnDService();
+ Assert.assertNotNull("Impossible to find dnd service", dndService); //$NON-NLS-1$
+
+ // Manage the drop gtom the papyris drop assistant
+ CommonDropAdapter commonDropAdapter = ((CustomCommonViewer) modelExplorerView.getCommonViewer()).getDropAdapter();
+ CommonDropAdapterAssistant[] commonDropAdapterAssistants = dndService.findCommonDropAdapterAssistants(target, (IStructuredSelection) viewer.getSelection());
+ for (CommonDropAdapterAssistant assistant : commonDropAdapterAssistants) {
+ // try to adapt to a Papyrus drop assistant. If not, send a warning
+ if (assistant instanceof org.eclipse.papyrus.views.modelexplorer.dnd.CommonDropAdapterAssistant) {
+ org.eclipse.papyrus.views.modelexplorer.dnd.CommonDropAdapterAssistant papyrusAssistant = (org.eclipse.papyrus.views.modelexplorer.dnd.CommonDropAdapterAssistant) assistant;
+ Field currentOperationField = ViewerDropAdapter.class.getDeclaredField("currentOperation"); //$NON-NLS-1$
+ Assert.assertNotNull(currentOperationField);
+ currentOperationField.setAccessible(true);
+ currentOperationField.set(commonDropAdapter, DND.DROP_MOVE);
+ Field currentLocationField = ViewerDropAdapter.class.getDeclaredField("currentLocation"); //$NON-NLS-1$
+ Assert.assertNotNull(currentLocationField);
+ currentLocationField.setAccessible(true);
+ currentLocationField.set(commonDropAdapter, ViewerDropAdapter.LOCATION_ON);
+ LocalSelectionTransfer.getTransfer().setSelection(modelExplorerView.getCommonViewer().getSelection());
+ command = papyrusAssistant.getDrop(target);
+ }
+ }
+
+ return command;
+ }
+
+ /**
+ * Retrieves the Model Element Item for the given EObject
+ *
+ * @param objectToFind
+ * object represented by the searched item
+ * @return the {@link ModelElementItem} that corresponds to the diagram
+ * @throws Exception
+ * exception thrown in case of issue
+ */
+ protected EObjectTreeElement findSemanticModelElementItem(final EObject objectToFind) throws Exception {
+ selectAndReveal(Arrays.asList(objectToFind));
+ IStructuredSelection selection = (IStructuredSelection) modelExplorerPart.getSite().getSelectionProvider().getSelection();
+ Assert.assertEquals("One and only one object should be selected", 1, selection.size()); //$NON-NLS-1$
+ Object selectedElement = selection.getFirstElement();
+ Assert.assertTrue("Selection should be a model item element", selectedElement instanceof EObjectTreeElement); //$NON-NLS-1$
+ Assert.assertTrue("Selection should be linked to a EObject", ((EObjectTreeElement) selectedElement).getEObject() instanceof EObject); //$NON-NLS-1$
+ Assert.assertTrue("Selection should be linked to the Object: " + objectToFind, ((EObjectTreeElement) selectedElement).getEObject().equals(objectToFind)); //$NON-NLS-1$
+ return (EObjectTreeElement) selectedElement;
+ }
+
+ /**
+ * Selects and reveal the specified list of elements
+ *
+ * @param newElements
+ * the list of objects to select
+ * @throws Exception
+ * exception thrown in case element could not be selected
+ */
+ protected static void selectAndReveal(final List<EObject> newElements) throws Exception {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ // Retrieve model explorer
+ ModelExplorerView modelExplorerView = null;
+
+ ModelExplorerPageBookView bookViewPart = (ModelExplorerPageBookView) NavigatorUtils.findViewPart(ModelExplorerPageBookView.VIEW_ID);
+ if (bookViewPart != null) {
+ modelExplorerView = (ModelExplorerView) bookViewPart.getActiveView();
+ }
+
+ // Set selection on new element in the model explorer
+ if ((modelExplorerView != null) && (newElements != null)) {
+ List<EObject> semanticElementList = new ArrayList<EObject>();
+ semanticElementList.addAll(newElements);
+ modelExplorerView.revealSemanticElement(semanticElementList);
+ } else {
+ throw new Exception("Impossible to find the model explorer required to select: " + newElements); //$NON-NLS-1$
+ }
+ } catch (Exception ex) {
+ Activator.log.error(ex);
+ }
+ }
+ });
+ }
+
+ /**
+ * Check the initial table content display.
+ *
+ * @param rowElements
+ * the row elements
+ * @throws Exception
+ * The exception
+ */
+ private void checkInitialTable(final List<?> rowElements) throws Exception {
+ Assert.assertEquals("The initial table does not contains the correct number of rows", 6, rowElements.size()); //$NON-NLS-1$
+
+ final IAxis firstRow = (IAxis) rowElements.get(0);
+ 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(1);
+ final Object secondRowRepresentedElement = secondRow.getElement();
+ Assert.assertEquals("The first element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) secondRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the first element is not corresponding to the first class", FIRST_CLASS, ((org.eclipse.uml2.uml.Class) secondRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis thirdRow = (IAxis) rowElements.get(2);
+ final Object thirdRowRepresentedElement = thirdRow.getElement();
+ Assert.assertEquals("The second element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) thirdRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the second element is not corresponding to the second class", SECOND_CLASS, ((org.eclipse.uml2.uml.Class) thirdRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis fourthRow = (IAxis) rowElements.get(3);
+ final Object fourthRowRepresentedElement = fourthRow.getElement();
+ Assert.assertEquals("The third element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) fourthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the third element is not corresponding to the third class", THIRD_CLASS, ((org.eclipse.uml2.uml.Class) fourthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis fifthRow = (IAxis) rowElements.get(4);
+ final Object fifthRowRepresentedElement = fifthRow.getElement();
+ Assert.assertEquals("The fourth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) fifthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the fourth element is not corresponding to the fourth class", FOURTH_CLASS, ((org.eclipse.uml2.uml.Class) fifthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis sixthRow = (IAxis) rowElements.get(5);
+ final Object sixthColumnRepresentedElement = sixthRow.getElement();
+ Assert.assertEquals("The fifth element must be a package", UMLPackage.eINSTANCE.getPackage(), ((EObject) sixthColumnRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the fifth element is not corresponding to the first package", FIRST_PACKAGE, ((org.eclipse.uml2.uml.Package) sixthColumnRepresentedElement).getName()); //$NON-NLS-1$
+ }
+
+ /**
+ * Check the initial table content display.
+ *
+ * @param rowElements
+ * the row elements
+ * @throws Exception
+ * The exception
+ */
+ private void checkSimpleMoveSameParentTable(final List<?> rowElements) throws Exception {
+ Assert.assertEquals("The initial table does not contains the correct number of rows", 6, rowElements.size()); //$NON-NLS-1$
+
+ final IAxis firstRow = (IAxis) rowElements.get(0);
+ 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(1);
+ final Object secondRowRepresentedElement = secondRow.getElement();
+ Assert.assertEquals("The first element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) secondRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the first element is not corresponding to the second class", SECOND_CLASS, ((org.eclipse.uml2.uml.Class) secondRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis thirdRow = (IAxis) rowElements.get(2);
+ final Object thirdRowRepresentedElement = thirdRow.getElement();
+ Assert.assertEquals("The second element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) thirdRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the second element is not corresponding to the third class", THIRD_CLASS, ((org.eclipse.uml2.uml.Class) thirdRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis fourthRow = (IAxis) rowElements.get(3);
+ final Object fourthRowRepresentedElement = fourthRow.getElement();
+ Assert.assertEquals("The third element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) fourthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the third element is not corresponding to the fourth class", FOURTH_CLASS, ((org.eclipse.uml2.uml.Class) fourthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis fifthRow = (IAxis) rowElements.get(4);
+ final Object fifthRowRepresentedElement = fifthRow.getElement();
+ Assert.assertEquals("The fourth element must be a package", UMLPackage.eINSTANCE.getPackage(), ((EObject) fifthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the fourth element is not corresponding to the first package", FIRST_PACKAGE, ((org.eclipse.uml2.uml.Package) fifthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis sixthRow = (IAxis) rowElements.get(5);
+ final Object sixthColumnRepresentedElement = sixthRow.getElement();
+ Assert.assertEquals("The fifth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) sixthColumnRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the fifth element is not corresponding to the first class", FIRST_CLASS, ((org.eclipse.uml2.uml.Class) sixthColumnRepresentedElement).getName()); //$NON-NLS-1$
+ }
+
+ /**
+ * Check the initial table content display.
+ *
+ * @param rowElements
+ * the row elements
+ * @throws Exception
+ * The exception
+ */
+ private void checkMultipleMoveSameParentTable(final List<?> rowElements) throws Exception {
+ Assert.assertEquals("The initial table does not contains the correct number of rows", 6, rowElements.size()); //$NON-NLS-1$
+
+ final IAxis firstRow = (IAxis) rowElements.get(0);
+ 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(1);
+ final Object secondRowRepresentedElement = secondRow.getElement();
+ Assert.assertEquals("The first element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) secondRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the first element is not corresponding to the third class", THIRD_CLASS, ((org.eclipse.uml2.uml.Class) secondRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis thirdRow = (IAxis) rowElements.get(2);
+ final Object thirdRowRepresentedElement = thirdRow.getElement();
+ Assert.assertEquals("The second element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) thirdRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the second element is not corresponding to the fourth class", FOURTH_CLASS, ((org.eclipse.uml2.uml.Class) thirdRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis fourthRow = (IAxis) rowElements.get(3);
+ final Object fourthRowRepresentedElement = fourthRow.getElement();
+ Assert.assertEquals("The third element must be a package", UMLPackage.eINSTANCE.getPackage(), ((EObject) fourthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the third element is not corresponding to the first package", FIRST_PACKAGE, ((org.eclipse.uml2.uml.Package) fourthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis fifthRow = (IAxis) rowElements.get(4);
+ final Object fifthRowRepresentedElement = fifthRow.getElement();
+ Assert.assertEquals("The fourth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) fifthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the fourth element is not corresponding to the first class", FIRST_CLASS, ((org.eclipse.uml2.uml.Class) fifthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis sixthRow = (IAxis) rowElements.get(5);
+ final Object sixthColumnRepresentedElement = sixthRow.getElement();
+ Assert.assertEquals("The fifth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) sixthColumnRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the fifth element is not corresponding to the second class", SECOND_CLASS, ((org.eclipse.uml2.uml.Class) sixthColumnRepresentedElement).getName()); //$NON-NLS-1$
+ }
+
+ /**
+ * Check the initial table content display.
+ *
+ * @param rowElements
+ * the row elements
+ * @throws Exception
+ * The exception
+ */
+ private void checkSimpleMoveSubElementsParentTable(final List<?> rowElements) throws Exception {
+ Assert.assertEquals("The initial table does not contains the correct number of rows", 7, rowElements.size()); //$NON-NLS-1$
+
+ final IAxis firstRow = (IAxis) rowElements.get(0);
+ 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(1);
+ final Object secondRowRepresentedElement = secondRow.getElement();
+ Assert.assertEquals("The first element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) secondRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the first element is not corresponding to the second class", SECOND_CLASS, ((org.eclipse.uml2.uml.Class) secondRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis thirdRow = (IAxis) rowElements.get(2);
+ final Object thirdRowRepresentedElement = thirdRow.getElement();
+ Assert.assertEquals("The second element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) thirdRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the second element is not corresponding to the third class", THIRD_CLASS, ((org.eclipse.uml2.uml.Class) thirdRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis fourthRow = (IAxis) rowElements.get(3);
+ final Object fourthRowRepresentedElement = fourthRow.getElement();
+ Assert.assertEquals("The third element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) fourthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the third element is not corresponding to the fourth class", FOURTH_CLASS, ((org.eclipse.uml2.uml.Class) fourthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis fifthRow = (IAxis) rowElements.get(4);
+ final Object fifthRowRepresentedElement = fifthRow.getElement();
+ Assert.assertEquals("The fourth element must be a package", UMLPackage.eINSTANCE.getPackage(), ((EObject) fifthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the fourth element is not corresponding to the first package", FIRST_PACKAGE, ((org.eclipse.uml2.uml.Package) fifthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis sixthRow = (IAxis) rowElements.get(5);
+ final Object sixthRowRepresentedElement = sixthRow.getElement();
+ Assert.assertTrue("The sixth row must be a tree filling configuration", sixthRowRepresentedElement instanceof TreeFillingConfiguration); //$NON-NLS-1$
+
+ final IAxis seventhRow = (IAxis) rowElements.get(6);
+ final Object seventhColumnRepresentedElement = seventhRow.getElement();
+ Assert.assertEquals("The fifth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) seventhColumnRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the fifth element is not corresponding to the first class", FIRST_CLASS, ((org.eclipse.uml2.uml.Class) seventhColumnRepresentedElement).getName()); //$NON-NLS-1$
+ }
+
+ /**
+ * Check the initial table content display.
+ *
+ * @param rowElements
+ * the row elements
+ * @throws Exception
+ * The exception
+ */
+ private void checkMultipleMoveSubElementsParentTable(final List<?> rowElements) throws Exception {
+ Assert.assertEquals("The initial table does not contains the correct number of rows", 7, rowElements.size()); //$NON-NLS-1$
+
+ final IAxis firstRow = (IAxis) rowElements.get(0);
+ 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(1);
+ final Object secondRowRepresentedElement = secondRow.getElement();
+ Assert.assertEquals("The first element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) secondRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the first element is not corresponding to the third class", THIRD_CLASS, ((org.eclipse.uml2.uml.Class) secondRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis thirdRow = (IAxis) rowElements.get(2);
+ final Object thirdRowRepresentedElement = thirdRow.getElement();
+ Assert.assertEquals("The second element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) thirdRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the second element is not corresponding to the fourth class", FOURTH_CLASS, ((org.eclipse.uml2.uml.Class) thirdRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis fourthRow = (IAxis) rowElements.get(3);
+ final Object fourthRowRepresentedElement = fourthRow.getElement();
+ Assert.assertEquals("The third element must be a package", UMLPackage.eINSTANCE.getPackage(), ((EObject) fourthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the third element is not corresponding to the first package", FIRST_PACKAGE, ((org.eclipse.uml2.uml.Package) fourthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis sixthRow = (IAxis) rowElements.get(4);
+ final Object sixthRowRepresentedElement = sixthRow.getElement();
+ Assert.assertTrue("The sixth row must be a tree filling configuration", sixthRowRepresentedElement instanceof TreeFillingConfiguration); //$NON-NLS-1$
+
+ final IAxis fifthRow = (IAxis) rowElements.get(5);
+ final Object fifthRowRepresentedElement = fifthRow.getElement();
+ Assert.assertEquals("The fourth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) fifthRowRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the fourth element is not corresponding to the first class", FIRST_CLASS, ((org.eclipse.uml2.uml.Class) fifthRowRepresentedElement).getName()); //$NON-NLS-1$
+
+ final IAxis seventhRow = (IAxis) rowElements.get(6);
+ final Object seventhColumnRepresentedElement = seventhRow.getElement();
+ Assert.assertEquals("The fifth element must be a class", UMLPackage.eINSTANCE.getClass_(), ((EObject) seventhColumnRepresentedElement).eClass()); //$NON-NLS-1$
+ Assert.assertEquals("The name of the fifth element is not corresponding to the second class", SECOND_CLASS, ((org.eclipse.uml2.uml.Class) seventhColumnRepresentedElement).getName()); //$NON-NLS-1$
+ }
+
+}
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/ContentsAndExpandWithCategories_0_1_2_Tests.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/ContentsAndExpandWithCategories_0_1_2_Tests.java
index 2a794fbafe8..166db0117e5 100644
--- a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/ContentsAndExpandWithCategories_0_1_2_Tests.java
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/ContentsAndExpandWithCategories_0_1_2_Tests.java
@@ -1,185 +1,185 @@
-/*****************************************************************************
- * Copyright (c) 2014 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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.papyrus.infra.nattable.common.editor.NatTableEditor;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.manager.table.ITreeNattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemAxis;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TreeFillingConfiguration;
-import org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum;
-import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
-import org.eclipse.papyrus.junit.utils.GenericUtils;
-import org.eclipse.papyrus.uml.nattable.clazz.config.tests.Activator;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-
-/**
- * @author Vincent Lorenzo
- *
- */
-public class ContentsAndExpandWithCategories_0_1_2_Tests extends AbstractOpenTableTest {
-
- public static String fileName = "contents_with_categories_0_1_2"; //$NON-NLS-1$
-
- private static final String CLASS1_NAME = "Class1"; //$NON-NLS-1$
-
- private static final String OPERATION1_NAME = "Operation1"; //$NON-NLS-1$
-
- @Before
- public void initModel() throws Exception {
- initModel("classTreeTable", fileName, getBundle()); //$NON-NLS-1$
- };
-
-
- /**
- * This method tests the contents of the tree table and its filling expanding level one by one
- *
- * @throws Exception
- */
- @Test
- public void testExpand_1_by_1() throws Exception {
- testOpenExistingTable("classTreeTable", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$
- IEditorPart tableEditor = editor.getActiveEditor();
- Assert.assertTrue(tableEditor instanceof NatTableEditor);
- INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class);
- Assert.assertTrue(manager instanceof ITreeNattableModelManager);
- ITreeNattableModelManager treeTableManager = (ITreeNattableModelManager) manager;
- List<?> rowElements = manager.getRowElementsList();
- int size = rowElements.size();
-
- // nothing is expanded into the table,
- Assert.assertEquals(1, size);
- ITreeItemAxis axis = (ITreeItemAxis) rowElements.get(0);
- Object representedElement = AxisUtils.getRepresentedElement(axis);
- Assert.assertTrue(representedElement instanceof TreeFillingConfiguration);
- Assert.assertEquals(UMLPackage.eINSTANCE.getPackage_PackagedElement(), ((TreeFillingConfiguration) representedElement).getAxisUsedAsAxisProvider().getElement());
- Assert.assertEquals(6, axis.getChildren().size());
-
- // the elements have no children because nothing has been expanded
- for (ITreeItemAxis child : axis.getChildren()) {
- Assert.assertEquals(0, child.getChildren().size());
- }
-
- // we expand the first class owned by the root package
- treeTableManager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ONE_LEVEL, Collections.singletonList(axis));
-
- Class class1 = null;
- ITreeItemAxis class1Representation = null;
- // now the children must have elements
- for (ITreeItemAxis child : axis.getChildren()) {
- Object tmp = AxisUtils.getRepresentedElement(child);
- Assert.assertTrue(tmp instanceof Class);
- class1 = (Class) tmp;
- if (CLASS1_NAME.equals(class1.getName())) {
- class1Representation = child;
- Assert.assertEquals(3, child.getChildren().size());
- } else {
- Assert.assertEquals(0, child.getChildren().size());
- }
- }
- Assert.assertNotNull(class1);
-
-
-
-
-
- for (ITreeItemAxis child : class1Representation.getChildren()) {
- Assert.assertEquals(0, child.getChildren().size());
- }
- // we expand class1 in order to fill its children
- treeTableManager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ONE_LEVEL, Collections.singletonList(class1Representation));
-
- // the children of class1 must have children now
- ITreeItemAxis ownedOperationAxis = null;
- for (ITreeItemAxis child : class1Representation.getChildren()) {
- Assert.assertEquals(3, child.getChildren().size());
-
- TreeFillingConfiguration conf = (TreeFillingConfiguration) child.getElement();
- if (conf.getAxisUsedAsAxisProvider().getElement() == UMLPackage.eINSTANCE.getClass_OwnedOperation()) {
- ownedOperationAxis = child;
- }
- // we expand each filling configuration to fill children
- treeTableManager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ONE_LEVEL, Collections.singletonList(child));
- }
-
- Assert.assertNotNull(ownedOperationAxis);
- // we expand the ownedOperation axis
- treeTableManager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ONE_LEVEL, Collections.singletonList(ownedOperationAxis));
-
- ITreeItemAxis operation1Representation = null;
-
- for (ITreeItemAxis child : ownedOperationAxis.getChildren()) {
- Assert.assertTrue(child.getElement() instanceof Operation);
- Operation op = (Operation) child.getElement();
- if (OPERATION1_NAME.equals(op.getName())) {
- operation1Representation = child;
- Assert.assertEquals(1, child.getChildren().size());
- } else {
- Assert.assertEquals(0, child.getChildren().size());
- }
- }
-
- Assert.assertNotNull(operation1Representation);
- // we expand operation1
- treeTableManager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ONE_LEVEL, Collections.singletonList(operation1Representation));
-
- ITreeItemAxis parametersFeatureAxis = operation1Representation.getChildren().get(0);
- Assert.assertEquals(parametersFeatureAxis.getChildren().size(), 3);
- }
-
- @Test
- public void testExpandAll() throws Exception {
- testOpenExistingTable("classTreeTable", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$
- IEditorPart tableEditor = editor.getActiveEditor();
- Assert.assertTrue(tableEditor instanceof NatTableEditor);
- INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class);
- Assert.assertTrue(manager instanceof ITreeNattableModelManager);
- ITreeNattableModelManager treeTableManager = (ITreeNattableModelManager) manager;
- List<?> rowElements = manager.getRowElementsList();
- int size = rowElements.size();
-
- // nothing is expanded into the table,
- Assert.assertEquals(1, size);
- treeTableManager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
-
- size = rowElements.size();
- Assert.assertEquals(23, size);
- }
-
- @Override
- protected String getSourcePath() {
- return "/resources/contents_and_expand_tests_resources/"; //$NON-NLS-1$
- }
-
- @Override
- protected Bundle getBundle() {
- return Activator.getDefault().getBundle();
- }
-
- @AfterClass
- public static void endOfTest() {
- GenericUtils.closeAllEditors();
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.nattable.common.editor.NatTableEditor;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.ITreeNattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TreeFillingConfiguration;
+import org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
+import org.eclipse.papyrus.junit.utils.GenericUtils;
+import org.eclipse.papyrus.uml.nattable.clazz.config.tests.Activator;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Vincent Lorenzo
+ *
+ */
+public class ContentsAndExpandWithCategories_0_1_2_Tests extends AbstractOpenTableTest {
+
+ public static String fileName = "contents_with_categories_0_1_2"; //$NON-NLS-1$
+
+ private static final String CLASS1_NAME = "Class1"; //$NON-NLS-1$
+
+ private static final String OPERATION1_NAME = "Operation1"; //$NON-NLS-1$
+
+ @Before
+ public void initModel() throws Exception {
+ initModel("classTreeTable", fileName, getBundle()); //$NON-NLS-1$
+ };
+
+
+ /**
+ * This method tests the contents of the tree table and its filling expanding level one by one
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testExpand_1_by_1() throws Exception {
+ testOpenExistingTable("classTreeTable", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$
+ IEditorPart tableEditor = editor.getActiveEditor();
+ Assert.assertTrue(tableEditor instanceof NatTableEditor);
+ INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class);
+ Assert.assertTrue(manager instanceof ITreeNattableModelManager);
+ ITreeNattableModelManager treeTableManager = (ITreeNattableModelManager) manager;
+ List<?> rowElements = manager.getRowElementsList();
+ int size = rowElements.size();
+
+ // nothing is expanded into the table,
+ Assert.assertEquals(1, size);
+ ITreeItemAxis axis = (ITreeItemAxis) rowElements.get(0);
+ Object representedElement = AxisUtils.getRepresentedElement(axis);
+ Assert.assertTrue(representedElement instanceof TreeFillingConfiguration);
+ Assert.assertEquals(UMLPackage.eINSTANCE.getPackage_PackagedElement(), ((TreeFillingConfiguration) representedElement).getAxisUsedAsAxisProvider().getElement());
+ Assert.assertEquals(6, axis.getChildren().size());
+
+ // the elements have no children because nothing has been expanded
+ for (ITreeItemAxis child : axis.getChildren()) {
+ Assert.assertEquals(0, child.getChildren().size());
+ }
+
+ // we expand the first class owned by the root package
+ treeTableManager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ONE_LEVEL, Collections.singletonList(axis));
+
+ Class class1 = null;
+ ITreeItemAxis class1Representation = null;
+ // now the children must have elements
+ for (ITreeItemAxis child : axis.getChildren()) {
+ Object tmp = AxisUtils.getRepresentedElement(child);
+ Assert.assertTrue(tmp instanceof Class);
+ class1 = (Class) tmp;
+ if (CLASS1_NAME.equals(class1.getName())) {
+ class1Representation = child;
+ Assert.assertEquals(3, child.getChildren().size());
+ } else {
+ Assert.assertEquals(0, child.getChildren().size());
+ }
+ }
+ Assert.assertNotNull(class1);
+
+
+
+
+
+ for (ITreeItemAxis child : class1Representation.getChildren()) {
+ Assert.assertEquals(0, child.getChildren().size());
+ }
+ // we expand class1 in order to fill its children
+ treeTableManager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ONE_LEVEL, Collections.singletonList(class1Representation));
+
+ // the children of class1 must have children now
+ ITreeItemAxis ownedOperationAxis = null;
+ for (ITreeItemAxis child : class1Representation.getChildren()) {
+ Assert.assertEquals(3, child.getChildren().size());
+
+ TreeFillingConfiguration conf = (TreeFillingConfiguration) child.getElement();
+ if (conf.getAxisUsedAsAxisProvider().getElement() == UMLPackage.eINSTANCE.getClass_OwnedOperation()) {
+ ownedOperationAxis = child;
+ }
+ // we expand each filling configuration to fill children
+ treeTableManager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ONE_LEVEL, Collections.singletonList(child));
+ }
+
+ Assert.assertNotNull(ownedOperationAxis);
+ // we expand the ownedOperation axis
+ treeTableManager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ONE_LEVEL, Collections.singletonList(ownedOperationAxis));
+
+ ITreeItemAxis operation1Representation = null;
+
+ for (ITreeItemAxis child : ownedOperationAxis.getChildren()) {
+ Assert.assertTrue(child.getElement() instanceof Operation);
+ Operation op = (Operation) child.getElement();
+ if (OPERATION1_NAME.equals(op.getName())) {
+ operation1Representation = child;
+ Assert.assertEquals(1, child.getChildren().size());
+ } else {
+ Assert.assertEquals(0, child.getChildren().size());
+ }
+ }
+
+ Assert.assertNotNull(operation1Representation);
+ // we expand operation1
+ treeTableManager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ONE_LEVEL, Collections.singletonList(operation1Representation));
+
+ ITreeItemAxis parametersFeatureAxis = operation1Representation.getChildren().get(0);
+ Assert.assertEquals(parametersFeatureAxis.getChildren().size(), 3);
+ }
+
+ @Test
+ public void testExpandAll() throws Exception {
+ testOpenExistingTable("classTreeTable", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$
+ IEditorPart tableEditor = editor.getActiveEditor();
+ Assert.assertTrue(tableEditor instanceof NatTableEditor);
+ INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class);
+ Assert.assertTrue(manager instanceof ITreeNattableModelManager);
+ ITreeNattableModelManager treeTableManager = (ITreeNattableModelManager) manager;
+ List<?> rowElements = manager.getRowElementsList();
+ int size = rowElements.size();
+
+ // nothing is expanded into the table,
+ Assert.assertEquals(1, size);
+ treeTableManager.doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
+
+ size = rowElements.size();
+ Assert.assertEquals(23, size);
+ }
+
+ @Override
+ protected String getSourcePath() {
+ return "/resources/contents_and_expand_tests_resources/"; //$NON-NLS-1$
+ }
+
+ @Override
+ protected Bundle getBundle() {
+ return Activator.getDefault().getBundle();
+ }
+
+ @AfterClass
+ public static void endOfTest() {
+ GenericUtils.closeAllEditors();
+ }
+}
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/OpenTableTest.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/OpenTableTest.java
index 3fd401f375b..7d6c3bef263 100644
--- a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/OpenTableTest.java
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/OpenTableTest.java
@@ -1,59 +1,59 @@
-/*****************************************************************************
- * Copyright (c) 2014 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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests;
-
-import org.eclipse.papyrus.junit.utils.GenericUtils;
-import org.eclipse.papyrus.uml.nattable.clazz.config.tests.Activator;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-
-/**
- * @author Vincent Lorenzo
- *
- */
-public class OpenTableTest extends AbstractOpenTableTest {
-
- @Before
- public void initModel() throws Exception {
- initModel("classTreeTable", "openTest", getBundle()); //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- /**
- * This test allows to be sure that we doesn't break existing table model
- *
- * @throws Exception
- */
- @Test
- public void testOpenExistingTable() throws Exception {
- testOpenExistingTable("classTreeTable", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Override
- protected String getSourcePath() {
- return "/resources/"; //$NON-NLS-1$
- }
-
- @Override
- protected Bundle getBundle() {
- return Activator.getDefault().getBundle();
- }
-
- @AfterClass
- public static void endOfTest() {
- GenericUtils.closeAllEditors();
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests;
+
+import org.eclipse.papyrus.junit.utils.GenericUtils;
+import org.eclipse.papyrus.uml.nattable.clazz.config.tests.Activator;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Vincent Lorenzo
+ *
+ */
+public class OpenTableTest extends AbstractOpenTableTest {
+
+ @Before
+ public void initModel() throws Exception {
+ initModel("classTreeTable", "openTest", getBundle()); //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ /**
+ * This test allows to be sure that we doesn't break existing table model
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testOpenExistingTable() throws Exception {
+ testOpenExistingTable("classTreeTable", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ protected String getSourcePath() {
+ return "/resources/"; //$NON-NLS-1$
+ }
+
+ @Override
+ protected Bundle getBundle() {
+ return Activator.getDefault().getBundle();
+ }
+
+ @AfterClass
+ public static void endOfTest() {
+ GenericUtils.closeAllEditors();
+ }
+
+}
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/TableFillingAndExpandTest.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/TableFillingAndExpandTest.java
index a365a9ccf2b..43c709fc828 100644
--- a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/TableFillingAndExpandTest.java
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/TableFillingAndExpandTest.java
@@ -1,140 +1,140 @@
-/*****************************************************************************
- * Copyright (c) 2014 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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.junit.utils.GenericUtils;
-import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest;
-import org.eclipse.papyrus.uml.nattable.clazz.config.tests.Activator;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Model;
-import org.eclipse.uml2.uml.Package;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-
-import ca.odell.glazedlists.TreeList;
-
-/**
- * @author Vincent Lorenzo
- *
- */
-public class TableFillingAndExpandTest extends AbstractEditorTest {
- protected Resource di;
-
- protected Resource notation;
-
- protected Resource uml;
-
- protected Model rootModel;
-
- protected Class classTest;
-
- protected List<?> elementListTest;
-
- protected Package packageTest;
-
- private List<?> root;
-
- private Object diagramTest;
-
- private final String modelName = "tableFillingAndTableExpandTest"; //$NON-NLS-1$
-
- private final String uml_EXT = "uml"; //$NON-NLS-1$
- private final String notation_EXT = "notation"; //$NON-NLS-1$
- private final String di_EXT = "di"; //$NON-NLS-1$
- private final String DOT = "."; //$NON-NLS-1$
- private final StringBuilder umlBuiler = new StringBuilder(modelName).append(DOT).append(uml_EXT);
- private final StringBuilder notationBuiler = new StringBuilder(modelName).append(DOT).append(notation_EXT);
- private final StringBuilder diBuilder = new StringBuilder(modelName).append(DOT).append(di_EXT);
-
- @Before
- public void initTests() throws CoreException, IOException {
- try {
- initModel(modelName, modelName, getBundle());
- } catch (Exception e) {
- Activator.log.error(e);
- }
-
- ResourceSet set = null;
- try {
- set = getModelSet();
- } catch (ServiceException e) {
- e.printStackTrace();
- }
-
- List<Resource> resources = set.getResources();
-
- for (Resource current : resources) {
- if (current.getURI().lastSegment().equals(umlBuiler.toString())) {
- uml = current;
- } else if (current.getURI().lastSegment().equals(notationBuiler.toString())) {
- notation = current;
- } else if (current.getURI().lastSegment().equals(diBuilder.toString())) {
- di = current;
- }
- }
-
- rootModel = (Model) uml.getContents().get(0);
- root = notation.getContents();
- // TODO on luna : open diagram
- }
-
- @Override
- protected String getSourcePath() {
- return "/resources/"; //$NON-NLS-1$
- }
-
- @Override
- protected Bundle getBundle() {
- return Activator.getDefault().getBundle();
- }
-
- @AfterClass
- public static void endOfTest() {
- GenericUtils.closeAllEditors();
- }
-
- @Test
- public void fullTest() {
- selectTablePage(0);
- INattableModelManager manager = (INattableModelManager) this.editor.getAdapter(INattableModelManager.class);
- List<?> elements = manager.getRowElementsList();
- Assert.isTrue(elements instanceof TreeList<?>, " the list managing the rows in not a TreeList"); //$NON-NLS-1$
- int size = elements.size();
- int i = 0;
- i++;
- }
-
- protected void selectTablePage(int index) {
- try {
- Object tablePage = getPageManager().allPages().get(index);
- // getPageManager().closeAllOpenedPages();
- // getPageManager().openPage(tablePage);
- getPageManager().selectPage(tablePage);
- } catch (ServiceException e) {
- Activator.log.error(e);
- }
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.junit.utils.GenericUtils;
+import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest;
+import org.eclipse.papyrus.uml.nattable.clazz.config.tests.Activator;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+import ca.odell.glazedlists.TreeList;
+
+/**
+ * @author Vincent Lorenzo
+ *
+ */
+public class TableFillingAndExpandTest extends AbstractEditorTest {
+ protected Resource di;
+
+ protected Resource notation;
+
+ protected Resource uml;
+
+ protected Model rootModel;
+
+ protected Class classTest;
+
+ protected List<?> elementListTest;
+
+ protected Package packageTest;
+
+ private List<?> root;
+
+ private Object diagramTest;
+
+ private final String modelName = "tableFillingAndTableExpandTest"; //$NON-NLS-1$
+
+ private final String uml_EXT = "uml"; //$NON-NLS-1$
+ private final String notation_EXT = "notation"; //$NON-NLS-1$
+ private final String di_EXT = "di"; //$NON-NLS-1$
+ private final String DOT = "."; //$NON-NLS-1$
+ private final StringBuilder umlBuiler = new StringBuilder(modelName).append(DOT).append(uml_EXT);
+ private final StringBuilder notationBuiler = new StringBuilder(modelName).append(DOT).append(notation_EXT);
+ private final StringBuilder diBuilder = new StringBuilder(modelName).append(DOT).append(di_EXT);
+
+ @Before
+ public void initTests() throws CoreException, IOException {
+ try {
+ initModel(modelName, modelName, getBundle());
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+
+ ResourceSet set = null;
+ try {
+ set = getModelSet();
+ } catch (ServiceException e) {
+ e.printStackTrace();
+ }
+
+ List<Resource> resources = set.getResources();
+
+ for (Resource current : resources) {
+ if (current.getURI().lastSegment().equals(umlBuiler.toString())) {
+ uml = current;
+ } else if (current.getURI().lastSegment().equals(notationBuiler.toString())) {
+ notation = current;
+ } else if (current.getURI().lastSegment().equals(diBuilder.toString())) {
+ di = current;
+ }
+ }
+
+ rootModel = (Model) uml.getContents().get(0);
+ root = notation.getContents();
+ // TODO on luna : open diagram
+ }
+
+ @Override
+ protected String getSourcePath() {
+ return "/resources/"; //$NON-NLS-1$
+ }
+
+ @Override
+ protected Bundle getBundle() {
+ return Activator.getDefault().getBundle();
+ }
+
+ @AfterClass
+ public static void endOfTest() {
+ GenericUtils.closeAllEditors();
+ }
+
+ @Test
+ public void fullTest() {
+ selectTablePage(0);
+ INattableModelManager manager = (INattableModelManager) this.editor.getAdapter(INattableModelManager.class);
+ List<?> elements = manager.getRowElementsList();
+ Assert.isTrue(elements instanceof TreeList<?>, " the list managing the rows in not a TreeList"); //$NON-NLS-1$
+ int size = elements.size();
+ int i = 0;
+ i++;
+ }
+
+ protected void selectTablePage(int index) {
+ try {
+ Object tablePage = getPageManager().allPages().get(index);
+ // getPageManager().closeAllOpenedPages();
+ // getPageManager().openPage(tablePage);
+ getPageManager().selectPage(tablePage);
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+ }
+
+}

Back to the top