diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/MarkerService.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/MarkerService.java index 0b628db1311f0517d9e4972c072c8b9b2bbcd8c4..55392da57abfa987d1ea44464b02338bbae596f0 100644 --- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/MarkerService.java +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/MarkerService.java @@ -126,7 +126,7 @@ public class MarkerService implements IMarkerService, /** {@inheritDoc} */ @Override - public Collection<IConstraintViolation<EObject>> getViolations( + public Collection<IConstraintViolation<? extends EObject>> getViolations( EObject element) { ITopLevelElement top = IPersistencyService.INSTANCE .getTopLevelElementFor(element); @@ -163,7 +163,7 @@ public class MarkerService implements IMarkerService, @Override public void refreshMarkers(ITopLevelElement element) { - List<IConstraintViolation<EObject>> checkResult = IConstraintCheckerService.INSTANCE + List<IConstraintViolation<? extends EObject>> checkResult = IConstraintCheckerService.INSTANCE .performAllConstraintChecksRecursively(element .getTopLevelElement()); synchronized (violationCache) { @@ -262,7 +262,7 @@ public class MarkerService implements IMarkerService, private static class CacheEntry { /** Stores the mapping from model elements to violation lists. */ - private final Map<EObject, List<IConstraintViolation<EObject>>> violationsMap = new HashMap<EObject, List<IConstraintViolation<EObject>>>(); + private final Map<EObject, List<IConstraintViolation<? extends EObject>>> violationsMap = new HashMap<EObject, List<IConstraintViolation<? extends EObject>>>(); /** Stores the highest severity value for each cached element. */ private final Map<EObject, ESeverity> highestSeverityMap = new HashMap<EObject, ESeverity>(); @@ -286,15 +286,15 @@ public class MarkerService implements IMarkerService, /** Updates the cache entry. */ public synchronized void updateCacheEntries( - List<IConstraintViolation<EObject>> newViolations) { + List<IConstraintViolation<? extends EObject>> newViolations) { clearCachedLists(); // update cache entries - for (IConstraintViolation<EObject> violation : newViolations) { + for (IConstraintViolation<? extends EObject> violation : newViolations) { getCachedList(violation.getSource()).add(violation); } // fix cached list order for (EObject eo : violationsMap.keySet()) { - List<IConstraintViolation<EObject>> list = violationsMap + List<IConstraintViolation<? extends EObject>> list = violationsMap .get(eo); if (list.isEmpty()) { highestSeverityMap.put(eo, ESeverity.lowest()); @@ -325,12 +325,12 @@ public class MarkerService implements IMarkerService, /** * Returns the cached list instance creating it if necessary. */ - private List<IConstraintViolation<EObject>> getCachedList( + private List<IConstraintViolation<? extends EObject>> getCachedList( EObject element) { - List<IConstraintViolation<EObject>> list = violationsMap + List<IConstraintViolation<? extends EObject>> list = violationsMap .get(element); if (list == null) { - list = new ArrayList<IConstraintViolation<EObject>>(); + list = new ArrayList<IConstraintViolation<? extends EObject>>(); violationsMap.put(element, list); } return list; @@ -338,7 +338,7 @@ public class MarkerService implements IMarkerService, /** Clears all cached lists. */ private void clearCachedLists() { - for (List<IConstraintViolation<EObject>> list : violationsMap + for (List<IConstraintViolation<? extends EObject>> list : violationsMap .values()) { list.clear(); } diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/service/IMarkerService.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/service/IMarkerService.java index e94d2657d46291c32046749c1c266a7bd6080812..38382a437ca88e123f6af3c6cf2bdd74084f10f5 100644 --- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/service/IMarkerService.java +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/service/IMarkerService.java @@ -34,7 +34,7 @@ import org.fortiss.tooling.kernel.ui.internal.MarkerService; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: 30E5845252B4939B202D380028CBB6B1 + * @ConQAT.Rating GREEN Hash: 579B2321FC685A2D551FAFF13A0FB3A6 */ public interface IMarkerService { @@ -42,7 +42,8 @@ public interface IMarkerService { public static final IMarkerService INSTANCE = new MarkerService(); /** Returns the constraint violations for the given element. */ - Collection<IConstraintViolation<EObject>> getViolations(EObject element); + Collection<IConstraintViolation<? extends EObject>> getViolations( + EObject element); /** Returns the highest severity for the given element. */ ESeverity getHighestViolationSeverity(EObject element); diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/IConstraintChecker.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/IConstraintChecker.java index f1c8a7cdd9fd171e715f36fdc64cbcbc681fb6d0..8ce5b467b56cdf0061b395fe0cc1b6d4dc29ceb7 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/IConstraintChecker.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/IConstraintChecker.java @@ -36,7 +36,7 @@ import org.fortiss.tooling.kernel.service.base.IEObjectAware; * @author hoelzlf * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: 9D1C13DDE03060268433FC560D3BB754 + * @ConQAT.Rating GREEN Hash: 16D08BC35D459B4038A71F198B561B27 */ public interface IConstraintChecker<C extends EObject> extends IEObjectAware<C> { @@ -47,5 +47,5 @@ public interface IConstraintChecker<C extends EObject> extends IEObjectAware<C> boolean isApplicable(C modelElement); /** Applies the constraint checker to the given model element. */ - IConstraintViolation<EObject> apply(C modelElement); + IConstraintViolation<? extends EObject> apply(C modelElement); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintViolationBase.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintViolationBase.java new file mode 100644 index 0000000000000000000000000000000000000000..2c8bb9651417ccd0dbdec919d548a090d55c44d9 --- /dev/null +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintViolationBase.java @@ -0,0 +1,53 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2011 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.extension.base; + +import org.eclipse.emf.ecore.EObject; +import org.fortiss.tooling.kernel.extension.data.IConstraintViolation; + +/** + * Base implementation for model element constraint checkers. + * + * @author hoelzl + * @author $Author$ + * @version $Rev$ + * @ConQAT.Rating YELLOW Hash: 3DDF9C3071E7CA9B599EFAFEEC27DDFF + */ +public abstract class ConstraintViolationBase<T extends EObject> implements + IConstraintViolation<T> { + + /** Stores the model element. */ + private final T source; + + /** Constructor. */ + public ConstraintViolationBase(T source) { + this.source = source; + } + + /** {@inheritDoc} */ + @Override + public T getSource() { + return source; + } + + /** {@inheritDoc} */ + @Override + public IQuickFixHandler getQuickFixHandler() { + return null; + } +} diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/data/IConstraintViolation.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/data/IConstraintViolation.java index 230d9c04f20dc236bf99527778b31ac2d35d4669..f49ef4510d06edfd25c9e06272965e1f97792ea9 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/data/IConstraintViolation.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/data/IConstraintViolation.java @@ -30,7 +30,7 @@ import org.eclipse.emf.ecore.EObject; * @author hoelzlf * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: 59B63AA8B22AF7224E17B92B0CD261BF + * @ConQAT.Rating GREEN Hash: 6340788DB3948AD781A97861749504DB */ public interface IConstraintViolation<T extends EObject> { @@ -88,11 +88,11 @@ public interface IConstraintViolation<T extends EObject> { } /** Stores the severity comparator used during violation sorting. */ - public static final Comparator<IConstraintViolation<EObject>> SEVERITY_COMPARATOR = new Comparator<IConstraintViolation<EObject>>() { + public static final Comparator<IConstraintViolation<? extends EObject>> SEVERITY_COMPARATOR = new Comparator<IConstraintViolation<? extends EObject>>() { /** {@inheritDoc} */ @Override - public int compare(IConstraintViolation<EObject> arg0, - IConstraintViolation<EObject> arg1) { + public int compare(IConstraintViolation<? extends EObject> arg0, + IConstraintViolation<? extends EObject> arg1) { int sev0 = ESeverity.getIntSeverity(arg0.getSeverity()); int sev1 = ESeverity.getIntSeverity(arg1.getSeverity()); return sev0 - sev1; diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConstraintCheckerService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConstraintCheckerService.java index 7b2f9b6a099a2ed054d4dffa3f7bbca841a28261..ea52f489e3a9ebf50800bc30fffa6caa7766b7a0 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConstraintCheckerService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConstraintCheckerService.java @@ -17,6 +17,7 @@ $Id$ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.internal; +import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; @@ -34,7 +35,7 @@ import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: FEB4237E503A79A9B119E465A3D49C31 + * @ConQAT.Rating GREEN Hash: 74C0500ED08841180F543A62284F2A9E */ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstraintChecker<EObject>> implements @@ -51,9 +52,9 @@ public class ConstraintCheckerService extends /** {@inheritDoc} */ @Override - public List<IConstraintViolation<EObject>> performAllConstraintChecksRecursively( + public List<IConstraintViolation<? extends EObject>> performAllConstraintChecksRecursively( EObject modelElement) { - List<IConstraintViolation<EObject>> result = new LinkedList<IConstraintViolation<EObject>>(); + List<IConstraintViolation<? extends EObject>> result = new LinkedList<IConstraintViolation<? extends EObject>>(); performConstraintCheck(modelElement, result); for (Iterator<EObject> iter = modelElement.eAllContents(); iter .hasNext();) { @@ -65,9 +66,9 @@ public class ConstraintCheckerService extends /** {@inheritDoc} */ @Override - public List<IConstraintViolation<EObject>> performAllConstraintChecks( + public List<IConstraintViolation<? extends EObject>> performAllConstraintChecks( EObject modelElement) { - List<IConstraintViolation<EObject>> result = new LinkedList<IConstraintViolation<EObject>>(); + List<IConstraintViolation<? extends EObject>> result = new LinkedList<IConstraintViolation<? extends EObject>>(); performConstraintCheck(modelElement, result); Collections.sort(result, IConstraintViolation.SEVERITY_COMPARATOR); return result; @@ -79,7 +80,7 @@ public class ConstraintCheckerService extends * considered. */ private void performConstraintCheck(EObject modelElement, - List<IConstraintViolation<EObject>> violationList) { + List<IConstraintViolation<? extends EObject>> violationList) { List<IConstraintChecker<EObject>> handlers = getRegisteredHandlers(modelElement .getClass()); if (handlers == null) { @@ -87,7 +88,7 @@ public class ConstraintCheckerService extends } for (IConstraintChecker<EObject> checker : handlers) { if (checker.isApplicable(modelElement)) { - IConstraintViolation<EObject> violation = checker + IConstraintViolation<? extends EObject> violation = checker .apply(modelElement); if (violation != null) { violationList.add(violation); @@ -98,9 +99,10 @@ public class ConstraintCheckerService extends /** {@inheritDoc} */ @Override - public List<IConstraintChecker<EObject>> getAllConstraintCheckers( + public List<IConstraintChecker<? extends EObject>> getAllConstraintCheckers( EObject modelElement) { - return getRegisteredHandlers(modelElement.getClass()); + return new ArrayList<IConstraintChecker<? extends EObject>>( + getRegisteredHandlers(modelElement.getClass())); } /** {@inheritDoc} */ diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/IConstraintCheckerService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/IConstraintCheckerService.java index 942fb3f17e444d533210aaa69c66cd0e545f02f3..22b8e8b7891bc385a159dc8fa58a4d436bd85062 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/IConstraintCheckerService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/IConstraintCheckerService.java @@ -34,7 +34,7 @@ import org.fortiss.tooling.kernel.internal.ConstraintCheckerService; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: 9F13D22CC269B9811CD13C341024AA78 + * @ConQAT.Rating GREEN Hash: C0BC2D1C3BDE3F2ECEA8E91A612857EF */ public interface IConstraintCheckerService { @@ -49,7 +49,7 @@ public interface IConstraintCheckerService { * The returned list is ordered according to {@link ESeverity} from FATAL to * DEBUG. */ - List<IConstraintViolation<EObject>> performAllConstraintChecksRecursively( + List<IConstraintViolation<? extends EObject>> performAllConstraintChecksRecursively( EObject modelElement); /** @@ -59,13 +59,13 @@ public interface IConstraintCheckerService { * The returned list is ordered according to {@link ESeverity} from FATAL to * DEBUG. */ - <T extends EObject> List<IConstraintViolation<T>> performAllConstraintChecks( - T modelElement); + List<IConstraintViolation<? extends EObject>> performAllConstraintChecks( + EObject modelElement); /** * Returns the list of registered constraint checkers for the given model * element. */ - <T extends EObject> List<IConstraintChecker<T>> getAllConstraintCheckers( - T modelElement); + List<IConstraintChecker<? extends EObject>> getAllConstraintCheckers( + EObject modelElement); }