Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager')
-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
3 files changed, 70 insertions, 49 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);
+ }
}
}
}

Back to the top