Class EvlValidator
- java.lang.Object
-
- org.eclipse.epsilon.evl.emf.validation.EvlValidator
-
- All Implemented Interfaces:
org.eclipse.emf.ecore.EValidator
public class EvlValidator extends java.lang.Object implements org.eclipse.emf.ecore.EValidator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceEvlValidator.ValidationProblemListener-
Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.EValidator
org.eclipse.emf.ecore.EValidator.Descriptor, org.eclipse.emf.ecore.EValidator.PatternMatcher, org.eclipse.emf.ecore.EValidator.Registry, org.eclipse.emf.ecore.EValidator.SubstitutionLabelProvider, org.eclipse.emf.ecore.EValidator.ValidationDelegate
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringbundleIdprotected org.eclipse.emf.ecore.resource.ResourcecurrentResourcestatic java.lang.StringDEFAULT_MODEL_NAMEprotected org.eclipse.emf.common.util.DiagnosticChaindiagnosticsprotected java.util.Set<java.lang.String>diagnosticVariablesprotected java.util.Collection<org.eclipse.emf.ecore.EPackage>ePackagesCollection of all packages that are available to this validatorprotected java.lang.StringePackageUriprotected java.util.Collection<org.eclipse.emf.ecore.EObject>historyprotected booleanlogErrorsprotected java.lang.StringmodelNameprotected IEvlModulemoduleprotected EmfPrettyPrinterprinterprotected java.util.Collection<EvlValidator.ValidationProblemListener>problemListenersprotected ValidationResultsresultsprotected booleanshowErrorDialogprotected java.net.URIsourcestatic java.lang.StringVALIDATION_MONITORKey for the validation context, that (when provided) holds a IProgressMonitor object
-
Constructor Summary
Constructors Constructor Description EvlValidator()Note when using this constructor, make sure to callinitialise(URI, String, String, String)afterwardsEvlValidator(java.net.URI source, java.lang.String modelName, java.lang.String ePackageUri, java.lang.String bundleId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAdditionalPackage(java.lang.String packageUri)Make an additional package available to be used by this validator.voidaddDiagnosticianVariable(java.lang.String name)Indicates that the value of the entry of theDiagnosticiancontextMapwith the specifiednameshould be published as a global variable in the EVL script.protected voidaddMarkers(java.lang.String msgPrefix, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.common.util.DiagnosticChain diagnostics)voidaddValidationProblemListener(EvlValidator.ValidationProblemListener listener)protected org.eclipse.emf.common.util.DiagnosticcreateDiagnostic(java.lang.String msgPrefix, UnsatisfiedConstraint unsatisfied)voidinitialise(java.net.URI source, java.lang.String modelName, java.lang.String ePackageUri, java.lang.String bundleId)booleanisLogErrors()This method is used by the default implementation oflogException()booleanisShowErrorDialog()booleanlogException(java.lang.Exception exception)Method to determine whether the given exception needs to be logged.protected IEvlModulenewModule()booleanremoveValidationProblemListener(EvlValidator.ValidationProblemListener listener)voidsetLogErrors(boolean logErrors)Sets whether errors need to be logged or notvoidsetShowErrorDialog(boolean showErrorDialog)Sets whether an error dialog needs to be shownbooleanvalidate(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)booleanvalidate(org.eclipse.emf.ecore.EDataType dataType, java.lang.Object value, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)booleanvalidate(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)protected voidvalidate(org.eclipse.emf.ecore.resource.Resource resource, java.util.Map<java.lang.Object,java.lang.Object> context)
-
-
-
Field Detail
-
diagnosticVariables
protected java.util.Set<java.lang.String> diagnosticVariables
-
module
protected IEvlModule module
-
source
protected java.net.URI source
-
printer
protected EmfPrettyPrinter printer
-
currentResource
protected org.eclipse.emf.ecore.resource.Resource currentResource
-
results
protected ValidationResults results
-
history
protected java.util.Collection<org.eclipse.emf.ecore.EObject> history
-
modelName
protected java.lang.String modelName
-
ePackageUri
protected java.lang.String ePackageUri
-
bundleId
protected java.lang.String bundleId
-
showErrorDialog
protected boolean showErrorDialog
-
logErrors
protected boolean logErrors
-
problemListeners
protected java.util.Collection<EvlValidator.ValidationProblemListener> problemListeners
-
diagnostics
protected org.eclipse.emf.common.util.DiagnosticChain diagnostics
-
ePackages
protected java.util.Collection<org.eclipse.emf.ecore.EPackage> ePackages
Collection of all packages that are available to this validator
-
DEFAULT_MODEL_NAME
public static final java.lang.String DEFAULT_MODEL_NAME
- See Also:
- Constant Field Values
-
VALIDATION_MONITOR
public static final java.lang.String VALIDATION_MONITOR
Key for the validation context, that (when provided) holds a IProgressMonitor object- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EvlValidator
public EvlValidator()
Note when using this constructor, make sure to callinitialise(URI, String, String, String)afterwards
-
EvlValidator
public EvlValidator(java.net.URI source, java.lang.String modelName, java.lang.String ePackageUri, java.lang.String bundleId)
-
-
Method Detail
-
initialise
public void initialise(java.net.URI source, java.lang.String modelName, java.lang.String ePackageUri, java.lang.String bundleId)
-
addDiagnosticianVariable
public void addDiagnosticianVariable(java.lang.String name)
Indicates that the value of the entry of the
DiagnosticiancontextMapwith the specifiednameshould be published as a global variable in the EVL script. If the context map does not contain an entry with the specifiedname, the variable will be set tonull.Note: this map is received through the
validatemethods in this class.
-
addAdditionalPackage
public void addAdditionalPackage(java.lang.String packageUri)
Make an additional package available to be used by this validator.- Parameters:
packageUri- Namespace URI of the package
-
validate
public boolean validate(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)- Specified by:
validatein interfaceorg.eclipse.emf.ecore.EValidator
-
validate
public boolean validate(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)- Specified by:
validatein interfaceorg.eclipse.emf.ecore.EValidator
-
validate
public boolean validate(org.eclipse.emf.ecore.EDataType dataType, java.lang.Object value, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)- Specified by:
validatein interfaceorg.eclipse.emf.ecore.EValidator
-
createDiagnostic
protected org.eclipse.emf.common.util.Diagnostic createDiagnostic(java.lang.String msgPrefix, UnsatisfiedConstraint unsatisfied)
-
newModule
protected IEvlModule newModule()
- Returns:
- A new
IEvlModule - Since:
- 1.6
-
validate
protected void validate(org.eclipse.emf.ecore.resource.Resource resource, java.util.Map<java.lang.Object,java.lang.Object> context)
-
addMarkers
protected void addMarkers(java.lang.String msgPrefix, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.common.util.DiagnosticChain diagnostics)
-
isShowErrorDialog
public boolean isShowErrorDialog()
- Returns:
- true if an error dialog needs to be shown when an error occurs
-
setShowErrorDialog
public void setShowErrorDialog(boolean showErrorDialog)
Sets whether an error dialog needs to be shown- See Also:
isShowErrorDialog()
-
logException
public boolean logException(java.lang.Exception exception)
Method to determine whether the given exception needs to be logged. Can be overridden to filter out certain types of exceptions (e.g. when the user cancelled the validation)- Returns:
- true if error needs to be logged
-
isLogErrors
public boolean isLogErrors()
This method is used by the default implementation oflogException()- Returns:
- true if errors need to be logged
- See Also:
logException(Exception)
-
setLogErrors
public void setLogErrors(boolean logErrors)
Sets whether errors need to be logged or not- See Also:
isLogErrors()
-
addValidationProblemListener
public void addValidationProblemListener(EvlValidator.ValidationProblemListener listener)
-
removeValidationProblemListener
public boolean removeValidationProblemListener(EvlValidator.ValidationProblemListener listener)
-
-