Add variability factory for creating elements from UI.
Change-Id: I7de06ceecca6b7be878c371125c2a5e3a6140bee
Signed-off-by: Stefan Schulz <schulzs@mathematik.uni-marburg.de>
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/commands/VariabilityAttributeCreateCommand.java b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/commands/VariabilityAttributeCreateCommand.java
index a5bf813..9d879bc 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/commands/VariabilityAttributeCreateCommand.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/commands/VariabilityAttributeCreateCommand.java
@@ -16,6 +16,7 @@
import org.eclipse.emf.henshin.model.Rule;
import org.eclipse.emf.henshin.model.util.HenshinModelCleaner;
import org.eclipse.emf.henshin.variability.configuration.ui.helpers.VariabilityModelHelper;
+import org.eclipse.emf.henshin.variability.wrapper.TransactionalVariabilityFactory;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityFactory;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.diagram.ui.menus.PopupMenu;
@@ -72,7 +73,7 @@
}
}
attribute.setValue(param!=null ? param.getName() : String.valueOf(type.getDefaultValue()));
- VariabilityFactory.createVariabilityAttribute(attribute).setPresenceCondition(VariabilityModelHelper.getPresenceCondition(configuration));
+ TransactionalVariabilityFactory.INSTANCE.createVariabilityAttribute(attribute).setPresenceCondition(VariabilityModelHelper.getPresenceCondition(configuration));
node.getAttributes().add(attribute);
// and to all mapped nodes...
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/commands/VariabilityEdgeCreateCommand.java b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/commands/VariabilityEdgeCreateCommand.java
index 59cf2cd..cfe3652 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/commands/VariabilityEdgeCreateCommand.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/commands/VariabilityEdgeCreateCommand.java
@@ -7,6 +7,7 @@
import org.eclipse.emf.henshin.diagram.edit.commands.EdgeCreateCommand;
import org.eclipse.emf.henshin.model.Edge;
import org.eclipse.emf.henshin.variability.configuration.ui.helpers.VariabilityModelHelper;
+import org.eclipse.emf.henshin.variability.wrapper.TransactionalVariabilityFactory;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityFactory;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
@@ -33,7 +34,7 @@
CommandResult result = super.doExecuteWithResult(monitor, info);
Edge edge = (Edge) result.getReturnValue();
String pc = VariabilityModelHelper.getPresenceConditionForNewEdge(edge, configuration);
- VariabilityFactory.createVariabilityEdge(edge).setPresenceCondition(pc);
+ TransactionalVariabilityFactory.INSTANCE.createVariabilityEdge(edge).setPresenceCondition(pc);
return result;
}
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/commands/VariabilityNodeCreateCommand.java b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/commands/VariabilityNodeCreateCommand.java
index 33a53f9..36bbfee 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/commands/VariabilityNodeCreateCommand.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/commands/VariabilityNodeCreateCommand.java
@@ -12,6 +12,7 @@
import org.eclipse.emf.henshin.model.Node;
import org.eclipse.emf.henshin.model.Rule;
import org.eclipse.emf.henshin.variability.configuration.ui.helpers.VariabilityModelHelper;
+import org.eclipse.emf.henshin.variability.wrapper.TransactionalVariabilityFactory;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityFactory;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
@@ -38,7 +39,7 @@
IAdaptable info) throws ExecutionException {
CommandResult result = super.doExecuteWithResult(monitor, info);
Node node = (Node) result.getReturnValue();
- if (node != null) VariabilityFactory.createVariabilityNode(node).setPresenceCondition(VariabilityModelHelper.getPresenceCondition(configuration));
+ if (node != null) TransactionalVariabilityFactory.INSTANCE.createVariabilityNode(node).setPresenceCondition(VariabilityModelHelper.getPresenceCondition(configuration));
return result;
}
@@ -68,7 +69,7 @@
|| (newNode.getType()).isSuperTypeOf(refType)) {
if (rule.canCreateEdge(container, newNode, ref)) {
Edge edge = rule.createEdge(container, newNode, ref);
- VariabilityFactory.createVariabilityEdge(edge).setPresenceCondition(VariabilityModelHelper.getPresenceCondition(configuration));
+ TransactionalVariabilityFactory.INSTANCE.createVariabilityEdge(edge).setPresenceCondition(VariabilityModelHelper.getPresenceCondition(configuration));
return;
}
}
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/helpers/RuleEditPartVisibilityHelper.java b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/helpers/RuleEditPartVisibilityHelper.java
index acf5a72..2ca0d23 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/helpers/RuleEditPartVisibilityHelper.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/helpers/RuleEditPartVisibilityHelper.java
@@ -11,7 +11,7 @@
import org.eclipse.emf.henshin.model.Edge;
import org.eclipse.emf.henshin.model.GraphElement;
import org.eclipse.emf.henshin.variability.matcher.FeatureExpression;
-import org.eclipse.emf.henshin.variability.wrapper.VariabilityFactory;
+import org.eclipse.emf.henshin.variability.wrapper.TransactionalVariabilityFactory;
import aima.core.logic.propositional.parsing.ast.Sentence;
import configuration.Configuration;
@@ -46,7 +46,7 @@
@Override
public boolean shouldConceal(GraphElement graphElement) {
- String pc = VariabilityFactory.createVariabilityGraphElement(graphElement).getPresenceCondition();
+ String pc = TransactionalVariabilityFactory.INSTANCE.createVariabilityGraphElement(graphElement).getPresenceCondition();
return pc != null && !pc.isEmpty();
}
}
@@ -62,7 +62,7 @@
@Override
public boolean shouldConceal(GraphElement graphElement) {
boolean result = REVEAL;
- String pc = VariabilityFactory.createVariabilityGraphElement(graphElement).getPresenceCondition();
+ String pc = TransactionalVariabilityFactory.INSTANCE.createVariabilityGraphElement(graphElement).getPresenceCondition();
if (pc != null && !pc.isEmpty()) {
Sentence expr = FeatureExpression.getExpr(pc);
result = FeatureExpression.contradicts(expr, configurationExpr);
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/helpers/VariabilityModelHelper.java b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/helpers/VariabilityModelHelper.java
index 7fd0456..b3ec55f 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/helpers/VariabilityModelHelper.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/helpers/VariabilityModelHelper.java
@@ -7,6 +7,7 @@
import org.eclipse.emf.henshin.model.Rule;
import org.eclipse.emf.henshin.variability.matcher.FeatureExpression;
import org.eclipse.emf.henshin.variability.util.Logic;
+import org.eclipse.emf.henshin.variability.wrapper.TransactionalVariabilityFactory;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityFactory;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityNode;
import org.eclipse.gmf.runtime.notation.impl.ShapeImpl;
@@ -35,7 +36,7 @@
}
public static Sentence getFeatureExpression(Configuration configuration) {
- Sentence expr = FeatureExpression.getExpr(VariabilityFactory.createVariabilityRule(configuration.getRule()).getFeatureModel());
+ Sentence expr = FeatureExpression.getExpr(TransactionalVariabilityFactory.INSTANCE.createVariabilityRule(configuration.getRule()).getFeatureModel());
for (Feature vp : configuration.getFeatures()) {
if (vp.getBinding() == FeatureBinding.TRUE) {
expr = FeatureExpression.and(expr, FeatureExpression.getExpr(vp.getName()));
@@ -66,7 +67,7 @@
}
private static Sentence getFeatureExpression(Configuration configuration, Feature feature) {
- Sentence expr = FeatureExpression.getExpr(VariabilityFactory.createVariabilityRule(configuration.getRule()).getFeatureModel());
+ Sentence expr = FeatureExpression.getExpr(TransactionalVariabilityFactory.INSTANCE.createVariabilityRule(configuration.getRule()).getFeatureModel());
if (expr == null)
expr = FeatureExpression.getExpr(Logic.TRUE);
for (Feature vp : configuration.getFeatures()) {
@@ -102,8 +103,8 @@
public static String getPresenceConditionForNewEdge(Edge edge, Configuration configuration) {
String configPC = getPresenceCondition(configuration);
- VariabilityNode varSource = VariabilityFactory.createVariabilityNode(edge.getSource());
- VariabilityNode varTarget = VariabilityFactory.createVariabilityNode(edge.getTarget());
+ VariabilityNode varSource = TransactionalVariabilityFactory.INSTANCE.createVariabilityNode(edge.getSource());
+ VariabilityNode varTarget = TransactionalVariabilityFactory.INSTANCE.createVariabilityNode(edge.getTarget());
Sentence config = FeatureExpression.getExpr(configPC);
Sentence source = FeatureExpression.getExpr(varSource.getPresenceCondition());
Sentence target = FeatureExpression.getExpr(varTarget.getPresenceCondition());
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/providers/ConfigurationProvider.java b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/providers/ConfigurationProvider.java
index 11a5c95..29878df 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/providers/ConfigurationProvider.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/configuration/ui/providers/ConfigurationProvider.java
@@ -9,7 +9,7 @@
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.henshin.model.Rule;
-import org.eclipse.emf.henshin.variability.wrapper.VariabilityFactory;
+import org.eclipse.emf.henshin.variability.wrapper.TransactionalVariabilityFactory;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityRule;
import configuration.Configuration;
@@ -135,10 +135,10 @@
Configuration result = null;
if (rule != null) {
- VariabilityRule varRule = VariabilityFactory.createVariabilityRule(rule);
+ VariabilityRule varRule = TransactionalVariabilityFactory.INSTANCE.createVariabilityRule(rule);
ConfigurationFactory fac = ConfigurationFactoryImpl.init();
result = fac.createConfiguration();
- result.setRule(rule);
+ result.setRule(varRule);
String featureModel = varRule.getFeatureModel();
EList<Feature> variabilityPoints = result.getFeatures();
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/ui/views/ObservableFeatureModelValue.java b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/ui/views/ObservableFeatureModelValue.java
index 714b014..3468df0 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/ui/views/ObservableFeatureModelValue.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/ui/views/ObservableFeatureModelValue.java
@@ -8,6 +8,7 @@
import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.emf.databinding.internal.EMFObservableValueDecorator;
import org.eclipse.emf.henshin.model.Rule;
+import org.eclipse.emf.henshin.variability.wrapper.TransactionalVariabilityFactory;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityConstants;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityFactory;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityRule;
@@ -121,7 +122,7 @@
EMFObservableValueDecorator emfValue = (EMFObservableValueDecorator) this.value;
if (emfValue.getObserved() != null && emfValue.getObserved() instanceof Rule) {
- return VariabilityFactory.createVariabilityRule((Rule) emfValue.getObserved());
+ return TransactionalVariabilityFactory.INSTANCE.createVariabilityRule((Rule) emfValue.getObserved());
}
}
return null;
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/ui/views/VariabilityView.java b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/ui/views/VariabilityView.java
index 1850c8a..e71a601 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/ui/views/VariabilityView.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.configuration.ui/src/org/eclipse/emf/henshin/variability/ui/views/VariabilityView.java
@@ -40,6 +40,7 @@
import org.eclipse.emf.henshin.variability.ui.viewer.util.FeatureViewerComparator;
import org.eclipse.emf.henshin.variability.ui.viewer.util.FeatureViewerContentProvider;
import org.eclipse.emf.henshin.variability.ui.viewer.util.FeatureViewerNameEditingSupport;
+import org.eclipse.emf.henshin.variability.wrapper.TransactionalVariabilityFactory;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityConstants;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityFactory;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityRule;
@@ -186,7 +187,7 @@
Rule rule = VariabilityModelHelper.getRuleForEditPart(selectedRuleEditPart);
NameDialog dialog = new NameDialog(getViewSite().getShell(), "Feature",
- VariabilityFactory.createVariabilityRule(rule).getFeatures());
+ TransactionalVariabilityFactory.INSTANCE.createVariabilityRule(rule).getFeatures());
if (dialog.open() == Window.OK) {
String featureName = dialog.getName().trim();
@@ -584,7 +585,7 @@
if (isChecked() && selectedRuleEditPart != null) {
super.run();
RuleEditPartVisibilityHelper.showConfiguredRule(selectedRuleEditPart, config,
- VariabilityFactory.createVariabilityRule(config.getRule()).getFeatureModel());
+ TransactionalVariabilityFactory.INSTANCE.createVariabilityRule(config.getRule()).getFeatureModel());
if (creationMode == CreationMode.SELECTION) {
updateEditPolicy(selectedRuleEditPart);
}
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.configuration/src/configuration/Configuration.java b/plugins/variability/org.eclipse.emf.henshin.variability.configuration/src/configuration/Configuration.java
index 598b9a5..272aa32 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.configuration/src/configuration/Configuration.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.configuration/src/configuration/Configuration.java
@@ -49,11 +49,21 @@
* <!-- end-user-doc -->
* @param value the new value of the '<em>Rule</em>' reference.
* @see #getRule()
- * @generated
+ * @generated NOT
*/
void setRule(Rule value);
/**
+ * Sets the value of the '{@link configuration.Configuration#getRule <em>Rule</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Rule</em>' reference.
+ * @see #getRule()
+ * @generated NOT
+ */
+ void setRule(VariabilityRule value);
+
+ /**
* Returns the value of the '<em><b>Features</b></em>' reference list.
* The list contents are of type {@link configuration.Feature}.
* <!-- begin-user-doc -->
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.configuration/src/configuration/impl/ConfigurationImpl.java b/plugins/variability/org.eclipse.emf.henshin.variability.configuration/src/configuration/impl/ConfigurationImpl.java
index c26b84b..56cf8ef 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.configuration/src/configuration/impl/ConfigurationImpl.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.configuration/src/configuration/impl/ConfigurationImpl.java
@@ -17,8 +17,8 @@
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.henshin.model.Annotation;
import org.eclipse.emf.henshin.model.Rule;
-import org.eclipse.emf.henshin.variability.wrapper.VariabilityConstants;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityFactory;
+import org.eclipse.emf.henshin.variability.wrapper.VariabilityConstants;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityHelper;
import org.eclipse.emf.henshin.variability.wrapper.VariabilityRule;
@@ -150,18 +150,27 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated
+ * @generated NOT
*/
@Override
public void setRule(Rule newRule) {
+ setRule(VariabilityFactory.INSTANCE.createVariabilityRule(newRule));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated NOT
+ */
+ @Override
+ public void setRule(VariabilityRule newRule) {
Rule oldRule = rule;
if (featuresContentAdapter != null) {
oldRule.eResource().getResourceSet().eAdapters().remove(featuresContentAdapter);
} else {
featuresContentAdapter = new EFeatureModelContentAdapter();
}
-
- rule = VariabilityFactory.createVariabilityRule(newRule);
+ rule = newRule;
rule.eResource().getResourceSet().eAdapters().add(featuresContentAdapter);
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackage.CONFIGURATION__RULE, oldRule, rule));
@@ -182,7 +191,7 @@
private void updateAllFeatures() {
Map<String, FeatureBinding> bindings = getBindings();
- List<String> annotationFeatures = VariabilityFactory.createVariabilityRule(rule).getFeatures();
+ List<String> annotationFeatures = VariabilityFactory.INSTANCE.createVariabilityRule(rule).getFeatures();
EList<Feature> oldFeatures = getFeatures();
features.clear();
for (String featureName : annotationFeatures) {
@@ -201,7 +210,7 @@
@Override
public boolean addFeature(Feature feature) {
disableContentAdapter();
- List<String> annotationFeatures = VariabilityFactory.createVariabilityRule(rule).getFeatures();
+ List<String> annotationFeatures = VariabilityFactory.INSTANCE.createVariabilityRule(rule).getFeatures();
String featureAnnotationValue = "";
if (annotationFeatures != null && !annotationFeatures.isEmpty()) {
featureAnnotationValue = String.join(", ", annotationFeatures);
@@ -236,7 +245,7 @@
public boolean removeFeature(final Feature feature) {
disableContentAdapter();
if (feature != null) {
- List<String> annotationFeatures = VariabilityFactory.createVariabilityRule(rule).getFeatures();
+ List<String> annotationFeatures = VariabilityFactory.INSTANCE.createVariabilityRule(rule).getFeatures();
String featureAnnotationValue = "";
for (String annotationFeature : annotationFeatures) {
if (!annotationFeature.equals(feature.getName())) {
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.mergein.refactoring/src/org/eclipse/emf/henshin/variability/mergein/refactoring/logic/NewMerger.java b/plugins/variability/org.eclipse.emf.henshin.variability.mergein.refactoring/src/org/eclipse/emf/henshin/variability/mergein/refactoring/logic/NewMerger.java
index 37d80b2..713651b 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.mergein.refactoring/src/org/eclipse/emf/henshin/variability/mergein/refactoring/logic/NewMerger.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.mergein.refactoring/src/org/eclipse/emf/henshin/variability/mergein/refactoring/logic/NewMerger.java
@@ -198,7 +198,7 @@
private void setFeatureModel() {
String featureModel = XOR;
- VariabilityRule masterVarRule = VariabilityFactory.createVariabilityRule(masterRule);
+ VariabilityRule masterVarRule = VariabilityFactory.INSTANCE.createVariabilityRule(masterRule);
masterVarRule.addFeature(masterVarRule.getName());
featureModel += BRACKET_LEFT;
featureModel += getCondition(masterRule);
@@ -208,7 +208,7 @@
masterVarRule.addFeature(rule.getName());
}
featureModel += BRACKET_RIGHT;
- VariabilityFactory.createVariabilityRule(masterRule).setFeatureModel(featureModel);
+ VariabilityFactory.INSTANCE.createVariabilityRule(masterRule).setFeatureModel(featureModel);
}
private void setFeatures() {
@@ -219,7 +219,7 @@
}
String value = sb.toString();
value = value.substring(0, value.length()-1);
- VariabilityFactory.createVariabilityRule(masterRule).setFeatures(value);
+ VariabilityFactory.INSTANCE.createVariabilityRule(masterRule).setFeatures(value);
}
private void addNestedCondition2Graph(NestedCondition condition, boolean nac) {
@@ -543,10 +543,10 @@
private void setPresenceCondition(MergeRuleElement mre) {
for (GraphElement elem : mre.getReferenceElements()) {
- String presenceCondition = VariabilityFactory.createVariabilityGraphElement(elem).getPresenceCondition();
+ String presenceCondition = VariabilityFactory.INSTANCE.createVariabilityGraphElement(elem).getPresenceCondition();
if (elem.getGraph().isNestedCondition()) {
NestedCondition condition = (NestedCondition) elem.getGraph().eContainer();
- VariabilityFactory.createVariabilityNestedCondition(condition).setPresenceCondition(presenceCondition);
+ VariabilityFactory.INSTANCE.createVariabilityNestedCondition(condition).setPresenceCondition(presenceCondition);
}
}
}
@@ -574,7 +574,7 @@
if (mre.getReferenceElements().size() != numberOfRules) {
for (GraphElement elem : mre.getReferenceElements()) {
String condition = getCondition(mre);
- VariabilityFactory.createVariabilityGraphElement(elem).setPresenceCondition(condition);
+ VariabilityFactory.INSTANCE.createVariabilityGraphElement(elem).setPresenceCondition(condition);
}
}
}
@@ -594,19 +594,19 @@
private void setPresenceCondition(MergeNAC nac, Graph g) {
String condition = getCondition(nac);
- VariabilityFactory.createVariabilityNestedCondition(((NestedCondition) g.eContainer())).setPresenceCondition(condition);
+ VariabilityFactory.INSTANCE.createVariabilityNestedCondition(((NestedCondition) g.eContainer())).setPresenceCondition(condition);
for (Node node : g.getNodes()) {
if (node.getActionNode() == node)
- VariabilityFactory.createVariabilityNode(node).setPresenceCondition(condition);
+ VariabilityFactory.INSTANCE.createVariabilityNode(node).setPresenceCondition(condition);
for (Attribute attribute : node.getAttributes()) {
if (attribute.getActionAttribute() == attribute)
- VariabilityFactory.createVariabilityAttribute(attribute).setPresenceCondition(condition);
+ VariabilityFactory.INSTANCE.createVariabilityAttribute(attribute).setPresenceCondition(condition);
}
}
for (Edge edge : g.getEdges()) {
if (edge.getActionEdge() == edge)
- VariabilityFactory.createVariabilityEdge(edge).setPresenceCondition(condition);
+ VariabilityFactory.INSTANCE.createVariabilityEdge(edge).setPresenceCondition(condition);
}
}
@@ -700,7 +700,7 @@
injective.add(rule);
}
if (injective.isEmpty()) {
- VariabilityFactory.createVariabilityRule(masterRule).setInjectiveMatchingPresenceCondition("false");
+ VariabilityFactory.INSTANCE.createVariabilityRule(masterRule).setInjectiveMatchingPresenceCondition("false");
} else if (injective.size() == mergeRule.getRules().size()) {
// NOOP, is default.
} else {
@@ -708,7 +708,7 @@
for (int i = 1; i < injective.size(); i++) {
condition += OR + getCondition(injective.get(i));
}
- VariabilityFactory.createVariabilityRule(masterRule).setInjectiveMatchingPresenceCondition(condition);
+ VariabilityFactory.INSTANCE.createVariabilityRule(masterRule).setInjectiveMatchingPresenceCondition(condition);
}
}
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.mergein.refactoring/src/org/eclipse/emf/henshin/variability/mergein/refactoring/logic/NewMergerTester.java b/plugins/variability/org.eclipse.emf.henshin.variability.mergein.refactoring/src/org/eclipse/emf/henshin/variability/mergein/refactoring/logic/NewMergerTester.java
index 4197b36..0bf9ec8 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.mergein.refactoring/src/org/eclipse/emf/henshin/variability/mergein/refactoring/logic/NewMergerTester.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.mergein.refactoring/src/org/eclipse/emf/henshin/variability/mergein/refactoring/logic/NewMergerTester.java
@@ -51,7 +51,7 @@
for (MergeRuleElement mre : mr.getElements()) {
String str = mre.getName() + ":";
for (GraphElement elem : mre.getReferenceElements()) {
- str += " " + elem + "(" + VariabilityFactory.createVariabilityGraphElement(elem).getPresenceCondition() + ")";
+ str += " " + elem + "(" + VariabilityFactory.INSTANCE.createVariabilityGraphElement(elem).getPresenceCondition() + ")";
}
System.out.println(str);
}
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability.test/tests/org/eclipse/emf/henshin/variability/test/VBEngineParameterizedTest.java b/plugins/variability/org.eclipse.emf.henshin.variability.test/tests/org/eclipse/emf/henshin/variability/test/VBEngineParameterizedTest.java
index 5e9fb56..cd48484 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability.test/tests/org/eclipse/emf/henshin/variability/test/VBEngineParameterizedTest.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability.test/tests/org/eclipse/emf/henshin/variability/test/VBEngineParameterizedTest.java
@@ -30,6 +30,9 @@
import org.eclipse.emf.henshin.interpreter.impl.EGraphImpl;
import org.eclipse.emf.henshin.interpreter.impl.EngineImpl;
import org.eclipse.emf.henshin.interpreter.impl.MatchImpl;
+import org.eclipse.emf.henshin.model.Annotation;
+import org.eclipse.emf.henshin.model.GraphElement;
+import org.eclipse.emf.henshin.model.ModelElement;
import org.eclipse.emf.henshin.model.Module;
import org.eclipse.emf.henshin.model.Rule;
import org.eclipse.emf.henshin.model.resource.HenshinResourceSet;
@@ -38,6 +41,8 @@
import org.eclipse.emf.henshin.variability.matcher.VariabilityAwareEngine;
import org.eclipse.emf.henshin.variability.matcher.VariabilityAwareMatch;
import org.eclipse.emf.henshin.variability.util.RuleUtil;
+import org.eclipse.emf.henshin.variability.wrapper.VariabilityFactory;
+import org.eclipse.emf.henshin.variability.wrapper.VariabilityRule;
import org.junit.Test;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@@ -166,6 +171,7 @@
@Test
public void testVBEngine() throws InconsistentRuleException {
EGraphImpl graph = new EGraphImpl(data.resource);
+ //VariabilityRule varRule = VariabilityFactory.INSTANCE.createVariabilityRule(data.rule);
VariabilityAwareEngine vbEngine = new VariabilityAwareEngine(data.rule, graph);
Set<VariabilityAwareMatch> matches = vbEngine.findMatches();
int numberOfMatches = matches.size();
@@ -195,6 +201,26 @@
}
}
}
+
+ private void compareRules(Rule rule1, Rule rule2) {
+ //Compare Annotations
+ for (Annotation anno : rule1.getAnnotations()) {
+ if (!containsAnnotation(rule2, anno.getKey(), anno.getValue())) {
+ System.out.println("Rule 2 does not contain Annotation " + anno.getKey() + " - " + anno.getValue());
+ }
+ }
+ }
+
+ private boolean containsAnnotation(ModelElement modelElement, String key, String value) {
+ for (Annotation anno : modelElement.getAnnotations()) {
+ if (anno.getKey().equals(key) &&
+ ((anno.getValue() == null && value == null) || anno.getValue().equals(value)) &&
+ ((anno.getValue() == null && value == null) || anno.getValue().equals(value))) {
+ return true;
+ }
+ }
+ return false;
+ }
/**
* Applies the match
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/matcher/RulePreparator.java b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/matcher/RulePreparator.java
index c4c5083..3352794 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/matcher/RulePreparator.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/matcher/RulePreparator.java
@@ -144,7 +144,7 @@
removeFormulaContainingRef.put(rule.getLhs().getFormula(), rule.getLhs().getFormula().eContainingFeature());
} else {
for (NestedCondition ac : rule.getLhs().getNestedConditions()) {
- Sentence acPC = ruleInfo.getExpressions().get(VariabilityFactory.createVariabilityNestedCondition(ac).getPresenceCondition());
+ Sentence acPC = ruleInfo.getExpressions().get(VariabilityFactory.INSTANCE.createVariabilityNestedCondition(ac).getPresenceCondition());
if (rejected.contains(acPC)) {
Formula removeFormula = null;
if (ac.isNAC())
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/matcher/VariabilityAwareEngine.java b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/matcher/VariabilityAwareEngine.java
index e801464..fe7cb52 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/matcher/VariabilityAwareEngine.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/matcher/VariabilityAwareEngine.java
@@ -112,10 +112,10 @@
// in the LHS and the RHS.
for (Mapping mapping : rule.getMappings()) {
- VariabilityNode origin = VariabilityFactory.createVariabilityNode(mapping.getOrigin());
- VariabilityNode image = VariabilityFactory.createVariabilityNode(mapping.getImage());
+ VariabilityNode origin = VariabilityFactory.INSTANCE.createVariabilityNode(mapping.getOrigin());
+ VariabilityNode image = VariabilityFactory.INSTANCE.createVariabilityNode(mapping.getImage());
- if (origin.getPresenceCondition() != image.getPresenceCondition()) {
+ if (!origin.getPresenceCondition().equals(image.getPresenceCondition())) {
image.setPresenceCondition(origin.getPresenceCondition());
}
}
@@ -271,7 +271,7 @@
}
private static boolean presenceConditionEmpty(GraphElement elem) {
- String presenceCondition = VariabilityFactory.createVariabilityGraphElement(elem).getPresenceCondition();
+ String presenceCondition = VariabilityFactory.INSTANCE.createVariabilityGraphElement(elem).getPresenceCondition();
return (presenceCondition == null) || presenceCondition.isEmpty();
}
@@ -285,7 +285,18 @@
public RuleInfo(Rule rule) {
- this.rule = VariabilityFactory.createVariabilityRule(rule);
+ this.rule = VariabilityFactory.INSTANCE.createVariabilityRule(rule);
+ this.featureModel = FeatureExpression.getExpr(this.rule.getFeatureModel());
+ String injective = this.rule.getInjectiveMatchingPresenceCondition();
+ if (injective == null)
+ injective = rule.isInjectiveMatching() + "";
+ this.injectiveMatching = FeatureExpression.getExpr(injective);
+
+ populateMaps();
+ }
+
+ public RuleInfo(VariabilityRule rule) {
+ this.rule = rule;
this.featureModel = FeatureExpression.getExpr(this.rule.getFeatureModel());
String injective = this.rule.getInjectiveMatchingPresenceCondition();
if (injective == null)
@@ -315,7 +326,7 @@
while (it.hasNext()) {
EObject o = it.next();
if (o instanceof Node || o instanceof Edge || o instanceof Attribute) {
- VariabilityGraphElement g = VariabilityFactory.createVariabilityGraphElement((GraphElement) o);
+ VariabilityGraphElement g = VariabilityFactory.INSTANCE.createVariabilityGraphElement((GraphElement) o);
if (!presenceConditionEmpty(g)) {
String pc = g.getPresenceCondition();
Sentence expr = FeatureExpression.getExpr(pc);
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/util/RuleUtil.java b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/util/RuleUtil.java
index 1396994..41bdd0e 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/util/RuleUtil.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/util/RuleUtil.java
@@ -55,7 +55,7 @@
public static boolean isVarRule(Unit unit) {
if (unit instanceof Rule) {
- if (VariabilityFactory.createVariabilityRule((Rule) unit).getFeatureModel() != null) {
+ if (VariabilityFactory.INSTANCE.createVariabilityRule((Rule) unit).getFeatureModel() != null) {
return true;
}
}
@@ -66,7 +66,7 @@
if (!isVarRule(rule)) {
return true;
}
- VariabilityRule varRule = VariabilityFactory.createVariabilityRule(rule);
+ VariabilityRule varRule = VariabilityFactory.INSTANCE.createVariabilityRule(rule);
List<String> features = varRule.getFeatures();
Stream<PropositionSymbol> fm = SymbolCollector
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/AbstractVariabilityFactory.java b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/AbstractVariabilityFactory.java
new file mode 100644
index 0000000..4299d7c
--- /dev/null
+++ b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/AbstractVariabilityFactory.java
@@ -0,0 +1,220 @@
+package org.eclipse.emf.henshin.variability.wrapper;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.henshin.model.Attribute;
+import org.eclipse.emf.henshin.model.Edge;
+import org.eclipse.emf.henshin.model.Graph;
+import org.eclipse.emf.henshin.model.GraphElement;
+import org.eclipse.emf.henshin.model.NestedCondition;
+import org.eclipse.emf.henshin.model.Node;
+import org.eclipse.emf.henshin.model.Rule;
+
+public abstract class AbstractVariabilityFactory {
+
+ private final boolean isTransactional;
+
+ public AbstractVariabilityFactory(boolean isTransactional) {
+ this.isTransactional = isTransactional;
+ }
+
+ /**
+ * Creates a new empty variability-aware {@link org.eclipse.emf.henshin.model.Attribute}.
+ * @return the Attribute.
+ */
+ public VariabilityAttribute createVariabilityAttribute() {
+ return new VariabilityAttribute();
+ }
+
+ /**
+ * Creates a new variability-aware {@link org.eclipse.emf.henshin.model.Attribute} with the given type and value
+ * and adds it to the given {@link org.eclipse.emf.henshin.model.Node}.
+ * @param node the Node to add the Attribute to.
+ * @param type the type of the Attribute.
+ * @param value the value of the Attribute.
+ * @return the Attribute.
+ */
+ public VariabilityAttribute createVariabilityAttribute(Node node, EAttribute type, String value) {
+ return new VariabilityAttribute(node, type, value);
+ }
+
+ /**
+ * Adds variability-awareness to the given {@link org.eclipse.emf.henshin.model.Attribute} by wrapping it in a {@link org.eclipse.emf.henshin.variability.wrapper.VariabilityAttribute}.
+ * If the Attribute is already variability-aware it is not wrapped, but returned instead.
+ * @param attribute the Attribute to add variability-awareness to.
+ * @return the variability-aware Attribute.
+ */
+ public VariabilityAttribute createVariabilityAttribute(Attribute attribute) {
+ if (attribute instanceof VariabilityAttribute) {
+ return (VariabilityAttribute) attribute;
+ } else {
+ return new VariabilityAttribute(attribute, isTransactional);
+ }
+ }
+
+ /**
+ * Creates a new empty variability-aware {@link org.eclipse.emf.henshin.model.Edge}.
+ * @return the Edge.
+ */
+ public VariabilityEdge createVariabilityEdge() {
+ return new VariabilityEdge();
+ }
+
+ /**
+ * Creates a new variability-aware {@link org.eclipse.emf.henshin.model.Edge} between the given {@link org.eclipse.emf.henshin.model.Node}s.
+ * @param source Source node.
+ * @param target Target node.
+ * @param type Edge type.
+ * @return the variability-aware Edge.
+ */
+ public VariabilityEdge createVariabilityEdge(Node source, Node target, EReference type) {
+ return new VariabilityEdge(source, target, type);
+ }
+
+ /**
+ * Adds variability-awareness to the given {@link org.eclipse.emf.henshin.model.Edge} by wrapping it in a {@link org.eclipse.emf.henshin.variability.wrapper.VariabilityEdge}.
+ * If the Edge is already variability-aware it is not wrapped, but returned instead.
+ * @param edge the Edge to add variability-awareness to.
+ * @return the variability-aware Edge.
+ */
+ public VariabilityEdge createVariabilityEdge(Edge edge) {
+ if (edge instanceof VariabilityEdge) {
+ return (VariabilityEdge) edge;
+ } else {
+ return new VariabilityEdge(edge);
+ }
+ }
+
+ /**
+ * Adds variability-awareness to the given {@link org.eclipse.emf.henshin.model.GraphElement} by wrapping it in a {@link org.eclipse.emf.henshin.variability.wrapper.VariabilityGraphElement}.
+ * If the GraphElement is already variability-aware it is not wrapped, but returned instead.
+ * @param graphElement the GraphElement to add variability-awareness to.
+ * @return the variability-aware GraphElement.
+ */
+ public VariabilityGraphElement createVariabilityGraphElement(GraphElement graphElement) {
+ if (graphElement instanceof VariabilityGraphElement) {
+ return (VariabilityGraphElement) graphElement;
+ } else {
+ if (graphElement instanceof Attribute) {
+ return createVariabilityAttribute((Attribute) graphElement);
+ } else if (graphElement instanceof Node) {
+ return createVariabilityNode((Node) graphElement);
+ } else if (graphElement instanceof Edge) {
+ return createVariabilityEdge((Edge) graphElement);
+ } else {
+ throw new RuntimeException();
+ }
+ }
+ }
+
+ /**
+ * Creates a new empty variability-aware {@link org.eclipse.emf.henshin.model.NestedCondition}.
+ * @return the NestedCondition.
+ */
+ public VariabilityNestedCondition createVariabilityNestedCondition() {
+ return new VariabilityNestedCondition();
+ }
+
+ /**
+ * Adds variability-awareness to the given {@link org.eclipse.emf.henshin.model.NestedCondition} by wrapping it in a {@link org.eclipse.emf.henshin.variability.wrapper.VariabilityNestedCondition}.
+ * If the NestedCondition is already variability-aware it is not wrapped, but returned instead.
+ * @param condition the NestedCondition to add variability-awareness to.
+ * @return the variability-aware NestedCondition.
+ */
+ public VariabilityNestedCondition createVariabilityNestedCondition(NestedCondition condition) {
+ if (condition instanceof VariabilityGraphElement) {
+ return (VariabilityNestedCondition) condition;
+ } else {
+ return new VariabilityNestedCondition(condition);
+ }
+ }
+
+ /**
+ * Creates a new empty variability-aware {@link org.eclipse.emf.henshin.model.Node}.
+ * @return the Node.
+ */
+ public VariabilityNode createVariabilityNode() {
+ return new VariabilityNode();
+ }
+
+ public VariabilityNode createVariabilityNode(Graph graph, EClass type, String name) {
+ return new VariabilityNode(graph, type, name);
+ }
+
+ /**
+ * Adds variability-awareness to the given {@link org.eclipse.emf.henshin.model.Node} by wrapping it in a {@link org.eclipse.emf.henshin.variability.wrapper.VariabilityNode}.
+ * If the Node is already variability-aware it is not wrapped, but returned instead.
+ * @param node the Node to add variability-awareness to.
+ * @return the variability-aware Node.
+ */
+ public VariabilityNode createVariabilityNode(Node node) {
+ if (node instanceof VariabilityNode) {
+ return (VariabilityNode) node;
+ } else {
+ transformAttributes(node);
+ return new VariabilityNode(node, isTransactional);
+ }
+ }
+
+ /**
+ * Creates a new empty variability-aware {@link org.eclipse.emf.henshin.model.Rule}.
+ * @return the Rule.
+ */
+ public VariabilityRule createVariabilityRule() {
+ return new VariabilityRule();
+ }
+
+ /**
+ * Creates a new variability-aware {@link org.eclipse.emf.henshin.model.Rule} with the given name.
+ * @param name the name of the Rule.
+ * @return the variability-aware Rule.
+ */
+ public VariabilityRule createVariabilityRule(String name) {
+ return new VariabilityRule(name);
+ }
+
+ /**
+ * Adds variability-awareness to the given {@link org.eclipse.emf.henshin.model.Rule} by wrapping it in a {@link org.eclipse.emf.henshin.variability.wrapper.VariabilityRule}.
+ * If the Rule is already variability-aware it is not wrapped, but returned instead.
+ * @param rule the Rule to add variability-awareness to.
+ * @return the variability-aware Rule.
+ */
+ public VariabilityRule createVariabilityRule(Rule rule) {
+ if (rule instanceof VariabilityRule) {
+ return (VariabilityRule) rule;
+ } else {
+ transformGraphElements(rule.getLhs());
+ transformGraphElements(rule.getRhs());
+ return new VariabilityRule(rule, isTransactional);
+ }
+ }
+
+ /**
+ * Transforms all elements in a {@link Graph} to be variability-aware without creating new wrapper objects.
+ * @param graph the {@link Graph} to be transformed.
+ */
+ private void transformGraphElements(Graph graph) {
+ for (Node node : graph.getNodes()) {
+ VariabilityNode.addVariabilityToNode(node, isTransactional);
+ transformAttributes(node);
+ }
+ for (Edge edge : graph.getEdges()) {
+ VariabilityEdge.addVariabilityToEdge(edge, isTransactional);
+ }
+ for (NestedCondition condition : graph.getNestedConditions()) {
+ VariabilityNestedCondition.addVariabilityToNestedCondition(condition, isTransactional);
+ transformGraphElements(condition.getConclusion());
+ }
+ }
+
+ /**
+ * Transform all attributes in a {@link }
+ * @param node
+ */
+ private void transformAttributes(Node node) {
+ for (Attribute attribute : node.getAttributes()) {
+ VariabilityAttribute.addVariabilityToAttribute(attribute, isTransactional);
+ }
+ }
+}
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/TransactionalVariabilityFactory.java b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/TransactionalVariabilityFactory.java
new file mode 100644
index 0000000..8cd4029
--- /dev/null
+++ b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/TransactionalVariabilityFactory.java
@@ -0,0 +1,28 @@
+package org.eclipse.emf.henshin.variability.wrapper;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.henshin.model.Attribute;
+import org.eclipse.emf.henshin.model.Edge;
+import org.eclipse.emf.henshin.model.Graph;
+import org.eclipse.emf.henshin.model.GraphElement;
+import org.eclipse.emf.henshin.model.NestedCondition;
+import org.eclipse.emf.henshin.model.Node;
+import org.eclipse.emf.henshin.model.Rule;
+
+/**
+ * The factory for the variability-aware graph elements.
+ * It provides methods for creating different variability graph elements.
+ *
+ * @author Stefan Schulz
+ *
+ */
+public class TransactionalVariabilityFactory extends AbstractVariabilityFactory {
+
+ public final static TransactionalVariabilityFactory INSTANCE = new TransactionalVariabilityFactory();
+
+ private TransactionalVariabilityFactory() {
+ super(true);
+ }
+}
\ No newline at end of file
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityAttribute.java b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityAttribute.java
index 99ca679..7861f42 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityAttribute.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityAttribute.java
@@ -33,7 +33,7 @@
final Attribute attribute;
final Annotation presenceCondition;
- static Annotation addVariabilityToAttribute(Attribute attribute) {
+ static Annotation addVariabilityToAttribute(Attribute attribute, boolean transactional) {
EList<Annotation> annos = attribute.getAnnotations();
Iterator<Annotation> it = annos.iterator();
Annotation pc = null;
@@ -47,6 +47,8 @@
if(pc != null) {
return pc;
+ } else if (transactional){
+ return VariabilityTransactionHelper.addAnnotation(attribute, VariabilityConstants.PRESENCE_CONDITION, "");
} else {
return VariabilityHelper.addAnnotation(attribute, VariabilityConstants.PRESENCE_CONDITION, "");
}
@@ -74,8 +76,17 @@
* @param attribute
*/
VariabilityAttribute(Attribute attribute) {
+ this(attribute, false);
+ }
+
+ /**
+ * Adds an {@link org.eclipse.emf.henshin.model.Annotation} to the given {@link org.eclipse.emf.henshin.model.Attribute} in order to enable variability awareness.
+ * @param attribute
+ * @param transactional
+ */
+ VariabilityAttribute(Attribute attribute, boolean transactional) {
this.attribute = attribute;
- this.presenceCondition = addVariabilityToAttribute(attribute);
+ this.presenceCondition = addVariabilityToAttribute(attribute, transactional);
}
public GraphElement getGraphElement() {
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityEdge.java b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityEdge.java
index 75258e0..fcd70f8 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityEdge.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityEdge.java
@@ -32,7 +32,7 @@
final Edge edge;
final Annotation presenceCondition;
- static Annotation addVariabilityToEdge(Edge edge) {
+ static Annotation addVariabilityToEdge(Edge edge, boolean transactional) {
EList<Annotation> annos = edge.getAnnotations();
Iterator<Annotation> it = annos.iterator();
Annotation pc = null;
@@ -46,6 +46,8 @@
if(pc != null) {
return pc;
+ } else if (transactional) {
+ return VariabilityTransactionHelper.addAnnotation(edge, VariabilityConstants.PRESENCE_CONDITION, "");
} else {
return VariabilityHelper.addAnnotation(edge, VariabilityConstants.PRESENCE_CONDITION, "");
}
@@ -75,8 +77,17 @@
* @param edge
*/
VariabilityEdge(Edge edge) {
+ this(edge, false);
+ }
+
+ /**
+ * Adds an {@link org.eclipse.emf.henshin.model.Annotation} to the given {@link org.eclipse.emf.henshin.model.Edge} in order to enable variability awareness.
+ * @param edge
+ * @param transactional
+ */
+ VariabilityEdge(Edge edge, boolean transactional) {
this.edge = edge;
- this.presenceCondition = addVariabilityToEdge(edge);
+ this.presenceCondition = addVariabilityToEdge(edge, transactional);
}
public GraphElement getGraphElement() {
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityFactory.java b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityFactory.java
index 8b341e7..95d7fa7 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityFactory.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityFactory.java
@@ -1,16 +1,5 @@
package org.eclipse.emf.henshin.variability.wrapper;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.henshin.model.Attribute;
-import org.eclipse.emf.henshin.model.Edge;
-import org.eclipse.emf.henshin.model.Graph;
-import org.eclipse.emf.henshin.model.GraphElement;
-import org.eclipse.emf.henshin.model.NestedCondition;
-import org.eclipse.emf.henshin.model.Node;
-import org.eclipse.emf.henshin.model.Rule;
-
/**
* The factory for the variability-aware graph elements.
* It provides methods for creating different variability graph elements.
@@ -18,208 +7,11 @@
* @author Stefan Schulz
*
*/
-public class VariabilityFactory {
+public class VariabilityFactory extends AbstractVariabilityFactory {
+
+ public final static VariabilityFactory INSTANCE = new VariabilityFactory();
private VariabilityFactory() {
- // This class should not be instatiated
- }
-
- /**
- * Creates a new empty variability-aware {@link org.eclipse.emf.henshin.model.Attribute}.
- * @return the Attribute.
- */
- public static VariabilityAttribute createVariabilityAttribute() {
- return new VariabilityAttribute();
- }
-
- /**
- * Creates a new variability-aware {@link org.eclipse.emf.henshin.model.Attribute} with the given type and value
- * and adds it to the given {@link org.eclipse.emf.henshin.model.Node}.
- * @param node the Node to add the Attribute to.
- * @param type the type of the Attribute.
- * @param value the value of the Attribute.
- * @return the Attribute.
- */
- public static VariabilityAttribute createVariabilityAttribute(Node node, EAttribute type, String value) {
- return new VariabilityAttribute(node, type, value);
- }
-
- /**
- * Adds variability-awareness to the given {@link org.eclipse.emf.henshin.model.Attribute} by wrapping it in a {@link org.eclipse.emf.henshin.variability.wrapper.VariabilityAttribute}.
- * If the Attribute is already variability-aware it is not wrapped, but returned instead.
- * @param attribute the Attribute to add variability-awareness to.
- * @return the variability-aware Attribute.
- */
- public static VariabilityAttribute createVariabilityAttribute(Attribute attribute) {
- if (attribute instanceof VariabilityAttribute) {
- return (VariabilityAttribute) attribute;
- } else {
- return new VariabilityAttribute(attribute);
- }
- }
-
- /**
- * Creates a new empty variability-aware {@link org.eclipse.emf.henshin.model.Edge}.
- * @return the Edge.
- */
- public static VariabilityEdge createVariabilityEdge() {
- return new VariabilityEdge();
- }
-
- /**
- * Creates a new variability-aware {@link org.eclipse.emf.henshin.model.Edge} between the given {@link org.eclipse.emf.henshin.model.Node}s.
- * @param source Source node.
- * @param target Target node.
- * @param type Edge type.
- * @return the variability-aware Edge.
- */
- public static VariabilityEdge createVariabilityEdge(Node source, Node target, EReference type) {
- return new VariabilityEdge(source, target, type);
- }
-
- /**
- * Adds variability-awareness to the given {@link org.eclipse.emf.henshin.model.Edge} by wrapping it in a {@link org.eclipse.emf.henshin.variability.wrapper.VariabilityEdge}.
- * If the Edge is already variability-aware it is not wrapped, but returned instead.
- * @param edge the Edge to add variability-awareness to.
- * @return the variability-aware Edge.
- */
- public static VariabilityEdge createVariabilityEdge(Edge edge) {
- if (edge instanceof VariabilityEdge) {
- return (VariabilityEdge) edge;
- } else {
- return new VariabilityEdge(edge);
- }
- }
-
- /**
- * Adds variability-awareness to the given {@link org.eclipse.emf.henshin.model.GraphElement} by wrapping it in a {@link org.eclipse.emf.henshin.variability.wrapper.VariabilityGraphElement}.
- * If the GraphElement is already variability-aware it is not wrapped, but returned instead.
- * @param graphElement the GraphElement to add variability-awareness to.
- * @return the variability-aware GraphElement.
- */
- public static VariabilityGraphElement createVariabilityGraphElement(GraphElement graphElement) {
- if (graphElement instanceof VariabilityGraphElement) {
- return (VariabilityGraphElement) graphElement;
- } else {
- if (graphElement instanceof Attribute) {
- return createVariabilityAttribute((Attribute) graphElement);
- } else if (graphElement instanceof Node) {
- return createVariabilityNode((Node) graphElement);
- } else if (graphElement instanceof Edge) {
- return createVariabilityEdge((Edge) graphElement);
- } else {
- throw new RuntimeException();
- }
- }
- }
-
- /**
- * Creates a new empty variability-aware {@link org.eclipse.emf.henshin.model.NestedCondition}.
- * @return the NestedCondition.
- */
- public static VariabilityNestedCondition createVariabilityNestedCondition() {
- return new VariabilityNestedCondition();
- }
-
- /**
- * Adds variability-awareness to the given {@link org.eclipse.emf.henshin.model.NestedCondition} by wrapping it in a {@link org.eclipse.emf.henshin.variability.wrapper.VariabilityNestedCondition}.
- * If the NestedCondition is already variability-aware it is not wrapped, but returned instead.
- * @param condition the NestedCondition to add variability-awareness to.
- * @return the variability-aware NestedCondition.
- */
- public static VariabilityNestedCondition createVariabilityNestedCondition(NestedCondition condition) {
- if (condition instanceof VariabilityGraphElement) {
- return (VariabilityNestedCondition) condition;
- } else {
- return new VariabilityNestedCondition(condition);
- }
- }
-
- /**
- * Creates a new empty variability-aware {@link org.eclipse.emf.henshin.model.Node}.
- * @return the Node.
- */
- public static VariabilityNode createVariabilityNode() {
- return new VariabilityNode();
- }
-
- public static VariabilityNode createVariabilityNode(Graph graph, EClass type, String name) {
- return new VariabilityNode(graph, type, name);
- }
-
- /**
- * Adds variability-awareness to the given {@link org.eclipse.emf.henshin.model.Node} by wrapping it in a {@link org.eclipse.emf.henshin.variability.wrapper.VariabilityNode}.
- * If the Node is already variability-aware it is not wrapped, but returned instead.
- * @param node the Node to add variability-awareness to.
- * @return the variability-aware Node.
- */
- public static VariabilityNode createVariabilityNode(Node node) {
- if (node instanceof VariabilityNode) {
- return (VariabilityNode) node;
- } else {
- transformAttributes(node);
- return new VariabilityNode(node);
- }
- }
-
- /**
- * Creates a new empty variability-aware {@link org.eclipse.emf.henshin.model.Rule}.
- * @return the Rule.
- */
- public static VariabilityRule createVariabilityRule() {
- return new VariabilityRule();
- }
-
- /**
- * Creates a new variability-aware {@link org.eclipse.emf.henshin.model.Rule} with the given name.
- * @param name the name of the Rule.
- * @return the variability-aware Rule.
- */
- public static VariabilityRule createVariabilityRule(String name) {
- return new VariabilityRule(name);
- }
-
- /**
- * Adds variability-awareness to the given {@link org.eclipse.emf.henshin.model.Rule} by wrapping it in a {@link org.eclipse.emf.henshin.variability.wrapper.VariabilityRule}.
- * If the Rule is already variability-aware it is not wrapped, but returned instead.
- * @param rule the Rule to add variability-awareness to.
- * @return the variability-aware Rule.
- */
- public static VariabilityRule createVariabilityRule(Rule rule) {
- if (rule instanceof VariabilityRule) {
- return (VariabilityRule) rule;
- } else {
- transformGraphElements(rule.getLhs());
- transformGraphElements(rule.getRhs());
- return new VariabilityRule(rule);
- }
- }
-
- /**
- * Transforms all elements in a {@link Graph} to be variability-aware without creating new wrapper objects.
- * @param graph the {@link Graph} to be transformed.
- */
- private static void transformGraphElements(Graph graph) {
- for (Node node : graph.getNodes()) {
- VariabilityNode.addVariabilityToNode(node);
- transformAttributes(node);
- }
- for (Edge edge : graph.getEdges()) {
- VariabilityEdge.addVariabilityToEdge(edge);
- }
- for (NestedCondition condition : graph.getNestedConditions()) {
- VariabilityNestedCondition.addVariabilityToNestedCondition(condition);
- transformGraphElements(condition.getConclusion());
- }
- }
-
- /**
- * Transform all attributes in a {@link }
- * @param node
- */
- private static void transformAttributes(Node node) {
- for (Attribute attribute : node.getAttributes()) {
- VariabilityAttribute.addVariabilityToAttribute(attribute);
- }
+ super(false);
}
}
\ No newline at end of file
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityNestedCondition.java b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityNestedCondition.java
index ea79a55..ab48589 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityNestedCondition.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityNestedCondition.java
@@ -30,7 +30,7 @@
final NestedCondition nestedCondition;
final Annotation presenceCondition;
- static Annotation addVariabilityToNestedCondition(NestedCondition condition) {
+ static Annotation addVariabilityToNestedCondition(NestedCondition condition, boolean transactional) {
EList<Annotation> annos = condition.getAnnotations();
Iterator<Annotation> it = annos.iterator();
Annotation pc = null;
@@ -44,6 +44,8 @@
if(pc != null) {
return pc;
+ } else if (transactional) {
+ return VariabilityTransactionHelper.addAnnotation(condition, VariabilityConstants.PRESENCE_CONDITION, "");
} else {
return VariabilityHelper.addAnnotation(condition, VariabilityConstants.PRESENCE_CONDITION, "");
}
@@ -61,8 +63,17 @@
* @param condition
*/
VariabilityNestedCondition(NestedCondition condition) {
+ this(condition, false);
+ }
+
+ /**
+ * Adds an {@link org.eclipse.emf.henshin.model.Annotation} to the given {@link org.eclipse.emf.henshin.model.NestedCondition} in order to enable variability awareness.
+ * @param condition
+ * @param transactional
+ */
+ VariabilityNestedCondition(NestedCondition condition, boolean transactional) {
this.nestedCondition = condition;
- this.presenceCondition = addVariabilityToNestedCondition(condition);
+ this.presenceCondition = addVariabilityToNestedCondition(condition, transactional);
}
/**
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityNode.java b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityNode.java
index 432ef91..c1a558b 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityNode.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityNode.java
@@ -34,7 +34,7 @@
final Node node;
final Annotation presenceCondition;
- static Annotation addVariabilityToNode(Node node) {
+ static Annotation addVariabilityToNode(Node node, boolean transactional) {
EList<Annotation> annos = node.getAnnotations();
Iterator<Annotation> it = annos.iterator();
Annotation pc = null;
@@ -48,6 +48,8 @@
if(pc != null) {
return pc;
+ } else if (transactional) {
+ return VariabilityTransactionHelper.addAnnotation(node, VariabilityConstants.PRESENCE_CONDITION, "");
} else {
return VariabilityHelper.addAnnotation(node, VariabilityConstants.PRESENCE_CONDITION, "");
}
@@ -75,8 +77,17 @@
* @param node
*/
VariabilityNode(Node node) {
+ this(node, false);
+ }
+
+ /**
+ * Adds an {@link org.eclipse.emf.henshin.model.Annotation} to the given {@link org.eclipse.emf.henshin.model.Node} in order to enable variability awareness.
+ * @param node
+ * @param transactional
+ */
+ VariabilityNode(Node node, boolean transactional) {
this.node = node;
- this.presenceCondition = addVariabilityToNode(node);
+ this.presenceCondition = addVariabilityToNode(node, transactional);
}
public GraphElement getGraphElement() {
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityRule.java b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityRule.java
index 3b717a7..533de9f 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityRule.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityRule.java
@@ -51,29 +51,9 @@
final Annotation featureModel;
final Annotation injectiveMatchingPresenceCondition;
final Annotation features;
-
- /**
- * Creates a new {@link org.eclipse.emf.henshin.model.Rule} and makes it variability aware.
- */
- VariabilityRule() {
- this(HenshinFactoryImpl.eINSTANCE.createRule());
- }
- /**
- * Creates a new {@link org.eclipse.emf.henshin.model.Rule} with the given name and makes it variability aware.
- * @param name the name of the new henshin rule
- */
- VariabilityRule(String name) {
- this(HenshinFactoryImpl.eINSTANCE.createRule(name));
- }
-
- /**
- * Adds multiple {@link org.eclipse.emf.henshin.model.Annotation} to the given {@link org.eclipse.emf.henshin.model.Rule} in order to enable variability awareness.
- * @param rule
- */
- VariabilityRule(Rule rule) {
- this.rule = rule;
-
+ static Annotation[] addVariabilityToRule(Rule rule, boolean transactional) {
+ Annotation[] result = new Annotation[3];
Annotation featModel = null;
Annotation injMatPreCon = null;
Annotation feats = null;
@@ -96,22 +76,66 @@
}
if(featModel != null) {
- featureModel = featModel;
+ result[0] = featModel;
+ } else if (transactional) {
+ result[0] = VariabilityTransactionHelper.addAnnotation(rule, VariabilityConstants.FEATURE_MODEL, "");
} else {
- featureModel = VariabilityHelper.addAnnotation(rule, VariabilityConstants.FEATURE_MODEL, "");
+ result[0] = VariabilityHelper.addAnnotation(rule, VariabilityConstants.FEATURE_MODEL, "");
}
if(injMatPreCon != null) {
- injectiveMatchingPresenceCondition = injMatPreCon;
+ result[1] = injMatPreCon;
+ } else if (transactional) {
+ result[1] = VariabilityTransactionHelper.addAnnotation(rule, VariabilityConstants.INJECTIVE_MATCHING_PC, "");
} else {
- injectiveMatchingPresenceCondition = VariabilityHelper.addAnnotation(rule, VariabilityConstants.INJECTIVE_MATCHING_PC, "");
+ result[1] = VariabilityHelper.addAnnotation(rule, VariabilityConstants.INJECTIVE_MATCHING_PC, "");
}
if(feats != null) {
- features = feats;
+ result[2] = feats;
+ } else if (transactional) {
+ result[2] = VariabilityTransactionHelper.addAnnotation(rule, VariabilityConstants.FEATURES, "");
} else {
- features = VariabilityHelper.addAnnotation(rule, VariabilityConstants.FEATURES, "");
+ result[2] = VariabilityHelper.addAnnotation(rule, VariabilityConstants.FEATURES, "");
}
+
+ return result;
+ }
+
+ /**
+ * Creates a new {@link org.eclipse.emf.henshin.model.Rule} and makes it variability aware.
+ */
+ VariabilityRule() {
+ this(HenshinFactoryImpl.eINSTANCE.createRule());
+ }
+
+ /**
+ * Creates a new {@link org.eclipse.emf.henshin.model.Rule} with the given name and makes it variability aware.
+ * @param name the name of the new henshin rule
+ */
+ VariabilityRule(String name) {
+ this(HenshinFactoryImpl.eINSTANCE.createRule(name));
+ }
+
+ /**
+ * Adds multiple {@link org.eclipse.emf.henshin.model.Annotation} to the given {@link org.eclipse.emf.henshin.model.Rule} in order to enable variability awareness.
+ * @param rule
+ */
+ VariabilityRule(Rule rule) {
+ this(rule, false);
+ }
+
+ /**
+ * Adds multiple {@link org.eclipse.emf.henshin.model.Annotation} to the given {@link org.eclipse.emf.henshin.model.Rule} in order to enable variability awareness.
+ * @param rule
+ * @param transactional
+ */
+ VariabilityRule(Rule rule, boolean transactional) {
+ this.rule = rule;
+ Annotation[] annos = addVariabilityToRule(rule, transactional);
+ featureModel = annos[0];
+ injectiveMatchingPresenceCondition = annos[1];
+ features = annos[2];
}
/**
diff --git a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityTransactionHelper.java b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityTransactionHelper.java
index a0ae0ec..4036f87 100644
--- a/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityTransactionHelper.java
+++ b/plugins/variability/org.eclipse.emf.henshin.variability/src/org/eclipse/emf/henshin/variability/wrapper/VariabilityTransactionHelper.java
@@ -4,6 +4,7 @@
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.henshin.model.Annotation;
@@ -24,21 +25,28 @@
private VariabilityTransactionHelper() {
// This class should not be instantiated
}
-
- static Annotation addAnnotation(ModelElement modelElement, String key, String value) {
- EditingDomain domain = TransactionUtil.getEditingDomain(modelElement);
+
+ private static TransactionalEditingDomain getOrCreateEditingDomain(ModelElement modelElement) {
+ TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(modelElement);
if (domain == null) {
ResourceSet resSet = new ResourceSetImpl();
resSet.createResource(modelElement.eResource().getURI());
domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resSet);
}
- Annotation anno = HenshinFactory.eINSTANCE.createAnnotation();
+ return domain;
+ }
+ static Annotation addAnnotation(ModelElement modelElement, String key, String value) {
+ Annotation anno = HenshinFactory.eINSTANCE.createAnnotation();
anno.setKey(key);
anno.setValue(value);
try {
modelElement.getAnnotations().add(anno);
+// EditingDomain domain = getOrCreateEditingDomain(modelElement);
+// Command command = AddCommand.create(domain, modelElement, HenshinPackage.Literals.MODEL_ELEMENT__ANNOTATIONS, anno);
+// CommandStack stack = domain.getCommandStack();
+// stack.execute(command);
} catch (IllegalStateException e) {
}
return anno;
@@ -48,12 +56,7 @@
Annotation anno = getAnnotation(modelElement, key);
if (anno != null && anno.getValue() != null && !anno.getValue().equals(value)) {
- TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(modelElement);
- if (domain == null) {
- ResourceSet resSet = new ResourceSetImpl();
- resSet.createResource(modelElement.eResource().getURI());
- domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resSet);
- }
+ EditingDomain domain = getOrCreateEditingDomain(modelElement);
Command command = SetCommand.create(domain, anno, HenshinPackage.Literals.ANNOTATION__VALUE, value);
CommandStack stack = domain.getCommandStack();
try {