use of org.eclipse.wst.xml.search.editor.validation.IValidationResult in project liferay-ide by liferay.
the class LiferayBaseValidator method validateReferenceToAllType.
/**
* default implementation of all kinds of validation
*/
protected void validateReferenceToAllType(IXMLReferenceTo referenceTo, IDOMNode node, IFile file, IValidator validator, IReporter reporter, boolean batchMode) {
String nodeValue = DOMUtils.getNodeValue(node);
IValidationResult result = referenceTo.getSearcher().searchForValidation(node, nodeValue, -1, -1, file, referenceTo);
if (result != null) {
boolean addMessage = false;
int nbElements = result.getNbElements();
if (nbElements > 0) {
if ((nbElements > 1) && !isMultipleElementsAllowed(node, nbElements)) {
addMessage = true;
}
} else {
addMessage = true;
}
if (addMessage) {
ValidationType validationType = getValidationType(referenceTo, nbElements);
int severity = getServerity(validationType, file);
String liferayPluginValidationType = getLiferayPluginValidationType(validationType, file);
if (severity != ValidationMessage.IGNORE) {
String messageText = getMessageText(validationType, referenceTo, node, file);
addMessage(node, file, validator, reporter, batchMode, messageText, severity, liferayPluginValidationType, referenceTo.getQuerySpecificationId());
}
}
}
}
use of org.eclipse.wst.xml.search.editor.validation.IValidationResult in project liferay-ide by liferay.
the class LiferayJspValidator method validateReferenceToProperty.
@Override
protected void validateReferenceToProperty(IXMLReferenceTo referenceTo, IDOMNode node, IFile file, IValidator validator, IReporter reporter, boolean batchMode) {
String languageKey = DOMUtils.getNodeValue(node);
if (file.exists() && !languageKey.contains(_jsp_rag_start) && !languageKey.contains(_jsp_rag_end)) {
IValidationResult result = referenceTo.getSearcher().searchForValidation(node, languageKey, -1, -1, file, referenceTo);
if (result != null) {
boolean addMessage = false;
int nbElements = result.getNbElements();
if (nbElements > 0) {
if ((nbElements > 1) && !isMultipleElementsAllowed(node, nbElements)) {
addMessage = true;
}
} else {
addMessage = true;
}
if (addMessage) {
Properties properties = PortalLanguagePropertiesCacheUtil.getPortalLanguageProperties(LiferayCore.create(file.getProject()));
if (properties != null) {
try {
String languageValue = (String) properties.get(languageKey);
if (!languageValue.equals("")) {
addMessage = false;
}
} catch (Exception e) {
}
}
if (addMessage) {
ValidationType validationType = getValidationType(referenceTo, nbElements);
int severity = getServerity(validationType, file);
if (severity != ValidationMessage.IGNORE) {
String liferayPluginValidationType = getLiferayPluginValidationType(validationType, file);
String querySpecificationId = referenceTo.getQuerySpecificationId();
String messageText = getMessageText(validationType, referenceTo, node, file);
addMessage(node, file, validator, reporter, batchMode, messageText, severity, liferayPluginValidationType, querySpecificationId);
}
}
}
}
}
}
Aggregations