diff options
author | Nicolas FAUVERGUE | 2015-06-17 07:39:20 +0000 |
---|---|---|
committer | vincent lorenzo | 2015-07-01 13:11:53 +0000 |
commit | dd1d28c9b0412ef77a84099ee9ed5ffe76f38869 (patch) | |
tree | cbf78868d70fd2d32dd8e562cead8115ee15f5da | |
parent | 0e2b098d0b7da504a6426b833b2b0e084ac38f1e (diff) | |
download | org.eclipse.papyrus-dd1d28c9b0412ef77a84099ee9ed5ffe76f38869.tar.gz org.eclipse.papyrus-dd1d28c9b0412ef77a84099ee9ed5ffe76f38869.tar.xz org.eclipse.papyrus-dd1d28c9b0412ef77a84099ee9ed5ffe76f38869.zip |
Bug 467507: [TreeTable] Missing implementation for destroying axis
https://bugs.eclipse.org/bugs/show_bug.cgi?id=467507
- JUnit tests for DestroyAxisCommand and DestroyAxisElementCommand
- The tests are failed for configuration 0 due to a problem of result
- The tests in failure are marked as FailingTest
Change-Id: I9fced26c5f0e277153a0a8845a7a369a6c982094
Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
Reviewed-on: https://git.eclipse.org/r/50321
Tested-by: Hudson CI
Reviewed-by: Gabriel Pascual <gabriel.pascual@all4tec.net>
Reviewed-by: vincent lorenzo <vincent.lorenzo@cea.fr>
32 files changed, 2528 insertions, 496 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java index 086149718fd..83ad1c4dfc1 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java @@ -1,298 +1,292 @@ -/*****************************************************************************
- * Copyright (c) 2012 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.nattable.handler;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.nebula.widgets.nattable.NatTable;
-import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
-import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
-import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
-import org.eclipse.papyrus.infra.nattable.provider.TableStructuredSelection;
-import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
-import org.eclipse.papyrus.infra.nattable.utils.TableSelectionWrapper;
-import org.eclipse.papyrus.infra.tools.util.WorkbenchPartHelper;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * The abstract handler to use for the table actions
- *
- * @author Vincent Lorenzo
- *
- */
-public abstract class AbstractTableHandler extends AbstractHandler {
-
- /** the id used to find the NatEvent in the EclipseContext */
- public static final String NAT_EVENT_DATA_PARAMETER_ID = "natEventParameterId"; //$NON-NLS-1$
-
- /**
- * the event which have declenched the call to setEnable(Object evaluationContext. This event contains the location of the mouse pointer when
- * the popup menu for this handler have been created
- *
- * we do a weak reference to fix the bug 469376: [Table] Memory Leak : (Tree)NattableWidgetManager, EObjectTreeItemAxis and others objects are not disposed when the table is closed
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=469376
- */
- // TODO : should maybe be removed with the future usage of e4 and the Eclipse Context
- private WeakReference<NatEventData> eventDataWeakReference;
-
- /**
- *
- * @return
- * the current active part
- */
- protected IWorkbenchPart getActivePart() {
- return WorkbenchPartHelper.getCurrentActiveWorkbenchPart();
- }
-
- /**
- *
- * @param evaluationContextOrExecutionEvent
- *
- */
- protected final TableSelectionWrapper getTableSelectionWrapper(Object evaluationContextOrExecutionEvent) {
- if (evaluationContextOrExecutionEvent instanceof IEvaluationContext) {
- Object selection = HandlerUtil.getVariable(evaluationContextOrExecutionEvent, "selection"); //$NON-NLS-1$
- if (selection instanceof IAdaptable) {
- return (TableSelectionWrapper) ((IAdaptable) selection).getAdapter(TableSelectionWrapper.class);
- }
- } else if (evaluationContextOrExecutionEvent instanceof ExecutionEvent) {
- IWorkbenchPart p = HandlerUtil.getActivePart((ExecutionEvent) evaluationContextOrExecutionEvent);
- ISelection selection = (ISelection) p.getAdapter(ISelection.class);
- if (selection instanceof TableStructuredSelection) {
- return (TableSelectionWrapper) ((TableStructuredSelection) selection).getAdapter(TableSelectionWrapper.class);
- }
- }
- return null;
- }
-
- /**
- *
- * @return
- * the current table manager or <code>null</code> if not found
- */
- protected INattableModelManager getCurrentNattableModelManager() {
- final IWorkbenchPart currentPart = getActivePart();
- if (currentPart != null) {
- final INattableModelManager manager = (INattableModelManager) currentPart.getAdapter(INattableModelManager.class);
- return manager;
- }
- return null;
- }
-
-
- /**
- * Returns the EditingDomain associated to the table
- *
- * @return
- */
- protected TransactionalEditingDomain getTableEditingDomain() {// duplicated code from NattableModelManager
- return TableEditingDomainUtils.getTableEditingDomain(getCurrentNattableModelManager().getTable());
- }
-
- /**
- * Returns the EditingDomain associated to the context
- *
- * @return
- */
- protected TransactionalEditingDomain getContextEditingDomain() {// duplicated code from NattableModelManager
- return TableEditingDomainUtils.getTableContextEditingDomain(getCurrentNattableModelManager().getTable());
- }
-
- protected NatEventData getNatEventData() {
- if (this.eventDataWeakReference != null) {
- return this.eventDataWeakReference.get();
- }
- return null;
- }
-
- /**
- *
- * @param evaluationContext
- * the evaluation context
- * @return
- * the NatEventData from this evaluation context
- */
- protected NatEventData getNatEventData(final Object evaluationContext) {
- if (evaluationContext instanceof NatEventData) {
- return (NatEventData) evaluationContext;
- }
- NatEventData eventData = null;
- if (evaluationContext instanceof IEvaluationContext) {
- Object value = ((IEvaluationContext) evaluationContext).getVariable(NAT_EVENT_DATA_PARAMETER_ID);
- if (value instanceof NatEventData) {
- eventData = (NatEventData) value;
- }
- }
- // TODO : currently we can't have dependency on org.eclipse.e4....
- // that's why we can't add the variable NAT_EVENT_DATA_PARAMETER_ID and we need to create a NatEventData instead of to get it in evaluationContext
- if (eventData == null) {
- Point cursorLocation = Display.getDefault().getCursorLocation();
- Control control = Display.getDefault().getCursorControl();// TODO doesn't work when we are selecting a command in a menu!
- if (control instanceof NatTable) {// TODO : not nice, but required
- cursorLocation = control.toControl(cursorLocation);
- Event e = new Event();
- e.x = cursorLocation.x;
- e.y = cursorLocation.y;
- e.display = Display.getDefault();
- e.widget = control;
- MouseEvent event = new MouseEvent(e);
- eventData = NatEventData.createInstanceFromEvent(event);
- }
- }
- return eventData;
- }
-
- /**
- *
- * @param evaluationContext
- * @return
- * the index of the rows which are fully selected
- */
- protected List<Integer> getFullSelectedRowsIndex(Object evaluationContext) {
- final INattableModelManager manager = getCurrentNattableModelManager();
- if (manager != null) {
- final NatEventData data = getNatEventData(evaluationContext);
- if (data != null) {
- final SelectionLayer layer = manager.getBodyLayerStack().getSelectionLayer();
- int[] fullSelectedColumnsPosition = layer.getFullySelectedRowPositions();
- List<Integer> positions = new ArrayList<Integer>();
- for (int i : fullSelectedColumnsPosition) {
- positions.add(layer.getRowIndexByPosition(i));
- }
- return positions;
- }
- }
- return Collections.emptyList();
- }
-
- /**
- *
- * @param evaluationContext
- * @return
- * the index of the columns which are fully selected
- */
- protected List<Integer> getFullSelectedColumnsIndex(Object evaluationContext) {
- final INattableModelManager manager = getCurrentNattableModelManager();
- if (manager != null) {
- final NatEventData data = getNatEventData(evaluationContext);
- if (data != null) {
- final SelectionLayer layer = manager.getBodyLayerStack().getSelectionLayer();
- int[] fullSelectedColumnsPosition = layer.getFullySelectedColumnPositions();
- List<Integer> positions = new ArrayList<Integer>();
- for (int i : fullSelectedColumnsPosition) {
- positions.add(layer.getColumnIndexByPosition(i));
- }
- return positions;
- }
- }
- return Collections.emptyList();
- }
-
-
- /**
- *
- * @return
- * the row axis manager
- */
- protected IAxisManager getRowAxisManager() {
- final INattableModelManager manager = getCurrentNattableModelManager();
- if (manager != null) {
- return manager.getRowAxisManager();
- }
- return null;
- }
-
- /**
- *
- * @return
- * the column axis manager
- */
- protected IAxisManager getColumnAxisManager() {
- final INattableModelManager manager = getCurrentNattableModelManager();
- if (manager != null) {
- return manager.getColumnAxisManager();
- }
- return null;
- }
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
- */
- @Override
- public void setEnabled(Object evaluationContext) {
- this.eventDataWeakReference = new WeakReference<NatEventData>(getNatEventData(evaluationContext));
- boolean enabled = getCurrentNattableModelManager() != null;
- setBaseEnabled(enabled);
- }
-
- /**
- * @see org.eclipse.core.commands.AbstractHandler#setBaseEnabled(boolean)
- *
- * @param state
- */
- @Override
- protected void setBaseEnabled(boolean state) {
- if (!state) {
- this.eventDataWeakReference = null;
- }
- super.setBaseEnabled(state);
- }
-
- /**
- *
- * @return
- * the currently managed table
- */
- protected final Table getTable() {
- return getCurrentNattableModelManager().getTable();
- }
-
- /**
- * Refreshes the table
- */
- protected final void refreshTable() {
- ((NattableModelManager) getCurrentNattableModelManager()).refreshNatTable();
- }
-
- /**
- * @see org.eclipse.core.commands.AbstractHandler#dispose()
- *
- */
- @Override
- public void dispose() {
- super.dispose();
- this.eventDataWeakReference = null;
- }
-}
+/***************************************************************************** + * Copyright (c) 2012 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: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.nattable.handler; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; +import org.eclipse.nebula.widgets.nattable.ui.NatEventData; +import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.provider.TableStructuredSelection; +import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils; +import org.eclipse.papyrus.infra.nattable.utils.TableSelectionWrapper; +import org.eclipse.papyrus.infra.tools.util.WorkbenchPartHelper; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * The abstract handler to use for the table actions + * + * @author Vincent Lorenzo + * + */ +public abstract class AbstractTableHandler extends AbstractHandler { + + /** the id used to find the NatEvent in the EclipseContext */ + public static final String NAT_EVENT_DATA_PARAMETER_ID = "natEventParameterId"; //$NON-NLS-1$ + + /** + * the event which have declenched the call to setEnable(Object evaluationContext. This event contains the location of the mouse pointer when + * the popup menu for this handler have been created + * + * we do a weak reference to fix the bug 469376: [Table] Memory Leak : (Tree)NattableWidgetManager, EObjectTreeItemAxis and others objects are not disposed when the table is closed + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=469376 + */ + // TODO : should maybe be removed with the future usage of e4 and the Eclipse Context + private WeakReference<NatEventData> eventDataWeakReference; + + /** + * + * @return + * the current active part + */ + protected IWorkbenchPart getActivePart() { + return WorkbenchPartHelper.getCurrentActiveWorkbenchPart(); + } + + /** + * + * @param evaluationContextOrExecutionEvent + * + */ + protected final TableSelectionWrapper getTableSelectionWrapper(Object evaluationContextOrExecutionEvent) { + if (evaluationContextOrExecutionEvent instanceof IEvaluationContext) { + Object selection = HandlerUtil.getVariable(evaluationContextOrExecutionEvent, "selection"); //$NON-NLS-1$ + if (selection instanceof IAdaptable) { + return (TableSelectionWrapper) ((IAdaptable) selection).getAdapter(TableSelectionWrapper.class); + } + } else if (evaluationContextOrExecutionEvent instanceof ExecutionEvent) { + IWorkbenchPart p = HandlerUtil.getActivePart((ExecutionEvent) evaluationContextOrExecutionEvent); + ISelection selection = (ISelection) p.getAdapter(ISelection.class); + if (selection instanceof TableStructuredSelection) { + return (TableSelectionWrapper) ((TableStructuredSelection) selection).getAdapter(TableSelectionWrapper.class); + } + } + return null; + } + + /** + * + * @return + * the current table manager or <code>null</code> if not found + */ + protected INattableModelManager getCurrentNattableModelManager() { + final IWorkbenchPart currentPart = getActivePart(); + if (currentPart != null) { + final INattableModelManager manager = (INattableModelManager) currentPart.getAdapter(INattableModelManager.class); + return manager; + } + return null; + } + + + /** + * Returns the EditingDomain associated to the table + * + * @return + */ + protected TransactionalEditingDomain getTableEditingDomain() {// duplicated code from NattableModelManager + return TableEditingDomainUtils.getTableEditingDomain(getCurrentNattableModelManager().getTable()); + } + + /** + * Returns the EditingDomain associated to the context + * + * @return + */ + protected TransactionalEditingDomain getContextEditingDomain() {// duplicated code from NattableModelManager + return TableEditingDomainUtils.getTableContextEditingDomain(getCurrentNattableModelManager().getTable()); + } + + protected NatEventData getNatEventData() { + if (this.eventDataWeakReference != null) { + return this.eventDataWeakReference.get(); + } + return null; + } + + /** + * + * @param evaluationContext + * the evaluation context + * @return + * the NatEventData from this evaluation context + */ + protected NatEventData getNatEventData(final Object evaluationContext) { + if (evaluationContext instanceof NatEventData) { + return (NatEventData) evaluationContext; + } + NatEventData eventData = null; + if (evaluationContext instanceof IEvaluationContext) { + Object value = ((IEvaluationContext) evaluationContext).getVariable(NAT_EVENT_DATA_PARAMETER_ID); + if (value instanceof NatEventData) { + eventData = (NatEventData) value; + } + } + // TODO : currently we can't have dependency on org.eclipse.e4.... + // that's why we can't add the variable NAT_EVENT_DATA_PARAMETER_ID and we need to create a NatEventData instead of to get it in evaluationContext + if (eventData == null) { + Point cursorLocation = Display.getDefault().getCursorLocation(); + Control control = Display.getDefault().getCursorControl();// TODO doesn't work when we are selecting a command in a menu! + if (control instanceof NatTable) {// TODO : not nice, but required + cursorLocation = control.toControl(cursorLocation); + Event e = new Event(); + e.x = cursorLocation.x; + e.y = cursorLocation.y; + e.display = Display.getDefault(); + e.widget = control; + MouseEvent event = new MouseEvent(e); + eventData = NatEventData.createInstanceFromEvent(event); + } + } + return eventData; + } + + /** + * + * @param evaluationContext + * @return + * the index of the rows which are fully selected + */ + protected List<Integer> getFullSelectedRowsIndex(Object evaluationContext) { + final INattableModelManager manager = getCurrentNattableModelManager(); + if (manager != null) { + final SelectionLayer layer = manager.getBodyLayerStack().getSelectionLayer(); + int[] fullSelectedColumnsPosition = layer.getFullySelectedRowPositions(); + List<Integer> positions = new ArrayList<Integer>(); + for (int i : fullSelectedColumnsPosition) { + positions.add(layer.getRowIndexByPosition(i)); + } + return positions; + } + return Collections.emptyList(); + } + + /** + * + * @param evaluationContext + * @return + * the index of the columns which are fully selected + */ + protected List<Integer> getFullSelectedColumnsIndex(Object evaluationContext) { + final INattableModelManager manager = getCurrentNattableModelManager(); + if (manager != null) { + final SelectionLayer layer = manager.getBodyLayerStack().getSelectionLayer(); + int[] fullSelectedColumnsPosition = layer.getFullySelectedColumnPositions(); + List<Integer> positions = new ArrayList<Integer>(); + for (int i : fullSelectedColumnsPosition) { + positions.add(layer.getColumnIndexByPosition(i)); + } + return positions; + } + return Collections.emptyList(); + } + + + /** + * + * @return + * the row axis manager + */ + protected IAxisManager getRowAxisManager() { + final INattableModelManager manager = getCurrentNattableModelManager(); + if (manager != null) { + return manager.getRowAxisManager(); + } + return null; + } + + /** + * + * @return + * the column axis manager + */ + protected IAxisManager getColumnAxisManager() { + final INattableModelManager manager = getCurrentNattableModelManager(); + if (manager != null) { + return manager.getColumnAxisManager(); + } + return null; + } + + /** + * + * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object) + * + * @param evaluationContext + */ + @Override + public void setEnabled(Object evaluationContext) { + this.eventDataWeakReference = new WeakReference<NatEventData>(getNatEventData(evaluationContext)); + boolean enabled = getCurrentNattableModelManager() != null; + setBaseEnabled(enabled); + } + + /** + * @see org.eclipse.core.commands.AbstractHandler#setBaseEnabled(boolean) + * + * @param state + */ + @Override + protected void setBaseEnabled(boolean state) { + if (!state) { + this.eventDataWeakReference = null; + } + super.setBaseEnabled(state); + } + + /** + * + * @return + * the currently managed table + */ + protected final Table getTable() { + return getCurrentNattableModelManager().getTable(); + } + + /** + * Refreshes the table + */ + protected final void refreshTable() { + ((NattableModelManager) getCurrentNattableModelManager()).refreshNatTable(); + } + + /** + * @see org.eclipse.core.commands.AbstractHandler#dispose() + * + */ + @Override + public void dispose() { + super.dispose(); + this.eventDataWeakReference = null; + } +} diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java index 39db280ec5e..878f83c6188 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java @@ -1,67 +1,64 @@ -/*****************************************************************************
- * Copyright (c) 2013 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.nattable.handler;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
-import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
-
-/**
- * The handler used to destroy the element represented by the selected rows
- *
- * @author VL222926
- *
- */
-public class RowDestroyAxisElementHandler extends AbstractTableHandler {
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- *
- * @param event
- * @return
- * @throws ExecutionException
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- final IAxisManager axisManager = getRowAxisManager();
- NatEventData eventData = getNatEventData();
- if (axisManager != null && eventData != null) {
- axisManager.destroyAxisElement(getFullSelectedRowsIndex(eventData));
- }
- return null;
- }
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
- */
- @Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- boolean enabled = false;
- NatEventData eventData = getNatEventData();
- final IAxisManager axisManager = getRowAxisManager();
- if (isEnabled() && axisManager != null && eventData != null) {
- final List<Integer> rows = getFullSelectedRowsIndex(eventData);
- enabled = axisManager.canDestroyAxisElement(rows);
- }
- setBaseEnabled(enabled);
- }
-}
+/***************************************************************************** + * Copyright (c) 2013 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: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.nattable.handler; + +import java.util.List; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager; + +/** + * The handler used to destroy the element represented by the selected rows + * + * @author VL222926 + * + */ +public class RowDestroyAxisElementHandler extends AbstractTableHandler { + + /** + * + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + * + * @param event + * @return + * @throws ExecutionException + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + final IAxisManager axisManager = getRowAxisManager(); + if (axisManager != null) { + axisManager.destroyAxisElement(getFullSelectedRowsIndex(event)); + } + return null; + } + + /** + * + * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object) + * + * @param evaluationContext + */ + @Override + public void setEnabled(Object evaluationContext) { + super.setEnabled(evaluationContext); + boolean enabled = false; + final IAxisManager axisManager = getRowAxisManager(); + if (isEnabled() && axisManager != null) { + final List<Integer> rows = getFullSelectedRowsIndex(evaluationContext); + enabled = axisManager.canDestroyAxisElement(rows); + } + setBaseEnabled(enabled); + } +} diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java index d23fe6b958a..47235f6ee23 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java @@ -1,67 +1,64 @@ -/*****************************************************************************
- * Copyright (c) 2013 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.nattable.handler;
-
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
-import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
-
-/**
- * The handler used to destroy the element represented by the selected rows
- *
- * @author VL222926
- *
- */
-public class RowDestroyAxisHandler extends AbstractTableHandler {
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- *
- * @param event
- * @return
- * @throws ExecutionException
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- final IAxisManager axisManager = getRowAxisManager();
- NatEventData eventData = getNatEventData();
- if (axisManager != null && eventData!=null) {
- axisManager.destroyAxis(getFullSelectedRowsIndex(eventData));
- }
- return null;
- }
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
- */
- @Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- final IAxisManager axisManager = getRowAxisManager();
- boolean enabled = false;
- NatEventData eventData = getNatEventData();
- if (isEnabled() && axisManager != null && eventData!=null) {
- final List<Integer> rows = getFullSelectedRowsIndex(eventData);
- enabled = axisManager.canDestroyAxis(rows);
- }
- setBaseEnabled(enabled);
- }
-}
+/***************************************************************************** + * Copyright (c) 2013 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: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.nattable.handler; + +import java.util.List; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager; + +/** + * The handler used to destroy the element represented by the selected rows + * + * @author VL222926 + * + */ +public class RowDestroyAxisHandler extends AbstractTableHandler { + + /** + * + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + * + * @param event + * @return + * @throws ExecutionException + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + final IAxisManager axisManager = getRowAxisManager(); + if (axisManager != null) { + axisManager.destroyAxis(getFullSelectedRowsIndex(event)); + } + return null; + } + + /** + * + * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object) + * + * @param evaluationContext + */ + @Override + public void setEnabled(Object evaluationContext) { + super.setEnabled(evaluationContext); + final IAxisManager axisManager = getRowAxisManager(); + boolean enabled = false; + if (isEnabled() && axisManager != null) { + final List<Integer> rows = getFullSelectedRowsIndex(evaluationContext); + enabled = axisManager.canDestroyAxis(rows); + } + setBaseEnabled(enabled); + } +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/resources/destroy/DeleteRow.di b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/resources/destroy/DeleteRow.di new file mode 100644 index 00000000000..bf9abab340f --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/resources/destroy/DeleteRow.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/> diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/resources/destroy/DeleteRow.notation b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/resources/destroy/DeleteRow.notation new file mode 100644 index 00000000000..903042d2a2d --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/resources/destroy/DeleteRow.notation @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<nattable:Table xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:configuration="http://www.eclipse.org/papyrus/infra/viewpoints/configuration" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:nattable="http://www.eclipse.org/papyrus/nattable/model" xmlns:nattableaxis="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis" xmlns:nattableaxisconfiguration="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration" xmlns:nattableaxisprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider" xmlns:nattableconfiguration="http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis http://www.eclipse.org/papyrus/nattable/model#//nattableaxis http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model#//nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableconfiguration" xmi:id="_zQ0ncA34EeWbxvoYyEMlEA" name="RequirementTable0" currentRowAxisProvider="_zQ0ndQ34EeWbxvoYyEMlEA" currentColumnAxisProvider="_zQ0ncQ34EeWbxvoYyEMlEA"> + <context xmi:type="uml:Model" href="DeleteRow.uml#_qqOagA33EeWbxvoYyEMlEA"/> + <owner xmi:type="uml:Model" href="DeleteRow.uml#_qqOagA33EeWbxvoYyEMlEA"/> + <prototype xmi:type="configuration:PapyrusSyncTable" href="platform:/plugin/org.eclipse.papyrus.infra.viewpoints.policy/builtin/default.configuration#_7wNb3txhEeOqHvRyiN87hA"/> + <tableConfiguration xmi:type="nattableconfiguration:TableConfiguration" href="platform:/plugin/org.eclipse.papyrus.sysml.nattable.requirement.config/configs/requirement.nattableconfiguration#/"/> + <columnAxisProvidersHistory xmi:type="nattableaxisprovider:SlaveObjectAxisProvider" xmi:id="_zQ0ncQ34EeWbxvoYyEMlEA" description="Provides the columns of the tables with a default configuration" name="Requirements Feature Columns Provider"> + <axis xmi:type="nattableaxis:FeatureIdAxis" xmi:id="_zQ0ncg34EeWbxvoYyEMlEA" element="property_of_stereotype:/SysML::Requirements::Requirement::id"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.sysml.nattable.requirement.config/configs/requirement.nattableconfiguration#//@columnHeaderAxisConfiguration/@axisManagers.1"/> + </axis> + <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_zQ0ncw34EeWbxvoYyEMlEA"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.sysml.nattable.requirement.config/configs/requirement.nattableconfiguration#//@columnHeaderAxisConfiguration/@axisManagers.0"/> + <element xmi:type="ecore:EAttribute" href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement/name"/> + </axis> + <axis xmi:type="nattableaxis:FeatureIdAxis" xmi:id="_zQ0ndA34EeWbxvoYyEMlEA" element="property_of_stereotype:/SysML::Requirements::Requirement::text"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.sysml.nattable.requirement.config/configs/requirement.nattableconfiguration#//@columnHeaderAxisConfiguration/@axisManagers.1"/> + </axis> + </columnAxisProvidersHistory> + <rowAxisProvidersHistory xmi:type="nattableaxisprovider:MasterObjectAxisProvider" xmi:id="_zQ0ndQ34EeWbxvoYyEMlEA" description="Provides the requirements directly owned by the context of the table" name="Requirement Axis Provider" disconnectSlave="true"/> +</nattable:Table> diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/resources/destroy/DeleteRow.uml b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/resources/destroy/DeleteRow.uml new file mode 100644 index 00000000000..1e35e1ad5a8 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/resources/destroy/DeleteRow.uml @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Allocations="http://www.eclipse.org/papyrus/0.7.0/SysML/Allocations" xmlns:Requirements="http://www.eclipse.org/papyrus/0.7.0/SysML/Requirements" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/0.7.0/SysML/Allocations http://www.eclipse.org/papyrus/0.7.0/SysML#//allocations http://www.eclipse.org/papyrus/0.7.0/SysML/Requirements http://www.eclipse.org/papyrus/0.7.0/SysML#//requirements"> + <uml:Model xmi:id="_qqOagA33EeWbxvoYyEMlEA" name="RootElement"> + <packagedElement xmi:type="uml:Class" xmi:id="_sCWEAA33EeWbxvoYyEMlEA" name="Class1"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_ufc_oA33EeWbxvoYyEMlEA" name="Attribute1"/> + <ownedOperation xmi:type="uml:Operation" xmi:id="_yfJvYA33EeWbxvoYyEMlEA" name="Operation1"> + <ownedParameter xmi:type="uml:Parameter" xmi:id="_zv-eEA33EeWbxvoYyEMlEA" name="Parameter1"/> + </ownedOperation> + <nestedClassifier xmi:type="uml:Class" xmi:id="_www68A33EeWbxvoYyEMlEA" name="nestedClass1"/> + </packagedElement> + <packagedElement xmi:type="uml:Class" xmi:id="_1LFKIA33EeWbxvoYyEMlEA" name="Class2"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_1LFKIQ33EeWbxvoYyEMlEA" name="Attribute2" visibility="public"/> + <ownedOperation xmi:type="uml:Operation" xmi:id="_1LFKIg33EeWbxvoYyEMlEA" name="Operation2"> + <ownedParameter xmi:type="uml:Parameter" xmi:id="_1LFKIw33EeWbxvoYyEMlEA" name="Parameter2" visibility="public" effect="create"/> + </ownedOperation> + <nestedClassifier xmi:type="uml:Class" xmi:id="_1LFKJA33EeWbxvoYyEMlEA" name="nestedClass2"/> + </packagedElement> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_SMr4IA34EeWbxvoYyEMlEA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_SMttUA34EeWbxvoYyEMlEA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML_PROFILES/SysML.profile.uml#_TZ_nULU5EduiKqCzJMWbGw"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_SMu7cA34EeWbxvoYyEMlEA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_SMu7cQ34EeWbxvoYyEMlEA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//modelelements"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML_PROFILES/SysML.profile.uml#_Gx8MgLX7EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_SMwJkA34EeWbxvoYyEMlEA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_SMwwoA34EeWbxvoYyEMlEA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//blocks"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML_PROFILES/SysML.profile.uml#_fSw28LX7EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_SMxXsA34EeWbxvoYyEMlEA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_SMx-wA34EeWbxvoYyEMlEA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//portandflows"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML_PROFILES/SysML.profile.uml#_rpx28LX7EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_SMyl0A34EeWbxvoYyEMlEA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_SMyl0Q34EeWbxvoYyEMlEA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//constraints"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML_PROFILES/SysML.profile.uml#_5WYJ0LX7EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_SMzz8A34EeWbxvoYyEMlEA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_SMzz8Q34EeWbxvoYyEMlEA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//activities"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML_PROFILES/SysML.profile.uml#_C2zXMLX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_SM0bAA34EeWbxvoYyEMlEA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_SM1CEA34EeWbxvoYyEMlEA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//allocations"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML_PROFILES/SysML.profile.uml#_NxdG4LX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_SM1pIA34EeWbxvoYyEMlEA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_SM2QMA34EeWbxvoYyEMlEA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//requirements"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML_PROFILES/SysML.profile.uml#_OOJC4LX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_SM23QA34EeWbxvoYyEMlEA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_SM3eUA34EeWbxvoYyEMlEA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//interactions"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML_PROFILES/SysML.profile.uml#_meOioLX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_SM4FYA34EeWbxvoYyEMlEA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_SM4FYQ34EeWbxvoYyEMlEA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//statemachines"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML_PROFILES/SysML.profile.uml#_nAF5kLX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_SM5TgA34EeWbxvoYyEMlEA"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_SM5TgQ34EeWbxvoYyEMlEA" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//usecases"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://SysML_PROFILES/SysML.profile.uml#_neZmMLX8EduFmqQsrNB9lw"/> + </profileApplication> + </uml:Model> + <Allocations:Allocated xmi:id="_U1a08A34EeWbxvoYyEMlEA" base_NamedElement="_ufc_oA33EeWbxvoYyEMlEA"/> + <Allocations:Allocated xmi:id="_Vjfb4A34EeWbxvoYyEMlEA" base_NamedElement="_yfJvYA33EeWbxvoYyEMlEA"/> + <Allocations:Allocated xmi:id="_WqtioA34EeWbxvoYyEMlEA" base_NamedElement="_zv-eEA33EeWbxvoYyEMlEA"/> + <Allocations:Allocated xmi:id="_YyyCYA34EeWbxvoYyEMlEA" base_NamedElement="_1LFKIQ33EeWbxvoYyEMlEA"/> + <Allocations:Allocated xmi:id="_ZxiJoA34EeWbxvoYyEMlEA" base_NamedElement="_1LFKIg33EeWbxvoYyEMlEA"/> + <Allocations:Allocated xmi:id="_aSwnYA34EeWbxvoYyEMlEA" base_NamedElement="_1LFKIw33EeWbxvoYyEMlEA"/> + <Requirements:Requirement xmi:id="_vEkCYA34EeWbxvoYyEMlEA" base_Class="_1LFKJA33EeWbxvoYyEMlEA"/> + <Requirements:Requirement xmi:id="_w0l1kA34EeWbxvoYyEMlEA" base_Class="_www68A33EeWbxvoYyEMlEA"/> + <Requirements:Requirement xmi:id="_xpCxUA34EeWbxvoYyEMlEA" base_Class="_sCWEAA33EeWbxvoYyEMlEA"/> + <Requirements:Requirement xmi:id="_47xDsA6KEeWbxvoYyEMlEA" base_Class="_1LFKIA33EeWbxvoYyEMlEA"/> +</xmi:XMI> diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/tests/AllTests.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/tests/AllTests.java index fab8315da60..dc07e9be441 100755 --- a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/tests/AllTests.java +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/tests/AllTests.java @@ -1,32 +1,40 @@ -/*****************************************************************************
- * Copyright (c) 2012 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.sysml.nattable.requirement.tests.tests;
-
-
-import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.without.service.edit.Bug443814_Enumeration;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-
-@RunWith(Suite.class)
-@SuiteClasses({ Bug443814_Enumeration.class, TableCreationInSysMLModelTest.class, OpenTableTest.class, TableCreationInUMLModel.class, RevealRequirementTableTest.class,
-
-})
-public class AllTests {
-
- /** The type of the requirement table */
- public static final String REQUIREMENT_TABLE_ID = "PapyrusSysMLRequirementTable"; //$NON-NLS-1$
-
- /** the creation command tested for the requirement table */
- public static final String COMMAND_ID = "org.eclipse.papyrus.sysml.nattable.requirement.create.withoutdialog.command"; //$NON-NLS-1$
-}
+/***************************************************************************** + * Copyright (c) 2012 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: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 467507 + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.nattable.requirement.tests.tests; + + +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.without.service.edit.Bug443814_Enumeration; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + + +@RunWith(Suite.class) +@SuiteClasses({ + Bug443814_Enumeration.class, + TableCreationInSysMLModelTest.class, + OpenTableTest.class, + TableCreationInUMLModel.class, + RevealRequirementTableTest.class, + DestroyRowAxisElementTest.class + +}) +public class AllTests { + + /** The type of the requirement table */ + public static final String REQUIREMENT_TABLE_ID = "PapyrusSysMLRequirementTable"; //$NON-NLS-1$ + + /** the creation command tested for the requirement table */ + public static final String COMMAND_ID = "org.eclipse.papyrus.sysml.nattable.requirement.create.withoutdialog.command"; //$NON-NLS-1$ +} diff --git a/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/tests/DestroyRowAxisElementTest.java b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/tests/DestroyRowAxisElementTest.java new file mode 100644 index 00000000000..227ef2f94e9 --- /dev/null +++ b/tests/junit/plugins/sysml/nattable/org.eclipse.papyrus.sysml.nattable.requirement.tests/src/org/eclipse/papyrus/sysml/nattable/requirement/tests/tests/DestroyRowAxisElementTest.java @@ -0,0 +1,188 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.sysml.nattable.requirement.tests.tests; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.IHandler; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.nattable.common.editor.AbstractEMFNattableEditor; +import org.eclipse.papyrus.infra.nattable.handler.PasteInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils; +import org.eclipse.papyrus.junit.utils.GenericUtils; +import org.eclipse.papyrus.sysml.nattable.requirement.tests.paste.without.service.edit.AbstractOpenTableTest; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.commands.ICommandService; +import org.eclipse.uml2.uml.UMLPackage; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * The abstract destroy axis command and destroy axis element command class. + */ +public class DestroyRowAxisElementTest extends AbstractOpenTableTest { + + /** + * The file name of the papyrus project used. + */ + public static String fileName = "DeleteRow"; //$NON-NLS-1$ + + /** + * The first class name. + */ + protected static final String FIRST_CLASS_NAME = "Class1"; + + /** + * The second class name. + */ + protected static final String SECOND_CLASS_NAME = "Class2"; + + /** + * Initialize the model. + * + * @throws Exception + * The exception. + */ + @Before + public void initModel() throws Exception { + initModel("RequirementTable0", fileName, getBundle()); //$NON-NLS-1$ //$NON-NLS-2$ + }; + + @Test + public void testDestroyAxisElement() throws Exception { + testOpenExistingTable("RequirementTable0", fileName); + flushDisplayEvents(); + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(2, rowElements.size()); + checkInitialDisplay(rowElements); + + // Get the command service + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull(commandService); + + // The destroy axis won't be enable for each row + for (int rowToCheck = 0; rowToCheck < 2; rowToCheck++) { + // Manage the selection of the row to check + final Object firstColumnRepresentedElement = rowElements.get(rowToCheck); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstColumnRepresentedElement); + flushDisplayEvents(); + + // Get the command and the handler + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row.element"); //$NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + + // Check the availability of the handler + Assert.assertTrue("The handler is not enabled for the row " + rowToCheck, handler.isEnabled()); + } + + // Get the first class + final Object firstColumnRepresentedElement = rowElements.get(0); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstColumnRepresentedElement); + flushDisplayEvents(); + + // Get the command + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row.element"); //$NON-NLS-1$ + + // Execute the command + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + flushDisplayEvents(); + cmd.executeWithChecks(event); + + // Check the table after destroy axis element + rowElements = manager.getRowElementsList(); + Assert.assertEquals(1, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements); + + // Undo + getTransactionalEditingDomain().getCommandStack().undo(); + Assert.assertEquals(2, rowElements.size()); + // The classes are invert because this is a synchronized table + // Check the second class + final Object firstRowRepresentedElement = rowElements.get(0); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) firstRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_CLASS_NAME, ((org.eclipse.uml2.uml.Class) firstRowRepresentedElement).getName()); + + // Check the first class + final Object secondRowRepresentedElement = rowElements.get(1); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) secondRowRepresentedElement).eClass()); + Assert.assertEquals(FIRST_CLASS_NAME, ((org.eclipse.uml2.uml.Class) secondRowRepresentedElement).getName()); + + // Redo + getTransactionalEditingDomain().getCommandStack().redo(); + Assert.assertEquals(1, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements); + } + + /** + * Check the initial display of the table. + * + * @param rowElements + * The row elements. + */ + protected void checkInitialDisplay(final List<?> rowElements) { + // Check the first class + final Object firstRowRepresentedElement = rowElements.get(0); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) firstRowRepresentedElement).eClass()); + Assert.assertEquals(FIRST_CLASS_NAME, ((org.eclipse.uml2.uml.Class) firstRowRepresentedElement).getName()); + + // Check the second class + final Object secondRowRepresentedElement = rowElements.get(1); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) secondRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_CLASS_NAME, ((org.eclipse.uml2.uml.Class) secondRowRepresentedElement).getName()); + } + + /** + * Check the table display after the first class exis element destroy. + * + * @param rowElements + * The row elements. + */ + protected void checkAfterClass1AxisElementDestroyDisplay(final List<?> rowElements) { + // Check the second class + final Object firstRowRepresentedElement = rowElements.get(0); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) firstRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_CLASS_NAME, ((org.eclipse.uml2.uml.Class) firstRowRepresentedElement).getName()); + } + + /** + * {@inheritDoc} + */ + @Override + protected String getSourcePath() { + return "/resources/destroy/"; //$NON-NLS-1$ + } + + /** + * This allow to close the opened editors. + */ + @AfterClass + public static void endOfTest() { + GenericUtils.closeAllEditors(); + } +} diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/META-INF/MANIFEST.MF index a35eba6ed98..e94c7066fea 100644 --- a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/META-INF/MANIFEST.MF @@ -24,7 +24,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.1.0", ca.odell.glazedlists;bundle-version="1.9.0", org.eclipse.nebula.widgets.nattable.core;bundle-version="[1.2.0,2.0.0)", - org.eclipse.papyrus.infra.tools;bundle-version="1.1.0" + org.eclipse.papyrus.infra.tools;bundle-version="1.1.0", + org.eclipse.papyrus.infra.widgets;bundle-version="1.1.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_H1_H2_Test.di b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_H1_H2_Test.di new file mode 100644 index 00000000000..8634d4c00e0 --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_H1_H2_Test.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_H1_H2_Test.notation b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_H1_H2_Test.notation new file mode 100644 index 00000000000..e553753aa2e --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_H1_H2_Test.notation @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<nattable:Table xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:configuration="http://www.eclipse.org/papyrus/infra/viewpoints/configuration" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:nattable="http://www.eclipse.org/papyrus/nattable/model" xmlns:nattableaxis="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis" xmlns:nattableaxisconfiguration="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration" xmlns:nattableaxisprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider" xmlns:nattableconfiguration="http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration" xmlns:nattablelabelprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattablecontentprovider" xmlns:nattablestyle="http://www.eclipse.org/papyrus/nattable/model/table/nattablestyle" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis http://www.eclipse.org/papyrus/nattable/model#//nattableaxis http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model#//nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattablecontentprovider http://www.eclipse.org/papyrus/nattable/model#//nattablelabelprovider http://www.eclipse.org/papyrus/nattable/model/table/nattablestyle http://www.eclipse.org/papyrus/nattable/model#//nattablestyle" xmi:id="_kTc2QABwEeWWcdqdZbcrig" name="ClassTreeTable0" currentRowAxisProvider="_kTddUABwEeWWcdqdZbcrig" currentColumnAxisProvider="_kTc2QQBwEeWWcdqdZbcrig">
+ <styles xmi:type="nattablestyle:IntListValueStyle" xmi:id="_YcgA8ABxEeWWcdqdZbcrig" name="hiddenCategoriesByDepth">
+ <intListValue>1</intListValue>
+ <intListValue>2</intListValue>
+ </styles>
+ <context xmi:type="uml:Model" href="DeleteRowAndRowAxis_0_H1_H2_Test.uml#_jPWU8ABwEeWWcdqdZbcrig"/>
+ <owner xmi:type="uml:Model" href="DeleteRowAndRowAxis_0_H1_H2_Test.uml#_jPWU8ABwEeWWcdqdZbcrig"/>
+ <prototype xmi:type="configuration:PapyrusSyncTable" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/classTreeTable.configuration#_P3J1cEr7EeSVGbM3cmVSqQ"/>
+ <tableConfiguration xmi:type="nattableconfiguration:TableConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#/"/>
+ <columnAxisProvidersHistory xmi:type="nattableaxisprovider:SlaveObjectAxisProvider" xmi:id="_kTc2QQBwEeWWcdqdZbcrig" description="This axis provider provides available columns according to the rows of the table (features of the object displayed on the other axis)" name="UML Feature axis provider">
+ <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_kTc2QgBwEeWWcdqdZbcrig">
+ <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@columnHeaderAxisConfiguration/@axisManagers.0"/>
+ <element xmi:type="ecore:EAttribute" href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement/name"/>
+ </axis>
+ </columnAxisProvidersHistory>
+ <rowAxisProvidersHistory xmi:type="nattableaxisprovider:MasterObjectAxisProvider" xmi:id="_kTddUABwEeWWcdqdZbcrig" description="This axis provider manages the rows, according to the wanted hierarchy" name="HierarchicalRowaAxisManager" disconnectSlave="true">
+ <axis xmi:type="nattableaxis:EObjectTreeItemAxis" xmi:id="_NcFAcABxEeWWcdqdZbcrig">
+ <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/>
+ <element xmi:type="uml:Class" href="DeleteRowAndRowAxis_0_H1_H2_Test.uml#_laJYkABwEeWWcdqdZbcrig"/>
+ </axis>
+ <axis xmi:type="nattableaxis:EObjectTreeItemAxis" xmi:id="_NcFAcQBxEeWWcdqdZbcrig">
+ <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/>
+ <element xmi:type="uml:Class" href="DeleteRowAndRowAxis_0_H1_H2_Test.uml#_mJ9r8ABwEeWWcdqdZbcrig"/>
+ </axis>
+ </rowAxisProvidersHistory>
+ <localRowHeaderAxisConfiguration xmi:type="nattableaxisconfiguration:LocalTableHeaderAxisConfiguration" xmi:id="_L_Do0ABxEeWWcdqdZbcrig" indexStyle="NUMERIC">
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:TreeFillingConfiguration" xmi:id="_L_JvcABxEeWWcdqdZbcrig" depth="1" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_L_JvcQBxEeWWcdqdZbcrig" alias="">
+ <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//StructuredClassifier/ownedAttribute"/>
+ </axisUsedAsAxisProvider>
+ <labelProvider xmi:type="nattablelabelprovider:FeatureLabelProviderConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@ownedLabelConfigurations.1"/>
+ </ownedAxisConfigurations>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:TreeFillingConfiguration" xmi:id="_L_JvcgBxEeWWcdqdZbcrig" depth="1" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_L_JvcwBxEeWWcdqdZbcrig" alias="">
+ <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class/nestedClassifier"/>
+ </axisUsedAsAxisProvider>
+ <labelProvider xmi:type="nattablelabelprovider:FeatureLabelProviderConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@ownedLabelConfigurations.1"/>
+ </ownedAxisConfigurations>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:TreeFillingConfiguration" xmi:id="_L_JvdABxEeWWcdqdZbcrig" depth="1" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_L_JvdQBxEeWWcdqdZbcrig" alias="">
+ <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class/ownedOperation"/>
+ </axisUsedAsAxisProvider>
+ <labelProvider xmi:type="nattablelabelprovider:FeatureLabelProviderConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@ownedLabelConfigurations.1"/>
+ </ownedAxisConfigurations>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:TreeFillingConfiguration" xmi:id="_L_JvdgBxEeWWcdqdZbcrig" depth="2" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_L_JvdwBxEeWWcdqdZbcrig" alias="">
+ <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioralFeature/ownedParameter"/>
+ </axisUsedAsAxisProvider>
+ <labelProvider xmi:type="nattablelabelprovider:FeatureLabelProviderConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@ownedLabelConfigurations.1"/>
+ </ownedAxisConfigurations>
+ <axisManagerConfigurations xmi:type="nattableaxisconfiguration:AxisManagerConfiguration" xmi:id="_L_JIYABxEeWWcdqdZbcrig" localSpecificConfigurations="_L_JvcABxEeWWcdqdZbcrig _L_JvcgBxEeWWcdqdZbcrig _L_JvdABxEeWWcdqdZbcrig _L_JvdgBxEeWWcdqdZbcrig">
+ <axisManager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/>
+ </axisManagerConfigurations>
+ </localRowHeaderAxisConfiguration>
+</nattable:Table>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_H1_H2_Test.uml b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_H1_H2_Test.uml new file mode 100644 index 00000000000..4f9d803851a --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_H1_H2_Test.uml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_jPWU8ABwEeWWcdqdZbcrig" name="RootElement">
+ <packagedElement xmi:type="uml:Class" xmi:id="_laJYkABwEeWWcdqdZbcrig" name="Class1">
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_oM3-4ABwEeWWcdqdZbcrig" name="Attribute1"/>
+ <ownedOperation xmi:type="uml:Operation" xmi:id="_nDbqkABwEeWWcdqdZbcrig" name="Operation1">
+ <ownedParameter xmi:type="uml:Parameter" xmi:id="_rf2ykABwEeWWcdqdZbcrig" name="Parameter1"/>
+ </ownedOperation>
+ <nestedClassifier xmi:type="uml:Class" xmi:id="_p4-7YABwEeWWcdqdZbcrig" name="nestedClass1"/>
+ </packagedElement>
+ <packagedElement xmi:type="uml:Class" xmi:id="_mJ9r8ABwEeWWcdqdZbcrig" name="Class2">
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_s-ALkABwEeWWcdqdZbcrig" name="Attribute2"/>
+ <ownedOperation xmi:type="uml:Operation" xmi:id="_s-ALkQBwEeWWcdqdZbcrig" name="Operation2">
+ <ownedParameter xmi:type="uml:Parameter" xmi:id="_s-ALkgBwEeWWcdqdZbcrig" name="Parameter2"/>
+ </ownedOperation>
+ <nestedClassifier xmi:type="uml:Class" xmi:id="_s-AyoABwEeWWcdqdZbcrig" name="nestedClass2"/>
+ </packagedElement>
+</uml:Model>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_V1_V2_Test.di b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_V1_V2_Test.di new file mode 100644 index 00000000000..8634d4c00e0 --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_V1_V2_Test.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_V1_V2_Test.notation b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_V1_V2_Test.notation new file mode 100644 index 00000000000..2e7cca1ce8d --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_V1_V2_Test.notation @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<nattable:Table xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:configuration="http://www.eclipse.org/papyrus/infra/viewpoints/configuration" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:nattable="http://www.eclipse.org/papyrus/nattable/model" xmlns:nattableaxis="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis" xmlns:nattableaxisconfiguration="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration" xmlns:nattableaxisprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider" xmlns:nattableconfiguration="http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration" xmlns:nattablelabelprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattablecontentprovider" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis http://www.eclipse.org/papyrus/nattable/model#//nattableaxis http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model#//nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattablecontentprovider http://www.eclipse.org/papyrus/nattable/model#//nattablelabelprovider" xmi:id="_kTc2QABwEeWWcdqdZbcrig" name="ClassTreeTable0" currentRowAxisProvider="_kTddUABwEeWWcdqdZbcrig" currentColumnAxisProvider="_kTc2QQBwEeWWcdqdZbcrig">
+ <context xmi:type="uml:Model" href="DeleteRowAndRowAxis_0_V1_V2_Test.uml#_jPWU8ABwEeWWcdqdZbcrig"/>
+ <owner xmi:type="uml:Model" href="DeleteRowAndRowAxis_0_V1_V2_Test.uml#_jPWU8ABwEeWWcdqdZbcrig"/>
+ <prototype xmi:type="configuration:PapyrusSyncTable" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/classTreeTable.configuration#_P3J1cEr7EeSVGbM3cmVSqQ"/>
+ <tableConfiguration xmi:type="nattableconfiguration:TableConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#/"/>
+ <columnAxisProvidersHistory xmi:type="nattableaxisprovider:SlaveObjectAxisProvider" xmi:id="_kTc2QQBwEeWWcdqdZbcrig" description="This axis provider provides available columns according to the rows of the table (features of the object displayed on the other axis)" name="UML Feature axis provider">
+ <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_kTc2QgBwEeWWcdqdZbcrig">
+ <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@columnHeaderAxisConfiguration/@axisManagers.0"/>
+ <element xmi:type="ecore:EAttribute" href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement/name"/>
+ </axis>
+ </columnAxisProvidersHistory>
+ <rowAxisProvidersHistory xmi:type="nattableaxisprovider:MasterObjectAxisProvider" xmi:id="_kTddUABwEeWWcdqdZbcrig" description="This axis provider manages the rows, according to the wanted hierarchy" name="HierarchicalRowaAxisManager" disconnectSlave="true">
+ <axis xmi:type="nattableaxis:EObjectTreeItemAxis" xmi:id="_NcFAcABxEeWWcdqdZbcrig">
+ <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/>
+ <element xmi:type="uml:Class" href="DeleteRowAndRowAxis_0_V1_V2_Test.uml#_laJYkABwEeWWcdqdZbcrig"/>
+ </axis>
+ <axis xmi:type="nattableaxis:EObjectTreeItemAxis" xmi:id="_NcFAcQBxEeWWcdqdZbcrig">
+ <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/>
+ <element xmi:type="uml:Class" href="DeleteRowAndRowAxis_0_V1_V2_Test.uml#_mJ9r8ABwEeWWcdqdZbcrig"/>
+ </axis>
+ </rowAxisProvidersHistory>
+ <localRowHeaderAxisConfiguration xmi:type="nattableaxisconfiguration:LocalTableHeaderAxisConfiguration" xmi:id="_L_Do0ABxEeWWcdqdZbcrig" indexStyle="NUMERIC">
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:TreeFillingConfiguration" xmi:id="_L_JvcABxEeWWcdqdZbcrig" depth="1" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_L_JvcQBxEeWWcdqdZbcrig" alias="">
+ <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//StructuredClassifier/ownedAttribute"/>
+ </axisUsedAsAxisProvider>
+ <labelProvider xmi:type="nattablelabelprovider:FeatureLabelProviderConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@ownedLabelConfigurations.1"/>
+ </ownedAxisConfigurations>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:TreeFillingConfiguration" xmi:id="_L_JvcgBxEeWWcdqdZbcrig" depth="1" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_L_JvcwBxEeWWcdqdZbcrig" alias="">
+ <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class/nestedClassifier"/>
+ </axisUsedAsAxisProvider>
+ <labelProvider xmi:type="nattablelabelprovider:FeatureLabelProviderConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@ownedLabelConfigurations.1"/>
+ </ownedAxisConfigurations>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:TreeFillingConfiguration" xmi:id="_L_JvdABxEeWWcdqdZbcrig" depth="1" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_L_JvdQBxEeWWcdqdZbcrig" alias="">
+ <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class/ownedOperation"/>
+ </axisUsedAsAxisProvider>
+ <labelProvider xmi:type="nattablelabelprovider:FeatureLabelProviderConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@ownedLabelConfigurations.1"/>
+ </ownedAxisConfigurations>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:TreeFillingConfiguration" xmi:id="_L_JvdgBxEeWWcdqdZbcrig" depth="2" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_L_JvdwBxEeWWcdqdZbcrig" alias="">
+ <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioralFeature/ownedParameter"/>
+ </axisUsedAsAxisProvider>
+ <labelProvider xmi:type="nattablelabelprovider:FeatureLabelProviderConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@ownedLabelConfigurations.1"/>
+ </ownedAxisConfigurations>
+ <axisManagerConfigurations xmi:type="nattableaxisconfiguration:AxisManagerConfiguration" xmi:id="_L_JIYABxEeWWcdqdZbcrig" localSpecificConfigurations="_L_JvcABxEeWWcdqdZbcrig _L_JvcgBxEeWWcdqdZbcrig _L_JvdABxEeWWcdqdZbcrig _L_JvdgBxEeWWcdqdZbcrig">
+ <axisManager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/>
+ </axisManagerConfigurations>
+ </localRowHeaderAxisConfiguration>
+</nattable:Table>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_V1_V2_Test.uml b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_V1_V2_Test.uml new file mode 100644 index 00000000000..4f9d803851a --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_0_V1_V2_Test.uml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_jPWU8ABwEeWWcdqdZbcrig" name="RootElement">
+ <packagedElement xmi:type="uml:Class" xmi:id="_laJYkABwEeWWcdqdZbcrig" name="Class1">
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_oM3-4ABwEeWWcdqdZbcrig" name="Attribute1"/>
+ <ownedOperation xmi:type="uml:Operation" xmi:id="_nDbqkABwEeWWcdqdZbcrig" name="Operation1">
+ <ownedParameter xmi:type="uml:Parameter" xmi:id="_rf2ykABwEeWWcdqdZbcrig" name="Parameter1"/>
+ </ownedOperation>
+ <nestedClassifier xmi:type="uml:Class" xmi:id="_p4-7YABwEeWWcdqdZbcrig" name="nestedClass1"/>
+ </packagedElement>
+ <packagedElement xmi:type="uml:Class" xmi:id="_mJ9r8ABwEeWWcdqdZbcrig" name="Class2">
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_s-ALkABwEeWWcdqdZbcrig" name="Attribute2"/>
+ <ownedOperation xmi:type="uml:Operation" xmi:id="_s-ALkQBwEeWWcdqdZbcrig" name="Operation2">
+ <ownedParameter xmi:type="uml:Parameter" xmi:id="_s-ALkgBwEeWWcdqdZbcrig" name="Parameter2"/>
+ </ownedOperation>
+ <nestedClassifier xmi:type="uml:Class" xmi:id="_s-AyoABwEeWWcdqdZbcrig" name="nestedClass2"/>
+ </packagedElement>
+</uml:Model>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_H1_H1_H2_Test.di b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_H1_H1_H2_Test.di new file mode 100644 index 00000000000..8634d4c00e0 --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_H1_H1_H2_Test.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_H1_H1_H2_Test.notation b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_H1_H1_H2_Test.notation new file mode 100644 index 00000000000..bc145114d00 --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_H1_H1_H2_Test.notation @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<nattable:Table xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:configuration="http://www.eclipse.org/papyrus/infra/viewpoints/configuration" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:nattable="http://www.eclipse.org/papyrus/nattable/model" xmlns:nattableaxis="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis" xmlns:nattableaxisconfiguration="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration" xmlns:nattableaxisprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider" xmlns:nattableconfiguration="http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration" xmlns:nattablestyle="http://www.eclipse.org/papyrus/nattable/model/table/nattablestyle" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis http://www.eclipse.org/papyrus/nattable/model#//nattableaxis http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model#//nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattablestyle http://www.eclipse.org/papyrus/nattable/model#//nattablestyle" xmi:id="_kTc2QABwEeWWcdqdZbcrig" name="ClassTreeTable0" currentRowAxisProvider="_kTddUABwEeWWcdqdZbcrig" currentColumnAxisProvider="_kTc2QQBwEeWWcdqdZbcrig">
+ <styles xmi:type="nattablestyle:IntListValueStyle" xmi:id="_E5hwkABxEeWWcdqdZbcrig" name="hiddenCategoriesByDepth">
+ <intListValue>0</intListValue>
+ <intListValue>1</intListValue>
+ <intListValue>2</intListValue>
+ </styles>
+ <context xmi:type="uml:Model" href="DeleteRowAndRowAxis_H1_H1_H2_Test.uml#_jPWU8ABwEeWWcdqdZbcrig"/>
+ <owner xmi:type="uml:Model" href="DeleteRowAndRowAxis_H1_H1_H2_Test.uml#_jPWU8ABwEeWWcdqdZbcrig"/>
+ <prototype xmi:type="configuration:PapyrusSyncTable" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/classTreeTable.configuration#_P3J1cEr7EeSVGbM3cmVSqQ"/>
+ <tableConfiguration xmi:type="nattableconfiguration:TableConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#/"/>
+ <columnAxisProvidersHistory xmi:type="nattableaxisprovider:SlaveObjectAxisProvider" xmi:id="_kTc2QQBwEeWWcdqdZbcrig" description="This axis provider provides available columns according to the rows of the table (features of the object displayed on the other axis)" name="UML Feature axis provider">
+ <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_kTc2QgBwEeWWcdqdZbcrig">
+ <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@columnHeaderAxisConfiguration/@axisManagers.0"/>
+ <element xmi:type="ecore:EAttribute" href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement/name"/>
+ </axis>
+ </columnAxisProvidersHistory>
+ <rowAxisProvidersHistory xmi:type="nattableaxisprovider:MasterObjectAxisProvider" xmi:id="_kTddUABwEeWWcdqdZbcrig" description="This axis provider manages the rows, according to the wanted hierarchy" name="HierarchicalRowaAxisManager" disconnectSlave="true"/>
+</nattable:Table>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_H1_H1_H2_Test.uml b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_H1_H1_H2_Test.uml new file mode 100644 index 00000000000..4f9d803851a --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_H1_H1_H2_Test.uml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_jPWU8ABwEeWWcdqdZbcrig" name="RootElement">
+ <packagedElement xmi:type="uml:Class" xmi:id="_laJYkABwEeWWcdqdZbcrig" name="Class1">
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_oM3-4ABwEeWWcdqdZbcrig" name="Attribute1"/>
+ <ownedOperation xmi:type="uml:Operation" xmi:id="_nDbqkABwEeWWcdqdZbcrig" name="Operation1">
+ <ownedParameter xmi:type="uml:Parameter" xmi:id="_rf2ykABwEeWWcdqdZbcrig" name="Parameter1"/>
+ </ownedOperation>
+ <nestedClassifier xmi:type="uml:Class" xmi:id="_p4-7YABwEeWWcdqdZbcrig" name="nestedClass1"/>
+ </packagedElement>
+ <packagedElement xmi:type="uml:Class" xmi:id="_mJ9r8ABwEeWWcdqdZbcrig" name="Class2">
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_s-ALkABwEeWWcdqdZbcrig" name="Attribute2"/>
+ <ownedOperation xmi:type="uml:Operation" xmi:id="_s-ALkQBwEeWWcdqdZbcrig" name="Operation2">
+ <ownedParameter xmi:type="uml:Parameter" xmi:id="_s-ALkgBwEeWWcdqdZbcrig" name="Parameter2"/>
+ </ownedOperation>
+ <nestedClassifier xmi:type="uml:Class" xmi:id="_s-AyoABwEeWWcdqdZbcrig" name="nestedClass2"/>
+ </packagedElement>
+</uml:Model>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_V1_V1_V2_Test.di b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_V1_V1_V2_Test.di new file mode 100644 index 00000000000..8634d4c00e0 --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_V1_V1_V2_Test.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_V1_V1_V2_Test.notation b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_V1_V1_V2_Test.notation new file mode 100644 index 00000000000..7bb6500e94c --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_V1_V1_V2_Test.notation @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<nattable:Table xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:configuration="http://www.eclipse.org/papyrus/infra/viewpoints/configuration" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:nattable="http://www.eclipse.org/papyrus/nattable/model" xmlns:nattableaxis="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis" xmlns:nattableaxisconfiguration="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration" xmlns:nattableaxisprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider" xmlns:nattableconfiguration="http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis http://www.eclipse.org/papyrus/nattable/model#//nattableaxis http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model#//nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableconfiguration" xmi:id="_kTc2QABwEeWWcdqdZbcrig" name="ClassTreeTable0" currentRowAxisProvider="_kTddUABwEeWWcdqdZbcrig" currentColumnAxisProvider="_kTc2QQBwEeWWcdqdZbcrig">
+ <context xmi:type="uml:Model" href="DeleteRowAndRowAxis_V1_V1_V2_Test.uml#_jPWU8ABwEeWWcdqdZbcrig"/>
+ <owner xmi:type="uml:Model" href="DeleteRowAndRowAxis_V1_V1_V2_Test.uml#_jPWU8ABwEeWWcdqdZbcrig"/>
+ <prototype xmi:type="configuration:PapyrusSyncTable" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/classTreeTable.configuration#_P3J1cEr7EeSVGbM3cmVSqQ"/>
+ <tableConfiguration xmi:type="nattableconfiguration:TableConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#/"/>
+ <columnAxisProvidersHistory xmi:type="nattableaxisprovider:SlaveObjectAxisProvider" xmi:id="_kTc2QQBwEeWWcdqdZbcrig" description="This axis provider provides available columns according to the rows of the table (features of the object displayed on the other axis)" name="UML Feature axis provider">
+ <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_kTc2QgBwEeWWcdqdZbcrig">
+ <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.clazz.config/configs/class_synchronized_tree.nattableconfiguration#//@columnHeaderAxisConfiguration/@axisManagers.0"/>
+ <element xmi:type="ecore:EAttribute" href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement/name"/>
+ </axis>
+ </columnAxisProvidersHistory>
+ <rowAxisProvidersHistory xmi:type="nattableaxisprovider:MasterObjectAxisProvider" xmi:id="_kTddUABwEeWWcdqdZbcrig" description="This axis provider manages the rows, according to the wanted hierarchy" name="HierarchicalRowaAxisManager" disconnectSlave="true"/>
+</nattable:Table>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_V1_V1_V2_Test.uml b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_V1_V1_V2_Test.uml new file mode 100644 index 00000000000..4f9d803851a --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/destroy/DeleteRowAndRowAxis_V1_V1_V2_Test.uml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_jPWU8ABwEeWWcdqdZbcrig" name="RootElement">
+ <packagedElement xmi:type="uml:Class" xmi:id="_laJYkABwEeWWcdqdZbcrig" name="Class1">
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_oM3-4ABwEeWWcdqdZbcrig" name="Attribute1"/>
+ <ownedOperation xmi:type="uml:Operation" xmi:id="_nDbqkABwEeWWcdqdZbcrig" name="Operation1">
+ <ownedParameter xmi:type="uml:Parameter" xmi:id="_rf2ykABwEeWWcdqdZbcrig" name="Parameter1"/>
+ </ownedOperation>
+ <nestedClassifier xmi:type="uml:Class" xmi:id="_p4-7YABwEeWWcdqdZbcrig" name="nestedClass1"/>
+ </packagedElement>
+ <packagedElement xmi:type="uml:Class" xmi:id="_mJ9r8ABwEeWWcdqdZbcrig" name="Class2">
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_s-ALkABwEeWWcdqdZbcrig" name="Attribute2"/>
+ <ownedOperation xmi:type="uml:Operation" xmi:id="_s-ALkQBwEeWWcdqdZbcrig" name="Operation2">
+ <ownedParameter xmi:type="uml:Parameter" xmi:id="_s-ALkgBwEeWWcdqdZbcrig" name="Parameter2"/>
+ </ownedOperation>
+ <nestedClassifier xmi:type="uml:Class" xmi:id="_s-AyoABwEeWWcdqdZbcrig" name="nestedClass2"/>
+ </packagedElement>
+</uml:Model>
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/destroy/tests/AbstractDestroyTest.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/destroy/tests/AbstractDestroyTest.java new file mode 100644 index 00000000000..1a800067f36 --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/destroy/tests/AbstractDestroyTest.java @@ -0,0 +1,304 @@ +/***************************************************************************** + * 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.destroy.tests; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TreeFillingConfiguration; +import org.eclipse.papyrus.junit.utils.GenericUtils; +import org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests.AbstractOpenTableTest; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.Parameter; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; + +/** + * The abstract destroy axis command and destroy axis element command class. + */ +public class AbstractDestroyTest extends AbstractOpenTableTest { + + /** + * The file name of the papyrus project used. + */ + public static String fileName = "destroy"; //$NON-NLS-1$ + + /** + * The first class name. + */ + protected static final String FIRST_CLASS_NAME = "Class1"; + + /** + * The first attribute name. + */ + protected static final String FIRST_ATTRIBUTE_NAME = "Attribute1"; + + /** + * the first nested class name. + */ + protected static final String FIRST_NESTED_CLASS_NAME = "nestedClass1"; + + /** + * The first operation name. + */ + protected static final String FIRST_OPERATION_NAME = "Operation1"; + + /** + * The first parameter name. + */ + protected static final String FIRST_PARAMETER_NAME = "Parameter1"; + + /** + * The second class name. + */ + protected static final String SECOND_CLASS_NAME = "Class2"; + + /** + * The second attribute name. + */ + protected static final String SECOND_ATTRIBUTE_NAME = "Attribute2"; + + /** + * the second nested class name. + */ + protected static final String SECOND_NESTED_CLASS_NAME = "nestedClass2"; + + /** + * The second operation name. + */ + protected static final String SECOND_OPERATION_NAME = "Operation2"; + + /** + * The second parameter name. + */ + protected static final String SECOND_PARAMETER_NAME = "Parameter2"; + + /** + * Initialize the model. + * + * @throws Exception + * The exception. + */ + @Before + public void initModel() throws Exception { + initModel("ClassTreeTable0", getClass().getSimpleName(), getBundle()); //$NON-NLS-1$ + }; + + /** + * {@inheritDoc} + */ + @Override + protected String getSourcePath() { + return "/resources/destroy/"; //$NON-NLS-1$ + } + + /** + * This allow to close the opened editors. + */ + @AfterClass + public static void endOfTest() { + GenericUtils.closeAllEditors(); + } + + /** + * Check the initial display of the table. + * + * @param rowElements + * The row elements. + * @param hasFirstTreeFillingConfiguration + * <code>true</code> if a first TreeFillingConfiguration is available, <code>false</code> otherwise. + */ + protected void checkInitialDisplay(final List<?> rowElements, final boolean hasFirstTreeFillingConfiguration) { + int increment = 0; + if (hasFirstTreeFillingConfiguration) { + final IAxis zeroRow = (IAxis) rowElements.get(0); + final Object zeroRowRepresentedElement = zeroRow.getElement(); + Assert.assertTrue(zeroRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + } + + // Check the first class with its hierarchy + final IAxis firstRow = (IAxis) rowElements.get(increment); + final Object firstRowRepresentedElement = firstRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) firstRowRepresentedElement).eClass()); + Assert.assertEquals(FIRST_CLASS_NAME, ((org.eclipse.uml2.uml.Class) firstRowRepresentedElement).getName()); + increment++; + + final IAxis secondRow = (IAxis) rowElements.get(increment); + final Object secondRowRepresentedElement = secondRow.getElement(); + Assert.assertTrue(secondRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + + final IAxis thirdRow = (IAxis) rowElements.get(increment); + final Object thirdRowRepresentedElement = thirdRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getProperty(), ((EObject) thirdRowRepresentedElement).eClass()); + Assert.assertEquals(FIRST_ATTRIBUTE_NAME, ((Property) thirdRowRepresentedElement).getName()); + increment++; + + final IAxis fourthRow = (IAxis) rowElements.get(increment); + final Object fourthRowRepresentedElement = fourthRow.getElement(); + Assert.assertTrue(fourthRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + + final IAxis fifthRow = (IAxis) rowElements.get(increment); + final Object fifthRowRepresentedElement = fifthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) fifthRowRepresentedElement).eClass()); + Assert.assertEquals(FIRST_NESTED_CLASS_NAME, ((org.eclipse.uml2.uml.Class) fifthRowRepresentedElement).getName()); + increment++; + + final IAxis sixthRow = (IAxis) rowElements.get(increment); + final Object sixthRowRepresentedElement = sixthRow.getElement(); + Assert.assertTrue(sixthRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + + final IAxis seventhRow = (IAxis) rowElements.get(increment); + final Object seventhRowRepresentedElement = seventhRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getOperation(), ((EObject) seventhRowRepresentedElement).eClass()); + Assert.assertEquals(FIRST_OPERATION_NAME, ((Operation) seventhRowRepresentedElement).getName()); + increment++; + + final IAxis heigthRow = (IAxis) rowElements.get(increment); + final Object heightRowRepresentedElement = heigthRow.getElement(); + Assert.assertTrue(heightRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + + final IAxis ninthRow = (IAxis) rowElements.get(increment); + final Object ninthRowRepresentedElement = ninthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getParameter(), ((EObject) ninthRowRepresentedElement).eClass()); + Assert.assertEquals(FIRST_PARAMETER_NAME, ((Parameter) ninthRowRepresentedElement).getName()); + increment++; + + // Check the second class with its hierarchy + final IAxis tenthRow = (IAxis) rowElements.get(increment); + final Object tenthRowRepresentedElement = tenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) tenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_CLASS_NAME, ((org.eclipse.uml2.uml.Class) tenthRowRepresentedElement).getName()); + increment++; + + final IAxis eleventhRow = (IAxis) rowElements.get(increment); + final Object eleventhRowRepresentedElement = eleventhRow.getElement(); + Assert.assertTrue(eleventhRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + + final IAxis twelfthRow = (IAxis) rowElements.get(increment); + final Object twelfthRowRepresentedElement = twelfthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getProperty(), ((EObject) twelfthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_ATTRIBUTE_NAME, ((Property) twelfthRowRepresentedElement).getName()); + increment++; + + final IAxis thirteenthRow = (IAxis) rowElements.get(increment); + final Object thirteenthRowRepresentedElement = thirteenthRow.getElement(); + Assert.assertTrue(thirteenthRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + + final IAxis fourteenthRow = (IAxis) rowElements.get(increment); + final Object fourteenthRowRepresentedElement = fourteenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) fourteenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_NESTED_CLASS_NAME, ((org.eclipse.uml2.uml.Class) fourteenthRowRepresentedElement).getName()); + increment++; + + final IAxis fifteenthRow = (IAxis) rowElements.get(increment); + final Object fifteenthRowRepresentedElement = fifteenthRow.getElement(); + Assert.assertTrue(fifteenthRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + + final IAxis sixteenthRow = (IAxis) rowElements.get(increment); + final Object sixteenthRowRepresentedElement = sixteenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getOperation(), ((EObject) sixteenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_OPERATION_NAME, ((Operation) sixteenthRowRepresentedElement).getName()); + increment++; + + final IAxis seventeenthRow = (IAxis) rowElements.get(increment); + final Object seventeenthRowRepresentedElement = seventeenthRow.getElement(); + Assert.assertTrue(seventeenthRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + + final IAxis eighteenthRow = (IAxis) rowElements.get(increment); + final Object eighteenthRowRepresentedElement = eighteenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getParameter(), ((EObject) eighteenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_PARAMETER_NAME, ((Parameter) eighteenthRowRepresentedElement).getName()); + } + + /** + * Check the table display after the first class exis element destroy. + * + * @param rowElements + * The row elements. + * @param hasFirstTreeFillingConfiguration + * <code>true</code> if a first TreeFillingConfiguration is available, <code>false</code> otherwise. + */ + protected void checkAfterClass1AxisElementDestroyDisplay(final List<?> rowElements, final boolean hasFirstTreeFillingConfiguration) { + int increment = 0; + if (hasFirstTreeFillingConfiguration) { + final IAxis zeroRow = (IAxis) rowElements.get(0); + final Object zeroRowRepresentedElement = zeroRow.getElement(); + Assert.assertTrue(zeroRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + } + + // Check the second class with its hierarchy + final IAxis tenthRow = (IAxis) rowElements.get(increment); + final Object tenthRowRepresentedElement = tenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) tenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_CLASS_NAME, ((org.eclipse.uml2.uml.Class) tenthRowRepresentedElement).getName()); + increment++; + + final IAxis eleventhRow = (IAxis) rowElements.get(increment); + final Object eleventhRowRepresentedElement = eleventhRow.getElement(); + Assert.assertTrue(eleventhRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + + final IAxis twelfthRow = (IAxis) rowElements.get(increment); + final Object twelfthRowRepresentedElement = twelfthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getProperty(), ((EObject) twelfthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_ATTRIBUTE_NAME, ((Property) twelfthRowRepresentedElement).getName()); + increment++; + + final IAxis thirteenthRow = (IAxis) rowElements.get(increment); + final Object thirteenthRowRepresentedElement = thirteenthRow.getElement(); + Assert.assertTrue(thirteenthRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + + final IAxis fourteenthRow = (IAxis) rowElements.get(increment); + final Object fourteenthRowRepresentedElement = fourteenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) fourteenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_NESTED_CLASS_NAME, ((org.eclipse.uml2.uml.Class) fourteenthRowRepresentedElement).getName()); + increment++; + + final IAxis fifteenthRow = (IAxis) rowElements.get(increment); + final Object fifteenthRowRepresentedElement = fifteenthRow.getElement(); + Assert.assertTrue(fifteenthRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + + final IAxis sixteenthRow = (IAxis) rowElements.get(increment); + final Object sixteenthRowRepresentedElement = sixteenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getOperation(), ((EObject) sixteenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_OPERATION_NAME, ((Operation) sixteenthRowRepresentedElement).getName()); + increment++; + + final IAxis seventeenthRow = (IAxis) rowElements.get(increment); + final Object seventeenthRowRepresentedElement = seventeenthRow.getElement(); + Assert.assertTrue(seventeenthRowRepresentedElement instanceof TreeFillingConfiguration); + increment++; + + final IAxis eighteenthRow = (IAxis) rowElements.get(increment); + final Object eighteenthRowRepresentedElement = eighteenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getParameter(), ((EObject) eighteenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_PARAMETER_NAME, ((Parameter) eighteenthRowRepresentedElement).getName()); + } +} 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/destroy/tests/DeleteRowAndRowAxis_0_H1_H2_Test.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/destroy/tests/DeleteRowAndRowAxis_0_H1_H2_Test.java new file mode 100644 index 00000000000..72ea5f0d707 --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/destroy/tests/DeleteRowAndRowAxis_0_H1_H2_Test.java @@ -0,0 +1,214 @@ +/***************************************************************************** + * 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.destroy.tests; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.IHandler; +import org.eclipse.papyrus.infra.nattable.common.editor.AbstractEMFNattableEditor; +import org.eclipse.papyrus.infra.nattable.handler.PasteInTableHandler; +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.IAxis; +import org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum; +import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils; +import org.eclipse.papyrus.junit.framework.classification.FailingTest; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.commands.ICommandService; +import org.junit.Assert; +import org.junit.Test; + +/** + * This class allows to test the destroy axis command and the destroy axis element command in the Hierarchical NatTable + */ +public class DeleteRowAndRowAxis_0_H1_H2_Test extends AbstractDestroyTest { + + /** + * The rows number. + */ + private static final int ROWS_NUMBER = 18; + + /** + * The number of rows to check. + */ + private static final int NUMBER_ROWS_TO_CHECK = 9; + + @Test + public void testOpen() throws Exception{ + testOpenExistingTable("ClassTreeTable0", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + Assert.assertTrue(manager instanceof ITreeNattableModelManager); + + // Expand the initial tree table + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, false); + } + + @FailingTest + public void testDestroyAxis() throws Exception { + testOpenExistingTable("ClassTreeTable0", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + Assert.assertTrue(manager instanceof ITreeNattableModelManager); + + // Expand the initial tree table + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, false); + + // Get the command service + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull(commandService); + + // The rows to check (enable for destroy axis command) + final List<Integer> rowsToCheckEnabled = new ArrayList<Integer>(); + rowsToCheckEnabled.add(0); + rowsToCheckEnabled.add(5); + + // The destroy axis won't be enable for element not dropped + for (int rowToCheck = 0; rowToCheck <= NUMBER_ROWS_TO_CHECK; rowToCheck++) { + // Manage the selection of the row to check + final IAxis firstRow = (IAxis) rowElements.get(rowToCheck); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command and the handler + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row"); //$NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + + // Check the availability of the handler + if (rowsToCheckEnabled.contains(rowToCheck)) { + Assert.assertTrue("The handler is not enabled for the row " + rowToCheck, handler.isEnabled()); //$NON-NLS-1$ + } else { + Assert.assertTrue("The handler is enabled for the row " + rowToCheck, !handler.isEnabled()); //$NON-NLS-1$ + } + } + + // Get the first class + final IAxis firstRow = (IAxis) rowElements.get(0); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row"); //$NON-NLS-1$ + + // Get the command and execute + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + Display.getCurrent().readAndDispatch(); + cmd.executeWithChecks(event); + + // Check the table after destroy axis element + rowElements = manager.getRowElementsList(); + Assert.assertEquals(9, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements, false); + + // Undo + getTransactionalEditingDomain().getCommandStack().undo(); + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, true); + + // Redo + getTransactionalEditingDomain().getCommandStack().redo(); + Assert.assertEquals(9, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements, false); + } + + @FailingTest + public void testDestroyAxisElement() throws Exception { + testOpenExistingTable("ClassTreeTable0", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + Assert.assertTrue(manager instanceof ITreeNattableModelManager); + + // Expand the initial tree table + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, false); + + // Get the command service + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull(commandService); + + // The destroy axis won't be enable for each row + for (int rowToCheck = 0; rowToCheck <= NUMBER_ROWS_TO_CHECK; rowToCheck++) { + // Manage the selection of the row to check + final IAxis firstRow = (IAxis) rowElements.get(rowToCheck); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command and the handler + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row.element"); //$NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + + // Check the availability of the handler + Assert.assertTrue("The handler is not enabled for the row " + rowToCheck, handler.isEnabled()); //$NON-NLS-1$ + } + + // Get the first class + final IAxis firstRow = (IAxis) rowElements.get(0); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row.element"); //$NON-NLS-1$ + + // Get the command and execute + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + Display.getCurrent().readAndDispatch(); + cmd.executeWithChecks(event); + + // Check the table after destroy axis element + rowElements = manager.getRowElementsList(); + Assert.assertEquals(9, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements, false); + + // Undo + getTransactionalEditingDomain().getCommandStack().undo(); + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, true); + + // Redo + getTransactionalEditingDomain().getCommandStack().redo(); + Assert.assertEquals(9, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements, false); + } +} 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/destroy/tests/DeleteRowAndRowAxis_0_V1_V2_Test.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/destroy/tests/DeleteRowAndRowAxis_0_V1_V2_Test.java new file mode 100644 index 00000000000..3d674097bd0 --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/destroy/tests/DeleteRowAndRowAxis_0_V1_V2_Test.java @@ -0,0 +1,219 @@ +/***************************************************************************** + * 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.destroy.tests; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.IHandler; +import org.eclipse.papyrus.infra.nattable.common.editor.AbstractEMFNattableEditor; +import org.eclipse.papyrus.infra.nattable.handler.PasteInTableHandler; +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.IAxis; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TreeFillingConfiguration; +import org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum; +import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils; +import org.eclipse.papyrus.junit.framework.classification.FailingTest; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.commands.ICommandService; +import org.junit.Assert; +import org.junit.Test; + +/** + * This class allows to test the destroy axis command and the destroy axis element command in the Hierarchical NatTable + */ +public class DeleteRowAndRowAxis_0_V1_V2_Test extends AbstractDestroyTest { + + /** + * The rows number. + */ + private static final int ROWS_NUMBER = 18; + + @Test + public void testOpen() throws Exception{ + testOpenExistingTable("ClassTreeTable0", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + Assert.assertTrue(manager instanceof ITreeNattableModelManager); + + // Expand the initial tree table + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, false); + } + + @FailingTest + public void testDestroyAxis() throws Exception { + testOpenExistingTable("ClassTreeTable0", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + Assert.assertTrue(manager instanceof ITreeNattableModelManager); + + // Expand the initial tree table + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, false); + + // Get the command service + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull(commandService); + + // The rows to check (enable for destroy axis command) + final List<Integer> rowsToCheckEnabled = new ArrayList<Integer>(); + rowsToCheckEnabled.add(0); + rowsToCheckEnabled.add(9); + + // The destroy axis won't be enable for element not dropped + for (int rowToCheck = 0; rowToCheck < ROWS_NUMBER; rowToCheck++) { + // Manage the selection of the row to check + final IAxis firstRow = (IAxis) rowElements.get(rowToCheck); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command and the handler + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row"); //$NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + + // Check the availability of the handler + if (rowsToCheckEnabled.contains(rowToCheck)) { + Assert.assertTrue("The handler is not enabled for the row " + rowToCheck, handler.isEnabled()); //$NON-NLS-1$ + } else { + Assert.assertTrue("The handler is enabled for the row " + rowToCheck, !handler.isEnabled()); //$NON-NLS-1$ + } + } + + // Get the first class + final IAxis firstRow = (IAxis) rowElements.get(0); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row"); //$NON-NLS-1$ + + // Get the command and execute + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + Display.getCurrent().readAndDispatch(); + cmd.executeWithChecks(event); + + // Check the table after destroy axis element + rowElements = manager.getRowElementsList(); + Assert.assertEquals(9, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements, false); + + // Undo + getTransactionalEditingDomain().getCommandStack().undo(); + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, true); + + // Redo + getTransactionalEditingDomain().getCommandStack().redo(); + Assert.assertEquals(9, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements, false); + } + + @FailingTest + public void testDestroyAxisElement() throws Exception { + testOpenExistingTable("ClassTreeTable0", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + Assert.assertTrue(manager instanceof ITreeNattableModelManager); + + // Expand the initial tree table + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, false); + + // Get the command service + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull(commandService); + + // The destroy axis won't be enable for each row + for (int rowToCheck = 0; rowToCheck < ROWS_NUMBER; rowToCheck++) { + // Manage the selection of the row to check + final IAxis firstRow = (IAxis) rowElements.get(rowToCheck); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the row element + final IAxis row = (IAxis) rowElements.get(rowToCheck); + final Object rowRepresentedElement = row.getElement(); + + // Get the command and the handler + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row.element"); //$NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + + // Check the availability of the handler + if (rowRepresentedElement instanceof TreeFillingConfiguration) { + Assert.assertTrue("The handler is enabled for the row " + rowToCheck, !handler.isEnabled()); //$NON-NLS-1$ + } else { + Assert.assertTrue("The handler is not enabled for the row " + rowToCheck, handler.isEnabled()); //$NON-NLS-1$ + } + } + + // Get the first class + final IAxis firstRow = (IAxis) rowElements.get(0); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row.element"); //$NON-NLS-1$ + + // Get the command and execute + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + Display.getCurrent().readAndDispatch(); + cmd.executeWithChecks(event); + + // Check the table after destroy axis element + rowElements = manager.getRowElementsList(); + Assert.assertEquals(9, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements, false); + + // Undo + getTransactionalEditingDomain().getCommandStack().undo(); + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, true); + + // Redo + getTransactionalEditingDomain().getCommandStack().redo(); + Assert.assertEquals(9, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements, false); + } + +} 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/destroy/tests/DeleteRowAndRowAxis_H1_H1_H2_Test.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/destroy/tests/DeleteRowAndRowAxis_H1_H1_H2_Test.java new file mode 100644 index 00000000000..d0d0535da54 --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/destroy/tests/DeleteRowAndRowAxis_H1_H1_H2_Test.java @@ -0,0 +1,155 @@ +/***************************************************************************** + * 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.destroy.tests; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.IHandler; +import org.eclipse.papyrus.infra.nattable.common.editor.AbstractEMFNattableEditor; +import org.eclipse.papyrus.infra.nattable.handler.PasteInTableHandler; +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.IAxis; +import org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum; +import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.commands.ICommandService; +import org.junit.Assert; +import org.junit.Test; + +/** + * This class allows to test the destroy axis command and the destroy axis element command in the Hierarchical NatTable + */ +public class DeleteRowAndRowAxis_H1_H1_H2_Test extends AbstractDestroyTest { + + /** + * The rows number. + */ + private static final int ROWS_NUMBER = 19; + + /** + * The number of rows to check. + */ + private static final int NUMBER_ROWS_TO_CHECK = 9; + + + @Test + public void testDestroyAxis() throws Exception { + testOpenExistingTable("ClassTreeTable0", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + Assert.assertTrue(manager instanceof ITreeNattableModelManager); + + // Expand the initial tree table + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, true); + + // Get the command service + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull(commandService); + + // The destroy axis won't be enable for each row + for (int rowToCheck = 0; rowToCheck <= NUMBER_ROWS_TO_CHECK; rowToCheck++) { + // Manage the selection of the row to check + final IAxis firstRow = (IAxis) rowElements.get(rowToCheck); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command and the handler + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row"); //$NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + + // Check the availability of the handler + Assert.assertTrue("The handler is enabled for the row " + rowToCheck, !handler.isEnabled()); + } + } + + @Test + public void testDestroyAxisElement() throws Exception { + testOpenExistingTable("ClassTreeTable0", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + Assert.assertTrue(manager instanceof ITreeNattableModelManager); + + // Expand the initial tree table + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, true); + + // Get the command service + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull(commandService); + + // The destroy axis won't be enable for each row + for (int rowToCheck = 0; rowToCheck <= NUMBER_ROWS_TO_CHECK; rowToCheck++) { + // Manage the selection of the row to check + final IAxis firstRow = (IAxis) rowElements.get(rowToCheck); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command and the handler + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row.element"); //$NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + + // Check the availability of the handler + Assert.assertTrue("The handler is not enabled for the row " + rowToCheck, handler.isEnabled()); //$NON-NLS-1$ + } + + // Get the first class + final IAxis firstRow = (IAxis) rowElements.get(0); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row.element"); //$NON-NLS-1$ + + // Get the command and execute + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + Display.getCurrent().readAndDispatch(); + cmd.executeWithChecks(event); + + // Check the table after destroy axis element + rowElements = manager.getRowElementsList(); + Assert.assertEquals(10, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements, true); + + // Undo + getTransactionalEditingDomain().getCommandStack().undo(); + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, true); + + // Redo + getTransactionalEditingDomain().getCommandStack().redo(); + Assert.assertEquals(10, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements, true); + } +} 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/destroy/tests/DeleteRowAndRowAxis_V1_V1_V2_Test.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/destroy/tests/DeleteRowAndRowAxis_V1_V1_V2_Test.java new file mode 100644 index 00000000000..35354409b50 --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/destroy/tests/DeleteRowAndRowAxis_V1_V1_V2_Test.java @@ -0,0 +1,154 @@ +/***************************************************************************** + * 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.destroy.tests; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.IHandler; +import org.eclipse.papyrus.infra.nattable.common.editor.AbstractEMFNattableEditor; +import org.eclipse.papyrus.infra.nattable.handler.PasteInTableHandler; +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.IAxis; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TreeFillingConfiguration; +import org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum; +import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.commands.ICommandService; +import org.junit.Assert; +import org.junit.Test; + +/** + * This class allows to test the destroy axis command and the destroy axis element command in the Hierarchical NatTable + */ +public class DeleteRowAndRowAxis_V1_V1_V2_Test extends AbstractDestroyTest { + + /** + * The rows number. + */ + private static final int ROWS_NUMBER = 19; + + + @Test + public void testDestroyAxis() throws Exception { + testOpenExistingTable("ClassTreeTable0", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + Assert.assertTrue(manager instanceof ITreeNattableModelManager); + + // Expand the initial tree table + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, true); + + // Get the command service + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull(commandService); + + // The destroy axis won't be enable for each row + for (int rowToCheck = 0; rowToCheck < ROWS_NUMBER; rowToCheck++) { + // Manage the selection of the row to check + final IAxis firstRow = (IAxis) rowElements.get(rowToCheck); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command and the handler + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row"); //$NON-NLS-1$ + IHandler handler = cmd.getHandler(); + + // Check the availability of the handler + Assert.assertTrue("The handler is enabled for the row " + rowToCheck, !handler.isEnabled()); //$NON-NLS-1$ + } + } + + @Test + public void testDestroyAxisElement() throws Exception { + testOpenExistingTable("ClassTreeTable0", "openTest"); //$NON-NLS-1$ //$NON-NLS-2$ + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + Assert.assertTrue(manager instanceof ITreeNattableModelManager); + + // Expand the initial tree table + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, true); + + // Get the command service + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull(commandService); + + // The destroy axis won't be enable for each row + for (int rowToCheck = 0; rowToCheck < ROWS_NUMBER; rowToCheck++) { + // Manage the selection of the row to check + final IAxis firstRow = (IAxis) rowElements.get(rowToCheck); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command and the handler + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row.element"); //$NON-NLS-1$ + IHandler handler = cmd.getHandler(); + + // Check the availability of the handler + if (firstRowRepresentedElement instanceof TreeFillingConfiguration) { + Assert.assertTrue("The handler is enabled for the row " + rowToCheck, !handler.isEnabled()); //$NON-NLS-1$ + } else { + Assert.assertTrue("The handler is not enabled for the row " + rowToCheck, handler.isEnabled()); //$NON-NLS-1$ + } + } + + // Get the first class + final IAxis firstRow = (IAxis) rowElements.get(1); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row.element"); //$NON-NLS-1$ + + // Get the command and execute + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + cmd.executeWithChecks(event); + + // Check the table after destroy axis element + rowElements = manager.getRowElementsList(); + Assert.assertEquals(10, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements, true); + + // Undo + getTransactionalEditingDomain().getCommandStack().undo(); + ((ITreeNattableModelManager) manager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements, true); + + // Redo + getTransactionalEditingDomain().getCommandStack().redo(); + Assert.assertEquals(10, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements, true); + } + +} 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/AllTests.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/AllTests.java index 2dd997a6f55..6d5f63f7d07 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/AllTests.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/AllTests.java @@ -15,6 +15,10 @@ package org.eclipse.papyrus.uml.nattable.clazz.config.tests.tests; import org.eclipse.papyrus.uml.nattable.clazz.config.tests.bugs.EditInvalidPastedText_V1_V3_V1; +import org.eclipse.papyrus.uml.nattable.clazz.config.tests.destroy.tests.DeleteRowAndRowAxis_0_H1_H2_Test; +import org.eclipse.papyrus.uml.nattable.clazz.config.tests.destroy.tests.DeleteRowAndRowAxis_0_V1_V2_Test; +import org.eclipse.papyrus.uml.nattable.clazz.config.tests.destroy.tests.DeleteRowAndRowAxis_H1_H1_H2_Test; +import org.eclipse.papyrus.uml.nattable.clazz.config.tests.destroy.tests.DeleteRowAndRowAxis_V1_V1_V2_Test; import org.eclipse.papyrus.uml.nattable.clazz.config.tests.filter.ReopenFilteredTable_Empty_H1_H1; import org.eclipse.papyrus.uml.nattable.clazz.config.tests.filter.ReopenFilteredTable_Empty_H1_V1; import org.eclipse.papyrus.uml.nattable.clazz.config.tests.filter.ReopenFilteredTable_Empty_V1_H1; @@ -79,7 +83,11 @@ import org.junit.runners.Suite.SuiteClasses; ReopenFilteredTable_V1_V1_H1.class, ReopenFilteredTable_V1_V1_V1.class, - + // Destroy axis + DeleteRowAndRowAxis_0_H1_H2_Test.class, + DeleteRowAndRowAxis_0_V1_V2_Test.class, + DeleteRowAndRowAxis_H1_H1_H2_Test.class, + DeleteRowAndRowAxis_V1_V1_V2_Test.class, PasteWithCategories_Empty_H1_H1_MultiColumns_Test.class, PasteWithCategories_Empty_H1_V1_MultiColumns_Test.class, diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/resources/destroy/DeleteRowAndRowAxis.di b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/resources/destroy/DeleteRowAndRowAxis.di new file mode 100644 index 00000000000..bf9abab340f --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/resources/destroy/DeleteRowAndRowAxis.di @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/> diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/resources/destroy/DeleteRowAndRowAxis.notation b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/resources/destroy/DeleteRowAndRowAxis.notation new file mode 100644 index 00000000000..f6a79a9065d --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/resources/destroy/DeleteRowAndRowAxis.notation @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<nattable:Table xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:configuration="http://www.eclipse.org/papyrus/infra/viewpoints/configuration" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:nattable="http://www.eclipse.org/papyrus/nattable/model" xmlns:nattableaxis="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis" xmlns:nattableaxisconfiguration="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration" xmlns:nattableaxisprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider" xmlns:nattableconfiguration="http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis http://www.eclipse.org/papyrus/nattable/model#//nattableaxis http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model#//nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableconfiguration" xmi:id="_9ZPeYA33EeWbxvoYyEMlEA" name="GenericTable0" currentRowAxisProvider="_9ZPeYg33EeWbxvoYyEMlEA" currentColumnAxisProvider="_9ZPeYQ33EeWbxvoYyEMlEA"> + <context xmi:type="uml:Model" href="DeleteRowAndRowAxis.uml#_qqOagA33EeWbxvoYyEMlEA"/> + <owner xmi:type="uml:Model" href="DeleteRowAndRowAxis.uml#_qqOagA33EeWbxvoYyEMlEA"/> + <prototype xmi:type="configuration:PapyrusSyncTable" href="platform:/plugin/org.eclipse.papyrus.infra.viewpoints.policy/builtin/default.configuration#_7wNb2NxhEeOqHvRyiN87hA"/> + <tableConfiguration xmi:type="nattableconfiguration:TableConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.generic.config/configs/generic.nattableconfiguration#/"/> + <columnAxisProvidersHistory xmi:type="nattableaxisprovider:SlaveObjectAxisProvider" xmi:id="_9ZPeYQ33EeWbxvoYyEMlEA" description="This axis provider provides available columns according to the rows of the table (features of the object displayed on the other axis)" name="UML Feature axis provider"> + <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_B3mgIQ34EeWbxvoYyEMlEA"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.generic.config/configs/generic.nattableconfiguration#//@columnHeaderAxisConfiguration/@axisManagers.0"/> + <element xmi:type="ecore:EAttribute" href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement/name"/> + </axis> + </columnAxisProvidersHistory> + <rowAxisProvidersHistory xmi:type="nattableaxisprovider:MasterObjectAxisProvider" xmi:id="_9ZPeYg33EeWbxvoYyEMlEA" description="This axis provider contains the object dropped by the user into the table" name="DroppedElementAxisProvider"> + <axis xmi:type="nattableaxis:EObjectAxis" xmi:id="_918ogA33EeWbxvoYyEMlEA"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.generic.config/configs/generic.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/> + <element xmi:type="uml:Class" href="DeleteRowAndRowAxis.uml#_sCWEAA33EeWbxvoYyEMlEA"/> + </axis> + <axis xmi:type="nattableaxis:EObjectAxis" xmi:id="_-Io7AA33EeWbxvoYyEMlEA"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.generic.config/configs/generic.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/> + <element xmi:type="uml:Property" href="DeleteRowAndRowAxis.uml#_ufc_oA33EeWbxvoYyEMlEA"/> + </axis> + <axis xmi:type="nattableaxis:EObjectAxis" xmi:id="_AcPVUA34EeWbxvoYyEMlEA"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.generic.config/configs/generic.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/> + <element xmi:type="uml:Class" href="DeleteRowAndRowAxis.uml#_www68A33EeWbxvoYyEMlEA"/> + </axis> + <axis xmi:type="nattableaxis:EObjectAxis" xmi:id="_Am67UA34EeWbxvoYyEMlEA"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.generic.config/configs/generic.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/> + <element xmi:type="uml:Operation" href="DeleteRowAndRowAxis.uml#_yfJvYA33EeWbxvoYyEMlEA"/> + </axis> + <axis xmi:type="nattableaxis:EObjectAxis" xmi:id="_Aw-PMA34EeWbxvoYyEMlEA"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.generic.config/configs/generic.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/> + <element xmi:type="uml:Parameter" href="DeleteRowAndRowAxis.uml#_zv-eEA33EeWbxvoYyEMlEA"/> + </axis> + <axis xmi:type="nattableaxis:EObjectAxis" xmi:id="_A_X3kA34EeWbxvoYyEMlEA"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.generic.config/configs/generic.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/> + <element xmi:type="uml:Class" href="DeleteRowAndRowAxis.uml#_1LFKIA33EeWbxvoYyEMlEA"/> + </axis> + <axis xmi:type="nattableaxis:EObjectAxis" xmi:id="_BOEa4A34EeWbxvoYyEMlEA"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.generic.config/configs/generic.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/> + <element xmi:type="uml:Property" href="DeleteRowAndRowAxis.uml#_1LFKIQ33EeWbxvoYyEMlEA"/> + </axis> + <axis xmi:type="nattableaxis:EObjectAxis" xmi:id="_BhSR0A34EeWbxvoYyEMlEA"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.generic.config/configs/generic.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/> + <element xmi:type="uml:Class" href="DeleteRowAndRowAxis.uml#_1LFKJA33EeWbxvoYyEMlEA"/> + </axis> + <axis xmi:type="nattableaxis:EObjectAxis" xmi:id="_Bs0zcA34EeWbxvoYyEMlEA"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.generic.config/configs/generic.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/> + <element xmi:type="uml:Operation" href="DeleteRowAndRowAxis.uml#_1LFKIg33EeWbxvoYyEMlEA"/> + </axis> + <axis xmi:type="nattableaxis:EObjectAxis" xmi:id="_B3mgEA34EeWbxvoYyEMlEA"> + <manager xmi:type="nattableaxisconfiguration:AxisManagerRepresentation" href="platform:/plugin/org.eclipse.papyrus.uml.nattable.generic.config/configs/generic.nattableconfiguration#//@rowHeaderAxisConfiguration/@axisManagers.0"/> + <element xmi:type="uml:Parameter" href="DeleteRowAndRowAxis.uml#_1LFKIw33EeWbxvoYyEMlEA"/> + </axis> + </rowAxisProvidersHistory> +</nattable:Table> diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/resources/destroy/DeleteRowAndRowAxis.uml b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/resources/destroy/DeleteRowAndRowAxis.uml new file mode 100644 index 00000000000..42d80233d66 --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/resources/destroy/DeleteRowAndRowAxis.uml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_qqOagA33EeWbxvoYyEMlEA" name="RootElement"> + <packagedElement xmi:type="uml:Class" xmi:id="_sCWEAA33EeWbxvoYyEMlEA" name="Class1"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_ufc_oA33EeWbxvoYyEMlEA" name="Attribute1"/> + <ownedOperation xmi:type="uml:Operation" xmi:id="_yfJvYA33EeWbxvoYyEMlEA" name="Operation1"> + <ownedParameter xmi:type="uml:Parameter" xmi:id="_zv-eEA33EeWbxvoYyEMlEA" name="Parameter1"/> + </ownedOperation> + <nestedClassifier xmi:type="uml:Class" xmi:id="_www68A33EeWbxvoYyEMlEA" name="nestedClass1"/> + </packagedElement> + <packagedElement xmi:type="uml:Class" xmi:id="_1LFKIA33EeWbxvoYyEMlEA" name="Class2"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_1LFKIQ33EeWbxvoYyEMlEA" name="Attribute2" visibility="public"/> + <ownedOperation xmi:type="uml:Operation" xmi:id="_1LFKIg33EeWbxvoYyEMlEA" name="Operation2"> + <ownedParameter xmi:type="uml:Parameter" xmi:id="_1LFKIw33EeWbxvoYyEMlEA" name="Parameter2" visibility="public" effect="create"/> + </ownedOperation> + <nestedClassifier xmi:type="uml:Class" xmi:id="_1LFKJA33EeWbxvoYyEMlEA" name="nestedClass2"/> + </packagedElement> +</uml:Model> diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/src/org/eclipse/papyrus/uml/nattable/generic/tests/tests/AllTests.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/src/org/eclipse/papyrus/uml/nattable/generic/tests/tests/AllTests.java index 79b08a8e6eb..2300fd80ad5 100755 --- a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/src/org/eclipse/papyrus/uml/nattable/generic/tests/tests/AllTests.java +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/src/org/eclipse/papyrus/uml/nattable/generic/tests/tests/AllTests.java @@ -1,30 +1,33 @@ -/*****************************************************************************
- * Copyright (c) 2014 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- * Quentin Le Menez (CEA LIST) quentin.lemenez@cea.fr
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.nattable.generic.tests.tests;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@RunWith(Suite.class)
-@SuiteClasses({ Bug458492_Edition_Enumeration.class,
- RevealGenericTableTest.class,
- FilterStringMatcherTest.class,
- FilterEEnumMatcherTest.class,
- FilterNumericMatcherTest.class,
- FilterUMLEnumerationMatcherTest.class })
-public class AllTests {
- // JUnit 4 test suite
-}
+/***************************************************************************** + * Copyright (c) 2014 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: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * Quentin Le Menez (CEA LIST) quentin.lemenez@cea.fr + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 467507 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.nattable.generic.tests.tests; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ Bug458492_Edition_Enumeration.class, + RevealGenericTableTest.class, + FilterStringMatcherTest.class, + FilterEEnumMatcherTest.class, + FilterNumericMatcherTest.class, + FilterUMLEnumerationMatcherTest.class, + DestroyRowAndRowAxisTest.class +}) +public class AllTests { + // JUnit 4 test suite +} diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/src/org/eclipse/papyrus/uml/nattable/generic/tests/tests/DestroyRowAndRowAxisTest.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/src/org/eclipse/papyrus/uml/nattable/generic/tests/tests/DestroyRowAndRowAxisTest.java new file mode 100644 index 00000000000..e2befe113d4 --- /dev/null +++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.tests/src/org/eclipse/papyrus/uml/nattable/generic/tests/tests/DestroyRowAndRowAxisTest.java @@ -0,0 +1,382 @@ +/***************************************************************************** + * 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.generic.tests.tests; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.IHandler; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.nattable.common.editor.AbstractEMFNattableEditor; +import org.eclipse.papyrus.infra.nattable.handler.PasteInTableHandler; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis; +import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils; +import org.eclipse.papyrus.junit.utils.GenericUtils; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.commands.ICommandService; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.Parameter; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * The abstract destroy axis command and destroy axis element command class. + */ +public class DestroyRowAndRowAxisTest extends AbstractGenericTableTest { + + /** + * The rows number. + */ + private static final int ROWS_NUMBER = 10; + + /** + * The file name of the papyrus project used. + */ + public static String fileName = "DeleteRowAndRowAxis"; //$NON-NLS-1$ + + /** + * The first class name. + */ + protected static final String FIRST_CLASS_NAME = "Class1"; + + /** + * The first attribute name. + */ + protected static final String FIRST_ATTRIBUTE_NAME = "Attribute1"; + + /** + * the first nested class name. + */ + protected static final String FIRST_NESTED_CLASS_NAME = "nestedClass1"; + + /** + * The first operation name. + */ + protected static final String FIRST_OPERATION_NAME = "Operation1"; + + /** + * The first parameter name. + */ + protected static final String FIRST_PARAMETER_NAME = "Parameter1"; + + /** + * The second class name. + */ + protected static final String SECOND_CLASS_NAME = "Class2"; + + /** + * The second attribute name. + */ + protected static final String SECOND_ATTRIBUTE_NAME = "Attribute2"; + + /** + * the second nested class name. + */ + protected static final String SECOND_NESTED_CLASS_NAME = "nestedClass2"; + + /** + * The second operation name. + */ + protected static final String SECOND_OPERATION_NAME = "Operation2"; + + /** + * The second parameter name. + */ + protected static final String SECOND_PARAMETER_NAME = "Parameter2"; + + /** + * Initialize the model. + * + * @throws Exception + * The exception. + */ + @Before + public void initModel() throws Exception { + initModel("GenericTable0", fileName, getBundle()); //$NON-NLS-1$ + }; + + @Test + public void testDestroyAxis() throws Exception { + loadGenericTable(); + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements); + + // Get the command service + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull(commandService); + + // The destroy axis won't be enable for element not dropped + for (int rowToCheck = 0; rowToCheck < ROWS_NUMBER; rowToCheck++) { + // Manage the selection of the row to check + final IAxis firstRow = (IAxis) rowElements.get(rowToCheck); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command and the handler + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row"); //$NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + + // Check the availability of the handler + Assert.assertTrue("The handler is not enabled for the row " + rowToCheck, handler.isEnabled()); + } + + // Select the 5 first rows + final IAxis firstRow = (IAxis) rowElements.get(0); + final Object firstRowRepresentedElement = firstRow.getElement(); + final IAxis secondRow = (IAxis) rowElements.get(1); + final Object secondRowRepresentedElement = secondRow.getElement(); + final IAxis thirdRow = (IAxis) rowElements.get(2); + final Object thirdRowRepresentedElement = thirdRow.getElement(); + final IAxis fourthRow = (IAxis) rowElements.get(3); + final Object fourthRowRepresentedElement = fourthRow.getElement(); + final IAxis fifthRow = (IAxis) rowElements.get(4); + final Object fifthRowRepresentedElement = fifthRow.getElement(); + final List<Object> axisToDestroy = new ArrayList<Object>(5); + axisToDestroy.add(firstRowRepresentedElement); + axisToDestroy.add(secondRowRepresentedElement); + axisToDestroy.add(thirdRowRepresentedElement); + axisToDestroy.add(fourthRowRepresentedElement); + axisToDestroy.add(fifthRowRepresentedElement); + ((AbstractEMFNattableEditor) tableEditor).revealElement(axisToDestroy); + + // Get the command + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row"); //$NON-NLS-1$ + + // Execute the command + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + cmd.executeWithChecks(event); + + // Check the table after destroy axis element + rowElements = manager.getRowElementsList(); + Assert.assertEquals(5, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements); + + // Undo + getTransactionalEditingDomain().getCommandStack().undo(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements); + + // Redo + getTransactionalEditingDomain().getCommandStack().redo(); + Assert.assertEquals(5, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements); + } + + @Test + public void testDestroyAxisElement() throws Exception { + loadGenericTable(); + IEditorPart tableEditor = editor.getActiveEditor(); + Assert.assertTrue(tableEditor instanceof AbstractEMFNattableEditor); + INattableModelManager manager = (INattableModelManager) tableEditor.getAdapter(INattableModelManager.class); + + // Get the row elements and check the initial display + List<?> rowElements = manager.getRowElementsList(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements); + + // Get the command service + final ICommandService commandService = EclipseCommandUtils.getCommandService(); + Assert.assertNotNull(commandService); + + // The destroy axis won't be enable for each row + for (int rowToCheck = 0; rowToCheck < ROWS_NUMBER; rowToCheck++) { + // Manage the selection of the row to check + final IAxis firstRow = (IAxis) rowElements.get(rowToCheck); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command and the handler + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row.element"); //$NON-NLS-1$ + final IHandler handler = cmd.getHandler(); + + // Check the availability of the handler + Assert.assertTrue("The handler is not enabled for the row " + rowToCheck, handler.isEnabled()); + } + + // Remove the first element + final IAxis firstRow = (IAxis) rowElements.get(0); + final Object firstRowRepresentedElement = firstRow.getElement(); + ((AbstractEMFNattableEditor) tableEditor).revealElement(firstRowRepresentedElement); + + // Get the command + final Command cmd = commandService.getCommand("org.eclipse.papyrus.infra.nattable.destroy.row.element"); //$NON-NLS-1$ + + // Execute the command + final Map<Object, Object> parameters = new HashMap<Object, Object>(); + parameters.put(PasteInTableHandler.OPEN_DIALOG_ON_FAIL_BOOLEAN_PARAMETER, Boolean.FALSE); + parameters.put(PasteInTableHandler.OPEN__PROGRESS_MONITOR_DIALOG, Boolean.FALSE); + ExecutionEvent event = new ExecutionEvent(cmd, parameters, null, null); + cmd.executeWithChecks(event); + + // Check the table after destroy axis element + rowElements = manager.getRowElementsList(); + Assert.assertEquals(5, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements); + + // Undo + getTransactionalEditingDomain().getCommandStack().undo(); + Assert.assertEquals(ROWS_NUMBER, rowElements.size()); + checkInitialDisplay(rowElements); + + // Redo + getTransactionalEditingDomain().getCommandStack().redo(); + Assert.assertEquals(5, rowElements.size()); + checkAfterClass1AxisElementDestroyDisplay(rowElements); + } + + /** + * Check the initial display of the table. + * + * @param rowElements + * The row elements. + */ + protected void checkInitialDisplay(final List<?> rowElements) { + int increment = 0; + + // Check the first class with its hierarchy + final IAxis firstRow = (IAxis) rowElements.get(increment); + final Object firstRowRepresentedElement = firstRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) firstRowRepresentedElement).eClass()); + Assert.assertEquals(FIRST_CLASS_NAME, ((org.eclipse.uml2.uml.Class) firstRowRepresentedElement).getName()); + increment++; + + final IAxis thirdRow = (IAxis) rowElements.get(increment); + final Object thirdRowRepresentedElement = thirdRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getProperty(), ((EObject) thirdRowRepresentedElement).eClass()); + Assert.assertEquals(FIRST_ATTRIBUTE_NAME, ((Property) thirdRowRepresentedElement).getName()); + increment++; + + final IAxis fifthRow = (IAxis) rowElements.get(increment); + final Object fifthRowRepresentedElement = fifthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) fifthRowRepresentedElement).eClass()); + Assert.assertEquals(FIRST_NESTED_CLASS_NAME, ((org.eclipse.uml2.uml.Class) fifthRowRepresentedElement).getName()); + increment++; + + final IAxis seventhRow = (IAxis) rowElements.get(increment); + final Object seventhRowRepresentedElement = seventhRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getOperation(), ((EObject) seventhRowRepresentedElement).eClass()); + Assert.assertEquals(FIRST_OPERATION_NAME, ((Operation) seventhRowRepresentedElement).getName()); + increment++; + + final IAxis ninthRow = (IAxis) rowElements.get(increment); + final Object ninthRowRepresentedElement = ninthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getParameter(), ((EObject) ninthRowRepresentedElement).eClass()); + Assert.assertEquals(FIRST_PARAMETER_NAME, ((Parameter) ninthRowRepresentedElement).getName()); + increment++; + + // Check the second class with its hierarchy + final IAxis tenthRow = (IAxis) rowElements.get(increment); + final Object tenthRowRepresentedElement = tenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) tenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_CLASS_NAME, ((org.eclipse.uml2.uml.Class) tenthRowRepresentedElement).getName()); + increment++; + + final IAxis twelfthRow = (IAxis) rowElements.get(increment); + final Object twelfthRowRepresentedElement = twelfthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getProperty(), ((EObject) twelfthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_ATTRIBUTE_NAME, ((Property) twelfthRowRepresentedElement).getName()); + increment++; + + final IAxis fourteenthRow = (IAxis) rowElements.get(increment); + final Object fourteenthRowRepresentedElement = fourteenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) fourteenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_NESTED_CLASS_NAME, ((org.eclipse.uml2.uml.Class) fourteenthRowRepresentedElement).getName()); + increment++; + + final IAxis sixteenthRow = (IAxis) rowElements.get(increment); + final Object sixteenthRowRepresentedElement = sixteenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getOperation(), ((EObject) sixteenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_OPERATION_NAME, ((Operation) sixteenthRowRepresentedElement).getName()); + increment++; + + final IAxis eighteenthRow = (IAxis) rowElements.get(increment); + final Object eighteenthRowRepresentedElement = eighteenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getParameter(), ((EObject) eighteenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_PARAMETER_NAME, ((Parameter) eighteenthRowRepresentedElement).getName()); + } + + /** + * Check the table display after the first class exis element destroy. + * + * @param rowElements + * The row elements. + */ + protected void checkAfterClass1AxisElementDestroyDisplay(final List<?> rowElements) { + int increment = 0; + + // Check the second class with its hierarchy + final IAxis tenthRow = (IAxis) rowElements.get(increment); + final Object tenthRowRepresentedElement = tenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) tenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_CLASS_NAME, ((org.eclipse.uml2.uml.Class) tenthRowRepresentedElement).getName()); + increment++; + + final IAxis twelfthRow = (IAxis) rowElements.get(increment); + final Object twelfthRowRepresentedElement = twelfthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getProperty(), ((EObject) twelfthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_ATTRIBUTE_NAME, ((Property) twelfthRowRepresentedElement).getName()); + increment++; + + final IAxis fourteenthRow = (IAxis) rowElements.get(increment); + final Object fourteenthRowRepresentedElement = fourteenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getClass_(), ((EObject) fourteenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_NESTED_CLASS_NAME, ((org.eclipse.uml2.uml.Class) fourteenthRowRepresentedElement).getName()); + increment++; + + final IAxis sixteenthRow = (IAxis) rowElements.get(increment); + final Object sixteenthRowRepresentedElement = sixteenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getOperation(), ((EObject) sixteenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_OPERATION_NAME, ((Operation) sixteenthRowRepresentedElement).getName()); + increment++; + + final IAxis eighteenthRow = (IAxis) rowElements.get(increment); + final Object eighteenthRowRepresentedElement = eighteenthRow.getElement(); + Assert.assertEquals(UMLPackage.eINSTANCE.getParameter(), ((EObject) eighteenthRowRepresentedElement).eClass()); + Assert.assertEquals(SECOND_PARAMETER_NAME, ((Parameter) eighteenthRowRepresentedElement).getName()); + } + + /** + * {@inheritDoc} + */ + @Override + protected String getSourcePath() { + return "/resources/destroy/"; //$NON-NLS-1$ + } + + /** + * This allow to close the opened editors. + */ + @AfterClass + public static void endOfTest() { + GenericUtils.closeAllEditors(); + } +} |