Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 36537 Details for
Bug 132228
Provide support for alternate validator implementations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Initial contribution
ValidatorDelegatePatch.txt (text/plain), 81.57 KB, created by
Valentin Baciu
on 2006-03-17 18:25:39 EST
(
hide
)
Description:
Initial contribution
Filename:
MIME Type:
Creator:
Valentin Baciu
Created:
2006-03-17 18:25:39 EST
Size:
81.57 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.validation >Index: validate/org/eclipse/wst/validation/internal/ProjectConfiguration.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/validation/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ProjectConfiguration.java,v >retrieving revision 1.12 >diff -u -r1.12 ProjectConfiguration.java >--- validate/org/eclipse/wst/validation/internal/ProjectConfiguration.java 17 Mar 2006 15:34:57 -0000 1.12 >+++ validate/org/eclipse/wst/validation/internal/ProjectConfiguration.java 17 Mar 2006 23:24:49 -0000 >@@ -11,6 +11,7 @@ > package org.eclipse.wst.validation.internal; > > import java.lang.reflect.InvocationTargetException; >+import java.util.Map; > import java.util.logging.Level; > > import org.eclipse.core.resources.IMarker; >@@ -19,6 +20,7 @@ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.jem.util.logger.LogEntry; > import org.eclipse.jem.util.logger.proxy.Logger; >+import org.eclipse.wst.validation.internal.delegates.ValidatorDelegateDescriptor; > import org.eclipse.wst.validation.internal.plugin.ValidationPlugin; > > >@@ -146,6 +148,17 @@ > return super.getValidators(); > } > >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.wst.validation.internal.ValidationConfiguration#getDelegatingValidators() >+ */ >+ public Map getDelegatingValidators() throws InvocationTargetException { >+ if (useGlobalPreference()) { >+ return ConfigurationManager.getManager().getGlobalConfiguration().getDelegatingValidators(); >+ } >+ return super.getDelegatingValidators(); >+ } >+ > /** > * @see org.eclipse.wst.validation.internal.operations.internal.attribute.ValidationConfiguration#getEnabledIncrementalValidators(boolean) > */ >@@ -266,6 +279,7 @@ > > setEnabledManualValidators(gp.getManualEnabledValidators()); > setEnabledBuildValidators(gp.getBuildEnabledValidators()); >+ setDelegatingValidators(gp.getDelegatingValidators()); > > // except for this field, which is unique to the project preferences > setDoesProjectOverride(getDoesProjectOverrideDefault()); >@@ -276,6 +290,7 @@ > GlobalConfiguration gp = ConfigurationManager.getManager().getGlobalConfiguration(); > setEnabledManualValidators(gp.getManualEnabledValidators()); > setEnabledBuildValidators(gp.getBuildEnabledValidators()); >+ setDelegatingValidators(gp.getDelegatingValidators()); > } > > /** >@@ -464,6 +479,21 @@ > return false; > } > >+ public boolean haveDelegatesChanged(Map oldDelegates, boolean allow) throws InvocationTargetException { >+ >+ if (super.haveDelegatesChanged(oldDelegates)) { >+ return true; >+ } >+ >+ if (allow) { >+ Map projDelegates = super.getDelegatingValidators(); >+ GlobalConfiguration gp = ConfigurationManager.getManager().getGlobalConfiguration(); >+ return gp.haveDelegatesChanged(projDelegates); >+ } >+ >+ return false; >+ } >+ > > /** > * @see org.eclipse.wst.validation.internal.operations.internal.attribute.ValidationConfiguration#deserialize(String) >@@ -580,4 +610,12 @@ > } > return super.isDisableAllValidation(); > } >+ >+ public ValidatorDelegateDescriptor getDelegateDescriptor(ValidatorMetaData vmd) throws InvocationTargetException { >+ if (useGlobalPreference()) { >+ return ConfigurationManager.getManager().getGlobalConfiguration().getDelegateDescriptor(vmd); >+ } >+ >+ return super.getDelegateDescriptor(vmd); >+ } > } >\ No newline at end of file >Index: validate/org/eclipse/wst/validation/internal/GlobalConfiguration.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/validation/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/GlobalConfiguration.java,v >retrieving revision 1.9 >diff -u -r1.9 GlobalConfiguration.java >--- validate/org/eclipse/wst/validation/internal/GlobalConfiguration.java 21 Feb 2006 22:19:59 -0000 1.9 >+++ validate/org/eclipse/wst/validation/internal/GlobalConfiguration.java 17 Mar 2006 23:24:49 -0000 >@@ -63,10 +63,11 @@ > _canProjectsOverride = can; > } > >- public void resetToDefault() { >+ public void resetToDefault() throws InvocationTargetException { > setDisableAllValidation(getDisableValidationDefault()); > setEnabledValidators(getEnabledValidatorsDefault()); > setCanProjectsOverride(getCanProjectsOverrideDefault()); >+ setDefaultDelegates(getValidators()); > } > > /** >Index: validate/org/eclipse/wst/validation/internal/ConfigurationConstants.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/validation/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ConfigurationConstants.java,v >retrieving revision 1.12 >diff -u -r1.12 ConfigurationConstants.java >--- validate/org/eclipse/wst/validation/internal/ConfigurationConstants.java 15 Feb 2006 21:48:01 -0000 1.12 >+++ validate/org/eclipse/wst/validation/internal/ConfigurationConstants.java 17 Mar 2006 23:24:49 -0000 >@@ -38,7 +38,7 @@ > public static final int DEPTH_INFINITE = IResource.DEPTH_INFINITE; > public static final int DEPTH_ZERO = IResource.DEPTH_ZERO; > /* package */static final String ELEMENT_SEPARATOR = ";"; //$NON-NLS-1$ // separates the name of one IValidator from the next in the list of enabled validators for a project or preference >- >+ static final String DELEGATES_SEPARATOR = "="; //$NON-NLS-1$ // Separates the delegating validator id from the delegate validator id in the list of delegates > // The following values must match the attributes in the preference marker as shown in > // plugin.xml > // Even though the plugin.xml values are not used to create new Preference or Project markers, >@@ -46,6 +46,7 @@ > // These are the QualifiedNames used to persist the user's settings. > /* package */static final String ENABLED_MANUAL_VALIDATORS = "enabledManualValidatorList"; //$NON-NLS-1$ // String > /* package */static final String ENABLED_BUILD_VALIDATORS = "enabledBuildValidatorList"; //$NON-NLS-1$ // String >+ /* package */static final String DELEGATE_VALIDATORS = "delegateValidatorList"; //$NON-NLS-1$ // String > public static final String J2EE_PLUGIN_ID = "org.eclipse.jst.j2ee"; //$NON-NLS-1$ // For 4.03, this is the plugin id that the validation constants were declared in. > /* package */static final String MAXNUMMESSAGES = "maxNumMessages"; //$NON-NLS-1$ // integer > public static final String PLUGIN_ID = ValidationPlugin.PLUGIN_ID; >@@ -61,6 +62,7 @@ > /* package */static final QualifiedName USER_PREFERENCE = new QualifiedName(PLUGIN_ID, "ValidationConfiguration"); //$NON-NLS-1$ // ValidationConfiguration for the IResource > /* package */static final QualifiedName USER_MANUAL_PREFERENCE = new QualifiedName(PLUGIN_ID, "ValidationManualConfiguration"); //$NON-NLS-1$ // ValidationConfiguration for the IResource > /* package */static final QualifiedName USER_BUILD_PREFERENCE = new QualifiedName(PLUGIN_ID, "ValidationBuildConfiguration"); //$NON-NLS-1$ // ValidationConfiguration for the IResource >+ /* package */static final QualifiedName DELEGATES_PREFERENCE = new QualifiedName(PLUGIN_ID, "ValidationDelegatesConfiguration"); //$NON-NLS-1$ // ValidationConfiguration for the IResource > > // Validation message marker constants > /* package */static final String VALIDATION_MARKER = PLUGIN_ID + ".problemmarker"; //$NON-NLS-1$ // The extension which is used to add validation markers to the task list >Index: validate/org/eclipse/wst/validation/internal/ValidationConfiguration.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/validation/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationConfiguration.java,v >retrieving revision 1.12 >diff -u -r1.12 ValidationConfiguration.java >--- validate/org/eclipse/wst/validation/internal/ValidationConfiguration.java 17 Mar 2006 16:48:42 -0000 1.12 >+++ validate/org/eclipse/wst/validation/internal/ValidationConfiguration.java 17 Mar 2006 23:24:49 -0000 >@@ -30,6 +30,8 @@ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.jem.util.logger.LogEntry; > import org.eclipse.jem.util.logger.proxy.Logger; >+import org.eclipse.wst.validation.internal.delegates.ValidatorDelegateDescriptor; >+import org.eclipse.wst.validation.internal.delegates.ValidatorDelegatesRegistry; > import org.eclipse.wst.validation.internal.plugin.ValidationPlugin; > > >@@ -49,6 +51,7 @@ > // disabled. > protected HashMap manualValidators = null; > protected HashMap buildValidators = null; >+ private Map _delegatesByTarget = null; > > public static String getEnabledElementsAsString(Set elements) { > if (elements == null) { >@@ -125,6 +128,7 @@ > > protected ValidationConfiguration() throws InvocationTargetException { > _validators = new HashMap(); >+ _delegatesByTarget = new HashMap(); > } > > protected ValidationConfiguration(IResource resource, ValidatorMetaData[] validators) throws InvocationTargetException { >@@ -373,7 +377,21 @@ > } > } > >- >+ public void setDefaultDelegates(ValidatorMetaData[] vmds) throws InvocationTargetException { >+ _delegatesByTarget.clear(); >+ for (int i = 0; i < vmds.length; i++) { >+ ValidatorMetaData vmd = vmds[i]; >+ if (vmd == null) { >+ continue; >+ } >+ String targetID = vmd.getValidatorUniqueName(); >+ String delegateID = ValidatorDelegatesRegistry.getInstance().getDefaultDelegate(targetID); >+ if (delegateID == null) { >+ continue; >+ } >+ _delegatesByTarget.put(targetID, ValidatorDelegatesRegistry.getInstance().getDefaultDelegate(targetID)); >+ } >+ } > > /** > * Returns the number of configured validators on the given project or installed validators in >@@ -563,6 +581,7 @@ > getResource().setPersistentProperty(ConfigurationConstants.USER_PREFERENCE, serialize()); > getResource().setPersistentProperty(ConfigurationConstants.USER_MANUAL_PREFERENCE, serializeManualSetting()); > getResource().setPersistentProperty(ConfigurationConstants.USER_BUILD_PREFERENCE, serializeBuildSetting()); >+ getResource().setPersistentProperty(ConfigurationConstants.DELEGATES_PREFERENCE, serializeDelegatesSetting()); > } catch (CoreException exc) { > throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_SAVE, new String[]{getResource().getName()})); > } >@@ -719,6 +738,8 @@ > deserializeManual(storedManualConfiguration); > String storedBuildConfiguration = resource.getPersistentProperty(ConfigurationConstants.USER_BUILD_PREFERENCE); > deserializeBuild(storedBuildConfiguration); >+ String storedDelegatesConfiguration = resource.getPersistentProperty(ConfigurationConstants.DELEGATES_PREFERENCE); >+ deserializeDelegates(storedDelegatesConfiguration); > } catch (CoreException exc) { > throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{getResource().getName()})); > } >@@ -748,6 +769,32 @@ > setEnabledManualValidators(getStringAsEnabledElementsArray(manualValidation)); > } > >+ private void deserializeDelegates(String storedConfiguration) throws InvocationTargetException { >+ >+ if (storedConfiguration == null || storedConfiguration.length() == 0) { >+ // Assume that the configuration has never been set (new workspace). >+ resetToDefault(); >+ return; >+ } >+ >+ int delegatesIndex = storedConfiguration.indexOf(ConfigurationConstants.DELEGATE_VALIDATORS); >+ >+ String delegates = storedConfiguration.substring(delegatesIndex + ConfigurationConstants.DELEGATE_VALIDATORS.length(),storedConfiguration.length()); >+ >+ if (delegates == null) { >+ return; >+ } >+ >+ StringTokenizer tokenizer = new StringTokenizer(delegates, ConfigurationConstants.ELEMENT_SEPARATOR); >+ while (tokenizer.hasMoreTokens()) { >+ String delegateConfiguration = tokenizer.nextToken(); >+ int separatorIndex = delegateConfiguration.indexOf(ConfigurationConstants.DELEGATES_SEPARATOR); >+ String targetID = delegateConfiguration.substring(0, separatorIndex); >+ String delegateID = delegateConfiguration.substring(separatorIndex + 1); >+ _delegatesByTarget.put(targetID, delegateID); >+ } >+ } >+ > protected void copyTo(ValidationConfiguration up) throws InvocationTargetException { > up.setVersion(getVersion()); > up.setResource(getResource()); >@@ -756,9 +803,20 @@ > up.setEnabledValidators(getEnabledValidators()); > up.setEnabledManualValidators(getManualEnabledValidators()); > up.setEnabledBuildValidators(getBuildEnabledValidators()); >+ up.setDelegatingValidators(getDelegatingValidators()); > } > >- /** >+ public Map getDelegatingValidators() throws InvocationTargetException { >+ return _delegatesByTarget; >+ } >+ >+ public void setDelegatingValidators(Map source) >+ { >+ // It is safe to copy this map as it contains only immutable strings. >+ _delegatesByTarget.putAll(source); >+ } >+ >+ /** > * Return true if the enabled validators have not changed since this ValidationConfiguration was > * constructed, false otherwise. (This method is needed for the Properties and Preference pages; > * if the list of validators hasn't changed, then there is no need to update the task list; >@@ -787,6 +845,42 @@ > > return false; > } >+ >+ /** >+ * Determines if there has been a change in the list of delegate validators. >+ * @param oldDelegates a Map with the old delegates ID by target ID. >+ * @return true if there has been a change, false otherwise. >+ * @throws InvocationTargetException >+ */ >+ protected boolean haveDelegatesChanged(Map oldDelegates) throws InvocationTargetException { >+ >+ if (oldDelegates == null) { >+ return true; >+ } >+ >+ Iterator iterator = oldDelegates.keySet().iterator(); >+ >+ while (iterator.hasNext()) >+ { >+ String targetID = (String) iterator.next(); >+ String oldDelegateID = (String) oldDelegates.get(targetID); >+ String newDelegateID = (String) _delegatesByTarget.get(targetID); >+ >+ if (oldDelegateID == null || newDelegateID == null) { >+ return true; >+ } >+ >+ if (!newDelegateID.equals(oldDelegateID)) { >+ return true; >+ } >+ } >+ >+ if (oldDelegates.size() != _delegatesByTarget.size()) { >+ return true; >+ } >+ >+ return false; >+ } > > protected String serialize() throws InvocationTargetException { > StringBuffer buffer = new StringBuffer(); >@@ -811,7 +905,69 @@ > return buffer.toString(); > } > >- /** >+ protected String serializeDelegatesSetting() throws InvocationTargetException { >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append(ConfigurationConstants.DELEGATE_VALIDATORS); >+ buffer.append(getDelegatesAsString(getValidatorMetaData())); >+ return buffer.toString(); >+ } >+ >+ /** >+ * Provides a String which contains pairs of targetID=delegateID separated by a semicolon. >+ * @param validatorMetaData a Map with the currently configured validators. >+ * @return a String. >+ */ >+ private String getDelegatesAsString(Map validatorMetaData) { >+ >+ StringBuffer buffer = new StringBuffer(); >+ Iterator iterator = validatorMetaData.keySet().iterator(); >+ >+ while (iterator.hasNext()) { >+ >+ ValidatorMetaData vmd = (ValidatorMetaData) iterator.next(); >+ String targetID = vmd.getValidatorUniqueName(); >+ String delegateID = getDelegateUniqueName(vmd); >+ >+ if (delegateID == null) { >+ continue; >+ } >+ >+ // Write out pairs targetID=delegateID >+ >+ buffer.append(targetID); >+ buffer.append(ConfigurationConstants.DELEGATES_SEPARATOR); >+ buffer.append(delegateID); >+ buffer.append(ConfigurationConstants.ELEMENT_SEPARATOR); >+ } >+ >+ return buffer.toString(); >+ } >+ >+ /** >+ * Provides the delegate's ID of the validator delegate configured in this configuration for >+ * a given delegating validator. >+ * >+ * @param vmd the delegating validator's metadata. Must not be null. >+ * @return a String with the unique name (ID) of the validator delegate, null if there isn't one. >+ */ >+ public String getDelegateUniqueName(ValidatorMetaData vmd) { >+ String targetID = vmd.getValidatorUniqueName(); >+ return (String) _delegatesByTarget.get(targetID); >+ } >+ >+ /** >+ * Sets the delegate's ID of the validator delegate to be used in this configuration for the >+ * given delegating validator. >+ * >+ * @param vmd the delegating validator's metadata. Must not be null. >+ * @param delegateID a String with the unique name (ID) of the validator delegate. Must not be null. >+ */ >+ public void setDelegateUniqueName(ValidatorMetaData vmd, String delegateID) { >+ String targetID = vmd.getValidatorUniqueName(); >+ _delegatesByTarget.put(targetID, delegateID); >+ } >+ >+ /** > * Deserialize everything except the version number; the version is deserialized first, in the > * loadVersion() method. > */ >@@ -874,5 +1030,19 @@ > > public int numberOfManualEnabledValidators() throws InvocationTargetException { > return getManualEnabledValidators().length; >- } >+ } >+ >+ /** >+ * Provides the delegate validator descriptor of the validator delegate configured >+ * for the given delegating validator in the context of this configuration. >+ * @param vmd the delegating validator's meta data. Must not be null. >+ * @return a ValidatorDelegateDescriptor for the given delegating validator. >+ */ >+ public ValidatorDelegateDescriptor getDelegateDescriptor(ValidatorMetaData vmd) throws InvocationTargetException { >+ String targetID = vmd.getValidatorUniqueName(); >+ String delegateID = getDelegateUniqueName(vmd); >+ >+ ValidatorDelegateDescriptor descriptor = ValidatorDelegatesRegistry.getInstance().getDescriptor(targetID, delegateID); >+ return descriptor; >+ } > } >\ No newline at end of file >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/webtools/wst/components/validation/plugins/org.eclipse.wst.validation/plugin.xml,v >retrieving revision 1.19 >diff -u -r1.19 plugin.xml >--- plugin.xml 29 Nov 2005 21:15:36 -0000 1.19 >+++ plugin.xml 17 Mar 2006 23:24:49 -0000 >@@ -7,7 +7,8 @@ > <extension-point id="validator" name="%Validator" schema="xsds/validatorExtSchema.exsd"/> > <extension-point id="referencialFileValidator" name="%ReferencialFileValidator" schema="xsds/referencialFileExtSchema.exsd"/> > <extension-point id="validationSelectionHandler" name="%validationSelectionHandler" schema="xsds/validationSelectionHandler.exsd"/> >- <extension-point id="validationHelper" name="validationHelper" schema="xsds/validationHelper.exsd"/> >+ <extension-point id="validationHelper" name="validationHelper" schema="xsds/validationHelper.exsd"/> >+ <extension-point id="validatorDelegates" name="%ValidatorDelegates" schema="xsds/validatorDelegates.exsd"/> > > <!--============================--> > <!-- Validation Contributions --> >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/webtools/wst/components/validation/plugins/org.eclipse.wst.validation/plugin.properties,v >retrieving revision 1.6 >diff -u -r1.6 plugin.properties >--- plugin.properties 22 Aug 2005 21:05:41 -0000 1.6 >+++ plugin.properties 17 Mar 2006 23:24:49 -0000 >@@ -17,4 +17,5 @@ > VALIDATION_PREFERENCEMARKER_NAME=Validation Preferences > Validator=Validator > ReferencialFileValidator=ReferencialFileValidator >-validationSelectionHandler=validationSelectionHandler >\ No newline at end of file >+validationSelectionHandler=validationSelectionHandler >+ValidatorDelegates=Validator Delegates >Index: validate/org/eclipse/wst/validation/internal/operations/IWorkbenchContext.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/validation/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IWorkbenchContext.java,v >retrieving revision 1.1 >diff -u -r1.1 IWorkbenchContext.java >--- validate/org/eclipse/wst/validation/internal/operations/IWorkbenchContext.java 12 Apr 2005 19:36:01 -0000 1.1 >+++ validate/org/eclipse/wst/validation/internal/operations/IWorkbenchContext.java 17 Mar 2006 23:24:49 -0000 >@@ -13,7 +13,7 @@ > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IResource; >-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; >+import org.eclipse.wst.validation.internal.provisional.core.IProjectValidationContext; > > > >@@ -23,7 +23,7 @@ > * also needs to load items from the eclipse workbench. This interface should be extended by > * workbench IHelpers, so that items can be added to, and from, the task list. > */ >-public interface IWorkbenchContext extends IValidationContext { >+public interface IWorkbenchContext extends IProjectValidationContext { > /** > * When the validation is complete, this method will be called so that the IWorkbenchContext can > * clean up any resources it allocated during the validation. >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/wst/components/validation/plugins/org.eclipse.wst.validation/META-INF/MANIFEST.MF,v >retrieving revision 1.8 >diff -u -r1.8 MANIFEST.MF >--- META-INF/MANIFEST.MF 1 Mar 2006 17:44:44 -0000 1.8 >+++ META-INF/MANIFEST.MF 17 Mar 2006 23:24:49 -0000 >@@ -8,6 +8,7 @@ > Bundle-Localization: plugin > Export-Package: org.eclipse.wst.validation.internal;x-internal:=true, > org.eclipse.wst.validation.internal.core;x-internal:=true, >+ org.eclipse.wst.validation.internal.delegates;x-internal:=true, > org.eclipse.wst.validation.internal.operations;x-internal:=true, > org.eclipse.wst.validation.internal.plugin;x-internal:=true, > org.eclipse.wst.validation.internal.provisional;x-internal:=true, >Index: xsds/validatorDelegates.exsd >=================================================================== >RCS file: xsds/validatorDelegates.exsd >diff -N xsds/validatorDelegates.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ xsds/validatorDelegates.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,134 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.wst.validation"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.wst.validation" id="validatorDelegates" name="Validator Delegates"/> >+ </appInfo> >+ <documentation> >+ This extension point allows validator providers to contribute alternate implementations for a delegating validator. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <complexType> >+ <sequence> >+ <element ref="delegate"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="delegate"> >+ <annotation> >+ <documentation> >+ Defines a validator delegate. Delegating validators can have one or more delegates registered, only one of which can be active (selected) at once. >+ </documentation> >+ </annotation> >+ <complexType> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ Specifies the class name of the delegate validator. The class must implement IValidator. >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.wst.validation.internal.provisional.core.IValidator"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ <attribute name="target" type="string" use="required"> >+ <annotation> >+ <documentation> >+ Specifies the id of the validator extension for which this delegate is being registered. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ <b>This extension point is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.</b> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ <extension point="org.eclipse.wst.validation.validatorDelegates"> >+ <delegate >+ class="com.acme.fast.SuperFastValidator" >+ name="Super fast validator" >+ target="org.acme.core.ACMEDelegatingValidator"/> >+ </extension> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiInfo"/> >+ </appInfo> >+ <documentation> >+ A delegate validator will have to implement the IValidator interface. >+The target validator, the one who will delegate its implementation to a delegate validator will have to extend org.eclipse.wst.validation.delegates.BaseDelegatingValidator. >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="implementation"/> >+ </appInfo> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="copyright"/> >+ </appInfo> >+ <documentation> >+ Copyright (c) 2006 IBM Corporation and others.<br> >+All rights reserved. This program and the accompanying materials are made >+available under the terms of the Eclipse Public License v1.0 which accompanies >+this distribution, and is available at <a >+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema> >Index: validate/org/eclipse/wst/validation/internal/delegates/IDelegatingValidator.java >=================================================================== >RCS file: validate/org/eclipse/wst/validation/internal/delegates/IDelegatingValidator.java >diff -N validate/org/eclipse/wst/validation/internal/delegates/IDelegatingValidator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ validate/org/eclipse/wst/validation/internal/delegates/IDelegatingValidator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.wst.validation.internal.delegates; >+ >+import org.eclipse.wst.validation.internal.provisional.core.IValidator; >+ >+/** >+ * A delegating validator delegates the actual validation work to a delegate >+ * validator. This is a marker interface used internally by the framework to >+ * determine if a delegate is a delegating validator. >+ * >+ * [Issue] Could/should this interface be replaced with an attribute on the >+ * validators extension definition? >+ * >+ * <p> >+ * <b>Note:</b> This class/interface is part of an interim API that is still >+ * under development and expected to change significantly before reaching >+ * stability. It is being made available at this early stage to solicit feedback >+ * from pioneering adopters on the understanding that any code that uses this >+ * API will almost certainly be broken (repeatedly) as the API evolves. >+ * </p> >+ */ >+public interface IDelegatingValidator extends IValidator >+{ >+} >Index: validate/org/eclipse/wst/validation/internal/delegates/ValidatorDelegatesRegistryReader.java >=================================================================== >RCS file: validate/org/eclipse/wst/validation/internal/delegates/ValidatorDelegatesRegistryReader.java >diff -N validate/org/eclipse/wst/validation/internal/delegates/ValidatorDelegatesRegistryReader.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ validate/org/eclipse/wst/validation/internal/delegates/ValidatorDelegatesRegistryReader.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,114 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.wst.validation.internal.delegates; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.Platform; >+ >+/** >+ * This class reads the plugin extension registry and registers each delegating >+ * validator descriptor with the delegates registry. >+ * >+ * @see ValidatorDelegatesRegistry >+ */ >+class ValidatorDelegatesRegistryReader >+{ >+ /** >+ * The delegate class attribute. Must be visible in the package because it is >+ * used by other classes in the package. >+ */ >+ static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$ >+ >+ /** >+ * The delegate element name. >+ */ >+ private static final String DELEGATE_ELEMENT = "delegate"; //$NON-NLS-1$ >+ >+ /** >+ * The validator delegates extension point id. >+ */ >+ private static final String EXTENSION_POINT_ID = "validatorDelegates"; //$NON-NLS-1$ >+ >+ /** >+ * The delegate name attribute. >+ */ >+ private static final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$ >+ >+ /** >+ * Plugin id. >+ */ >+ private static final String PLUGIN_ID = "org.eclipse.wst.validation"; //$NON-NLS-1$ >+ >+ /** >+ * The target id attribute name. >+ */ >+ private static final String TARGET_ATTRIBUTE = "target"; //$NON-NLS-1$ >+ >+ /** >+ * The validator registry where the descriptors being read will be placed. >+ */ >+ private ValidatorDelegatesRegistry registry; >+ >+ /** >+ * Constructor. >+ * >+ * @param registry >+ * the registry where the descriptors being read will be placed. >+ */ >+ public ValidatorDelegatesRegistryReader(ValidatorDelegatesRegistry registry) >+ { >+ this.registry = registry; >+ } >+ >+ /** >+ * Reads a configuration element. >+ * >+ * @param element >+ * the platform configuration element being read. >+ */ >+ private void readElement(IConfigurationElement element) >+ { >+ String elementName = element.getName(); >+ >+ if (elementName.equals(DELEGATE_ELEMENT)) >+ { >+ String delegateID = (String) element.getAttribute(CLASS_ATTRIBUTE); >+ String delegateName = (String) element.getAttribute(NAME_ATTRIBUTE); >+ String targetValidatorID = (String) element.getAttribute(TARGET_ATTRIBUTE); >+ >+ ValidatorDelegateDescriptor descriptor = new ValidatorDelegateDescriptor(delegateID, element, delegateName, targetValidatorID); >+ >+ registry.add(descriptor); >+ } >+ } >+ >+ /** >+ * Read from the extensions registry and parse it. >+ */ >+ void readRegistry() >+ { >+ IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry(); >+ IExtensionPoint point = pluginRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID); >+ >+ if (point != null) >+ { >+ IConfigurationElement[] elements = point.getConfigurationElements(); >+ >+ for (int index = 0; index < elements.length; index++) >+ { >+ readElement(elements[index]); >+ } >+ } >+ } >+} >Index: validate/org/eclipse/wst/validation/internal/delegates/DelegatingValidator.java >=================================================================== >RCS file: validate/org/eclipse/wst/validation/internal/delegates/DelegatingValidator.java >diff -N validate/org/eclipse/wst/validation/internal/delegates/DelegatingValidator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ validate/org/eclipse/wst/validation/internal/delegates/DelegatingValidator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,237 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.wst.validation.internal.delegates; >+ >+import java.lang.reflect.InvocationTargetException; >+import java.util.List; >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.wst.validation.internal.ConfigurationManager; >+import org.eclipse.wst.validation.internal.ProjectConfiguration; >+import org.eclipse.wst.validation.internal.ValidationRegistryReader; >+import org.eclipse.wst.validation.internal.ValidatorMetaData; >+import org.eclipse.wst.validation.internal.core.ValidationException; >+import org.eclipse.wst.validation.internal.operations.LocalizedMessage; >+import org.eclipse.wst.validation.internal.provisional.core.IMessage; >+import org.eclipse.wst.validation.internal.provisional.core.IProjectValidationContext; >+import org.eclipse.wst.validation.internal.provisional.core.IReporter; >+import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; >+import org.eclipse.wst.validation.internal.provisional.core.IValidator; >+ >+/** >+ * This class is to be used as a base class by clients who want to provide >+ * alternate validator implementations for a given validator type. >+ * >+ * It locates the currently configured delegate for this validator and calls its >+ * validate method. >+ * >+ * @see IValidator >+ * @see IDelegatingValidator >+ * >+ * <p> >+ * <b>Note:</b> This class/interface is part of an interim API that is still >+ * under development and expected to change significantly before reaching >+ * stability. It is being made available at this early stage to solicit feedback >+ * from pioneering adopters on the understanding that any code that uses this >+ * API will almost certainly be broken (repeatedly) as the API evolves. >+ * </p> >+ */ >+public class DelegatingValidator implements IDelegatingValidator >+{ >+ /** >+ * Default constructor. >+ */ >+ public DelegatingValidator() >+ { >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.wst.validation.internal.provisional.core.IValidator#cleanup(org.eclipse.wst.validation.internal.provisional.core.IReporter) >+ */ >+ public void cleanup(IReporter reporter) >+ { >+ // [Issue] This method does not get passed the validation context. How are >+ // going >+ // to know what is the delegate in order to invoke its cleanup method? >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.wst.validation.internal.provisional.core.IValidator#validate(org.eclipse.wst.validation.internal.provisional.core.IValidationContext, >+ * org.eclipse.wst.validation.internal.provisional.core.IReporter) >+ */ >+ public void validate(IValidationContext helper, IReporter reporter) throws ValidationException >+ { >+ // We need to ensure that the context is an IProjectValidationContext. The >+ // limitation of using an IValidationContext is that it does not readily >+ // provide the project the validator is being invoked upon. >+ >+ if (!(helper instanceof IProjectValidationContext)) >+ { >+ // [Issue] Since this message goes to the user, do we need a less >+ // technical message text? Maybe we should log instead and send a >+ // generic message to the user. >+ throw new ValidationException(new LocalizedMessage(IMessage.HIGH_SEVERITY, "The validation context is not an IProjectValidationContext.")); >+ } >+ >+ IProjectValidationContext projectContext = (IProjectValidationContext) helper; >+ IProject project = projectContext.getProject(); >+ >+ ValidatorDelegateDescriptor delegateDescriptor = null; >+ >+ try >+ { >+ ProjectConfiguration projectConfig = ConfigurationManager.getManager().getProjectConfiguration(project); >+ >+ if (projectConfig == null) >+ { >+ throw new ValidationException(new LocalizedMessage(IMessage.HIGH_SEVERITY, "Unable to read the project validation configuration.")); >+ } >+ >+ ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(this); >+ >+ delegateDescriptor = projectConfig.getDelegateDescriptor(vmd); >+ } >+ catch (InvocationTargetException e) >+ { >+ throw new ValidationException(new LocalizedMessage(IMessage.HIGH_SEVERITY, "Error retrieving the project validation configuration.")); >+ } >+ >+ >+ IValidator delegate = delegateDescriptor.getValidator(); >+ >+ // We need to make it look like this validator is the one generating >+ // messages so we wrap the reporter and use this validator as the source. >+ // The validation framework does not recognize our validators because they >+ // are not registered directly with the framework. >+ // We could make them work like the aggregated validators but that would >+ // create problems with markers not being cleaned up if someone switches >+ // validators. >+ // TODO : Maybe we could clear all the markers generated by a delegate when >+ // the user chooses a different delegate implementation? >+ >+ DelegatingReporter delegatingReporter = new DelegatingReporter(this, reporter); >+ >+ delegate.validate(helper, delegatingReporter); >+ } >+ >+ /** >+ * Wraps the original reporter instance to make it look like this validator is >+ * the one generating messages. This is needed because the framework ignores >+ * messages coming from the delegate validator because it is not registered >+ * with the validation framework. >+ */ >+ private class DelegatingReporter implements IReporter >+ { >+ /** >+ * The reporter passed originally to the delegating validator by the >+ * framework. >+ */ >+ IReporter delegatingReporter; >+ >+ /** >+ * The delegating validator. >+ */ >+ IValidator delegatingValidator; >+ >+ /** >+ * Constructor. >+ * >+ * @param validator >+ * the original validator. >+ * @param reporter >+ * the reporter originally passed to the delegating validator. >+ */ >+ DelegatingReporter(IValidator validator, IReporter reporter) >+ { >+ delegatingReporter = reporter; >+ delegatingValidator = validator; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.wst.validation.internal.provisional.core.IReporter#addMessage(org.eclipse.wst.validation.internal.provisional.core.IValidator, >+ * org.eclipse.wst.validation.internal.provisional.core.IMessage) >+ */ >+ public void addMessage(IValidator origin, IMessage message) >+ { >+ delegatingReporter.addMessage(delegatingValidator, message); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.wst.validation.internal.provisional.core.IReporter#displaySubtask(org.eclipse.wst.validation.internal.provisional.core.IValidator, >+ * org.eclipse.wst.validation.internal.provisional.core.IMessage) >+ */ >+ public void displaySubtask(IValidator validator, IMessage message) >+ { >+ delegatingReporter.displaySubtask(delegatingValidator, message); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.wst.validation.internal.provisional.core.IReporter#getMessages() >+ */ >+ public List getMessages() >+ { >+ return delegatingReporter.getMessages(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.wst.validation.internal.provisional.core.IReporter#isCancelled() >+ */ >+ public boolean isCancelled() >+ { >+ return delegatingReporter.isCancelled(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.wst.validation.internal.provisional.core.IReporter#removeAllMessages(org.eclipse.wst.validation.internal.provisional.core.IValidator) >+ */ >+ public void removeAllMessages(IValidator origin) >+ { >+ delegatingReporter.removeAllMessages(delegatingValidator); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.wst.validation.internal.provisional.core.IReporter#removeAllMessages(org.eclipse.wst.validation.internal.provisional.core.IValidator, >+ * java.lang.Object) >+ */ >+ public void removeAllMessages(IValidator origin, Object object) >+ { >+ delegatingReporter.removeAllMessages(delegatingValidator, object); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.wst.validation.internal.provisional.core.IReporter#removeMessageSubset(org.eclipse.wst.validation.internal.provisional.core.IValidator, >+ * java.lang.Object, java.lang.String) >+ */ >+ public void removeMessageSubset(IValidator validator, Object obj, String groupName) >+ { >+ delegatingReporter.removeMessageSubset(delegatingValidator, obj, groupName); >+ } >+ } >+} >Index: validate_core/org/eclipse/wst/validation/internal/provisional/core/IProjectValidationContext.java >=================================================================== >RCS file: validate_core/org/eclipse/wst/validation/internal/provisional/core/IProjectValidationContext.java >diff -N validate_core/org/eclipse/wst/validation/internal/provisional/core/IProjectValidationContext.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ validate_core/org/eclipse/wst/validation/internal/provisional/core/IProjectValidationContext.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.wst.validation.internal.provisional.core; >+ >+import org.eclipse.core.resources.IProject; >+ >+/** >+ * IProjectValidationContext extends IValidationContext to provide access to a >+ * reference to the project on which a validator is being invoked. >+ * <p> >+ * <b>Note:</b> This class/interface is part of an interim API that is still >+ * under development and expected to change significantly before reaching >+ * stability. It is being made available at this early stage to solicit feedback >+ * from pioneering adopters on the understanding that any code that uses this >+ * API will almost certainly be broken (repeatedly) as the API evolves. >+ * </p> >+ */ >+public interface IProjectValidationContext extends IValidationContext >+{ >+ /** >+ * Provides the project on which the validator is being invoked. >+ * >+ * @return an IProject reference to the project on which the validator is >+ * being invoked. >+ */ >+ IProject getProject(); >+} >Index: validate/org/eclipse/wst/validation/internal/delegates/ValidatorDelegateDescriptor.java >=================================================================== >RCS file: validate/org/eclipse/wst/validation/internal/delegates/ValidatorDelegateDescriptor.java >diff -N validate/org/eclipse/wst/validation/internal/delegates/ValidatorDelegateDescriptor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ validate/org/eclipse/wst/validation/internal/delegates/ValidatorDelegateDescriptor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,129 @@ >+/******************************************************************************* >+* Copyright (c) 2006 IBM Corporation and others. >+* All rights reserved. This program and the accompanying materials >+* are made available under the terms of the Eclipse Public License v1.0 >+* which accompanies this distribution, and is available at >+* http://www.eclipse.org/legal/epl-v10.html >+* >+* Contributors: >+* IBM Corporation - initial API and implementation >+*******************************************************************************/ >+ >+package org.eclipse.wst.validation.internal.delegates; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.wst.validation.internal.provisional.core.IValidator; >+ >+/** >+ * ValidatorDelegateDescriptor stores information about a delegate validator. >+ * >+ * It is also used to store the instance of the validator it describes. To >+ * obtain the instance call getValidator(). >+ */ >+public class ValidatorDelegateDescriptor >+{ >+ /** >+ * The instance of the validator refered to by this descriptor. >+ */ >+ private IValidator delegate; >+ >+ /** >+ * The platform configuration element describing this delegate. >+ */ >+ private IConfigurationElement delegateConfiguration; >+ >+ /** >+ * The delegating validator's ID. >+ */ >+ private String delegatingValidatorID; >+ >+ /** >+ * The delegate's ID. >+ */ >+ private String id; >+ >+ /** >+ * The delegate's display name. >+ */ >+ private String name; >+ >+ /** >+ * Constructs a descriptor. >+ * >+ * @param id >+ * the delegate's uniques id. Must be unique in the context of a >+ * delegating validator. >+ * @param delegateConfiguration >+ * the delegates configuration element >+ * @param delegateName >+ * the delegate's display name. >+ * @param targetValidatorID >+ * the target validator's unique id. >+ */ >+ public ValidatorDelegateDescriptor(String id, IConfigurationElement delegateConfiguration, String delegateName, String targetValidatorID) >+ { >+ this.id = id; >+ this.delegateConfiguration = delegateConfiguration; >+ this.name = delegateName; >+ this.delegatingValidatorID = targetValidatorID; >+ } >+ >+ /** >+ * Provides the delegate's ID. >+ * >+ * @return a string with the fully qualified class name of this validator >+ * implementation. >+ */ >+ public String getId() >+ { >+ return id; >+ } >+ >+ /** >+ * Provides the delegate's name. >+ * >+ * @return a String with the validator's display name. >+ */ >+ public String getName() >+ { >+ return name; >+ } >+ >+ /** >+ * Retrieves the target validator's ID. >+ * >+ * @return a String with the fully qualified class name of the delegating >+ * validator who will delegate its implementation to the validator >+ * described by this descriptor. >+ */ >+ public String getTargetID() >+ { >+ return delegatingValidatorID; >+ } >+ >+ /** >+ * Provides the instance of the validator delegate pointed to by this >+ * descriptor. >+ * >+ * @return an IValidator instance. >+ */ >+ public IValidator getValidator() >+ { >+ if (delegate != null) >+ { >+ return delegate; >+ } >+ >+ try >+ { >+ delegate = (IValidator) delegateConfiguration.createExecutableExtension(ValidatorDelegatesRegistryReader.CLASS_ATTRIBUTE); >+ } >+ catch (CoreException e) >+ { >+ e.printStackTrace(); >+ } >+ >+ return delegate; >+ } >+} >Index: validate/org/eclipse/wst/validation/internal/delegates/ValidatorDelegatesRegistry.java >=================================================================== >RCS file: validate/org/eclipse/wst/validation/internal/delegates/ValidatorDelegatesRegistry.java >diff -N validate/org/eclipse/wst/validation/internal/delegates/ValidatorDelegatesRegistry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ validate/org/eclipse/wst/validation/internal/delegates/ValidatorDelegatesRegistry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,194 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.wst.validation.internal.delegates; >+ >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; >+ >+import org.eclipse.wst.validation.internal.provisional.core.IValidator; >+ >+/** >+ * ValidatorDelegatesRegistry is a singleton used to store validator delegate >+ * descriptors for each delegating validator. >+ */ >+public class ValidatorDelegatesRegistry >+{ >+ /** >+ * The one and only instance of this registry. >+ */ >+ private static ValidatorDelegatesRegistry instance; >+ >+ /** >+ * Provides the one and only instance of this class. >+ * >+ * The actual platform extension registry reading happens at this time. >+ * >+ * @see ValidatorDelegatesRegistryReader >+ * >+ * @return the validator delegates registry singleton instance. >+ */ >+ public static ValidatorDelegatesRegistry getInstance() >+ { >+ if (instance == null) >+ { >+ instance = new ValidatorDelegatesRegistry(); >+ >+ ValidatorDelegatesRegistryReader reader = new ValidatorDelegatesRegistryReader(instance); >+ reader.readRegistry(); >+ } >+ >+ return instance; >+ } >+ >+ /** >+ * The map of target validator id to Map of delegates by id. >+ */ >+ private Map delegatesByTarget = new HashMap(); >+ >+ /** >+ * Adds a descriptor to the registry. >+ * >+ * @param descriptor >+ * the descriptor to add. Must not be null. >+ */ >+ void add(ValidatorDelegateDescriptor descriptor) >+ { >+ if (descriptor == null) >+ { >+ return; >+ } >+ >+ String targetID = descriptor.getTargetID(); >+ >+ Map delegates = (Map) delegatesByTarget.get(targetID); >+ >+ if (delegates == null) >+ { >+ delegates = new HashMap(); >+ delegatesByTarget.put(targetID, delegates); >+ } >+ >+ delegates.put(descriptor.getId(), descriptor); >+ } >+ >+ /** >+ * Provides the default delegate ID for the given delegating validator ID. >+ * >+ * @param targetID >+ * the delegating validator's ID. >+ * @return a String with the ID of the default delegate. >+ */ >+ public String getDefaultDelegate(String targetID) >+ { >+ Map delegates = getDelegateDescriptors(targetID); >+ >+ if (delegates == null) >+ { >+ return null; >+ } >+ >+ // TODO: Implement a default attribute and use that to get the default? >+ // What happens if two or more delegates claim to be the default one? >+ // For now, just pick the first one in the list. >+ >+ Iterator delegatesIterator = delegates.values().iterator(); >+ >+ if (!delegatesIterator.hasNext()) >+ { >+ return null; >+ } >+ >+ ValidatorDelegateDescriptor descriptor = (ValidatorDelegateDescriptor) delegatesIterator.next(); >+ >+ return descriptor.getId(); >+ } >+ >+ /** >+ * Retrieves a delegate instance based on the target and delegate IDs. >+ * >+ * @param targetID >+ * the delegating validator's ID. >+ * @param delegateID >+ * the delegate validator's ID. >+ * @return an instance of the delegate validator or null if one cannot be >+ * found. >+ */ >+ public IValidator getDelegate(String targetID, String delegateID) >+ { >+ ValidatorDelegateDescriptor descriptor = getDescriptor(targetID, delegateID); >+ >+ if (descriptor == null) >+ { >+ return null; >+ } >+ >+ IValidator delegate = descriptor.getValidator(); >+ >+ return delegate; >+ } >+ >+ /** >+ * Provides a map with all delegates descriptors for the given target, keyed >+ * by their ID. >+ * >+ * @param targetID >+ * the target (delegating) validator id. Must not be null. >+ * @return a Map <string, ValidatorDelegateDescriptor>. May be null if the ID >+ * passed in is not a delegating validator. >+ */ >+ public Map getDelegateDescriptors(String targetID) >+ { >+ return (Map) delegatesByTarget.get(targetID); >+ } >+ >+ /** >+ * Finds a delegate descriptor based on the target id and delegate id. >+ * >+ * @param targetID >+ * the delegating validator's id >+ * @param delegateID >+ * the delegate id >+ * @return a ValidatorDelegateDescriptor for the given target and id or null >+ * if one cannot be found. >+ */ >+ public ValidatorDelegateDescriptor getDescriptor(String targetID, String delegateID) >+ { >+ Map delegates = (Map) delegatesByTarget.get(targetID); >+ >+ if (delegates == null) >+ { >+ // No delegates registered for this target. >+ >+ return null; >+ } >+ >+ ValidatorDelegateDescriptor descriptor = (ValidatorDelegateDescriptor) delegates.get(delegateID); >+ >+ return descriptor; >+ } >+ >+ /** >+ * Determines if a given validator has delegates. >+ * >+ * @param targetID >+ * the target validator id. >+ * @return true if the target has registered delegates, false otherwise. >+ */ >+ public boolean hasDelegates(String targetID) >+ { >+ Map delegatesByID = (Map) delegatesByTarget.get(targetID); >+ >+ boolean hasDelegates = (delegatesByID != null); >+ return hasDelegates; >+ } >+} >#P org.eclipse.wst.validation.ui >Index: validateui/org/eclipse/wst/validation/internal/ui/ValidationPreferencePage.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/validation/plugins/org.eclipse.wst.validation.ui/validateui/org/eclipse/wst/validation/internal/ui/ValidationPreferencePage.java,v >retrieving revision 1.14 >diff -u -r1.14 ValidationPreferencePage.java >--- validateui/org/eclipse/wst/validation/internal/ui/ValidationPreferencePage.java 16 Mar 2006 22:16:05 -0000 1.14 >+++ validateui/org/eclipse/wst/validation/internal/ui/ValidationPreferencePage.java 17 Mar 2006 23:24:50 -0000 >@@ -12,7 +12,9 @@ > > import java.lang.reflect.InvocationTargetException; > import java.util.ArrayList; >+import java.util.HashMap; > import java.util.List; >+import java.util.Map; > import java.util.logging.Level; > > import org.eclipse.core.resources.IProject; >@@ -30,6 +32,7 @@ > import org.eclipse.jface.viewers.TableViewer; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.viewers.ViewerSorter; >+import org.eclipse.jface.window.Window; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.ScrolledComposite; > import org.eclipse.swt.events.MouseAdapter; >@@ -44,8 +47,10 @@ > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.MessageBox; >+import org.eclipse.swt.widgets.Shell; > import org.eclipse.swt.widgets.Table; > import org.eclipse.swt.widgets.TableColumn; > import org.eclipse.swt.widgets.TableItem; >@@ -57,7 +62,9 @@ > import org.eclipse.wst.validation.internal.GlobalConfiguration; > import org.eclipse.wst.validation.internal.ProjectConfiguration; > import org.eclipse.wst.validation.internal.ValidatorMetaData; >+import org.eclipse.wst.validation.internal.delegates.IDelegatingValidator; > import org.eclipse.wst.validation.internal.operations.ValidatorManager; >+import org.eclipse.wst.validation.internal.provisional.core.IValidator; > import org.eclipse.wst.validation.internal.ui.plugin.ValidationUIPlugin; > > /** >@@ -250,6 +257,7 @@ > // order to access this field) > //private boolean _isAutoBuildEnabled; // initialized in the constructor > private ValidatorMetaData[] _oldVmd = null; // Cache the enabled validators so that, if >+ private Map _oldDelegates = null; // Cache the validator delegates. > // there is no change to this list, the > // expensive task list update can be avoided > private boolean _allow = false; // Cache the value of the prefence "allow projects to >@@ -336,16 +344,43 @@ > } > } > >+ private Image getImage(String imageName) { >+ boolean isDisabled = !validatorsTable.isEnabled(); >+ if (isDisabled) { >+ imageName = imageName + "_disabled"; //$NON-NLS-N$ >+ } >+ Image image = ValidationUIPlugin.getPlugin().getImage(imageName); >+ return image; >+ } >+ > public Image getColumnImage(Object element, int columnIndex) { > if(columnIndex == 1) { > if(((ValidatorMetaData)element).isManualValidation()) >- return ValidationUIPlugin.getPlugin().getImage("ok_tbl"); >- return ValidationUIPlugin.getPlugin().getImage("fail_tbl"); >- } else if(columnIndex == 2) { >+ return getImage("ok_tbl"); >+ return getImage("fail_tbl"); >+ } >+ else if(columnIndex == 2) { > if(((ValidatorMetaData)element).isBuildValidation()) >- return ValidationUIPlugin.getPlugin().getImage("ok_tbl");; >- return ValidationUIPlugin.getPlugin().getImage("fail_tbl"); >+ return getImage("ok_tbl");; >+ return getImage("fail_tbl"); > } >+ else if (columnIndex == 3) >+ { >+ ValidatorMetaData vmd = (ValidatorMetaData)element; >+ IValidator validator = null; >+ try >+ { >+ validator = vmd.getValidator(); >+ } >+ catch (InstantiationException e) >+ { >+ e.printStackTrace(); >+ } >+ if (validator instanceof IDelegatingValidator) >+ { >+ return getImage("settings"); >+ } >+ } > return null; > > } >@@ -409,7 +444,10 @@ > // that, if there is no change to this > // list, the expensive task list > // update can be avoided >- _allow = pagePreferences.canProjectsOverride(); >+ >+ _oldDelegates = new HashMap(pagePreferences.getDelegatingValidators()); >+ >+ _allow = pagePreferences.canProjectsOverride(); > > page = createPage(parent); > } >@@ -427,6 +465,10 @@ > buildColumn.setText("Build"); > buildColumn.setResizable(false); > buildColumn.setWidth(30); >+ TableColumn settingsColumn = new TableColumn(table, SWT.NONE); >+ settingsColumn.setText("Settings"); >+ settingsColumn.setResizable(false); >+ settingsColumn.setWidth(40); > } > > public Composite createPage(Composite parent) throws InvocationTargetException { >@@ -484,6 +526,7 @@ > validatorsTable.setEnabled(!disableAllValidation.getSelection()); > enableAllButton.setEnabled(!disableAllValidation.getSelection()); > disableAllButton.setEnabled(!disableAllValidation.getSelection()); >+ validatorList.refresh(); > } > }); > >@@ -499,8 +542,10 @@ > validatorsTable = new Table(validatorGroup,SWT.BORDER | SWT.FULL_SELECTION); > TableLayout tableLayout = new TableLayout(); > tableLayout.addColumnData(new ColumnWeightData(160, true)); >- tableLayout.addColumnData(new ColumnWeightData(40, true)); >- tableLayout.addColumnData(new ColumnWeightData(30, true)); >+ tableLayout.addColumnData(new ColumnWeightData(40, true)); >+ tableLayout.addColumnData(new ColumnWeightData(30, true)); >+ tableLayout.addColumnData(new ColumnWeightData(40, true)); >+ > validatorsTable.setHeaderVisible(true); > validatorsTable.setLinesVisible(true); > validatorsTable.setLayout(tableLayout); >@@ -613,6 +658,24 @@ > case 2: > vmd.setBuildValidation(!vmd.isBuildValidation()); > break; >+ case 3: >+ { >+ String delegateID = pagePreferences.getDelegateUniqueName(vmd); >+ >+ Shell shell = Display.getCurrent().getActiveShell(); >+ DelegatingValidatorPreferencesDialog dialog = new DelegatingValidatorPreferencesDialog(shell, vmd, delegateID); >+ >+ dialog.setBlockOnOpen(true); >+ dialog.create(); >+ >+ int result = dialog.open(); >+ >+ if (result == Window.OK) >+ { >+ pagePreferences.setDelegateUniqueName(vmd, dialog.getDelegateID()); >+ } >+ } >+ break; > default: > break; > } >@@ -840,7 +903,8 @@ > try { > if (project.isOpen()) { > ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project); >- if (!prjp.doesProjectOverride() && (prjp.hasEnabledValidatorsChanged(_oldVmd, allowChanged) || true)) { >+ if (!prjp.doesProjectOverride() && (prjp.hasEnabledValidatorsChanged(_oldVmd, allowChanged) || true) && >+ (prjp.haveDelegatesChanged(_oldDelegates, allowChanged) || true)) { > // If the project used to override the preferences, and the preferences > // make that impossible now, then update the task list. > // >Index: validateui/org/eclipse/wst/validation/internal/ui/ValidationPropertiesPage.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/validation/plugins/org.eclipse.wst.validation.ui/validateui/org/eclipse/wst/validation/internal/ui/ValidationPropertiesPage.java,v >retrieving revision 1.14 >diff -u -r1.14 ValidationPropertiesPage.java >--- validateui/org/eclipse/wst/validation/internal/ui/ValidationPropertiesPage.java 16 Mar 2006 22:16:05 -0000 1.14 >+++ validateui/org/eclipse/wst/validation/internal/ui/ValidationPropertiesPage.java 17 Mar 2006 23:24:50 -0000 >@@ -13,7 +13,9 @@ > > import java.lang.reflect.InvocationTargetException; > import java.util.ArrayList; >+import java.util.HashMap; > import java.util.List; >+import java.util.Map; > import java.util.logging.Level; > > import javax.swing.event.HyperlinkEvent; >@@ -30,6 +32,7 @@ > import org.eclipse.jface.viewers.TableViewer; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.viewers.ViewerSorter; >+import org.eclipse.jface.window.Window; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.ScrolledComposite; > import org.eclipse.swt.events.MouseAdapter; >@@ -46,8 +49,10 @@ > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.MessageBox; >+import org.eclipse.swt.widgets.Shell; > import org.eclipse.swt.widgets.Table; > import org.eclipse.swt.widgets.TableColumn; > import org.eclipse.swt.widgets.TableItem; >@@ -61,7 +66,9 @@ > import org.eclipse.wst.validation.internal.GlobalConfiguration; > import org.eclipse.wst.validation.internal.ProjectConfiguration; > import org.eclipse.wst.validation.internal.ValidatorMetaData; >+import org.eclipse.wst.validation.internal.delegates.IDelegatingValidator; > import org.eclipse.wst.validation.internal.operations.ValidatorManager; >+import org.eclipse.wst.validation.internal.provisional.core.IValidator; > import org.eclipse.wst.validation.internal.ui.plugin.ValidationUIPlugin; > > /** >@@ -241,6 +248,7 @@ > private boolean canOverride = false; > > private ValidatorMetaData[] oldVmd = null; // Cache the enabled validators so that, if there >+ private Map oldDelegates = null; // Cache the validator delegates. > > // is no change to this list, the expensive task > // list update can be avoided >@@ -340,18 +348,44 @@ > return null; > } > >- public Image getColumnImage(Object element, int columnIndex) { >+ private Image getImage(String imageName) { >+ boolean isDisabled = !validatorsTable.isEnabled(); >+ if (isDisabled) { >+ imageName = imageName + "_disabled"; //$NON-NLS-N$ >+ } >+ Image image = ValidationUIPlugin.getPlugin().getImage(imageName); >+ return image; >+ } >+ >+ >+ public Image getColumnImage(Object element, int columnIndex) { > if(columnIndex == 1) { > if(((ValidatorMetaData)element).isManualValidation()) >- return ValidationUIPlugin.getPlugin().getImage("ok_tbl"); >- return ValidationUIPlugin.getPlugin().getImage("fail_tbl"); >+ return getImage("ok_tbl"); >+ return getImage("fail_tbl"); > } else if(columnIndex == 2) { > if(((ValidatorMetaData)element).isBuildValidation()) >- return ValidationUIPlugin.getPlugin().getImage("ok_tbl");; >- return ValidationUIPlugin.getPlugin().getImage("fail_tbl"); >+ return getImage("ok_tbl");; >+ return getImage("fail_tbl"); > } >+ else if (columnIndex == 3) >+ { >+ ValidatorMetaData vmd = (ValidatorMetaData)element; >+ IValidator validator = null; >+ try >+ { >+ validator = vmd.getValidator(); >+ } >+ catch (InstantiationException e) >+ { >+ e.printStackTrace(); >+ } >+ if (validator instanceof IDelegatingValidator) >+ { >+ return getImage("settings"); >+ } >+ } > return null; >- > } > } > >@@ -401,9 +435,11 @@ > //isAutoBuildEnabled = vMgr.isGlobalAutoBuildEnabled(); > //isBuilderConfigured = ValidatorManager.doesProjectSupportBuildValidation(getProject()); > oldVmd = pagePreferences.getEnabledValidators(); // Cache the enabled validators so >- // that, if there is no change to this >- // list, the expensive task list update >- // can be avoided >+ // that, if there is no change to this >+ // list, the expensive task list update >+ // can be avoided >+ >+ oldDelegates = new HashMap(pagePreferences.getDelegatingValidators()); > > createPage(parent); > } >@@ -421,6 +457,10 @@ > buildColumn.setText("Build"); > buildColumn.setResizable(false); > buildColumn.setWidth(30); >+ TableColumn settingsColumn = new TableColumn(table, SWT.NONE); >+ settingsColumn.setText("Settings"); >+ settingsColumn.setResizable(false); >+ settingsColumn.setWidth(40); > } > > /** >@@ -506,6 +546,11 @@ > validatorsTable.setEnabled(!disableAllValidation.getSelection()); > enableAllButton.setEnabled(!disableAllValidation.getSelection()); > disableAllButton.setEnabled(!disableAllValidation.getSelection()); >+ try { >+ updateWidgets(); >+ } catch (InvocationTargetException exc) { >+ displayAndLogError(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_INTERNAL_TITLE), ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_INTERNAL_PAGE), exc); >+ } > } > }); > >@@ -523,8 +568,9 @@ > validatorsTable = new Table(validatorGroup,SWT.BORDER | SWT.FULL_SELECTION); > TableLayout tableLayout = new TableLayout(); > tableLayout.addColumnData(new ColumnWeightData(160, true)); >- tableLayout.addColumnData(new ColumnWeightData(40, true)); >- tableLayout.addColumnData(new ColumnWeightData(30, true)); >+ tableLayout.addColumnData(new ColumnWeightData(40, true)); >+ tableLayout.addColumnData(new ColumnWeightData(30, true)); >+ tableLayout.addColumnData(new ColumnWeightData(40, true)); > validatorsTable.setHeaderVisible(true); > validatorsTable.setLinesVisible(true); > validatorsTable.setLayout(tableLayout); >@@ -756,6 +802,23 @@ > case 2: > vmd.setBuildValidation(!vmd.isBuildValidation()); > break; >+ case 3: >+ { >+ String delegateID = pagePreferences.getDelegateUniqueName(vmd); >+ >+ Shell shell = Display.getCurrent().getActiveShell(); >+ DelegatingValidatorPreferencesDialog dialog = new DelegatingValidatorPreferencesDialog(shell, vmd, delegateID); >+ >+ dialog.setBlockOnOpen(true); >+ dialog.create(); >+ >+ int result = dialog.open(); >+ >+ if (result == Window.OK) >+ { >+ pagePreferences.setDelegateUniqueName(vmd, dialog.getDelegateID()); >+ } >+ } > default: > break; > } >@@ -816,8 +879,10 @@ > */ > private void enableDependentControls(boolean overridePreferences) { > validatorsTable.setEnabled(overridePreferences); >+ validatorList.refresh(); > enableAllButton.setEnabled(overridePreferences); // since help messsage isn't > disableAllButton.setEnabled(overridePreferences); >+ > } > > protected void updateHelp() throws InvocationTargetException { >@@ -939,7 +1004,8 @@ > // Persist the values. > storeValues(); > >- if (pagePreferences.hasEnabledValidatorsChanged(oldVmd, false)) { >+ if (pagePreferences.hasEnabledValidatorsChanged(oldVmd, false) || >+ pagePreferences.haveDelegatesChanged(oldDelegates, false)) { > // false means that the preference "allow" value hasn't changed > ValidatorManager.getManager().updateTaskList(getProject()); > } >Index: validateui/org/eclipse/wst/validation/internal/ui/ResourceConstants.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/validation/plugins/org.eclipse.wst.validation.ui/validateui/org/eclipse/wst/validation/internal/ui/ResourceConstants.java,v >retrieving revision 1.5 >diff -u -r1.5 ResourceConstants.java >--- validateui/org/eclipse/wst/validation/internal/ui/ResourceConstants.java 9 Mar 2006 18:39:30 -0000 1.5 >+++ validateui/org/eclipse/wst/validation/internal/ui/ResourceConstants.java 17 Mar 2006 23:24:50 -0000 >@@ -61,6 +61,7 @@ > > public static final String VBF_UI_POPUP_RUNVALIDATION = "%VBF_UI_POPUP_RUNVALIDATION"; //$NON-NLS-1$ > >+ /* package */static final String PREF_BUTTON_ADVANCED = "PREF_BUTTON_ADVANCED"; //$NON-NLS-1$ > /* package */static final String PREF_BUTTON_ENABLEALL = "PREF_BUTTON_ENABLEALL"; //$NON-NLS-1$ > /* package */static final String PREF_BUTTON_DISABLEALL = "PREF_BUTTON_DISABLEALL"; //$NON-NLS-1$ > /* package */static final String PREF_VALLIST_TITLE = "PREF_VALLIST_TITLE"; //$NON-NLS-1$ >@@ -89,4 +90,7 @@ > > /* package */static final String DISABLE_VALIDATION = "DISABLE_VALIDATION"; //$NON-NLS-1$ > static final String INFO = "INFO"; //$NON-NLS-1$ >-} >\ No newline at end of file >+ >+ String DELEGATES_DIALOG_TITLE = "DELEGATES_DIALOG_TITLE"; //$NON-NLS-1$ >+ String DELEGATES_COMBO_LABEL = "DELEGATES_COMBO_LABEL"; //$NON-NLS-1$ >+ } >\ No newline at end of file >Index: property_files/validate_ui.properties >=================================================================== >RCS file: /cvsroot/webtools/wst/components/validation/plugins/org.eclipse.wst.validation.ui/property_files/validate_ui.properties,v >retrieving revision 1.6 >diff -u -r1.6 validate_ui.properties >--- property_files/validate_ui.properties 9 Mar 2006 18:39:30 -0000 1.6 >+++ property_files/validate_ui.properties 17 Mar 2006 23:24:50 -0000 >@@ -110,6 +110,9 @@ > DISABLE_VALIDATION=Suspend all validators > INFO=This preference applies to the projects that have org.eclipse.wst.validation.validationbuilder defined.Validators are run on the projects based on the filters defined in the org.eclipse.wst.validation.validator extension point. > >+DELEGATES_DIALOG_TITLE=Validator Preferences >+DELEGATES_COMBO_LABEL=Implementation: >+ > # > # End Validation Builder Framework UI Strings > # >Index: validateui/org/eclipse/wst/validation/internal/ui/DelegatingValidatorPreferencesDialog.java >=================================================================== >RCS file: validateui/org/eclipse/wst/validation/internal/ui/DelegatingValidatorPreferencesDialog.java >diff -N validateui/org/eclipse/wst/validation/internal/ui/DelegatingValidatorPreferencesDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ validateui/org/eclipse/wst/validation/internal/ui/DelegatingValidatorPreferencesDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,260 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.wst.validation.internal.ui; >+ >+import java.util.Collection; >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.jface.viewers.ComboViewer; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.ILabelProviderListener; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.wst.validation.internal.ValidatorMetaData; >+import org.eclipse.wst.validation.internal.delegates.ValidatorDelegateDescriptor; >+import org.eclipse.wst.validation.internal.delegates.ValidatorDelegatesRegistry; >+ >+/** >+ * Dialog used to allow the user to select a validator delegate from the list of >+ * registered delegates for a given delegating validator. >+ */ >+public class DelegatingValidatorPreferencesDialog extends Dialog >+{ >+ /** >+ * The delegating validator's descriptor . >+ */ >+ private ValidatorMetaData delegatingValidatorDescriptor; >+ /** >+ * The selected validator delegate ID. >+ */ >+ private String delegateID; >+ >+ /** >+ * Constructs the dialog on the given shell. >+ * >+ * @param parentShell >+ * the dialog's parent. Must not be null. >+ * @param targetID >+ * the delegating validator's id >+ * >+ * @param delegateID >+ * the ID of the currently selected validator delegate. >+ */ >+ protected DelegatingValidatorPreferencesDialog(Shell parentShell, ValidatorMetaData vmd, String delegateID) >+ { >+ super(parentShell); >+ >+ delegatingValidatorDescriptor = vmd; >+ this.delegateID = delegateID; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createDialogArea(Composite parent) >+ { >+ super.createDialogArea(parent); >+ >+ getShell().setText(ResourceHandler.getExternalizedMessage(ResourceConstants.DELEGATES_DIALOG_TITLE)); >+ >+ GridLayout layout = new GridLayout(); >+ parent.setLayout(layout); >+ >+ Label label = new Label(parent, SWT.NONE); >+ GridData labelData = new GridData(SWT.FILL, SWT.CENTER, true, false); >+ labelData.widthHint = 250; >+ label.setLayoutData(labelData); >+ label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.TEXT_FONT)); >+ String delegatingValidatorName = delegatingValidatorDescriptor.getValidatorDisplayName(); >+ label.setText(delegatingValidatorName); >+ >+ Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); >+ GridData separatorData = new GridData(SWT.FILL, SWT.CENTER, true, false); >+ separator.setLayoutData(separatorData); >+ >+ Composite group = new Composite(parent, SWT.NONE); >+ GridData groupGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); >+ group.setLayoutData(groupGridData); >+ GridLayout groupLayout = new GridLayout(2, false); >+ group.setLayout(groupLayout); >+ >+ Label comboLabel = new Label(group, SWT.NONE); >+ comboLabel.setLayoutData(new GridData()); >+ comboLabel.setText(ResourceHandler.getExternalizedMessage(ResourceConstants.DELEGATES_COMBO_LABEL)); >+ >+ Combo combo = new Combo(group, SWT.NONE); >+ GridData comboGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); >+ combo.setLayoutData(comboGridData); >+ >+ final ComboViewer comboViewer = new ComboViewer(combo); >+ comboViewer.setContentProvider(new DelegatesContentProvider()); >+ comboViewer.setLabelProvider(new DelegatesLabelProvider()); >+ String targetID = delegatingValidatorDescriptor.getValidatorUniqueName(); >+ >+ comboViewer.addSelectionChangedListener(new ISelectionChangedListener() >+ { >+ >+ public void selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event) >+ { >+ IStructuredSelection selection = (IStructuredSelection) comboViewer.getSelection(); >+ setDelegateID(((ValidatorDelegateDescriptor) selection.getFirstElement()).getId()); >+ } >+ }); >+ >+ comboViewer.setInput(targetID); >+ >+ ValidatorDelegateDescriptor selected = ValidatorDelegatesRegistry.getInstance().getDescriptor(targetID, delegateID); >+ >+ if (selected != null) >+ { >+ comboViewer.setSelection(new StructuredSelection(new Object[] { selected })); >+ } >+ >+ Label endSeparator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); >+ GridData endSeparatorData = new GridData(SWT.FILL, SWT.CENTER, true, false); >+ endSeparator.setLayoutData(endSeparatorData); >+ >+ return parent; >+ } >+ >+ /** >+ * Provides contents for the delegate validators combo box. >+ */ >+ private final class DelegatesContentProvider implements IStructuredContentProvider >+ { >+ public void dispose() >+ { >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) >+ */ >+ public Object[] getElements(Object inputElement) >+ { >+ String targetID = (String) inputElement; >+ Collection delegates = ValidatorDelegatesRegistry.getInstance().getDelegateDescriptors(targetID).values(); >+ return delegates.toArray(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, >+ * java.lang.Object, java.lang.Object) >+ */ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) >+ { >+ } >+ } >+ >+ /** >+ * Provides the labels/images for the delegate validator combo box >+ * >+ * @author vbaciul >+ * >+ */ >+ private final class DelegatesLabelProvider implements ILabelProvider >+ { >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) >+ */ >+ public void addListener(ILabelProviderListener listener) >+ { >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() >+ */ >+ public void dispose() >+ { >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) >+ */ >+ public Image getImage(Object element) >+ { >+ return null; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) >+ */ >+ public String getText(Object element) >+ { >+ return ((ValidatorDelegateDescriptor) element).getName(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, >+ * java.lang.String) >+ */ >+ public boolean isLabelProperty(Object element, String property) >+ { >+ return false; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) >+ */ >+ public void removeListener(ILabelProviderListener listener) >+ { >+ } >+ } >+ >+ /* >+ * Provides the ID of the currently selected validator delegate ID. >+ */ >+ public String getDelegateID() >+ { >+ return delegateID; >+ } >+ >+ /** >+ * Sets the currently selected validator delegate ID. >+ * >+ * @param delegateID >+ */ >+ private void setDelegateID(String delegateID) >+ { >+ this.delegateID = delegateID; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 132228
:
36537
|
36538
|
36539
|
36540
|
36541
|
36631
|
36632
|
36671
|
37456