[254647] [ui]Validation should be triggered when changing the setting of the "indicate if grammar is not specified" preference settings
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java index 5ff3602..f3a4da8 100644 --- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java +++ b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java
@@ -75,10 +75,13 @@ { // validationstart was not called, so manually setup and tear down nestedcontext = getNestedContext(state, true); + nestedcontext.setProject(file.getProject()); setupValidation(nestedcontext); teardownRequired = true; } - nestedcontext.setProject(file.getProject()); + else { + nestedcontext.setProject(file.getProject()); + } validate(file, null, result, reporter, nestedcontext); if (teardownRequired)
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/Validator.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/Validator.java index 1824ab4..55e2ba0 100644 --- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/Validator.java +++ b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/Validator.java
@@ -38,6 +38,7 @@ { private static final String XML_VALIDATOR_CONTEXT = "org.eclipse.wst.xml.core.validatorContext"; //$NON-NLS-1$ protected int indicateNoGrammar = 0; + private IScopeContext[] fPreferenceScopes = null; /** * Set any preferences for XML validation. * @@ -46,15 +47,18 @@ protected void setupValidation(NestedValidatorContext context) { super.setupValidation(context); - //indicateNoGrammar = XMLCorePlugin.getDefault().getPluginPreferences().getInt(); + fPreferenceScopes = createPreferenceScopes(context); + indicateNoGrammar = Platform.getPreferencesService().getInt(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.INDICATE_NO_GRAMMAR, 0, fPreferenceScopes); } protected IScopeContext[] createPreferenceScopes(NestedValidatorContext context) { - final IProject project = context.getProject(); - if (project != null && project.isAccessible()) { - final ProjectScope projectScope = new ProjectScope(project); - if (projectScope.getNode(XMLCorePlugin.getDefault().getBundle().getSymbolicName()).getBoolean(XMLCorePreferenceNames.USE_PROJECT_SETTINGS, false)) - return new IScopeContext[]{projectScope, new InstanceScope(), new DefaultScope()}; + if (context != null) { + final IProject project = context.getProject(); + if (project != null && project.isAccessible()) { + final ProjectScope projectScope = new ProjectScope(project); + if (projectScope.getNode(XMLCorePlugin.getDefault().getBundle().getSymbolicName()).getBoolean(XMLCorePreferenceNames.USE_PROJECT_SETTINGS, false)) + return new IScopeContext[]{projectScope, new InstanceScope(), new DefaultScope()}; + } } return new IScopeContext[]{new InstanceScope(), new DefaultScope()}; } @@ -72,16 +76,13 @@ XMLValidator validator = XMLValidator.getInstance(); XMLValidationConfiguration configuration = new XMLValidationConfiguration(); - final IScopeContext[] preferenceScopes = createPreferenceScopes(context); - final IPreferencesService preferencesService = Platform.getPreferencesService(); - indicateNoGrammar = preferencesService.getInt(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.INDICATE_NO_GRAMMAR, 0, preferenceScopes); - try { //Preferences pluginPreferences = XMLCorePlugin.getDefault().getPluginPreferences(); configuration.setFeature(XMLValidationConfiguration.INDICATE_NO_GRAMMAR, indicateNoGrammar); - configuration.setFeature(XMLValidationConfiguration.USE_XINCLUDE, preferencesService.getBoolean(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.USE_XINCLUDE, false, preferenceScopes)); - configuration.setFeature(XMLValidationConfiguration.HONOUR_ALL_SCHEMA_LOCATIONS, preferencesService.getBoolean(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, true, preferenceScopes)); + final IPreferencesService preferencesService = Platform.getPreferencesService(); + configuration.setFeature(XMLValidationConfiguration.USE_XINCLUDE, preferencesService.getBoolean(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.USE_XINCLUDE, false, fPreferenceScopes)); + configuration.setFeature(XMLValidationConfiguration.HONOUR_ALL_SCHEMA_LOCATIONS, preferencesService.getBoolean(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, true, fPreferenceScopes)); } catch(Exception e) {