revert accidental removal of the workspace runnable
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/ValidateAction.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/ValidateAction.java
index 9aafd26..f5aaa73 100644
--- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/ValidateAction.java
+++ b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/ValidateAction.java
@@ -14,11 +14,15 @@
import java.io.InputStream;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.xml.core.internal.validation.XMLValidationReport;
import org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage;
+import org.eclipse.wst.xml.ui.internal.Logger;
/**
@@ -27,7 +31,7 @@
* - manages Marker creation based on the results of the validation
* - (optionally) displays dialog to summarize the results of validation
*
- * @author Craig Saler, IBM
+ * @author Craig Salter, IBM
* @author Lawrence Mandel, IBM
*/
public class ValidateAction extends org.eclipse.wst.xml.ui.internal.validation.core.ValidateAction
@@ -75,65 +79,98 @@
}
}
-
- protected void validate(final IFile file) {
- XMLValidationOutcome valoutcome = new XMLValidationOutcome();
- IPath path = file.getLocation();
- final String uri = createURIForFilePath(path.toString());
+ protected void validate(final IFile file)
+ {
+ final XMLValidationOutcome valoutcome = new XMLValidationOutcome();
+ IPath path = file.getLocation();
+ final String uri = createURIForFilePath(path.toString());
- XMLValidator validator = XMLValidator.getInstance();
+ IWorkspaceRunnable op = new IWorkspaceRunnable()
+ {
+ public void run(IProgressMonitor progressMonitor) throws CoreException
+ {
+ XMLValidator validator = XMLValidator.getInstance();
- clearMarkers(file);
- XMLValidationReport valreport = null;
- if (inputStream != null) {
- valreport = validator.validate(uri, inputStream);
- }
- else {
- valreport = validator.validate(uri);
- }
+ clearMarkers(file);
+ XMLValidationReport valreport = null;
+ if (inputStream != null)
+ {
+ valreport = validator.validate(uri, inputStream);
+ }
+ else
+ {
+ valreport = validator.validate(uri);
+ }
+
+ valoutcome.isValid = valreport.isValid();
+ if(valreport.getValidationMessages().length == 0)
+ {
+ valoutcome.hasMessages = false;
+ }
+ else
+ {
+ valoutcome.hasMessages = true;
+ }
+ valoutcome.isGrammarEncountered = valreport.isGrammarEncountered();
+ createMarkers(file, valreport.getValidationMessages());
+
+ file.setSessionProperty(ValidationMessage.ERROR_MESSAGE_MAP_QUALIFIED_NAME, valreport.getNestedMessages());
+ }
+ };
- valoutcome.isValid = valreport.isValid();
- if (valreport.getValidationMessages().length == 0) {
- valoutcome.hasMessages = false;
- }
- else {
- valoutcome.hasMessages = true;
- }
- valoutcome.isGrammarEncountered = valreport.isGrammarEncountered();
- createMarkers(file, valreport.getValidationMessages());
+
+ try
+ {
+ ResourcesPlugin.getWorkspace().run(op, null);
+// String internalErrorMessage = null;
+// if (validator.getInternalError() != null)
+// {
+// internalErrorMessage = XMLValidatePlugin.getString("_UI_VALIDATION_INTERNAL_ERROR");
+// internalErrorMessage += " : " + validator.getInternalError();
+// }
+
+ if (showDialog)
+ {
+ // The file is invalid.
+ if (!valoutcome.isValid)
+ {
+ String title = resourceBundle.getString(_UI_VALIDATION_FAILED);
+ String message = resourceBundle.getString(_UI_THE_XML_FILE_IS_NOT_VALID);
+ openErrorDialog(title, message);
+ }
+ else
+ {
+ // The file is valid however warnings were issued.
+ if(valoutcome.hasMessages)
+ {
+ String title = resourceBundle.getString(_UI_VALIDATION_SUCEEDED);
+ String message = valoutcome.isGrammarEncountered ?
+ resourceBundle.getString(_UI_THE_XML_FILE_IS_VALID_WITH_WARNINGS) :
+ resourceBundle.getString(_UI_THE_XML_FILE_IS_WELL_FORMED_WITH_WARNINGS) +
+ resourceBundle.getString(_UI_NO_GRAMMAR_WARNING);
+
+ openWarningDialog(title, message);
+ }
+ // The file is valid with no warnings.
+ else
+ {
+ String title = resourceBundle.getString(_UI_VALIDATION_SUCEEDED);
+ String message = valoutcome.isGrammarEncountered ?
+ resourceBundle.getString(_UI_THE_XML_FILE_IS_VALID) :
+ resourceBundle.getString(_UI_THE_XML_FILE_IS_WELL_FORMED) +
+ resourceBundle.getString(_UI_NO_GRAMMAR_WARNING);
+
+ openValidDialog(title, message);
+ }
+ }
+ }
+ }
- try {
- file.setSessionProperty(ValidationMessage.ERROR_MESSAGE_MAP_QUALIFIED_NAME, valreport.getNestedMessages());
- }
- catch (CoreException e) {
- }
-
-
- if (showDialog) {
- // The file is invalid.
- if (!valoutcome.isValid) {
- String title = resourceBundle.getString(_UI_VALIDATION_FAILED);
- String message = resourceBundle.getString(_UI_THE_XML_FILE_IS_NOT_VALID);
- openErrorDialog(title, message);
- }
- else {
- // The file is valid however warnings were issued.
- if (valoutcome.hasMessages) {
- String title = resourceBundle.getString(_UI_VALIDATION_SUCEEDED);
- String message = valoutcome.isGrammarEncountered ? resourceBundle.getString(_UI_THE_XML_FILE_IS_VALID_WITH_WARNINGS) : resourceBundle.getString(_UI_THE_XML_FILE_IS_WELL_FORMED_WITH_WARNINGS) + resourceBundle.getString(_UI_NO_GRAMMAR_WARNING);
-
- openWarningDialog(title, message);
- }
- // The file is valid with no warnings.
- else {
- String title = resourceBundle.getString(_UI_VALIDATION_SUCEEDED);
- String message = valoutcome.isGrammarEncountered ? resourceBundle.getString(_UI_THE_XML_FILE_IS_VALID) : resourceBundle.getString(_UI_THE_XML_FILE_IS_WELL_FORMED) + resourceBundle.getString(_UI_NO_GRAMMAR_WARNING);
-
- openValidDialog(title, message);
- }
- }
- }
- }
+ catch (CoreException e)
+ {
+ Logger.logException(e);
+ }
+ }
/**
* An XML specific validation outcome that includes whether a grammar