Index: trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree/display/ViewLabelProvider.java
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree/display/ViewLabelProvider.java	(revision 926)
+++ trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree/display/ViewLabelProvider.java	(revision 933)
@@ -370,7 +370,11 @@
 	private String getValueClientOrProviderIndicatorString(TreeObject treeObject) {
 		String string = "";
-		if (treeObject.isValueClient()) {
+		if (treeObject.isValueClient_required()) {
+			string = string+ requiredClientIndicator+", ";
+		}
+		else if (treeObject.isValueClient()) {
 			string = string+ clientIndicator+", ";
 		}
+		
 		if (treeObject.isValueProvider()) {
 			string = string + providerIndicator+", ";
@@ -379,4 +383,5 @@
 	}
 	
+	private final static String requiredClientIndicator = "(req. client)";
 	private final static String clientIndicator = "(client)";
 	private final static String providerIndicator = "(provider)";
@@ -478,5 +483,8 @@
 		
 		// if it is a required client and there is no binding equation (modification) for it -> error
-		if (treeParent.isValueClient_required() && treeParent.getFinalModificationRightHand() == null) {
+		/*
+		 * TODO: If the actual client is a sub-component of the item then an analysis of the subcomponents is required...  
+		 */
+		if (treeParent.isLeaf() && treeParent.isValueClient_required() && treeParent.getFinalModificationRightHand() == null) {
 			list.add(treeParent);
 		}
@@ -512,22 +520,24 @@
 			// markers
 			ExtendedUmlModel umlModel = (ExtendedUmlModel) UmlUtils.getUmlModel();
-			String projectName = umlModel.getResource().getURI().segment(1);
-			IWorkspace workspace = ResourcesPlugin.getWorkspace();
-			IWorkspaceRoot root = workspace.getRoot();
-			IProject iProject = root.getProject(projectName);
-			
-			IMarker[] markers = null;
-			try {
-				if (iProject != null) {
-					markers = iProject.findMarkers(markerType, true, IResource.DEPTH_INFINITE);
-					for (IMarker marker : markers) {
-						Object sourceId = marker.getAttribute(IMarker.SOURCE_ID);
-							if (item.getDotPath().equals(sourceId)) {
-								return true;				
+			if (umlModel != null) {
+				String projectName = umlModel.getResource().getURI().segment(1);
+				IWorkspace workspace = ResourcesPlugin.getWorkspace();
+				IWorkspaceRoot root = workspace.getRoot();
+				IProject iProject = root.getProject(projectName);
+				
+				IMarker[] markers = null;
+				try {
+					if (iProject != null) {
+						markers = iProject.findMarkers(markerType, true, IResource.DEPTH_INFINITE);
+						for (IMarker marker : markers) {
+							Object sourceId = marker.getAttribute(IMarker.SOURCE_ID);
+								if (item.getDotPath().equals(sourceId)) {
+									return true;				
+							}
 						}
 					}
-				}
-			} catch (CoreException e) {
-				//e.printStackTrace();
+				} catch (CoreException e) {
+					//e.printStackTrace();
+				}
 			}
 		}
Index: trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree/validation/ComponentModificationValidator.java
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree/validation/ComponentModificationValidator.java	(revision 926)
+++ trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree/validation/ComponentModificationValidator.java	(revision 933)
@@ -1,5 +1,4 @@
 package org.openmodelica.modelicaml.view.componentstree.validation;
 
-import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -13,13 +12,7 @@
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.EValidator;
-import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.papyrus.resource.uml.ExtendedUmlModel;
 import org.eclipse.papyrus.resource.uml.UmlUtils;
@@ -28,11 +21,8 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Dependency;
 import org.eclipse.uml2.uml.Element;
 import org.eclipse.uml2.uml.NamedElement;
 import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
 import org.openmodelica.modelicaml.common.constants.Constants;
-import org.openmodelica.modelicaml.common.contentassist.ModelicaMLContentAssist;
 import org.openmodelica.modelicaml.common.contentassist.ModelicaMLContentAssist2;
 import org.openmodelica.modelicaml.common.instantiation.ModificationManager;
@@ -60,7 +50,12 @@
 	private IProject iProject;
 	
-	private String textToEdit;
+//	private String textToEdit;
+	
+//	private Element classToBeValidated = null;
 
 	public ComponentModificationValidator(TreeParent parent){
+		
+//		this.classToBeValidated = parent.getSelectedClass();
+		
 		// collect client, mediator and provider tree nodes
 		collectItems(parent);
@@ -74,4 +69,6 @@
 	}
 	
+	private String stringLog = "";
+	
 	public void validate(){
 
@@ -83,8 +80,4 @@
 		}
 		// TODO: validate the array size and declarations, conditinal expressions, etc?! 
-		
-		// TODO check with OMC
-		
-
 	}
 	
@@ -211,4 +204,12 @@
 			//e.printStackTrace();
 		}
+	}
+
+	public void setStringLog(String stringLog) {
+		this.stringLog = stringLog;
+	}
+
+	public String getStringLog() {
+		return stringLog;
 	}
 	
Index: trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree/views/ComponentsTree.java
===================================================================
--- trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree/views/ComponentsTree.java	(revision 926)
+++ trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree/views/ComponentsTree.java	(revision 933)
@@ -77,4 +77,5 @@
 import org.eclipse.swt.dnd.Transfer;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Shell;
@@ -111,8 +112,10 @@
 import org.openmodelica.modelicaml.common.services.StringUtls;
 import org.openmodelica.modelicaml.common.utls.ResourceManager;
+import org.openmodelica.modelicaml.gen.modelica.cg.helpers.OMCClassValidator;
 import org.openmodelica.modelicaml.helper.handlers.InstantiateRequirementsHandler;
 import org.openmodelica.modelicaml.helper.handlers.InstantiateTestScenarioHandler;
 import org.openmodelica.modelicaml.helper.impl.TestVerdictElementsGenerator;
 import org.openmodelica.modelicaml.helper.impl.ValueBindingCreator;
+import org.openmodelica.modelicaml.simulation.handlers.CGFromEntireModelAndSimThisClassWithOMCSimCenterAction;
 import org.openmodelica.modelicaml.view.componentstree.Activator;
 import org.openmodelica.modelicaml.view.componentstree.dialogs.DialogComponentModification;
@@ -239,5 +242,11 @@
 	private Action actionInstantiateTestScenarios;
 
+	private Action actionValidateComponentModifications;
+
+	private Action actionShowRequiredValueClients;
+
 	private Action actionValidate;
+
+	private Action actionSimulate;
 	
 	public final static int DEFAULT_EXPAND_LEVEL = 2;
@@ -334,4 +343,5 @@
 		manager.add(actionShowOutputs);
 		manager.add(actionShowValueClients);
+		manager.add(actionShowRequiredValueClients);
 		manager.add(actionShowValueProviders);
 		manager.add(actionShowRequirements);
@@ -571,5 +581,8 @@
 	private void fillLocalToolBar(IToolBarManager manager) {
 		manager.add(actionReload);
+		manager.add(new Separator());
 		manager.add(actionValidate);
+		manager.add(actionSimulate);
+		manager.add(new Separator());
 		manager.add(actionCollapseAll);
 		manager.add(actionLinkWithEditor);
@@ -719,6 +732,7 @@
 			public void run() {
 				showSelection(par, sel);
+				
 				// validate the component modifications
-				actionValidate.run();
+				actionValidateComponentModifications.run();
 			}
 		};
@@ -726,11 +740,10 @@
 		actionReload.setToolTipText("(Re)load and validate");
 		actionReload.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/reload.png"));
-		
-		
-		actionValidate = new Action("actionValidate") { //obviously a check box style
+		actionReload.setEnabled(false);
+		
+		actionValidateComponentModifications = new Action("actionValidateComponentModifications") { //obviously a check box style
 			public void run() {
 				
 				if (root != null) {
-					final ComponentModificationValidator validator = new ComponentModificationValidator(root);
 					
 					// UIJob is needed because composites are used for xtext editors. 
@@ -738,23 +751,65 @@
 					UIJob UIjob = new UIJob("Component Modifications Validation") {
 						public IStatus runInUIThread(IProgressMonitor monitor) {
+							
+							ComponentModificationValidator validator = new ComponentModificationValidator(root);
 							validator.validate();
+							
 							viewer.refresh();
+							
 							return Status.OK_STATUS;
 						}
 					};
-					
 					UIjob.setUser(true);
 					UIjob.schedule();
 				}
 				else {
-					MessageDialog.openError(new Shell(), "Component Validation", "Instantiate a class to be validated.");
-				}
-			}
-		};
-		actionValidate.setText("Validate Component Modifications");
-		actionValidate.setToolTipText("Validate Component Modifications");
+					MessageDialog.openError(new Shell(), "Component Validation", "Please select a class in Papyrus Model Explorer.");
+				}
+			}
+		};
+		actionValidateComponentModifications.setText("Validate Component Modifications");
+		actionValidateComponentModifications.setToolTipText("Validate Component Modifications");
+		actionValidateComponentModifications.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/validate.gif"));
+		actionValidateComponentModifications.setEnabled(false);
+		
+		actionValidate = new Action("actionValidate") { //obviously a check box style
+			public void run() {
+				if (root != null) {
+					actionValidateComponentModifications.run();
+					// Check with OMC
+					if (root.getSelectedClass() != null) {
+						OMCClassValidator omcValidator = new OMCClassValidator(root.getSelectedClass());
+						omcValidator.validate();
+					}
+				}
+				else {
+					MessageDialog.openError(new Shell(), "Component Validation", "Please select a class in Papyrus Model Explorer.");
+				}
+			}
+		};
+		actionValidate.setText("Validate");
+		actionValidate.setToolTipText("Validate");
 		actionValidate.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/validate.gif"));
-
-
+		actionValidate.setEnabled(false);
+		
+		
+		actionSimulate = new Action("actionSimulate") {
+			public void run() {
+				viewer.setSelection(new StructuredSelection(root));
+				CGFromEntireModelAndSimThisClassWithOMCSimCenterAction c = new CGFromEntireModelAndSimThisClassWithOMCSimCenterAction();
+				try {
+					c.execute(null);
+				} catch (ExecutionException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+		};
+		actionSimulate.setText("Simulate with OMC");
+		actionSimulate.setToolTipText("Simulate with OMC");
+		actionSimulate.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/simulate.png"));
+		actionSimulate.setEnabled(false);
+		
+		
 		actionUpdateBindings = new Action("actionUpdateBindings") {
 			public void run() {
@@ -941,4 +996,24 @@
 //		actionShowValueClients.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
 
+		
+		actionShowRequiredValueClients = new Action("actionShowRequiredValueClients", 8) {
+			public void run() {
+				if (actionShowRequiredValueClients.isChecked()) {
+					ISelection selection = viewer.getSelection();
+					Object obj = ((IStructuredSelection)selection).getFirstElement();
+					
+					ViewerFilter[] filters = {requiredValueClientFilter};
+					viewer.setFilters(filters);
+					
+					// select in view
+					TreeUtls.selectInView(obj, root, viewer);					
+					viewer.expandToLevel(ComponentsTree.DEFAULT_EXPAND_LEVEL);
+				}
+			}
+		};
+		actionShowRequiredValueClients.setText("Show only required Value Clients");
+		actionShowRequiredValueClients.setToolTipText("Show only required Value Clients");
+		
+		
 		actionShowValueProviders = new Action("actionShowValueProviders", 8) {
 			public void run() {
@@ -1587,5 +1662,5 @@
 		actionCollapseAll.setToolTipText("Collapse all");
 		actionCollapseAll.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_COLLAPSEALL));
-
+		actionCollapseAll.setEnabled(false);
 		
 		actionShowAboutInfo = new Action("actionShowAboutInfo") { //obviously a check box style
@@ -1651,16 +1726,17 @@
 				TreeParent item = ((TreeParent)element); 
 
-				if (item.isRoot()) { // always show the root
-					return true;
-				}
-				if (item.getHasInputs() == null && !item.isLeaf()){ // not a leaf and indicator is NOT set
-					return false;
-				}
-				if (item.getHasInputs() != null && !item.getHasInputs() ) { // not a leaf but indicator is set
-					return false;
-				}
-				if ( item.isLeaf() && !item.isInput()) { // is leaf 
-					return false;
-				}
+//				if (item.isRoot()) { // always show the root
+//					return true;
+//				}
+//				if (item.getHasInputs() == null && !item.isLeaf()){ // not a leaf and indicator is NOT set
+//					return false;
+//				}
+//				if (item.getHasInputs() != null && !item.getHasInputs() ) { // not a leaf but indicator is set
+//					return false;
+//				}
+//				if ( item.isLeaf() && !item.isInput()) { // is leaf 
+//					return false;
+//				}
+				return hasInputs(item);
 			}
 			return true;
@@ -1669,4 +1745,37 @@
 	InputFilter inputFilter = new InputFilter();
 	
+	
+	private boolean hasInputs(TreeObject item){
+		if (item.isInput()) {
+			return true;
+		}
+		else if (item instanceof TreeParent) {
+			HashSet<TreeObject> list= findNextInput((TreeParent) item);
+			if (list != null && list.size() > 0) {
+				return true;
+			}
+		}
+		
+		return false;
+	}
+	
+	private HashSet<TreeObject> findNextInput(TreeParent item){
+		HashSet<TreeObject> list = new HashSet<TreeObject>();
+
+		TreeObject[] children = item.getChildren();
+		for (int i = 0; i < children.length; i++) {
+			TreeObject child = children[i];
+			if (child.isInput()) {
+				list.add(child);
+				return list;
+			}
+			else if (child instanceof TreeParent) {
+				list.addAll(findNextInput( (TreeParent)child ));	
+			}
+		}
+		 return list;
+	}
+	
+	// Outputs ******************************************************************
 
 	class OutputFilter extends ViewerFilter {
@@ -1677,16 +1786,17 @@
 				TreeParent item = ((TreeParent)element); 
 
-				if (item.isRoot()) { // always show the root
-					return true;
-				}
-				if (item.getHasOutputs() == null && !item.isLeaf()){ // not a leaf and indicator is NOT set
-					return false;
-				}
-				if (item.getHasOutputs() != null && !item.getHasOutputs() ) { // not a leaf but indicator is set
-					return false;
-				}
-				if ( item.isLeaf() && !item.isOutput()) { // is leaf 
-					return false;
-				}
+//				if (item.isRoot()) { // always show the root
+//					return true;
+//				}
+//				if (item.getHasOutputs() == null && !item.isLeaf()){ // not a leaf and indicator is NOT set
+//					return false;
+//				}
+//				if (item.getHasOutputs() != null && !item.getHasOutputs() ) { // not a leaf but indicator is set
+//					return false;
+//				}
+//				if ( item.isLeaf() && !item.isOutput()) { // is leaf 
+//					return false;
+//				}
+				return hasOutputs(item);
 			}
 			return true;
@@ -1695,5 +1805,37 @@
 	OutputFilter outputFilter = new OutputFilter();
 	
-	
+	private boolean hasOutputs(TreeObject item){
+		if (item.isOutput()) {
+			return true;
+		}
+		else if (item instanceof TreeParent) {
+			HashSet<TreeObject> list= findNextOutput((TreeParent) item);
+			if (list != null && list.size() > 0) {
+				return true;
+			}
+		}
+		
+		return false;
+	}
+	
+	private HashSet<TreeObject> findNextOutput(TreeParent item){
+		HashSet<TreeObject> list = new HashSet<TreeObject>();
+
+		TreeObject[] children = item.getChildren();
+		for (int i = 0; i < children.length; i++) {
+			TreeObject child = children[i];
+			if (child.isOutput()) {
+				list.add(child);
+				return list;
+			}
+			else if (child instanceof TreeParent) {
+				list.addAll(findNextOutput( (TreeParent)child ));	
+			}
+		}
+		 return list;
+	}
+	
+	
+	// Clients *****************************************************************
 	class ValueClientFilter extends ViewerFilter {
 		@Override
@@ -1702,14 +1844,16 @@
 				TreeParent item = ((TreeParent)element); 
 
-				if (item.isRoot()) { // always show the root
-					return true;
-				}
-//				System.err.println("item.hasValueClients(): " + item + " -> " + item.hasValueClients());
-				if (item.hasValueClients()) {
-					return true;
-				}
-				if (item.isValueClient()) { 
-					return true;
-				}
+//				if (item.isRoot()) { // always show the root
+//					return true;
+//				}
+////				System.err.println("item.hasValueClients(): " + item + " -> " + item.hasValueClients());
+//				if (item.hasValueClients()) {
+//					return true;
+//				}
+//				if (item.isValueClient()) { 
+//					return true;
+//				}
+				
+				return hasClients(item);
 			}
 			return false;
@@ -1717,4 +1861,83 @@
 	}
 	ValueClientFilter valueClientFilter = new ValueClientFilter();
+	
+	private boolean hasClients(TreeObject item){
+		if (item.isValueClient()) {
+			return true;
+		}
+		else if (item instanceof TreeParent) {
+			HashSet<TreeObject> list= findNextClient((TreeParent) item);
+			if (list != null && list.size() > 0) {
+				return true;
+			}
+		}
+		
+		return false;
+	}
+	
+	private HashSet<TreeObject> findNextClient(TreeParent item){
+		HashSet<TreeObject> list = new HashSet<TreeObject>();
+
+		TreeObject[] children = item.getChildren();
+		for (int i = 0; i < children.length; i++) {
+			TreeObject child = children[i];
+			if (child.isValueClient()) {
+				list.add(child);
+				return list;
+			}
+			else if (child instanceof TreeParent) {
+				list.addAll(findNextClient( (TreeParent)child ));	
+			}
+		}
+		 return list;
+	}
+	
+	
+	//Required Clients *****************************************************
+	
+	class RequiredValueClientFilter extends ViewerFilter {
+		@Override
+		public boolean select(Viewer viewer, Object parentElement, Object element) {
+			if (element instanceof TreeParent) {
+				TreeParent item = ((TreeParent)element); 
+				return hasRequiredClients(item);
+			}
+			return false;
+		}
+	}
+	RequiredValueClientFilter requiredValueClientFilter = new RequiredValueClientFilter();
+	
+	private boolean hasRequiredClients(TreeObject item){
+		if (item.isValueClient_required()) {
+			return true;
+		}
+		else if (item instanceof TreeParent) {
+			HashSet<TreeObject> list= findNextRequiredClient((TreeParent) item);
+			if (list != null && list.size() > 0) {
+				return true;
+			}
+		}
+		
+		return false;
+	}
+	
+	private HashSet<TreeObject> findNextRequiredClient(TreeParent item){
+		HashSet<TreeObject> list = new HashSet<TreeObject>();
+
+		TreeObject[] children = item.getChildren();
+		for (int i = 0; i < children.length; i++) {
+			TreeObject child = children[i];
+			if (child.isValueClient_required()) {
+				list.add(child);
+				return list;
+			}
+			else if (child instanceof TreeParent) {
+				list.addAll(findNextRequiredClient( (TreeParent)child ));	
+			}
+		}
+		 return list;
+	}
+	
+	// Providers *****************************************************
 	
 	class ValueProviderFilter extends ViewerFilter {
@@ -1724,13 +1947,15 @@
 				TreeParent item = ((TreeParent)element); 
 
-				if (item.isRoot()) { // always show the root
-					return true;
-				}
-				if (item.hasValueProviders()) {
-					return true;
-				}
-				if (item.isValueProvider()) { 
-					return true;
-				}
+				return hasProviders(item);
+
+//				if (item.isRoot()) { // always show the root
+//					return true;
+//				}
+//				if (item.hasValueProviders()) {
+//					return true;
+//				}
+//				if (item.isValueProvider()) { 
+//					return true;
+//				}
 			}
 			return false;
@@ -1740,4 +1965,37 @@
 	ValueProviderFilter valueProviderFilter = new ValueProviderFilter();
 	
+	private boolean hasProviders(TreeObject item){
+		if (item.isValueProvider()) {
+			return true;
+		}
+		else if (item instanceof TreeParent) {
+			HashSet<TreeObject> list= findNextProvider((TreeParent) item);
+			if (list != null && list.size() > 0) {
+				return true;
+			}
+		}
+		
+		return false;
+	}
+	
+	private HashSet<TreeObject> findNextProvider(TreeParent item){
+		HashSet<TreeObject> list = new HashSet<TreeObject>();
+
+		TreeObject[] children = item.getChildren();
+		for (int i = 0; i < children.length; i++) {
+			TreeObject child = children[i];
+			if (child.isValueProvider()) {
+				list.add(child);
+				return list;
+			}
+			else if (child instanceof TreeParent) {
+				list.addAll(findNextProvider( (TreeParent)child ));	
+			}
+		}
+		 return list;
+	}
+	
+	
+	// Requirements ***********************************************************************
 	
 	class RequirementInstanceFilter extends ViewerFilter {
@@ -1747,13 +2005,15 @@
 				TreeParent item = ((TreeParent)element); 
 
-				if (item.isRoot()) { // always show the root
-					return true;
-				}
-				if (item.hasRequirements()) { // Intermediate node with an indicator
-					return true;
-				}
-				if (item.isRequirementInstance()) { 
-					return true;
-				}
+//				if (item.isRoot()) { // always show the root
+//					return true;
+//				}
+//				if (item.hasRequirements()) { // Intermediate node with an indicator
+//					return true;
+//				}
+//				if (item.isRequirementInstance()) { 
+//					return true;
+//				}
+				
+				return hasRequirements(item);
 			}
 			return false;
@@ -1762,4 +2022,36 @@
 	RequirementInstanceFilter requirementInstanceFilter = new RequirementInstanceFilter();
 
+	private boolean hasRequirements(TreeObject item){
+		if (item.isRequirementInstance()) {
+			return true;
+		}
+		else if (item instanceof TreeParent) {
+			HashSet<TreeObject> list= findNextRequirement((TreeParent) item);
+			if (list != null && list.size() > 0) {
+				return true;
+			}
+		}
+		
+		return false;
+	}
+	
+	private HashSet<TreeObject> findNextRequirement(TreeParent item){
+		HashSet<TreeObject> list = new HashSet<TreeObject>();
+
+		TreeObject[] children = item.getChildren();
+		for (int i = 0; i < children.length; i++) {
+			TreeObject child = children[i];
+			if (child.isRequirementInstance()) {
+				list.add(child);
+				return list;
+			}
+			else if (child instanceof TreeParent) {
+				list.addAll(findNextRequirement( (TreeParent)child ));	
+			}
+		}
+		 return list;
+	}
+	
+	// State machines *****************************************************************
 	class HideStateMachnineElementFilter extends ViewerFilter {
 		@Override
@@ -2000,6 +2292,8 @@
 			// add the selection listener
 			getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(listener);
-
+			
 			if (sel != null) {
+				// disable action by default until the selection is a class.
+				
 				if (sel instanceof IStructuredSelection) {
 //					Object first = ((IStructuredSelection) sel).getFirstElement();
@@ -2059,5 +2353,21 @@
 					if (selectedElement instanceof Class ) {
 						selectedClass = (Class) selectedElement;
+						
+						if (selectedClass != null && !(selectedClass instanceof Behavior) && isValid(selectedClass)) {
+							actionSimulate.setEnabled(true);
+							actionValidate.setEnabled(true);
+							actionReload.setEnabled(true);
+							actionCollapseAll.setEnabled(true);
+							
+//							createTree(selectedClass); // build the entire tree
+						}
+						else {
+							actionSimulate.setEnabled(false);
+							actionValidate.setEnabled(false);
+							actionReload.setEnabled(false);
+							actionCollapseAll.setEnabled(false);
+						}
 					}
+
 					createTree(selectedClass); // build the entire tree
 				}
