Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 399678 - [CDO] Avoid treating EObjects that are Resources as model elements
Summary: [CDO] Avoid treating EObjects that are Resources as model elements
Status: RESOLVED FIXED
Alias: None
Product: Papyrus
Classification: Modeling
Component: Core (show other bugs)
Version: 0.10.0   Edit
Hardware: PC Mac OS X
: P2 enhancement (vote)
Target Milestone: M6   Edit
Assignee: Christian Damus CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 290952
  Show dependency tree
 
Reported: 2013-01-31 15:26 EST by Christian Damus CLA
Modified: 2013-04-12 18:08 EDT (History)
0 users

See Also:
give.a.damus: kepler+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Damus CLA 2013-01-31 15:26:03 EST
The assumption that all EObjects are model elements (either UML elements, stereotype instances, diagram views, table instances, etc.) is invalid in a CDO context because CDO resources are EObjects.

So, a more accurate determination of what is a model element is that it is an EObject that is not also a Resource.

To that end, Papyrus code that tests whether objects are EObjects needs to be reviews to see whether it should be more discriminating.  This should be supported by new utilities that abstract the notion (possibly with extensibility) of what constitutes a "model element".
Comment 1 Christian Damus CLA 2013-01-31 15:26:45 EST
I'll take this on (work already in progress).
Comment 2 Christian Damus CLA 2013-01-31 16:10:30 EST
Committed in r9980:

Added EMFHelper utilities:

  * boolean isEMFModelElement(Object) - is an object an EMF model element?
  * EObject asEMFModelElement(Object) - coerce an object to an EMF model
      element, if appropriate

These utilities currently check only that the object is an EObject and that it is not a Resource.  This excludes CDOResources.

Also, the existing EObject getEObject(Object) API is updated to filter on the "is model element" condition.  This fixes numerous exceptions and other problems in the UI, where for example the calculation of menu enablement bombs on attempts to work with the eResource of an EObject (which for a CDOResource doesn't make sense).

These new utilities are employed in listeners that manipulate and/or clean up stereotype applications, as they would react to changes in CDOResources at inopportune times (e.g., trying to get the eContainer() or eResource() of a CDOResource that has been unloaded when a transaction is closed, which then fails because the CDOResource is a dead object after the transaction has been closed).
Comment 3 Christian Damus CLA 2013-04-12 18:08:08 EDT
The known problem use cases have been addressed.  Any further issues will have to be raised as bugs as they are discovered.