Index: trunk/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 882)
+++ trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/SimulationModelsGenarator.java	(revision 883)
@@ -7,4 +7,5 @@
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Classifier;
 import org.eclipse.uml2.uml.Element;
 import org.eclipse.uml2.uml.NamedElement;
@@ -103,18 +104,8 @@
 				generateSimulationModels(sourceModel);
 			}
-			
-//			if there are some messages -> display them
-//			if ( !getLog().trim().equals("") ) {
-//				String infoText = "";
-//				// show translation messages
-//				DialogMessage dialog = new DialogMessage(new Shell(), "Notes on Simulation Models Generation", infoText, getLog());
-//				dialog.open();
-//			}
 		}
 	}
 	
 	private void clearAllLists(){
-//		allRequirements.clear();
-//		allTestScenarios.clear();
 		testScenariosToBeInstantiated.clear();
 		testScenariosDiscarded.clear();
@@ -147,25 +138,37 @@
 	private void createSimulationModels(Element sourceModel){
 		
-		PackageableElement p = ((Package)targetPackage).createPackagedElement(Constants.simModelsPackageNamePrefix + ((NamedElement)sourceModel).getName(), 
+		/*TODO: create dialog that lets the user select the found test scenarios and requirements
+		 * and shows which test scenarios are discarded and which requirements are not selected. 
+		 */
+		
+		PackageableElement simulationModelsPackage = (
+				(Package)targetPackage).createPackagedElement(Constants.simModelsPackageNamePrefix + ((NamedElement)sourceModel).getName(),
 				UMLPackage.Literals.PACKAGE);
+		
 		for (Element testScenario : testScenariosToBeInstantiated) {
-			if (testScenario instanceof NamedElement) {
+			
+			if (testScenario instanceof Classifier) {
 				
 				// add class
 				String simulationModelName = Constants.simModelsNamePrefix + ((NamedElement)testScenario).getName();
-				Class c = ((Package)p).createOwnedClass(simulationModelName, false);
-				Stereotype s_model = c.getApplicableStereotype(Constants.stereotypeQName_Model);
-				Stereotype s_simulation = c.getApplicableStereotype(Constants.stereotypeQName_Simulation);
+				Class simulationModel = ((Package)simulationModelsPackage).createOwnedClass(simulationModelName, false);
+				
+				// TODO: here 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);
 				if (s_model != null && s_simulation != null) {
-					c.applyStereotype(s_model);
-					c.applyStereotype(s_simulation);
+					simulationModel.applyStereotype(s_model);
+					simulationModel.applyStereotype(s_simulation);
 				}
 				else {
-					String msg = "ERROR: Cannot apply the stereotypes 'Model' and 'Simulation' to the '" + c.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+					String msg = "ERROR: Cannot apply the stereotypes 'Model' and 'Simulation' to the '" 
+						+ simulationModel.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
 					addToLog(msg);
 				}
 				
 				// add system model property
-				Property p_systemModel = c.createOwnedAttribute(
+				Property p_systemModel = simulationModel.createOwnedAttribute(
 						Constants.systemModelPropertyNamePrefix 
 						+ StringUtls.replaceSpecChar(((NamedElement)sourceModel).getName().toLowerCase()), 
@@ -176,10 +179,11 @@
 				}
 				else {
-					String msg = "ERROR: Cannot apply the stereotypes 'Component' to the '" + p_systemModel.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+					String msg = "ERROR: Cannot apply the stereotypes 'Component' to the '" 
+						+ p_systemModel.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
 					addToLog(msg);
 				}
 
 				// add test scenario property
-				Property p_testScenario = c.createOwnedAttribute(
+				Property p_testScenario = simulationModel.createOwnedAttribute(
 						Constants.testScenarioPropertyNamePrefix 
 						+ StringUtls.replaceSpecChar(((NamedElement)testScenario).getName().toLowerCase()), 
@@ -199,22 +203,23 @@
 					// if this requirement was selected, i.e. was not discarded
 					if (!requirementsDiscarded.contains(requirement) && requirement instanceof Class) {
-
-						// get the number of required instantiations
-						int requiredNumberOfInstantions = ri.getMaxNumberOfProviders(c, (Class) requirement);
-						for (int i = 0; i < requiredNumberOfInstantions; i++) {
-							Property p_req = c.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 stereotypes 'requirementInstantance' to the '" + p_req.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
-								addToLog(msg);
+						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 stereotypes 'requirementInstantance' to the '" + p_req.getQualifiedName() + "'. Check if the ModelicaML profile is applied.";
+									addToLog(msg);
+								}
 							}
 						}
@@ -223,9 +228,12 @@
 				
 				// instantiate the class
-				ClassInstantiation ci = new ClassInstantiation((Class) c, true);
+				ClassInstantiation ci = new ClassInstantiation((Class) simulationModel, true);
 				ci.createTree();
 				
 				// update bindings
 				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);
 			}
@@ -249,4 +257,8 @@
 		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.
+		 */
 		vbc.updateAllBindings((Package)valueBindingsPackage, ciSourceModel.getTreeRoot(), simulatedInstantiationTreeRoot, false, true, false, true);
 
@@ -255,12 +267,11 @@
 		 */
 		
-		/* NOTE: Checking if test clients are all satisfied by the 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 alternative and are not provided by another. 
+		 * one design alternative and are not satisfied by another design alternative. 
 		 */
 		
-		
-		//TODO: rework: use the required client attribute to see if all required clients are satisfied
+		//TODO: Check if all required clients are satisfied! 
 		
 		if (treeContainsOneOf(vbc.getUsedProviders(), ciTestScenario.getTreeRoot())) {
@@ -280,4 +291,7 @@
 				
 				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);
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 882)
+++ trunk/modelicaml/org.openmodelica.modelicaml.helper/src/org/openmodelica/modelicaml/helper/impl/ValueBindingCreator.java	(revision 883)
@@ -93,5 +93,9 @@
 		
 		// update bindings for all sub-components (recursively) of the selected tree item.
-		updateAllSubComponents(treeParent, treeRoot, deleteOldBindings, isAutomaticSelectionOfPreferredProvidersEnabled, onlySimulate);
+		updateAllSubComponents(treeParent, 
+				treeRoot, 
+				deleteOldBindings, 
+				isAutomaticSelectionOfPreferredProvidersEnabled, 
+				onlySimulate);
 	}
 	
@@ -114,5 +118,9 @@
 		
 		// update the binding only for the selected tree item
-		updateSingle(treeItem, treeRoot, deleteOldBindings, isAutomaticSelectionOfPreferredProvidersEnabled, onlySimulate);
+		updateSingle(treeItem, 
+				treeRoot, 
+				deleteOldBindings, 
+				isAutomaticSelectionOfPreferredProvidersEnabled, 
+				onlySimulate);
 	}
 	
@@ -146,60 +154,11 @@
 				// update a single item
 				updateSingle(item, treeRoot, deleteOldBindings, isAutomaticSelectionOfPreferredProvidersEnabled, onlySimulate);
-
-				// replaced by the updateSingle() 
-//				Element element = item.getUmlElement();
-//				
-//				Element modificationStoreLocation = item.getModificationStoreLocation();
-//				String componentPath = "";
-//				if (modificationStoreLocation instanceof Property) {
-//					componentPath = item.getDotPathWithoutFirstLevelComponent();
-//				}
-//				else if (modificationStoreLocation instanceof Generalization) {
-//					componentPath = item.getDotPath();
-//				}
-//				
-//				if (element instanceof Property) {
-//					// No user guidance is possible so far. 
-//					// TODO: Think about the option to guide, 
-//					// therefore the user should be able to cancel single code derivation or the overall "update all bindings" function.
-//					// Moreover, the code derivation dialogs should always include the information about client, mediator, provider.
-//					// This is not the case so far, for example, in the provider selection dialog.
-//					
-//					deriveCodeHelper.deriveBindingCodeForClient(item, false, isAutomaticSelectionOfPreferredProvidersEnabled); 
-//					String code = deriveCodeHelper.getCode(); 
-//					
-//		    		// delete old bindings
-//					// if the client element was found based on the selected tree item or the upper level scripts 
-//					// -> this means that in general there is a binding.
-//					// -> If the option is selected then delete the binding for the current tree item. 
-//					// -> However, it may happen that the binding code cannot be derived without user guidance so that the modification of the current item will be empty at the end. 
-//					
-//					if ( deriveCodeHelper.getClientElement() != null && modificationStoreLocation != null && deleteOldBindings ) {
-//		    			String result = ModificationManager.deleteComponentModificationBasedOnLeftHandValue(modificationStoreLocation, componentPath);
-//		    			if (result != null && !result.trim().equals("")) {
-//		    				
-//		    				deletedModifications.add(result);
-//							deletedItemsModification.add(item);
-//							
-//	    					item.setFinalModificationRightHand( null ); 
-//							item.setFinalModificationSource( null );
-//						}
-//					}
-//					
-//		    		// add modifications
-//		    		if (deriveCodeHelper.getClientElement() != null && code != null && modificationStoreLocation != null) {
-//
-//		    			ModificationManager.addComponentModification( modificationStoreLocation, componentPath, code, true);
-//						
-//		    			item.setFinalModificationRightHand(code); 
-//						item.setFinalModificationSource( modificationStoreLocation );
-//		    			
-//						updatedItems.add(item);
-//		    			updatedItemsToNewModification.put(item, code);		    			
-//					}
-//				}
 			
 				if (item instanceof TreeParent) {
-					updateAllSubComponents((TreeParent)item, treeRoot, deleteOldBindings, isAutomaticSelectionOfPreferredProvidersEnabled, onlySimulate);
+					updateAllSubComponents((TreeParent)item, 
+							treeRoot, 
+							deleteOldBindings, 
+							isAutomaticSelectionOfPreferredProvidersEnabled, 
+							onlySimulate);
 				}
 			}
