Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2015-07-16 14:22:43 +0000
committervincent lorenzo2015-09-03 09:03:41 +0000
commit5bde04081e1c733634a2626e52cd0d0bd57c26d8 (patch)
tree8bb5cfa5261356ff9221d82b4771dac11b5f3b14
parent98b3304e2e21260fae09ea05509eed886c6afbaf (diff)
downloadorg.eclipse.papyrus-5bde04081e1c733634a2626e52cd0d0bd57c26d8.tar.gz
org.eclipse.papyrus-5bde04081e1c733634a2626e52cd0d0bd57c26d8.tar.xz
org.eclipse.papyrus-5bde04081e1c733634a2626e52cd0d0bd57c26d8.zip
Bug 470809: [Tree Table] Paste doesn't work when categories have be
changed https://bugs.eclipse.org/bugs/show_bug.cgi?id=470809 - Manage the PasteEObjectConfiguration from table and not only by the TreeFillingConfiguration Change-Id: I0a04f0b5de1858f82e2eb827b363f46e529f717e 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/provider/PasteEObjectTreeAxisInNattableCommandProvider.java18
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteSeverityCode.java7
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/ConfigureTableCategoriesWizard.java17
3 files changed, 36 insertions, 6 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java
index c9b5cf626b8..ec237a4bff7 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java
@@ -43,7 +43,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EFactory;
@@ -911,8 +910,19 @@ public class PasteEObjectTreeAxisInNattableCommandProvider {
nbReadCell++;
}
- int depth = getDepth(nbReadCell);
- boolean isCategory = isCategory(nbReadCell);
+ int depth = -1;
+ boolean isCategory = false;
+ try {
+ depth = getDepth(nbReadCell);
+ isCategory = isCategory(nbReadCell);
+ } catch (UnsupportedOperationException ex) {
+ String message = NLS.bind("No defined depth for line {0}", nbReadCell); //$NON-NLS-1$
+ // The following lines allows to cancel all the paste if a problem of depth appears
+ // If a partial paste is authorized, remove this lines
+ Activator.log.error(message, ex);
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, PasteSeverityCode.PASTE_ERROR__MORE_LINES_THAN_DEPTH, message, null);
+ return new CommandResult(status);
+ }
if (isCategory) {
confMap.put(Integer.valueOf(depth), (PasteEObjectConfiguration) getPasteConfigurationsFor(depth, valueAsString));
@@ -947,7 +957,7 @@ public class PasteEObjectTreeAxisInNattableCommandProvider {
final IElementEditService creationContextCommandProvider = ElementEditServiceUtils.getCommandProvider(context);
final ICommand commandCreation = creationContextCommandProvider.getEditCommand(createRequest1);
- if (commandCreation.canExecute()) {
+ if (null != commandCreation && commandCreation.canExecute()) {
// 1. we create the element
commandCreation.execute(monitor, info);
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteSeverityCode.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteSeverityCode.java
index 51678925abe..b1591cca7bf 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteSeverityCode.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteSeverityCode.java
@@ -58,10 +58,15 @@ public class PasteSeverityCode {
* the severity code used when we try to paste columns in a tree table
*/
public static final int PASTE_ERROR__CANT_PASTE_COLUMNS_IN_TREE_TABLE = PASTE_ERROR__UNKNOWN_ELEMENT_TYPE + 1;
+
+ /**
+ * the severity code used when more lines is pasted than the number of depth available
+ */
+ public static final int PASTE_ERROR__MORE_LINES_THAN_DEPTH = PASTE_ERROR__CANT_PASTE_COLUMNS_IN_TREE_TABLE + 1;
/**
* the severity code used when there are too many cells on a rows
*/
- public static final int PASTE_WARNING__TOO_MANY_CELLS_ON_ROWS = PASTE_ERROR__CANT_PASTE_COLUMNS_IN_TREE_TABLE + 1;
+ public static final int PASTE_WARNING__TOO_MANY_CELLS_ON_ROWS = PASTE_ERROR__MORE_LINES_THAN_DEPTH + 1;
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/ConfigureTableCategoriesWizard.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/ConfigureTableCategoriesWizard.java
index a95f4ab7c42..ab44588698c 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/ConfigureTableCategoriesWizard.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/ConfigureTableCategoriesWizard.java
@@ -24,6 +24,7 @@ import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.jface.viewers.ILabelProvider;
@@ -45,6 +46,7 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfigurati
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.LocalTableHeaderAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationFactory;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.PasteEObjectConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TableHeaderAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TreeFillingConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ILabelProviderConfiguration;
@@ -420,6 +422,8 @@ public class ConfigureTableCategoriesWizard extends AbstractTableWizard {
ITreeItemAxis root = (ITreeItemAxis) tmp;
AxisManagerRepresentation representation = root.getManager();
List<TreeFillingConfiguration> createdFillingConfiguration = new ArrayList<TreeFillingConfiguration>();
+ List<PasteEObjectConfiguration> createdPasteEObjectConfiguration = new ArrayList<PasteEObjectConfiguration>();
+
for (ITreeItemAxis depthItem : root.getChildren()) {
Assert.isTrue(CategoriesWizardUtils.isDepthItem(depthItem));
int wantedDepth = Integer.valueOf((String) depthItem.getElement());
@@ -433,7 +437,15 @@ public class ConfigureTableCategoriesWizard extends AbstractTableWizard {
// 1. try to find existing conf
TreeFillingConfiguration newConf = findExistingTreeFillingConfiguration(table, representation, wantedDepth, categoryItem.getElement());
- if (newConf == null || EMFHelper.isReadOnly(newConf)) {
+ if (null == newConf || EMFHelper.isReadOnly(newConf)) {
+ PasteEObjectConfiguration copiedEObjectConfiguration = null;
+ if(null != newConf){
+ PasteEObjectConfiguration existingPasteConfiguration = newConf.getPasteConfiguration();
+ copiedEObjectConfiguration = EcoreUtil.copy(existingPasteConfiguration);
+ if(null != copiedEObjectConfiguration){
+ createdPasteEObjectConfiguration.add(copiedEObjectConfiguration);
+ }
+ }
// we create new TreeFillingConfiguration
newConf = NattableaxisconfigurationFactory.eINSTANCE.createTreeFillingConfiguration();
newConf.setDepth(wantedDepth);
@@ -441,6 +453,8 @@ public class ConfigureTableCategoriesWizard extends AbstractTableWizard {
newConf.setAxisUsedAsAxisProvider(axis);
newConf.setLabelProvider(getLabelConfigurationForTreeFillingConfiguration(table));
newConf.setLabelProviderContext(getLabelProviderContextForTreeFillingConfiguration(table));
+ // Manage the paste configuration
+ newConf.setPasteConfiguration(copiedEObjectConfiguration);
} else {
// update the alias if required
@@ -479,6 +493,7 @@ public class ConfigureTableCategoriesWizard extends AbstractTableWizard {
}
local.getOwnedAxisConfigurations().clear();
local.getOwnedAxisConfigurations().addAll(createdFillingConfiguration);
+ local.getOwnedAxisConfigurations().addAll(createdPasteEObjectConfiguration);
wantedAxisManagerConfiguration.getLocalSpecificConfigurations().clear();
wantedAxisManagerConfiguration.getLocalSpecificConfigurations().addAll(createdFillingConfiguration);
}

Back to the top