Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-01-08 17:43:26 +0000
committervincent lorenzo2016-02-09 15:06:57 +0000
commitaa593b9a2870da6662ac032b7b3dd0e779374952 (patch)
tree2133c4e25a94675cc9f1bd529d8b77fd080dfa31
parentadd5530b1037779fe0c8a40ba2db902dfe4ad670 (diff)
downloadorg.eclipse.papyrus-aa593b9a2870da6662ac032b7b3dd0e779374952.tar.gz
org.eclipse.papyrus-aa593b9a2870da6662ac032b7b3dd0e779374952.tar.xz
org.eclipse.papyrus-aa593b9a2870da6662ac032b7b3dd0e779374952.zip
Bug 481310: [Table] Paste in table with several categories for the same
depth and all categories hidden https://bugs.eclipse.org/bugs/show_bug.cgi?id=481310 The max depth is calculated before the check of paste configuration to check only the needed ones. Change-Id: I42cf00039b732379682e195ce744e7a84bda12ab Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractInsertImportInNattableManager.java19
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java20
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInsertInNattableManager.java80
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteHelperUtils.java107
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.di2
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.notation81
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.txt2
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.uml2
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/bugs/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.java91
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/paste/tests/AbstractPasteWithCategoriesTests.java7
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/AllTests.java16
11 files changed, 365 insertions, 62 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractInsertImportInNattableManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractInsertImportInNattableManager.java
index af5d5796fc1..babd488f9f9 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractInsertImportInNattableManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractInsertImportInNattableManager.java
@@ -91,6 +91,9 @@ public abstract class AbstractInsertImportInNattableManager extends AbstractPast
IStatus resultStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.InsertInNattableManager_InsertNotYetManaged);
PasteEnablementStatus pasteStatus = null;
+
+ int maxDepth = Integer.MAX_VALUE;
+
// Check if the paste configuration is needed for the paste action
pasteStatus = findPasteModeFromTableConfiguration(this.tableManager);
if (PasteModeEnumeration.PASTE_NO_CONFIGURATION != pasteStatus.getPasteMode() && PasteModeEnumeration.CANT_PASTE != pasteStatus.getPasteMode()) {
@@ -114,7 +117,7 @@ public abstract class AbstractInsertImportInNattableManager extends AbstractPast
resultStatus = createCantInsertStatus(pasteStatus);
break;
case PASTE_EOBJECT_ROW:
- resultStatus = insertRow(this.tableManager, pasteStatus, pasteHelper);
+ resultStatus = insertRow(this.tableManager, pasteStatus, pasteHelper, maxDepth);
break;
case PASTE_EOBJECT_COLUMN:
case PASTE_EOBJECT_ROW_OR_COLUMN:
@@ -164,17 +167,19 @@ public abstract class AbstractInsertImportInNattableManager extends AbstractPast
* the paste status
* @param pasteHelper
* the paste helper
+ * @param maxDepth
+ * The maximum depth to check.
* @return
* <code>true</code> if the paste can be done
*/
- private IStatus insertRow(final INattableModelManager manager, final PasteEnablementStatus pasteStatus, final CSVPasteHelper pasteHelper) {
+ private IStatus insertRow(final INattableModelManager manager, final PasteEnablementStatus pasteStatus, final CSVPasteHelper pasteHelper, final int maxDepth) {
IStatus resultStatus = Status.OK_STATUS;
if (TableHelper.isTreeTable(manager)) {
if (null != tableSelectionWrapper) {
resultStatus = insertTreeRows(manager, pasteStatus, pasteHelper, tableSelectionWrapper);
} else {
- resultStatus = insertTreeRows(manager, pasteStatus, pasteHelper);
+ resultStatus = insertTreeRows(manager, pasteStatus, pasteHelper, maxDepth);
}
} else {
if (null != tableSelectionWrapper) {
@@ -217,12 +222,12 @@ public abstract class AbstractInsertImportInNattableManager extends AbstractPast
* The paste status.
* @param pasteHelper
* The paste helper.
- * @param tableSelectionWrapper
- * The current selection.
+ * @param maxDepth
+ * The maximum depth to check.
* @return The status of the paste.
*/
- private IStatus insertTreeRows(final INattableModelManager manager, final PasteEnablementStatus pasteStatus, final CSVPasteHelper pasteHelper) {
- IStatus status = checkTreeTableConfiguration(manager);
+ private IStatus insertTreeRows(final INattableModelManager manager, final PasteEnablementStatus pasteStatus, final CSVPasteHelper pasteHelper, final int maxDepth) {
+ IStatus status = checkTreeTableConfiguration(manager, maxDepth);
if (status.isOK()) {
status = insertTree(manager, pasteStatus, useProgressMonitorDialog, createReader(), null, getDataSize());
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java
index a9dc9833105..c93499d4854 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java
@@ -133,6 +133,9 @@ public abstract class AbstractPasteImportInNattableManager extends AbstractPaste
IStatus resultStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.AbstractPasteImportInNattableManager_PasteNotYetManaged);
PasteEnablementStatus pasteStatus = null;
+
+ int maxDepth = Integer.MAX_VALUE;
+
// Check if the paste configuration is needed for the paste action
boolean useElse = true;
if (!isNeededPasteConfiguration()) {
@@ -166,6 +169,9 @@ public abstract class AbstractPasteImportInNattableManager extends AbstractPaste
}
if (useElse) {
+ if(TableHelper.isTreeTable(tableManager)){
+ maxDepth = PasteHelperUtils.getMaxDepthToPaste(tableManager, pasteHelper, createReader());
+ }
pasteStatus = findPasteModeFromTableConfiguration(this.tableManager);
if (pasteStatus.getPasteMode() == PasteModeEnumeration.PASTE_EOBJECT_ROW_OR_COLUMN) {
final boolean value = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), PasteImportStatusDialog.DIALOG_TITLE, Messages.AbstractPasteImportInsertInNattableManager_WhatAreYouPasting);
@@ -186,7 +192,7 @@ public abstract class AbstractPasteImportInNattableManager extends AbstractPaste
resultStatus = createCantPasteStatus(pasteStatus);
break;
case PASTE_EOBJECT_ROW:
- resultStatus = pasteRow(this.tableManager, pasteStatus, pasteHelper);
+ resultStatus = pasteRow(this.tableManager, pasteStatus, pasteHelper, maxDepth);
break;
case PASTE_EOBJECT_COLUMN:
resultStatus = pasteColumn(this.tableManager, pasteStatus, pasteHelper);
@@ -276,17 +282,19 @@ public abstract class AbstractPasteImportInNattableManager extends AbstractPaste
* the paste status
* @param pasteHelper
* the paste helper
+ * @param maxDepth
+ * The maximum depth to check.
* @return
* <code>true</code> if the paste can be done
*/
- private IStatus pasteRow(final INattableModelManager manager, final PasteEnablementStatus pasteStatus, final CSVPasteHelper pasteHelper) {
+ private IStatus pasteRow(final INattableModelManager manager, final PasteEnablementStatus pasteStatus, final CSVPasteHelper pasteHelper, final int maxDepth) {
IStatus resultStatus = Status.OK_STATUS;
if (TableHelper.isTreeTable(manager)) {
if (null != tableSelectionWrapper) {
resultStatus = pasteTreeRows(manager, pasteStatus, pasteHelper, tableSelectionWrapper);
} else {
- resultStatus = pasteTreeRows(manager, pasteStatus, pasteHelper);
+ resultStatus = pasteTreeRows(manager, pasteStatus, pasteHelper, maxDepth);
}
} else {
if (null != tableSelectionWrapper) {
@@ -331,10 +339,12 @@ public abstract class AbstractPasteImportInNattableManager extends AbstractPaste
* The paste helper.
* @param tableSelectionWrapper
* The current selection.
+ * @param maxDepth
+ * The maximum depth to check.
* @return The status of the paste.
*/
- private IStatus pasteTreeRows(final INattableModelManager manager, final PasteEnablementStatus pasteStatus, final CSVPasteHelper pasteHelper) {
- IStatus status = checkTreeTableConfiguration(manager);
+ private IStatus pasteTreeRows(final INattableModelManager manager, final PasteEnablementStatus pasteStatus, final CSVPasteHelper pasteHelper, final int maxDepth) {
+ IStatus status = checkTreeTableConfiguration(manager, maxDepth);
if (status.isOK()) {
status = pasteTree(manager, pasteStatus, useProgressMonitorDialog, createReader(), null, getDataSize());
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInsertInNattableManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInsertInNattableManager.java
index 33605280376..b8dcbec2a6f 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInsertInNattableManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInsertInNattableManager.java
@@ -464,55 +464,61 @@ public abstract class AbstractPasteImportInsertInNattableManager {
*
* @param manager
* The nattable model manager.
+ * @param maxDepth The maximum depth to check.
* @return The status of the check.
*/
- protected IStatus checkTreeTableConfiguration(final INattableModelManager manager) {
+ protected IStatus checkTreeTableConfiguration(final INattableModelManager manager, final int maxDepth) {
IStatus status = Status.OK_STATUS;
// we check than there is only one categories by hidden depth
final List<Integer> hiddenCategories = StyleUtils.getHiddenDepths(manager);
for (final Integer current : hiddenCategories) {
- final int size = FillingConfigurationUtils.getAllTreeFillingConfigurationForDepth(manager.getTable(), current.intValue()).size();
- if (size > 1) {
- status = new PapyrusNattableStatus(IPapyrusNattableStatus.PASTE_CONFIGURATiON_ERROR, Activator.PLUGIN_ID, PasteSeverityCode.PASTE_ERROR__MORE_THAN_ONE_CATEGORY_FOR_A_HIDDEN_DEPTH,
- NLS.bind(Messages.AbstractPasteImportInsertInNattableManager_YouHaveMoreThan1Category, current.intValue()), null);
+ if(current <= maxDepth){
+ final int size = FillingConfigurationUtils.getAllTreeFillingConfigurationForDepth(manager.getTable(), current.intValue()).size();
+ if (size > 1) {
+ status = new PapyrusNattableStatus(IPapyrusNattableStatus.PASTE_CONFIGURATiON_ERROR, Activator.PLUGIN_ID, PasteSeverityCode.PASTE_ERROR__MORE_THAN_ONE_CATEGORY_FOR_A_HIDDEN_DEPTH,
+ NLS.bind(Messages.AbstractPasteImportInsertInNattableManager_YouHaveMoreThan1Category, current.intValue()), null);
+ }
}
}
if (status.isOK()) {
for (final TreeFillingConfiguration current : FillingConfigurationUtils.getAllTreeFillingConfiguration(manager.getTable())) {
- final PasteEObjectConfiguration conf = current.getPasteConfiguration();
- if (conf == null) {
- // TODO : add detail of the error in message
- status = new PapyrusNattableStatus(IPapyrusNattableStatus.PASTE_CONFIGURATiON_ERROR, Activator.PLUGIN_ID, PasteSeverityCode.PASTE_ERROR__NO_PASTE_CONFIGURATION,
- Messages.AbstractPasteImportInsertInNattableManager_ThereIsNoPasteConfgurationForATreeFillingConfiguration,
- null);
- } else {
-
- final String elementTypeId = conf.getPastedElementId();
- if (elementTypeId == null || elementTypeId.isEmpty()) {
- status = new PapyrusNattableStatus(IPapyrusNattableStatus.PASTE_CONFIGURATiON_ERROR, Activator.PLUGIN_ID, PasteSeverityCode.PASTE_ERROR__NO_ELEMENT_TYPE_IN_PASTE_CONFIGURATION,
- Messages.AbstractPasteImportInsertInNattableManager_ThereIsNoElementIdDefinedInThePasteConfiguration, null);
- } else if (!ElementTypeUtils.getAllExistingElementTypesIds().contains(elementTypeId)) {
- status = new PapyrusNattableStatus(IPapyrusNattableStatus.PASTE_CONFIGURATiON_ERROR, Activator.PLUGIN_ID, PasteSeverityCode.PASTE_ERROR__UNKNOWN_ELEMENT_TYPE,
- String.format(Messages.AbstractPasteImportInsertInNattableManager_TheElementTypeIsUnknown, elementTypeId), null);
- }
-
-
- if (status.isOK()) {
- final EStructuralFeature feature = conf.getPasteElementContainementFeature();
- if (feature == null) {
- final IAxis axis = current.getAxisUsedAsAxisProvider();
- final NatTable natTable = manager.getAdapter(NatTable.class);
- final LabelProviderContextElementWrapper wrapper = new LabelProviderContextElementWrapper();
- wrapper.setObject(axis);
- wrapper.setConfigRegistry(natTable.getConfigRegistry());
- final LabelProviderService serv = natTable.getConfigRegistry().getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
- ILabelProvider p = serv.getLabelProvider(wrapper);
- p = serv.getLabelProvider(Constants.HEADER_LABEL_PROVIDER_CONTEXT);
- final String categoryName = p.getText(axis);
- status = new PapyrusNattableStatus(IPapyrusNattableStatus.PASTE_CONFIGURATiON_ERROR, Activator.PLUGIN_ID, PasteSeverityCode.PASTE_ERROR__NO_CONTAINMENT_FEATURE,
- String.format(Messages.AbstractPasteImportInsertInNattableManager_PasteConfigurationFeatureHasNotBeenSet, categoryName, current.getDepth()), null);
+ if(current.getDepth() <= maxDepth){
+
+ final PasteEObjectConfiguration conf = current.getPasteConfiguration();
+ if (conf == null) {
+ // TODO : add detail of the error in message
+ status = new PapyrusNattableStatus(IPapyrusNattableStatus.PASTE_CONFIGURATiON_ERROR, Activator.PLUGIN_ID, PasteSeverityCode.PASTE_ERROR__NO_PASTE_CONFIGURATION,
+ Messages.AbstractPasteImportInsertInNattableManager_ThereIsNoPasteConfgurationForATreeFillingConfiguration,
+ null);
+ } else {
+
+ final String elementTypeId = conf.getPastedElementId();
+ if (elementTypeId == null || elementTypeId.isEmpty()) {
+ status = new PapyrusNattableStatus(IPapyrusNattableStatus.PASTE_CONFIGURATiON_ERROR, Activator.PLUGIN_ID, PasteSeverityCode.PASTE_ERROR__NO_ELEMENT_TYPE_IN_PASTE_CONFIGURATION,
+ Messages.AbstractPasteImportInsertInNattableManager_ThereIsNoElementIdDefinedInThePasteConfiguration, null);
+ } else if (!ElementTypeUtils.getAllExistingElementTypesIds().contains(elementTypeId)) {
+ status = new PapyrusNattableStatus(IPapyrusNattableStatus.PASTE_CONFIGURATiON_ERROR, Activator.PLUGIN_ID, PasteSeverityCode.PASTE_ERROR__UNKNOWN_ELEMENT_TYPE,
+ String.format(Messages.AbstractPasteImportInsertInNattableManager_TheElementTypeIsUnknown, elementTypeId), null);
+ }
+
+
+ if (status.isOK()) {
+ final EStructuralFeature feature = conf.getPasteElementContainementFeature();
+ if (feature == null) {
+ final IAxis axis = current.getAxisUsedAsAxisProvider();
+ final NatTable natTable = manager.getAdapter(NatTable.class);
+ final LabelProviderContextElementWrapper wrapper = new LabelProviderContextElementWrapper();
+ wrapper.setObject(axis);
+ wrapper.setConfigRegistry(natTable.getConfigRegistry());
+ final LabelProviderService serv = natTable.getConfigRegistry().getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
+ ILabelProvider p = serv.getLabelProvider(wrapper);
+ p = serv.getLabelProvider(Constants.HEADER_LABEL_PROVIDER_CONTEXT);
+ final String categoryName = p.getText(axis);
+ status = new PapyrusNattableStatus(IPapyrusNattableStatus.PASTE_CONFIGURATiON_ERROR, Activator.PLUGIN_ID, PasteSeverityCode.PASTE_ERROR__NO_CONTAINMENT_FEATURE,
+ String.format(Messages.AbstractPasteImportInsertInNattableManager_PasteConfigurationFeatureHasNotBeenSet, categoryName, current.getDepth()), null);
+ }
}
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteHelperUtils.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteHelperUtils.java
index 326f3407d54..24618fd070a 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteHelperUtils.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteHelperUtils.java
@@ -14,36 +14,47 @@
package org.eclipse.papyrus.infra.nattable.utils;
import java.io.Reader;
+import java.util.Map;
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.model.nattable.nattableaxisconfiguration.TreeFillingConfiguration;
import org.eclipse.papyrus.infra.nattable.parsers.CSVParser;
import org.eclipse.papyrus.infra.nattable.parsers.CellIterator;
import org.eclipse.papyrus.infra.nattable.parsers.RowIterator;
/**
- *
+ * The helper for the paste.
*/
public class PasteHelperUtils {
/**
+ * The character of the indentation for the single column.
+ */
+ private static final char INDENTATION_CHARACTER = ' '; // $NON-NLS-1$
+
+ /**
* Constructor.
*/
private PasteHelperUtils() {
// to prevent instanciation
}
-
+
/**
* Manage if this is a paste with overwrite or just a basic paste.
*
- * @param tableManager The nattable model manager.
- * @param pasteHelper The paste helper.
- * @param reader The reader of the file.
+ * @param tableManager
+ * The nattable model manager.
+ * @param pasteHelper
+ * The paste helper.
+ * @param reader
+ * The reader of the file.
* @return
*/
public static final boolean isPasteWithOverwrite(final INattableModelManager tableManager, final CSVPasteHelper pasteHelper, final Reader reader) {
boolean isPasteWithOverwrite = false;
-
+
final CSVParser parser = pasteHelper.createParser(reader);
// Get the pasted text
@@ -75,5 +86,89 @@ public class PasteHelperUtils {
isPasteWithOverwrite = nbColumnRead != nbExpectedColumn;
return isPasteWithOverwrite;
}
+
+ /**
+ * This allows to get the max depth available in the pasted text (to define which paste configuration must be verified).
+ *
+ * @param tableManager
+ * The nattable model manager.
+ * @param pasteHelper
+ * The paste helper.
+ * @param reader
+ * the reader.
+ * @return The max depth available in the pasted text.
+ */
+ public static final int getMaxDepthToPaste(final INattableModelManager tableManager, final CSVPasteHelper pasteHelper, final Reader reader) {
+ int maxDepth = -1;
+
+ if(TableHelper.isTreeTable(tableManager)){
+ final Table table = tableManager.getTable();
+ final boolean isSingleHeaderColumnTreeTable = TableHelper.isSingleColumnTreeTable(table);
+
+ final CSVParser parser = pasteHelper.createParser(reader, isSingleHeaderColumnTreeTable);
+
+ // Get the pasted text
+ final RowIterator rowIter = parser.parse();
+
+ while (rowIter.hasNext()) {
+ final CellIterator cellIter = rowIter.next();
+
+ if (!cellIter.hasNext()) {
+ continue;// to avoid blank line
+ }
+
+ String valueAsString = cellIter.next();
+ int nbReadCell = 1;
+
+ if (isSingleHeaderColumnTreeTable && !valueAsString.isEmpty()) {
+ // If the table is a single header column, parse the value string to manage the correct depth
+ // (manage each separator character as empty cell)
+ while (INDENTATION_CHARACTER == valueAsString.charAt(0)) {
+ nbReadCell++;
+ valueAsString = valueAsString.substring(1);
+ }
+ } else {
+ // test if the value is empty (we are in the tree header)
+ while (cellIter.hasNext() && valueAsString.isEmpty()) {
+ valueAsString = cellIter.next();
+ nbReadCell++;
+ }
+ }
+ final int currentDepth = PasteTreeUtils.getDepth(nbReadCell, FillingConfigurationUtils.getMaxDepthForTree(table), StyleUtils.getHiddenDepths(table), FillingConfigurationUtils.hasTreeFillingConfigurationForDepth(table, 0));
+
+ if (maxDepth < currentDepth) {
+ maxDepth = currentDepth;
+ }
+
+ while (cellIter.hasNext()) {
+ cellIter.next();
+ }
+ }
+ }
+
+ return -1 == maxDepth ? Integer.MAX_VALUE : maxDepth;
+ }
+
+ public static final int getMinDepthOfSelection(final INattableModelManager tableManager, final TableSelectionWrapper tableSelectionWrapper) {
+ int minDepth = 0;
+
+ if (null != tableSelectionWrapper && !tableSelectionWrapper.getFullySelectedRows().isEmpty() && tableSelectionWrapper.getFullySelectedColumns().isEmpty()) {
+ minDepth = Integer.MAX_VALUE;
+
+ final Map<Integer, Object> selectedRows = tableSelectionWrapper.getFullySelectedRows();
+
+ for (int rowIndex : selectedRows.keySet()) {
+ if (selectedRows.get(rowIndex) instanceof TreeFillingConfiguration) {
+ if (minDepth > ((TreeFillingConfiguration) selectedRows.get(rowIndex)).getDepth()) {
+ minDepth = ((TreeFillingConfiguration) selectedRows.get(rowIndex)).getDepth();
+ }
+ } else {
+ System.out.println(selectedRows.get(rowIndex));
+ }
+ }
+ }
+
+ return minDepth;
+ }
}
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.di b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.di
new file mode 100644
index 00000000000..bf9abab340f
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.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/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.notation b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.notation
new file mode 100644
index 00000000000..c6fdcd9c279
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.notation
@@ -0,0 +1,81 @@
+<?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="_Yk1o8GZzEeSDCaDFwPGYVw" name="ClassTreeTable0" currentRowAxisProvider="_Yk1o82ZzEeSDCaDFwPGYVw" currentColumnAxisProvider="_Yk1o8WZzEeSDCaDFwPGYVw">
+ <styles xmi:type="nattablestyle:IntListValueStyle" xmi:id="_PCk74HcDEeSihK466TsMPg" name="hiddenCategoriesByDepth">
+ <intListValue>0</intListValue>
+ <intListValue>1</intListValue>
+ <intListValue>2</intListValue>
+ </styles>
+ <context xmi:type="uml:Model" href="PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.uml#_W0BLkGZzEeSDCaDFwPGYVw"/>
+ <owner xmi:type="uml:Model" href="PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.uml#_W0BLkGZzEeSDCaDFwPGYVw"/>
+ <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="_Yk1o8WZzEeSDCaDFwPGYVw" 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="_Yk1o8mZzEeSDCaDFwPGYVw">
+ <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>
+ <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_c9OSsHrxEeSFP8xW-pegcg">
+ <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/visibility"/>
+ </axis>
+ <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_c9O5wHrxEeSFP8xW-pegcg">
+ <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#//RedefinableElement/isLeaf"/>
+ </axis>
+ <axis xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_c9O5wXrxEeSFP8xW-pegcg">
+ <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#//Parameter/direction"/>
+ </axis>
+ </columnAxisProvidersHistory>
+ <rowAxisProvidersHistory xmi:type="nattableaxisprovider:MasterObjectAxisProvider" xmi:id="_Yk1o82ZzEeSDCaDFwPGYVw" description="This axis provider manages the rows, according to the wanted hierarchy" name="HierarchicalRowaAxisManager" disconnectSlave="true"/>
+ <localRowHeaderAxisConfiguration xmi:type="nattableaxisconfiguration:LocalTableHeaderAxisConfiguration" xmi:id="_53PFMG5fEeSSk_Uaj9vcpQ" indexStyle="NUMERIC" displayIndex="false">
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:TreeFillingConfiguration" xmi:id="_BU9nQXcBEeSihK466TsMPg" pasteConfiguration="_3ExscHyIEeSxVJAGQ_SozA" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_BU9nQncBEeSihK466TsMPg">
+ <element xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//Package/packagedElement"/>
+ </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="_BU9nQ3cBEeSihK466TsMPg" pasteConfiguration="_3ExscXyIEeSxVJAGQ_SozA" depth="1" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_BU9nRHcBEeSihK466TsMPg">
+ <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="_BU9nRXcBEeSihK466TsMPg" pasteConfiguration="_3ExscnyIEeSxVJAGQ_SozA" depth="1" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_BU9nRncBEeSihK466TsMPg">
+ <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="_BU9nR3cBEeSihK466TsMPg" pasteConfiguration="_3Exsc3yIEeSxVJAGQ_SozA" depth="1" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_BU9nSHcBEeSihK466TsMPg">
+ <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="_er6pEHu1EeSOIP1uah0_EA" pasteConfiguration="_3ExsdHyIEeSxVJAGQ_SozA" depth="2" labelProviderContext="org.eclipse.papyrus.infra.nattable.header.treefilling.feature.labelprovider">
+ <axisUsedAsAxisProvider xmi:type="nattableaxis:EStructuralFeatureAxis" xmi:id="_er6pEXu1EeSOIP1uah0_EA">
+ <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>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:PasteEObjectConfiguration" xmi:id="_3ExscHyIEeSxVJAGQ_SozA" detachedMode="false" pastedElementId="org.eclipse.papyrus.uml.Class">
+ <pasteElementContainementFeature xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//Package/packagedElement"/>
+ </ownedAxisConfigurations>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:PasteEObjectConfiguration" xmi:id="_3ExscXyIEeSxVJAGQ_SozA" detachedMode="false" pastedElementId="org.eclipse.papyrus.uml.Property">
+ <pasteElementContainementFeature xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//StructuredClassifier/ownedAttribute"/>
+ </ownedAxisConfigurations>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:PasteEObjectConfiguration" xmi:id="_3ExscnyIEeSxVJAGQ_SozA" detachedMode="false" pastedElementId="org.eclipse.papyrus.uml.Operation">
+ <pasteElementContainementFeature xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class/ownedOperation"/>
+ </ownedAxisConfigurations>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:PasteEObjectConfiguration" xmi:id="_3Exsc3yIEeSxVJAGQ_SozA" detachedMode="false" pastedElementId="org.eclipse.papyrus.uml.Class">
+ <pasteElementContainementFeature xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//Class/nestedClassifier"/>
+ </ownedAxisConfigurations>
+ <ownedAxisConfigurations xmi:type="nattableaxisconfiguration:PasteEObjectConfiguration" xmi:id="_3ExsdHyIEeSxVJAGQ_SozA" detachedMode="false" pastedElementId="org.eclipse.papyrus.uml.Parameter">
+ <pasteElementContainementFeature xmi:type="ecore:EReference" href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioralFeature/ownedParameter"/>
+ </ownedAxisConfigurations>
+ <axisManagerConfigurations xmi:type="nattableaxisconfiguration:AxisManagerConfiguration" xmi:id="_BU9nQHcBEeSihK466TsMPg" localSpecificConfigurations="_BU9nQXcBEeSihK466TsMPg _BU9nQ3cBEeSihK466TsMPg _BU9nRXcBEeSihK466TsMPg _BU9nR3cBEeSihK466TsMPg _er6pEHu1EeSOIP1uah0_EA">
+ <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/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.txt b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.txt
new file mode 100644
index 00000000000..4782e884b6f
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.txt
@@ -0,0 +1,2 @@
+Class0 Class0 public false N/A
+Class1 Class1 private true N/A \ No newline at end of file
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.uml b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.uml
new file mode 100644
index 00000000000..03789110028
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/resources/bugs/bug481310/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.uml
@@ -0,0 +1,2 @@
+<?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="_W0BLkGZzEeSDCaDFwPGYVw" name="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/bugs/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/bugs/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.java
new file mode 100644
index 00000000000..5b12deac6c0
--- /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/bugs/PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.java
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.nattable.clazz.config.tests.bugs;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemAxis;
+import org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.tests.AbstractPasteWithCategoriesMultiColumnsAttachedModeTests;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.NamedElement;
+import org.junit.Assert;
+
+/**
+ * Test pastes with 1 hidden category to the 1st level (H1), 3 hidden categories on the 2nd level (H3) and 1 hidden category to the 3rd level (H1).
+ * If only the first depth elements are added, the paste must be done correctly.
+ */
+public class PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test extends AbstractPasteWithCategoriesMultiColumnsAttachedModeTests {
+
+ /**
+ * The bug 481310 folder.
+ */
+ public static final String BUG_481310_FOLDER = "/resources/bugs/bug481310/"; //$NON-NLS-1$
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.tests.AbstractPasteWithCategoriesTests#getSourcePath()
+ */
+ @Override
+ protected String getSourcePath() {
+ return BUG_481310_FOLDER;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.tests.AbstractPasteWithCategoriesTests#validateReturnedStatus(org.eclipse.core.runtime.IStatus)
+ */
+ @Override
+ protected void validateReturnedStatus(final IStatus status) {
+ Assert.assertTrue(status.isOK());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.tests.AbstractPasteWithCategoriesTests#verifyModel_1_3_1()
+ */
+ @Override
+ protected void verifyModel_1_3_1() throws ServiceException {
+ final EObject context = getTable().getContext();
+ Assert.assertTrue(context instanceof Model);
+ final Model pack = (Model) context;
+ final List<NamedElement> members = pack.getMembers();
+ Assert.assertEquals(2, members.size());
+ for (int i = 0; i < members.size(); i++) {
+ final NamedElement tmp = members.get(i);
+ Assert.assertTrue(tmp instanceof Class);
+ final Class clazz = (Class) tmp;
+ final StringBuilder className = new StringBuilder(CLASS_BASE_NAME);
+ className.append(i);
+ Assert.assertEquals(className.toString(), clazz.getName());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.nattable.clazz.config.tests.paste.tests.AbstractPasteWithCategoriesTests#checkChildrenClasses(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemAxis)
+ */
+ @Override
+ protected void checkRootClasses(final ITreeItemAxis root, final EObject parent) throws Exception {
+ // Do nothing : no child in classes
+ }
+
+}
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/paste/tests/AbstractPasteWithCategoriesTests.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/paste/tests/AbstractPasteWithCategoriesTests.java
index 8c40e5a636b..4714924b664 100644
--- a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/paste/tests/AbstractPasteWithCategoriesTests.java
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/paste/tests/AbstractPasteWithCategoriesTests.java
@@ -420,7 +420,12 @@ public abstract class AbstractPasteWithCategoriesTests extends AbstractOpenTable
}
}
- protected final void validateReturnedStatus(final IStatus status) {
+ /**
+ * This allows to check the returned status of the paste action.
+ *
+ * @param status The status got.
+ */
+ protected void validateReturnedStatus(final IStatus status) {
String className = getClass().getSimpleName();
className = className.replaceFirst("PasteWithCategories_", ""); //$NON-NLS-1$ //$NON-NLS-2$
final String[] result = className.split("_"); //$NON-NLS-1$
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config.tests/src/org/eclipse/papyrus/uml/nattable/clazz/config/tests/tests/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 1e5dd077c11..5025b0a13e9 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
@@ -22,6 +22,7 @@ import org.eclipse.papyrus.uml.nattable.clazz.config.tests.bugs.EditInvalidPaste
import org.eclipse.papyrus.uml.nattable.clazz.config.tests.bugs.MoveElementsTreeTableTest;
import org.eclipse.papyrus.uml.nattable.clazz.config.tests.bugs.NoDepth0TreeFillingConfigurationTest;
import org.eclipse.papyrus.uml.nattable.clazz.config.tests.bugs.OpenAndDeleteTest;
+import org.eclipse.papyrus.uml.nattable.clazz.config.tests.bugs.PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test;
import org.eclipse.papyrus.uml.nattable.clazz.config.tests.bugs.RequirementsNestedClassifier;
import org.eclipse.papyrus.uml.nattable.clazz.config.tests.creation.outside.CreateElementDepth0_H1_V3_V1_Test;
import org.eclipse.papyrus.uml.nattable.clazz.config.tests.creation.outside.CreateElementDepth0_V1_V3_V1_Test;
@@ -186,7 +187,7 @@ import org.junit.runners.Suite.SuiteClasses;
SortAxisClassTreeTableTest.class,
EditAxisClassTreeTableTest.class,
-
+
// Bug 481020 : Delete a requirement containing a nested requirement
DeleteRequirementsWithNestedClassifier.class,
@@ -281,6 +282,9 @@ import org.junit.runners.Suite.SuiteClasses;
PasteWithCategories_V1_H1_V1_MultiColumns_AttachedMode_Test.class,
PasteWithCategories_V1_V3_H1_MultiColumns_AttachedMode_Test.class,
PasteWithCategories_V1_V3_V1_MultiColumns_AttachedMode_Test.class,
+
+ // Bug 481310 : Paste one depth when others can't get pasted elements
+ PasteWithCategories_H1_H3_H1_MultiColumns_AttachedMode_Bug481310Test.class,
// Detached Mode
// Paste tests for single column
@@ -300,7 +304,7 @@ import org.junit.runners.Suite.SuiteClasses;
PasteWithCategories_V1_H1_V1_SingleColumn_DetachedMode_Test.class,
PasteWithCategories_V1_V3_H1_SingleColumn_DetachedMode_Test.class,
PasteWithCategories_V1_V3_V1_SingleColumn_DetachedMode_Test.class,
-
+
// Paste tests for multi columns
PasteWithCategories_Empty_H1_H1_MultiColumns_DetachedMode_Test.class,
PasteWithCategories_Empty_H1_V1_MultiColumns_DetachedMode_Test.class,
@@ -321,7 +325,7 @@ import org.junit.runners.Suite.SuiteClasses;
// Tests of the paste with overwrite
PasteEmptyClipboard_H1_H1_H1_MultiColumns_Test.class,
-
+
PasteCellsOverwriteAll_H1_H1_H1_MultiColumns_Test.class,
PasteCellsOverwriteAll_V1_V3_V1_MultiColumns_Test.class,
PasteCellsOverwriteByOneLine_H1_H1_H1_MultiColumns_Test.class,
@@ -354,7 +358,7 @@ import org.junit.runners.Suite.SuiteClasses;
// Tests of insert
InsertEmptyClipboard_H1_H1_H1_MultiColumns_Test.class,
-
+
InsertRowsReplaceAll_H1_H1_H1_MultiColumns_Test.class,
InsertRowsReplaceAll_V1_V3_V1_MultiColumns_Test.class,
InsertRowsAddAll_H1_H1_H1_MultiColumns_Test.class,
@@ -393,8 +397,8 @@ import org.junit.runners.Suite.SuiteClasses;
ImportEmptyAddAll_V1_V3_V1_MultiColumns_Test.class,
ImportEmptySkipAll_H1_H1_H1_MultiColumns_Test.class,
ImportEmptySkipAll_V1_V3_V1_MultiColumns_Test.class,
-
- //validation markers tests
+
+ // validation markers tests
ValidationMarkerInTableHeaderTest.class,
})
public class AllTests {

Back to the top