Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortarendt2012-11-22 13:59:34 +0000
committertarendt2012-11-22 13:59:34 +0000
commit93db73d34c6b9dd2e182c8f8d34bd7b255bffa4f (patch)
tree288ecee50a9d581a6c61d8ee05de9eccf7670fe7
parent748fc8d53115be2e00394e80592b190a1f6b4535 (diff)
downloadorg.eclipse.emf.refactor.refactoring-93db73d34c6b9dd2e182c8f8d34bd7b255bffa4f.tar.gz
org.eclipse.emf.refactor.refactoring-93db73d34c6b9dd2e182c8f8d34bd7b255bffa4f.tar.xz
org.eclipse.emf.refactor.refactoring-93db73d34c6b9dd2e182c8f8d34bd7b255bffa4f.zip
three henshin runtime classes added
-rw-r--r--org.eclipse.emf.refactor.refactoring.henshin/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/runtime/CheckConditionsCommand.java104
-rw-r--r--org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/runtime/HenshinApplicationMonitor.java83
-rw-r--r--org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/runtime/HenshinInformationAdapter.java64
4 files changed, 254 insertions, 1 deletions
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/META-INF/MANIFEST.MF b/org.eclipse.emf.refactor.refactoring.henshin/META-INF/MANIFEST.MF
index 88f3160..4e32df7 100644
--- a/org.eclipse.emf.refactor.refactoring.henshin/META-INF/MANIFEST.MF
+++ b/org.eclipse.emf.refactor.refactoring.henshin/META-INF/MANIFEST.MF
@@ -7,6 +7,8 @@ Bundle-Activator: org.eclipse.emf.refactor.refactoring.henshin.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.emf.refactor.refactoring;bundle-version="0.7.0",
- org.eclipse.emf.refactor.refactoring.generator;bundle-version="0.7.0"
+ org.eclipse.emf.refactor.refactoring.generator;bundle-version="0.7.0",
+ org.eclipse.emf.refactor.refactoring.runtime;bundle-version="0.7.0",
+ org.eclipse.emf.henshin.interpreter;bundle-version="0.9.4"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/runtime/CheckConditionsCommand.java b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/runtime/CheckConditionsCommand.java
new file mode 100644
index 0000000..01384b4
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/runtime/CheckConditionsCommand.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) Philipps University of Marburg. 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:
+ * Philipps University of Marburg - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.refactor.refactoring.henshin.runtime;
+
+import java.util.List;
+
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.change.util.ChangeRecorder;
+import org.eclipse.emf.refactor.refactoring.henshin.interfaces.IHenshinInformation;
+
+/**
+ * Class used for checking initial an final conditions of
+ * a EMF model refactoring using Henshin transformations.
+ * @generated NOT
+ * @author Florian Mantz
+ */
+public class CheckConditionsCommand extends AbstractCommand {
+
+ /**
+ * Root of the corresponding EMF model.
+ */
+ private final EObject root;
+
+ /**
+ * Corresponding HenshinInformation object providing the
+ * name of the Henshin transformation to be used.
+ */
+ private final IHenshinInformation henshinInformation;
+
+ /**
+ * List of messages indication errors which occur during
+ * conditions checking.
+ */
+ private List<String> messages;
+
+ /**
+ * Default constructor using the corresponding HenshinInformation
+ * object and the root of the corresponding EMF model.
+ * @param henshinInformation Corresponding HenshinInformation object
+ * providing the name of the Henshin transformation to be used.
+ * @param root Root of the corresponding EMF model.
+ */
+ public CheckConditionsCommand
+ (IHenshinInformation henshinInformation, EObject root) {
+ super();
+ this.root = root;
+ this.henshinInformation = henshinInformation;
+ }
+
+ /**
+ * Gets a list of messages indicating errors which occur during
+ * conditions checking.
+ * @return List of messages indicating errors which occur during
+ * conditions checking.
+ */
+ public List<String> getMessages() {
+ return messages;
+ }
+
+ /**
+ * @see org.eclipse.emf.common.command.Command#execute()
+ */
+ @Override
+ public void execute() {
+ //Start Recorder:
+ ChangeRecorder changeRecorder = new ChangeRecorder(root);
+ this.messages = HenshinRunner.checkConditions
+ (this.henshinInformation, this.root);
+ //Undo
+ changeRecorder.endRecording().applyAndReverse();
+ }
+
+ /**
+ * @see org.eclipse.emf.common.command.Command#redo()
+ */
+ @Override
+ public void redo() {
+ //do nothing
+ }
+
+ /**
+ * @see org.eclipse.emf.common.command.AbstractCommand#canExecute()
+ */
+ public boolean canExecute() {
+ return true;
+ }
+
+ /**
+ * @see org.eclipse.emf.common.command.AbstractCommand#canUndo()
+ */
+ public boolean canUndo() {
+ return false;//Important
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/runtime/HenshinApplicationMonitor.java b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/runtime/HenshinApplicationMonitor.java
new file mode 100644
index 0000000..70b26a2
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/runtime/HenshinApplicationMonitor.java
@@ -0,0 +1,83 @@
+package org.eclipse.emf.refactor.refactoring.henshin.runtime;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.henshin.interpreter.ApplicationMonitor;
+import org.eclipse.emf.henshin.interpreter.RuleApplication;
+import org.eclipse.emf.henshin.interpreter.UnitApplication;
+
+public class HenshinApplicationMonitor implements ApplicationMonitor {
+
+ private List<RuleApplication> appliedRules = new ArrayList<RuleApplication>(5);
+
+ // Canceled flag:
+ protected boolean canceled = false;
+
+ // Undoing flag:
+ protected boolean undo = false;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.emf.henshin.interpreter.ApplicationMonitor#isCanceled()
+ */
+ @Override
+ public boolean isCanceled() {
+ return canceled;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.emf.henshin.interpreter.ApplicationMonitor#isUndo()
+ */
+ @Override
+ public boolean isUndo() {
+ return undo;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.emf.henshin.interpreter.ApplicationMonitor#cancel()
+ */
+ @Override
+ public void cancel() {
+ canceled = true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.emf.henshin.interpreter.ApplicationMonitor#cancelAndUndo()
+ */
+ @Override
+ public void cancelAndUndo() {
+ canceled = true;
+ undo = true;
+ }
+
+ @Override
+ public void notifyExecute(UnitApplication application, boolean success) {
+ if (success && application instanceof RuleApplication && application.getUnit().getDescription() != null && !application.getUnit().getDescription().isEmpty())
+ appliedRules.add((RuleApplication) application);
+ }
+
+ @Override
+ public void notifyUndo(UnitApplication application, boolean succeess) {
+ // do nothing
+ }
+
+ @Override
+ public void notifyRedo(UnitApplication application, boolean success) {
+ // do nothing
+ }
+
+ /**
+ * Returns the applied UnitApplications where:
+ * (a) the execution was successful
+ * (b) the description is not empty
+ * @return
+ */
+ public List<RuleApplication> getAppliedRules() {
+ return appliedRules;
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/runtime/HenshinInformationAdapter.java b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/runtime/HenshinInformationAdapter.java
new file mode 100644
index 0000000..6d86352
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/runtime/HenshinInformationAdapter.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) Philipps University of Marburg. 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:
+ * Philipps University of Marburg - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.refactor.refactoring.henshin.runtime;
+
+import org.eclipse.emf.refactor.refactoring.henshin.interfaces.IHenshinInformation;
+
+/**
+ * Adapter implementation of the IHenshinInformation interface used
+ * for specifying a Henshin file that shall be used by a specific
+ * EMF model refactoring.
+ * @generated NOT
+ * @author Thorsten Arendt
+ */
+public abstract class HenshinInformationAdapter implements IHenshinInformation {
+
+ private final String UNSPECIFIED = "unspecified";
+
+ /**
+ * Default name of the Henshin transformation file that shall
+ * be used by a specific EMF model refactoring.
+ */
+ protected String transformationFileName = UNSPECIFIED;
+
+ /**
+ * Sets the the name of the Henshin transformation file that
+ * shall be used by a specific EMF model refactoring.
+ * @param transformationFileName Name of the Henshin transformation
+ * file that shall be used by a specific EMF model refactoring.
+ */
+ public void setTransformationFileName(String transformationFileName) {
+ if (transformationFileName == null
+ || transformationFileName.isEmpty()){
+ this.transformationFileName = UNSPECIFIED;
+ }
+ this.transformationFileName = transformationFileName;
+ }
+
+ /**
+ * @see org.eclipse.emf.refactor.henshin.core.IHenshinInformation#
+ * getTransformationFileName()
+ */
+ @Override
+ public String getTransformationFileName() {
+ return this.transformationFileName;
+ }
+
+ /**
+ * @see org.eclipse.emf.refactor.henshin.core.IHenshinInformation#
+ * isTransformationFileSpecified()
+ */
+ @Override
+ public Boolean isTransformationFileSpecified() {
+ return !this.transformationFileName.endsWith(UNSPECIFIED);
+ }
+
+}

Back to the top