manager class HenshinRuntimeManager added
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/interfaces/IHenshinController.java b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/interfaces/IHenshinController.java
index 7e246ba..4faeff6 100644
--- a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/interfaces/IHenshinController.java
+++ b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/interfaces/IHenshinController.java
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.eclipse.emf.refactor.refactoring.henshin.interfaces;
 
+import org.eclipse.emf.refactor.refactoring.henshin.managers.HenshinRuntimeManager;
 import org.eclipse.emf.refactor.refactoring.interfaces.IController;
 
 /**
@@ -26,7 +27,7 @@
 	 * @return HenshinRunner that executes Henshin transformations using 
 	 * the Henshin interpreter.
 	 */
-	public HenshinRunner getHenshinRunner();
+	public HenshinRuntimeManager getHenshinRuntimeManager();
 	
 	/**
 	 * @see org.eclipse.emf.refactor.common.core.IController#
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/managers/HenshinFileManager.java b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/managers/HenshinFileManager.java
new file mode 100644
index 0000000..b9f9e2d
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/managers/HenshinFileManager.java
@@ -0,0 +1,36 @@
+package org.eclipse.emf.refactor.refactoring.henshin.managers;
+
+import java.io.File;
+import java.io.FileFilter;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+public class HenshinFileManager {
+	
+	private final static String HENSHIN_EXT = ".henshin";
+	 
+	public static File[] getAllHenshinFiles(String path) {
+		File file = new File(path);
+		FileFilter ff = new FileFilter() {
+			@Override
+			public boolean accept(File pathname) {
+				if (pathname.getName().endsWith(HENSHIN_EXT)) {
+					return true;
+				} else {
+					return false;
+				}
+			}
+		};
+		return file.listFiles(ff);
+	}
+	
+	public static EObject loadFile(String filename) {
+		ResourceSet resourceSet = new ResourceSetImpl();
+		Resource resource = resourceSet.getResource(URI.createFileURI(filename), true);
+		return resource.getContents().get(0);
+	}
+}
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/managers/HenshinRuntimeManager.java b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/managers/HenshinRuntimeManager.java
new file mode 100644
index 0000000..9026ec9
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/managers/HenshinRuntimeManager.java
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * 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.managers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.henshin.interpreter.EGraph;
+import org.eclipse.emf.henshin.interpreter.Engine;
+import org.eclipse.emf.henshin.interpreter.RuleApplication;
+import org.eclipse.emf.henshin.interpreter.UnitApplication;
+import org.eclipse.emf.henshin.interpreter.impl.EGraphImpl;
+import org.eclipse.emf.henshin.interpreter.impl.EngineImpl;
+import org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl;
+import org.eclipse.emf.henshin.model.HenshinFactory;
+import org.eclipse.emf.henshin.model.Module;
+import org.eclipse.emf.henshin.model.Parameter;
+import org.eclipse.emf.henshin.model.Unit;
+import org.eclipse.emf.refactor.refactoring.henshin.interfaces.IHenshinDataManagement;
+import org.eclipse.emf.refactor.refactoring.henshin.interfaces.IHenshinInformation;
+import org.eclipse.emf.refactor.refactoring.henshin.runtime.HenshinApplicationMonitor;
+
+/**
+ * Class that executes Henshin transformations using the Henshin
+ * interpreter.
+ * @generated NOT
+ * @author Thorsten Arendt
+ */
+public class HenshinRuntimeManager {
+	
+	/**
+	 * Given selection of EObjects the model refactoring 
+	 * shall be executed on.
+	 */
+	protected final List<EObject> selection;
+	
+	public final static String HENSHINEXTENSION = ".henshin";
+	private static final String MAINUNIT = "mainUnit";
+	
+	/**
+	 * Corresponding HenshinDataManagement object which specifies 
+	 * data concerning a model refactoring that shall be executed by 
+	 * EMF model transformations using Henshin. 
+	 */
+	private IHenshinDataManagement dataManagementObject;
+	
+	/**
+	 * Factory for creating Henshin objects.
+	 */
+	private static HenshinFactory henshinFactory = HenshinFactory.eINSTANCE;
+	
+	/**
+	 * Henshin transformation system to be executed.
+	 */
+	private Module module = henshinFactory.createModule();
+
+	/**
+	 * Default constructor using a selection of EObjects the model refactoring 
+	 * shall be executed on and the corresponding HenshinDataManagement object 
+	 * which specifies data concerning a model refactoring that shall be 
+	 * executed by EMF model transformations using Henshin. 
+	 * @param selection Given selection of EObjects the model refactoring 
+	 * shall be executed on.
+	 * @param dataManagementObject Corresponding HenshinDataManagement object 
+	 * which specifies data concerning a model refactoring that shall be 
+	 * executed by EMF model transformations using Henshin. 
+	 */
+	public HenshinRuntimeManager
+		(List<EObject> selection, IHenshinDataManagement dataManagementObject){
+		this.selection = selection;
+		this.dataManagementObject = dataManagementObject;
+	}
+	
+	/**
+	 * Static method for checking initial or final conditions of a EMF
+	 * model refactoring using Henshin transformations.
+	 * @param henshinInformation Corresponding HenshinInformation object 
+	 * specifying a Henshin file that shall be used.
+	 * @param root Root object of the EMF model to be refactored.
+	 * @return List of messages indicating errors which occur during
+	 * conditions checking.
+	 */
+	public static List<String> checkConditions
+					(IHenshinInformation henshinInformation, EObject root) {
+		List<String> result = new ArrayList<String>();
+		if (henshinInformation.isTransformationFileSpecified()) {
+			String path = henshinInformation.getTransformationFileName() 
+														+ HENSHINEXTENSION;
+			Module checkTransformationSystem = 
+						(Module) HenshinFileManager.loadFile(path);
+			EGraph graph = new EGraphImpl();
+			graph.addTree(root);
+			Engine engine = new EngineImpl();
+			
+			Unit mainUnit = 
+						checkTransformationSystem.getUnit(MAINUNIT);
+			
+			UnitApplication unitApplication = new UnitApplicationImpl(engine);
+			unitApplication.setUnit(mainUnit);
+			unitApplication.setEGraph(graph);
+
+			
+			// Map <Parameter, Object> values = new HashMap<Parameter, Object>();
+			for (Parameter par : mainUnit.getParameters()){
+				try {
+					/*values.put(par, 
+							henshinInformation.getHenshinDataManagement()
+								.getInPortByName(par.getName()).getValue());*/
+					unitApplication.setParameterValue(par.getName(), 
+							henshinInformation.getHenshinDataManagement()
+								.getInPortByName(par.getName()).getValue());
+				} catch (IllegalArgumentException ex) {
+					ex.printStackTrace();
+				}			
+			}
+			
+			HenshinApplicationMonitor am = new HenshinApplicationMonitor(); 
+			
+			unitApplication.execute(am);
+			List<RuleApplication> appliedRules = am.getAppliedRules();
+			for (UnitApplication ua : appliedRules) {
+				result.add(((RuleApplication) ua).getResultMatch().getRule().getDescription());
+			}
+/*			while (!appliedRules.empty()) {
+				RuleApplication appliedRule = appliedRules.pop();
+				if ((null != appliedRule.getDescription()) 
+							&& (! appliedRule.getDescription().isEmpty())) {
+					result.add
+						(appliedRule.getMatch().getRule().getDescription());
+				}
+			} */
+		}
+		return result;
+	}
+	
+	/**
+	 * Method that executes the EMF model refactoring using Henshin.
+	 */
+	public void run(){
+		if (this.dataManagementObject.getCreateChangeHenshinInformation()
+										.isTransformationFileSpecified()) {
+			String path = this.dataManagementObject
+					.getCreateChangeHenshinInformation()
+						.getTransformationFileName() + HENSHINEXTENSION;
+			this.module = 
+						(Module) HenshinFileManager.loadFile(path);
+			EObject root = EcoreUtil.getRootContainer(selection.get(0));
+			EGraph graph = new EGraphImpl();
+			graph.addTree(root);
+			Engine engine = new EngineImpl();
+			
+			Unit mainUnit = 
+						this.module.getUnit(MAINUNIT);
+			UnitApplication unitApplication = new UnitApplicationImpl(engine);
+			unitApplication.setUnit(mainUnit);
+			unitApplication.setEGraph(graph);
+
+			// Map <Parameter, Object> values = new HashMap<Parameter, Object>();
+			for (Parameter par : mainUnit.getParameters()){
+				try {
+					unitApplication.setParameterValue(par.getName(), 
+							this.dataManagementObject
+								.getInPortByName(par.getName()).getValue());
+					/*values.put
+						(par, this.dataManagementObject
+								.getInPortByName(par.getName()).getValue()); */
+				} catch (IllegalArgumentException ex) {
+					ex.printStackTrace();
+				}			
+			}
+			
+			unitApplication.execute(null);			
+		}
+	}
+
+//	private final static String MAIN_RULE = "mainRule";
+//	private final static String CONTEXT = "context";
+//
+//	public static double run(String transformationPath, EObject context) {
+//		EObject root = EcoreUtil.getRootContainer(context);		
+//		EGraph graph = new EGraphImpl();
+//		graph.addTree(root);
+//		Engine engine = new EngineImpl();
+//		Module module = (Module) HenshinFileManager.loadFile(transformationPath);
+//		Rule rule = (Rule) module.getUnit(MAIN_RULE);
+//		Match prematch = new MatchImpl(rule);
+//		for (Parameter par : rule.getParameters()) {
+//			if (par.getName().equals(CONTEXT)) {
+//				prematch.setParameterValue(par, context);
+//			}
+//		}
+//		RuleApplication application = new RuleApplicationImpl(engine, graph, rule, prematch); 
+//		List<Match> matches = InterpreterUtil.findAllMatches(engine,
+//				application.getRule(), application.getEGraph(),
+//				application.getPartialMatch());
+//		return matches.size();
+//	}
+}
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
index 01384b4..f2f83f0 100644
--- 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
@@ -16,6 +16,7 @@
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.change.util.ChangeRecorder;
 import org.eclipse.emf.refactor.refactoring.henshin.interfaces.IHenshinInformation;
+import org.eclipse.emf.refactor.refactoring.henshin.managers.HenshinRuntimeManager;
 
 /**
  * Class used for checking initial an final conditions of
@@ -73,7 +74,7 @@
 	public void execute() {
 		//Start Recorder:
 		ChangeRecorder changeRecorder = new ChangeRecorder(root);		
-		this.messages = HenshinRunner.checkConditions
+		this.messages = HenshinRuntimeManager.checkConditions
 							(this.henshinInformation, this.root);		
 		//Undo
 		changeRecorder.endRecording().applyAndReverse();