diff options
author | Vincent Lorenzo | 2018-03-20 10:24:46 +0000 |
---|---|---|
committer | vincent lorenzo | 2018-03-23 14:04:06 +0000 |
commit | 20b61b1805a8fcabb95ca1ce470e8e281e2f867a (patch) | |
tree | 2b84250f07ef0f434abedd47cdc84183ef20b87f /plugins/uml | |
parent | b36be92ed00417eeb48f5ed3c77a6d89f1fd2295 (diff) | |
download | org.eclipse.papyrus-20b61b1805a8fcabb95ca1ce470e8e281e2f867a.tar.gz org.eclipse.papyrus-20b61b1805a8fcabb95ca1ce470e8e281e2f867a.tar.xz org.eclipse.papyrus-20b61b1805a8fcabb95ca1ce470e8e281e2f867a.zip |
Bug 532639: [Table][Matrix] System shall enable to specify the creation location of relationships created using a matrix editor.
Change-Id: I4ffde565f069e65c85c838bd14aebb4b809c61b7
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'plugins/uml')
35 files changed, 735 insertions, 72 deletions
diff --git a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/META-INF/MANIFEST.MF b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/META-INF/MANIFEST.MF index 47511f3787e..f938282829a 100755 --- a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/META-INF/MANIFEST.MF +++ b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/META-INF/MANIFEST.MF @@ -2,16 +2,16 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.papyrus.uml.architecture;singleton:=true -Bundle-Version: 1.1.0.qualifier +Bundle-Version: 1.1.100.qualifier Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.eclipse.papyrus.uml.service.types;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.infra.nattable.common;bundle-version="[4.0.0,5.0.0)", + org.eclipse.papyrus.infra.nattable.common;bundle-version="[5.0.0,6.0.0)", org.eclipse.papyrus.infra.constraints;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.emf;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.infra.nattable;bundle-version="[5.0.0,6.0.0)", - org.eclipse.papyrus.infra.nattable.views.config;bundle-version="[4.0.0,5.0.0)", + org.eclipse.papyrus.infra.nattable;bundle-version="[6.0.0,7.0.0)", + org.eclipse.papyrus.infra.nattable.views.config;bundle-version="[5.0.0,6.0.0)", org.eclipse.papyrus.infra.services.controlmode;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.services.edit;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.infra.types.rulebased;bundle-version="[3.0.0,4.0.0)", diff --git a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/pom.xml b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/pom.xml index 3c69d2d7496..013f9c9d041 100644 --- a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/pom.xml +++ b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/pom.xml @@ -7,6 +7,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.architecture</artifactId> - <version>1.1.0-SNAPSHOT</version> + <version>1.1.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/META-INF/MANIFEST.MF index 8106472f0a5..57a2715cd7f 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/META-INF/MANIFEST.MF +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/META-INF/MANIFEST.MF @@ -1,12 +1,12 @@ Manifest-Version: 1.0 -Require-Bundle: org.eclipse.papyrus.uml.nattable;bundle-version="[4.0.0,5.0.0)";visibility:=reexport, +Require-Bundle: org.eclipse.papyrus.uml.nattable;bundle-version="[5.0.0,6.0.0)";visibility:=reexport, org.eclipse.nebula.widgets.nattable.extension.glazedlists;bundle-version="[1.5.0,2.0.0)", org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[2.0.0,3.0.0)" Export-Package: org.eclipse.papyrus.uml.nattable.clazz.config, org.eclipse.papyrus.uml.nattable.clazz.config.manager.axis Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy -Bundle-Version: 4.0.0.qualifier +Bundle-Version: 5.0.0.qualifier Bundle-Localization: plugin Bundle-Name: %Bundle-Name Bundle-Activator: org.eclipse.papyrus.uml.nattable.clazz.config.Activator diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/pom.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/pom.xml index bbfedde2e69..2d4d1e0ea3c 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/pom.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/pom.xml @@ -8,6 +8,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.nattable.clazz.config</artifactId> - <version>4.0.0-SNAPSHOT</version> + <version>5.0.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.config/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.config/META-INF/MANIFEST.MF index 9376cd00d8f..db663b4a9c9 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.config/META-INF/MANIFEST.MF +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.config/META-INF/MANIFEST.MF @@ -1,10 +1,10 @@ Manifest-Version: 1.0 -Require-Bundle: org.eclipse.papyrus.infra.nattable;bundle-version="[5.0.0,6.0.0)", +Require-Bundle: org.eclipse.papyrus.infra.nattable;bundle-version="[6.0.0,7.0.0)", org.eclipse.uml2.uml;bundle-version="[5.3.0,6.0.0)" Export-Package: org.eclipse.papyrus.uml.nattable.generic.config Bundle-Vendor: Eclipse Modeling Project Bundle-ActivationPolicy: lazy -Bundle-Version: 1.2.0.qualifier +Bundle-Version: 1.2.100.qualifier Bundle-Name: UML Generic Table Config Bundle-Activator: org.eclipse.papyrus.uml.nattable.generic.config.Activator Bundle-ManifestVersion: 2 diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.config/pom.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.config/pom.xml index 96029e3192a..6a72146bf56 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.config/pom.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic.config/pom.xml @@ -8,6 +8,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.nattable.generic.config</artifactId> - <version>1.2.0-SNAPSHOT</version> + <version>1.2.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic/META-INF/MANIFEST.MF index a5fbf68527b..d1b644c59d1 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic/META-INF/MANIFEST.MF +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic/META-INF/MANIFEST.MF @@ -1,9 +1,9 @@ Manifest-Version: 1.0 -Require-Bundle: org.eclipse.papyrus.infra.nattable.common;bundle-version="[4.0.0,5.0.0)", +Require-Bundle: org.eclipse.papyrus.infra.nattable.common;bundle-version="[5.0.0,6.0.0)", org.eclipse.papyrus.uml.nattable.generic.config;bundle-version="[1.2.0,2.0.0)" Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy -Bundle-Version: 1.2.0.qualifier +Bundle-Version: 1.2.100.qualifier Bundle-Name: %Bundle-Name Bundle-Activator: org.eclipse.papyrus.uml.nattable.generic.Activator Bundle-ManifestVersion: 2 diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic/pom.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic/pom.xml index 191e5c283e8..32d878d50bd 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic/pom.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.generic/pom.xml @@ -8,6 +8,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.nattable.generic</artifactId> - <version>1.2.0-SNAPSHOT</version> + <version>1.2.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/META-INF/MANIFEST.MF index d320b3b5437..4930e7642fc 100755 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/META-INF/MANIFEST.MF +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/META-INF/MANIFEST.MF @@ -7,11 +7,11 @@ Bundle-Vendor: Eclipse Modeling Project Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)", org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)", - org.eclipse.papyrus.infra.nattable;bundle-version="[5.0.0,6.0.0)", + org.eclipse.papyrus.infra.nattable;bundle-version="[6.0.0,7.0.0)", org.eclipse.uml2.uml;bundle-version="[5.3.0,6.0.0)", - org.eclipse.papyrus.infra.nattable.model;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.nattable.model;bundle-version="[4.0.0,5.0.0)", org.eclipse.papyrus.infra.emf.expressions;bundle-version="1.0.0", - org.eclipse.papyrus.infra.emf.nattable;bundle-version="[4.0.0,5.0.0)", + org.eclipse.papyrus.infra.emf.nattable;bundle-version="[5.0.0,6.0.0)", org.eclipse.papyrus.infra.services.edit;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)", org.eclipse.papyrus.infra.types.core;bundle-version="[3.0.0,4.0.0)", diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/cell/managers/AbstractUMLGenericMatrixRelationshipCellManager.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/cell/managers/AbstractUMLGenericMatrixRelationshipCellManager.java index e6f4ee33c3f..79d3d15ecaa 100755 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/cell/managers/AbstractUMLGenericMatrixRelationshipCellManager.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/cell/managers/AbstractUMLGenericMatrixRelationshipCellManager.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2017 CEA LIST and others. + * Copyright (c) 2017, 2018 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 @@ -9,6 +9,7 @@ * Contributors: * Vincent Lorenzo (CEA LIST) - vincent.lorenzo@cea.fr - Initial API and implementation * Thanh Liem PHAN (ALL4TEC) - thanhliem.phan@all4tec.net - Bug 515806 + * Vincent Lorenzo (CEA LIST) - vincent.lorenzo@cea.fr - Bug 532639 *****************************************************************************/ package org.eclipse.papyrus.uml.nattable.matrix.cell.managers; @@ -19,6 +20,12 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.emf.common.command.Command; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; @@ -26,16 +33,24 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.EStructuralFeature.Setting; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.infra.core.services.ServiceException; import org.eclipse.papyrus.infra.emf.expressions.booleanexpressions.BooleanExpressionsFactory; import org.eclipse.papyrus.infra.emf.expressions.booleanexpressions.IBooleanEObjectExpression; import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject; +import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceSet; import org.eclipse.papyrus.infra.nattable.manager.cell.AbstractCellManager; import org.eclipse.papyrus.infra.nattable.manager.cell.IGenericMatrixRelationshipCellManager; import org.eclipse.papyrus.infra.nattable.manager.table.IMatrixTableWidgetManager; @@ -44,15 +59,23 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.Table; import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecelleditor.GenericRelationshipMatrixCellEditorConfiguration; import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecelleditor.ICellEditorConfiguration; import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecelleditor.MatrixRelationShipDirection; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattablewrapper.IWrapper; import org.eclipse.papyrus.infra.nattable.utils.AxisUtils; import org.eclipse.papyrus.infra.nattable.utils.CellHelper; import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils; import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; +import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService; import org.eclipse.papyrus.infra.types.ElementTypeConfiguration; import org.eclipse.papyrus.infra.types.MetamodelTypeConfiguration; import org.eclipse.papyrus.infra.types.SpecializationTypeConfiguration; +import org.eclipse.papyrus.infra.ui.emf.dialog.NestedEditingDialogContext; +import org.eclipse.papyrus.uml.nattable.matrix.Activator; +import org.eclipse.papyrus.uml.nattable.matrix.messages.Messages; +import org.eclipse.papyrus.uml.nattable.matrix.validator.RelationshipOwnerValidator; import org.eclipse.papyrus.uml.tools.helper.UMLRelationshipHelper; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; import org.eclipse.uml2.uml.Element; /** @@ -147,7 +170,8 @@ public abstract class AbstractUMLGenericMatrixRelationshipCellManager extends Ab // we don't check if the source and target element have the required applied stereotype and other stuff, we delegate to the Service type if (isEditable) { - Command cmd = getSetValueCommand(TableEditingDomainUtils.getTableContextEditingDomain(manager.getTable()), columnElement, rowElement, Boolean.TRUE, manager); + // we check if the set value command is executable with the owner calculated by Papyrus + Command cmd = getSetValueCommand(TableEditingDomainUtils.getTableContextEditingDomain(manager.getTable()), columnElement, rowElement, Boolean.TRUE, manager, true); isEditable = null == cmd ? false : cmd.canExecute(); } return isEditable; @@ -162,7 +186,7 @@ public abstract class AbstractUMLGenericMatrixRelationshipCellManager extends Ab * @param manager * the table manager * @return - * <code>true</code> if the cell must be ediatable according to the arguments; + * <code>true</code> if the cell must be editable according to the arguments; */ protected final boolean isCellEditableIgnoringCurrentValue(final Object columnElement, final Object rowElement, final INattableModelManager manager) { final Element realColumn = (Element) AxisUtils.getRepresentedElement(columnElement); // we already know that it is UML Element due to the handles method @@ -213,9 +237,43 @@ public abstract class AbstractUMLGenericMatrixRelationshipCellManager extends Ab } /** + * Returns the best owner for the created relationship, according to the value of {@link GenericRelationshipMatrixCellEditorConfiguration#getRelationshipOwnerStrategy()} + */ + private final Element getBestOwner(final IMatrixTableWidgetManager tableManager, final ElementTypeConfiguration elementTypeConfiguration, final Element source, final Element target, final EObject context) { + final GenericRelationshipMatrixCellEditorConfiguration conf = getCellEditorConfiguration(tableManager); + if (null != conf) { + switch (conf.getRelationshipOwnerStrategy()) { + case ROW_AS_OWNER: + return source; + case ROW_OWNER: + return source.getOwner(); + case COLUMN_AS_OWNER: + return target; + case COLUMN_OWNER: + return target.getOwner(); + case TABLE_CONTEXT: + return (Element) context; // brutal cast, because, we don't yet support other usecase than Element + case OTHER: + final IWrapper wrapper = conf.getRelationshipOwner(); + if (null != wrapper && wrapper.getElement() instanceof Element) { + return (Element) wrapper.getElement(); + } else { + return null; + } + case DEFAULT:// default case + default: + // default case + + } + } + return this.helper.getBestOwner(elementTypeConfiguration, source, target, (Element) context); + + } + + /** * * @param elementTypeConfiguration - * the elemen type configruation declared in the table cell editor configuration + * the element type configuration declared in the table cell editor configuration * @param source * the source of the relationship to create * @param target @@ -224,6 +282,7 @@ public abstract class AbstractUMLGenericMatrixRelationshipCellManager extends Ab * the context of the table * @return * the element which should own the relationship after its creation + * */ protected Element getBestOwner(final ElementTypeConfiguration elementTypeConfiguration, final Element source, final Element target, final EObject context) { return this.helper.getBestOwner(elementTypeConfiguration, source, target, (Element) context); @@ -489,12 +548,98 @@ public abstract class AbstractUMLGenericMatrixRelationshipCellManager extends Ab * @param newValue * @param tableManager * @return + * the setValueCommand, using the relationship owner defined by the value of the {@link GenericRelationshipMatrixCellEditorConfiguration#MatrixRelationShipOwnerStrategy} */ @Override public Command getSetValueCommand(final TransactionalEditingDomain domain, final Object columnElement, final Object rowElement, final Object newValue, final INattableModelManager tableManager) { final Element realColumn = (Element) AxisUtils.getRepresentedElement(columnElement); final Element realRow = (Element) AxisUtils.getRepresentedElement(rowElement); + final GenericRelationshipMatrixCellEditorConfiguration conf = getCellEditorConfiguration((IMatrixTableWidgetManager) tableManager); + final MatrixRelationShipDirection dir = conf.getDirection(); + final EObject owner; + final EObject tableContext = tableManager.getTable().getContext(); + + switch (dir) { + case FROM_ROW_TO_COLUMN: + owner = getBestOwner((IMatrixTableWidgetManager) tableManager, conf.getEditedElement(), realRow, realColumn, tableContext); + break; + case FROM_COLUMN_TO_ROW: + owner = getBestOwner((IMatrixTableWidgetManager) tableManager, conf.getEditedElement(), realColumn, realRow, tableContext); + break; + default: + owner = null; + } + + return getSetValueCommand(domain, columnElement, rowElement, newValue, tableManager, owner); + } + + /** + * + * @see org.eclipse.papyrus.infra.nattable.manager.cell.AbstractCellManager#getSetValueCommand(org.eclipse.emf.transaction.TransactionalEditingDomain, java.lang.Object, java.lang.Object, java.lang.Object, + * org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager) + * + * @param domain + * @param columnElement + * @param rowElement + * @param newValue + * @param tableManager + * @param usePapyrusDefaultOwner + * if <code>true</code> we return the set value command using the owner calculated by Papyrus, if <code>false</code>, we use the owner strategy defined by the user, reading + * {@link GenericRelationshipMatrixCellEditorConfiguration#MatrixRelationShipOwnerStrategy} + * @return + * the command to use to set the cell value, using the calculated owner, according to the last argument ({@link usePapyrusDefaultOwner}) value + */ + @SuppressWarnings("unused") + private final Command getSetValueCommand(final TransactionalEditingDomain domain, final Object columnElement, final Object rowElement, final Object newValue, final INattableModelManager tableManager, final boolean usePapyrusDefaultOwner) { + final Element realColumn = (Element) AxisUtils.getRepresentedElement(columnElement); + final Element realRow = (Element) AxisUtils.getRepresentedElement(rowElement); + + final GenericRelationshipMatrixCellEditorConfiguration conf = getCellEditorConfiguration((IMatrixTableWidgetManager) tableManager); + final MatrixRelationShipDirection dir = conf.getDirection(); + final EObject owner; + final EObject tableContext = tableManager.getTable().getContext(); + switch (dir) { + case FROM_ROW_TO_COLUMN: + owner = usePapyrusDefaultOwner ? + // owner defined by Papyrus code + getBestOwner(conf.getEditedElement(), realRow, realColumn, tableContext) : + // owner defined by {@link GenericRelationshipMatrixCellEditorConfiguration#MatrixRelationShipOwnerStrategy} + getBestOwner((IMatrixTableWidgetManager) tableManager, conf.getEditedElement(), realRow, realColumn, tableContext); + break; + case FROM_COLUMN_TO_ROW: + owner = usePapyrusDefaultOwner ? + // owner defined by Papyrus code + getBestOwner(conf.getEditedElement(), realColumn, realRow, tableContext) : + // owner defined by {@link GenericRelationshipMatrixCellEditorConfiguration#MatrixRelationShipOwnerStrategy} + getBestOwner((IMatrixTableWidgetManager) tableManager, conf.getEditedElement(), realColumn, realRow, tableContext); + break; + default: + owner = null; + } + + return getSetValueCommand(domain, columnElement, rowElement, newValue, tableManager, owner); + } + + /** + * + * @see org.eclipse.papyrus.infra.nattable.manager.cell.AbstractCellManager#getSetValueCommand(org.eclipse.emf.transaction.TransactionalEditingDomain, java.lang.Object, java.lang.Object, java.lang.Object, + * org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager) + * + * @param domain + * @param columnElement + * @param rowElement + * @param newValue + * @param tableManager + * @param owner + * the owner of the created relationship + * @return + * the command to use to set the cell value, using the owner defined as parameter's method in case of relationship's creation + */ + private final Command getSetValueCommand(final TransactionalEditingDomain domain, final Object columnElement, final Object rowElement, final Object newValue, final INattableModelManager tableManager, final EObject owner) { + final Element realColumn = (Element) AxisUtils.getRepresentedElement(columnElement); + final Element realRow = (Element) AxisUtils.getRepresentedElement(rowElement); + if (Boolean.FALSE.equals(newValue)) { final List<Element> r = getMatchingRelationships(realColumn, realRow, tableManager); if (r.size() == 1) {// according to the isCellEditable there are only 1 relationship @@ -507,28 +652,40 @@ public abstract class AbstractUMLGenericMatrixRelationshipCellManager extends Ab } } if (Boolean.TRUE.equals(newValue)) { - final GenericRelationshipMatrixCellEditorConfiguration conf = getCellEditorConfiguration((IMatrixTableWidgetManager) tableManager); + final IMatrixTableWidgetManager matrixManager = (IMatrixTableWidgetManager) tableManager; + final GenericRelationshipMatrixCellEditorConfiguration conf = getCellEditorConfiguration(matrixManager); final MatrixRelationShipDirection dir = conf.getDirection(); final IElementType elementType = getElementTypeToCreate(conf); final CreateRelationshipRequest request; - final EObject owner; - switch (dir) { case FROM_ROW_TO_COLUMN: - owner = getBestOwner(conf.getEditedElement(), realRow, realColumn, tableManager.getTable().getContext()); request = new CreateRelationshipRequest(owner, realRow, realColumn, elementType); break; case FROM_COLUMN_TO_ROW: - owner = getBestOwner(conf.getEditedElement(), realColumn, realRow, tableManager.getTable().getContext()); request = new CreateRelationshipRequest(owner, realColumn, realRow, elementType); break; default: request = null; - owner = null; } final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(owner); final ICommand cmd = provider.getEditCommand(request); + + final RelationshipOwnerValidator validator = new RelationshipOwnerValidator(matrixManager); + final IStatus validationStatus = validator.validate(owner); + + // we decided to trust the validation status, instead of the returned command which could be customized and create the relationship in a more good owner than chosen one! + if (false == validationStatus.isOK()) { + final ILabelProvider labelProvider = getLabelProvider(realRow); + final String rowLabel = null != labelProvider ? labelProvider.getText(realRow) : realRow.toString(); + final String columnLabel = null != labelProvider ? labelProvider.getText(realColumn) : realColumn.toString(); + final String ownerLabel = null != labelProvider ? labelProvider.getText(owner) : owner.toString(); + + final String str = NLS.bind(Messages.AbstractUMLGenericMatrixRelationshipCellManager_RelationshipCanBeCreated, + new String[] { elementType.getDisplayName(), rowLabel, columnLabel, ownerLabel, validationStatus.getMessage() }); + + return new GMFtoEMFCommandWrapper(new OpenMessageDialogCommand(domain, Messages.AbstractUMLGenericMatrixRelationshipCellManager_CreateRelationshipMessageDialogTitle, str, MessageDialog.ERROR)); + } if (null != cmd && cmd.canExecute()) { return new GMFtoEMFCommandWrapper(cmd); } @@ -536,6 +693,27 @@ public abstract class AbstractUMLGenericMatrixRelationshipCellManager extends Ab return null; } + /** + * + * @param eobject + * an eobject + * @return + * the label provider to use + */ + private final ILabelProvider getLabelProvider(final EObject eobject) { + LabelProviderService lpSvc = null; + try { + lpSvc = (eobject.eResource() != null) + ? ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, eobject) + : ServiceUtilsForResourceSet.getInstance().getService(LabelProviderService.class, NestedEditingDialogContext.getInstance().getResourceSet()); + } catch (ServiceException e) { + Activator.log.error(e); + } + if (null != lpSvc) { + return lpSvc.getLabelProvider(); + } + return null; + } /** * @see org.eclipse.papyrus.infra.nattable.manager.cell.IGenericMatrixRelationshipCellManager#getManagedRelationship() @@ -546,4 +724,118 @@ public abstract class AbstractUMLGenericMatrixRelationshipCellManager extends Ab public EClass getManagedRelationship() { return this.managedElement; } + + /** + * + * @author Vincent LORENZO + * + * This class allows to open a message dialog and to return a command result consistent with the user answer or the MessageDialog kind + * TODO move me in an util plugin + */ + private static final class OpenMessageDialogCommand extends AbstractTransactionalCommand { + + /** + * The title of the dialog + */ + private final String dialogTitle; + + /** + * the message of the dialog + */ + private final String message; + + /** + * the type of the dialog + */ + private final int dialogType; + + + /** + * + * Constructor. + * + * @param domain + * the editing domain + * @param dialogTitle + * the dialog title + * @param message + * the message to display + * @param dialogType + * the style of dialog: + * <ul> + * <li>MessageDialog.ERROR: the command result will return a {@link IStatus#ERROR}</li> + * <li>MessageDialog.INFORMATION:the command result will return a {@link IStatus#OK}</li> + * <li>MessageDialog.QUESTION: the command result will return a {@link IStatus#OK}, with a boolean value (<code>true</code> for Yes button, and <code>false</code> for No button)</li></li> + * <li>MessageDialog.WARNING: the command result will return a {@link IStatus#OK}</li> + * <li>MessageDialog.CONFIRM: the command result will return a {@link IStatus#CANCEL} for cancel button and {@link IStatus#OK} for OK button</li> + * </ul> + * + */ + public OpenMessageDialogCommand(final TransactionalEditingDomain domain, final String dialogTitle, final String message, final int dialogType) { + super(domain, null, null); + this.message = message; + this.dialogTitle = dialogTitle; + this.dialogType = dialogType; + switch (this.dialogType) { + case MessageDialog.ERROR: + case MessageDialog.INFORMATION: + case MessageDialog.QUESTION: + case MessageDialog.WARNING: + case MessageDialog.CONFIRM: + break;// all is ok + default: + Assert.isLegal(false, NLS.bind("The value {0} is not supported as iconType by this dialog", this.dialogType)); //$NON-NLS-1$ + break; + } + } + + + /** + * + * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + * + * @param monitor + * @param info + * @return + * @throws ExecutionException + */ + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + final Shell shell = Display.getDefault().getActiveShell(); + + switch (this.dialogType) { + case MessageDialog.NONE: + // not supported + break; + + case MessageDialog.ERROR: + MessageDialog.openError(shell, dialogTitle, message); + return CommandResult.newErrorCommandResult(message); // only ok button + case MessageDialog.INFORMATION: + MessageDialog.openInformation(shell, dialogTitle, message);// only ok button + return CommandResult.newOKCommandResult(); + case MessageDialog.QUESTION: + boolean res = MessageDialog.openQuestion(shell, dialogTitle, message);// return true/false for yes/no button + return CommandResult.newOKCommandResult(res); + + case MessageDialog.WARNING: + MessageDialog.openWarning(shell, dialogTitle, message);// only OK button + return CommandResult.newOKCommandResult(); + + case MessageDialog.CONFIRM: + res = MessageDialog.openConfirm(shell, dialogTitle, message);// ok and cancel button + if (res) { + return CommandResult.newOKCommandResult(); + } + return CommandResult.newCancelledCommandResult(); + + default: + // nothing to do + // not possible with the current implementation + break; + } + // not possible with the current implementation + return new CommandResult(Status.OK_STATUS); + }; + + } } diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/messages/Messages.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/messages/Messages.java index 91e35a2257b..fa0df620463 100755 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/messages/Messages.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/messages/Messages.java @@ -21,7 +21,19 @@ import org.eclipse.osgi.util.NLS; */ public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.papyrus.uml.nattable.matrix.messages.messages"; //$NON-NLS-1$ + public static String AbstractUMLGenericMatrixRelationshipCellManager_CreateRelationshipMessageDialogTitle; + public static String AbstractUMLGenericMatrixRelationshipCellManager_RelationshipCanBeCreated; public static String GenericMatrixRelationshipCellEditorConfiguration_description; + public static String RelationshipOwnerValidator_ChosenRelationshipIsAbstract; + public static String RelationshipOwnerValidator_ColumnCantbeUsedAsOwner; + public static String RelationshipOwnerValidator_ColumnOwnerCantbeUsedAsOwner; + public static String RelationshipOwnerValidator_ElementCantBeResolvedAsEObject; + public static String RelationshipOwnerValidator_ItIsAPapyrusBug; + public static String RelationshipOwnerValidator_NoRelationshipDefined; + public static String RelationshipOwnerValidator_RowCantbeUsedAsOwner; + public static String RelationshipOwnerValidator_RowOwnerCantbeUsedAsOwner; + public static String RelationshipOwnerValidator_TableContextCantbeUsedAsOwner; + public static String RelationshipOwnerValidator_TheChosenElementCantBeUsedAsOwner; static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/messages/messages.properties b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/messages/messages.properties index f675673ad04..00aab38ec58 100755 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/messages/messages.properties +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/messages/messages.properties @@ -1 +1,13 @@ -GenericMatrixRelationshipCellEditorConfiguration_description=This configuration provides CellEditor, CellPainter and CellConverter used by UML Relationship matrix +AbstractUMLGenericMatrixRelationshipCellManager_CreateRelationshipMessageDialogTitle=Create Relationship +AbstractUMLGenericMatrixRelationshipCellManager_RelationshipCanBeCreated=The {0} relationship can't be created between {1} and {2}, with {3} as owner, as expected with the chosen owner strategy.\nError Message:\n\t{4}. +GenericMatrixRelationshipCellEditorConfiguration_description=This configuration provides CellEditor, CellPainter and CellConverter used by UML Relationship matrix. +RelationshipOwnerValidator_ChosenRelationshipIsAbstract=The relationship to create is an abstract. +RelationshipOwnerValidator_ColumnCantbeUsedAsOwner=The column {0} can't be used as owner for the created relationship. +RelationshipOwnerValidator_ColumnOwnerCantbeUsedAsOwner=The column's owner {0} can't be used as owner for the created relationship. +RelationshipOwnerValidator_ElementCantBeResolvedAsEObject=The element {0} can't be resolved as an EObject. +RelationshipOwnerValidator_ItIsAPapyrusBug=If you read this message, it is a Papyrus Bug. Please fill a bug with your model. +RelationshipOwnerValidator_NoRelationshipDefined=There is no relationship defined. +RelationshipOwnerValidator_RowCantbeUsedAsOwner=The row {0} can't be used as owner for the created relationship. +RelationshipOwnerValidator_RowOwnerCantbeUsedAsOwner=The row's owner {0} can't be used as owner for the created relationship. +RelationshipOwnerValidator_TableContextCantbeUsedAsOwner=The table context (Root Element) {0} can't be used as owner for the created relationship. +RelationshipOwnerValidator_TheChosenElementCantBeUsedAsOwner=The chosen element {0} can't be used as owner for the created relationship. diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/validator/RelationshipOwnerValidator.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/validator/RelationshipOwnerValidator.java new file mode 100644 index 00000000000..ff447ec3ccd --- /dev/null +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.matrix/src/org/eclipse/papyrus/uml/nattable/matrix/validator/RelationshipOwnerValidator.java @@ -0,0 +1,191 @@ +/***************************************************************************** + * Copyright (c) 2018 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: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.nattable.matrix.validator; + +import org.eclipse.core.databinding.validation.IValidator; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject; +import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceSet; +import org.eclipse.papyrus.infra.nattable.manager.table.IMatrixTableWidgetManager; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectTreeItemAxis; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecelleditor.GenericRelationshipMatrixCellEditorConfiguration; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattablewrapper.EObjectWrapper; +import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService; +import org.eclipse.papyrus.infra.types.ElementTypeConfiguration; +import org.eclipse.papyrus.infra.types.MetamodelTypeConfiguration; +import org.eclipse.papyrus.infra.ui.emf.dialog.NestedEditingDialogContext; +import org.eclipse.papyrus.uml.nattable.matrix.Activator; +import org.eclipse.papyrus.uml.nattable.matrix.messages.Messages; + +/** + * @author Vincent LORENZO + * + * This class provides a validate method to check the used owner during a relationship's creation. We assume the checked object is compliant with the strategy defined by the user. + * If not, the returned message in the returned status will be invalid!!! + * + */ +public class RelationshipOwnerValidator implements IValidator { + + + /** + * the cell editor configuration of the current matrix + */ + private final GenericRelationshipMatrixCellEditorConfiguration conf; + + /** + * Constructor. + * + */ + public RelationshipOwnerValidator(final IMatrixTableWidgetManager matrixManager) { + this.conf = (GenericRelationshipMatrixCellEditorConfiguration) matrixManager.getTable().getOwnedCellEditorConfigurations(); + } + + /** + * + * @param message + * the message to set in the error IStatus + * @return + * the created IStatus error + */ + private final IStatus createErrorStatus(final String message) { + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, message); + } + + /** + * @see org.eclipse.core.databinding.validation.IValidator#validate(java.lang.Object) + * + * @param value + * a value to validate. We assume the value to check is consistent with the owner strategy mode defined in the {@link GenericRelationshipMatrixCellEditorConfiguration}. + * If not the returned message will be probably invalid!!!! + * @return + */ + @Override + public IStatus validate(final Object value) { + EObject realEObject = null; + if (value instanceof EObjectWrapper) { + realEObject = ((EObjectWrapper) value).getElement(); + } else if (value instanceof EObjectTreeItemAxis) { + realEObject = ((EObjectTreeItemAxis) value).getElement(); + } else if (value instanceof EObject) { + realEObject = (EObject) value; + } + + if (null == realEObject) { + return createErrorStatus(NLS.bind(Messages.RelationshipOwnerValidator_ElementCantBeResolvedAsEObject, value)); + } + + final IStatus relationshipDefinition = hasADefinedRelationship(); + if (false == relationshipDefinition.isOK()) { + return relationshipDefinition; + } + + boolean hasAValidFeature = hasFeatureAcceptingRelationShip(realEObject); + // We assume the value to check is consistent with the owner strategy mode defined in the {@link GenericRelationshipMatrixCellEditorConfiguration}. + // If not the returned message will be probably invalid!!!! + if (false == hasAValidFeature) { + final ILabelProvider labelProvider = getLabelProvider(realEObject); + final String realObjectLabel = null != labelProvider ? labelProvider.getText(realEObject) : realEObject.toString(); + + switch (conf.getRelationshipOwnerStrategy()) { + case COLUMN_AS_OWNER: + return createErrorStatus(NLS.bind(Messages.RelationshipOwnerValidator_ColumnCantbeUsedAsOwner, realObjectLabel)); + case COLUMN_OWNER: + return createErrorStatus(NLS.bind(Messages.RelationshipOwnerValidator_ColumnOwnerCantbeUsedAsOwner, realObjectLabel)); + case DEFAULT: + // we hope it never appears! + return createErrorStatus(NLS.bind(Messages.RelationshipOwnerValidator_ItIsAPapyrusBug, realObjectLabel)); + case OTHER: + return createErrorStatus(NLS.bind(Messages.RelationshipOwnerValidator_TheChosenElementCantBeUsedAsOwner, realObjectLabel)); + case ROW_AS_OWNER: + return createErrorStatus(NLS.bind(Messages.RelationshipOwnerValidator_RowCantbeUsedAsOwner, realObjectLabel)); + case ROW_OWNER: + return createErrorStatus(NLS.bind(Messages.RelationshipOwnerValidator_RowOwnerCantbeUsedAsOwner, realObjectLabel)); + case TABLE_CONTEXT: + return createErrorStatus(NLS.bind(Messages.RelationshipOwnerValidator_TableContextCantbeUsedAsOwner, realObjectLabel)); + default: + break; + } + } + return Status.OK_STATUS; + } + + /** + * + * @return + * a IStatus indicating if the relationship is defined and valid or not + */ + private final IStatus hasADefinedRelationship() { + final ElementTypeConfiguration etc = this.conf.getEditedElement(); + if (null == etc) { + return createErrorStatus(Messages.RelationshipOwnerValidator_NoRelationshipDefined); + } + final EClass eclass = ((MetamodelTypeConfiguration) etc).getEClass(); + if (eclass.isAbstract()) { + return createErrorStatus(Messages.RelationshipOwnerValidator_ChosenRelationshipIsAbstract); // very unlucky case, probably impossible + } + return Status.OK_STATUS; + } + + + /** + * + * @param wantedOwner + * the wanted owner for the created relationship + * @return + * <code>true</code> if the wanted owner has a feature accepting the created relationship + */ + private final boolean hasFeatureAcceptingRelationShip(final EObject wantedOwner) { + Assert.isNotNull(wantedOwner); + final ElementTypeConfiguration etc = this.conf.getEditedElement(); + final EClass eclass = ((MetamodelTypeConfiguration) etc).getEClass(); + final EObject dummyRelationship = eclass.getEPackage().getEFactoryInstance().create(eclass); + for (EStructuralFeature current : wantedOwner.eClass().getEAllContainments()) { + if (current.getEType().isInstance(dummyRelationship)) { + return true; + } + } + return false; + } + + /** + * + * @param eobject + * an eobject + * @return + * the label provider to use + */ + private final ILabelProvider getLabelProvider(final EObject eobject) { + LabelProviderService lpSvc = null; + try { + lpSvc = (eobject.eResource() != null) + ? ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, eobject) + : ServiceUtilsForResourceSet.getInstance().getService(LabelProviderService.class, NestedEditingDialogContext.getInstance().getResourceSet()); + } catch (ServiceException e) { + Activator.log.error(e); + } + if (null != lpSvc) { + return lpSvc.getLabelProvider(); + } + return null; + } + +} diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.menu/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.menu/META-INF/MANIFEST.MF index 514c1ec0a52..7c6b1cfc80f 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.menu/META-INF/MANIFEST.MF +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.menu/META-INF/MANIFEST.MF @@ -3,11 +3,11 @@ Export-Package: org.eclipse.papyrus.uml.nattable.menu, org.eclipse.papyrus.uml.nattable.menu.handlers, org.eclipse.papyrus.uml.nattable.menu.messages, org.eclipse.papyrus.uml.nattable.menu.util -Require-Bundle: org.eclipse.papyrus.infra.nattable.common;bundle-version="[4.0.0,5.0.0)", +Require-Bundle: org.eclipse.papyrus.infra.nattable.common;bundle-version="[5.0.0,6.0.0)", org.eclipse.papyrus.uml.service.types.ui;bundle-version="[2.0.0,3.0.0)" Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy -Bundle-Version: 1.2.0.qualifier +Bundle-Version: 1.2.100.qualifier Bundle-Name: %Bundle-Name Bundle-Activator: org.eclipse.papyrus.uml.nattable.menu.Activator Bundle-ManifestVersion: 2 diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.menu/pom.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.menu/pom.xml index a3256fa12fd..e12959951ae 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.menu/pom.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.menu/pom.xml @@ -8,6 +8,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.nattable.menu</artifactId> - <version>1.2.0-SNAPSHOT</version> + <version>1.2.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/META-INF/MANIFEST.MF index 29931cf27a0..3ace5510a24 100755 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/META-INF/MANIFEST.MF +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/META-INF/MANIFEST.MF @@ -2,10 +2,10 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.papyrus.uml.nattable.properties;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.0.100.qualifier Bundle-Vendor: %Bundle-Vendor Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Require-Bundle: org.eclipse.papyrus.infra.nattable;bundle-version="[5.0.0,6.0.0]", +Require-Bundle: org.eclipse.papyrus.infra.nattable;bundle-version="[6.0.0,7.0.0]", org.eclipse.papyrus.infra.nattable.model;bundle-version="2.0.0", org.eclipse.papyrus.infra.properties;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.infra.nattable.properties;bundle-version="[2.2.0,3.0.0)", @@ -13,10 +13,10 @@ Require-Bundle: org.eclipse.papyrus.infra.nattable;bundle-version="[5.0.0,6.0.0] org.eclipse.papyrus.infra.properties.ui;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.100,2.0.0)", org.eclipse.papyrus.infra.services.edit;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.infra.emf.nattable;bundle-version="[4.0.0,5.0.0)", + org.eclipse.papyrus.infra.emf.nattable;bundle-version="[5.0.0,6.0.0)", org.eclipse.uml2.uml;bundle-version="[5.3.0,6.0.0)", org.eclipse.papyrus.infra.types.core;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.infra.nattable.common;bundle-version="[4.0.0,5.0.0)", + org.eclipse.papyrus.infra.nattable.common;bundle-version="[5.0.0,6.0.0)", org.eclipse.papyrus.uml.expressions;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.emf.expressions.properties;bundle-version="[1.0.0,2.0.0)", org.eclipse.papyrus.infra.emf.expressions;bundle-version="[1.0.0,2.0.0)" diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/pom.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/pom.xml index cbd74c828a2..6dadb9dad16 100755 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/pom.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/pom.xml @@ -8,7 +8,7 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.nattable.properties</artifactId> - <version>1.0.0-SNAPSHOT</version> + <version>1.0.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <description>This plugin provides properties views specialized for Papyrus UML Table.</description> </project> diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/properties/GenericUMLRelationshipMatrix.ctx b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/properties/GenericUMLRelationshipMatrix.ctx index 0b23b408048..bbc89b8560f 100755 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/properties/GenericUMLRelationshipMatrix.ctx +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/properties/GenericUMLRelationshipMatrix.ctx @@ -20,6 +20,9 @@ <properties xmi:id="_TDc0ISwOEeeKOdJYr-htag" name="managedElementType" type="Reference"/> <properties xmi:id="_TDc0IiwOEeeKOdJYr-htag" name="relationshipDirection" type="Enumeration"/> <properties xmi:id="_7ml2MCwPEeeKOdJYr-htag" name="cellContentsFilter" type="Reference"/> + <properties xmi:id="_TDc0IiwOEeeKOdJYr-htag" name="relationshipOwnerStrategy" type="Enumeration"/> + <properties xmi:id="_qWk8YCwOEeeKOdJYr-htag" name="relationshipOwner" type="Reference"/> + <properties xmi:id="_qWk8YCwOEeeKOdJYr-htag" name="relationshipOwnerFeature" type="Reference"/> </elements> <modelElementFactory href="Environment.xmi#//@modelElementFactories.0"/> </dataContexts> diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/properties/ui/Matrix.xwt b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/properties/ui/Matrix.xwt index 1f1c197ecae..477147998e3 100755 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/properties/ui/Matrix.xwt +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/properties/ui/Matrix.xwt @@ -48,4 +48,15 @@ property="GenericUMLRelationshipMatrixDataContext:GenericRelationshipMatrixCellEditorConfiguration:cellContentsFilter" customLabel="Contents Filter"></ppe:ReferenceDialog> </Group> + <Group text="Relation Owner"> + <Group.layout> + <ppel:PropertiesLayout></ppel:PropertiesLayout> + </Group.layout> + <ppe:EnumCombo input="{Binding}" + property="GenericUMLRelationshipMatrixDataContext:GenericRelationshipMatrixCellEditorConfiguration:relationshipOwnerStrategy" + customLabel="Owner Strategy"></ppe:EnumCombo> + <ppe:ReferenceDialog input="{Binding}" + property="GenericUMLRelationshipMatrixDataContext:GenericRelationshipMatrixCellEditorConfiguration:relationshipOwner" + customLabel="Relation Owner"></ppe:ReferenceDialog> + </Group> </Composite>
\ No newline at end of file diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/modelelements/GenericUMLRelationshipMatrixModelElement.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/modelelements/GenericUMLRelationshipMatrixModelElement.java index 21ebbf15c24..ddae1fce18e 100755 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/modelelements/GenericUMLRelationshipMatrixModelElement.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/modelelements/GenericUMLRelationshipMatrixModelElement.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2017 CEA LIST and others. + * Copyright (c) 2017, 2018 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 @@ -8,7 +8,7 @@ * * Contributors: * Vincent LORENZO (CEA-LIST) vincent.lorenzo@cea.fr - Initial API and implementation - * + * Vincent Lorenzo (CEA LIST) - vincent.lorenzo@cea.fr - Bug 532639 *****************************************************************************/ package org.eclipse.papyrus.uml.nattable.properties.modelelements; @@ -18,6 +18,7 @@ import java.util.Iterator; import java.util.List; import org.eclipse.core.databinding.observable.IObservable; +import org.eclipse.core.databinding.validation.IValidator; import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.impl.AdapterImpl; @@ -29,8 +30,9 @@ import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.papyrus.infra.emf.expressions.booleanexpressions.IBooleanEObjectExpression; import org.eclipse.papyrus.infra.emf.expressions.properties.utils.BooleanEObjectExpressionPropertyEditorFactory; -import org.eclipse.papyrus.infra.nattable.contentprovider.MatrixSourcesContentProvider; import org.eclipse.papyrus.infra.nattable.contentprovider.MatrixDirectionContentProvider; +import org.eclipse.papyrus.infra.nattable.contentprovider.MatrixRelationshipOwnerStrategyContentProvider; +import org.eclipse.papyrus.infra.nattable.contentprovider.MatrixSourcesContentProvider; import org.eclipse.papyrus.infra.nattable.manager.table.IMatrixTableWidgetManager; import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage; import org.eclipse.papyrus.infra.nattable.model.nattable.Table; @@ -47,17 +49,20 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecelleditor.ICel import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecelleditor.NattablecelleditorPackage; import org.eclipse.papyrus.infra.nattable.model.nattable.nattablewrapper.EObjectWrapper; import org.eclipse.papyrus.infra.nattable.provider.MatrixRelationshipDirectionLabelProvider; +import org.eclipse.papyrus.infra.nattable.provider.MatrixRelationshipOwnerStrategyLabelProvider; import org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement; import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory; import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider; import org.eclipse.papyrus.uml.expressions.umlexpressions.UMLExpressionsPackage; import org.eclipse.papyrus.uml.nattable.properties.observables.MatrixCellContentsFilterObservableValue; -import org.eclipse.papyrus.uml.nattable.properties.observables.MatrixColumnSourcesEMFObservableList; import org.eclipse.papyrus.uml.nattable.properties.observables.MatrixColumnRootFilterObservableValue; +import org.eclipse.papyrus.uml.nattable.properties.observables.MatrixColumnSourcesEMFObservableList; import org.eclipse.papyrus.uml.nattable.properties.observables.MatrixDirectionObservableValue; import org.eclipse.papyrus.uml.nattable.properties.observables.MatrixManagedElementTypeObservableValue; -import org.eclipse.papyrus.uml.nattable.properties.observables.MatrixRowSourcesEMFObservableList; +import org.eclipse.papyrus.uml.nattable.properties.observables.MatrixRelationshipOwnerStrategyObservableValue; +import org.eclipse.papyrus.uml.nattable.properties.observables.MatrixRelationshipOwneryObservableValue; import org.eclipse.papyrus.uml.nattable.properties.observables.MatrixRowRootFilterObservableValue; +import org.eclipse.papyrus.uml.nattable.properties.observables.MatrixRowSourcesEMFObservableList; import org.eclipse.papyrus.uml.nattable.properties.providers.GenericRelationshipMatrixElementTypeContentProvider; import org.eclipse.papyrus.uml.nattable.properties.providers.GenericRelationshipMatrixElementTypeLabelProvider; import org.eclipse.papyrus.uml.nattable.properties.utils.MatrixPropertyConstants; @@ -120,7 +125,8 @@ public class GenericUMLRelationshipMatrixModelElement extends EMFModelElement { this.interestingFeatures.add(NattablecelleditorPackage.eINSTANCE.getGenericRelationshipMatrixCellEditorConfiguration_CellContentsFilter()); this.interestingFeatures.add(NattablecelleditorPackage.eINSTANCE.getGenericRelationshipMatrixCellEditorConfiguration_Direction()); this.interestingFeatures.add(NattablecelleditorPackage.eINSTANCE.getGenericRelationshipMatrixCellEditorConfiguration_EditedElement()); - + this.interestingFeatures.add(NattablecelleditorPackage.eINSTANCE.getGenericRelationshipMatrixCellEditorConfiguration_RelationshipOwner()); + this.interestingFeatures.add(NattablecelleditorPackage.eINSTANCE.getGenericRelationshipMatrixCellEditorConfiguration_RelationshipOwnerStrategy()); this.changeListener = new AdapterImpl() { @@ -314,6 +320,10 @@ public class GenericUMLRelationshipMatrixModelElement extends EMFModelElement { value = new MatrixDirectionObservableValue(getEditedTable()); } else if (MatrixPropertyConstants.MATRIX_CELL_FILTER.equals(propertyPath)) { value = new MatrixCellContentsFilterObservableValue(getEditedTable()); + } else if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_OWNER_STRATEGY.equals(propertyPath)) { + value = new MatrixRelationshipOwnerStrategyObservableValue(getEditedTable()); + } else if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_OWNER.equals(propertyPath)) { + value = new MatrixRelationshipOwneryObservableValue(getEditedTable()); } else { value = super.doGetObservable(propertyPath); } @@ -338,6 +348,10 @@ public class GenericUMLRelationshipMatrixModelElement extends EMFModelElement { provider = new GenericRelationshipMatrixElementTypeContentProvider(getRoot(getEditedTable().getContext())); } else if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_DIRECTION.equals(propertyPath)) { provider = new MatrixDirectionContentProvider(); + } else if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_OWNER_STRATEGY.equals(propertyPath)) { + provider = new MatrixRelationshipOwnerStrategyContentProvider(); + } else if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_OWNER.equals(propertyPath)) { + provider = new MatrixSourcesContentProvider(getRoot(getEditedTable().getContext())); } else { provider = super.getContentProvider(propertyPath); } @@ -354,18 +368,18 @@ public class GenericUMLRelationshipMatrixModelElement extends EMFModelElement { public EStructuralFeature getFeature(final String propertyPath) { if (MatrixPropertyConstants.MATRIX_ROW_FILTER.equals(propertyPath) || MatrixPropertyConstants.MATRIX_COLUMN_FILTER.equals(propertyPath)) { return NattableaxisconfigurationPackage.eINSTANCE.getTreeFillingConfiguration_FilterRule(); - } - if (MatrixPropertyConstants.MATRIX_ROW_SOURCES.equals(propertyPath) || MatrixPropertyConstants.MATRIX_COLUMN_SOURCES.equals(propertyPath)) { + } else if (MatrixPropertyConstants.MATRIX_ROW_SOURCES.equals(propertyPath) || MatrixPropertyConstants.MATRIX_COLUMN_SOURCES.equals(propertyPath)) { return NattableaxisproviderPackage.eINSTANCE.getIMasterAxisProvider_Sources(); - } - if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_DIRECTION.equals(propertyPath)) { + } else if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_DIRECTION.equals(propertyPath)) { return NattablecelleditorPackage.eINSTANCE.getGenericRelationshipMatrixCellEditorConfiguration_Direction(); - } - if (MatrixPropertyConstants.MATRIX_CELL_TYPE.equals(propertyPath)) { + } else if (MatrixPropertyConstants.MATRIX_CELL_TYPE.equals(propertyPath)) { return NattablecelleditorPackage.eINSTANCE.getGenericRelationshipMatrixCellEditorConfiguration_EditedElement(); - } - if (MatrixPropertyConstants.MATRIX_CELL_FILTER.equals(propertyPath)) { + } else if (MatrixPropertyConstants.MATRIX_CELL_FILTER.equals(propertyPath)) { return NattablecelleditorPackage.eINSTANCE.getGenericRelationshipMatrixCellEditorConfiguration_CellContentsFilter(); + } else if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_OWNER_STRATEGY.equals(propertyPath)) { + return NattablecelleditorPackage.eINSTANCE.getGenericRelationshipMatrixCellEditorConfiguration_RelationshipOwnerStrategy(); + } else if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_OWNER.equals(propertyPath)) { + return NattablecelleditorPackage.eINSTANCE.getGenericRelationshipMatrixCellEditorConfiguration_RelationshipOwner(); } return super.getFeature(propertyPath); } @@ -397,12 +411,17 @@ public class GenericUMLRelationshipMatrixModelElement extends EMFModelElement { @Override public ILabelProvider getLabelProvider(String propertyPath) { ILabelProvider provider = super.getLabelProvider(propertyPath); - if (MatrixPropertyConstants.MATRIX_COLUMN_SOURCES.equals(propertyPath) || MatrixPropertyConstants.MATRIX_ROW_SOURCES.equals(propertyPath)) { + if (MatrixPropertyConstants.MATRIX_COLUMN_SOURCES.equals(propertyPath) + || MatrixPropertyConstants.MATRIX_ROW_SOURCES.equals(propertyPath) + || MatrixPropertyConstants.MATRIX_RELATIONSHIP_OWNER.equals(propertyPath)) { provider = new WrappedLabelProvider(provider); } if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_DIRECTION.equals(propertyPath)) { provider = new MatrixRelationshipDirectionLabelProvider(); } + if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_OWNER_STRATEGY.equals(propertyPath)) { + provider = new MatrixRelationshipOwnerStrategyLabelProvider(); + } if (MatrixPropertyConstants.MATRIX_CELL_TYPE.equals(propertyPath)) { provider = new GenericRelationshipMatrixElementTypeLabelProvider(); } @@ -440,6 +459,9 @@ public class GenericUMLRelationshipMatrixModelElement extends EMFModelElement { if (MatrixPropertyConstants.MATRIX_ROW_SOURCES.equals(propertyPath) || MatrixPropertyConstants.MATRIX_COLUMN_SOURCES.equals(propertyPath)) { return false;// it is a containment feature, but we need to open a dialog to wrapper the selected element } + if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_OWNER.equals(propertyPath)) { + return false;// it is a containment feature, but we need to open a dialog to wrapper the selected element + } return super.getDirectCreation(propertyPath); } @@ -464,6 +486,8 @@ public class GenericUMLRelationshipMatrixModelElement extends EMFModelElement { factory.setNsUri(UMLExpressionsPackage.eNS_URI); return factory; } + } else if (MatrixPropertyConstants.MATRIX_RELATIONSHIP_OWNER.equals(propertyPath)) { + return null;// to remove the green plus } return super.getValueFactory(propertyPath); } diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/observables/AbstractMatrixRelationshipCellEditorConfigurationObservableValue.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/observables/AbstractMatrixRelationshipCellEditorConfigurationObservableValue.java index 1a0ecc9a46d..ab9f2f200da 100755 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/observables/AbstractMatrixRelationshipCellEditorConfigurationObservableValue.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/observables/AbstractMatrixRelationshipCellEditorConfigurationObservableValue.java @@ -88,7 +88,7 @@ public abstract class AbstractMatrixRelationshipCellEditorConfigurationObservabl * @param value */ @Override - protected final void doSetValue(Object value) { + protected void doSetValue(Object value) { final Command setCommand = SetCommand.create(this.domain, getEditedEObject(), getManagedFeature(), value); if (setCommand.canExecute()) { this.domain.getCommandStack().execute(setCommand); diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/observables/MatrixRelationshipOwnerStrategyObservableValue.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/observables/MatrixRelationshipOwnerStrategyObservableValue.java new file mode 100644 index 00000000000..48d0a0e2a9c --- /dev/null +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/observables/MatrixRelationshipOwnerStrategyObservableValue.java @@ -0,0 +1,37 @@ +/***************************************************************************** + * Copyright (c) 2018 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: + * Vincent LORENZO (CEA-LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.nattable.properties.observables; + +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecelleditor.NattablecelleditorPackage; +import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils; + + +/** + * Observable for the owner strategy of the relationships to create and display feature + */ +public class MatrixRelationshipOwnerStrategyObservableValue extends AbstractMatrixRelationshipCellEditorConfigurationObservableValue { + + /** + * Constructor. + * + * @param domain + * The current editing domain. + * @param table + * The managed table. + */ + public MatrixRelationshipOwnerStrategyObservableValue(final Table table) { + super(TableEditingDomainUtils.getTableEditingDomain(table), table, NattablecelleditorPackage.eINSTANCE.getGenericRelationshipMatrixCellEditorConfiguration_RelationshipOwnerStrategy()); + } + +} diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/observables/MatrixRelationshipOwneryObservableValue.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/observables/MatrixRelationshipOwneryObservableValue.java new file mode 100644 index 00000000000..357039dc288 --- /dev/null +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/observables/MatrixRelationshipOwneryObservableValue.java @@ -0,0 +1,73 @@ +/***************************************************************************** + * Copyright (c) 2018 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: + * Vincent LORENZO (CEA-LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.nattable.properties.observables; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecelleditor.NattablecelleditorPackage; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattablewrapper.EObjectWrapper; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattablewrapper.IWrapper; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattablewrapper.NattablewrapperFactory; +import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils; +import org.eclipse.uml2.uml.Element; + +/** + * @author Vincent LORENZO + * + */ +public class MatrixRelationshipOwneryObservableValue extends AbstractMatrixRelationshipCellEditorConfigurationObservableValue { + + /** + * + * Constructor. + * + * @param table + * the edited table + */ + public MatrixRelationshipOwneryObservableValue(final Table table) { + super(TableEditingDomainUtils.getTableEditingDomain(table), table, NattablecelleditorPackage.eINSTANCE.getGenericRelationshipMatrixCellEditorConfiguration_RelationshipOwner()); + } + + /** + * @see org.eclipse.papyrus.uml.nattable.properties.observables.AbstractMatrixRelationshipCellEditorConfigurationObservableValue#doGetValue() + * + * @return + */ + @Override + protected Object doGetValue() { + Object res = super.doGetValue(); + if (res instanceof IWrapper) { + res = ((IWrapper) res).getElement();// it seems the reference dialog is not able to propagate it as initial selection, so this line is useless + } + return res; + } + + /** + * @see org.eclipse.papyrus.uml.nattable.properties.observables.AbstractMatrixRelationshipCellEditorConfigurationObservableValue#doSetValue(java.lang.Object) + * + * @param value + */ + @Override + protected void doSetValue(Object value) { + if (value instanceof Element) { + final EObjectWrapper wrapper = NattablewrapperFactory.eINSTANCE.createEObjectWrapper(); + wrapper.setElement((EObject) value); + value = wrapper; + } + super.doSetValue(value); + } + + + +} diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/utils/MatrixPropertyConstants.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/utils/MatrixPropertyConstants.java index df53df35bf0..8c763258158 100755 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/utils/MatrixPropertyConstants.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.properties/src/org/eclipse/papyrus/uml/nattable/properties/utils/MatrixPropertyConstants.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2017 CEA LIST and others. + * Copyright (c) 2017, 2018 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 @@ -8,7 +8,7 @@ * * Contributors: * Vincent LORENZO (CEA-LIST) vincent.lorenzo@cea.fr - Initial API and implementation - * + * Vincent Lorenzo (CEA LIST) - vincent.lorenzo@cea.fr - Bug 532639 *****************************************************************************/ package org.eclipse.papyrus.uml.nattable.properties.utils; @@ -37,4 +37,12 @@ public class MatrixPropertyConstants { public static final String MATRIX_CELL_FILTER = "cellContentsFilter";//$NON-NLS-1$ public static final String MATRIX_RELATIONSHIP_DIRECTION = "relationshipDirection";//$NON-NLS-1$ + + public static final String MATRIX_RELATIONSHIP_OWNER = "relationshipOwner";//$NON-NLS-1$ + + public static final String MATRIX_RELATIONSHIP_OWNER_STRATEGY = "relationshipOwnerStrategy";//$NON-NLS-1$ + + // defined but not yet used + public static final String MATRIX_RELATIONSHIP_OWNER_FEATURE = "relationshipOwnerFeature";//$NON-NLS-1$ + } diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/META-INF/MANIFEST.MF index f0fd842bde6..289b0e800dd 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/META-INF/MANIFEST.MF +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/META-INF/MANIFEST.MF @@ -9,12 +9,12 @@ Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.papyrus.uml.nattable.richtext;singleton:=true Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)", - org.eclipse.papyrus.infra.nattable;bundle-version="[5.0.0,6.0.0)", + org.eclipse.papyrus.infra.nattable;bundle-version="[6.0.0,7.0.0)", org.eclipse.uml2.uml;bundle-version="[5.3.0,6.0.0)", org.eclipse.nebula.widgets.nattable.extension.nebula;bundle-version="[1.0.0,2.0.0)", org.eclipse.nebula.widgets.richtext;bundle-version="[1.0.0,2.0.0)", org.eclipse.papyrus.uml.tools;bundle-version="[4.0.0,5.0.0)", org.eclipse.papyrus.uml.ui;bundle-version="[1.2.0,2.0.0)", - org.eclipse.papyrus.uml.nattable;bundle-version="[4.0.0,5.0.0)" + org.eclipse.papyrus.uml.nattable;bundle-version="[5.0.0,6.0.0)" Export-Package: org.eclipse.papyrus.uml.nattable.richtext.celleditor.config Bundle-Description: %Bundle-Description diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/META-INF/MANIFEST.MF index 9c0a2f2c98d..f54e1c53a0c 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/META-INF/MANIFEST.MF +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Require-Bundle: org.eclipse.nebula.widgets.nattable.extension.glazedlists;bundle-version="[1.5.0,2.0.0)", org.eclipse.papyrus.uml.diagram.common;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.uml.nattable;bundle-version="[4.0.0,5.0.0)", + org.eclipse.papyrus.uml.nattable;bundle-version="[5.0.0,6.0.0)", org.eclipse.papyrus.uml.internationalization.utils;bundle-version="[1.0.0,2.0.0)" Export-Package: org.eclipse.papyrus.uml.nattable.stereotype.display, org.eclipse.papyrus.uml.nattable.stereotype.display.configuration, @@ -11,7 +11,7 @@ Export-Package: org.eclipse.papyrus.uml.nattable.stereotype.display, org.eclipse.papyrus.uml.nattable.stereotype.display.utils Bundle-Vendor: Eclipse Modeling Project Bundle-ActivationPolicy: lazy -Bundle-Version: 3.0.0.qualifier +Bundle-Version: 3.0.100.qualifier Bundle-Name: Stereotype Display Table Bundle-ManifestVersion: 2 Bundle-Activator: org.eclipse.papyrus.uml.nattable.stereotype.display.Activator diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/pom.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/pom.xml index f993d41010f..e1d36746c90 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/pom.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/pom.xml @@ -8,6 +8,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.nattable.stereotype.display</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF index 57229ec9ad3..4034ab8aa4c 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF @@ -2,11 +2,11 @@ Manifest-Version: 1.0 Export-Package: org.eclipse.papyrus.uml.nattable.xtext.integration, org.eclipse.papyrus.uml.nattable.xtext.integration.celleditor, org.eclipse.papyrus.uml.nattable.xtext.integration.util -Require-Bundle: org.eclipse.papyrus.infra.nattable.common;bundle-version="[4.0.0,5.0.0)", +Require-Bundle: org.eclipse.papyrus.infra.nattable.common;bundle-version="[5.0.0,6.0.0)", org.eclipse.papyrus.uml.xtext.integration.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.0.100.qualifier Bundle-Name: %Bundle-Name Bundle-Activator: org.eclipse.papyrus.uml.nattable.xtext.integration.Activator Bundle-ManifestVersion: 2 diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/pom.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/pom.xml index d93ff48f83f..5b2549261f2 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/pom.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/pom.xml @@ -7,6 +7,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.nattable.xtext.integration</artifactId> - <version>2.0.0-SNAPSHOT</version> + <version>2.0.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/META-INF/MANIFEST.MF index 31b28e89e44..dbd52249e21 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/META-INF/MANIFEST.MF +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/META-INF/MANIFEST.MF @@ -1,5 +1,5 @@ Manifest-Version: 1.0 -Require-Bundle: org.eclipse.papyrus.infra.emf.nattable;bundle-version="[4.0.0,5.0.0)";visibility:=reexport, +Require-Bundle: org.eclipse.papyrus.infra.emf.nattable;bundle-version="[5.0.0,6.0.0)";visibility:=reexport, org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils;bundle-version="[1.2.0,2.0.0)", org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui;bundle-version="[2.0.0,3.0.0)", @@ -9,7 +9,7 @@ Export-Package: org.eclipse.papyrus.uml.nattable.xtext.valuespecification, org.eclipse.papyrus.uml.nattable.xtext.valuespecification.manager.cell Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy -Bundle-Version: 4.0.0.qualifier +Bundle-Version: 5.0.0.qualifier Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-Activator: org.eclipse.papyrus.uml.nattable.xtext.valuespecification.Activator diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/pom.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/pom.xml index 87ac6f7a864..eb98f64af65 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/pom.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/pom.xml @@ -8,6 +8,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.nattable.xtext.valuespecification</artifactId> - <version>4.0.0-SNAPSHOT</version> + <version>5.0.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file 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 25ddd9a7677..215fdac165c 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 @@ -13,14 +13,14 @@ Export-Package: org.eclipse.papyrus.uml.nattable, org.eclipse.papyrus.uml.nattable.validator, org.eclipse.papyrus.uml.nattable.widget Require-Bundle: org.eclipse.papyrus.uml.tools;bundle-version="[4.0.0,5.0.0)";visibility:=reexport, - org.eclipse.papyrus.infra.emf.nattable;bundle-version="[4.0.0,5.0.0)";visibility:=reexport, + org.eclipse.papyrus.infra.emf.nattable;bundle-version="[5.0.0,6.0.0)";visibility:=reexport, org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.uml.internationalization.utils;bundle-version="[1.0.0,2.0.0)", org.eclipse.papyrus.infra.properties.ui;bundle-version="[3.0.0,4.0.0)" Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy -Bundle-Version: 4.0.100.qualifier +Bundle-Version: 5.0.0.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 4df401f4f09..48b2b3f55e1 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/pom.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/pom.xml @@ -8,6 +8,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.nattable</artifactId> - <version>4.0.100-SNAPSHOT</version> + <version>5.0.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF index 8c2b02e950d..0119f99ffa6 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF @@ -26,11 +26,11 @@ Require-Bundle: org.eclipse.papyrus.uml.profile;bundle-version="[3.0.0,4.0.0)";v org.eclipse.papyrus.uml.appearance;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.uml.diagram.common;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, org.eclipse.papyrus.uml.diagram.stereotype.edition;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, - org.eclipse.papyrus.infra.emf.nattable;bundle-version="[4.0.0,5.0.0)", + org.eclipse.papyrus.infra.emf.nattable;bundle-version="[5.0.0,6.0.0)", org.eclipse.papyrus.uml.nattable.stereotype.display;bundle-version="[3.0.0,4.0.0)", org.eclipse.nebula.widgets.richtext;bundle-version="[1.0.0,2.0.0)", org.eclipse.papyrus.uml.ui;bundle-version="[1.2.0,2.0.0)", - org.eclipse.papyrus.infra.nattable;bundle-version="[5.0.0,6.0.0)", + org.eclipse.papyrus.infra.nattable;bundle-version="[6.0.0,7.0.0)", org.eclipse.jface;bundle-version="[3.12.0,4.0.0)", org.eclipse.papyrus.infra.widgets;bundle-version="[3.1.0,4.0.0)", org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)", @@ -38,7 +38,7 @@ Require-Bundle: org.eclipse.papyrus.uml.profile;bundle-version="[3.0.0,4.0.0)";v org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.papyrus.uml.properties.constraints" -Bundle-Version: 3.1.0.qualifier +Bundle-Version: 3.1.100.qualifier Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-Activator: org.eclipse.papyrus.uml.properties.Activator diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml index 7e68d88667f..8364f33f743 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml @@ -8,6 +8,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.properties</artifactId> - <version>3.1.0-SNAPSHOT</version> + <version>3.1.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file |