use of org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage in project webtools.sourceediting by eclipse.
the class Validator2 method validate.
@Override
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
/*
* String s; switch(kind) { case IResourceDelta.ADDED: s = "added"; break; case IResourceDelta.CHANGED: s = "CHANGED"; break; case IResourceDelta.CONTENT: s = "CONTENT"; break; case
* IResourceDelta.REMOVED: s = "REMOVED"; break; default: s = "other"; } System.out.println(s);
*/
ValidationResult result = new ValidationResult();
if (resource.getType() == IResource.FILE) {
IFile file = (IFile) resource;
ValidationReport report = doValidation(file, kind, state, monitor);
StylesheetModel stylesheet = XSLCore.getInstance().getStylesheet(file);
IFile[] dependencies = stylesheet.getFileDependencies().toArray(new IFile[0]);
result.setDependsOn(dependencies);
for (ValidationMessage message : report.getValidationMessages()) {
XSLValidationMessage xslMsg = (XSLValidationMessage) message;
ValidatorMessage msg = ValidatorMessage.create(message.getMessage(), resource);
// $NON-NLS-1$
msg.setAttribute("lineNumber", xslMsg.getLineNumber());
// $NON-NLS-1$
msg.setAttribute("severity", xslMsg.getSeverity());
result.add(msg);
}
}
return result;
}
use of org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage in project tmdm-studio-se by Talend.
the class ViewValidator method validate.
@Override
public ValidationReport validate(String uri, InputStream inputstream, NestedValidatorContext context) {
ViewValidationReport viewValidationReport = new ViewValidationReport(uri);
// $NON-NLS-1$
String fileName = uri.substring(uri.lastIndexOf("/") + 1);
String viewName = getViewName(fileName);
// $NON-NLS-1$ //$NON-NLS-2$
viewName = viewName.replace("$", "#");
IRepositoryViewObject viewObj = RepositoryResourceUtil.findViewObjectByName(IServerObjectRepositoryType.TYPE_VIEW, viewName);
if (viewObj != null) {
WSViewItem item = (WSViewItem) viewObj.getProperty().getItem();
WSViewE view = (WSViewE) item.getMDMServerObject();
EList<WSWhereConditionE> whereConditions = view.getWhereConditions();
if (whereConditions != null && whereConditions.size() > 0) {
for (WSWhereConditionE conditionE : whereConditions) {
String userVarValue = conditionE.getRightValueOrPath();
boolean isValid = UserVarValueValidator.validate(userVarValue);
if (!isValid) {
String validateMsg = Messages.bind(Messages.ViewValidator_error, userVarValue, viewName);
viewValidationReport.addValidationMessage(new ValidationMessage(validateMsg, -1, -1));
}
}
}
}
return viewValidationReport;
}
Aggregations