[548631] Avoid breaking compat in DialectServices.copyRepresentation()
Keep a version of DialectServices.copyRepresentation() which takes a
DRepresentation available, but deprecated, to avoid an API break that
is not strictly required.
But: 548631
Change-Id: I5cc0790a6b1ec50cbf2b60d552e829d466c5320d
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index 6637e46..15a9157 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -187,9 +187,10 @@
<code>DAnalysis</code>.
</li>
<li><span class="label label-info">Modified</span> The method
- <code>org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices.copyRepresentation(DRepresentation, String, Session, IProgressMonitor)</code> has its first parameter changed from
- <code>DRepresentation</code> to
- <code>DRepresentationDescriptor</code>. Also the constructor of
+ <code>org.eclipse.sirius.business.api.dialect.DialectServices.copyRepresentation(DRepresentation, String, Session, IProgressMonitor)</code> is now deprecated. It is recommended to use the new alternative,
+ <code>org.eclipse.sirius.business.api.dialect.DialectServices.copyRepresentation(DRepresentationDescriptor, String, Session, IProgressMonitor)</code> which is identical except that it take a
+ <code>DRepresentationDescriptor</code> instead of a
+ <code>DRepresentation</code>. Also the constructor of
<code>org.eclipse.sirius.business.api.dialect.command.CopyRepresentationCommand</code> has been modified. Its parameter
<code>Collection<DRepresentation> representations</code> has been replaced by
<code>Collection<DRepresentationDescriptor> representationDescriptors</code>. Theses changes were made to be able to copy the name that is now only in
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index ce3268a..564118f 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -27,7 +27,7 @@
* <span class="label label-success">Added</span> The method @org.eclipse.sirius.business.api.query.DViewQuery.getLoadedRepresentationsDescriptors()@ has been added and allows to retrieve all loaded @DRepresentationDescriptor@ in a @DView@.
* <span class="label label-success">Added</span> The method @org.eclipse.sirius.business.api.session.AbstractSavingPolicy.hasDifferentSerialization(Resource, Map)@ has been extracted from internal subclasses. It is able to tell whether a save operation on a resource can succeed or not, and if the resulting file will change. It should be used with care as it basically saves the resource in a temporary resource to know whether it will change the file or not.
* <span class="label label-success">Added</span> The method @org.eclipse.sirius.business.api.query.DRepresentationQuery.findDescriptorFromAnalysis(DAnalysis)@ has been added to provide a way to look up for a @DRepresentationDescriptor@ in a given @DAnalysis@.
-* <span class="label label-info">Modified</span> The method @org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices.copyRepresentation(DRepresentation, String, Session, IProgressMonitor)@ has its first parameter changed from @DRepresentation@ to @DRepresentationDescriptor@. Also the constructor of @org.eclipse.sirius.business.api.dialect.command.CopyRepresentationCommand@ has been modified. Its parameter @Collection<DRepresentation> representations@ has been replaced by @Collection<DRepresentationDescriptor> representationDescriptors@. Theses changes were made to be able to copy the name that is now only in @DRepresentationDescriptor@.
+* <span class="label label-info">Modified</span> The method @org.eclipse.sirius.business.api.dialect.DialectServices.copyRepresentation(DRepresentation, String, Session, IProgressMonitor)@ is now deprecated. It is recommended to use the new alternative, @org.eclipse.sirius.business.api.dialect.DialectServices.copyRepresentation(DRepresentationDescriptor, String, Session, IProgressMonitor)@ which is identical except that it take a @DRepresentationDescriptor@ instead of a @DRepresentation@. Also the constructor of @org.eclipse.sirius.business.api.dialect.command.CopyRepresentationCommand@ has been modified. Its parameter @Collection<DRepresentation> representations@ has been replaced by @Collection<DRepresentationDescriptor> representationDescriptors@. Theses changes were made to be able to copy the name that is now only in @DRepresentationDescriptor@.
* <span class="label label-info">Modified</span> The @DocumentedElement@ interface providing a description for the representation implemented by @DRepresentation@ is now implemented by @DRepresentationDescriptor@. Also the @name@ EAttribute in @DRepresentation@ has been added to @DRepresentationDescriptor@. These changes allows to use these information without loading associated representation. The @name@ and @description@ attributes on @DREpresentation@ are now transient and volatile and computed from @DRepresentationDescriptor@
* <span class="label label-info">Modified</span>The class @org.eclipse.sirius.business.api.helper.SiriusHelper@ has been renamed into @org.eclipse.sirius.business.api.helper.RepresentationHelper@.
* <span class="label label-danger">Removed</span> In @org.eclipse.sirius.business.api.session.CustomDataConstants@, the constants @DREPRESENTATION@ and @DREPRESENTATION_DESCRIPTOR@ has been removed because they are not available anymore in custom data.
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectServices.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectServices.java
index 4105ba5..8601b6d 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectServices.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectServices.java
@@ -21,6 +21,7 @@
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.sirius.business.api.dialect.description.IInterpretedExpressionQuery;
import org.eclipse.sirius.business.api.helper.task.AbstractCommandTask;
+import org.eclipse.sirius.business.api.query.DRepresentationQuery;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor;
import org.eclipse.sirius.ext.base.Option;
@@ -73,6 +74,31 @@
/**
* Create a new representation from a given one (copy) and keep it in the given session.
*
+ * @param representation
+ * the representation to copy.
+ * @param name
+ * name of the newly representation.
+ * @param session
+ * session used to keep the data.
+ * @param monitor
+ * to track progress.
+ * @return the new representation .
+ * @since 0.9.0
+ * @deprecated Use {@link #copyRepresentation(DRepresentationDescriptor, String, Session, IProgressMonitor)} instead.
+ */
+ @Deprecated
+ default DRepresentation copyRepresentation(DRepresentation representation, String name, Session session, IProgressMonitor monitor) {
+ DRepresentationDescriptor descriptor = new DRepresentationQuery(representation, session).getRepresentationDescriptor();
+ if (descriptor != null) {
+ return this.copyRepresentation(descriptor, name, session, monitor);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Create a new representation from a given one (copy) and keep it in the given session.
+ *
* @param representationDescriptor
* the representation descriptor containing the representation to copy.
* @param name
@@ -82,7 +108,7 @@
* @param monitor
* to track progress.
* @return the new representation .
- * @since 0.9.0
+ * @since 6.3.0
*/
DRepresentation copyRepresentation(DRepresentationDescriptor representationDescriptor, String name, Session session, IProgressMonitor monitor);