Index: /trunk/modelicaml/org.openmodelica.modelicaml.helper/plugin.xml
===================================================================
--- /trunk/modelicaml/org.openmodelica.modelicaml.helper/plugin.xml	(revision 909)
+++ /trunk/modelicaml/org.openmodelica.modelicaml.helper/plugin.xml	(revision 910)
@@ -15,4 +15,5 @@
    <extension
          point="org.eclipse.ui.commands">
+      <!--
       <command
             id="org.openmodelica.modelicaml.helper.commands.instantiaterequirements"
@@ -23,4 +24,5 @@
             name="Create/Update Test Oracle Elements">
       </command>
+      -->
       <command
             id="org.openmodelica.modelicaml.helper.commands.generatesimmodels"
@@ -30,4 +32,5 @@
    <extension
          point="org.eclipse.ui.handlers">
+      <!--
       <handler
             class="org.openmodelica.modelicaml.helper.handlers.InstantiateRequirementsHandler"
@@ -116,6 +119,7 @@
          </activeWhen>
       </handler>
+      -->
       <handler
-            class="org.openmodelica.modelicaml.helper.handlers.SimulationModelsGenaratorHandler"
+            class="org.openmodelica.modelicaml.helper.handlers.TestSimulationModelsGenaratorHandler"
             commandId="org.openmodelica.modelicaml.helper.commands.generatesimmodels">
          <activeWhen>
Index: /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/dialogs/SelectTestScenariosAndRequirementsDialog.java
===================================================================
--- /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/dialogs/SelectTestScenariosAndRequirementsDialog.java	(revision 909)
+++ /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/dialogs/SelectTestScenariosAndRequirementsDialog.java	(revision 910)
@@ -2,11 +2,8 @@
 
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 
-import org.eclipse.emf.common.util.EList;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.TitleAreaDialog;
@@ -25,4 +22,6 @@
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.TabFolder;
@@ -32,11 +31,12 @@
 import org.eclipse.ui.ISharedImages;
 import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Class;
 import org.eclipse.uml2.uml.Element;
 import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Namespace;
 import org.openmodelica.modelicaml.common.dialogs.DialogMessage;
 import org.openmodelica.modelicaml.common.services.ModelicaMLServices;
 import org.openmodelica.modelicaml.common.utls.ResourceManager;
 import org.openmodelica.modelicaml.helper.impl.TestScenariosCollector;
+import org.openmodelica.modelicaml.helper.impl.TestSimulationModelCombination;
 
 public class SelectTestScenariosAndRequirementsDialog extends TitleAreaDialog {
@@ -47,6 +47,6 @@
 	private HashSet<Element> discardedTestScenarios;
 	
-	// requirements that are referenced by the test scenarios and for which all clients are satisfied 
-	private HashSet<Element> selectedRequirements;
+//	// requirements that are referenced by the test scenarios and for which all clients are satisfied 
+//	private HashSet<Element> selectedRequirements;
 
 	// requirements that are referenced by the test scenarios and for which NOT all clients are satisfied 
@@ -70,4 +70,6 @@
 	private List<TreeItem> treeItems = new ArrayList<TreeItem>();
 
+	private HashMap<Element, TestSimulationModelCombination> tsToTestSimulationModelCombination;
+	
 	private static final int DECORATION_WARNING = 0 ;
 	private static final int DECORATION_ERROR = 1 ;
@@ -91,5 +93,6 @@
 			Element systemModel,
 			TestScenariosCollector tsc,
-			String collectionLog) {
+			String collectionLog,
+			HashMap<Element, TestSimulationModelCombination> tsToTestSimulationModelCombination) {
 		
 		super(parentShell);
@@ -97,9 +100,10 @@
 		this.selectedTestScenarios = selectedTestScenarios;
 		this.discardedTestScenarios = discardedTestScenarios;
-		this.selectedRequirements = selectedRequirements;
+//		this.selectedRequirements = selectedRequirements;
 		this.discardedRequirements = discardedRequirements;
 		this.systemModel = systemModel;
 		this.tsc = tsc;
 		this.collectionLog = collectionLog;
+		this.tsToTestSimulationModelCombination = tsToTestSimulationModelCombination;
 	}
 
@@ -129,16 +133,50 @@
 		TabFolder tabFolder = new TabFolder(container, SWT.NONE);
 		tabFolder.setBounds(10, 10, 616, 315);
-		
-		TabItem tbtmTestScenarios = new TabItem(tabFolder, SWT.NONE);
+
+		// TAB: Pre-selected test scenarios
+		TabItem tbtmPreSelectedTestScenarios = new TabItem(tabFolder, SWT.NONE);
 //		tbtmTestScenarios.setImage(ResourceManager.getPluginImage("org.eclipse.ui", "/icons/full/elcl16/close_view.gif"));
-		tbtmTestScenarios.setText("Test Scenarios");
-		
-		final Tree tree = new Tree(tabFolder, SWT.CHECK);
-		buildTree(tree);
-		
-		// Add the listener
-		tree.addSelectionListener(new CheckboxTreeSelectionListener());
-		
-		tbtmTestScenarios.setControl(tree);
+		String metricPreSelected = "("+selectedTestScenarios.size()+" of " + tsc.getAllTS().size() + ")";
+		tbtmPreSelectedTestScenarios.setText("Preselected Test Scenarios " + metricPreSelected);
+		
+		final Tree treePreSelectedTestScenarios = new Tree(tabFolder, SWT.CHECK);
+		buildTree(treePreSelectedTestScenarios, false);
+		
+		// Add listeners
+		treePreSelectedTestScenarios.addSelectionListener(new CheckboxTreeSelectionListener());
+		treePreSelectedTestScenarios.addListener(SWT.MouseDoubleClick, new Listener() {
+		      public void handleEvent(Event event) {
+		        Point point = new Point(event.x, event.y);
+		        TreeItem item = treePreSelectedTestScenarios.getItem(point);
+		        if (item != null) {
+		        	openDescription(item);
+		        }
+		      }
+		    });
+	
+		tbtmPreSelectedTestScenarios.setControl(treePreSelectedTestScenarios);
+		
+		// TAB: Discarded test scenarios
+		TabItem tbtmDiscardedTestScenarios = new TabItem(tabFolder, SWT.NONE);
+//		tbtmTestScenarios.setImage(ResourceManager.getPluginImage("org.eclipse.ui", "/icons/full/elcl16/close_view.gif"));
+		String metricDiscarded  = "("+discardedTestScenarios.size()+" of " + tsc.getAllTS().size() + ")";
+		tbtmDiscardedTestScenarios.setText("Discarded Test Scenarios " + metricDiscarded);
+		
+		final Tree treeDiscardedTestScenarios = new Tree(tabFolder, SWT.CHECK);
+		buildTree(treeDiscardedTestScenarios, true);
+		
+		// Add listeners
+		treeDiscardedTestScenarios.addSelectionListener(new CheckboxTreeSelectionListener());
+		treeDiscardedTestScenarios.addListener(SWT.MouseDoubleClick, new Listener() {
+		      public void handleEvent(Event event) {
+		        Point point = new Point(event.x, event.y);
+		        TreeItem item = treeDiscardedTestScenarios.getItem(point);
+		        if (item != null) {
+		        	openDescription(item);
+		        }
+		      }
+		    });
+		tbtmDiscardedTestScenarios.setControl(treeDiscardedTestScenarios);
+		
 
 		Button btnSelectAll = new Button(container, SWT.NONE);
@@ -170,4 +208,5 @@
 			public void mouseDown(MouseEvent e) {
 				for (TreeItem treeItem : treeItems) {
+					
 					treeItem.setChecked(false);
 					// remove from to maps.
@@ -200,7 +239,11 @@
 			@Override
 			public void mouseDown(MouseEvent e) {
-				tree.removeAll();
+				treePreSelectedTestScenarios.removeAll();
+				treeDiscardedTestScenarios.removeAll();
+				
 				clearAllLists();
-				buildTree(tree);
+				
+				buildTree(treePreSelectedTestScenarios, false);
+				buildTree(treeDiscardedTestScenarios, true);
 			}
 		});
@@ -234,33 +277,25 @@
 
 	
-	private void buildTree(Tree treeRoot){
-	
-			if (this.selectedTestScenarios != null) {
-	
-				/*
-				 *  collect packages (owner) of selected test scenarios and create tree items. 
-				 */
-				List<Element> packagesOfTheSelectedTestScenariosSorted = getSortedByName(getTestScenarioPackages(this.selectedTestScenarios));
-				createPkgTreeItems(treeRoot, packagesOfTheSelectedTestScenariosSorted, true, false);
-				
-				// Sort test scenarios alphabetically 
-				List<Element> selectedTestScenariosSorted = getSortedByName(this.selectedTestScenarios);
-				for (Element testScenario : selectedTestScenariosSorted) {
-					if (testScenario instanceof NamedElement) {
-						createTestScenarioTreeItem(treeRoot, testScenario, false);
-					}
-				}				
-			}
-			
-			if (discardedTestScenarios != null && discardedTestScenarios.size() > 0) {
-				List<Element> packagesOfTheDiscardedTestScenariosSorted = getSortedByName(getTestScenarioPackages(discardedTestScenarios));
-				createPkgTreeItems(treeRoot, packagesOfTheDiscardedTestScenariosSorted, false, true);
-	
-				// add discarded test scenarios so that the user can still decide to generate the simulation model for them
-				for (Element discardedTestScenario : discardedTestScenarios) {
-					createTestScenarioTreeItem(treeRoot, discardedTestScenario, true);
-				}
-			}
-		}
+	private void buildTree(Tree treeRoot, boolean isDiscardedTree){
+		
+		HashSet<Element> testScenarios = new HashSet<Element>();
+		if (this.selectedTestScenarios != null && !isDiscardedTree) {
+			testScenarios.addAll(this.selectedTestScenarios);
+		}
+		else if (this.discardedTestScenarios != null && isDiscardedTree) {
+			testScenarios.addAll(this.discardedTestScenarios);
+		}
+		
+		List<Element> packagesOfTheSelectedTestScenariosSorted = ModelicaMLServices.getSortedByName(getTestScenarioPackages(this.selectedTestScenarios));
+		createPkgTreeItems(treeRoot, packagesOfTheSelectedTestScenariosSorted, !isDiscardedTree, isDiscardedTree);
+		
+		List<Element> testScenariosSorted = ModelicaMLServices.getSortedByName(testScenarios);
+		for (Element testScenario : testScenariosSorted) {
+			if (testScenario instanceof NamedElement) {
+				createTestScenarioTreeItem(treeRoot, testScenario, isDiscardedTree);
+			}
+		}	
+
+	}
 
 	private HashSet<Element> getTestScenarioPackages(HashSet<Element> testScenarios){
@@ -305,4 +340,5 @@
 	
 	private TreeItem getPackageTreeItem(Tree treeRoot, Element testScenario, boolean isDiscarded){
+		
 		TreeItem pkgItem = null;
 		// find the right package node at the 1 tree-level.
@@ -327,5 +363,4 @@
 	private void createTestScenarioTreeItem(Tree treeRoot, Element testScenario, boolean isDiscarded){
 
-//		TreeItem testScenarioItem = new TreeItem(treeRoot, 0);
 		TreeItem pkgItem = getPackageTreeItem(treeRoot, testScenario, isDiscarded);
 		TreeItem testScenarioItem = null;
@@ -365,24 +400,25 @@
 		
 		// sort requirements by requirement id
-		List<Element> associatedRequirements = getSortedByRequirementId(tsc.getTsToReq().get(testScenario));
+		List<Element> associatedRequirements = ModelicaMLServices.getSortedByRequirementId(tsc.getTsToReq().get(testScenario));
 		if (associatedRequirements != null) {
 			
-			// create info item
-			TreeItem testScenarioReqInfoNodeItem = new TreeItem(testScenarioItem, 0);
-//			treeItems.add(testScenarioReqInfoNodeItem); // there is no need to know info items.
-			String infoNodeTitle = "";
-			if (isDiscarded) {
-				infoNodeTitle = "Linked requirements:";
-			}
-			else {
-				infoNodeTitle = "Can be used to verify '" + ((NamedElement)systemModel).getName() + "' against the following requirements: ";
-			}
-			testScenarioReqInfoNodeItem.setText(infoNodeTitle);
-			testScenarioReqInfoNodeItem.setImage(ResourceManager.getPluginImage("org.eclipse.ui", "/icons/full/obj16/info_tsk.gif"));
-			testScenarioReqInfoNodeItem.setGrayed(true);
+//			// create info item
+//			TreeItem testScenarioReqInfoNodeItem = new TreeItem(testScenarioItem, 0);
+////			treeItems.add(testScenarioReqInfoNodeItem); // there is no need to know info items.
+//			String infoNodeTitle = "";
+//			if (isDiscarded) {
+//				infoNodeTitle = "Linked requirements:";
+//			}
+//			else {
+//				infoNodeTitle = "Can be used to verify '" + ((NamedElement)systemModel).getName() + "' against the following requirements: ";
+//			}
+//			testScenarioReqInfoNodeItem.setText(infoNodeTitle);
+//			testScenarioReqInfoNodeItem.setImage(ResourceManager.getPluginImage("org.eclipse.ui", "/icons/full/obj16/info_tsk.gif"));
+//			testScenarioReqInfoNodeItem.setGrayed(true);
 			
 			// create requirement items
 			for (Element req : associatedRequirements) {
-				createRequirementTreeItem(testScenarioReqInfoNodeItem, req, testScenario, isDiscarded);
+//				createRequirementTreeItem(testScenarioReqInfoNodeItem, req, testScenario, isDiscarded);
+				createRequirementTreeItem(testScenarioItem, req, testScenario, isDiscarded);
 			}
 		}
@@ -391,6 +427,4 @@
 	private void createRequirementTreeItem(TreeItem parentItem, Element req, Element testScenario, boolean isDiscarded){
 		String prefix = requirementNamePrefix;
-		
-//		TreeItem reqItem = new TreeItem(testScenarioItem, 0);
 		TreeItem reqItem = new TreeItem(parentItem, 0);
 		treeItems.add(reqItem);
@@ -400,15 +434,10 @@
 		reqData.setTestScenarioElement(testScenario);
 		
+		// if this is a requirement for which not all required clients are satisfied:
 		if (this.discardedRequirements.contains(req)) {
-			reqData.setIsDiscarded(true);
-			// prefix = prefix + "(INCONSISTENT) ";
-			reqItem.setImage(decorateError(ResourceManager.getPluginImage("org.openmodelica.modelicaml.profile", "resources/icons/icons16/requirement.gif")));
-			
-			// indicate inconsistencies
-//			testScenarioItem.setImage(decorateWarning(ResourceManager.getPluginImage("org.openmodelica.modelicaml.profile", "resources/icons/icons16/calculationModel.gif")));
-
 			// DO NOT preselect 
 			reqItem.setChecked(false);
-			
+			reqData.setIsDiscarded(true);
+			reqItem.setImage(decorateError(ResourceManager.getPluginImage("org.openmodelica.modelicaml.profile", "resources/icons/icons16/requirement.gif")));
 			// propagate error to all parents
 			propagateDecoration(reqItem, DECORATION_ERROR);
@@ -416,12 +445,12 @@
 		else {
 			reqData.setIsDiscarded(false);
-			
-			// preselect
-			reqItem.setChecked(true);
 			reqItem.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.profile", "resources/icons/icons16/requirement.gif"));
 			
+			// if the discarded tree is being built then do not preselect requirements and add them to the initial map.
 			if (!isDiscarded) {
 				// initially add to map
 				addToTestScenarioToRequirementsMap(testScenario, req);
+				// preselect
+				reqItem.setChecked(true);
 			}
 		}
@@ -432,12 +461,117 @@
 		reqItem.setData(reqData);
 	}
-	
-	
-	
-	
-	
+
+	// Tree Item Description Handling ************************************************************************ 
+	
+	private void openDescription(TreeItem item){
+		Object data = item.getData();
+    	if (data instanceof TreeItemData) {
+			Element testSceanrio = null;
+    		if ( ((TreeItemData)data).isRequirement) {
+				// get the test scenario and create a description of the combination
+				testSceanrio = ((TreeItemData)data).getTestScenarioElement();
+			}
+			if ( ((TreeItemData)data).isTestScenario) {
+				// get the test scenario and create a description of the combination
+				testSceanrio = ((TreeItemData)data).getTestScenarioElement();
+			}
+			
+			if (testSceanrio != null) {
+				String description = createDescription(testSceanrio);
+				DialogMessage dialog = new DialogMessage(new Shell(), "Test Simulation Model: Details", 
+						"Details of the selected combination of system model and test scenario:", 
+						description);
+				dialog.open();
+			}
+		}
+	}
+	
+	private String createDescription(Element testScenario){
+		String description = "";
+		TestSimulationModelCombination tsmc = tsToTestSimulationModelCombination.get(testScenario);
+		if (tsmc != null) {
+			Element systemModel = tsmc.getSystemModel();
+			description = description +
+					lineDelimiterString + 
+					"\nSystem Model: '"+((NamedElement)systemModel).getName()+"' ("+((NamedElement)systemModel).getQualifiedName()+")" +
+					getAdditionalModelsString(tsmc.getRequiredModels_systemModel(), tsmc, systemModel) + 
+					
+					lineDelimiterString + 
+					"\nTest Scenario: '"+((NamedElement)testScenario).getName()+"'("+((NamedElement)testScenario).getQualifiedName()+")" +
+					getAdditionalModelsString(tsmc.getRequiredModels_testScenario(), tsmc, testScenario) 
+					;
+			
+				description = description + getRequirementsString("", tsmc.getRequirements(), tsmc);
+		}
+		return description.trim();
+	}
+	
+	private static final String lineDelimiterString = "\n";
+//		"\n------------------------------------------------------------------------------ \n";
+
+	
+	private String getAdditionalModelsString(HashSet<Element> set, TestSimulationModelCombination tsmc, Element model){
+		String string = "";
+		if (set != null && set.size() > 0) {
+			string = "\n    - models required in addition: \n";
+			string = string + getAdditionalModelsStringParts(set, "         ", tsmc)
+			 + getUnsatisfiedClients("    ", model, tsmc);
+		}
+		
+		return string;
+	}
+	
+	private String getRequirementsString(String prefix, HashSet<Class> set, TestSimulationModelCombination tsmc){
+		String string  = "";
+		HashSet<Element> tempSet = new HashSet<Element>();
+		for (Element element : set) {
+			tempSet.add(element);
+		}
+		
+		List<Element> sortedList = ModelicaMLServices.getSortedByName(tempSet);
+		for (Element requirement : sortedList) {
+			if (requirement instanceof NamedElement) {
+				string = string + lineDelimiterString;
+				string = string + prefix +"Requirement: '" + ((NamedElement)requirement).getName() 
+						+ "' ("+((NamedElement)requirement).getQualifiedName()+")";
+				string = string + getAdditionalModelsString(tsmc.getRequiredModels_requirements().get(requirement), tsmc, requirement) + "\n";
+			}
+		}
+		return string;
+	}
+	
+	private String getAdditionalModelsStringParts(HashSet<Element> set, String prefix, TestSimulationModelCombination tsmc){
+		String string  = "";
+		List<Element> sortedList = ModelicaMLServices.getSortedByName(set);
+		for (Element element : sortedList) {
+			if (element instanceof NamedElement) {
+				string = string + prefix + "- " + getAlwaysIncludeString(element, tsmc) + ((NamedElement)element).getName() 
+				+ " ("+((NamedElement)element).getQualifiedName()+")\n";
+			}
+		}
+		return string;
+	}
+	
+	private String getAlwaysIncludeString(Element model, TestSimulationModelCombination tsmc){
+		String string = "";
+		if (tsmc.getAlwaysInclude().contains(model)) {
+			return "(always) ";
+		}
+		
+		return string;
+	}
+	
+	private String getUnsatisfiedClients(String prefix, Element element, TestSimulationModelCombination tsmc){
+		String string = "";
+		String unsatisfiedClientsString = tsmc.getClientsDotPathAsString(tsmc.getUnsatisfiedRequiredClients(element));
+		if (!unsatisfiedClientsString.trim().equals("")) {
+			string = prefix + "- unsatisfied required clients: " + "\n";
+			string = string + "         " + unsatisfiedClientsString;
+		}
+		return string;
+	}
 	
 	// Utls ************************************************************************ 
-	
+
 	private void clearAllLists(){
 		selectedTestScenariosWithRequirements.clear();
@@ -472,57 +606,4 @@
 		}
 	}
-	
-	
-	private List<Element> getSortedByName(HashSet<Element> set){
-		if (set == null) { return null; }
-
-		List<Element> listSorted = new ArrayList<Element>(set);
-		Comparator<Element> c = new Comparator<Element>() {
-			@Override
-			public int compare(Element arg0, Element arg1) {
-				if (arg0 instanceof NamedElement) {
-					return ((NamedElement)arg0).getName().compareToIgnoreCase( ((NamedElement)arg1).getName());
-				}
-				return arg0.toString().compareToIgnoreCase(arg1.toString());
-			}
-		};
-		Collections.sort(listSorted, c);
-		
-		return listSorted;
-	}
-	
-	private List<Element> getSortedByQName(HashSet<Element> set){
-		if (set == null) { return null; }
-
-		List<Element> listSorted = new ArrayList<Element>(set);
-		Comparator<Element> c = new Comparator<Element>() {
-			@Override
-			public int compare(Element arg0, Element arg1) {
-				if (arg0 instanceof NamedElement) {
-					return ((NamedElement)arg0).getQualifiedName().compareToIgnoreCase( ((NamedElement)arg1).getQualifiedName());
-				}
-				return arg0.toString().compareToIgnoreCase(arg1.toString());
-			}
-		};
-		Collections.sort(listSorted, c);
-		
-		return listSorted;
-	}
-	
-	private List<Element> getSortedByRequirementId(HashSet<Element> set){
-		if (set == null) { return null; }
-		List<Element> listSorted = new ArrayList<Element>(set);
-		Comparator<Element> c = new Comparator<Element>() {
-			@Override
-			public int compare(Element arg0, Element arg1) {
-				return ModelicaMLServices.getRequirementID(arg0).trim().compareToIgnoreCase( ModelicaMLServices.getRequirementID(arg1).trim());
-			}
-		};
-		Collections.sort(listSorted, c);
-		
-		return listSorted;
-	}
-	
-	
 	
 	// Image handling ************************************************************************
@@ -588,9 +669,11 @@
 							selectedTestScenariosWithRequirements.put(tesSscenario, new HashSet<Element>());
 							
-							// get the info node:
-							TreeItem[] infoNode = ((TreeItem)event.item).getItems();
+//							// get the info node:
+//							TreeItem[] infoNode = ((TreeItem)event.item).getItems();
+//							
+//							// add all test scenario linked requirements to map
+//							TreeItem[] requirementsItems = infoNode[0].getItems();
 							
-							// add all test scenario linked requirements to map
-							TreeItem[] requirementsItems = infoNode[0].getItems();
+							TreeItem[] requirementsItems = ((TreeItem)event.item).getItems();
 							for (int i = 0; i < requirementsItems.length; i++) {
 								TreeItem reqItem = requirementsItems[i];
@@ -621,9 +704,11 @@
 								if (testScenarioItem.getItems() != null && testScenarioItem.getItems().length > 0) {
 								
-									// get the info node
-									TreeItem[] infoNode = testScenarioItem.getItems();
+//									// get the info node
+//									TreeItem[] infoNode = testScenarioItem.getItems();
+//									
+//									// add all test scenario linked requirements to map
+//									TreeItem[] requirementsItems = infoNode[0].getItems();
 									
-									// add all test scenario linked requirements to map
-									TreeItem[] requirementsItems = infoNode[0].getItems();
+									TreeItem[] requirementsItems = testScenarioItem.getItems();
 									for (int j = 0; j < requirementsItems.length; j++) {
 										TreeItem reqItem = requirementsItems[j];
Index: unk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/handlers/SimulationModelsGenaratorHandler.java
===================================================================
--- /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/handlers/SimulationModelsGenaratorHandler.java	(revision 909)
+++ 	(revision )
@@ -1,270 +1,0 @@
-/*
- * This file is part of OpenModelica.
- *
- * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
- * c/o Linköpings universitet, Department of Computer and Information Science,
- * SE-58183 Linköping, Sweden.
- *
- * All rights reserved.
- *
- * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR 
- * THIS OSMC PUBLIC LICENSE (OSMC-PL). 
- * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
- * OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE. 
- *
- * The OpenModelica software and the Open Source Modelica
- * Consortium (OSMC) Public License (OSMC-PL) are obtained
- * from OSMC, either from the above address,
- * from the URLs: http://www.ida.liu.se/projects/OpenModelica or  
- * http://www.openmodelica.org, and in the OpenModelica distribution. 
- * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
- *
- * This program is distributed WITHOUT ANY WARRANTY; without
- * even the implied warranty of  MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
- * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
- *
- * See the full OSMC Public License conditions for more details.
- *
- * Main author: Wladimir Schamai, EADS Innovation Works / Linköping University, 2009-now
- *
- * Contributors: 
- *   Uwe Pohlmann, University of Paderborn 2009-2010, contribution to the Modelica code generation for state machine behavior, contribution to Papyrus GUI adoptations
- *   Parham Vasaiely, EADS Innovation Works / Hamburg University of Applied Sciences 2009-2011, implementation of simulation plugins
- */
-package org.openmodelica.modelicaml.helper.handlers;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
-import java.util.List;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.core.services.ServiceException;
-import org.eclipse.papyrus.core.services.ServicesRegistry;
-import org.eclipse.papyrus.core.utils.BusinessModelResolver;
-import org.eclipse.papyrus.core.utils.ServiceUtils;
-import org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers;
-import org.eclipse.papyrus.resource.NotFoundException;
-import org.eclipse.papyrus.resource.uml.UmlModel;
-import org.eclipse.papyrus.resource.uml.UmlUtils;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.NamedElement;
-import org.openmodelica.modelicaml.common.dialogs.DialogMessage;
-import org.openmodelica.modelicaml.helper.impl.SimulationModelsGenarator;
-
-public class SimulationModelsGenaratorHandler extends AbstractHandler {
-
-	private EObject selectedElement = null;
-	private HashSet<Element> sourceModels; 
-	private Element targetPackage;
-	private Element requirementsPackage; 
-	private Element testScenariosPackage; 
-	private Element valueMediatorsPackage;
-	private SimulationModelsGenarator smg;
-	
-	/* (non-Javadoc)
-	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
-	 */
-	@Override
-	public Object execute(ExecutionEvent event) throws ExecutionException {
-		selectedElement = (EObject) adaptSelectedElement(getCurrentSelections().get(0));
-		
-		if (selectedElement instanceof Class) {
-			
-			/* TODO: let the user select the target package, requirements package, test scenarios package and the value mediators package.
-			 * preselect all to the root UML Model from which the user selected the models to generate the simulation models for.
-			 */
-			
-			sourceModels = new HashSet<Element>();
-			sourceModels.add((Class)selectedElement);
-			
-			// get the uml model
-			UmlModel papyrusModel = UmlUtils.getUmlModel();
-			if (papyrusModel != null ) {
-				try {
-					targetPackage = (Element) papyrusModel.lookupRoot();
-				} catch (NotFoundException e) {
-					e.printStackTrace();
-					MessageDialog.openError(new Shell(), "Target Package Selection", "Cannot access the root model in Papyrus.");
-				}
-			}
-
-//			targetPackage = ((Class)selectedElement).getModel();
-			requirementsPackage = ((Class)selectedElement).getModel(); 
-			testScenariosPackage = ((Class)selectedElement).getModel(); 
-			valueMediatorsPackage = ((Class)selectedElement).getModel();
-			
-			Boolean go = MessageDialog.openQuestion(new Shell(), "Please confirm ...", "This helper will create a package " +
-					"that will contain miltiple simulation models each including one test scenario and all requirements "+ 
-					"that can be tested using this test scenario and the selected system model." +
-					"\n\nNote, only simulation models that have test scenarios and requirements with appropriate value bindings will be collected." +
-					"\n\n" +
-					
-					"   - Selected system model: '" + ((Class)selectedElement).getName() + "'\n" + 
-					"   - Package to store generated Sim. Models in: '" + ((NamedElement)targetPackage).getName() + "'\n" + 
-					"   - Package for Requirements search: '" + ((NamedElement)requirementsPackage).getName() + "'\n" +
-					"   - Package for Test Scnearios search: '" + ((NamedElement)testScenariosPackage).getName() + "'\n" +
-					"   - Package for Value Mediators search: '" + ((NamedElement)valueMediatorsPackage).getName() + "'\n"
-					);
-			
-			if (go) {
-				try {
-					ServicesRegistry  serviceRegistry = ServiceUtilsForActionHandlers.getInstance().getServiceRegistry();
-					TransactionalEditingDomain  editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
-					
-					smg = new SimulationModelsGenarator(
-							sourceModels, 
-							targetPackage,  
-							requirementsPackage, 
-							testScenariosPackage, 
-							valueMediatorsPackage);
-					
-					if (!smg.isCanceled()) {
-						// execute 
-						editingDomain.getCommandStack().execute(getCommand(editingDomain));
-					}
-					
-					// OBSOLETE: this is solved by a "Log" button in the GUI for selecting the test scenarios and requirements.
-					
-					/* TODO: prepare a better generation results overview for 
-					 * which simulation models were created 
-					 * which requirements were discarded 
-					 * which requirements are not covered by this test suite
-					 * which test scenarios are discarded
-					 */
-					
-//					// Simple results overview
-//					if ( !smg.isCanceled() && !smg.getLog().trim().equals("") ) {
-//						String infoText = "Simulation Models Generation:";
-//						String msg = "";
-//						msg = msg + "Number of created simulation models for '" + ((NamedElement)selectedElement).getName() 
-//										+ "' : " + smg.getTestScenariosToBeInstantiated().size() + "\n";
-//						msg = msg + "Number of discarded test scenarios: " + smg.getTestScenariosDiscarded().size() + "\n";
-//						msg = msg + "Number requirements that are instantiated: " + smg.getRequirementsToBeInstantiated().size() + "\n";
-//						msg = msg + "Number of discarded requirements: " + smg.getRequirementsDiscarded().size() + "\n";
-//						
-//						msg = msg + "\n   *** Generation log messages ***";
-//						msg = msg + smg.getLog();
-//						// show translation messages
-//						DialogMessage dialog = new DialogMessage(new Shell(), "Result", infoText, msg);
-//						dialog.open();
-//					}
-
-				} catch (ServiceException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
-			}
-		}
-		return null;
-	}
-
-	/**
-	 * Gets the test oracle element creation command.
-	 *
-	 * @param editingDomain the editing domain
-	 * @param owningClass the owning class
-	 * @return the test oracle element creation command
-	 */
-	protected Command getCommand(TransactionalEditingDomain editingDomain) {
-		CompoundCommand cc = new CompoundCommand("Generating simulation models for '" + ((Class)selectedElement).getQualifiedName() + "'");
-		Command command = new RecordingCommand(editingDomain) {
-			@Override
-			protected void doExecute() {
-				// collect data, create uml elements
-				/* TODO: check if there performance issue. If yes then the data collection
-				 * and creation of the uml elements should be separated in the class SimulationModelsGenarator
-				 */
-				try {
-					smg.generate();
-					new ProgressMonitorDialog(new Shell()).run(true, true, smg);
-				} catch (InvocationTargetException e) {
-					e.printStackTrace();
-					MessageDialog.openError(new Shell(), "Simulation Models Generation Process Error", "It was not possible to invoce the generation of simulation models operation.");
-				} catch (InterruptedException e) {
-					e.printStackTrace();
-					MessageDialog.openError(new Shell(), "Simulation Models Generation Process Abort", "The generation of simulation models was canceled.");
-				}
-
-//				smg.generate();
-			}
-		};
-		cc.append(command);
-		return (cc.unwrap());
-	}
-	
-	/* (non-Javadoc)
-	 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
-	 */
-	@Override
-	public boolean isEnabled() {
-		// TODO Auto-generated method stub
-		return true;
-	}
-
-
-//	@Override
-//	public boolean isHandled() {
-//		// TODO Auto-generated method stub
-//		return false;
-//	}
-
-	
-	/**
- * Gets the current selections.
- * 
- * @return the current selections
- */
-private List<Object> getCurrentSelections() {
-		ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
-		if(selection instanceof IStructuredSelection) {
-			IStructuredSelection structuredSelection = (IStructuredSelection)selection;
-			return structuredSelection.toList();
-		}
-		return null;
-	}
-	
-	
-	/**
-	 * Adapt selected element.
-	 * 
-	 * @param selection
-	 *            the selection
-	 * @return the e object
-	 */
-	protected EObject adaptSelectedElement( Object selection) {
-		EObject eObject = null;
-		if(selection != null) {
-			if(selection instanceof IAdaptable) {
-				selection = ((IAdaptable)selection).getAdapter(EObject.class);
-			}
-			Object businessObject = BusinessModelResolver.getInstance().getBusinessModel(selection);
-			if(businessObject instanceof EObject) {
-				eObject = (EObject)businessObject;
-			}
-		}
-		return eObject;
-	}
-	
-	
-	
-
-	
-	
-	
-}
Index: /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/handlers/TestSimulationModelsGenaratorHandler.java
===================================================================
--- /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/handlers/TestSimulationModelsGenaratorHandler.java	(revision 910)
+++ /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/handlers/TestSimulationModelsGenaratorHandler.java	(revision 910)
@@ -0,0 +1,246 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
+ * c/o Linköpings universitet, Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR 
+ * THIS OSMC PUBLIC LICENSE (OSMC-PL). 
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+ * OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE. 
+ *
+ * The OpenModelica software and the Open Source Modelica
+ * Consortium (OSMC) Public License (OSMC-PL) are obtained
+ * from OSMC, either from the above address,
+ * from the URLs: http://www.ida.liu.se/projects/OpenModelica or  
+ * http://www.openmodelica.org, and in the OpenModelica distribution. 
+ * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without
+ * even the implied warranty of  MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
+ * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
+ *
+ * See the full OSMC Public License conditions for more details.
+ *
+ * Main author: Wladimir Schamai, EADS Innovation Works / Linköping University, 2009-now
+ *
+ * Contributors: 
+ *   Uwe Pohlmann, University of Paderborn 2009-2010, contribution to the Modelica code generation for state machine behavior, contribution to Papyrus GUI adoptations
+ *   Parham Vasaiely, EADS Innovation Works / Hamburg University of Applied Sciences 2009-2011, implementation of simulation plugins
+ */
+package org.openmodelica.modelicaml.helper.handlers;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.core.services.ServiceException;
+import org.eclipse.papyrus.core.services.ServicesRegistry;
+import org.eclipse.papyrus.core.utils.BusinessModelResolver;
+import org.eclipse.papyrus.core.utils.ServiceUtils;
+import org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.resource.NotFoundException;
+import org.eclipse.papyrus.resource.uml.UmlModel;
+import org.eclipse.papyrus.resource.uml.UmlUtils;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+import org.openmodelica.modelicaml.common.dialogs.DialogMessage;
+import org.openmodelica.modelicaml.helper.impl.TestSimulationModelsGenarator;
+
+public class TestSimulationModelsGenaratorHandler extends AbstractHandler {
+
+	private EObject selectedElement = null;
+	private HashSet<Element> sourceModels; 
+	private Element targetPackage;
+	private Element requirementsPackage; 
+	private Element testScenariosPackage; 
+	private Element valueMediatorsPackage;
+	private TestSimulationModelsGenarator smg;
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+	 */
+	@Override
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		selectedElement = (EObject) adaptSelectedElement(getCurrentSelections().get(0));
+		
+		if (selectedElement instanceof Class) {
+			
+			/* TODO: let the user select the target package, requirements package, test scenarios package and the value mediators package.
+			 * preselect all to the root UML Model from which the user selected the models to generate the simulation models for.
+			 */
+			
+			sourceModels = new HashSet<Element>();
+			sourceModels.add((Class)selectedElement);
+			
+			// get the uml model
+			UmlModel papyrusModel = UmlUtils.getUmlModel();
+			if (papyrusModel != null ) {
+				try {
+					targetPackage = (Element) papyrusModel.lookupRoot();
+				} catch (NotFoundException e) {
+					e.printStackTrace();
+					MessageDialog.openError(new Shell(), "Target Package Selection", "Cannot access the root model in Papyrus.");
+				}
+			}
+
+//			targetPackage = ((Class)selectedElement).getModel();
+			requirementsPackage = ((Class)selectedElement).getModel(); 
+			testScenariosPackage = ((Class)selectedElement).getModel(); 
+			valueMediatorsPackage = ((Class)selectedElement).getModel();
+			
+			Boolean go = MessageDialog.openQuestion(new Shell(), "Please confirm ...", "This helper will create a package " +
+					"that will contain miltiple simulation models each including one test scenario and all requirements "+ 
+					"that can be tested using this test scenario and the selected system model." +
+					"\n\nNote, only simulation models that have test scenarios and requirements with appropriate value bindings will be collected." +
+					"\n\n" +
+					
+					"   - Selected system model: '" + ((Class)selectedElement).getName() + "'\n" + 
+					"   - Package to store generated Sim. Models in: '" + ((NamedElement)targetPackage).getName() + "'\n" + 
+					"   - Package for Requirements search: '" + ((NamedElement)requirementsPackage).getName() + "'\n" +
+					"   - Package for Test Scnearios search: '" + ((NamedElement)testScenariosPackage).getName() + "'\n" +
+					"   - Package for Value Mediators search: '" + ((NamedElement)valueMediatorsPackage).getName() + "'\n"
+					);
+			
+			if (go) {
+				try {
+					ServicesRegistry  serviceRegistry = ServiceUtilsForActionHandlers.getInstance().getServiceRegistry();
+					TransactionalEditingDomain  editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
+					
+					smg = new TestSimulationModelsGenarator(
+							sourceModels, 
+							targetPackage,  
+							requirementsPackage, 
+							testScenariosPackage, 
+							valueMediatorsPackage);
+					
+					if (!smg.isTestSimulationModelGenerationCanceled()) {
+						// execute 
+						editingDomain.getCommandStack().execute(getCommand(editingDomain));
+					}
+					if (!smg.isTestSimulationModelGenerationCanceled()) {
+						// show log
+						String msg = "Generation of Test Simulation Models for '" + ((NamedElement)selectedElement).getName() + "'\n" +
+									 "Number of created simulation models: " + smg.getUserSelectedTestScenarios().size() + "\n\n";
+
+						DialogMessage dialog = new DialogMessage(new Shell(), "Test Simulation Models Generation Log", 
+								"Data collecation and models generation log entries:", msg + smg.getLog().trim());
+						dialog.open();
+					}
+
+				} catch (ServiceException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * Gets the test oracle element creation command.
+	 *
+	 * @param editingDomain the editing domain
+	 * @param owningClass the owning class
+	 * @return the test oracle element creation command
+	 */
+	protected Command getCommand(TransactionalEditingDomain editingDomain) {
+		CompoundCommand cc = new CompoundCommand("Generating simulation models for '" + ((Class)selectedElement).getQualifiedName() + "'");
+		Command command = new RecordingCommand(editingDomain) {
+			@Override
+			protected void doExecute() {
+				try {
+					smg.generate();
+					new ProgressMonitorDialog(new Shell()).run(true, true, smg);
+				} catch (InvocationTargetException e) {
+					e.printStackTrace();
+					MessageDialog.openError(new Shell(), "Simulation Models Generation Process Error", "It was not possible to invoce the generation of simulation models operation.");
+				} catch (InterruptedException e) {
+					e.printStackTrace();
+					MessageDialog.openError(new Shell(), "Simulation Models Generation Process Abort", "The generation of simulation models was canceled.");
+				}
+			}
+		};
+		cc.append(command);
+		return (cc.unwrap());
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+	 */
+	@Override
+	public boolean isEnabled() {
+		// TODO Auto-generated method stub
+		return true;
+	}
+
+
+//	@Override
+//	public boolean isHandled() {
+//		// TODO Auto-generated method stub
+//		return false;
+//	}
+
+	
+	/**
+ * Gets the current selections.
+ * 
+ * @return the current selections
+ */
+private List<Object> getCurrentSelections() {
+		ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+		if(selection instanceof IStructuredSelection) {
+			IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+			return structuredSelection.toList();
+		}
+		return null;
+	}
+	
+	
+	/**
+	 * Adapt selected element.
+	 * 
+	 * @param selection
+	 *            the selection
+	 * @return the e object
+	 */
+	protected EObject adaptSelectedElement( Object selection) {
+		EObject eObject = null;
+		if(selection != null) {
+			if(selection instanceof IAdaptable) {
+				selection = ((IAdaptable)selection).getAdapter(EObject.class);
+			}
+			Object businessObject = BusinessModelResolver.getInstance().getBusinessModel(selection);
+			if(businessObject instanceof EObject) {
+				eObject = (EObject)businessObject;
+			}
+		}
+		return eObject;
+	}
+	
+	
+	
+
+	
+	
+	
+}
Index: unk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/SimulationModelsGenarator.java
===================================================================
--- /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/SimulationModelsGenarator.java	(revision 909)
+++ 	(revision )
@@ -1,723 +1,0 @@
-package org.openmodelica.modelicaml.helper.impl;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.HashSet;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.Dependency;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.PackageableElement;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.TypedElement;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.util.UMLUtil;
-import org.openmodelica.modelicaml.common.constants.Constants;
-import org.openmodelica.modelicaml.common.instantiation.ClassInstantiation;
-import org.openmodelica.modelicaml.common.instantiation.TreeObject;
-import org.openmodelica.modelicaml.common.instantiation.TreeParent;
-import org.openmodelica.modelicaml.common.services.ElementsCollector;
-import org.openmodelica.modelicaml.common.services.ModelicaMLServices;
-import org.openmodelica.modelicaml.common.services.StringUtls;
-import org.openmodelica.modelicaml.helper.dialogs.SelectTestScenariosAndRequirementsDialog;
-
-public class SimulationModelsGenarator implements IRunnableWithProgress {
-	
-	public SimulationModelsGenarator(
-			HashSet<Element> sourceModels,
-			Element targetPackage, Element requirementsPackage,
-			Element testScenariosPackage, Element valueMediatorsPackage) {
-		super();
-		this.sourceModels = sourceModels;
-		this.targetPackage = targetPackage;
-		this.requirementsPackage = requirementsPackage;
-		this.testScenariosPackage = testScenariosPackage;
-		this.valueBindingsPackage = valueMediatorsPackage;
-	}
-	
-	// the selected model to generate the simulation models for
-	private HashSet<Element> sourceModels = null;
-
-	// the package for simulation models
-	private Element targetPackage = null;
-	
-	// the package to containing the requirements to be used
-	private Element requirementsPackage = null;
-	// the package to containing the test scenarios to be used
-	private Element testScenariosPackage = null;
-	// the package to containing the value mediators to be used
-	private Element valueBindingsPackage = null;
-	
-	private TestScenariosCollector tsc;
-
-	// all requirements that were collected from the specified requirements package
-	private HashSet<Element> allRequirements = new HashSet<Element>();
-	// all test scenarios that were collected from the specified test scenarios package
-	private HashSet<Element> allTestScenarios = new HashSet<Element>();
-	
-	// all test scenarios that were selected for the selected system model
-	private HashSet<Element> testScenariosToBeInstantiated = new HashSet<Element>();
-	// all test scenarios that discarded because they cannot be used for stimulating the selected system model.
-	private HashSet<Element> testScenariosDiscarded = new HashSet<Element>();
-	
-	/* all requirements that were selected for instantiation because 
-	 * the selected test scenarios reference them and all their clients are satisfied by the selected system model
-	 */
-	private HashSet<Element> requirementsToBeInstantiated = new HashSet<Element>();
-	/* all requirements that were discarded because  
-	 * some of their clients are NOT satisfied by the selected system model.
-	 */
-	private HashSet<Element> requirementsDiscarded = new HashSet<Element>();
-	
-	// messages collected during translation
-	private String log = "";
-	
-	// indicated if the generation was canceled by the user.
-	private boolean canceled = false;
-	
-	
-	public void generate(){
-		
-		if (sourceModels != null) {
-			
-			/*
-			 * TODO: Implement a GUI for selecting the packages were to search for 
-			 * test scenarios, requirements, value mediators and 	
-			 * for selecting the targetPackage to generate the simulation models into.
-			 */
-			
-			// find all test scenarios
-			tsc = new TestScenariosCollector();
-			tsc.collectTestCasesFromPackage((Package) testScenariosPackage, true);
-			allTestScenarios.addAll(tsc.getAllTS());
-
-			/* Collect all requirements in order to be able to determine 
-			 * which are not covered by simulation models.
-			 */
-			ElementsCollector ec = new ElementsCollector();
-			ec.collectElementsFromModel(requirementsPackage, Constants.stereotypeQName_Requirement);
-			allRequirements.addAll(ec.getElements());
-			
-			/* For each of the selected system models create a package containing classes that 
-			 * instantiate all possible combinations of test scenarios and requirements that 
-			 * can be tested using a given test scenario.
-			 * NOTE, 
-			 * 	- only test scenarios will be selected that can be used to stimulate the given system mode
-			 * 	- only requirements will be selected that can be tested using the selected test scenarios 
-			 * 	  and for which for all of its clients the providers inside the system model are present.
-			 */
-			for (Element sourceModel : sourceModels) {
-				// clear all lists because the translation for each source model is individual.
-				clearAllLists();
-				// generate simulation models for the source model 
-				generateSimulationModels(sourceModel);
-			}
-		}
-	}
-	
-	private void clearAllLists(){
-		testScenariosToBeInstantiated.clear();
-		testScenariosDiscarded.clear();
-		requirementsToBeInstantiated.clear();
-		requirementsDiscarded.clear();
-	}
-	
-	private void generateSimulationModels(Element sourceModel){
-		
-		String errorTitle = "Test Simulation Models Generation Helper";
-		String errorMessage = "No test scenarios were found that can be used to stimulate the model " +
-				"'"+((NamedElement)sourceModel).getName()+"'.";
-
-		if (allTestScenarios.size() > 0) {
-			
-			// Instantiate the system model. This is used to determine the required coherence of clients and providers.
-			ClassInstantiation ciSourceModel = new ClassInstantiation((Class) sourceModel, true);
-			ciSourceModel.createTree();
-			
-			for (Element testScenario : allTestScenarios) {
-				/* 1) Find all test scenarios can be used to stimulate this system model,
-				 * 2) Find all requirements, that can be testing the found test scenarios and for which 
-				 * 	  all requirement clients can be bound to the selected system model.
-				 */
-				findTestSenariosAndRequirementsToBeInstantiated(ciSourceModel, (Class) testScenario);
-			}
-			if (testScenariosToBeInstantiated.size() > 0 && requirementsToBeInstantiated.size() > 0) {
-				// Create simulation model for each test scenario and all its referenced (and selected) requirements
-				createSimulationModels(sourceModel);
-			}
-			else {
-				informError(errorTitle, errorMessage);
-			}
-		}
-		else {
-			informError(errorTitle, errorMessage);
-		}
-	}
-	
-	private void informError(String title, String message){
-		MessageDialog.openError(new Shell(), title, message);
-	}
-	
-	private void createSimulationModels(Element sourceModel){
-
-		/* GUI to show the collected and discarded test scenarios and requirements.
-		 * It should enable a selection of test scenarios and requirements to be finally instantiated. 
-		 */
-
-		SelectTestScenariosAndRequirementsDialog dialog = new SelectTestScenariosAndRequirementsDialog(
-				new Shell(), 
-				testScenariosToBeInstantiated, 
-				testScenariosDiscarded, 
-				requirementsToBeInstantiated, 
-				requirementsDiscarded, 
-				sourceModel,
-				tsc,
-				getLog());
-		
-		dialog.open();
-		
-		if (dialog.getReturnCode() == 1) { // Cancel return code
-			setCanceled(true); // indicate abort and stop here. 
-		}
-		else {
-			// Get the selected test scenarios and requirements from the dialog.  
-			HashMap<Element,HashSet<Element>> userSelectedTestScenariosAndRequirements = dialog.getSelectedTestScenariosWithRequirements();
-			HashSet<Element> userSelectedTestScenarios = new HashSet<Element>();
-			userSelectedTestScenarios.addAll(userSelectedTestScenariosAndRequirements.keySet());
-			
-			if (userSelectedTestScenarios.size() > 0) {
-				String pkgName = Constants.simModelsPackageNamePrefix + ((NamedElement)sourceModel).getName();
-				String postFix = getNamePostFix((Package)targetPackage, pkgName);
-				PackageableElement simulationModelsPackage = ((Package)targetPackage).createPackagedElement(pkgName + postFix,UMLPackage.Literals.PACKAGE);
-			
-			
-	//			for (Element testScenario : testScenariosToBeInstantiated) {
-				for (Element testScenario : userSelectedTestScenarios) {
-					
-					if (testScenario instanceof Classifier) {
-						
-						// add class
-						String simulationModelName = Constants.simModelsNamePrefix + ((NamedElement)testScenario).getName();
-						Class simulationModel = ((Package)simulationModelsPackage).createOwnedClass(simulationModelName, false);
-						
-						/*
-						 *  Copy the simulation annotation values 
-						 *  from the TestScenario stereotype to the Simulation (or Test) stereotype 
-						 */
-						Stereotype s_model = simulationModel.getApplicableStereotype(Constants.stereotypeQName_Model);
-						Stereotype s_simulation = simulationModel.getApplicableStereotype(Constants.stereotypeQName_Simulation);
-						Stereotype s_test = simulationModel.getApplicableStereotype(Constants.stereotypeQName_Test);
-						if (s_model != null && s_simulation != null) {
-							simulationModel.applyStereotype(s_model);
-							simulationModel.applyStereotype(s_simulation);
-							simulationModel.applyStereotype(s_test);
-							
-							// Copy the simulation settings from test scenario to the test model.
-							copySimulatioSettings((Class) testScenario, simulationModel);
-						}
-						else {
-							String msg = "ERROR: Cannot apply the stereotype 'Model' and 'Simulation' to '" 
-								+ simulationModel.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
-							addToLog(msg);
-						}
-						
-						// add system model property
-						Property p_systemModel = simulationModel.createOwnedAttribute(
-								Constants.systemModelPropertyNamePrefix 
-								+ StringUtls.replaceSpecChar(((NamedElement)sourceModel).getName().toLowerCase()), 
-								(Type)sourceModel);
-						Stereotype s_component = p_systemModel.getApplicableStereotype(Constants.stereotypeQName_Component);
-						if (s_component != null) {
-							p_systemModel.applyStereotype(s_component);
-						}
-						else {
-							String msg = "ERROR: Cannot apply the stereotype 'Component' to '" 
-								+ p_systemModel.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
-							addToLog(msg);
-						}
-		
-						// add test scenario property
-						Property p_testScenario = simulationModel.createOwnedAttribute(
-								Constants.testScenarioPropertyNamePrefix 
-								+ StringUtls.replaceSpecChar(((NamedElement)testScenario).getName().toLowerCase()), 
-								(Type)testScenario);
-						Stereotype s_calProp = p_testScenario.getApplicableStereotype(Constants.stereotypeQName_CalculatedProperty);
-						if (s_calProp != null) {
-							p_testScenario.applyStereotype(s_calProp);
-						}
-						else {
-							String msg = "ERROR: Cannot apply the stereotype 'CalculatedProperty' to '" + p_testScenario.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
-							addToLog(msg);
-						}
-		
-						// add requirements
-						RequirementsInstantiator ri = new RequirementsInstantiator();
-	//					for (Element requirement : tsc.getTsToReq().get(testScenario)) {
-						for (Element requirement : userSelectedTestScenariosAndRequirements.get(testScenario)) {
-	
-							// if this requirement was selected, i.e. was not discarded
-	//						if (!requirementsDiscarded.contains(requirement) && requirement instanceof Class) {
-							if (requirement instanceof Class) {
-								if (requirement instanceof Classifier) {
-									// get the number of required instantiations
-									int requiredNumberOfInstantions = ri.getMaxNumberOfProviders(simulationModel, (Class) requirement);
-									for (int i = 0; i < requiredNumberOfInstantions; i++) {
-										Property p_req = simulationModel.createOwnedAttribute(
-												Constants.reqirementPropertyNamePrefix + 
-												getRequirementId((NamedElement) requirement) + "_" + 
-												StringUtls.replaceSpecChar(((NamedElement)requirement).getName().toLowerCase()), 
-												(Type) requirement);
-										
-										Stereotype s_reqInst = p_req.getApplicableStereotype(Constants.stereotypeQName_RequirementInstance);
-										
-										if (s_reqInst != null) {
-											p_req.applyStereotype(s_reqInst);
-										}
-										else {
-											String msg = "ERROR: Cannot apply the stereotype 'requirementInstantance' to '" + p_req.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
-											addToLog(msg);
-										}
-									}
-								}
-							}
-						}
-		
-						/*
-						 *  Based on Dependency <<Requires>>, for all test scenarios 
-						 *  and requirements to be instantiated, find models that should be instantiated in addition.
-						 */
-						
-						/*
-						 *  instantiate the created simulation model class in order to search for required additional models
-						 */
-						ClassInstantiation ciTemp = new ClassInstantiation((Class) simulationModel, true);
-						ciTemp.createTree();
-						
-						HashSet<Element> addtionalModels = getAdditionalModels(sourceModels, 
-								testScenariosToBeInstantiated, 
-								requirementsToBeInstantiated,
-								ciTemp);
-						
-						for (Element additionalModel : addtionalModels) {
-							
-							// create property
-							Property p_additionalModel = simulationModel.createOwnedAttribute(
-									Constants.additionalModelPrefix 
-									+ StringUtls.replaceSpecChar(((NamedElement)additionalModel).getName().toLowerCase()), 
-									(Type)additionalModel);
-							
-							// apply stereotype
-							Stereotype s_componentForAdditionalComponent = null;
-							if (additionalModel.getAppliedStereotype(Constants.stereotypeQName_CalculationModel) != null
-									|| additionalModel.getAppliedStereotype(Constants.stereotypeQName_TestScenario) != null) {
-								s_componentForAdditionalComponent = p_systemModel.getApplicableStereotype(Constants.stereotypeQName_CalculatedProperty);	
-							}
-							else {
-								s_componentForAdditionalComponent = p_systemModel.getApplicableStereotype(Constants.stereotypeQName_Component);
-							}
-							if (s_componentForAdditionalComponent != null) {
-								p_additionalModel.applyStereotype(s_componentForAdditionalComponent);
-							}
-							else {
-								String msg = "ERROR: Cannot apply the required stereotype to '" 
-									+ p_additionalModel.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
-								addToLog(msg);
-							}
-						}
-						
-						
-						/* 
-						 * instantiate the created simulation model class
-						 * (it not contains all components)
-						 */
-						ClassInstantiation ci = new ClassInstantiation((Class) simulationModel, true);
-						ci.createTree();
-						
-						// update bindings in the created simulation model class
-						ValueBindingCreator vbc = new ValueBindingCreator();
-						/* Note, the updateAllBindings() is called with the last argument simulateOnly = false  
-						 * so that modifications ARE created in components.
-						 */
-						vbc.updateAllBindings((Package)valueBindingsPackage, ci.getTreeRoot(), ci.getTreeRoot(), false, true, false, false);
-						
-						/*
-						 * Create test verdict code
-						 */
-						TestOracleElementsCreator.createTestEvaluationElements(simulationModel);
-						
-					}
-				}
-			}
-		}
-	}
-	
-	private void copySimulatioSettings(Classifier testScenarioModel, Classifier simulationModel){
-		Stereotype sTestScenario = testScenarioModel.getAppliedStereotype(Constants.stereotypeQName_TestScenario);
-		Stereotype sSimulation = simulationModel.getAppliedStereotype(Constants.stereotypeQName_Simulation);
-		
-		if (sTestScenario != null && sSimulation != null) {
-			Object startTime = testScenarioModel.getValue(sTestScenario, Constants.propertyName_startTime);
-			simulationModel.setValue(sSimulation, Constants.propertyName_startTime, startTime);
-			Object stopTime = testScenarioModel.getValue(sTestScenario, Constants.propertyName_stopTime);
-			simulationModel.setValue(sSimulation, Constants.propertyName_stopTime, stopTime);
-			Object numberOfIntervals = testScenarioModel.getValue(sTestScenario, Constants.propertyName_numberOfIntervals);
-			simulationModel.setValue(sSimulation, Constants.propertyName_numberOfIntervals, numberOfIntervals);
-			Object tolerance = testScenarioModel.getValue(sTestScenario, Constants.propertyName_tolerance);
-			simulationModel.setValue(sSimulation, Constants.propertyName_tolerance, tolerance);
-		}
-	}
-	
-	@SuppressWarnings("rawtypes")
-	private HashSet<Element> getAdditionalModels(
-			HashSet<Element> sourceModels, 
-			HashSet<Element> testScenariosToBeInstantiated, 
-			HashSet<Element> requirementsToBeInstantiated,
-			ClassInstantiation ciTemp){
-		
-		HashSet<Element> listOfAdditionalModels = new HashSet<Element>();
-		
-//		// all models that were selected: system models, test scenarios and requirements
-//		HashSet<Element> allCollectedModels = new HashSet<Element>();
-//		allCollectedModels.addAll(sourceModels);
-//		allCollectedModels.addAll(testScenariosToBeInstantiated);
-//		allCollectedModels.addAll(requirementsToBeInstantiated);
-		
-		// all models that will be instantiated: system models, test scenarios and requirements
-		HashSet<Element> allModelsInInstantiationTree = new HashSet<Element>();
-		allModelsInInstantiationTree.addAll(getAllTreeItemsClasses(ciTemp.getTreeRoot()));
-		
-		for (Element element : allModelsInInstantiationTree) {
-			if (element instanceof NamedElement) {
-				for (Element dep : ((NamedElement)element).getClientDependencies()) {
-					Stereotype s = dep.getAppliedStereotype(Constants.stereotypeQName_Requires);
-					if (s != null) {
-						Object list = dep.getValue(s, Constants.propertyName_onlyIncombinationWith);
-						if ( list instanceof EList && ((EList)list).size() > 0) { // check restriction
-							for (Object referencedModel : (EList<?>)list) {
-								Element referencedModelElement = UMLUtil.getBaseElement((EObject) referencedModel);
-								if (referencedModelElement instanceof Element 
-										&& allModelsInInstantiationTree.contains(referencedModelElement) ) {
-									// add the dependency target to the models that should be instantiated in addition
-									listOfAdditionalModels.add( ((Dependency)dep).getTargets().get(0) );
-								}
-							}
-						}
-						else { // no restriction -> add the dependency target to the list. 
-							listOfAdditionalModels.add( ((Dependency)dep).getTargets().get(0) );
-						}
-					}
-				}
-			}
-		}
-		return listOfAdditionalModels;
-	}
-	
-	private void findTestSenariosAndRequirementsToBeInstantiated(ClassInstantiation ciSourceModel, Class testScenario){
-		// add system model to the simulated instantiation of the 
-		TreeParent simulatedInstantiationTreeRoot = new TreeParent("Simulated Instantiation", null, null, "", false, true, null, null, true);
-		simulatedInstantiationTreeRoot.addChild(ciSourceModel.getTreeRoot());
-		
-		// instantiate test scenario
-		ClassInstantiation ciTestScenario = new ClassInstantiation((Class) testScenario, true);
-		ciTestScenario.createTree();
-		
-		// add test scenario to the simulated instantiation
-		simulatedInstantiationTreeRoot.addChild(ciTestScenario.getTreeRoot());
-		
-		/* get the list of system model clients for which the code could be derived (even if a user interaction would be necessary) 
-		from the test scenario providers */
-		ValueBindingCreator vbc = new ValueBindingCreator();
-		
-		/* Note, the updateAllBindings() is called with the last argument simulateOnly = true  
-		 * so that no modifications are created in components because we only want to analyze possible bindings.
-		 */
-		boolean allSystemModelRquiredClientsAreSatisfied = true;
-		vbc.updateAllBindings((Package)valueBindingsPackage, ciSourceModel.getTreeRoot(), simulatedInstantiationTreeRoot, false, true, false, true);
-		if ( vbc.getAllRequiredClientsFound().size() > 0 
-				&& !vbc.getAllClientsWithPossibleBindingCodeDerivation().containsAll(vbc.getAllRequiredClientsFound())) {
-			allSystemModelRquiredClientsAreSatisfied = false;
-		}
-
-		/* If there is at least one client that uses one of the test scenario providers
-		 * and all test scenario required clients are satisfied by the system model -> search for associated requirements
-		 * else stop here -> this test scenario is not appropriate to be used to stimulate this system model.
-		 */
-		
-		/* NOTE: Checking if test scenario clients are all satisfied by the system model
-		 * is not necessary because a test scenario must not have all clients bound to other model.
-		 * If it is used to test different design alternatives then some of the test scenario clients may be specific to
-		 * one design alternative and are not satisfied by another design alternative. 
-		 */
-		boolean atLeastOneTestScenarioProviderIsUsedInSystemModel = treeContainsOneOf(vbc.getUsedProviders(), ciTestScenario.getTreeRoot());
-
-//		if ( treeContainsOneOf(vbc.getUsedProviders(), ciTestScenario.getTreeRoot()) ) { // if at least one test scenario providers is used to stimulate the system model.
-		if ( atLeastOneTestScenarioProviderIsUsedInSystemModel && allSystemModelRquiredClientsAreSatisfied) {
-//			System.err.println( "selected test scenario: " + ((NamedElement)testScenario).getName());
-			
-			/* Create a new simulated instantiation, 
-			 * add system model to the simulated instantiation 
-			 */
-			TreeParent simulatedInstantiationTreeRoot_reqAndSystemModel = new TreeParent("Simulated Instantiation", null, null, "", false, true, null, null, true);
-			simulatedInstantiationTreeRoot_reqAndSystemModel.addChild(ciSourceModel.getTreeRoot());
-			
-			HashSet<Element> requirementsToBeInstantiated = new HashSet<Element>();
-			// get all requirements that can be tested using this scenario
-			for (Element requirement : tsc.getTsToReq().get(testScenario)) {
-				// instantiate test scenario
-				ClassInstantiation ciReq = new ClassInstantiation((Class) requirement, true);
-				ciReq.createTree();
-				
-				simulatedInstantiationTreeRoot_reqAndSystemModel.addChild(ciReq.getTreeRoot());
-				/* Note, the updateAllBindings() is called with the last argument simulateOnly = true  
-				 * so that no modifications are created in components because we only want to analyze possible bindings.
-				 */
-				vbc.updateAllBindings((Package)valueBindingsPackage, ciReq.getTreeRoot(), 
-						simulatedInstantiationTreeRoot_reqAndSystemModel, false, true, false, true);
-				
-				// if it was possible to derive code for all (required) clients of this requirement using the system model providers
-				if (vbc.getAllClientsFound().size() > 0 
-						&& vbc.getAllClientsWithPossibleBindingCodeDerivation().containsAll(vbc.getAllClientsFound())) {
-					// add to req.list to be instantiated
-					requirementsToBeInstantiated.add(requirement);
-//					System.err.println("selected req.: " + ((NamedElement)requirement).getName());
-				}
-				else if (vbc.getAllRequiredClientsFound().size() > 0 
-						&& vbc.getAllClientsWithPossibleBindingCodeDerivation().containsAll(vbc.getAllRequiredClientsFound())) {
-					// add to req.list to be instantiated
-					requirementsToBeInstantiated.add(requirement);
-//					System.err.println("selected req.: " + ((NamedElement)requirement).getName());
-				}
-				else {
-					requirementsDiscarded.add(requirement);
-//					System.err.println("discarded req.: " + ((NamedElement)requirement).getName());
-
-					// add to log
-					String msg = "DISCARDED: Requirement ("+ModelicaMLServices.getRequirementID(requirement)+") '" + ((NamedElement)requirement).getQualifiedName() + "'" +  
-								"\nFor some of its clients the binding code could NOT be derived using " +
-								"the providers of '"+ciSourceModel.getSelectedClass().getName()+"'. \n" ;
-					addToLog(msg);
-				}
-			}
-			
-			//Collect the test scenario and all its referenced requirements that are selected for instantiation
-			if (requirementsToBeInstantiated.size() > 0 ) {
-				this.testScenariosToBeInstantiated.add(testScenario);
-				this.requirementsToBeInstantiated.addAll(requirementsToBeInstantiated);
-			}
-			else {
-				testScenariosDiscarded.add(testScenario);
-//				System.err.println("discarded test scenario: " + ((NamedElement)testScenario).getName());
-				String msg = "";
-				
-				// if there no requirements referenced by the test scenario
-				if (tsc.getTsToReq().get(testScenario) == null) {
-					msg = "DISCARDED: Test Scenario '" + ((NamedElement)testScenario).getQualifiedName() + "'" +  
-					"\nNo requirements are found that can be tested using this test scenario " +
-					"and the model '"+ciSourceModel.getSelectedClass().getName()+"'. \n" ;
-				}
-				else {
-					msg = "DISCARDED: Test Scenario '" + ((NamedElement)testScenario).getQualifiedName() + "'" +  
-					"\nFor none of the referenced requirements clients the clients are satisfied by providers of " +
-					"the model '"+ciSourceModel.getSelectedClass().getName()+"'. \n" ;
-				}
-				// add to log
-				addToLog(msg);
-			}
-		}
-		else {
-			testScenariosDiscarded.add(testScenario);
-//			System.err.println("discarded test scenario: " + ((NamedElement)testScenario).getName());
-
-			// add to log
-			String msg = "DISCARDED: Test Scenario '" + ((NamedElement)testScenario).getQualifiedName() + "'" + 
-						"\nNone of its providers is used to stimulate the model '"+ciSourceModel.getSelectedClass().getName()+"'. \n" ;
-			addToLog(msg);
-		}
-	}
-	
-	// Utls ##########################################################
-	
-	private String getRequirementId(NamedElement req){
-		Stereotype s_req = req.getAppliedStereotype(Constants.stereotypeQName_Requirement);
-		Object o = req.getValue(s_req, Constants.propertyName_id);
-		if (o instanceof String) {
-			return (String) o;
-		}
-		return "";
-	}
-	
-	private HashSet<TreeObject> getAllTreeItems(TreeParent treeParent){
-		HashSet<TreeObject> allTreeItems = new HashSet<TreeObject>();
-		allTreeItems.add(treeParent);
-		
-		TreeObject[] children = treeParent.getChildren();
-		for (int i = 0; i < children.length; i++) {
-			allTreeItems.add(children[i]);
-			if (children[i] instanceof TreeParent) {
-				allTreeItems.addAll(getAllTreeItems((TreeParent)children[i]));
-			}
-		}
-		
-		return allTreeItems;
-	}
-	
-	private HashSet<Element> getAllTreeItemsClasses(TreeParent treeParent){
-		HashSet<Element> allTreeItems = new HashSet<Element>();
-		
-		TreeObject[] children = treeParent.getChildren();
-		for (int i = 0; i < children.length; i++) {
-			if (children[i].getUmlElement() instanceof TypedElement && ((TypedElement)children[i].getUmlElement()).getType() instanceof Classifier) {
-				allTreeItems.add(((TypedElement)children[i].getUmlElement()).getType());
-			}
-			if (children[i] instanceof TreeParent) {
-				allTreeItems.addAll(getAllTreeItemsClasses((TreeParent)children[i]));
-			}
-		}
-		return allTreeItems;
-	}
-	
-	
-	private boolean treeContainsOneOf(HashSet<TreeObject> treeItems, TreeParent treeParent){
-		HashSet<TreeObject> allTreeItems = getAllTreeItems(treeParent);
-		
-		for (TreeObject treeObject : treeItems) {
-			if (allTreeItems.contains(treeObject)) {
-				return true;
-			}
-		}
-		return false;
-	}
-
-	private String getNamePostFix(NamedElement owner, String name){
-		String postfix = "_";
-		int highestPostFixNumber = 0;
-	
-		EList<Element> ownedElements = owner.getOwnedElements();
-		for (Element element : ownedElements) {
-			if (element instanceof NamedElement && ((NamedElement)element).getName().startsWith(name)) {
-				
-				String namePart = ((NamedElement)element).getName();
-				String postFix = namePart.replaceFirst(name, "").replaceAll("_", "").trim();
-				
-				if (!postFix.equals("")) {
-					try {
-						int postFixNumber = Integer.valueOf(postFix);
-						if (postFixNumber > highestPostFixNumber) {
-							highestPostFixNumber = postFixNumber;
-						}
-					} catch (Exception e) {
-						// ignore, do nothing.
-					}
-				}
-			}
-		}
-		return postfix + (highestPostFixNumber + 1);	
-	}
-
-	private void addToLog(String msg){
-		this.log = this.log + "\n" + msg;
-	}
-
-	
-	// GETTERS ############################################
-	
-	public String getLog() {
-		return log;
-	}
-	
-	public HashSet<Element> getAllRequirements() {
-		return allRequirements;
-	}
-
-	public void setAllRequirements(HashSet<Element> allRequirements) {
-		this.allRequirements = allRequirements;
-	}
-
-	public HashSet<Element> getAllTestScenarios() {
-		return allTestScenarios;
-	}
-
-	public void setAllTestScenarios(HashSet<Element> allTestScenarios) {
-		this.allTestScenarios = allTestScenarios;
-	}
-
-	public HashSet<Element> getTestScenariosToBeInstantiated() {
-		return testScenariosToBeInstantiated;
-	}
-
-	public void setTestScenariosToBeInstantiated(
-			HashSet<Element> testScenariosToBeInstantiated) {
-		this.testScenariosToBeInstantiated = testScenariosToBeInstantiated;
-	}
-
-	public HashSet<Element> getTestScenariosDiscarded() {
-		return testScenariosDiscarded;
-	}
-
-	public void setTestScenariosDiscarded(HashSet<Element> testScenariosDiscarded) {
-		this.testScenariosDiscarded = testScenariosDiscarded;
-	}
-
-	public HashSet<Element> getRequirementsToBeInstantiated() {
-		return requirementsToBeInstantiated;
-	}
-
-	public void setRequirementsToBeInstantiated(
-			HashSet<Element> requirementsToBeInstantiated) {
-		this.requirementsToBeInstantiated = requirementsToBeInstantiated;
-	}
-
-	public HashSet<Element> getRequirementsDiscarded() {
-		return requirementsDiscarded;
-	}
-
-	public void setRequirementsDiscarded(HashSet<Element> requirementsDiscarded) {
-		this.requirementsDiscarded = requirementsDiscarded;
-	}
-
-	// The total sleep time
-	private static final int TOTAL_TIME = 100;
-	// The increment sleep time
-	private static final int INCREMENT = 10;
-	// process time´is unknown
-	private boolean indeterminate = true; 
-	
-	@Override
-	public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
-		
-		if (!isCanceled()) {
-			monitor.beginTask("Simulation models generator is running." , indeterminate ? IProgressMonitor.UNKNOWN : TOTAL_TIME);
-		    for (int total = 0; total < TOTAL_TIME && !monitor.isCanceled(); total += INCREMENT) {
-		      Thread.sleep(INCREMENT);
-		      monitor.worked(INCREMENT);
-		      if (total == TOTAL_TIME / 8) monitor.subTask("Collecting data ...");
-		      if (total == TOTAL_TIME / 4) monitor.subTask("Preparing simulation models to be created ...");
-		      if (total == TOTAL_TIME / 2) monitor.subTask("Creating models ...");
-		    }
-		    monitor.done();
-		    if (monitor.isCanceled()){
-		    	throw new InterruptedException("Simulation models generatorion was cancelled.");
-		    }   
-		}
-	}
-
-	public void setCanceled(boolean canceled) {
-		this.canceled = canceled;
-	}
-
-	public boolean isCanceled() {
-		return canceled;
-	}
-
-}
Index: /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/TestScenariosCollector.java
===================================================================
--- /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/TestScenariosCollector.java	(revision 909)
+++ /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/TestScenariosCollector.java	(revision 910)
@@ -36,6 +36,5 @@
 	private HashMap<Element,HashSet<Element>> reqToTS = new HashMap<Element,HashSet<Element>>();
 	
-	
-	// selected requirements that were provided in order for finding matching test cases.
+	// selected requirements that were provided for finding matching test cases.
 	private HashSet<Element> selectedReq = null;
 
@@ -146,5 +145,5 @@
 			// collect from stereotype
 			Stereotype s_ts = ((NamedElement)testCase).getAppliedStereotype(Constants.stereotypeQName_TestScenario); 
-			HashSet<Element> itemsFoundTroughStereotypeProperty = new HashSet<Element>();
+			HashSet<Element> itemsFoundThroughStereotypeProperty = new HashSet<Element>();
 			if ( s_ts != null ) {
 				// get the list of referenced requirements
@@ -156,5 +155,5 @@
 						Element umlElement = UMLUtil.getBaseElement(req);
 						if (umlElement instanceof Class && ((Class)umlElement).getAppliedStereotype(Constants.stereotypeQName_Requirement) != null) {
-							itemsFoundTroughStereotypeProperty.add(umlElement);
+							itemsFoundThroughStereotypeProperty.add(umlElement);
 //							System.err.println(((NamedElement) umlElement).getQualifiedName() );
 						}
@@ -166,5 +165,5 @@
 									for (Element target : dependency.getTargets()) {
 										if (target instanceof Class && target.getAppliedStereotype(Constants.stereotypeQName_Requirement) != null) {
-											itemsFoundTroughStereotypeProperty.add( target);
+											itemsFoundThroughStereotypeProperty.add( target);
 										}
 									}
@@ -178,10 +177,10 @@
 			// collect from dependencies
 			EList<Dependency> depList = ((NamedElement)testCase).getClientDependencies();
-			HashSet<Element> itemsFoundTroughDependencies = new HashSet<Element>();
+			HashSet<Element> itemsFoundThroughDependencies = new HashSet<Element>();
 			for (Dependency dependency : depList) {
 				// TODO: should we check if the dependency has a stereotype <<UsedToVerify>>?
 				for (Element target : dependency.getTargets()) {
 					if (target instanceof Class && target.getAppliedStereotype(Constants.stereotypeQName_Requirement) != null) {
-						itemsFoundTroughDependencies.add( (Class) target);
+						itemsFoundThroughDependencies.add( (Class) target);
 					}
 					// collect requirements from referenced elements
@@ -192,5 +191,5 @@
 								for (Element targetDependencyTarget : targetDependency.getTargets()) {
 									if (targetDependencyTarget.getAppliedStereotype(Constants.stereotypeQName_Requirement) != null) {
-										itemsFoundTroughDependencies.add( targetDependencyTarget);
+										itemsFoundThroughDependencies.add( targetDependencyTarget);
 									}
 								}
@@ -202,6 +201,6 @@
 			
 			// merge all items found
-			requirmentsFound.addAll(itemsFoundTroughStereotypeProperty);
-			requirmentsFound.addAll(itemsFoundTroughDependencies);
+			requirmentsFound.addAll(itemsFoundThroughStereotypeProperty);
+			requirmentsFound.addAll(itemsFoundThroughDependencies);
 		}
 		return requirmentsFound;		
Index: /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/TestSimulationModelCombination.java
===================================================================
--- /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/TestSimulationModelCombination.java	(revision 910)
+++ /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/TestSimulationModelCombination.java	(revision 910)
@@ -0,0 +1,636 @@
+package org.openmodelica.modelicaml.helper.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.TypedElement;
+import org.openmodelica.modelicaml.common.constants.Constants;
+import org.openmodelica.modelicaml.common.instantiation.ClassInstantiation;
+import org.openmodelica.modelicaml.common.instantiation.TreeObject;
+import org.openmodelica.modelicaml.common.instantiation.TreeParent;
+
+public class TestSimulationModelCombination {
+	/* 
+	 * Package were to search for value mediators  
+	 */
+	private Package valueMediatorsPackage;
+	
+	/* 
+	 * Selected system model to generate a simulation model.
+	 * The generated simulation model will include one test scenario, 
+	 * all requirements that can be verified using this test scenario,
+	 * all models that are required in addition. 
+	 */
+	private Element systemModel;
+
+
+
+	/*
+	 * All required models that are referenced (directly or indirectly) by the selected system model 
+	 */
+	private HashSet<Element> requiredModels_systemModel = new HashSet<Element>();
+
+	/* 
+	 * Test scenario that is used to stimulate the system model
+	 */
+	private Element testScenario;
+
+
+
+	/*
+	 * All required models that are referenced (directly or indirectly) by the test scenario model 
+	 */
+	private HashSet<Element> requiredModels_testScenario = new HashSet<Element>();
+	
+	/*
+	 * A set of requirements to be verified
+	 */
+	private HashSet<Class> requirements = new HashSet<Class>();
+
+	/*
+	 * All models that are required in addition based on the given set of requirements to be verified.
+	 */
+	private HashMap<Element, HashSet<Element>> requiredModels_requirements = new HashMap<Element, HashSet<Element>>();
+
+	// log messages
+	private String log = "";
+
+	//Set of models that constitutes the combination to be analyzed
+	private HashSet<Element> initialSetOfModels = new HashSet<Element>();
+
+	// All models that was found by required additional models search
+	private HashSet<Element> allCollectedAdditionalModels = new HashSet<Element>();
+
+	//Models that are found by the additional models search and that should always be instantiated.
+	private HashSet<Element> alwaysInclude = new HashSet<Element>();
+
+	//Any model that was considered for the required models search
+	private HashSet<Element> alreadyConsideredForAdditionalModelsSearch = new HashSet<Element>();
+	
+	// All instantiated models
+	private HashSet<TreeParent> allModelInstantiations = new HashSet<TreeParent>();
+
+	// All instantiated models
+	private HashMap<Element, TreeParent> modelToItsInstantiation = new HashMap<Element, TreeParent>();
+
+	// Virtual instantiation root. Its direct children are the instantiation roots of all models provided and collected. 
+	private TreeParent virtualInstantiationTreeRoot;
+
+	// contains tree objects (instantiation roots of models) with all required clients that are NOT satisfied.
+	private HashMap<TreeParent, HashSet<TreeObject>> requiredClients_unsatisfied = new HashMap<TreeParent, HashSet<TreeObject>>();
+
+
+
+	/*
+	 *  Indicates if this combination is discarded.
+	 *  The combination should be discarded if not all required clients of the system model are satisfied
+	 *  or if none of the test scenario providers is used in the virtual instantiation.
+	 */
+	private boolean isDiscarded = false;
+
+	/*
+	 *  Indicates that an error occurred during analysis
+	 */
+	private boolean isError = false;
+
+	
+	public TestSimulationModelCombination(Class systemModel, 
+			Class testScenario, 
+			HashSet<Class> requirements,
+			Package valueMediatorsPackage){
+		
+		this.systemModel = systemModel;
+		this.testScenario = testScenario;
+		this.requirements = requirements;
+		this.valueMediatorsPackage = valueMediatorsPackage;
+		
+		// initial information for the log
+		initializeLog();
+		
+		/*
+		 *  Initial set of models provided.
+		 *  This is used to indicate that these models should not be considered as additional models.   
+		 */
+		initialSetOfModels.add(systemModel);
+		initialSetOfModels.add(testScenario);
+		initialSetOfModels.addAll(requirements);
+		
+		// collect all models that are required in addition (deep search)
+		requiredModels_systemModel.addAll(findAdditionModels(systemModel));
+		requiredModels_testScenario.addAll(findAdditionModels(testScenario));
+		
+		for (Class requirement : requirements) {
+			requiredModels_requirements.put(requirement, findAdditionModels(requirement));
+		}
+
+		// virtual instantiation root 
+		virtualInstantiationTreeRoot = new TreeParent("Virtual Instantiation", null, null, "", false, true, null, null, true);
+		
+		// instantiate all models in order to enable checks
+		HashSet<Element> allModels = new HashSet<Element>();
+		allModels.addAll(initialSetOfModels);
+		allModels.addAll(allCollectedAdditionalModels);
+		instantiateAll(allModels);
+		
+		// validate this combination (checks only the system model and the test scenario)
+		validateCombination();
+		
+		// validate requirements 
+		validateRequirementsConsistency();
+	}
+	
+	
+	private HashSet<Element> findAdditionModels(Class sourceElement){
+		
+		HashSet<Element> collectedAdditionalModels = new HashSet<Element>();
+		
+		// if this model was not yet considered
+		if (!alreadyConsideredForAdditionalModelsSearch.contains(sourceElement)) {
+			
+			//Instantiate the source model in order to collect all classes that are used in its instance tree
+			ClassInstantiation ci_sourceModel = new ClassInstantiation(sourceElement, true);	
+			HashSet<Element> allModelsInInstantiationTree = new HashSet<Element>();
+			ci_sourceModel.createTree();
+			
+			allModelsInInstantiationTree.addAll(getAllTreeItemsClasses(ci_sourceModel.getTreeRoot()));
+			
+			// mark all classes collected from the instantiation tree in order to avoid dead lock search
+			alreadyConsideredForAdditionalModelsSearch.addAll(allModelsInInstantiationTree);
+			
+			// find additional models that are referenced directly by one of the class found in the instantiation tree
+			for (Element element : allModelsInInstantiationTree) {
+				if (element instanceof NamedElement) {
+
+					for (Element dep : ((NamedElement)element).getClientDependencies()) {
+						Stereotype s = dep.getAppliedStereotype(Constants.stereotypeQName_Requires);
+						if (s != null) {
+//							Object list = dep.getValue(s, Constants.propertyName_onlyIncombinationWith);
+							Object isAlways = dep.getValue(s, Constants.propertyName_always);
+
+							Element modelFound = ((Dependency)dep).getTargets().get(0);
+							
+							// check if this model should be discarded.
+							if (initialSetOfModels.contains(modelFound)) {
+								if (modelFound instanceof NamedElement) {
+									
+									String message = "DISCARDED (01): " +
+											"The additional model search found '"+((NamedElement)modelFound).getQualifiedName()
+											+ "'. This model already exists in the combination set and is discarded.";
+									
+									addToLog(message);
+								}
+							}
+							else {
+								// add to the collected additional models 
+								collectedAdditionalModels.add(modelFound );
+								
+								// add to the overall list of collected additional models
+								allCollectedAdditionalModels.add( modelFound );
+								
+								if (isAlways instanceof Boolean && (Boolean)isAlways) {
+									alwaysInclude.add(modelFound);
+								}
+							}
+						}
+					}
+				}
+			}
+			
+			// recursive call -> iterate over all collected models and find other models that are required in addition
+			for (Element newSourceModel : collectedAdditionalModels) {
+				if (newSourceModel instanceof Class) {
+					collectedAdditionalModels.addAll(findAdditionModels((Class) newSourceModel));	
+				}
+			}
+		}
+		
+		return collectedAdditionalModels;
+	}
+	
+	private void instantiateAll(HashSet<Element> models){
+
+		// remove all instantiations from the root
+		for (TreeParent instantiatedModel : allModelInstantiations) {
+			virtualInstantiationTreeRoot.removeChild(instantiatedModel);
+		}
+
+		// clear the list
+		allModelInstantiations.clear();
+		modelToItsInstantiation.clear();
+		
+		// new instantiations
+		for (Element model : models) {
+			if (model instanceof Class) {
+
+				// instantiate model
+				ClassInstantiation ci_model = new ClassInstantiation((Class) model, true);
+				ci_model.createTree();
+				
+				// add the instantiated model to the root
+				virtualInstantiationTreeRoot.addChild(ci_model.getTreeRoot());
+				
+				// add  the instantiation object to the map. 
+				allModelInstantiations.add(ci_model.getTreeRoot());
+				
+				// add to model -> its instantiation map
+				modelToItsInstantiation.put(model, ci_model.getTreeRoot());
+			}
+		}
+	}
+	
+	private void validateCombination(){
+		// Note, isDiscarded is false by default. There is no need to set it to false.
+		
+		TreeParent systemModelInstantiationTreeRoot = modelToItsInstantiation.get(this.systemModel);
+		TreeParent testScenarioInstantiationTreeRoot = modelToItsInstantiation.get(this.testScenario);
+		
+		if (systemModelInstantiationTreeRoot != null && testScenarioInstantiationTreeRoot != null) {
+			if (!areAllRequiredClientsSatisfied(virtualInstantiationTreeRoot, systemModelInstantiationTreeRoot)) {
+
+				setDiscarded(true);
+				String message = "DISCARDED(02): The combination " +
+						"\n   - Test Scenario: '" + ((NamedElement)this.testScenario).getQualifiedName() + "'" +
+						"\n   - System Model: '" + ((NamedElement)this.systemModel).getQualifiedName() + "'" +
+						"\nis discarded because the following required clients of the system model are not satisfied: " +
+						"\n" + getClientsDotPathAsString(requiredClients_unsatisfied.get(systemModelInstantiationTreeRoot));
+				addToLog(message);
+			}
+			if (!isAtLeastOneProviderUsed(virtualInstantiationTreeRoot, testScenarioInstantiationTreeRoot)) {
+				
+				setDiscarded(true);
+				String message = "DISCARDED(03): The combination " +
+						"\n   - Test Scneario: '" + ((NamedElement)this.testScenario).getQualifiedName() + "'" +
+						"\n   - System Model: '" + ((NamedElement)this.systemModel).getQualifiedName() + "'" +
+						"\nis discarded because none of the test scenario providers is used to stimulated the model. ";
+				addToLog(message);
+			}
+		}
+		else {
+
+			String message = "NOT VALID(04): The system model or the test scenario are not found.";
+			addToLog(message);
+			
+			setDiscarded(true);
+			setError(true);
+		}
+	}
+	
+	private void validateRequirementsConsistency(){
+		for (Element requirement : requirements) {
+			TreeParent requirementInstantiationTreeRootItem = modelToItsInstantiation.get(requirement);
+			if (requirementInstantiationTreeRootItem != null) {
+				// this method validates and collects the unsatisfied required clients at the same time.
+				areAllRequiredClientsSatisfied(virtualInstantiationTreeRoot, requirementInstantiationTreeRootItem);
+				
+				// add unsatisfied required clients to log
+				if (getUnsatisfiedRequiredClients(requirement) != null) {
+					String message = "PROBLEM(05): Requirement " + ((NamedElement)requirement).getQualifiedName() + "'" +
+					"\n has the following required clients which are not satisfied: " +
+					"\n" +getClientsDotPathAsString(getUnsatisfiedRequiredClients(requirement));
+					
+					addToLog(message);
+				}
+			}
+		}
+	}
+	
+	private boolean isAtLeastOneProviderUsed(TreeParent virtualInstantiationTreeRoot, TreeParent treeParentToStartTheCheckOn){
+		
+		boolean atLeastOneProviderIsUsed = false;
+		TreeObject[] children = virtualInstantiationTreeRoot.getChildren();
+		
+		for (int i = 0; i < children.length; i++) {
+			TreeObject modelInstnatiationTreeRootItem = children[i];
+
+			// discard itself
+			if (modelInstnatiationTreeRootItem != treeParentToStartTheCheckOn && modelInstnatiationTreeRootItem instanceof TreeParent) {
+				ValueBindingCreator vbc = new ValueBindingCreator();
+			
+				/* Note, the updateAllBindings() is called with the last argument simulateOnly = true  
+				 * so that no modifications are created in components because we only want to analyze possible bindings.
+				 */
+				vbc.updateAllBindings(valueMediatorsPackage, (TreeParent) modelInstnatiationTreeRootItem, virtualInstantiationTreeRoot, false, true, false, true);
+				atLeastOneProviderIsUsed = treeContainsOneOf(vbc.getUsedProviders(),treeParentToStartTheCheckOn);
+
+				// stop the check as soon as at least one used provider was found.
+				if (atLeastOneProviderIsUsed) {
+					return true;
+				}
+			}
+		}
+		
+		return atLeastOneProviderIsUsed;
+	}
+	
+	private boolean areAllRequiredClientsSatisfied(TreeParent virtualInstantiationTreeRoot, TreeParent treeParentToStartTheCheckOn){
+		
+		/* 
+		 * Get the list of clients for which the code could be derived (even if a user interaction would be necessary) 
+		*/
+		ValueBindingCreator vbc = new ValueBindingCreator();
+		
+		/* Note, the updateAllBindings() is called with the last argument simulateOnly = true  
+		 * so that no modifications are created in components because we only want to analyze possible bindings.
+		 */
+		boolean allRequiredClientsAreSatisfied = true;
+		
+		vbc.updateAllBindings(valueMediatorsPackage, treeParentToStartTheCheckOn, virtualInstantiationTreeRoot, false, true, false, true);
+		
+		if ( vbc.getAllRequiredClientsFound().size() > 0 
+				&& !vbc.getAllClientsWithPossibleBindingCodeDerivation().containsAll(vbc.getAllRequiredClientsFound())) {
+			allRequiredClientsAreSatisfied = false;
+		}
+		
+		// Collect all required clients that are not satisfied.
+		HashSet<TreeObject> unsatisfiedRequiredClients = new HashSet<TreeObject>();
+		unsatisfiedRequiredClients.addAll(vbc.getAllRequiredClientsFound());
+		unsatisfiedRequiredClients.removeAll(vbc.getAllClientsWithPossibleBindingCodeDerivation());
+
+		if (unsatisfiedRequiredClients.size() > 0 ) {
+			requiredClients_unsatisfied.put(treeParentToStartTheCheckOn, unsatisfiedRequiredClients);
+		}
+		
+		return allRequiredClientsAreSatisfied;
+	}
+	
+	
+	public void removeNotUsedRequirements(HashSet<Element> newRequirementsSubSet){
+		
+		HashSet<Element> notUsedRequirements = new HashSet<Element>();
+		// add all requirements
+		notUsedRequirements.addAll(this.requirements);
+		// remove all form the new set in order to get the remaining requirements that are not used and should be removed. 
+		notUsedRequirements.removeAll(newRequirementsSubSet);
+		
+		// remove all instantiations.
+		for (Element requirement : notUsedRequirements) {
+			TreeParent requirementInstantiation = modelToItsInstantiation.get(requirement);
+			if (requirementInstantiation != null) {
+				this.virtualInstantiationTreeRoot.removeChild(requirementInstantiation);	
+			}
+			// add to log.
+			String message = "REMOVED(06): Requirement '" + ((NamedElement)requirement).getQualifiedName()+ "' was unselected and is removed.";
+			addToLog(message);
+		}
+		// remove the elements
+		this.requirements.removeAll(notUsedRequirements);
+	}
+	
+	public HashSet<Element> getAdditionalSystemModelModels(boolean prune){
+		if (!prune) {
+			return this.requiredModels_systemModel;
+		}
+		HashSet<Element> additionalModels = new HashSet<Element>();
+		for (Element additionalModel : this.requiredModels_systemModel) {
+			TreeParent additionalModelInstantiation = this.modelToItsInstantiation.get(additionalModel);
+			if (additionalModelInstantiation != null) {
+				if (alwaysInclude.contains(additionalModel) 
+						|| isAtLeastOneProviderUsed(virtualInstantiationTreeRoot, additionalModelInstantiation)) {
+					additionalModels.add(additionalModel);
+				}
+				else { // -> prune this model
+					String message = "REMOVED(07): Additional Model '" + ((NamedElement)additionalModel).getQualifiedName() + "'" +
+					"\nwas removed because none of its providers is used.";
+					addToLog(message);
+				}
+			}
+		}
+		
+		return additionalModels;
+	}
+	
+	public HashSet<Element> getAdditionalTestScenarioModels(boolean prune){
+		if (!prune) {
+			return this.requiredModels_testScenario;
+		}
+		HashSet<Element> additionalModels = new HashSet<Element>();
+		for (Element additionalModel : this.requiredModels_testScenario) {
+			TreeParent additionalModelInstantiation = this.modelToItsInstantiation.get(additionalModel);
+			if (additionalModelInstantiation != null) {
+				if (alwaysInclude.contains(additionalModel) 
+						|| isAtLeastOneProviderUsed(virtualInstantiationTreeRoot, additionalModelInstantiation)) {
+					additionalModels.add(additionalModel);
+				}
+				else { // -> prune this model
+					String message = "REMOVED(08): Additional Model '" + ((NamedElement)additionalModel).getQualifiedName() + "'" +
+					"\nwas removed because none of its providers is used.";
+					addToLog(message);
+				}
+			}
+		}
+		
+		return additionalModels;
+	}
+	
+	public HashSet<Element> getAdditionalRequirementModels(Element requirement, boolean prune){
+		if (!prune) {
+			return this.requiredModels_requirements.get(requirement);
+		}
+		
+		HashSet<Element> additionalModels = new HashSet<Element>();
+		for (Element additionalModel : this.requiredModels_requirements.get(requirement)) {
+			TreeParent additionalModelInstantiation = this.modelToItsInstantiation.get(additionalModel);
+			if (additionalModelInstantiation != null) {
+				if (alwaysInclude.contains(additionalModel) 
+						|| isAtLeastOneProviderUsed(virtualInstantiationTreeRoot, additionalModelInstantiation)) {
+					additionalModels.add(additionalModel);
+				}
+				else { // -> prune this model
+					String message = "REMOVED(09): Additional Model '" + ((NamedElement)additionalModel).getQualifiedName() + "'" +
+					"\nwas removed because none of its providers is used.";
+					addToLog(message);
+				}
+			}
+		}
+		
+		return additionalModels;
+	}
+	
+	// Utls **********************************************************************
+	
+	public HashSet<TreeObject> getUnsatisfiedRequiredClients(Element model){
+		if (model != null) {
+			TreeParent modelInstantiation = modelToItsInstantiation.get(model);
+			
+			if (modelInstantiation != null) {
+				HashSet<TreeObject> unsatisfiedClients = requiredClients_unsatisfied.get(modelInstantiation);
+
+				if (unsatisfiedClients != null && unsatisfiedClients.size() > 0 ) {
+					return unsatisfiedClients;
+				}
+			}
+		}
+		return null;
+	}
+	
+	
+	
+	public String getClientsDotPathAsString(HashSet<TreeObject> items) {
+		if (items != null) {
+			String unsatisfiedRequiredClientList = "";
+			
+			List<String> dotPathList = new ArrayList<String>();
+			for (TreeObject treeObject: items) {
+				dotPathList.add(treeObject.getDotPath());
+			}
+			Collections.sort(dotPathList);
+			
+			for (String string : dotPathList) {
+				unsatisfiedRequiredClientList = unsatisfiedRequiredClientList + "- " + string + "\n"; 
+			}
+			
+			return unsatisfiedRequiredClientList;
+		}
+		return "";
+	}
+	
+	private boolean treeContainsOneOf(HashSet<TreeObject> treeItems, TreeParent treeParent){
+		HashSet<TreeObject> allTreeItems = getAllTreeItems(treeParent);
+		
+		for (TreeObject treeObject : treeItems) {
+			if (allTreeItems.contains(treeObject)) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	private HashSet<TreeObject> getAllTreeItems(TreeParent treeParent){
+		HashSet<TreeObject> allTreeItems = new HashSet<TreeObject>();
+		allTreeItems.add(treeParent);
+		
+		TreeObject[] children = treeParent.getChildren();
+		for (int i = 0; i < children.length; i++) {
+			allTreeItems.add(children[i]);
+			if (children[i] instanceof TreeParent) {
+				allTreeItems.addAll(getAllTreeItems((TreeParent)children[i]));
+			}
+		}
+		
+		return allTreeItems;
+	}
+	
+	private HashSet<Element> getAllTreeItemsClasses(TreeParent treeParent){
+		HashSet<Element> allTreeItems = new HashSet<Element>();
+		
+		// If it is the root then add the root class
+		if (treeParent.isRoot() && treeParent.getSelectedClass() != null) {
+			allTreeItems.add(treeParent.getSelectedClass());
+		}
+		
+		// add all classes used in children
+		TreeObject[] children = treeParent.getChildren();
+		for (int i = 0; i < children.length; i++) {
+			if (children[i].getUmlElement() instanceof TypedElement && ((TypedElement)children[i].getUmlElement()).getType() instanceof Classifier) {
+				allTreeItems.add(((TypedElement)children[i].getUmlElement()).getType());
+			}
+			if (children[i] instanceof TreeParent) {
+				allTreeItems.addAll(getAllTreeItemsClasses((TreeParent)children[i]));
+			}
+		}
+		return allTreeItems;
+	}
+	
+	private void initializeLog(){
+		this.log = "\n----------------------------------------------" +
+		"---------------------------------------------------" +
+		"--------------------------------------------------- \n" +
+		"Log for the combination:" +
+			"\n   - Test Scenario '" + ((NamedElement)this.testScenario).getQualifiedName() + "'" +
+			"\n   - System Model '" + ((NamedElement)this.systemModel).getQualifiedName() + "'" +
+			"\n";
+	}
+	
+	private void addToLog(String msg){
+		this.log = this.log + "\n" + msg + "\n";
+	}
+	
+	// Getter/Setter **************************************************************
+	
+	public Element getSystemModel() {
+		return systemModel;
+	}
+	
+	public Element getTestScenario() {
+		return testScenario;
+	}
+	
+	public String getLog() {
+		return log;
+	}
+	
+	public HashSet<Element> getRequiredModels_systemModel() {
+		return requiredModels_systemModel;
+	}
+
+	public HashSet<Element> getRequiredModels_testScenario() {
+		return requiredModels_testScenario;
+	}
+
+	public HashMap<Element, HashSet<Element>> getRequiredModels_requirements() {
+		return requiredModels_requirements;
+	}
+
+	public HashSet<Element> getAllCollectedAdditionalModels() {
+		return allCollectedAdditionalModels;
+	}
+	
+	public HashSet<Element> getDiscardTheseModelsWhenCollectingAdditionalModels() {
+		return initialSetOfModels;
+	}
+	
+	public void setDiscardTheseModelsWhenCollectingAdditionalModels(
+			HashSet<Element> discardTheseModelsWhenCollectingAdditionalModels) {
+		this.initialSetOfModels = discardTheseModelsWhenCollectingAdditionalModels;
+	}
+
+	public void setDiscarded(boolean isDiscarded) {
+		this.isDiscarded = isDiscarded;
+	}
+
+	public boolean isDiscarded() {
+		return isDiscarded;
+	}
+
+	public void setError(boolean isError) {
+		this.isError = isError;
+	}
+
+	public boolean isError() {
+		return isError;
+	}
+	
+
+	public HashMap<TreeParent, HashSet<TreeObject>> getRequiredClients_unsatisfied() {
+		return requiredClients_unsatisfied;
+	}
+
+
+	public HashSet<Class> getRequirements() {
+		return requirements;
+	}
+
+
+	public void setRequirements(HashSet<Class> requirements) {
+		this.requirements = requirements;
+	}
+	
+
+	public HashMap<Element, TreeParent> getModelToItsInstantiation() {
+		return modelToItsInstantiation;
+	}
+	
+	public HashSet<Element> getAlwaysInclude() {
+		return alwaysInclude;
+	}
+}
Index: /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/TestSimulationModelsGenarator.java
===================================================================
--- /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/TestSimulationModelsGenarator.java	(revision 910)
+++ /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/TestSimulationModelsGenarator.java	(revision 910)
@@ -0,0 +1,1212 @@
+package org.openmodelica.modelicaml.helper.impl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.openmodelica.modelicaml.common.constants.Constants;
+import org.openmodelica.modelicaml.common.instantiation.ClassInstantiation;
+import org.openmodelica.modelicaml.common.services.ModelicaMLServices;
+import org.openmodelica.modelicaml.common.services.StringUtls;
+import org.openmodelica.modelicaml.helper.dialogs.SelectTestScenariosAndRequirementsDialog;
+
+public class TestSimulationModelsGenarator implements IRunnableWithProgress {
+	
+	public TestSimulationModelsGenarator(
+			HashSet<Element> sourceModels,
+			Element targetPackage, 
+			Element requirementsPackage,
+			Element testScenariosPackage, 
+			Element valueMediatorsPackage) {
+		
+		super();
+		
+		this.sourceModels = sourceModels;
+		this.targetPackage = targetPackage;
+		this.requirementsPackage = requirementsPackage;
+		this.testScenariosPackage = testScenariosPackage;
+		this.valueBindingsPackage = valueMediatorsPackage;
+	}
+	
+	/*
+	 * Possible combinations, each containing an initial set (1 system model, 1 test scenario  and n requirements) and 
+	 * all additional model that are required by any of the initial set models. 
+	 */
+	private HashMap<Element, TestSimulationModelCombination> tsToTestSimulationModelCombination = new HashMap<Element, TestSimulationModelCombination>();
+	
+	// the selected model to generate the simulation models for
+	private HashSet<Element> sourceModels = null;
+
+	// the package for simulation models
+	private Element targetPackage = null;
+	
+	// the package to containing the requirements to be used
+	private Element requirementsPackage = null;
+	// the package to containing the test scenarios to be used
+	private Element testScenariosPackage = null;
+	// the package to containing the value mediators to be used
+	private Element valueBindingsPackage = null;
+	
+	private TestScenariosCollector tsc;
+
+	// all requirements that were collected from the specified requirements package
+	private HashSet<Element> allRequirements = new HashSet<Element>();
+	// all test scenarios that were collected from the specified test scenarios package
+	private HashSet<Element> allTestScenarios = new HashSet<Element>();
+	
+	// all test scenarios that were selected for the selected system model
+	private HashSet<Element> testScenariosToBeInstantiated = new HashSet<Element>();
+	// all test scenarios that discarded because they cannot be used for stimulating the selected system model.
+	private HashSet<Element> testScenariosDiscarded = new HashSet<Element>();
+	
+	// the set of test scenario after user selection
+	private HashSet<Element> userSelectedTestScenarios = new HashSet<Element>();
+	
+	/* all requirements that were selected for instantiation because 
+	 * the selected test scenarios reference them and all their clients are satisfied by the selected system model
+	 */
+	private HashSet<Element> requirementsToBeInstantiated = new HashSet<Element>();
+	/* all requirements that were discarded because  
+	 * some of their clients are NOT satisfied by the selected system model.
+	 */
+	private HashSet<Element> requirementsDiscarded = new HashSet<Element>();
+	
+	// messages collected during translation
+	private String log = "";
+	
+	// indicated if the generation was canceled by the user.
+	private boolean canceled = false;
+	
+	
+	public void generate(){
+		
+		if (sourceModels != null) {
+
+			/* Collect all requirements in order to be able to determine 
+			 * which are not covered by simulation models.
+			 */
+//			ElementsCollector ec = new ElementsCollector();
+//			ec.collectElementsFromModel(requirementsPackage, Constants.stereotypeQName_Requirement);
+//			allRequirements.addAll(ec.getElements());
+			
+			/* For each of the selected system models create a package containing classes that 
+			 * instantiate all possible combinations of test scenarios and requirements that 
+			 * can be tested using the given test scenario.
+			 */
+			for (Element sourceModel : sourceModels) {
+				// clear all lists because the translation for each source model is individual.
+				clearAllLists();
+				
+				// TODO: create a sub-progress monitor.
+				try {
+					// create combinations
+					new ProgressMonitorDialog(new Shell()).run(true, true, this);
+					createCombinationsForSimulationModels();
+
+				} catch (InvocationTargetException e) {
+					e.printStackTrace();
+					MessageDialog.openError(new Shell(), "Simulation Models Generation Process Error", "It was not possible to invoce the generation of simulation models operation.");
+				} catch (InterruptedException e) {
+					e.printStackTrace();
+					MessageDialog.openError(new Shell(), "Simulation Models Generation Process Abort", "The generation of simulation models was canceled.");
+				}
+				
+				// generate simulation models for the source model 
+				generateSimulationModels(sourceModel);
+			}
+		}
+	}
+	
+	private void clearAllLists(){
+		testScenariosToBeInstantiated.clear();
+		testScenariosDiscarded.clear();
+		requirementsToBeInstantiated.clear();
+		requirementsDiscarded.clear();
+	}
+	
+	private void createCombinationsForSimulationModels(){
+		monitorText1 = "Collecting data ...";
+		monitorText2 = "Analyzing combinations ...";
+		
+		for (Element sourceModel : this.sourceModels) {
+			
+			if (sourceModel instanceof Class) {
+				
+				Class systemModel = (Class) sourceModel;
+				
+				// find all test scenarios
+				tsc = new TestScenariosCollector();
+				tsc.collectTestCasesFromPackage((Package) testScenariosPackage, true);
+				if (tsc.getAllTS().size() == 0) {
+					String message = "INFO: No test scnearios were found.";
+					addToLog(message);
+				}
+
+				for (Element testScenario : tsc.getAllTS() ) {
+					if (testScenario instanceof Class) {
+						
+						Class testScenarioToBeUsed = (Class) testScenario;
+
+						// get requirements
+						HashSet<Element> reqList = tsc.getTsToReq().get(testScenarioToBeUsed);
+						HashSet<Class> requirementsToBeUsed = new HashSet<Class>();
+						
+						if (reqList != null) {
+							 for (Element req : reqList) {
+								if (req instanceof Class) {
+									requirementsToBeUsed.add((Class) req);
+								}
+								else {
+									String message = "NOT VALID: Requirement '" + req.toString() + "' is not a class";
+									addToLog(message);
+								}
+							}
+						}
+						else {
+							String message = "INFO: No requirements are found for the test scenario '" + testScenarioToBeUsed.getQualifiedName() + "'";
+							addToLog(message);
+						}
+						
+						TestSimulationModelCombination tsmc = new TestSimulationModelCombination(systemModel, 
+								testScenarioToBeUsed, 
+								requirementsToBeUsed,
+								(Package) valueBindingsPackage);
+						
+						// add to map
+						tsToTestSimulationModelCombination.put(testScenarioToBeUsed, tsmc);
+						
+						// add to selected or discarded test scenarios
+						if (!tsmc.isDiscarded()) {
+							testScenariosToBeInstantiated.add(testScenarioToBeUsed);
+						}
+						else {
+							testScenariosDiscarded.add(testScenarioToBeUsed);
+						}
+						
+						// add to selected or discarded requirements
+						HashSet<Class> requirements = tsmc.getRequirements();
+						for (Element requirement : requirements) {
+							if (tsmc.getUnsatisfiedRequiredClients(requirement) != null) {
+								requirementsDiscarded.add(requirement);
+							}
+							else {
+								requirementsToBeInstantiated.add(requirement);
+							}
+						}
+
+						// add log messages
+						addToLog(tsmc.getLog().trim());
+					}
+					else {
+						String message = "NOT VALID: Test scenario '" + sourceModel.toString() + "' is not a UML Class.";
+						addToLog(message);
+					}
+				}
+			}
+			else {
+				String message = "NOT VALID: System model '" + sourceModel.toString() + "' is not a UML Class.";
+				addToLog(message);
+			}
+		}
+	}
+	
+	private void generateSimulationModels(Element sourceModel){
+		
+		String errorTitle = "Test Simulation Models Generation Helper";
+		String errorMessage = "No test scenarios were found that can be used to stimulate the model " +
+				"'"+((NamedElement)sourceModel).getName()+"'.";
+
+		if (tsc.getAllTS().size() > 0) {
+			if (testScenariosToBeInstantiated.size() > 0) {
+				// Create test simulation models
+				createSimulationModels(sourceModel);
+			}
+			else {
+				reportError(errorTitle, errorMessage);
+			}
+		}
+		else {
+			reportError(errorTitle, errorMessage);
+		}
+	}
+	
+	private void reportError(String title, String message){
+		MessageDialog.openError(new Shell(), title, message);
+	}
+	
+	private void createSimulationModels(Element sourceModel){
+		
+		/* GUI to show the collected and discarded test scenarios and requirements.
+		 * It should enable a selection of test scenarios and requirements to be finally instantiated. 
+		 */
+
+		SelectTestScenariosAndRequirementsDialog dialog = new SelectTestScenariosAndRequirementsDialog(
+				new Shell(), 
+				testScenariosToBeInstantiated, 
+				testScenariosDiscarded, 
+				requirementsToBeInstantiated, 
+				requirementsDiscarded, 
+				sourceModel,
+				tsc,
+				getLog(),
+				tsToTestSimulationModelCombination);
+		
+		dialog.open();
+		
+		if (dialog.getReturnCode() == 1) { // Cancel return code
+			setTestSimulationModelGenerationCanceled(true); // indicate abort and stop here. 
+		}
+		else {
+			// Get the selected test scenarios and requirements from the dialog.  
+			HashMap<Element,HashSet<Element>> userSelectedTestScenariosAndRequirements = dialog.getSelectedTestScenariosWithRequirements();
+//			HashSet<Element> userSelectedTestScenarios = new HashSet<Element>();
+			userSelectedTestScenarios.addAll(userSelectedTestScenariosAndRequirements.keySet());
+			
+			if (userSelectedTestScenarios.size() > 0) {
+				// clear log. the tsmc objects still have all logs stored...
+				// create a new (final) log using addToLog(). 
+				clearLog();
+				
+				monitorText1 = "Preparing models to be created ...";
+				monitorText2 = "Creating models...";
+
+				String pkgName = Constants.simModelsPackageNamePrefix + ((NamedElement)sourceModel).getName();
+				String postFix = ModelicaMLServices.getNamePostFix((Package)targetPackage, pkgName);
+				PackageableElement simulationModelsPackage = ((Package)targetPackage).createPackagedElement(pkgName + postFix,UMLPackage.Literals.PACKAGE);
+			
+				/*
+				 * NOTE: only test scenarios from user selection are taken into account.
+				 * Any other combination that was prepared in advance is discarded.
+				 */
+				for (Element testScenario : userSelectedTestScenarios) {
+					
+					if (testScenario instanceof Classifier) {
+						
+						// create the test simulation model class
+						String simulationModelName = Constants.simModelsNamePrefix + ((NamedElement)testScenario).getName();
+						Class simulationModel = ((Package)simulationModelsPackage).createOwnedClass(simulationModelName, false);
+						
+						/*
+						 *  Copy the simulation annotation values 
+						 *  from the TestScenario stereotype to the Simulation (or Test) stereotype 
+						 */
+						Stereotype s_model = simulationModel.getApplicableStereotype(Constants.stereotypeQName_Model);
+						Stereotype s_simulation = simulationModel.getApplicableStereotype(Constants.stereotypeQName_Simulation);
+						Stereotype s_test = simulationModel.getApplicableStereotype(Constants.stereotypeQName_Test);
+						if (s_model != null && s_simulation != null) {
+							simulationModel.applyStereotype(s_model);
+							simulationModel.applyStereotype(s_simulation);
+							simulationModel.applyStereotype(s_test);
+							
+							// Copy the simulation settings from test scenario to the test model.
+							copySimulationSettings((Class) testScenario, simulationModel);
+						}
+						else {
+							String msg = "ERROR: Cannot apply the stereotype 'Model' and 'Simulation' to '" 
+								+ simulationModel.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+							addToLog(msg);
+						}
+
+						//************************************************************************************
+						// Get and adopt the data from the test scenario simulation model combination object
+						TestSimulationModelCombination tsmc = tsToTestSimulationModelCombination.get(testScenario);
+						
+						//************************************************************************************
+						// Remove requirements that were unselected
+						if (userSelectedTestScenariosAndRequirements.get(testScenario) != null) {
+							// remove all that were unselected by user
+							tsmc.removeNotUsedRequirements(userSelectedTestScenariosAndRequirements.get(testScenario));
+						}
+						else {
+							// remove all requirements
+							tsmc.removeNotUsedRequirements(new HashSet<Element>());
+						}
+						
+						//************************************************************************************
+						// add system model property
+						Element systemModel = tsmc.getSystemModel();
+						Property p_systemModel = simulationModel.createOwnedAttribute(
+								Constants.systemModelPropertyNamePrefix 
+								+ StringUtls.replaceSpecChar(((NamedElement)sourceModel).getName().toLowerCase()), 
+								(Type)systemModel);
+						Stereotype s_component = p_systemModel.getApplicableStereotype(Constants.stereotypeQName_Component);
+						if (s_component != null) {
+							p_systemModel.applyStereotype(s_component);
+						}
+						else {
+							String msg = "ERROR: Cannot apply the stereotype 'Component' to '" 
+										+ p_systemModel.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+							addToLog(msg);
+						}
+
+						/*
+						 * Add additional models that are required by the system model.
+						 * Hereby, prune all that are not used, i.e. those that don't have at least
+						 * one provider used in the combination.
+						 */
+						
+						createAdditionalModels(simulationModel, tsmc.getAdditionalSystemModelModels(true), 
+								Constants.systemModelPropertyNamePrefix + Constants.additionalModelPrefix);
+						
+						
+						//************************************************************************************
+						// add test scenario property
+						Property p_testScenario = simulationModel.createOwnedAttribute(
+								Constants.testScenarioPropertyNamePrefix 
+								+ StringUtls.replaceSpecChar(((NamedElement)testScenario).getName().toLowerCase()), 
+								(Type)testScenario);
+						Stereotype s_testScenario = p_testScenario.getApplicableStereotype(Constants.stereotypeQName_CalculatedProperty);
+						if (s_testScenario != null) {
+							p_testScenario.applyStereotype(s_testScenario);
+						}
+						else {
+							String msg = "ERROR: Cannot apply the stereotype 'CalculatedProperty' to '" + p_testScenario.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+							addToLog(msg);
+						}
+						
+						/*
+						 * Add additional models that are required by the test scenario.
+						 * Hereby, prune all that are not used, i.e. those that don't have at least
+						 * one provider used in the combination.
+						 */
+						createAdditionalModels(simulationModel, tsmc.getAdditionalTestScenarioModels(true), 
+								Constants.testScenarioPropertyNamePrefix + Constants.additionalModelPrefix);
+						
+						//************************************************************************************
+						// add requirements
+						RequirementsInstantiator ri = new RequirementsInstantiator();
+						HashSet<Element> reqList = new HashSet<Element>();
+						reqList.addAll(tsmc.getRequirements());
+						List<Element> requirements_sorted = ModelicaMLServices.getSortedByName(reqList);
+						
+						for (Element requirement : requirements_sorted) {
+							if (requirement instanceof Classifier) {
+							
+								// get the number of required instantiations
+								int requiredNumberOfInstantions = ri.getMaxNumberOfProviders(simulationModel, (Class) requirement);
+								String requiredNumberOfInstantionsString = "";
+								
+								for (int i = 0; i < requiredNumberOfInstantions; i++) {
+								
+									if (requiredNumberOfInstantions > 1) {
+										requiredNumberOfInstantionsString = String.valueOf(i) + "_";
+									}
+									Property p_req = simulationModel.createOwnedAttribute(
+											Constants.reqirementPropertyNamePrefix + 
+											ModelicaMLServices.getRequirementID((NamedElement) requirement) + "_" + 
+											requiredNumberOfInstantionsString +
+											StringUtls.replaceSpecChar(((NamedElement)requirement).getName().toLowerCase()), 
+											(Type) requirement);
+									
+									Stereotype s_reqInst = p_req.getApplicableStereotype(Constants.stereotypeQName_RequirementInstance);
+									
+									if (s_reqInst != null) {
+										p_req.applyStereotype(s_reqInst);
+									}
+									else {
+										String msg = "ERROR: Cannot apply the stereotype 'requirementInstantance' to '" + p_req.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+										addToLog(msg);
+									}
+								}
+								
+								/*
+								 * Add additional models that are required by the requirement model.
+								 * Hereby, prune all that are not used, i.e. those that don't have at least
+								 * one provider used in the combination.
+								 */
+								createAdditionalModels(simulationModel, 
+										tsmc.getAdditionalRequirementModels(requirement, true), 
+										Constants.reqirementPropertyNamePrefix
+											+ ModelicaMLServices.getRequirementID((NamedElement) requirement) 
+											+ "_" + Constants.additionalModelPrefix
+										);
+							}
+						}
+						
+						// add to log
+						addToLog("\n" + tsmc.getLog());
+						
+						/* 
+						 * Instantiate the created simulation model class
+						 * (it now contains all components)
+						 */
+						ClassInstantiation ci = new ClassInstantiation((Class) simulationModel, true);
+						ci.createTree();
+						
+						// update all bindings in the created simulation model class
+						ValueBindingCreator vbc = new ValueBindingCreator();
+						/* Note, the updateAllBindings() is called with the last argument simulateOnly = false  
+						 * so that modifications ARE created in components.
+						 */
+						vbc.updateAllBindings((Package)valueBindingsPackage, ci.getTreeRoot(), ci.getTreeRoot(), false, true, false, false);
+						
+						/*
+						 * Create test verdict code
+						 */
+						TestOracleElementsCreator.createTestEvaluationElements(simulationModel);
+					}
+				}
+			}
+		}
+	}
+	
+	private void createAdditionalModels(Class owningClass, HashSet<Element> additionalModels, String namePrefix){
+		if (additionalModels != null && additionalModels.size() > 0) {
+			List<Element> addtitionalModels_sorted = ModelicaMLServices.getSortedByName(additionalModels);
+			
+			for (int i = 0; i < addtitionalModels_sorted.size(); i++) {
+				Element additionalModel= addtitionalModels_sorted.get(i);
+				
+				// create property
+				Property p_additionalModel = owningClass.createOwnedAttribute(
+						namePrefix + i + "_" + StringUtls.replaceSpecChar(((NamedElement)additionalModel).getName().toLowerCase()), 
+						(Type)additionalModel);
+				
+				// apply stereotype
+				Stereotype s_additionalModel= null;
+				if (additionalModel.getAppliedStereotype(Constants.stereotypeQName_CalculationModel) != null
+						|| additionalModel.getAppliedStereotype(Constants.stereotypeQName_TestScenario) != null) {
+					
+					s_additionalModel = p_additionalModel.getApplicableStereotype(Constants.stereotypeQName_CalculatedProperty);	
+				}
+				else {
+					s_additionalModel = p_additionalModel.getApplicableStereotype(Constants.stereotypeQName_Component);
+				}
+				if (s_additionalModel != null) {
+					p_additionalModel.applyStereotype(s_additionalModel);
+				}
+				else {
+					String msg = "ERROR: Cannot apply the required stereotype to '" 
+						+ p_additionalModel.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+					addToLog(msg);
+				}
+			}
+		}
+	}
+	
+	private void copySimulationSettings(Classifier testScenarioModel, Classifier simulationModel){
+		Stereotype sTestScenario = testScenarioModel.getAppliedStereotype(Constants.stereotypeQName_TestScenario);
+		Stereotype sSimulation = simulationModel.getAppliedStereotype(Constants.stereotypeQName_Simulation);
+		
+		if (sTestScenario != null && sSimulation != null) {
+			Object startTime = testScenarioModel.getValue(sTestScenario, Constants.propertyName_startTime);
+			simulationModel.setValue(sSimulation, Constants.propertyName_startTime, startTime);
+			Object stopTime = testScenarioModel.getValue(sTestScenario, Constants.propertyName_stopTime);
+			simulationModel.setValue(sSimulation, Constants.propertyName_stopTime, stopTime);
+			Object numberOfIntervals = testScenarioModel.getValue(sTestScenario, Constants.propertyName_numberOfIntervals);
+			simulationModel.setValue(sSimulation, Constants.propertyName_numberOfIntervals, numberOfIntervals);
+			Object tolerance = testScenarioModel.getValue(sTestScenario, Constants.propertyName_tolerance);
+			simulationModel.setValue(sSimulation, Constants.propertyName_tolerance, tolerance);
+		}
+	}
+	
+//	private void createSimulationModels(Element sourceModel){
+//
+//		/* GUI to show the collected and discarded test scenarios and requirements.
+//		 * It should enable a selection of test scenarios and requirements to be finally instantiated. 
+//		 */
+//
+//		SelectTestScenariosAndRequirementsDialog dialog = new SelectTestScenariosAndRequirementsDialog(
+//				new Shell(), 
+//				testScenariosToBeInstantiated, 
+//				testScenariosDiscarded, 
+//				requirementsToBeInstantiated, 
+//				requirementsDiscarded, 
+//				sourceModel,
+//				tsc,
+//				getLog(),
+//				tsToTestSimulationModelCombination);
+//		
+//		dialog.open();
+//		
+//		if (dialog.getReturnCode() == 1) { // Cancel return code
+//			setCanceled(true); // indicate abort and stop here. 
+//		}
+//		else {
+//			// Get the selected test scenarios and requirements from the dialog.  
+//			HashMap<Element,HashSet<Element>> userSelectedTestScenariosAndRequirements = dialog.getSelectedTestScenariosWithRequirements();
+//			HashSet<Element> userSelectedTestScenarios = new HashSet<Element>();
+//			userSelectedTestScenarios.addAll(userSelectedTestScenariosAndRequirements.keySet());
+//			
+//			if (userSelectedTestScenarios.size() > 0) {
+//				String pkgName = Constants.simModelsPackageNamePrefix + ((NamedElement)sourceModel).getName();
+//				String postFix = getNamePostFix((Package)targetPackage, pkgName);
+//				PackageableElement simulationModelsPackage = ((Package)targetPackage).createPackagedElement(pkgName + postFix,UMLPackage.Literals.PACKAGE);
+//			
+//			
+//	//			for (Element testScenario : testScenariosToBeInstantiated) {
+//				for (Element testScenario : userSelectedTestScenarios) {
+//					
+//					if (testScenario instanceof Classifier) {
+//						
+//						// add class
+//						String simulationModelName = Constants.simModelsNamePrefix + ((NamedElement)testScenario).getName();
+//						Class simulationModel = ((Package)simulationModelsPackage).createOwnedClass(simulationModelName, false);
+//						
+//						/*
+//						 *  Copy the simulation annotation values 
+//						 *  from the TestScenario stereotype to the Simulation (or Test) stereotype 
+//						 */
+//						Stereotype s_model = simulationModel.getApplicableStereotype(Constants.stereotypeQName_Model);
+//						Stereotype s_simulation = simulationModel.getApplicableStereotype(Constants.stereotypeQName_Simulation);
+//						Stereotype s_test = simulationModel.getApplicableStereotype(Constants.stereotypeQName_Test);
+//						if (s_model != null && s_simulation != null) {
+//							simulationModel.applyStereotype(s_model);
+//							simulationModel.applyStereotype(s_simulation);
+//							simulationModel.applyStereotype(s_test);
+//							
+//							// Copy the simulation settings from test scenario to the test model.
+//							copySimulationSettings((Class) testScenario, simulationModel);
+//						}
+//						else {
+//							String msg = "ERROR: Cannot apply the stereotype 'Model' and 'Simulation' to '" 
+//								+ simulationModel.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+//							addToLog(msg);
+//						}
+//						
+//						// add system model property
+//						Property p_systemModel = simulationModel.createOwnedAttribute(
+//								Constants.systemModelPropertyNamePrefix 
+//								+ StringUtls.replaceSpecChar(((NamedElement)sourceModel).getName().toLowerCase()), 
+//								(Type)sourceModel);
+//						Stereotype s_component = p_systemModel.getApplicableStereotype(Constants.stereotypeQName_Component);
+//						if (s_component != null) {
+//							p_systemModel.applyStereotype(s_component);
+//						}
+//						else {
+//							String msg = "ERROR: Cannot apply the stereotype 'Component' to '" 
+//								+ p_systemModel.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+//							addToLog(msg);
+//						}
+//		
+//						// add test scenario property
+//						Property p_testScenario = simulationModel.createOwnedAttribute(
+//								Constants.testScenarioPropertyNamePrefix 
+//								+ StringUtls.replaceSpecChar(((NamedElement)testScenario).getName().toLowerCase()), 
+//								(Type)testScenario);
+//						Stereotype s_calProp = p_testScenario.getApplicableStereotype(Constants.stereotypeQName_CalculatedProperty);
+//						if (s_calProp != null) {
+//							p_testScenario.applyStereotype(s_calProp);
+//						}
+//						else {
+//							String msg = "ERROR: Cannot apply the stereotype 'CalculatedProperty' to '" + p_testScenario.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+//							addToLog(msg);
+//						}
+//		
+//						// add requirements
+//						RequirementsInstantiator ri = new RequirementsInstantiator();
+//	//					for (Element requirement : tsc.getTsToReq().get(testScenario)) {
+//						for (Element requirement : userSelectedTestScenariosAndRequirements.get(testScenario)) {
+//	
+//							// if this requirement was selected, i.e. was not discarded
+//	//						if (!requirementsDiscarded.contains(requirement) && requirement instanceof Class) {
+//							if (requirement instanceof Class) {
+//								if (requirement instanceof Classifier) {
+//									// get the number of required instantiations
+//									int requiredNumberOfInstantions = ri.getMaxNumberOfProviders(simulationModel, (Class) requirement);
+//									for (int i = 0; i < requiredNumberOfInstantions; i++) {
+//										Property p_req = simulationModel.createOwnedAttribute(
+//												Constants.reqirementPropertyNamePrefix + 
+//												getRequirementId((NamedElement) requirement) + "_" + 
+//												StringUtls.replaceSpecChar(((NamedElement)requirement).getName().toLowerCase()), 
+//												(Type) requirement);
+//										
+//										Stereotype s_reqInst = p_req.getApplicableStereotype(Constants.stereotypeQName_RequirementInstance);
+//										
+//										if (s_reqInst != null) {
+//											p_req.applyStereotype(s_reqInst);
+//										}
+//										else {
+//											String msg = "ERROR: Cannot apply the stereotype 'requirementInstantance' to '" + p_req.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+//											addToLog(msg);
+//										}
+//									}
+//								}
+//							}
+//						}
+//		
+//						/*
+//						 *  Based on Dependency <<Requires>>, for all test scenarios 
+//						 *  and requirements to be instantiated, find models that should be instantiated in addition.
+//						 */
+//						
+//						/*
+//						 *  instantiate the created simulation model class in order to search for required additional models
+//						 */
+//						ClassInstantiation ciTemp = new ClassInstantiation((Class) simulationModel, true);
+//						ciTemp.createTree();
+//						
+//						HashSet<Element> addtionalModels = getAdditionalModels(sourceModels, 
+//								testScenariosToBeInstantiated, 
+//								requirementsToBeInstantiated,
+//								ciTemp);
+//						
+//						for (Element additionalModel : addtionalModels) {
+//							
+//							// create property
+//							Property p_additionalModel = simulationModel.createOwnedAttribute(
+//									Constants.additionalModelPrefix 
+//									+ StringUtls.replaceSpecChar(((NamedElement)additionalModel).getName().toLowerCase()), 
+//									(Type)additionalModel);
+//							
+//							// apply stereotype
+//							Stereotype s_componentForAdditionalComponent = null;
+//							if (additionalModel.getAppliedStereotype(Constants.stereotypeQName_CalculationModel) != null
+//									|| additionalModel.getAppliedStereotype(Constants.stereotypeQName_TestScenario) != null) {
+//								s_componentForAdditionalComponent = p_systemModel.getApplicableStereotype(Constants.stereotypeQName_CalculatedProperty);	
+//							}
+//							else {
+//								s_componentForAdditionalComponent = p_systemModel.getApplicableStereotype(Constants.stereotypeQName_Component);
+//							}
+//							if (s_componentForAdditionalComponent != null) {
+//								p_additionalModel.applyStereotype(s_componentForAdditionalComponent);
+//							}
+//							else {
+//								String msg = "ERROR: Cannot apply the required stereotype to '" 
+//									+ p_additionalModel.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+//								addToLog(msg);
+//							}
+//						}
+//						
+//						
+//						/* 
+//						 * instantiate the created simulation model class
+//						 * (it now contains all components)
+//						 */
+//						ClassInstantiation ci = new ClassInstantiation((Class) simulationModel, true);
+//						ci.createTree();
+//						
+//						// update bindings in the created simulation model class
+//						ValueBindingCreator vbc = new ValueBindingCreator();
+//						/* Note, the updateAllBindings() is called with the last argument simulateOnly = false  
+//						 * so that modifications ARE created in components.
+//						 */
+//						vbc.updateAllBindings((Package)valueBindingsPackage, ci.getTreeRoot(), ci.getTreeRoot(), false, true, false, false);
+//						
+//						/*
+//						 * Create test verdict code
+//						 */
+//						TestOracleElementsCreator.createTestEvaluationElements(simulationModel);
+//						
+//					}
+//				}
+//			}
+//		}
+//	}
+	
+//	@SuppressWarnings("rawtypes")
+//	private HashSet<Element> getAdditionalModels(
+//			HashSet<Element> sourceModels, 
+//			HashSet<Element> testScenariosToBeInstantiated, 
+//			HashSet<Element> requirementsToBeInstantiated,
+//			ClassInstantiation ciTemp){
+//		
+//		HashSet<Element> listOfAdditionalModels = new HashSet<Element>();
+//		
+//		// all models that will be instantiated: system models, test scenarios and requirements
+//		HashSet<Element> allModelsInInstantiationTree = new HashSet<Element>();
+//		allModelsInInstantiationTree.addAll(getAllTreeItemsClasses(ciTemp.getTreeRoot()));
+//		
+//		for (Element element : allModelsInInstantiationTree) {
+//			if (element instanceof NamedElement) {
+//				for (Element dep : ((NamedElement)element).getClientDependencies()) {
+//					Stereotype s = dep.getAppliedStereotype(Constants.stereotypeQName_Requires);
+//					if (s != null) {
+//						Object list = dep.getValue(s, Constants.propertyName_onlyIncombinationWith);
+//						Object isAlways = dep.getValue(s, Constants.propertyName_always);
+//						
+//						if (isAlways instanceof Boolean && (Boolean)isAlways) { // no restriction -> include
+//							listOfAdditionalModels.add( ((Dependency)dep).getTargets().get(0) );
+//						}
+//						else if ( list instanceof EList && ((EList)list).size() > 0) { // check restriction
+//							for (Object referencedModel : (EList<?>)list) {
+//								Element referencedModelElement = UMLUtil.getBaseElement((EObject) referencedModel);
+//								if (referencedModelElement instanceof Element 
+//										&& allModelsInInstantiationTree.contains(referencedModelElement) ) {
+//									// add the dependency target to the models that should be instantiated in addition
+//									listOfAdditionalModels.add( ((Dependency)dep).getTargets().get(0) );
+//								}
+//							}
+//						}
+////						else { // no restriction -> add the dependency target to the list. 
+////							listOfAdditionalModels.add( ((Dependency)dep).getTargets().get(0) );
+////						}
+//					}
+//				}
+//			}
+//		}
+//		return listOfAdditionalModels;
+//	}
+	
+	
+//	private void findTestSenariosAndRequirementsToBeInstantiated(ClassInstantiation ciSourceModel, Class testScenario){
+//		// add system model to the simulated instantiation of the 
+//		TreeParent simulatedInstantiationTreeRoot = new TreeParent("Simulated Instantiation", null, null, "", false, true, null, null, true);
+//		simulatedInstantiationTreeRoot.addChild(ciSourceModel.getTreeRoot());
+//		
+//		// instantiate test scenario
+//		ClassInstantiation ciTestScenario = new ClassInstantiation((Class) testScenario, true);
+//		ciTestScenario.createTree();
+//		
+//		// add test scenario to the simulated instantiation
+//		simulatedInstantiationTreeRoot.addChild(ciTestScenario.getTreeRoot());
+//		
+//		/* get the list of system model clients for which the code could be derived (even if a user interaction would be necessary) 
+//		from the test scenario providers */
+//		ValueBindingCreator vbc = new ValueBindingCreator();
+//		
+//		/* Note, the updateAllBindings() is called with the last argument simulateOnly = true  
+//		 * so that no modifications are created in components because we only want to analyze possible bindings.
+//		 */
+//		boolean allSystemModelRquiredClientsAreSatisfied = true;
+//		vbc.updateAllBindings((Package)valueBindingsPackage, ciSourceModel.getTreeRoot(), simulatedInstantiationTreeRoot, false, true, false, true);
+//		if ( vbc.getAllRequiredClientsFound().size() > 0 
+//				&& !vbc.getAllClientsWithPossibleBindingCodeDerivation().containsAll(vbc.getAllRequiredClientsFound())) {
+//			allSystemModelRquiredClientsAreSatisfied = false;
+//		}
+//
+//		/* If there is at least one client that uses one of the test scenario providers
+//		 * and all test scenario required clients are satisfied by the system model -> search for associated requirements
+//		 * else stop here -> this test scenario is not appropriate to be used to stimulate this system model.
+//		 */
+//		
+//		/* NOTE: Checking if test scenario clients are all satisfied by the system model
+//		 * is not necessary because a test scenario must not have all clients bound to other model.
+//		 * If it is used to test different design alternatives then some of the test scenario clients may be specific to
+//		 * one design alternative and are not satisfied by another design alternative. 
+//		 */
+//		boolean atLeastOneTestScenarioProviderIsUsedInSystemModel = treeContainsOneOf(vbc.getUsedProviders(), ciTestScenario.getTreeRoot());
+//
+////		if ( treeContainsOneOf(vbc.getUsedProviders(), ciTestScenario.getTreeRoot()) ) { // if at least one test scenario providers is used to stimulate the system model.
+//		if ( atLeastOneTestScenarioProviderIsUsedInSystemModel && allSystemModelRquiredClientsAreSatisfied) {
+////			System.err.println( "selected test scenario: " + ((NamedElement)testScenario).getName());
+//			
+//			/* Create a new simulated instantiation, 
+//			 * add system model to the simulated instantiation 
+//			 */
+//			TreeParent simulatedInstantiationTreeRoot_reqAndSystemModel = new TreeParent("Simulated Instantiation", null, null, "", false, true, null, null, true);
+//			simulatedInstantiationTreeRoot_reqAndSystemModel.addChild(ciSourceModel.getTreeRoot());
+//			
+//			HashSet<Element> requirementsToBeInstantiated = new HashSet<Element>();
+//			// get all requirements that can be tested using this scenario
+//			for (Element requirement : tsc.getTsToReq().get(testScenario)) {
+//				// instantiate test scenario
+//				ClassInstantiation ciReq = new ClassInstantiation((Class) requirement, true);
+//				ciReq.createTree();
+//				
+//				simulatedInstantiationTreeRoot_reqAndSystemModel.addChild(ciReq.getTreeRoot());
+//				/* Note, the updateAllBindings() is called with the last argument simulateOnly = true  
+//				 * so that no modifications are created in components because we only want to analyze possible bindings.
+//				 */
+//				vbc.updateAllBindings((Package)valueBindingsPackage, ciReq.getTreeRoot(), 
+//						simulatedInstantiationTreeRoot_reqAndSystemModel, false, true, false, true);
+//				
+//				// if it was possible to derive code for all (required) clients of this requirement using the system model providers
+//				if (vbc.getAllClientsFound().size() > 0 
+//						&& vbc.getAllClientsWithPossibleBindingCodeDerivation().containsAll(vbc.getAllClientsFound())) {
+//					// add to req.list to be instantiated
+//					requirementsToBeInstantiated.add(requirement);
+////					System.err.println("selected req.: " + ((NamedElement)requirement).getName());
+//				}
+//				else if (vbc.getAllRequiredClientsFound().size() > 0 
+//						&& vbc.getAllClientsWithPossibleBindingCodeDerivation().containsAll(vbc.getAllRequiredClientsFound())) {
+//					// add to req.list to be instantiated
+//					requirementsToBeInstantiated.add(requirement);
+////					System.err.println("selected req.: " + ((NamedElement)requirement).getName());
+//				}
+//				else {
+//					requirementsDiscarded.add(requirement);
+////					System.err.println("discarded req.: " + ((NamedElement)requirement).getName());
+//
+//					// add to log
+//					String msg = "DISCARDED: Requirement ("+ModelicaMLServices.getRequirementID(requirement)+") '" + ((NamedElement)requirement).getQualifiedName() + "'" +  
+//								"\nFor some of its clients the binding code could NOT be derived using " +
+//								"the providers of '"+ciSourceModel.getSelectedClass().getName()+"'. \n" ;
+//					addToLog(msg);
+//				}
+//			}
+//			
+//			//Collect the test scenario and all its referenced requirements that are selected for instantiation
+//			if (requirementsToBeInstantiated.size() > 0 ) {
+//				this.testScenariosToBeInstantiated.add(testScenario);
+//				this.requirementsToBeInstantiated.addAll(requirementsToBeInstantiated);
+//			}
+//			else {
+//				testScenariosDiscarded.add(testScenario);
+////				System.err.println("discarded test scenario: " + ((NamedElement)testScenario).getName());
+//				String msg = "";
+//				
+//				// if there no requirements referenced by the test scenario
+//				if (tsc.getTsToReq().get(testScenario) == null) {
+//					msg = "DISCARDED: Test Scenario '" + ((NamedElement)testScenario).getQualifiedName() + "'" +  
+//					"\nNo requirements are found that can be tested using this test scenario " +
+//					"and the model '"+ciSourceModel.getSelectedClass().getName()+"'. \n" ;
+//				}
+//				else {
+//					msg = "DISCARDED: Test Scenario '" + ((NamedElement)testScenario).getQualifiedName() + "'" +  
+//					"\nFor none of the referenced requirements clients the clients are satisfied by providers of " +
+//					"the model '"+ciSourceModel.getSelectedClass().getName()+"'. \n" ;
+//				}
+//				// add to log
+//				addToLog(msg);
+//			}
+//		}
+//		else {
+//			testScenariosDiscarded.add(testScenario);
+////			System.err.println("discarded test scenario: " + ((NamedElement)testScenario).getName());
+//
+//			// add to log
+//			String msg = "DISCARDED: Test Scenario '" + ((NamedElement)testScenario).getQualifiedName() + "'" + 
+//						"\nNone of its providers is used to stimulate the model '"+ciSourceModel.getSelectedClass().getName()+"'. \n" ;
+//			addToLog(msg);
+//		}
+//	}
+	
+//	private void findTestSenariosAndRequirementsToBeInstantiated(ClassInstantiation ciSourceModel, Class testScenario){
+//		// add system model to the simulated instantiation of the 
+//		TreeParent simulatedInstantiationTreeRoot = new TreeParent("Simulated Instantiation", null, null, "", false, true, null, null, true);
+//		simulatedInstantiationTreeRoot.addChild(ciSourceModel.getTreeRoot());
+//		
+//		// instantiate test scenario
+//		ClassInstantiation ciTestScenario = new ClassInstantiation((Class) testScenario, true);
+//		ciTestScenario.createTree();
+//		
+//		// add test scenario to the simulated instantiation
+//		simulatedInstantiationTreeRoot.addChild(ciTestScenario.getTreeRoot());
+//		
+//		/* get the list of system model clients for which the code could be derived (even if a user interaction would be necessary) 
+//		from the test scenario providers */
+//		ValueBindingCreator vbc = new ValueBindingCreator();
+//		
+//		/* Note, the updateAllBindings() is called with the last argument simulateOnly = true  
+//		 * so that no modifications are created in components because we only want to analyze possible bindings.
+//		 */
+//		boolean allSystemModelRquiredClientsAreSatisfied = true;
+//		vbc.updateAllBindings((Package)valueBindingsPackage, ciSourceModel.getTreeRoot(), simulatedInstantiationTreeRoot, false, true, false, true);
+//		if ( vbc.getAllRequiredClientsFound().size() > 0 
+//				&& !vbc.getAllClientsWithPossibleBindingCodeDerivation().containsAll(vbc.getAllRequiredClientsFound())) {
+//			allSystemModelRquiredClientsAreSatisfied = false;
+//		}
+//
+//		/* If there is at least one client that uses one of the test scenario providers
+//		 * and all test scenario required clients are satisfied by the system model -> search for associated requirements
+//		 * else stop here -> this test scenario is not appropriate to be used to stimulate this system model.
+//		 */
+//		
+//		/* NOTE: Checking if test scenario clients are all satisfied by the system model
+//		 * is not necessary because a test scenario must not have all clients bound to other model.
+//		 * If it is used to test different design alternatives then some of the test scenario clients may be specific to
+//		 * one design alternative and are not satisfied by another design alternative. 
+//		 */
+//		boolean atLeastOneTestScenarioProviderIsUsedInSystemModel = treeContainsOneOf(vbc.getUsedProviders(), ciTestScenario.getTreeRoot());
+//
+////		if ( treeContainsOneOf(vbc.getUsedProviders(), ciTestScenario.getTreeRoot()) ) { // if at least one test scenario providers is used to stimulate the system model.
+//		if ( atLeastOneTestScenarioProviderIsUsedInSystemModel && allSystemModelRquiredClientsAreSatisfied) {
+////			System.err.println( "selected test scenario: " + ((NamedElement)testScenario).getName());
+//			
+//			/* Create a new simulated instantiation, 
+//			 * add system model to the simulated instantiation 
+//			 */
+//			TreeParent simulatedInstantiationTreeRoot_reqAndSystemModel = new TreeParent("Simulated Instantiation", null, null, "", false, true, null, null, true);
+//			simulatedInstantiationTreeRoot_reqAndSystemModel.addChild(ciSourceModel.getTreeRoot());
+//			
+//			HashSet<Element> requirementsToBeInstantiated = new HashSet<Element>();
+//			// get all requirements that can be tested using this scenario
+//			for (Element requirement : tsc.getTsToReq().get(testScenario)) {
+//				// instantiate test scenario
+//				ClassInstantiation ciReq = new ClassInstantiation((Class) requirement, true);
+//				ciReq.createTree();
+//				
+//				simulatedInstantiationTreeRoot_reqAndSystemModel.addChild(ciReq.getTreeRoot());
+//				/* Note, the updateAllBindings() is called with the last argument simulateOnly = true  
+//				 * so that no modifications are created in components because we only want to analyze possible bindings.
+//				 */
+//				vbc.updateAllBindings((Package)valueBindingsPackage, ciReq.getTreeRoot(), 
+//						simulatedInstantiationTreeRoot_reqAndSystemModel, false, true, false, true);
+//				
+//				// if it was possible to derive code for all (required) clients of this requirement using the system model providers
+//				if (vbc.getAllClientsFound().size() > 0 
+//						&& vbc.getAllClientsWithPossibleBindingCodeDerivation().containsAll(vbc.getAllClientsFound())) {
+//					// add to req.list to be instantiated
+//					requirementsToBeInstantiated.add(requirement);
+////					System.err.println("selected req.: " + ((NamedElement)requirement).getName());
+//				}
+//				else if (vbc.getAllRequiredClientsFound().size() > 0 
+//						&& vbc.getAllClientsWithPossibleBindingCodeDerivation().containsAll(vbc.getAllRequiredClientsFound())) {
+//					// add to req.list to be instantiated
+//					requirementsToBeInstantiated.add(requirement);
+////					System.err.println("selected req.: " + ((NamedElement)requirement).getName());
+//				}
+//				else {
+//					requirementsDiscarded.add(requirement);
+////					System.err.println("discarded req.: " + ((NamedElement)requirement).getName());
+//
+//					// add to log
+//					String msg = "DISCARDED: Requirement ("+ModelicaMLServices.getRequirementID(requirement)+") '" + ((NamedElement)requirement).getQualifiedName() + "'" +  
+//								"\nFor some of its clients the binding code could NOT be derived using " +
+//								"the providers of '"+ciSourceModel.getSelectedClass().getName()+"'. \n" ;
+//					addToLog(msg);
+//				}
+//			}
+//			
+//			//Collect the test scenario and all its referenced requirements that are selected for instantiation
+//			if (requirementsToBeInstantiated.size() > 0 ) {
+//				this.testScenariosToBeInstantiated.add(testScenario);
+//				this.requirementsToBeInstantiated.addAll(requirementsToBeInstantiated);
+//			}
+//			else {
+//				testScenariosDiscarded.add(testScenario);
+////				System.err.println("discarded test scenario: " + ((NamedElement)testScenario).getName());
+//				String msg = "";
+//				
+//				// if there no requirements referenced by the test scenario
+//				if (tsc.getTsToReq().get(testScenario) == null) {
+//					msg = "DISCARDED: Test Scenario '" + ((NamedElement)testScenario).getQualifiedName() + "'" +  
+//					"\nNo requirements are found that can be tested using this test scenario " +
+//					"and the model '"+ciSourceModel.getSelectedClass().getName()+"'. \n" ;
+//				}
+//				else {
+//					msg = "DISCARDED: Test Scenario '" + ((NamedElement)testScenario).getQualifiedName() + "'" +  
+//					"\nFor none of the referenced requirements clients the clients are satisfied by providers of " +
+//					"the model '"+ciSourceModel.getSelectedClass().getName()+"'. \n" ;
+//				}
+//				// add to log
+//				addToLog(msg);
+//			}
+//		}
+//		else {
+//			testScenariosDiscarded.add(testScenario);
+////			System.err.println("discarded test scenario: " + ((NamedElement)testScenario).getName());
+//
+//			// add to log
+//			String msg = "DISCARDED: Test Scenario '" + ((NamedElement)testScenario).getQualifiedName() + "'" + 
+//						"\nNone of its providers is used to stimulate the model '"+ciSourceModel.getSelectedClass().getName()+"'. \n" ;
+//			addToLog(msg);
+//		}
+//	}
+	
+	// Utls ##########################################################
+	
+	
+//	private HashSet<TreeObject> getUnsatisfiedRequiredClients(Element model, TestSimulationModelCombination tsmc){
+//		TreeParent reqInstantiation = tsmc.getModelToItsInstantiation().get(model);
+//		
+//		if (reqInstantiation != null) {
+//			HashSet<TreeObject> unsatisfiedClients = tsmc.getRequiredClients_unsatisfied().get(reqInstantiation);
+//			
+////			System.err.println(reqInstantiation);
+////			System.err.println("unsatisfiedClients: " + unsatisfiedClients);
+////			System.err.println("");
+//			
+//			if (unsatisfiedClients != null && unsatisfiedClients.size() > 0 ) {
+//				return unsatisfiedClients;
+//			}
+//		}
+//		return null;
+//	}
+	
+//	private String getRequirementId(NamedElement req){
+//		Stereotype s_req = req.getAppliedStereotype(Constants.stereotypeQName_Requirement);
+//		Object o = req.getValue(s_req, Constants.propertyName_id);
+//		if (o instanceof String) {
+//			return (String) o;
+//		}
+//		return "";
+//	}
+	
+//	private HashSet<TreeObject> getAllTreeItems(TreeParent treeParent){
+//		HashSet<TreeObject> allTreeItems = new HashSet<TreeObject>();
+//		allTreeItems.add(treeParent);
+//		
+//		TreeObject[] children = treeParent.getChildren();
+//		for (int i = 0; i < children.length; i++) {
+//			allTreeItems.add(children[i]);
+//			if (children[i] instanceof TreeParent) {
+//				allTreeItems.addAll(getAllTreeItems((TreeParent)children[i]));
+//			}
+//		}
+//		
+//		return allTreeItems;
+//	}
+//	
+//	private HashSet<Element> getAllTreeItemsClasses(TreeParent treeParent){
+//		HashSet<Element> allTreeItems = new HashSet<Element>();
+//		
+//		TreeObject[] children = treeParent.getChildren();
+//		for (int i = 0; i < children.length; i++) {
+//			if (children[i].getUmlElement() instanceof TypedElement && ((TypedElement)children[i].getUmlElement()).getType() instanceof Classifier) {
+//				allTreeItems.add(((TypedElement)children[i].getUmlElement()).getType());
+//			}
+//			if (children[i] instanceof TreeParent) {
+//				allTreeItems.addAll(getAllTreeItemsClasses((TreeParent)children[i]));
+//			}
+//		}
+//		return allTreeItems;
+//	}
+//	
+//	
+//	private boolean treeContainsOneOf(HashSet<TreeObject> treeItems, TreeParent treeParent){
+//		HashSet<TreeObject> allTreeItems = getAllTreeItems(treeParent);
+//		
+//		for (TreeObject treeObject : treeItems) {
+//			if (allTreeItems.contains(treeObject)) {
+//				return true;
+//			}
+//		}
+//		return false;
+//	}
+
+//	private String getNamePostFix(NamedElement owner, String name){
+//		String postfix = "_";
+//		int highestPostFixNumber = 0;
+//	
+//		EList<Element> ownedElements = owner.getOwnedElements();
+//		for (Element element : ownedElements) {
+//			if (element instanceof NamedElement && ((NamedElement)element).getName().startsWith(name)) {
+//				
+//				String namePart = ((NamedElement)element).getName();
+//				String postFix = namePart.replaceFirst(name, "").replaceAll("_", "").trim();
+//				
+//				if (!postFix.equals("")) {
+//					try {
+//						int postFixNumber = Integer.valueOf(postFix);
+//						if (postFixNumber > highestPostFixNumber) {
+//							highestPostFixNumber = postFixNumber;
+//						}
+//					} catch (Exception e) {
+//						// ignore, do nothing.
+//					}
+//				}
+//			}
+//		}
+//		return postfix + (highestPostFixNumber + 1);	
+//	}
+
+	private void addToLog(String msg){
+//		this.log = this.log + "\n" + msg;
+		this.log = this.log + msg + "\n";
+	}
+
+	private void clearLog(){
+		this.log = "";
+	}
+	
+	// GETTERS ############################################
+	
+	public String getLog() {
+		return log;
+	}
+	
+	public HashSet<Element> getAllRequirements() {
+		return allRequirements;
+	}
+
+	public void setAllRequirements(HashSet<Element> allRequirements) {
+		this.allRequirements = allRequirements;
+	}
+
+	public HashSet<Element> getAllTestScenarios() {
+		return allTestScenarios;
+	}
+
+	public void setAllTestScenarios(HashSet<Element> allTestScenarios) {
+		this.allTestScenarios = allTestScenarios;
+	}
+
+	public HashSet<Element> getTestScenariosToBeInstantiated() {
+		return testScenariosToBeInstantiated;
+	}
+
+	public void setTestScenariosToBeInstantiated(
+			HashSet<Element> testScenariosToBeInstantiated) {
+		this.testScenariosToBeInstantiated = testScenariosToBeInstantiated;
+	}
+
+	public HashSet<Element> getTestScenariosDiscarded() {
+		return testScenariosDiscarded;
+	}
+
+	public void setTestScenariosDiscarded(HashSet<Element> testScenariosDiscarded) {
+		this.testScenariosDiscarded = testScenariosDiscarded;
+	}
+
+	public HashSet<Element> getRequirementsToBeInstantiated() {
+		return requirementsToBeInstantiated;
+	}
+
+	public void setRequirementsToBeInstantiated(
+			HashSet<Element> requirementsToBeInstantiated) {
+		this.requirementsToBeInstantiated = requirementsToBeInstantiated;
+	}
+
+	public HashSet<Element> getRequirementsDiscarded() {
+		return requirementsDiscarded;
+	}
+
+	public void setRequirementsDiscarded(HashSet<Element> requirementsDiscarded) {
+		this.requirementsDiscarded = requirementsDiscarded;
+	}
+	
+	public void setTestSimulationModelGenerationCanceled(boolean canceled) {
+		this.canceled = canceled;
+	}
+
+	public boolean isTestSimulationModelGenerationCanceled() {
+		return canceled;
+	}
+
+	public HashSet<Element> getUserSelectedTestScenarios() {
+		return userSelectedTestScenarios;
+	}
+	
+
+	
+	// The total sleep time
+	private static final int TOTAL_TIME = 100;
+	// The increment sleep time
+	private static final int INCREMENT = 10;
+	// process time´is unknown
+	private boolean indeterminate = true; 
+	
+	private String progressMonitorTitle = "Test Simulation Models Generator ";
+	private String monitorText1 = "Collecting data ...";
+	private String monitorText2 = "Analyzing combinations ...";
+	
+	@Override
+	public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+		
+		if (!this.isTestSimulationModelGenerationCanceled()) {
+			monitor.beginTask(progressMonitorTitle + " is running." , indeterminate ? IProgressMonitor.UNKNOWN : TOTAL_TIME);
+		    for (int total = 0; total < TOTAL_TIME && !monitor.isCanceled(); total += INCREMENT) {
+		      Thread.sleep(INCREMENT);
+		      monitor.worked(INCREMENT);
+		      if (total == TOTAL_TIME / 4) monitor.subTask(monitorText1);
+		      if (total == TOTAL_TIME / 2) monitor.subTask(monitorText2);
+		      
+//		      if (total == TOTAL_TIME / 8) monitor.subTask("Collecting data ...");
+//		      if (total == TOTAL_TIME / 4) monitor.subTask("Preparing simulation models to be created ...");
+//		      if (total == TOTAL_TIME / 2) monitor.subTask("Creating models ...");
+		    }
+		    monitor.done();
+		    if (monitor.isCanceled()){
+		    	throw new InterruptedException(progressMonitorTitle + " was cancelled.");
+		    }   
+		}
+	}
+}
Index: /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/ValueBindingCreator.java
===================================================================
--- /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/ValueBindingCreator.java	(revision 909)
+++ /trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/ValueBindingCreator.java	(revision 910)
@@ -216,28 +216,41 @@
 				
 				// add to required clients list
-				if (deriveCodeHelper.getMediatorElement() != null ) {
-					EList<Dependency> clientDep = org.openmodelica.modelicaml.view.valuebindings.model.TreeUtls.
-											getMediatorDependency((NamedElement)deriveCodeHelper.getMediatorElement(), 
-													(NamedElement)deriveCodeHelper.getClientElement(), 
-													Constants.stereotypeQName_ProvidesValueFor);
-					if (clientDep.size() == 1) { // only one dependency is allowed.
-						Dependency dep = (Dependency)clientDep.get(0);
-						Stereotype sProvidesValueFor = dep.getAppliedStereotype(Constants.stereotypeQName_ProvidesValueFor);
-						if (sProvidesValueFor != null) {
-							if (dep.getValue(sProvidesValueFor, Constants.propertyName_isRequired) != null) {
-								allRequiredClientsFound.add(item);
-								
-								if (code == null) {
-									// Generate marker 
-									String message = "No binding code could be generated for the required client '"+ item.getDotPath() + "'."; 
-									// delete the marker if there was one from previous actions.
-									ModelicaMLMarkerSupport.deleteMarker(message, item.getFirstLevelComponent());
-									// generate new marker
-									ModelicaMLMarkerSupport.generateMarker(message, "error", item.getFirstLevelComponent());
-								}
-							}
-						}
+				if (deriveCodeHelper.isRequiredClient()) {
+					allRequiredClientsFound.add(item);
+					if (code == null) {
+						// Generate marker 
+						String message = "No binding code could be generated for the required client '"+ item.getDotPath() + "'."; 
+						// delete the marker if there was one from previous actions.
+						ModelicaMLMarkerSupport.deleteMarker(message, item.getFirstLevelComponent());
+						// generate new marker
+						ModelicaMLMarkerSupport.generateMarker(message, "error", item.getFirstLevelComponent());
 					}
 				}
+				
+//				if (deriveCodeHelper.getMediatorElement() != null ) {
+//					EList<Dependency> clientDep = org.openmodelica.modelicaml.view.valuebindings.model.TreeUtls.
+//											getMediatorDependency((NamedElement)deriveCodeHelper.getMediatorElement(), 
+//													(NamedElement)deriveCodeHelper.getClientElement(), 
+//													Constants.stereotypeQName_ProvidesValueFor);
+//					if (clientDep.size() == 1) { // only one dependency is allowed.
+//						Dependency dep = (Dependency)clientDep.get(0);
+//						Stereotype sProvidesValueFor = dep.getAppliedStereotype(Constants.stereotypeQName_ProvidesValueFor);
+//						if (sProvidesValueFor != null) {
+//							Object isRequired = dep.getValue(sProvidesValueFor, Constants.propertyName_isRequired);
+//							if (isRequired != null && isRequired instanceof Boolean && (Boolean)isRequired) {
+//								allRequiredClientsFound.add(item);
+//								
+//								if (code == null) {
+//									// Generate marker 
+//									String message = "No binding code could be generated for the required client '"+ item.getDotPath() + "'."; 
+//									// delete the marker if there was one from previous actions.
+//									ModelicaMLMarkerSupport.deleteMarker(message, item.getFirstLevelComponent());
+//									// generate new marker
+//									ModelicaMLMarkerSupport.generateMarker(message, "error", item.getFirstLevelComponent());
+//								}
+//							}
+//						}
+//					}
+//				}
 				
 				// if code could be derive -> add to possible code derivation clients
@@ -251,5 +264,7 @@
 					// Generate marker 
 					String message = "No binding code could be automatically generated for '"+ item.getDotPath() + "'. User decision is required."; 
+					// delete the marker if there was one from previous actions.
 					ModelicaMLMarkerSupport.deleteMarker(message, item.getFirstLevelComponent());
+					// generate new marker
 					ModelicaMLMarkerSupport.generateMarker(message, "error", item.getFirstLevelComponent());
 				}
