diff options
author | Vincent Lorenzo | 2019-03-20 09:52:03 +0000 |
---|---|---|
committer | Vincent Lorenzo | 2019-03-20 10:14:37 +0000 |
commit | 0e60491857f224c889785e340872dedb729716fc (patch) | |
tree | 3a61edd682227aaf3665f8b88e169339cbf60ecb /plugins | |
parent | 9be1d47984e9aa9da4d7e0cf86a48c43eaeda9a1 (diff) | |
download | org.eclipse.papyrus-0e60491857f224c889785e340872dedb729716fc.tar.gz org.eclipse.papyrus-0e60491857f224c889785e340872dedb729716fc.tar.xz org.eclipse.papyrus-0e60491857f224c889785e340872dedb729716fc.zip |
Bug 545575: [Table] Paste String resolution doesn't work for stereotype's properties typed with an UML metaclass
- fix the bug about the stereotype resolution problem
- change cell painter for UML reference and UML stereotype single reference to get he underline error in case of paste error
Change-Id: I379ca98592118c2311c046834d67820a5375ed00
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'plugins')
9 files changed, 54 insertions, 22 deletions
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/META-INF/MANIFEST.MF b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/META-INF/MANIFEST.MF index a8fa2e70fa0..e669489c1e8 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/META-INF/MANIFEST.MF +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/META-INF/MANIFEST.MF @@ -37,7 +37,7 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="[3.0.0,4.0.0)";vi org.eclipse.papyrus.infra.tools;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.infra.core.architecture;bundle-version="[2.0.0,3.0.0)" Bundle-Vendor: %providerName -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.0.100.qualifier Eclipse-BuddyPolicy: dependent Bundle-ManifestVersion: 2 Bundle-Activator: org.eclipse.papyrus.infra.ui.Activator diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/pom.xml b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/pom.xml index 1315f932d30..4a1d577baa6 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/pom.xml +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/pom.xml @@ -1,5 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<project> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <artifactId>org.eclipse.papyrus.infra-ui</artifactId> @@ -7,7 +9,7 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.infra.ui</artifactId> - <version>2.0.0-SNAPSHOT</version> + <version>2.0.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <description>Plugin dedicated to manage generic menus and actions, linked to EMF but not to UML nor GMF technologies.</description> </project>
\ No newline at end of file diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/converter/AbstractStringValueConverter.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/converter/AbstractStringValueConverter.java index a2fab15520b..4d3c7312780 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/converter/AbstractStringValueConverter.java +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/converter/AbstractStringValueConverter.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2013 CEA LIST. + * Copyright (c) 2013, 2019 CEA LIST. * * * All rights reserved. This program and the accompanying materials @@ -11,7 +11,7 @@ * * Contributors: * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation - * + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 545575 (add Cloneable implementation) *****************************************************************************/ package org.eclipse.papyrus.infra.ui.converter; @@ -28,7 +28,7 @@ import org.eclipse.papyrus.infra.ui.messages.Messages; * @since 1.2 * */ -public abstract class AbstractStringValueConverter implements IStringValueConverter { +public abstract class AbstractStringValueConverter implements IStringValueConverter, Cloneable { protected static final String THE_STRING_X_IS_NOT_VALID_TO_CREATE_Y = Messages.AbstractStringValueConverter_TheStringXIsNotValidToCreateY; @@ -63,7 +63,7 @@ public abstract class AbstractStringValueConverter implements IStringValueConver } /** - * + * * @return * the converted value, you should call deduceValueFromString before to call this method */ @@ -85,5 +85,17 @@ public abstract class AbstractStringValueConverter implements IStringValueConver */ protected abstract ConvertedValueContainer<?> doDeduceValueFromString(final Object type, final String valueAsString); - + /** + * + * Added to fix easily the Bug 545575: [Table] Paste String resolution doesn't work for stereotype's properties typed with an UML metaclass + * + * @see java.lang.Object#clone() + * + * @return + * @throws CloneNotSupportedException + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } } diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/converter/EMFStringValueConverter.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/converter/EMFStringValueConverter.java index 78c7cd7c3f2..e8512597290 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/converter/EMFStringValueConverter.java +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/converter/EMFStringValueConverter.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2013 CEA LIST. + * Copyright (c) 2013, 2019 CEA LIST. * * * All rights reserved. This program and the accompanying materials @@ -11,12 +11,13 @@ * * Contributors: * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation - * + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 545575 *****************************************************************************/ package org.eclipse.papyrus.infra.ui.converter; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -119,7 +120,6 @@ public class EMFStringValueConverter extends AbstractStringValueConverter { */ protected ConvertedValueContainer<?> deduceValueFromString(final Object feature, final EClassifier featureType, final String valueAsString) { ConvertedValueContainer<?> realValue = null; - // if(feature instanceof EStructuralFeature) { final int upperbound = getFeatureUpperBound(feature); boolean isMany = (upperbound > 1 || upperbound == -1); if (featureType instanceof EDataType) { @@ -168,7 +168,7 @@ public class EMFStringValueConverter extends AbstractStringValueConverter { if (valueAsString == null || valueAsString.equals("")) { return new ConvertedValueContainer<EObject>(null, Status.OK_STATUS); } - final IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(THE_STRING_VALUE_X_CANT_BE_RESOLVED, valueAsString)); + final IStatus status = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(NO_X_REPRESENTED_BY_Y_HAVE_BEEN_FOUND, featureType.getName(), valueAsString), Collections.singleton(valueAsString)); return new ConvertedValueContainer<EObject>(null, status); } diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/META-INF/MANIFEST.MF index f67e788cae2..896ecca5f47 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/META-INF/MANIFEST.MF +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/META-INF/MANIFEST.MF @@ -20,7 +20,7 @@ Require-Bundle: org.eclipse.papyrus.uml.tools;bundle-version="[4.0.0,5.0.0)";vis org.eclipse.papyrus.infra.properties.ui;bundle-version="[3.0.0,4.0.0)" Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy -Bundle-Version: 5.2.100.qualifier +Bundle-Version: 5.2.200.qualifier Bundle-Name: %Bundle-Name Bundle-Localization: plugin Bundle-Activator: org.eclipse.papyrus.uml.nattable.Activator diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/pom.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/pom.xml index 7c3f2fd7938..5f56d6e11cf 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/pom.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/pom.xml @@ -9,6 +9,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.nattable</artifactId> - <version>5.2.100-SNAPSHOT</version> + <version>5.2.200-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/SingleUMLReferenceCellEditorConfiguration.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/SingleUMLReferenceCellEditorConfiguration.java index 09cc8f8ab2b..0b430520522 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/SingleUMLReferenceCellEditorConfiguration.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/SingleUMLReferenceCellEditorConfiguration.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2015, 2017 CEA LIST and others. + * Copyright (c) 2015, 2017, 2019 CEA LIST and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +11,7 @@ * Contributors: * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation * Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 517374 + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 545575 *****************************************************************************/ package org.eclipse.papyrus.uml.nattable.config; @@ -20,7 +21,6 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes; import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes; -import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter; import org.eclipse.nebula.widgets.nattable.style.DisplayMode; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration; @@ -28,6 +28,7 @@ import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; import org.eclipse.papyrus.infra.nattable.model.nattable.Table; import org.eclipse.papyrus.infra.nattable.utils.AxisUtils; import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes; +import org.eclipse.papyrus.uml.nattable.config.utils.CellEditorConfigurationUtils; import org.eclipse.papyrus.uml.nattable.converter.SingleUMLReferenceDisplayConverter; import org.eclipse.papyrus.uml.nattable.editor.SingleReferenceValueCellEditor; import org.eclipse.uml2.uml.UMLPackage; @@ -89,7 +90,7 @@ public class SingleUMLReferenceCellEditorConfiguration implements ICellAxisConfi */ @Override public void configureCellEditor(final IConfigRegistry configRegistry, final Object axis, final String configLabel) { - configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new TextPainter(), DisplayMode.NORMAL, configLabel); + CellEditorConfigurationUtils.configureCellPainter(configRegistry, axis, configLabel); final INattableModelManager modelManager = configRegistry.getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID); configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new SingleReferenceValueCellEditor(axis, modelManager.getTableAxisElementProvider()), DisplayMode.EDIT, configLabel); diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleUMLReferenceCellEditorConfiguration.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleUMLReferenceCellEditorConfiguration.java index 38dfba8220e..42e06791003 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleUMLReferenceCellEditorConfiguration.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleUMLReferenceCellEditorConfiguration.java @@ -11,6 +11,7 @@ * Contributors: * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Bug 545401 + * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Bug 545575 *****************************************************************************/ package org.eclipse.papyrus.uml.nattable.config; @@ -18,12 +19,12 @@ package org.eclipse.papyrus.uml.nattable.config; import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes; import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes; -import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter; import org.eclipse.nebula.widgets.nattable.style.DisplayMode; import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; import org.eclipse.papyrus.infra.nattable.model.nattable.Table; import org.eclipse.papyrus.infra.nattable.utils.AxisUtils; import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes; +import org.eclipse.papyrus.uml.nattable.config.utils.CellEditorConfigurationUtils; import org.eclipse.papyrus.uml.nattable.converter.SingleUMLReferenceDisplayConverter; import org.eclipse.papyrus.uml.nattable.editor.SingleReferenceValueCellEditor; import org.eclipse.papyrus.uml.nattable.utils.UMLTableUtils; @@ -81,7 +82,7 @@ public class UMLStereotypeSingleUMLReferenceCellEditorConfiguration extends Sing */ @Override public void configureCellEditor(final IConfigRegistry configRegistry, final Object axis, final String configLabel) { - configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new TextPainter(), DisplayMode.NORMAL, configLabel); + CellEditorConfigurationUtils.configureCellPainter(configRegistry, axis, configLabel); final Object axisElement = AxisUtils.getRepresentedElement(axis); final INattableModelManager modelManager = configRegistry.getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID); diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/cell/StereotypePropertyCellManager.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/cell/StereotypePropertyCellManager.java index f82f30fcb26..117aa7148b7 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/cell/StereotypePropertyCellManager.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/cell/StereotypePropertyCellManager.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2012, 2017 CEA LIST and others. + * Copyright (c) 2012, 2017, 2019 CEA LIST and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -12,6 +12,7 @@ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation * Christian W. Damus (CEA) - bug 402525 * Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 515806 + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 545575 *****************************************************************************/ package org.eclipse.papyrus.uml.nattable.manager.cell; @@ -21,6 +22,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.emf.common.command.Command; @@ -34,6 +36,7 @@ import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; import org.eclipse.osgi.util.NLS; import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper; import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.nattable.manager.cell.CellManagerFactory; import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; import org.eclipse.papyrus.infra.nattable.paste.PastePostActionRegistry; import org.eclipse.papyrus.infra.nattable.utils.AxisUtils; @@ -281,6 +284,16 @@ public class StereotypePropertyCellManager extends UMLFeatureCellManager { // Don't apply the stereotype if there's no value to set. return null; } + + //Clone the converter, because it will be disposed too early for this usecase + Object tmpConverted = null; + try { + tmpConverted = valueSolver.clone(); + } catch (CloneNotSupportedException e) { + Activator.log.error(e); + } + Assert.isNotNull(tmpConverted, "The value converter is null");//$NON-NLS-1$ + final AbstractStringValueConverter clonedConverter = (AbstractStringValueConverter) tmpConverted; // Must first apply the stereotype return new RecordingCommand(domain, "Set Value") { //$NON-NLS-1$ @@ -288,8 +301,9 @@ public class StereotypePropertyCellManager extends UMLFeatureCellManager { protected void doExecute() { // This may apply the required stereotype if needed applyRequiredStereotype(domain, el, id); - // Now recursively execute the set-string-value command - Command command = getSetStringValueCommand(domain, columnElement, rowElement, newValue, valueSolver, tableManager); + + // we need to call the CellManagerFactory to get the StringResolutionProblemWrapperCellManager when required + Command command = CellManagerFactory.INSTANCE.getSetStringValueCommand(domain, columnElement, rowElement, newValue, clonedConverter, tableManager); if (command != null) { if (!command.canExecute()) { throw new OperationCanceledException(); @@ -299,6 +313,8 @@ public class StereotypePropertyCellManager extends UMLFeatureCellManager { } else { // A null command is not an error, it just means there's nothing to set because the value is already correct. } + //we dispose the cloned converter + clonedConverter.dispose(); } }; } |