From 99dd186b866520283732b9c78dfa093106db63d7 Mon Sep 17 00:00:00 2001
From: Vincent Aravantinos <aravantinos@fortiss.org>
Date: Wed, 17 Feb 2016 17:49:02 +0000
Subject: [PATCH] new form of contracts refs 2334

---
 .../trunk/icons/constraintErrorOverlay.png    | Bin 0 -> 559 bytes
 .../trunk/icons/constraintFailOverlay.png     | Bin 0 -> 872 bytes
 .../trunk/icons/constraintOutdatedOverlay.png | Bin 0 -> 612 bytes
 .../trunk/plugin.xml                          |  14 +
 .../trunk/schema/constraintVerifierUI.exsd    | 120 +++++++++
 .../ui/extension/IConstraintVerifierUI.java   |  50 ++++
 .../ui/internal/ConstraintLabelDecorator.java |  61 +++++
 .../ConstraintVerificationUIService.java      | 244 ++++++++++++++++++
 .../IConstraintVerificationUIService.java     |  30 +++
 .../kernel/ui/util/ConstraintsUtils.java      | 104 ++++++++
 10 files changed, 623 insertions(+)
 create mode 100644 org.fortiss.tooling.kernel.ui/trunk/icons/constraintErrorOverlay.png
 create mode 100644 org.fortiss.tooling.kernel.ui/trunk/icons/constraintFailOverlay.png
 create mode 100644 org.fortiss.tooling.kernel.ui/trunk/icons/constraintOutdatedOverlay.png
 create mode 100644 org.fortiss.tooling.kernel.ui/trunk/schema/constraintVerifierUI.exsd
 create mode 100644 org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/IConstraintVerifierUI.java
 create mode 100644 org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ConstraintLabelDecorator.java
 create mode 100644 org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ConstraintVerificationUIService.java
 create mode 100644 org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/service/IConstraintVerificationUIService.java
 create mode 100644 org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/ConstraintsUtils.java

diff --git a/org.fortiss.tooling.kernel.ui/trunk/icons/constraintErrorOverlay.png b/org.fortiss.tooling.kernel.ui/trunk/icons/constraintErrorOverlay.png
new file mode 100644
index 0000000000000000000000000000000000000000..47ffb847fe38eafb34fcc088442769e56973f29f
GIT binary patch
literal 559
zcmV+~0?_@5P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004b3#c}2nYxW
zd<bNS0005zNkl<ZIE{UiO=}ZT6o#LfiESj61Qk*c2A9$#W(>7LH^zn7jT%JMjm#8W
zYAF`o<_{EUmwsk~1))ey>7oh>Q?<Cz39~5OJ0K*b)d@6JGfZ_6NGHi82QK$q-ut}g
zTrNkTBO;=x=98)E+oR_cZ{K6D(ZH$iasRVX`ttKv$@{lo^xqeJdHV6_m_CshQ94Zl
z!l40<Mx$I=cxkL|RdPVhZ;<}3YKDAiB4)pP8^j|F4&qoA@l=`x({yGm^CVCU0lXR?
z*Zr`ZQ9#w&9f~@RX;QVyT$F^^`D4dRYdhN)#E2xRx9(0UePIAqBbrRMj*Gc#S>URe
zA4zC!ZTsP(-dsK6)X))4e4tHc1J$CAUAC~xR-1{xi_0hEY>05U3j~^AKv%VmjaEJ!
z8H$Av{6E<N0`mM^&nEzcXt+H^d43L}QEY88P_NW?9r4kNXGY%=wOUVU<%ewu5lK>a
zUoYu)=}liBICy_t$u#%pPjX`2^NNeJvsMrw>jh-J0DvG#ZQ6~}k^wA>05{h^X@?ID
zIDus=)q`A;h$|TiU%xqPJKH(v7^bIZ$Mie*rWE_b`z{}6bCcoI3fjuDvAR|58m3l6
xL{ZHrQq$L!Gs<7r<&W#~+jV)k{xNWz{{yyRxjBgX%gO)%002ovPDHLkV1lm%`Ro7y

literal 0
HcmV?d00001

diff --git a/org.fortiss.tooling.kernel.ui/trunk/icons/constraintFailOverlay.png b/org.fortiss.tooling.kernel.ui/trunk/icons/constraintFailOverlay.png
new file mode 100644
index 0000000000000000000000000000000000000000..e461531b7e5910b2e3a7ad3249b05dfec2922e5c
GIT binary patch
literal 872
zcmV-u1DE`XP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV0009oNkl<Zc${sM
ze`u6-9LHbJ_qpeu=eo@u)N1A?*X_nUmU=cykx4cP>7Q{?Q9<F#92J-|L=7uuS~022
z5;l@*BSb2S&6Q(O?x?L~&2yHN#xbEEvU5MYtv$Erx$pBl*B@imtj}K``22v+`~7(-
zTocW^_ilDwx0wQQ&vUW!lAM_%pSQcDbh^4fKGyl~eq|wfuI0dLpra}hiLYOGJJnUu
zMT@^blj8H<FBndZBpugD^qu%*`tJoV9%x-HRFQ1BXH#fp`Au9s@ge5$x41LYcsUc#
zo}*+_g6kiAjDeri9DL(&R!S%QRd4sS0PySnj)(3`glcYB!sXVz%nl7uka-kM!<#d~
z^Ozkx#c#WsSigKJPd7ag@;t8#Kz*t8_02W0>L=H&h>|(-Dt`(;>eii@ljHa&GB^_%
zsBa+n%nRgFr^$WULv7<$en^jo{ej{U5ipF#wY9e~)89+MaWEcvipp4w=(atKhi=5G
z-9UK9^DK*0QnI53XJ(pAXB+n?8YmPBjlN*;x{Wt4E#q?f0*dCx?mvkY4ihj8YW5#O
z6)J|VV_6nc$KFAixWe>clDeJy05%F;*XL#STog@X$(7%^)X|P*Sri3>1Of(ga~8k6
z`3k<Td+}TsX_^b>gnUAocT&-G5CR+r;ZqkshXQkBf8fjK@jQ=$_@^%NQUahB6(cmA
zTt$@dqfHowfo0iPmOX#Y%WpARy$07Upp`9Kn9qt?(@c&}OrlrCP&AFehP%;q9ox3~
z_4s?7-@lt#)1)XEr1<ge6#P1&x_Sl%zXM3Bb$8aIC`uxB$6BoP1+qimU{^$#>gz!}
zeF`Nt$fYwwOqG_C-S;dd;YyZo+r{B`I~g0x>`?$(550Z%fqNU`6-5CiK4?cV4D9qp
z%;CX#eLW9}ia#3TmX_D(J$s%bZAX*+eLZ&x0MpDhe)MT~cJ%5DrCYXRRIb1py$GsG
z!KWe0$|-$#3(<pZ^qu>O_M`7-g%FAVz$6r<W6i3S@v3NqRkzkGGGb^rMfYbX89Dc3
y()HZMFkOqYBb{dH$hedaQc9$hI8y#E&VK>*`eF72M?_Kp0000<MNUMnLSTY<)uvkj

literal 0
HcmV?d00001

diff --git a/org.fortiss.tooling.kernel.ui/trunk/icons/constraintOutdatedOverlay.png b/org.fortiss.tooling.kernel.ui/trunk/icons/constraintOutdatedOverlay.png
new file mode 100644
index 0000000000000000000000000000000000000000..2cc161f81d019ca3073dfa6c4e7de205aa801376
GIT binary patch
literal 612
zcmV-q0-ODbP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004b3#c}2nYxW
zd<bNS0006TNkl<ZIE{sq&1(};6va=*kyHp~CKZW|LZP7O!bH1BNJ<@dq6-U8NV{<&
zZd?c!ROrry3;zUhp(eI;Aq+%XY89a)n%JOCW}t<k5&TFSqqfNuliK8I;zD0&;zZB#
zz4tr!-ov{#v`G*|**`EidhpO;U%mbl)f&ZSWfSSwuj086@8gy7w^%y^0N{DvJ9I9b
zx%XhQVJv4G?YeSpta0P!t;Ug~$L0Vy8E5+q@AO{2dR;v~GA!)(^q^QOVLq8?DG&&T
zFrQ2yvuHrmbo2SM$GreHcmN>7BhgD2F9<GCY{G<)76V055D12vljc`G#<RxKN#51H
zM-GR>zJI|0KnQ6!k#4_xdzKqGAw~TC$1Pz+QJ^S_Wo7`d*X@aLr%s=ddiJ^hx@6S?
z!B9sNx95Pw+wJz2px9#;8f)K5U0u5bp0n9n4%v+VgPHgmr5!H`A#gYxh{a+p=1f~#
z-%W02dP@Dew%*aCTrOL}08m)Xsr(CdF1n!UQoqlOVyOfGaET%SScb<w699ZEtVX%w
z`dVy!d_pT%Dov0X$+8StmMuG*nVwQ>)#@V-03J?GMDE<ZZ<b86X~ML9JXSrO&X`$a
zX$Syz06@K7|C~y`oXzD60jE=NJDs~x_>_mP>&Rx80RStx95Raro<5mX7gC7;fDPc!
yGHsV2h_XL4INICS=cDuoD5ap3LVJ_4T<2fDkq_s)BB+}H0000<MNUMnLSTZ|NDt5e

literal 0
HcmV?d00001

diff --git a/org.fortiss.tooling.kernel.ui/trunk/plugin.xml b/org.fortiss.tooling.kernel.ui/trunk/plugin.xml
index 599e8b6ca..eae388ffc 100644
--- a/org.fortiss.tooling.kernel.ui/trunk/plugin.xml
+++ b/org.fortiss.tooling.kernel.ui/trunk/plugin.xml
@@ -6,6 +6,7 @@
    <extension-point id="editPartFactory" name="Edit Part Factory" schema="schema/editPartFactory.exsd"/>
    <extension-point id="contextMenuContribution" name="Context Menu Contribution" schema="schema/contextMenuContribution.exsd"/>
    <extension-point id="allocationEditPartFactory" name="Allocation Edit Part Factory" schema="schema/allocationEditPartFactory.exsd"/>
+   <extension-point id="constraintVerifierUI" name="Constraint Verifier UI" schema="schema/constraintVerifierUI.exsd"/>
    <extension
          point="org.eclipse.ui.editors">
       <editor
@@ -124,6 +125,19 @@
             </objectClass>
          </enablement>
       </decorator>
+      <decorator
+            class="org.fortiss.tooling.kernel.ui.internal.ConstraintLabelDecorator"
+            id="org.fortiss.tooling.kernel.ui.internal.ConstraintLabelDecorator"
+            label="Constraint Decorator"
+            lightweight="true"
+            location="TOP_LEFT"
+            state="true">
+         <enablement>
+            <objectClass
+                  name="org.fortiss.tooling.kernel.model.constraints.IConstrained">
+            </objectClass>
+         </enablement>
+      </decorator>
    </extension>
    <extension
          point="org.fortiss.tooling.kernel.ui.contextMenuContribution">
diff --git a/org.fortiss.tooling.kernel.ui/trunk/schema/constraintVerifierUI.exsd b/org.fortiss.tooling.kernel.ui/trunk/schema/constraintVerifierUI.exsd
new file mode 100644
index 000000000..cc435451a
--- /dev/null
+++ b/org.fortiss.tooling.kernel.ui/trunk/schema/constraintVerifierUI.exsd
@@ -0,0 +1,120 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.fortiss.tooling.kernel.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.fortiss.tooling.kernel.ui" id="constraintVerifierUI" name="Constraint Verifier UI"/>
+      </appinfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="constraintVerifierUI" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="constraintVerifierUI">
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <element ref="constraint" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="constraintVerifierUI" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":org.fortiss.tooling.kernel.ui.extension.IConstraintVerifierUI"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="constraint">
+      <complexType>
+         <attribute name="constraint" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":org.fortiss.tooling.kernel.model.constraints.IConstraint"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/IConstraintVerifierUI.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/IConstraintVerifierUI.java
new file mode 100644
index 000000000..f40aed268
--- /dev/null
+++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/IConstraintVerifierUI.java
@@ -0,0 +1,50 @@
+/*--------------------------------------------------------------------------+
+$Id$
+|                                                                          |
+| Copyright 2015 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.kernel.ui.extension;
+
+import org.fortiss.tooling.kernel.model.constraints.IConstraint;
+import org.fortiss.tooling.kernel.model.constraints.IConstraintVerificationStatus;
+import org.fortiss.tooling.kernel.service.base.IEObjectAware;
+
+/**
+ * Interface for the GUI of constraint verifiers.
+ * 
+ * @author aravantinos
+ * @author $Author$
+ * @version $Rev$
+ * @ConQAT.Rating YELLOW Hash: 011835D3C52A01134B1FCA85229D6859
+ */
+public interface IConstraintVerifierUI<T extends IConstraint> extends IEObjectAware<T> {
+
+	/**
+	 * Action to take when trying to open the given status. <code>canOpen</code> should be called
+	 * before to know if the status can be opened.
+	 * 
+	 * @return true if the status could indeed be open, false if it needs further handling.
+	 */
+	public boolean openStatus(IConstraintVerificationStatus status);
+
+	/** True if the given status can be open. */
+	public boolean canOpen(IConstraintVerificationStatus status);
+
+	/**
+	 * @param status
+	 * @return a short user-friendly description explaining the status.
+	 */
+	public String getMessage(IConstraintVerificationStatus status);
+}
diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ConstraintLabelDecorator.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ConstraintLabelDecorator.java
new file mode 100644
index 000000000..d7546958c
--- /dev/null
+++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ConstraintLabelDecorator.java
@@ -0,0 +1,61 @@
+/*--------------------------------------------------------------------------+
+$Id$
+|                                                                          |
+| Copyright 2016 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.kernel.ui.internal;
+
+import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.fortiss.tooling.kernel.model.constraints.IConstrained;
+import org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator;
+import org.fortiss.tooling.kernel.ui.service.IMarkerService;
+import org.fortiss.tooling.kernel.ui.util.ConstraintsUtils;
+import org.fortiss.tooling.kernel.ui.util.ConstraintsUtils.ClassifiedStatuses;
+
+/**
+ * Label decorator for the {@link IMarkerService} decorations: errors, warnings, etc.
+ * 
+ * @author hoelzl
+ * @author $Author$
+ * @version $Rev$
+ * @ConQAT.Rating YELLOW Hash: 22615D52E9BB387F51B1C3BE8A43207F
+ */
+public final class ConstraintLabelDecorator extends BaseLabelProvider implements
+		ILightweightLabelDecorator {
+
+	/** {@inheritDoc} */
+	@Override
+	public void decorate(Object element, IDecoration decoration) {
+		if(element instanceof IConstrained) {
+			IConstrained constrained = (IConstrained)element;
+			ClassifiedStatuses classifiedStatuses =
+					ConstraintsUtils.getClassifiedStatuses(constrained);
+			if(!classifiedStatuses.failedStatuses.isEmpty()) {
+				decoration.addOverlay(ToolingKernelUIActivator
+						.getImageDescriptor("icons/constraintFailOverlay.png"));
+			} else if(!classifiedStatuses.errorStatuses.isEmpty()) {
+				decoration.addOverlay(ToolingKernelUIActivator
+						.getImageDescriptor("icons/constraintErrorOverlay.png"));
+			} else if(!classifiedStatuses.outdatedStatuses.isEmpty()) {
+				decoration.addOverlay(ToolingKernelUIActivator
+						.getImageDescriptor("icons/constraintOutdatedOverlay.png"));
+			} else if(!classifiedStatuses.failedStatuses.isEmpty()) {
+				decoration.addOverlay(null);
+			}
+		}
+	}
+}
diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ConstraintVerificationUIService.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ConstraintVerificationUIService.java
new file mode 100644
index 000000000..df25053fa
--- /dev/null
+++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ConstraintVerificationUIService.java
@@ -0,0 +1,244 @@
+package org.fortiss.tooling.kernel.ui.internal;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.fortiss.tooling.kernel.ToolingKernelActivator;
+import org.fortiss.tooling.kernel.extension.IEclipseResourcePostLoadProvider;
+import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
+import org.fortiss.tooling.kernel.model.constraints.ConstrainedWithChecksum;
+import org.fortiss.tooling.kernel.model.constraints.ConstraintsPackage;
+import org.fortiss.tooling.kernel.model.constraints.IAutoCheck;
+import org.fortiss.tooling.kernel.model.constraints.IConstrained;
+import org.fortiss.tooling.kernel.model.constraints.IConstraint;
+import org.fortiss.tooling.kernel.model.constraints.IConstraintVerificationStatus;
+import org.fortiss.tooling.kernel.model.constraints.OutdatedVerificationStatus;
+import org.fortiss.tooling.kernel.service.IConstraintVerificationService;
+import org.fortiss.tooling.kernel.service.IPersistencyService;
+import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase;
+import org.fortiss.tooling.kernel.ui.extension.IConstraintVerifierUI;
+import org.fortiss.tooling.kernel.ui.service.IConstraintVerificationUIService;
+import org.fortiss.tooling.kernel.ui.util.ConstraintsUtils;
+import org.fortiss.tooling.kernel.utils.EcoreUtils;
+import org.fortiss.tooling.kernel.utils.LoggingUtils;
+
+/**
+ * Implementation of {@link IConstraintVerificationService}.
+ * 
+ * @author aravantinos
+ * @author $Author$
+ * @version $Rev$
+ * @ConQAT.Rating YELLOW Hash: 220B5753C9EEEF2B9E972690D285AFA9
+ */
+public final class ConstraintVerificationUIService extends
+		EObjectAwareServiceBase<IConstraintVerifierUI<IConstraint>> implements
+		IConstraintVerificationUIService, IEclipseResourcePostLoadProvider {
+
+	/**
+	 * @param constraint
+	 * @return the first registered verifier which provides a GUI for the verifier of
+	 *         <code>constraint</code>
+	 */
+	private IConstraintVerifierUI<IConstraint> getFirstVerifier(IConstraint constraint) {
+		List<IConstraintVerifierUI<IConstraint>> list =
+				getRegisteredHandlers(constraint.getClass());
+		if(list == null || list.isEmpty()) {
+			LoggingUtils.error(ToolingKernelActivator.getDefault(), String.format(
+					"Cannot find verifierUI for constraint %s", constraint.getClass()));
+			return null;
+		}
+		// get(0) because we know the list is not empty and because we want the first element
+		return list.get(0);
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public void openStatus(IConstraintVerificationStatus status) {
+		IConstraintVerifierUI<IConstraint> verifier = getFirstVerifier(status.getConstraint());
+		verifier.openStatus(status);
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public boolean canOpen(IConstraintVerificationStatus status) {
+		if(status != null) {
+			IConstraintVerifierUI<IConstraint> verifier = getFirstVerifier(status.getConstraint());
+			return verifier.canOpen(status);
+		}
+		return false;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * Installs all the required notifiers.
+	 */
+	@Override
+	public void postModelLoadRun(ITopLevelElement element) {
+		TreeIterator<EObject> tree = element.getRootModelElement().eAllContents();
+		while(tree.hasNext()) {
+			EObject next = tree.next();
+			if(next instanceof IConstraint) {
+				installNotifiers((IConstraint)next);
+			}
+		}
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public void installNotifiers(IConstraint constraint) {
+		new ConstrainedAdapters(constraint);
+	}
+
+	/** Adapter for changes on constrained elements. */
+	private static class ConstrainedAdapters {
+
+		/** Map containing the adapter of each constrained element. */
+		Map<IConstrained, Adapter> constrainedAdapterMap;
+
+		/** Constructor. */
+		public ConstrainedAdapters(IConstraint constraint) {
+			constrainedAdapterMap = new HashMap<IConstrained, Adapter>();
+			for(ConstrainedWithChecksum cwc : constraint.getConstrainedsWithChecksum()) {
+				IConstrained constrained = cwc.getConstrained();
+				Adapter adapter = new EContentAdapter() {
+					@Override
+					public void notifyChanged(Notification notification) {
+						super.notifyChanged(notification);
+						if(isTouch(notification)) {
+							return;
+						}
+						if(constraintRemoved(notification, constrained)) {
+							return;
+						}
+						constraintOutdated(constraint, notification);
+					}
+				};
+				constrained.eAdapters().add(adapter);
+				constrainedAdapterMap.put(constrained, adapter);
+			}
+		}
+
+		/**
+		 * @param constraint
+		 * @param notification
+		 *            If <code>constraint</code> is outdated because its verification status has
+		 *            just been changed, we do not want to change the status to outdated...
+		 */
+		private boolean skipConstraintSelfNotification(IConstraint constraint,
+				Notification notification) {
+			String n = ConstraintsPackage.eINSTANCE.getIConstraint_VerificationStatus().getName();
+			if(notification.getNotifier() != null && notification.getNotifier().equals(constraint)) {
+				if(notification.getFeature() instanceof EReference) {
+					return(n.equals(((ENamedElement)notification.getFeature()).getName()));
+				}
+			}
+			return false;
+		}
+
+		/**
+		 * @param constraint
+		 * @return <code>true</code> if <code>constraint</code> is outdated and has been handled as
+		 *         such.
+		 */
+		private boolean constraintOutdated(IConstraint constraint, Notification notification) {
+			if(skipConstraintSelfNotification(constraint, notification)) {
+				return false;
+			}
+			if(!IConstraintVerificationService.INSTANCE.isUpToDate(constraint)) {
+				if(constraint instanceof IAutoCheck) {
+					ITopLevelElement modelContext =
+							IPersistencyService.INSTANCE.getTopLevelElementFor(constraint);
+					modelContext.runAsCommand(new Runnable() {
+						@Override
+						public void run() {
+							IConstraintVerificationService.INSTANCE.verify(constraint);
+						}
+					});
+				} else if(!(constraint.getVerificationStatus() instanceof OutdatedVerificationStatus)) {
+					ConstraintsUtils.createOutdatedVerificationStatus(constraint);
+				}
+				return true;
+			}
+			return false;
+		}
+
+		/**
+		 * @param notification
+		 * @param constrained
+		 * @return true if the notification is a consequence of a constraint of
+		 *         <code>constrained</code> having been removed.
+		 */
+		private boolean constraintRemoved(Notification notification, IConstrained constrained) {
+			if(notification.getEventType() != Notification.REMOVE) {
+				return false;
+			}
+			if(!notification.getNotifier().equals(constrained)) {
+				return false;
+			}
+			if(notification.getFeature() instanceof EReference) {
+				String name = ((ENamedElement)notification.getFeature()).getName();
+				if(name.equals(ConstraintsPackage.eINSTANCE.getIConstrained_Constraints().getName())) {
+					constrained.eAdapters().remove(constrainedAdapterMap.get(constrained));
+					constrainedAdapterMap.remove(constrained);
+					return true;
+				}
+			}
+			return true;
+		}
+	}
+
+	/**
+	 * @param notification
+	 * @return true if <code>notification</code> is not relevant and should be skipped
+	 */
+	private static boolean isTouch(Notification notification) {
+		// Notifications which do not notify about a model change.
+		if(notification.isTouch()) {
+			return true;
+		}
+		// Notifications initiated by the the AF3 kernel which are only GUI related.
+		if(notification.getEventType() == EcoreUtils.KERNEL_EMF_EVENT_TYPE_COUNT) {
+			return true;
+		}
+		return false;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	protected String getExtensionPointName() {
+		return "org.fortiss.tooling.kernel.ui.constraintVerifierUI";
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	protected String getConfigurationElementName() {
+		return "constraintVerifierUI";
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	protected String getHandlerClassAttribute() {
+		return "constraintVerifierUI";
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	protected String getClassAttribute() {
+		return "constraint";
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	protected String getClassConfigurationElement() {
+		return "constraint";
+	}
+}
diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/service/IConstraintVerificationUIService.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/service/IConstraintVerificationUIService.java
new file mode 100644
index 000000000..cb6caeac9
--- /dev/null
+++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/service/IConstraintVerificationUIService.java
@@ -0,0 +1,30 @@
+package org.fortiss.tooling.kernel.ui.service;
+
+import org.fortiss.tooling.kernel.model.constraints.IConstraint;
+import org.fortiss.tooling.kernel.model.constraints.IConstraintVerificationStatus;
+import org.fortiss.tooling.kernel.service.IConstraintVerificationService;
+import org.fortiss.tooling.kernel.ui.internal.ConstraintVerificationUIService;
+
+/**
+ * GUI aspects of {@link IConstraintVerificationService}.
+ * 
+ * @author aravantinos
+ * @author $Author$
+ * @version $Rev$
+ * @ConQAT.Rating YELLOW Hash: 07DB0EA202D19FE3C1407B53B01F974F
+ */
+public interface IConstraintVerificationUIService {
+
+	/** Returns the singleton instance of the service. */
+	public static final IConstraintVerificationUIService INSTANCE =
+			new ConstraintVerificationUIService();
+
+	/** Action to take when trying to open the given status. */
+	public void openStatus(IConstraintVerificationStatus status);
+
+	/** True if the given status can be open. */
+	public boolean canOpen(IConstraintVerificationStatus status);
+
+	/** Install the notifiers required for the given constraint. */
+	public void installNotifiers(IConstraint constraint);
+}
diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/ConstraintsUtils.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/ConstraintsUtils.java
new file mode 100644
index 000000000..01cbd0699
--- /dev/null
+++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/ConstraintsUtils.java
@@ -0,0 +1,104 @@
+/*--------------------------------------------------------------------------+
+$Id$
+|                                                                          |
+| Copyright 2015 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.kernel.ui.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.fortiss.tooling.kernel.model.constraints.ConstraintsFactory;
+import org.fortiss.tooling.kernel.model.constraints.ErrorVerificationStatus;
+import org.fortiss.tooling.kernel.model.constraints.FailVerificationStatus;
+import org.fortiss.tooling.kernel.model.constraints.IConstrained;
+import org.fortiss.tooling.kernel.model.constraints.IConstraint;
+import org.fortiss.tooling.kernel.model.constraints.IConstraintVerificationStatus;
+import org.fortiss.tooling.kernel.model.constraints.OutdatedVerificationStatus;
+import org.fortiss.tooling.kernel.model.constraints.SuccessVerificationStatus;
+
+/**
+ * Utility functions for constraints.
+ * 
+ * @author aravantinos
+ * @author $Author$
+ * @version $Rev$
+ * @ConQAT.Rating YELLOW Hash: 6D5AD8843A4CA208840DD7AA8E3968C2
+ */
+public class ConstraintsUtils {
+	/**
+	 * @param constraint
+	 * @return An "outdated" verification status for <code>constraint</code>.
+	 */
+	public static OutdatedVerificationStatus
+			createOutdatedVerificationStatus(IConstraint constraint) {
+		OutdatedVerificationStatus status =
+				ConstraintsFactory.eINSTANCE.createOutdatedVerificationStatus();
+		// The order if these two lines matter: otherwise we might get to some inconsistent state in
+		// case some GUI element (like a table summarizing the status of all constraints) listens to
+		// changes to the constraint.
+		status.setConstraint(constraint);
+		constraint.setVerificationStatus(status);
+		return status;
+	}
+
+	/** Gathers some statuses by verification status. */
+	public static class ClassifiedStatuses {
+
+		/** Failed constraints. */
+		public List<FailVerificationStatus> failedStatuses;
+
+		/** Error statuses (constraint could not be checked). */
+		public List<ErrorVerificationStatus> errorStatuses;
+
+		/** Outdated statuses. */
+		public List<OutdatedVerificationStatus> outdatedStatuses;
+
+		/** Successful constraints. */
+		public List<SuccessVerificationStatus> successStatuses;
+
+		/** Constructor. */
+		public ClassifiedStatuses() {
+			failedStatuses = new ArrayList<FailVerificationStatus>();
+			errorStatuses = new ArrayList<ErrorVerificationStatus>();
+			outdatedStatuses = new ArrayList<OutdatedVerificationStatus>();
+			successStatuses = new ArrayList<SuccessVerificationStatus>();
+		}
+	}
+
+	/**
+	 * @param constrained
+	 * @return {@link ClassifiedStatuses} corresponding to <code>constrained</code>.
+	 */
+	public static ClassifiedStatuses getClassifiedStatuses(IConstrained constrained) {
+		ClassifiedStatuses res = new ClassifiedStatuses();
+		for(IConstraint constraint : constrained.getConstraints()) {
+			IConstraintVerificationStatus status = constraint.getVerificationStatus();
+			if(status instanceof FailVerificationStatus) {
+				res.failedStatuses.add((FailVerificationStatus)status);
+			}
+			if(status instanceof ErrorVerificationStatus) {
+				res.errorStatuses.add((ErrorVerificationStatus)status);
+			}
+			if(status instanceof OutdatedVerificationStatus) {
+				res.outdatedStatuses.add((OutdatedVerificationStatus)status);
+			}
+			if(status instanceof SuccessVerificationStatus) {
+				res.successStatuses.add((SuccessVerificationStatus)status);
+			}
+		}
+		return res;
+	}
+}
-- 
GitLab