Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
af3
kernel
Commits
a795e081
Commit
a795e081
authored
10 years ago
by
Vincent Aravantinos
Browse files
Options
Downloads
Patches
Plain Diff
fix attempt via a gross ugly hack. See EcoreUtils.copy
refs 2049
parent
af825495
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java
+51
-1
51 additions, 1 deletion
...runk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java
with
51 additions
and
1 deletion
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java
+
51
−
1
View file @
a795e081
...
...
@@ -24,12 +24,15 @@ import java.util.List;
import
org.eclipse.emf.common.notify.Notification
;
import
org.eclipse.emf.common.notify.impl.NotificationImpl
;
import
org.eclipse.emf.common.util.AbstractEList
;
import
org.eclipse.emf.common.util.BasicEList
;
import
org.eclipse.emf.common.util.ECollections
;
import
org.eclipse.emf.common.util.EList
;
import
org.eclipse.emf.common.util.TreeIterator
;
import
org.eclipse.emf.ecore.EObject
;
import
org.eclipse.emf.ecore.EReference
;
import
org.eclipse.emf.ecore.util.EcoreUtil
;
import
org.eclipse.emf.ecore.util.EcoreUtil.Copier
;
/**
* Utility methods for dealing with .ecore models. These methods should be used
...
...
@@ -38,7 +41,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
* @author ratiu
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating
GREEN
Hash:
AC63FE26BD51D0F6080CC6D0AD2508E3
* @ConQAT.Rating
YELLOW
Hash:
1B2A42365F56FD17DA8B4C77AD1793C7
*/
public
class
EcoreUtils
{
...
...
@@ -54,6 +57,7 @@ public class EcoreUtils {
/**
* Converts an EList of a given type into an EList of one of its subtypes.
* Utility method to avoid unnecessary casts.
* FIXME(VA) Redundant with JavaUtils.convertList
*
* @param targetClass
* - the class representing the subtype
...
...
@@ -217,4 +221,50 @@ public class EcoreUtils {
public
static
void
postRefreshNotification
(
EObject
eObject
)
{
eObject
.
eNotify
(
refreshNotification
);
}
/**
* Hack to the EcoreUtils copier which removes some duplicates in some lists, whereas we DO NOT
* want it.
*/
private
static
class
HackedCopier
extends
EcoreUtil
.
Copier
{
/** {@inheritDoc} */
@Override
protected
void
copyContainment
(
EReference
eReference
,
EObject
eObject
,
EObject
copyEObject
)
{
if
(
eObject
.
eIsSet
(
eReference
))
{
if
(
eReference
.
isMany
())
{
@SuppressWarnings
(
"unchecked"
)
List
<
EObject
>
source
=
(
List
<
EObject
>)
eObject
.
eGet
(
eReference
);
@SuppressWarnings
(
"unchecked"
)
AbstractEList
<
EObject
>
target
=
(
AbstractEList
<
EObject
>)
copyEObject
.
eGet
(
getTarget
(
eReference
));
if
(
source
.
isEmpty
())
{
target
.
clear
();
}
else
{
// Here is the hack: we use addAllUnique instead of addAll!
target
.
addAllUnique
(
copyAll
(
source
));
}
}
else
{
EObject
childEObject
=
(
EObject
)
eObject
.
eGet
(
eReference
);
copyEObject
.
eSet
(
getTarget
(
eReference
),
childEObject
==
null
?
null
:
copy
(
childEObject
));
}
}
}
}
/**
* Returns a self-contained copy of the eObject.
*
* @param eObject
* the object to copy.
* @return the copy.
* @see Copier
*/
public
static
<
T
extends
EObject
>
T
copy
(
T
eObject
)
{
Copier
copier
=
new
HackedCopier
();
EObject
result
=
copier
.
copy
(
eObject
);
copier
.
copyReferences
();
@SuppressWarnings
(
"unchecked"
)
T
t
=
(
T
)
result
;
return
t
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment