|
Lines 1-7
Link Here
|
| 1 |
/** |
1 |
/** |
| 2 |
* <copyright> |
2 |
* <copyright> |
| 3 |
* |
3 |
* |
| 4 |
* Copyright (c) 2004-2007 IBM Corporation and others. |
4 |
* Copyright (c) 2004-2009 IBM Corporation and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
7 |
* which accompanies this distribution, and is available at |
|
Lines 35-50
Link Here
|
| 35 |
import org.eclipse.emf.common.util.EMap; |
35 |
import org.eclipse.emf.common.util.EMap; |
| 36 |
import org.eclipse.emf.common.util.ResourceLocator; |
36 |
import org.eclipse.emf.common.util.ResourceLocator; |
| 37 |
|
37 |
|
| 38 |
import org.eclipse.emf.ecore.EValidator; |
|
|
| 39 |
|
| 40 |
import org.eclipse.emf.ecore.EAttribute; |
38 |
import org.eclipse.emf.ecore.EAttribute; |
| 41 |
import org.eclipse.emf.ecore.EObject; |
|
|
| 42 |
import org.eclipse.emf.ecore.EClass; |
39 |
import org.eclipse.emf.ecore.EClass; |
| 43 |
import org.eclipse.emf.ecore.EReference; |
|
|
| 44 |
import org.eclipse.emf.ecore.EcorePackage; |
| 45 |
import org.eclipse.emf.ecore.EDataType; |
40 |
import org.eclipse.emf.ecore.EDataType; |
|
|
41 |
import org.eclipse.emf.ecore.EObject; |
| 42 |
import org.eclipse.emf.ecore.EOperation; |
| 46 |
import org.eclipse.emf.ecore.EPackage; |
43 |
import org.eclipse.emf.ecore.EPackage; |
|
|
44 |
import org.eclipse.emf.ecore.EReference; |
| 47 |
import org.eclipse.emf.ecore.EStructuralFeature; |
45 |
import org.eclipse.emf.ecore.EStructuralFeature; |
|
|
46 |
import org.eclipse.emf.ecore.EValidator; |
| 47 |
import org.eclipse.emf.ecore.EcorePackage; |
| 48 |
import org.eclipse.emf.ecore.InternalEObject; |
48 |
import org.eclipse.emf.ecore.InternalEObject; |
| 49 |
|
49 |
|
| 50 |
import org.eclipse.emf.ecore.plugin.EcorePlugin; |
50 |
import org.eclipse.emf.ecore.plugin.EcorePlugin; |
|
Lines 166-171
Link Here
|
| 166 |
} |
166 |
} |
| 167 |
|
167 |
|
| 168 |
/** |
168 |
/** |
|
|
169 |
* @since 2.6 |
| 170 |
*/ |
| 171 |
protected static EValidator.ValidationDelegate.Registry getValidationDelegateRegistry(Map<Object, Object> context) |
| 172 |
{ |
| 173 |
if (context != null) |
| 174 |
{ |
| 175 |
EValidator.ValidationDelegate.Registry result = (EValidator.ValidationDelegate.Registry)context.get(EValidator.ValidationDelegate.Registry.class); |
| 176 |
if (result != null) |
| 177 |
{ |
| 178 |
return result; |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
return EValidator.ValidationDelegate.Registry.INSTANCE; |
| 183 |
} |
| 184 |
|
| 185 |
/** |
| 186 |
* Delegates evaluation of the given invariant expression against the object in the given context. |
| 187 |
* @return the result of the expression evaluation. |
| 188 |
* @since 2.6 |
| 189 |
*/ |
| 190 |
public static boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, String validationDelegate, EOperation invariant, String expression, int severity, String source, int code) |
| 191 |
{ |
| 192 |
ValidationDelegate delegate = getValidationDelegateRegistry(context).getValidationDelegate(validationDelegate); |
| 193 |
if (delegate != null) |
| 194 |
{ |
| 195 |
try |
| 196 |
{ |
| 197 |
if (!delegate.validate(eClass, eObject, context, invariant, expression)) |
| 198 |
{ |
| 199 |
if (diagnostics != null) |
| 200 |
reportInvariantDelegateViolation(eClass, eObject, diagnostics, context, invariant, severity, source, code); |
| 201 |
return false; |
| 202 |
} |
| 203 |
} |
| 204 |
catch (Throwable throwable) |
| 205 |
{ |
| 206 |
if (diagnostics != null) |
| 207 |
reportInvariantDelegateException(eClass, eObject, diagnostics, context, invariant, severity, source, code, throwable); |
| 208 |
} |
| 209 |
} |
| 210 |
else |
| 211 |
{ |
| 212 |
if (diagnostics != null) |
| 213 |
reportInvariantDelegateNotFound(eClass, eObject, diagnostics, context, invariant, severity, source, code, validationDelegate); |
| 214 |
} |
| 215 |
return true; |
| 216 |
} |
| 217 |
|
| 218 |
/** |
| 219 |
* Delegates evaluation of the given constraint expression against the object in the given context. |
| 220 |
* @return the result of the expression evaluation. |
| 221 |
* @since 2.6 |
| 222 |
*/ |
| 223 |
public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, String validationDelegate, String constraint, String expression, int severity, String source, int code) |
| 224 |
{ |
| 225 |
ValidationDelegate delegate = getValidationDelegateRegistry(context).getValidationDelegate(validationDelegate); |
| 226 |
if (delegate != null) |
| 227 |
{ |
| 228 |
try |
| 229 |
{ |
| 230 |
if (!delegate.validate(eClass, eObject, context, constraint, expression)) |
| 231 |
{ |
| 232 |
if (diagnostics != null) |
| 233 |
reportConstraintDelegateViolation(eClass, eObject, diagnostics, context, constraint, severity, source, code); |
| 234 |
return false; |
| 235 |
} |
| 236 |
} |
| 237 |
catch (Throwable throwable) |
| 238 |
{ |
| 239 |
if (diagnostics != null) |
| 240 |
reportConstraintDelegateException(eClass, eObject, diagnostics, context, constraint, severity, source, code, throwable); |
| 241 |
} |
| 242 |
} |
| 243 |
else |
| 244 |
{ |
| 245 |
if (diagnostics != null) |
| 246 |
reportConstraintDelegateNotFound(eClass, eObject, diagnostics, context, constraint, severity, source, code, validationDelegate); |
| 247 |
} |
| 248 |
return true; |
| 249 |
} |
| 250 |
|
| 251 |
/** |
| 252 |
* Delegates evaluation of the given constraint expression against the value in the given context. |
| 253 |
* @return the result of the expression evaluation. |
| 254 |
* @since 2.6 |
| 255 |
*/ |
| 256 |
public boolean validate(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context, String validationDelegate, String constraint, String expression, int severity, String source, int code) |
| 257 |
{ |
| 258 |
ValidationDelegate delegate = getValidationDelegateRegistry(context).getValidationDelegate(validationDelegate); |
| 259 |
if (delegate != null) |
| 260 |
{ |
| 261 |
try |
| 262 |
{ |
| 263 |
if (!delegate.validate(eDataType, value, context, constraint, expression)) |
| 264 |
{ |
| 265 |
if (diagnostics != null) |
| 266 |
reportConstraintDelegateViolation(eDataType, value, diagnostics, context, constraint, severity, source, code); |
| 267 |
return false; |
| 268 |
} |
| 269 |
} |
| 270 |
catch (Throwable throwable) |
| 271 |
{ |
| 272 |
if (diagnostics != null) |
| 273 |
reportConstraintDelegateException(eDataType, value, diagnostics, context, constraint, severity, source, code, throwable); |
| 274 |
} |
| 275 |
} |
| 276 |
else |
| 277 |
{ |
| 278 |
if (diagnostics != null) |
| 279 |
reportConstraintDelegateNotFound(eDataType, value, diagnostics, context, constraint, severity, source, code, validationDelegate); |
| 280 |
} |
| 281 |
return true; |
| 282 |
} |
| 283 |
|
| 284 |
/** |
| 169 |
* Validates the object in the given context, optionally producing diagnostics. |
285 |
* Validates the object in the given context, optionally producing diagnostics. |
| 170 |
* @param diagnostics a place to accumulate diagnostics; if it's <code>null</code>, no diagnostics should be produced. |
286 |
* @param diagnostics a place to accumulate diagnostics; if it's <code>null</code>, no diagnostics should be produced. |
| 171 |
* @param context a place to cache information, if it's <code>null</code>, no cache is supported. |
287 |
* @param context a place to cache information, if it's <code>null</code>, no cache is supported. |
|
Lines 184-194
Link Here
|
| 184 |
} |
300 |
} |
| 185 |
else |
301 |
else |
| 186 |
{ |
302 |
{ |
| 187 |
List<EClass> eSuperTypes = eClass.getESuperTypes(); |
303 |
return new DynamicEClassValidator() |
| 188 |
return |
304 |
{ |
| 189 |
eSuperTypes.isEmpty() ? |
305 |
// Ensure that the class loader for this class will be used downstream. |
| 190 |
validate_EveryDefaultConstraint(eObject, diagnostics, context) : |
306 |
// |
| 191 |
validate(eSuperTypes.get(0), eObject, diagnostics, context); |
307 |
}.validate(eClass, eObject, diagnostics, context); |
| 192 |
} |
308 |
} |
| 193 |
} |
309 |
} |
| 194 |
|
310 |
|
|
Lines 836-849
Link Here
|
| 836 |
} |
952 |
} |
| 837 |
} |
953 |
} |
| 838 |
|
954 |
|
| 839 |
public boolean validate(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) |
955 |
protected boolean validateDelegatedConstraints(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) |
| 840 |
{ |
956 |
{ |
| 841 |
boolean result = true; |
957 |
boolean result = true; |
|
|
958 |
List<String> validationDelegates = EcoreUtil.getValidationDelegates(eDataType.getEPackage()); |
| 959 |
|
| 960 |
if (!validationDelegates.isEmpty()) |
| 961 |
{ |
| 962 |
CONSTRAINTS: for (String constraint : EcoreUtil.getConstraints(eDataType)) |
| 963 |
{ |
| 964 |
for (String validationDelegate : validationDelegates) |
| 965 |
{ |
| 966 |
String expression = EcoreUtil.getAnnotation(eDataType, validationDelegate, constraint); |
| 967 |
if (expression != null) |
| 968 |
{ |
| 969 |
result &= EObjectValidator.this.validate(eDataType, value, diagnostics, context, validationDelegate, constraint, expression, Diagnostic.ERROR, DIAGNOSTIC_SOURCE, 0); |
| 970 |
if (!result && diagnostics == null) |
| 971 |
break CONSTRAINTS; |
| 972 |
} |
| 973 |
} |
| 974 |
} |
| 975 |
} |
| 976 |
|
| 977 |
return result; |
| 978 |
} |
| 979 |
|
| 980 |
protected boolean validateSchemaConstraints(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) |
| 981 |
{ |
| 982 |
boolean result = true; |
| 983 |
|
| 842 |
if (effectiveEnumeration != null) |
984 |
if (effectiveEnumeration != null) |
| 843 |
{ |
985 |
{ |
| 844 |
if (!effectiveEnumeration.contains(value)) |
986 |
if (!effectiveEnumeration.contains(value)) |
| 845 |
{ |
987 |
{ |
| 846 |
if (diagnostics != null) reportEnumerationViolation(eDataType, value, effectiveEnumeration, diagnostics, context); |
988 |
if (diagnostics != null) |
|
|
989 |
reportEnumerationViolation(eDataType, value, effectiveEnumeration, diagnostics, context); |
| 847 |
result = false; |
990 |
result = false; |
| 848 |
} |
991 |
} |
| 849 |
} |
992 |
} |
|
Lines 855-864
Link Here
|
| 855 |
|
998 |
|
| 856 |
if (effectiveMin != null) |
999 |
if (effectiveMin != null) |
| 857 |
{ |
1000 |
{ |
| 858 |
@SuppressWarnings("unchecked") Comparable<Object> comparableObject = (Comparable<Object>)effectiveMin; |
1001 |
@SuppressWarnings("unchecked") |
| 859 |
if (effectiveMinIsInclusive ? |
1002 |
Comparable<Object> comparableObject = (Comparable<Object>)effectiveMin; |
| 860 |
comparableObject.compareTo(value) > 0: |
1003 |
if (effectiveMinIsInclusive ? comparableObject.compareTo(value) > 0 : comparableObject.compareTo(value) >= 0) |
| 861 |
comparableObject.compareTo(value) >= 0) |
|
|
| 862 |
{ |
1004 |
{ |
| 863 |
if (diagnostics != null) |
1005 |
if (diagnostics != null) |
| 864 |
{ |
1006 |
{ |
|
Lines 877-886
Link Here
|
| 877 |
|
1019 |
|
| 878 |
if (effectiveMax != null) |
1020 |
if (effectiveMax != null) |
| 879 |
{ |
1021 |
{ |
| 880 |
@SuppressWarnings("unchecked") Comparable<Object> comparableObject = (Comparable<Object>)effectiveMax; |
1022 |
@SuppressWarnings("unchecked") |
| 881 |
if (effectiveMaxIsInclusive ? |
1023 |
Comparable<Object> comparableObject = (Comparable<Object>)effectiveMax; |
| 882 |
comparableObject.compareTo(value) < 0: |
1024 |
if (effectiveMaxIsInclusive ? comparableObject.compareTo(value) < 0 : comparableObject.compareTo(value) <= 0) |
| 883 |
comparableObject.compareTo(value) <= 0) |
|
|
| 884 |
{ |
1025 |
{ |
| 885 |
if (diagnostics != null) |
1026 |
if (diagnostics != null) |
| 886 |
{ |
1027 |
{ |
|
Lines 944-983
Link Here
|
| 944 |
result = false; |
1085 |
result = false; |
| 945 |
} |
1086 |
} |
| 946 |
} |
1087 |
} |
|
|
1088 |
|
| 1089 |
return result; |
| 1090 |
} |
| 1091 |
|
| 1092 |
public boolean validate(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) |
| 1093 |
{ |
| 1094 |
boolean result = validateDelegatedConstraints(eDataType, value, diagnostics, context); |
| 947 |
|
1095 |
|
| 948 |
if (itemType != null) |
1096 |
if (result || diagnostics != null) |
| 949 |
{ |
1097 |
{ |
| 950 |
EValidator rootValidator = getRootEValidator(context); |
1098 |
result &= validateSchemaConstraints(eDataType, value, diagnostics, context); |
| 951 |
for (Iterator<?> i = ((List<?>)value).iterator(); i.hasNext() && (result || diagnostics != null); ) |
1099 |
|
|
|
1100 |
if (itemType != null) |
| 1101 |
{ |
| 1102 |
EValidator rootValidator = getRootEValidator(context); |
| 1103 |
for (Iterator< ? > i = ((List< ? >)value).iterator(); i.hasNext() && (result || diagnostics != null);) |
| 1104 |
{ |
| 1105 |
result &= rootValidator.validate(itemType, i.next(), diagnostics, context); |
| 1106 |
} |
| 1107 |
return result; |
| 1108 |
} |
| 1109 |
else if (!memberTypes.isEmpty()) |
| 952 |
{ |
1110 |
{ |
| 953 |
result &= rootValidator.validate(itemType, i.next(), diagnostics, context); |
1111 |
EValidator rootValidator = getRootEValidator(context); |
|
|
1112 |
|
| 1113 |
for (EDataType memberType : memberTypes) |
| 1114 |
{ |
| 1115 |
if (rootValidator.validate(memberType, value, null, context)) |
| 1116 |
{ |
| 1117 |
return true; |
| 1118 |
} |
| 1119 |
} |
| 1120 |
for (EDataType memberType : memberTypes) |
| 1121 |
{ |
| 1122 |
if (memberType.isInstance(value)) |
| 1123 |
{ |
| 1124 |
return rootValidator.validate(memberType, value, diagnostics, context); |
| 1125 |
} |
| 1126 |
} |
| 1127 |
return false; |
| 1128 |
} |
| 1129 |
else |
| 1130 |
{ |
| 1131 |
return result; |
| 954 |
} |
1132 |
} |
| 955 |
return result; |
|
|
| 956 |
} |
1133 |
} |
| 957 |
else if (!memberTypes.isEmpty()) |
1134 |
|
|
|
1135 |
return result; |
| 1136 |
} |
| 1137 |
} |
| 1138 |
|
| 1139 |
public class DynamicEClassValidator |
| 1140 |
{ |
| 1141 |
protected boolean validateDelegatedInvariants(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) |
| 1142 |
{ |
| 1143 |
boolean result = true; |
| 1144 |
List<String> validationDelegates = EcoreUtil.getValidationDelegates(eClass.getEPackage()); |
| 1145 |
|
| 1146 |
if (!validationDelegates.isEmpty()) |
| 958 |
{ |
1147 |
{ |
| 959 |
EValidator rootValidator = getRootEValidator(context); |
1148 |
INVARIANTS: for (EOperation eOperation : eClass.getEOperations()) |
| 960 |
|
|
|
| 961 |
for (EDataType memberType : memberTypes) |
| 962 |
{ |
1149 |
{ |
| 963 |
if (rootValidator.validate(memberType, value, null, context)) |
1150 |
if (EcoreUtil.isInvariant(eOperation)) |
| 964 |
{ |
1151 |
{ |
| 965 |
return true; |
1152 |
for (String validationDelegate : validationDelegates) |
|
|
1153 |
{ |
| 1154 |
String expression = EcoreUtil.getAnnotation(eOperation, validationDelegate, "body"); |
| 1155 |
if (expression != null) |
| 1156 |
{ |
| 1157 |
result &= EObjectValidator.validate(eClass, eObject, diagnostics, context, validationDelegate, eOperation, expression, Diagnostic.ERROR, DIAGNOSTIC_SOURCE, 0); |
| 1158 |
if (!result && diagnostics == null) |
| 1159 |
break INVARIANTS; |
| 1160 |
} |
| 1161 |
} |
| 966 |
} |
1162 |
} |
| 967 |
} |
1163 |
} |
| 968 |
for (EDataType memberType : memberTypes) |
1164 |
} |
|
|
1165 |
|
| 1166 |
return result; |
| 1167 |
} |
| 1168 |
|
| 1169 |
protected boolean validateDelegatedConstraints(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) |
| 1170 |
{ |
| 1171 |
boolean result = true; |
| 1172 |
List<String> validationDelegates = EcoreUtil.getValidationDelegates(eClass.getEPackage()); |
| 1173 |
|
| 1174 |
if (!validationDelegates.isEmpty()) |
| 1175 |
{ |
| 1176 |
CONSTRAINTS: for (String constraint : EcoreUtil.getConstraints(eClass)) |
| 969 |
{ |
1177 |
{ |
| 970 |
if (memberType.isInstance(value)) |
1178 |
for (String validationDelegate : validationDelegates) |
| 971 |
{ |
1179 |
{ |
| 972 |
return rootValidator.validate(memberType, value, diagnostics, context); |
1180 |
String expression = EcoreUtil.getAnnotation(eClass, validationDelegate, constraint); |
|
|
1181 |
if (expression != null) |
| 1182 |
{ |
| 1183 |
result &= EObjectValidator.this.validate(eClass, eObject, diagnostics, context, validationDelegate, constraint, expression, Diagnostic.ERROR, DIAGNOSTIC_SOURCE, 0); |
| 1184 |
if (!result && diagnostics == null) |
| 1185 |
break CONSTRAINTS; |
| 1186 |
} |
| 973 |
} |
1187 |
} |
| 974 |
} |
1188 |
} |
| 975 |
return false; |
|
|
| 976 |
} |
1189 |
} |
| 977 |
else |
1190 |
|
|
|
1191 |
return result; |
| 1192 |
} |
| 1193 |
|
| 1194 |
public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) |
| 1195 |
{ |
| 1196 |
boolean result = validateDelegatedInvariants(eClass, eObject, diagnostics, context); |
| 1197 |
|
| 1198 |
if (result || diagnostics != null) |
| 978 |
{ |
1199 |
{ |
| 979 |
return result; |
1200 |
result &= validateDelegatedConstraints(eClass, eObject, diagnostics, context); |
|
|
1201 |
|
| 1202 |
if (result || diagnostics != null) |
| 1203 |
{ |
| 1204 |
List<EClass> eSuperTypes = eClass.getESuperTypes(); |
| 1205 |
result &= eSuperTypes.isEmpty() ? |
| 1206 |
validate_EveryDefaultConstraint(eObject, diagnostics, context) : |
| 1207 |
validate(eSuperTypes.get(0), eObject, diagnostics, context); |
| 1208 |
} |
| 980 |
} |
1209 |
} |
|
|
1210 |
|
| 1211 |
return result; |
| 981 |
} |
1212 |
} |
| 982 |
} |
1213 |
} |
| 983 |
|
1214 |
|
|
Lines 1202-1207
Link Here
|
| 1202 |
context)); |
1433 |
context)); |
| 1203 |
} |
1434 |
} |
| 1204 |
|
1435 |
|
|
|
1436 |
/** |
| 1437 |
* @since 2.6 |
| 1438 |
*/ |
| 1439 |
protected void reportConstraintDelegateViolation(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context, String constraint, int severity, String source, int code) |
| 1440 |
{ |
| 1441 |
diagnostics.add |
| 1442 |
(new BasicDiagnostic |
| 1443 |
(severity, |
| 1444 |
source, |
| 1445 |
code, |
| 1446 |
getString("_UI_GenericConstraint_diagnostic", new Object[] { constraint, getValueLabel(eDataType, value, context) }), |
| 1447 |
new Object [] { value })); |
| 1448 |
} |
| 1449 |
|
| 1450 |
/** |
| 1451 |
* @since 2.6 |
| 1452 |
*/ |
| 1453 |
protected void reportConstraintDelegateException(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context, String constraint, int severity, String source, int code, Throwable throwable) |
| 1454 |
{ |
| 1455 |
diagnostics.add |
| 1456 |
(new BasicDiagnostic |
| 1457 |
(severity, |
| 1458 |
source, |
| 1459 |
code, |
| 1460 |
getString("_UI_ConstraintDelegateException_diagnostic", new Object[] { constraint, getValueLabel(eDataType, value, context), throwable.getLocalizedMessage() }), |
| 1461 |
new Object [] { value })); |
| 1462 |
} |
| 1463 |
|
| 1464 |
/** |
| 1465 |
* @since 2.6 |
| 1466 |
*/ |
| 1467 |
protected void reportConstraintDelegateNotFound(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context, String constraint, int severity, String source, int code, String validationDelegate) |
| 1468 |
{ |
| 1469 |
diagnostics.add |
| 1470 |
(new BasicDiagnostic |
| 1471 |
(severity, |
| 1472 |
source, |
| 1473 |
code, |
| 1474 |
getString("_UI_ConstraintDelegateNotFound_diagnostic", new Object[] { constraint, getValueLabel(eDataType, value, context), validationDelegate }), |
| 1475 |
new Object [] { value })); |
| 1476 |
} |
| 1477 |
|
| 1478 |
/** |
| 1479 |
* @since 2.6 |
| 1480 |
*/ |
| 1481 |
protected void reportConstraintDelegateViolation(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, String constraint, int severity, String source, int code) |
| 1482 |
{ |
| 1483 |
diagnostics.add |
| 1484 |
(new BasicDiagnostic |
| 1485 |
(severity, |
| 1486 |
source, |
| 1487 |
code, |
| 1488 |
getString("_UI_GenericConstraint_diagnostic", new Object[] { constraint, getObjectLabel(eObject, context) }), |
| 1489 |
new Object [] { eObject })); |
| 1490 |
} |
| 1491 |
|
| 1492 |
/** |
| 1493 |
* @since 2.6 |
| 1494 |
*/ |
| 1495 |
protected void reportConstraintDelegateException(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, String constraint, int severity, String source, int code, Throwable throwable) |
| 1496 |
{ |
| 1497 |
diagnostics.add |
| 1498 |
(new BasicDiagnostic |
| 1499 |
(severity, |
| 1500 |
source, |
| 1501 |
code, |
| 1502 |
getString("_UI_ConstraintDelegateException_diagnostic", new Object[] { constraint, getObjectLabel(eObject, context), throwable.getLocalizedMessage() }), |
| 1503 |
new Object [] { eObject })); |
| 1504 |
} |
| 1505 |
|
| 1506 |
/** |
| 1507 |
* @since 2.6 |
| 1508 |
*/ |
| 1509 |
protected void reportConstraintDelegateNotFound(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, String constraint, int severity, String source, int code, String validationDelegate) |
| 1510 |
{ |
| 1511 |
diagnostics.add |
| 1512 |
(new BasicDiagnostic |
| 1513 |
(severity, |
| 1514 |
source, |
| 1515 |
code, |
| 1516 |
getString("_UI_ConstraintDelegateNotFound_diagnostic", new Object[] { constraint, getObjectLabel(eObject, context), validationDelegate }), |
| 1517 |
new Object [] { eObject })); |
| 1518 |
} |
| 1519 |
|
| 1520 |
/** |
| 1521 |
* @since 2.6 |
| 1522 |
*/ |
| 1523 |
protected static void reportInvariantDelegateViolation(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, EOperation invariant, int severity, String source, int code) |
| 1524 |
{ |
| 1525 |
diagnostics.add |
| 1526 |
(new BasicDiagnostic |
| 1527 |
(severity, |
| 1528 |
source, |
| 1529 |
code, |
| 1530 |
EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { invariant.getName(), getObjectLabel(eObject, context) }), |
| 1531 |
new Object [] { eObject })); |
| 1532 |
} |
| 1533 |
|
| 1534 |
/** |
| 1535 |
* @since 2.6 |
| 1536 |
*/ |
| 1537 |
protected static void reportInvariantDelegateException(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, EOperation invariant, int severity, String source, int code, Throwable throwable) |
| 1538 |
{ |
| 1539 |
diagnostics.add |
| 1540 |
(new BasicDiagnostic |
| 1541 |
(severity, |
| 1542 |
source, |
| 1543 |
code, |
| 1544 |
EcorePlugin.INSTANCE.getString("_UI_InvariantDelegateException_diagnostic", new Object[] { invariant.getName(), getObjectLabel(eObject, context), throwable.getLocalizedMessage() }), |
| 1545 |
new Object [] { eObject })); |
| 1546 |
} |
| 1547 |
|
| 1548 |
/** |
| 1549 |
* @since 2.6 |
| 1550 |
*/ |
| 1551 |
protected static void reportInvariantDelegateNotFound(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, EOperation invariant, int severity, String source, int code, String validationDelegate) |
| 1552 |
{ |
| 1553 |
diagnostics.add |
| 1554 |
(new BasicDiagnostic |
| 1555 |
(severity, |
| 1556 |
source, |
| 1557 |
code, |
| 1558 |
EcorePlugin.INSTANCE.getString("_UI_InvariantDelegateNotFound_diagnostic", new Object[] { invariant.getName(), getObjectLabel(eObject, context), validationDelegate }), |
| 1559 |
new Object [] { eObject })); |
| 1560 |
} |
| 1561 |
|
| 1205 |
protected static Collection<Object> wrapEnumerationValues(Object [] values) |
1562 |
protected static Collection<Object> wrapEnumerationValues(Object [] values) |
| 1206 |
{ |
1563 |
{ |
| 1207 |
return java.util.Arrays.asList(values); |
1564 |
return java.util.Arrays.asList(values); |
|
Lines 1471-1476
Link Here
|
| 1471 |
} |
1828 |
} |
| 1472 |
|
1829 |
|
| 1473 |
/** |
1830 |
/** |
|
|
1831 |
* @since 2.6 |
| 1832 |
*/ |
| 1833 |
protected boolean isEcoreString(String key) |
| 1834 |
{ |
| 1835 |
return "_UI_GenericConstraint_diagnostic".equals(key) || "_UI_GenericInvariant_diagnostic".equals(key) |
| 1836 |
|| "_UI_ConstraintDelegateException_diagnostic".equals(key) || "_UI_InvariantDelegateException_diagnostic".equals(key) |
| 1837 |
|| "_UI_ConstraintDelegateNotFound_diagnostic".equals(key) || "_UI_InvariantDelegateNotFound_diagnostic".equals(key); |
| 1838 |
} |
| 1839 |
|
| 1840 |
/** |
| 1474 |
* Returns a translated message with the given substitutions. |
1841 |
* Returns a translated message with the given substitutions. |
| 1475 |
* The {@link #getResourceLocator() resource locator} is used. |
1842 |
* The {@link #getResourceLocator() resource locator} is used. |
| 1476 |
* @param key the key for the message. |
1843 |
* @param key the key for the message. |
|
Lines 1480-1486
Link Here
|
| 1480 |
*/ |
1847 |
*/ |
| 1481 |
protected String getString(String key, Object [] substitutions) |
1848 |
protected String getString(String key, Object [] substitutions) |
| 1482 |
{ |
1849 |
{ |
| 1483 |
return getString("_UI_GenericConstraint_diagnostic".equals(key) ? getEcoreResourceLocator() : getResourceLocator(), key, substitutions); |
1850 |
return getString(isEcoreString(key) ? getEcoreResourceLocator() : getResourceLocator(), key, substitutions); |
| 1484 |
} |
1851 |
} |
| 1485 |
|
1852 |
|
| 1486 |
/** |
1853 |
/** |