From a7ba29d859a810d899e383e63426641d325ec33e Mon Sep 17 00:00:00 2001
From: Levi Lucio <lucio@fortiss.org>
Date: Mon, 9 Apr 2018 13:58:09 +0000
Subject: [PATCH] YELLOW

---
 .../fortiss/tooling/base/ui/editor/.ratings   |   2 +-
 .../editor/ConstraintBasedProcessEditor.java  | 766 ++++++++++++------
 .../ConstraintBasedProcessEditorHelper.java   | 223 +++++
 .../fortiss/tooling/base/ui/utils/.ratings    |   2 +-
 .../tooling/base/ui/utils/StatusUtils.java    |   3 +-
 5 files changed, 763 insertions(+), 233 deletions(-)
 create mode 100644 org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/ConstraintBasedProcessEditorHelper.java

diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/.ratings b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/.ratings
index 24d87b2a4..da3863ec4 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/.ratings
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/.ratings
@@ -1,7 +1,7 @@
 AdvancedTreeViewerEditorBase.java 3bb67c52886069379765289885df3b23790b88c9 GREEN
 AllocationDiagramEditorBase.java 3c03b9220f1c342ded673d6d1b2fd2c01b57fba6 GREEN
 CommonDiagramEditorBase.java 438babd95dd7a185bd32246cb8180b00bb53f18a GREEN
-ConstraintBasedProcessEditor.java ff7253ad26f25f681e09a36d0527b0214df08d30 RED
+ConstraintBasedProcessEditor.java 5d29c95bb69762814e1e0f3065a15f76155fac40 YELLOW
 DiagramEditorBase.java 3d2bb40e18548ebca0dfdd78f094598e5ee298d1 GREEN
 DiagramKeyHandler.java 8b64048b966e6e8cacfa7fb78edebef2a4981fc4 GREEN
 FormsEditorBase.java 50934d36124dea9b16ac45fe3621d878afb48bc7 GREEN
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/ConstraintBasedProcessEditor.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/ConstraintBasedProcessEditor.java
index af878de69..5be57079b 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/ConstraintBasedProcessEditor.java
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/ConstraintBasedProcessEditor.java
@@ -17,7 +17,6 @@ package org.fortiss.tooling.base.ui.editor;
 
 import static org.eclipse.core.runtime.IStatus.ERROR;
 import static org.eclipse.jface.dialogs.ErrorDialog.openError;
-import static org.eclipse.swt.widgets.Display.getCurrent;
 import static org.fortiss.tooling.base.utils.ConstraintsBaseUtils.DEFAULT_CONFIGURATION_NAME;
 import static org.fortiss.tooling.base.utils.ConstraintsBaseUtils.getActiveConfigurationsTransitively;
 import static org.fortiss.tooling.base.utils.ConstraintsBaseUtils.getActiveConstraintsTransitively;
@@ -33,42 +32,61 @@ import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.CheckStateChangedEvent;
 import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
 import org.eclipse.jface.viewers.EditingSupport;
 import org.eclipse.jface.viewers.ICheckStateListener;
 import org.eclipse.jface.viewers.ICheckStateProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StyledString;
 import org.eclipse.jface.viewers.TextCellEditor;
 import org.eclipse.jface.viewers.TreeViewerColumn;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.viewers.ViewerFilter;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.TreeColumn;
 import org.fortiss.tooling.base.model.element.ConstraintConfiguration;
 import org.fortiss.tooling.base.model.element.ElementFactory;
 import org.fortiss.tooling.base.model.element.IConstraintBasedProcess;
 import org.fortiss.tooling.base.ui.ToolingBaseUIActivator;
+import org.fortiss.tooling.base.ui.editor.ConstraintBasedProcessEditorHelper.ConfigurationRefWithContextualConfiguration;
+import org.fortiss.tooling.base.ui.editor.ConstraintBasedProcessEditorHelper.ConstraintWithContextualConfiguration;
+import org.fortiss.tooling.base.ui.editor.ConstraintBasedProcessEditorHelper.GreenFontStyler;
+import org.fortiss.tooling.base.ui.editor.ConstraintBasedProcessEditorHelper.NormalFontStyler;
+import org.fortiss.tooling.base.ui.editor.ConstraintBasedProcessEditorHelper.RedFontStyler;
+import org.fortiss.tooling.base.ui.editor.ConstraintBasedProcessEditorHelper.TreeStructureNode;
 import org.fortiss.tooling.base.ui.utils.ConstraintsBaseUIUtils;
-import org.fortiss.tooling.base.ui.utils.StatusUtils;
 import org.fortiss.tooling.kernel.extension.IConstraint;
 import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
+import org.fortiss.tooling.kernel.model.constraints.ConstraintInstance;
+import org.fortiss.tooling.kernel.model.constraints.FailedConstraintInstanceStatus;
 import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceContainer;
+import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
+import org.fortiss.tooling.kernel.model.constraints.SuccessConstraintInstanceStatus;
+import org.fortiss.tooling.kernel.model.constraints.impl.ConstraintInstanceImpl;
+import org.fortiss.tooling.kernel.model.constraints.impl.ConstraintNameToChecksumImpl;
 import org.fortiss.tooling.kernel.service.IConstraintService;
 import org.fortiss.tooling.kernel.service.IElementCompositorService;
 import org.fortiss.tooling.kernel.service.IPersistencyService;
@@ -82,9 +100,9 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
 /**
  * Editor for {@link IConstraintBasedProcess}s.
  * 
- * TODO(2931): should not be an editor but a widget
- * 
  * @author aravantinos
+ * @ConQAT.Rating RED Hash: E05108EBDA465E0637FAD82A817FE0D6
+ * @ConQAT.Rating RED Hash: E05108EBDA465E0637FAD82A817FE0D6
  */
 public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> extends
 		EditorBase<CBP> implements ContextMenuContextProvider, ISelectionProvider {
@@ -107,53 +125,12 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 	/** Selection of the tree. */
 	private ISelection selection;
 
+	/**  */
+	private List<TreeStructureNode> parentList;
+
 	/** Adapter for refreshing content. */
 	private EContentAdapter refreshAdapter;
 
-	/** Reference to a constraint configuration. */
-	private static class WithContextualConfiguration {
-
-		/** Contextual constraint configuration. */
-		ConstraintConfiguration config;
-
-		/** Constructor. */
-		public WithContextualConfiguration(ConstraintConfiguration config) {
-			this.config = config;
-		}
-	}
-
-	/** Constraint accompanied with a configuration providing the context. */
-	private static class ConstraintWithContextualConfiguration extends WithContextualConfiguration {
-
-		/** Constraint. */
-		Class<? extends IConstraint> cstr;
-
-		/** Constructor. */
-		public ConstraintWithContextualConfiguration(Class<? extends IConstraint> cstr,
-				ConstraintConfiguration config) {
-			super(config);
-			this.cstr = cstr;
-		}
-	}
-
-	/**
-	 * Configuration accompanied with another configuration providing the context.
-	 * Intent is that the contained configuration is a dependency of the context one.
-	 */
-	private static class ConfigurationRefWithContextualConfiguration extends
-			WithContextualConfiguration {
-
-		/** Constraint. */
-		ConstraintConfiguration target;
-
-		/** Constructor. */
-		public ConfigurationRefWithContextualConfiguration(ConstraintConfiguration configRef,
-				ConstraintConfiguration config) {
-			super(config);
-			this.target = configRef;
-		}
-	}
-
 	/** {@inheritDoc} */
 	@Override
 	public void createPartControl(Composite parent) {
@@ -174,6 +151,17 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 			}
 		};
 		editedObject.eAdapters().add(refreshAdapter);
+		treeViewer.addFilter(new ViewerFilter() {
+
+			@Override
+			public boolean select(Viewer viewer, Object parentElement, Object element) {
+				if(element instanceof TreeStructureNode &&
+						parentElement instanceof TreeStructureNode) {
+					return checkIfDuplicate(viewer, parentElement, element);
+				}
+				return true;
+			}
+		});
 	}
 
 	/** {@inheritDoc} */
@@ -199,9 +187,34 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 	/** Content provider for the configuration tree. */
 	private class ConfigTreeContentProvider extends TreeContentProviderBase {
 
+		/** {@inheritDoc} */
+		@Override
+		public Object getParent(Object inputElement) {
+			if(inputElement instanceof ConfigurationRefWithContextualConfiguration) {
+				ConfigurationRefWithContextualConfiguration input =
+						(ConfigurationRefWithContextualConfiguration)inputElement;
+				for(TreeStructureNode iterableElement : parentList) {
+					if(iterableElement.data instanceof ConfigurationRefWithContextualConfiguration) {
+						ConfigurationRefWithContextualConfiguration ref =
+								(ConfigurationRefWithContextualConfiguration)iterableElement.data;
+						if(ref.config.getName().equalsIgnoreCase(input.config.getName())) {
+							return iterableElement.parent;
+						}
+					}
+				}
+			} else if(inputElement instanceof TreeStructureNode) {
+				return ((TreeStructureNode)inputElement).parent;
+			}
+			return null;
+		}
+
 		/** {@inheritDoc} */
 		@Override
 		public Object[] getChildren(Object parentElement) {
+
+			if(parentList == null) {
+				parentList = new ArrayList<TreeStructureNode>();
+			}
 			if(parentElement instanceof IConstraintBasedProcess) {
 				IConstraintBasedProcess cbdp = (IConstraintBasedProcess)parentElement;
 				ArrayList<Object> configs = new ArrayList<>();
@@ -209,6 +222,7 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 				configs.addAll(cbdp.getConfigurations());
 				return configs.toArray();
 			} else if(parentElement instanceof ConstraintConfiguration) {
+
 				List<Object> types = new ArrayList<Object>();
 				Set<Class<? extends IConstraint>> availableCstrs =
 						IConstraintUIService.getInstance().getAllConstraints();
@@ -223,6 +237,10 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 									.map(t -> new ConfigurationRefWithContextualConfiguration(t,
 											(ConstraintConfiguration)parentElement))
 									.collect(Collectors.toList());
+					refs.removeIf(c -> c.config.getName().equalsIgnoreCase(c.target.getName()));
+					refs.forEach(c -> {
+						parentList.add(new TreeStructureNode(parentElement, c));
+					});
 					types.add(refs);
 				}
 
@@ -230,42 +248,62 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 						IConstraintUIService.getInstance().getAllConstraints();
 				IConstraintUIService cuis = IConstraintUIService.getInstance();
 
-				// Collecting the groups and putting the constraints in the groups in the array list
+				// Collecting the groups in the array list
 				List<String> groupName = new ArrayList<String>();
 				for(Class<? extends IConstraint> c : availableConstraints) {
 					String constGroupName = IConstraintService.getInstance().getGroupName(c);
 					if(!groupName.contains(constGroupName)) {
 						groupName.add(constGroupName);
-						types.add(constGroupName);
-						HashMap<String, String> constraintInfo = new HashMap<String, String>();
-						for(Class<? extends IConstraint> ctr : availableConstraints) {
-							String ctrGroupName =
-									IConstraintService.getInstance().getGroupName(ctr);
-							String desc = cuis.getDescription(ctr);
-							constraintMap.put(ctr.getName(), desc);
-							if(ctrGroupName.equalsIgnoreCase(constGroupName)) {
-								constraintInfo.put(ctr.getName(), cuis.getDescription(ctr));
-							}
+					}
+				}
+
+				// Collect the constraints for each of the groups.
+				for(String constraintGroupName : groupName) {
+					HashMap<String, String> constraintInfo = new HashMap<String, String>();
+					for(Class<? extends IConstraint> c : availableConstraints) {
+						String cGroupName = IConstraintService.getInstance().getGroupName(c);
+						String desc = cuis.getDescription(c);
+						constraintMap.put(c.getName(), desc);
+						if(cGroupName.equalsIgnoreCase(constraintGroupName)) {
+							constraintInfo.put(c.getName(), cuis.getDescription(c));
 						}
-						groupNameAndConstraints.put(constGroupName, constraintInfo);
 					}
+					groupNameAndConstraints.put(constraintGroupName, constraintInfo);
 				}
+				// Add the constraint groups to the tree.
+				for(String constraintGroupName : groupNameAndConstraints.keySet()) {
+					types.add(new TreeStructureNode(parentElement, constraintGroupName));
+					parentList.add(new TreeStructureNode(parentElement, constraintGroupName));
+				}
+
 				return types.toArray();
 			} else if(parentElement instanceof List<?>) {
 				return ((List<?>)parentElement).toArray();
 			}
+
 			// Add the constraints to the tree based on the group name.
-			else if(parentElement instanceof String) {
-				// Loop over all the names of the groups
-				for(String constraintGroupName : groupNameAndConstraints.keySet()) {
-					if(parentElement.toString().equalsIgnoreCase(constraintGroupName.toString())) {
-						// Return complete keySet of the HashMap inside the value field of the
-						// HashMap groupNameAndConstraints<String, "HashMap<String",String>> that
-						// contains the names of the constraints that are grouped under a particular
-						// constraint group
-						return groupNameAndConstraints.get(constraintGroupName).keySet().toArray();
+			else if(parentElement instanceof TreeStructureNode) {
+				HashMap<String, String> constraintInfo = new HashMap<String, String>();
+				List<TreeStructureNode> nodeList = new ArrayList<TreeStructureNode>();
+
+				Object stringNode = ((TreeStructureNode)parentElement).data;
+				if(groupNameAndConstraints.get(stringNode) != null) {
+					for(String constraintGroupName : groupNameAndConstraints.keySet()) {
+						if(stringNode.toString().equalsIgnoreCase(constraintGroupName.toString())) {
+
+							HashMap<String, String> groupedConstraint =
+									groupNameAndConstraints.get(constraintGroupName);
+							for(String key : groupedConstraint.keySet()) {
+								// if(isUniqueConstraint(key)) {
+								constraintInfo.put(key, groupedConstraint.get(key));
+								TreeStructureNode node = new TreeStructureNode(parentElement, key);
+								parentList.add(node);
+								nodeList.add(node);
+							}
+						}
 					}
 				}
+				return nodeList.toArray();
 			}
 			return new Object[0];
 		}
@@ -291,15 +329,17 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 			return ((ConfigurationRefWithContextualConfiguration)element).target.getName();
 		} else if(element instanceof List<?>) {
 			return "Required configurations";
-		} else if(element instanceof String) {
-			if(groupNameAndConstraints.containsKey(element)) {
+		} else if(element instanceof TreeStructureNode) {
+
+			Object stringNode = ((TreeStructureNode)element).data;
+			if(groupNameAndConstraints.containsKey(stringNode)) {
 				for(String constraintGroupName : groupNameAndConstraints.keySet()) {
-					if(element.toString().equalsIgnoreCase(constraintGroupName.toString())) {
-						return constraintGroupName;
+					if((stringNode.toString().equalsIgnoreCase(constraintGroupName.toString()))) {
+						return constraintGroupName + getInstanceCount(element);
 					}
 				}
-			} else if(constraintMap.containsKey(element)) {
-				return constraintMap.get(element);
+			} else if(constraintMap.containsKey(stringNode)) {
+				return constraintMap.get(stringNode);
 			}
 		}
 		return null;
@@ -311,28 +351,44 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 		/** {@inheritDoc} */
 		@Override
 		public boolean isGrayed(Object element) {
-			return !(element instanceof ConstraintWithContextualConfiguration ||
-					element instanceof ConfigurationRefWithContextualConfiguration || constraintMap
-						.containsKey(element));
+			return false;
 		}
 
 		/** {@inheritDoc} */
 		@Override
 		public boolean isChecked(Object element) {
+
 			if(element instanceof ConstraintWithContextualConfiguration) {
 				ConstraintWithContextualConfiguration cstrInContext =
 						(ConstraintWithContextualConfiguration)element;
 				IConstraintService cs = IConstraintService.getInstance();
 				String name = cs.getName(cstrInContext.cstr);
-				return cstrInContext.config.getActiveConstraints().contains(name);
+				// return cstrInContext.config.getActiveConstraints().contains(name);
+				HashMap<String, String> hashMap = groupNameAndConstraints.get(element.toString());
+				return hashMap.keySet().contains(name);
 			} else if(element instanceof ConfigurationRefWithContextualConfiguration) {
+
 				ConfigurationRefWithContextualConfiguration configRef =
 						(ConfigurationRefWithContextualConfiguration)element;
 				return configRef.config.getIncludedConfigurations().contains(configRef.target);
-			} else if(constraintMap.containsKey(element)) {
-				return editedObject.getCurrentObjective().getActiveConstraints().contains(element);
+			} else if(element instanceof TreeStructureNode) {
+				String stringNode = ((TreeStructureNode)element).data.toString();
+				if(constraintMap.containsKey(stringNode)) {
+					ITreeContentProvider provider =
+							(ITreeContentProvider)treeViewer.getContentProvider();
+					Object parent = provider.getParent(element);
+					Object parent2 = provider.getParent(parent);
+					ConstraintConfiguration config = ((ConstraintConfiguration)parent2);
+					EList<String> activeConstraints = config.getActiveConstraints();
+					for(String string : activeConstraints) {
+
+						if(string.equalsIgnoreCase(stringNode)) {
+							return true;
+						}
+					}
+				}
 			}
-			return true;
+			return false;
 		}
 	}
 
@@ -350,29 +406,27 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 				ConstraintWithContextualConfiguration cstrInContext =
 						(ConstraintWithContextualConfiguration)element;
 				String name = cs.getName(cstrInContext.cstr);
-				top.runAsCommand(new Runnable() {
-
-					@Override
-					public void run() {
-						if(event.getChecked()) {
-							cstrInContext.config.getActiveConstraints().add(name);
-							List<ConstraintConfiguration> activeConfigs =
-									getActiveConfigurationsTransitively(currentObj, null);
-							if(activeConfigs.contains(cstrInContext.config)) {
-								cuis.activate(cstrInContext.cstr, cstrContainer);
-							}
-						} else {
-							cstrInContext.config.getActiveConstraints().remove(name);
-							List<Class<? extends IConstraint>> stillActiveCstrs =
-									getActiveConstraintsTransitively(currentObj,
-											cstrInContext.config);
-							if(!stillActiveCstrs.contains(cstrInContext.cstr)) {
-								cuis.deactivate(cstrInContext.cstr, cstrContainer);
-							}
+
+				top.runAsCommand(() -> {
+					if(event.getChecked()) {
+
+						cstrInContext.config.getActiveConstraints().add(name);
+						List<ConstraintConfiguration> activeConfigs =
+								getActiveConfigurationsTransitively(currentObj, null);
+						if(activeConfigs.contains(cstrInContext.config)) {
+							cuis.activate(cstrInContext.cstr, cstrContainer);
+						}
+					} else {
+						cstrInContext.config.getActiveConstraints().remove(name);
+						List<Class<? extends IConstraint>> stillActiveCstrs =
+								getActiveConstraintsTransitively(currentObj, cstrInContext.config);
+						if(!stillActiveCstrs.contains(cstrInContext.cstr)) {
+							cuis.deactivate(cstrInContext.cstr, cstrContainer);
 						}
 					}
 				});
 			} else if(element instanceof ConfigurationRefWithContextualConfiguration) {
+
 				ConfigurationRefWithContextualConfiguration configRef =
 						(ConfigurationRefWithContextualConfiguration)element;
 				top.runAsCommand(() -> {
@@ -380,6 +434,8 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 						configRef.config.getIncludedConfigurations().add(configRef.target);
 						ConstraintsBaseUIUtils.activateConfiguration(configRef.target,
 								cstrContainer);
+
+						// }
 					} else {
 						configRef.config.getIncludedConfigurations().remove(configRef.target);
 						ConstraintsBaseUIUtils.deactivateConfiguration(configRef.target,
@@ -388,64 +444,50 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 				});
 			}
 			// Check if the constraint belongs to the constraints HashMap
-			else if(constraintMap.containsKey(element)) {
-
-				top.runAsCommand(new Runnable() {
-					@Override
-					public void run() {
-						// Get the constraintName as a full class path (e.g.,
-						// a.b.c.constraintName.Java)
-						String constraintName = element.toString();
-						if(event.getChecked()) {
-							// If the constraint is checked than add it to the active
-							// constraints list
-							editedObject.getCurrentObjective().getActiveConstraints()
-									.add(constraintName);
-							// Collect all the active constraints in the list of constraints
-							List<ConstraintConfiguration> activeConfigs =
-									getActiveConfigurationsTransitively(currentObj, null);
-							// If the selected constraint is in the active constraints list
-							EList<String> activeConstraints =
-									activeConfigs.get(0).getActiveConstraints();
-							if(activeConstraints.contains(cs.getConstraintByName(constraintName)
-									.getCanonicalName())) {
-								// Activate the constraint
-								cuis.activate(cs.getConstraintByName(constraintName), cstrContainer);
-							}
-						} else {
-							// If the constraint is unchecked from the tree remove the
-							// constraint from
-							// the active constraints list
-							editedObject.getCurrentObjective().getActiveConstraints()
-									.remove(constraintName);
-							List<ConstraintConfiguration> stillActiveConfigs =
-									getActiveConfigurationsTransitively(currentObj, null);
-							// If the constraint is still not active
-							EList<String> stillActiveConstraints =
-									stillActiveConfigs.get(0).getActiveConstraints();
-							if(!stillActiveConstraints.contains(cs.getConstraintByName(
-									constraintName).getCanonicalName())) {
-								Class<? extends IConstraint> constrainttoDeActivate =
-										cs.getConstraintByName(constraintName);
-								// Deactivate the constraint
-								cuis.deactivate(constrainttoDeActivate, cstrContainer);
+			else if(element instanceof TreeStructureNode) {
+
+				ITreeContentProvider provider =
+						(ITreeContentProvider)treeViewer.getContentProvider();
+				Object parent = provider.getParent(element);
+				Object parent2 = provider.getParent(parent);
+				ConstraintConfiguration config = ((ConstraintConfiguration)parent2);
+				String constraintName = ((TreeStructureNode)element).data.toString();
+				if(constraintMap.containsKey(constraintName)) {
+					top.runAsNonDirtyingCommand(new Runnable() {
+						@Override
+						public void run() {
+
+							// Get the constraintName as a full class path (e.g.,
+							// a.b.c.constraintName.Java)
+							if(event.getChecked()) {
+
+								config.getActiveConstraints().add(constraintName);
+
+								List<ConstraintConfiguration> activeConfigs =
+										getActiveConfigurationsTransitively(config, null);
+								// If the selected constraint is in the active constraints list
+								EList<String> activeConstraints =
+										activeConfigs.get(0).getActiveConstraints();
+								if(activeConstraints.contains(cs
+										.getConstraintByName(constraintName).getCanonicalName())) {
+									// Activate the constraint
+									cuis.activate(cs.getConstraintByName(constraintName),
+											cstrContainer);
+								}
+							} else {
+								clearConstraintInstance(cs, cuis, config, constraintName);
 							}
 						}
-					}
-				});
+					});
+				}
 			}
+			treeViewer.refresh();
 		}
 	}
 
 	/** Tree for configurations. */
 	private class ConfigTree extends CheckboxTreeViewer implements ISelectionChangedListener {
 
-		/** {@inheritDoc} */
-		@Override
-		public void addSelectionChangedListener(ISelectionChangedListener listener) {
-			super.addSelectionChangedListener(listener);
-		}
-
 		/** Constructor. */
 		public ConfigTree(Composite parent) {
 			super(parent);
@@ -453,7 +495,6 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 			setContentProvider(new ConfigTreeContentProvider());
 			setCheckStateProvider(new ConfigTreeCheckStateProvider());
 			addCheckStateListener(new ConfigTreeCheckStateListener());
-			addSelectionChangedListener(this);
 		}
 
 		/** {@inheritDoc} */
@@ -471,32 +512,7 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 		column.setText("Constraint configurations");
 		column.setWidth(1300);
 		TreeViewerColumn onlyViewerColumn = new TreeViewerColumn(treeViewer, column);
-		onlyViewerColumn.setLabelProvider(new ColumnLabelProvider() {
-
-			/** {@inheritDoc} */
-			@Override
-			public String getText(Object element) {
-				return getLabelText(element);
-			}
-
-			@Override
-			public Color getForeground(Object element) {
-				return getConstraintForeGround(element, colorCtr);
-			}
-
-			@Override
-			public Color getBackground(Object element) {
-				// Collect all the active constraints from the currentObject (i.e., the current
-				// active configuration)
-				List<String> activeConstraints =
-						editedObject.getCurrentObjective().getActiveConstraints();
-				if(constraintMap.containsKey(element)) {
-					// Ask for the constraint color based on status
-					return getConstraintBackgroundColor(element, activeConstraints);
-				}
-				return null;
-			}
-		});
+		onlyViewerColumn.setLabelProvider(new BoldColumnLabelProvider());
 
 		onlyViewerColumn.setEditingSupport(new EditingSupport(treeViewer) {
 			@Override
@@ -539,70 +555,47 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 						constraintMap.containsKey(element);
 			}
 		});
+		treeViewer.setUseHashlookup(true);
 		treeViewer.setComparator(new ConstraintComparator());
 		treeViewer.setInput(editedObject);
 	}
 
 	/**
 	 * @param element
-	 *            is the selected constraint
-	 * @param activeConstraints
-	 *            active constraints in the current objective
-	 * @return return the color (i.e., red (Failed), green (Successful) or white(not active))
+	 *            the element to set color
+	 * @return color instance that will be applied on the element
 	 */
-	public Color getConstraintBackgroundColor(Object element, List<String> activeConstraints) {
+	public Color getConstraintBackgroundColor(Object element) {
 		// Get the complete path of the constraint class (e.g., a.b.c.constraint.java)
-		String constraintToFind = element.toString();
+		String constraintToFind = ((TreeStructureNode)element).data.toString();
 		// If the constraint is in the active constraint list and the status is true
 		// than make the background color green
-		if(activeConstraints.contains(constraintToFind) &&
-				StatusUtils.areAllInstancesSuccessful(constraintToFind, editedObject
-						.getConstraintInstanceContainer(), editedObject.getCurrentObjective()
-						.getActiveConstraints()) == true) {
-			return getCurrent().getSystemColor(SWT.COLOR_GREEN);
-		}
-		// If the constraint doesn't belong to the active list of constrains than let
-		// the color remain white
-		else if(activeConstraints.contains(constraintToFind) == false) {
-			return getCurrent().getSystemColor(SWT.COLOR_WHITE);
-		}
-		// If the constraint is active and the status is false than make the background
-		// color red
-		if(activeConstraints.contains(constraintToFind) &&
-				StatusUtils.areAllInstancesSuccessful(constraintToFind, editedObject
-						.getConstraintInstanceContainer(), editedObject.getCurrentObjective()
-						.getActiveConstraints()) == false) {
-			return getCurrent().getSystemColor(SWT.COLOR_RED);
-		}
-		return null;
-	}
-
-	/** Color Array for at least seven groups. */
-	int[] colorArray = {SWT.COLOR_DARK_GREEN, SWT.COLOR_DARK_BLUE, SWT.COLOR_DARK_YELLOW,
-			SWT.COLOR_BLACK, SWT.COLOR_DARK_RED, SWT.COLOR_GREEN, SWT.COLOR_CYAN};
-
-	/** Counter for the colorArray */
-	int colorCtr = 0;
 
-	/**
-	 * @param element
-	 *            the groupName for which we need to set the background.
-	 * @param colorIndex
-	 *            index used for the colors in the colorArray.
-	 * @return color required for a particular group.
-	 */
-	public Color getConstraintForeGround(Object element, int colorIndex) {
-		if(groupNameAndConstraints.keySet().contains(element)) {
-			if(colorIndex != colorCtr + 1) {
-				if(groupNameAndConstraints.keySet().size() == colorCtr + 1) {
-					colorCtr = 0;
-				} else {
-					colorCtr++;
+		EList<ConstraintInstance> constraintInstances =
+				editedObject.getConstraintInstanceContainer().getConstraintInstances();
+		ITreeContentProvider provider = (ITreeContentProvider)treeViewer.getContentProvider();
+		Object parent = provider.getParent(element);
+		Object parent2 = provider.getParent(parent);
+		ConstraintConfiguration config = ((ConstraintConfiguration)parent2);
+
+		if(config.getName().equalsIgnoreCase(editedObject.getCurrentObjective().getName())) {
+			for(ConstraintInstance instance : constraintInstances) {
+				for(String constraintName : editedObject.getCurrentObjective()
+						.getActiveConstraints()) {
+					if(instance.getConstraintName().equalsIgnoreCase(constraintName) &&
+							constraintToFind.equalsIgnoreCase(constraintName)) {
+						IConstraintInstanceStatus status =
+								IConstraintUIService.getInstance().getStatus(instance);
+						if(status instanceof SuccessConstraintInstanceStatus) {
+							return Display.getCurrent().getSystemColor(SWT.COLOR_GREEN);
+						} else if(status instanceof FailedConstraintInstanceStatus) {
+							return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
+						}
+					}
 				}
-				return getCurrent().getSystemColor(colorArray[colorIndex]);
 			}
 		}
-		return null;
+		return Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
 	}
 
 	/**
@@ -617,7 +610,7 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 			Status status =
 					new Status(ERROR, ToolingBaseUIActivator.PLUGIN_ID, 0,
 							"A configuration with this name already exists.", null);
-			openError(getCurrent().getActiveShell(), "Error", null, status);
+			openError(Display.getCurrent().getActiveShell(), "Error", null, status);
 			return true;
 		}
 		return false;
@@ -650,6 +643,10 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 				String n1 = ((ConfigurationRefWithContextualConfiguration)e1).target.getName();
 				String n2 = ((ConfigurationRefWithContextualConfiguration)e2).target.getName();
 				return n1.compareToIgnoreCase(n2);
+			} else if(e1 instanceof TreeStructureNode && e2 instanceof TreeStructureNode) {
+				String n1 = ((TreeStructureNode)e1).parent.toString();
+				String n2 = ((TreeStructureNode)e2).parent.toString();
+				return n1.compareToIgnoreCase(n2);
 			}
 			return super.compare(viewer, e1, e2);
 		}
@@ -697,4 +694,315 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
 	public void setSelection(ISelection selection) {
 		// Not supported
 	}
+
+	/**
+	 * @param cs
+	 *            constraintService
+	 * @param cuis
+	 *            constraintUIService
+	 * @param config
+	 *            the configuration in which the constraint remains
+	 * @param constraintName
+	 *            the name of the constraint
+	 */
+	private void clearConstraintInstance(IConstraintService cs, IConstraintUIService cuis,
+			ConstraintConfiguration config, String constraintName) {
+		// If the constraint is unchecked from the tree remove the
+		// constraint from
+		// the active constraints list and constraint instance list
+
+		config.getActiveConstraints().remove(constraintName);
+		// If the constraint is still not active
+		EList<String> stillActiveConstraints = config.getActiveConstraints();
+		if(!stillActiveConstraints.contains(cs.getConstraintByName(constraintName)
+				.getCanonicalName())) {
+			Class<? extends IConstraint> constrainttoDeActivate =
+					cs.getConstraintByName(constraintName);
+			// Deactivate the constraint
+			cuis.deactivate(constrainttoDeActivate, cstrContainer);
+
+			ITopLevelElement modelContext =
+					IPersistencyService.getInstance().getTopLevelElementFor(editedObject);
+			modelContext.runAsNonDirtyingCommand(() -> {
+
+				TreeIterator<EObject> allContents =
+						editedObject.getCurrentObjective().eResource().getAllContents();
+				EList<EObject> eContents = editedObject.getCurrentObjective().eContents();
+				List<EObject> duplicateList = new ArrayList<EObject>();
+				duplicateList.addAll(eContents);
+				List<Object> toReomve = new ArrayList<Object>();
+
+				while(allContents.hasNext()) {
+					EObject next = allContents.next();
+
+					if(next instanceof ConstraintNameToChecksumImpl &&
+							next.toString().contains(constraintName)) {
+						toReomve.add(next);
+					}
+					if(next instanceof ConstraintInstanceImpl &&
+							next.toString().contains(constraintName)) {
+						toReomve.add(next);
+					}
+				}
+				toReomve.forEach(c -> {
+					duplicateList.remove(c);
+					EcoreUtil.delete((EObject)c);
+				});
+			});
+		}
+	}
+
+	/**
+	 * @param viewer
+	 *            the tree viewer
+	 * @param parentElement
+	 *            the parent element of the given element
+	 * @param element
+	 *            the element to consider
+	 * @return the decision on whether the constraint was checked in previous dependent configs or
+	 *         not
+	 */
+	private boolean checkIfDuplicate(Viewer viewer, Object parentElement, Object element) {
+		ITreeContentProvider provider = (ITreeContentProvider)treeViewer.getContentProvider();
+
+		ConstraintConfiguration config =
+				((ConstraintConfiguration)provider.getParent(parentElement));
+		// for(TreeStructureNode node : parentList) {
+		List<Class<? extends IConstraint>> activeConstraintsTransitively =
+				getActiveConstraintsTransitively(config, null);
+		List<String> constraintList =
+				activeConstraintsTransitively.stream().map((item) -> item.getName())
+						.collect(Collectors.toList());
+
+		for(String string : constraintList) {
+			if(!config.getActiveConstraints().contains(string) &&
+					((TreeStructureNode)element).data.toString().equalsIgnoreCase(string)) {
+				return false;
+			}
+		}
+
+		return true;
+	}
+
+	/**
+	 * @param element
+	 * @return the concatenated string containing the score for the configuration
+	 */
+	private String getInstanceCount(Object element) {
+		String constraintGroupName = ((TreeStructureNode)element).data.toString();
+		// If the constraint is in the active constraint list and the status is true
+		// than make the background color green
+
+		int successCount = 0;
+		int failCount = 0;
+		HashMap<String, String> hashMap = groupNameAndConstraints.get(constraintGroupName);
+		EList<ConstraintInstance> constraintInstances =
+				editedObject.getConstraintInstanceContainer().getConstraintInstances();
+		ITreeContentProvider provider = (ITreeContentProvider)treeViewer.getContentProvider();
+		Object parent = provider.getParent(element);
+		ConstraintConfiguration config = ((ConstraintConfiguration)parent);
+
+		EList<String> activeConstraints = config.getActiveConstraints();
+		List<Class<? extends IConstraint>> stillActiveCstrs =
+				getActiveConstraintsTransitively(config, null);
+
+		int duplicateSize =
+				stillActiveCstrs.stream().filter(c -> !(activeConstraints.contains(c.getName())))
+						.collect(Collectors.toList()).size();
+		if(config.getName().equalsIgnoreCase(editedObject.getCurrentObjective().getName())) {
+			for(ConstraintInstance instance : constraintInstances) {
+				for(String constraintName : editedObject.getCurrentObjective()
+						.getActiveConstraints()) {
+					if(instance.getConstraintName().equalsIgnoreCase(constraintName) &&
+							(hashMap.containsKey(constraintName))) {
+						IConstraintInstanceStatus status =
+								IConstraintUIService.getInstance().getStatus(instance);
+						if(status instanceof SuccessConstraintInstanceStatus) {
+							successCount++;
+						}
+					}
+				}
+			}
+			return "[ " + Integer.toString(successCount) + " / " + Integer.toString(failCount) +
+					"/" + Integer.toString(hashMap.size() - duplicateSize) + " ]";
+		}
+		return "";
+	}
+
+	/** Text labels for the tree of configurations. */
+	private StyledString getStylizedLabel(Object element) {
+		if(element instanceof FakeChild) {
+			return new StyledString("click to add a new configuration");
+		} else if(element instanceof ConstraintConfiguration) {
+			return new StyledString(((ConstraintConfiguration)element).getName());
+		} else if(element instanceof ConstraintBasedProcessEditorHelper.ConstraintWithContextualConfiguration) {
+			IConstraintUIService cuis = IConstraintUIService.getInstance();
+			return new StyledString(
+					cuis.getDescription(((ConstraintBasedProcessEditorHelper.ConstraintWithContextualConfiguration)element).cstr));
+		} else if(element instanceof ConfigurationRefWithContextualConfiguration) {
+			return new StyledString(
+					((ConfigurationRefWithContextualConfiguration)element).target.getName());
+		} else if(element instanceof List<?>) {
+			return new StyledString("Required configurations");
+		} else if(element instanceof TreeStructureNode) {
+
+			Object stringNode = ((TreeStructureNode)element).data;
+			if(groupNameAndConstraints.containsKey(stringNode)) {
+				for(String constraintGroupName : groupNameAndConstraints.keySet()) {
+					if((stringNode.toString().equalsIgnoreCase(constraintGroupName.toString()))) {
+
+						ArrayList<Integer> instanceCountList = getInstanceCount2(element);
+						int constarintNameLength = constraintGroupName.length();
+						if(instanceCountList == null) {
+							StyledString finalString = new StyledString(constraintGroupName);
+							ConstraintBasedProcessEditorHelper
+									.adjustColorIndex(groupNameAndConstraints.keySet().size());
+							finalString.setStyle(0, finalString.length(), new NormalFontStyler());
+							return finalString;
+						}
+						// the elements are stored in the list sequentially- success count, fail
+						// count and total of instances
+						int successLength = Integer.toString(instanceCountList.get(0)).length();
+						int failCountLength = Integer.toString(instanceCountList.get(1)).length();
+						// creating the string with all the counts
+						StyledString finalString =
+								new StyledString(constraintGroupName + "[" +
+										Integer.toString(instanceCountList.get(0)) + "/" +
+										Integer.toString(instanceCountList.get(1)) + "/" +
+										Integer.toString(instanceCountList.get(2)) + "]");
+						ConstraintBasedProcessEditorHelper.adjustColorIndex(groupNameAndConstraints
+								.keySet().size());
+
+						finalString.setStyle(0, finalString.length(), new NormalFontStyler());
+						finalString.setStyle(constarintNameLength + 1, successLength,
+								new GreenFontStyler());
+						finalString.setStyle(constarintNameLength + 2 + successLength,
+								failCountLength, new RedFontStyler());
+						return finalString;
+					}
+				}
+			} else if(constraintMap.containsKey(stringNode)) {
+				return new StyledString(constraintMap.get(stringNode));
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * the class to create stylized string for labels of the tree
+	 * 
+	 * @author ss
+	 */
+	private class BoldColumnLabelProvider extends DelegatingStyledCellLabelProvider {
+
+		// Styler styler = new BoldFontStyler();
+
+		/** {@inheritDoc} */
+		@Override
+		public Color getForeground(Object element) {
+			return null;
+		}
+
+		/** {@inheritDoc} */
+		@Override
+		public Color getBackground(Object element) {
+			if(element instanceof TreeStructureNode) {
+				if(constraintMap.containsKey(((TreeStructureNode)element).data.toString())) {
+					// Ask for the constraint color based on status
+					return getConstraintBackgroundColor(element);
+				}
+			}
+			return null;
+		}
+
+		/**
+		 * the class for generating stylized text
+		 * 
+		 */
+		public BoldColumnLabelProvider() {
+			super(new IStyledLabelProvider() {
+				@Override
+				public Image getImage(Object element) {
+					return null;
+				}
+
+				@Override
+				public StyledString getStyledText(Object element) {
+					return getStylizedLabel(element);
+				}
+
+				@Override
+				public void addListener(ILabelProviderListener listener) {
+					return;
+				}
+
+				@Override
+				public void dispose() {
+					return;
+				}
+
+				@Override
+				public boolean isLabelProperty(Object element, String property) {
+					return false;
+				}
+
+				@Override
+				public void removeListener(ILabelProviderListener listener) {
+					return;
+				}
+			});
+		}
+	}
+
+	/**
+	 * @param element
+	 *            the group name element
+	 * @return array list of integer containing success count, fail count, and total count
+	 */
+	private ArrayList<Integer> getInstanceCount2(Object element) {
+		String constraintGroupName = ((TreeStructureNode)element).data.toString();
+		// If the constraint is in the active constraint list and the status is true
+		// than make the background color green
+
+		int successCount = 0;
+		int failCount = 0;
+		HashMap<String, String> hashMap = groupNameAndConstraints.get(constraintGroupName);
+		EList<ConstraintInstance> constraintInstances =
+				editedObject.getConstraintInstanceContainer().getConstraintInstances();
+		ITreeContentProvider provider = (ITreeContentProvider)treeViewer.getContentProvider();
+		Object parent = provider.getParent(element);
+		ConstraintConfiguration config = ((ConstraintConfiguration)parent);
+
+		EList<String> activeConstraints = config.getActiveConstraints();
+		List<Class<? extends IConstraint>> stillActiveCstrs =
+				getActiveConstraintsTransitively(config, null);
+
+		int duplicateSize =
+				stillActiveCstrs.stream().filter(c -> !(activeConstraints.contains(c.getName())))
+						.collect(Collectors.toList()).size();
+		if(config.getName().equalsIgnoreCase(editedObject.getCurrentObjective().getName())) {
+			for(ConstraintInstance instance : constraintInstances) {
+				for(String constraintName : editedObject.getCurrentObjective()
+						.getActiveConstraints()) {
+					if(instance.getConstraintName().equalsIgnoreCase(constraintName) &&
+							(hashMap.containsKey(constraintName))) {
+						IConstraintInstanceStatus status =
+								IConstraintUIService.getInstance().getStatus(instance);
+						if(status instanceof SuccessConstraintInstanceStatus) {
+							successCount++;
+						}
+						if(status instanceof FailedConstraintInstanceStatus) {
+							failCount++;
+						}
+					}
+				}
+			}
+			ArrayList<Integer> countList = new ArrayList<Integer>();
+			countList.add(new Integer(successCount));
+			countList.add(new Integer(failCount));
+			countList.add(new Integer(hashMap.size() - duplicateSize));
+			return countList;
+		}
+		return null;
+	}
 }
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/ConstraintBasedProcessEditorHelper.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/ConstraintBasedProcessEditorHelper.java
new file mode 100644
index 000000000..9f4be1b4c
--- /dev/null
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/ConstraintBasedProcessEditorHelper.java
@@ -0,0 +1,223 @@
+/*-------------------------------------------------------------------------+
+| Copyright 2017 fortiss GmbH                                              |
+|                                                                          |
+| Licensed under the Apache License, Version 2.0 (the "License");          |
+| you may not use this file except in compliance with the License.         |
+| You may obtain a copy of the License at                                  |
+|                                                                          |
+|    http://www.apache.org/licenses/LICENSE-2.0                            |
+|                                                                          |
+| Unless required by applicable law or agreed to in writing, software      |
+| distributed under the License is distributed on an "AS IS" BASIS,        |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and      |
+| limitations under the License.                                           |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.base.ui.editor;
+
+import org.eclipse.jface.resource.FontDescriptor;
+import org.eclipse.jface.viewers.StyledString.Styler;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.TextStyle;
+import org.eclipse.swt.widgets.Display;
+import org.fortiss.tooling.base.model.element.ConstraintConfiguration;
+import org.fortiss.tooling.kernel.extension.IConstraint;
+
+/**
+ * 
+ * @author ss
+ */
+public class ConstraintBasedProcessEditorHelper {
+
+	/** Color Array for at least seven groups. */
+	static int[] colorArray = {SWT.COLOR_DARK_GREEN, SWT.COLOR_DARK_BLUE, SWT.COLOR_DARK_YELLOW,
+			SWT.COLOR_BLACK, SWT.COLOR_DARK_RED, SWT.COLOR_GREEN, SWT.COLOR_CYAN};
+
+	/** Counter for the colorArray */
+	public static int colorCtr = 0;
+
+	/** Reference to a constraint configuration. */
+	public static class WithContextualConfiguration {
+
+		/** Contextual constraint configuration. */
+		ConstraintConfiguration config;
+
+		/** Constructor. */
+		public WithContextualConfiguration(ConstraintConfiguration config) {
+			this.config = config;
+		}
+	}
+
+	/** Constraint accompanied with a configuration providing the context. */
+	public static class ConstraintWithContextualConfiguration extends WithContextualConfiguration {
+
+		/** Constraint. */
+		Class<? extends IConstraint> cstr;
+
+		/** Constructor. */
+		public ConstraintWithContextualConfiguration(Class<? extends IConstraint> cstr,
+				ConstraintConfiguration config) {
+			super(config);
+			this.cstr = cstr;
+		}
+	}
+
+	/**
+	 * Configuration accompanied with another configuration providing the context.
+	 * Intent is that the contained configuration is a dependency of the context one.
+	 */
+	public static class ConfigurationRefWithContextualConfiguration extends
+			WithContextualConfiguration {
+
+		/** Constraint. */
+		ConstraintConfiguration target;
+
+		/** Constructor. */
+		public ConfigurationRefWithContextualConfiguration(ConstraintConfiguration configRef,
+				ConstraintConfiguration config) {
+			super(config);
+			this.target = configRef;
+		}
+
+		/** {@inheritDoc} */
+		@Override
+		public boolean equals(Object obj) {
+			if(obj instanceof ConfigurationRefWithContextualConfiguration) {
+				return this.target.getName().equalsIgnoreCase(
+						((ConfigurationRefWithContextualConfiguration)obj).target.getName()) &&
+						this.config.getName()
+								.equalsIgnoreCase(
+										((ConfigurationRefWithContextualConfiguration)obj).config
+												.getName());
+			}
+			return false;
+		}
+
+		/** {@inheritDoc} */
+		@Override
+		public int hashCode() {
+			return target.hashCode();
+		}
+	}
+
+	/**
+	 * the class to manipulate and store parent of elements
+	 * 
+	 * @author salman
+	 */
+	public static class TreeStructureNode {
+
+		/** parent object variable */
+		Object parent;
+
+		/** data object variable */
+		Object data;
+
+		/**
+		 * @param parent
+		 *            the parent element
+		 * @param children
+		 */
+		public TreeStructureNode(Object parent, Object children) {
+			this.parent = parent;
+			this.data = children;
+		}
+
+		/** {@inheritDoc} */
+		@Override
+		public boolean equals(Object obj) {
+			if(obj instanceof TreeStructureNode) {
+				return this.data.toString().equalsIgnoreCase(
+						((TreeStructureNode)obj).data.toString()) &&
+						this.parent.toString().equalsIgnoreCase(
+								((TreeStructureNode)obj).parent.toString());
+			}
+			return false;
+		}
+
+		/** {@inheritDoc} */
+		@Override
+		public int hashCode() {
+			return parent.hashCode();
+		}
+	}
+
+	/**
+	 * styler class to create colored bold labels for constraint group name
+	 * 
+	 * @author ss
+	 */
+	public static class NormalFontStyler extends Styler {
+
+		/** counter to keep track of currently used color in color array */
+		int colorIndex = 0;
+
+		/**
+		 * constructor
+		 * index the index for color ickup in color array
+		 */
+		public NormalFontStyler() {
+			this.colorIndex = colorCtr;
+		}
+
+		/** {@inheritDoc} */
+		@Override
+		public void applyStyles(final TextStyle textStyle) {
+
+			FontDescriptor boldDescriptor =
+					FontDescriptor.createFrom(new FontData()).setStyle(SWT.BOLD);
+			Font boldFont = boldDescriptor.createFont(Display.getCurrent());
+			textStyle.font = boldFont;
+			textStyle.foreground = Display.getCurrent().getSystemColor(colorArray[colorIndex]);
+		}
+	}
+
+	/**
+	 * 
+	 * @author ss
+	 */
+	public static class RedFontStyler extends Styler {
+		/** {@inheritDoc} */
+		@Override
+		public void applyStyles(final TextStyle textStyle) {
+			FontDescriptor boldDescriptor =
+					FontDescriptor.createFrom(new FontData()).setStyle(SWT.BOLD);
+			Font boldFont = boldDescriptor.createFont(Display.getCurrent());
+			textStyle.font = boldFont;
+			textStyle.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED);
+		}
+	}
+
+	/**
+	 * styler class to create green color labels
+	 * 
+	 * @author ss
+	 */
+	public static class GreenFontStyler extends Styler {
+		/** {@inheritDoc} */
+		@Override
+		public void applyStyles(final TextStyle textStyle) {
+			FontDescriptor boldDescriptor =
+					FontDescriptor.createFrom(new FontData()).setStyle(SWT.BOLD);
+			Font boldFont = boldDescriptor.createFont(Display.getCurrent());
+			textStyle.font = boldFont;
+			textStyle.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN);
+		}
+	}
+
+	/**
+	 * @param groupSize
+	 *            the size of the groups present
+	 */
+	public static void adjustColorIndex(int groupSize) {
+		if(ConstraintBasedProcessEditorHelper.colorCtr != ConstraintBasedProcessEditorHelper.colorCtr - 1) {
+			if(groupSize == ConstraintBasedProcessEditorHelper.colorCtr + 1) {
+				ConstraintBasedProcessEditorHelper.colorCtr = 0;
+			} else {
+				ConstraintBasedProcessEditorHelper.colorCtr++;
+			}
+		}
+	}
+}
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/.ratings b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/.ratings
index 21e6574f8..b4ce5dcc6 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/.ratings
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/.ratings
@@ -8,7 +8,7 @@ LayoutDataUIUtils.java 0b2d3d1f47eef070c11b56fb7b332e0e49fa5a52 GREEN
 PropertiesViewUtils.java 009d390b8aa41bb79b45b1e09a3375d0374fa139 GREEN
 RectangleLayoutUIUtils.java b64f2f86b8254363689bf0809f681fc59a87a04a GREEN
 SnapToGridUtils.java 0ee536d1c1028aec313c59d533d6717b68febc85 GREEN
-StatusUtils.java a5bf0a9d6a9e35b191ec23b753ed71fafae46c96 RED
+StatusUtils.java f81d4c9a2ac359712844753f4dc4b9a896776673 YELLOW
 TableViewerUtils.java 7b72baa029b4a8a5371464f78fe6f2829e2e87eb GREEN
 TreeViewerUtils.java 296ae7efad3a472c00522be723d7853710069177 GREEN
 ZoomUIUtils.java 0e04976d43076e7e4b3f2d244a303463c71390f5 GREEN
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/StatusUtils.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/StatusUtils.java
index 08f5013ee..51f20ea45 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/StatusUtils.java
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/StatusUtils.java
@@ -43,8 +43,7 @@ public class StatusUtils {
 			IConstraintInstanceContainer instanceContainer, EList<String> currentActiveConstraints) {
 
 		for(ConstraintInstance ci : instanceContainer.getConstraintInstances()) {
-			// TODO(HP) why using toString()? constraintToFind is already a string.
-			if(constraintToFind.toString().equalsIgnoreCase(ci.getConstraintName())) {
+			if(constraintToFind.equalsIgnoreCase(ci.getConstraintName())) {
 				if(currentActiveConstraints.contains(constraintToFind.toString())) {
 					if(ci.getConstraintName().equalsIgnoreCase(constraintToFind.toString())) {
 						// If the constraint instance has a "failed status"
-- 
GitLab