Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Turning off validation
Turning off validation [message #199087] Wed, 29 August 2007 15:24 Go to next message
Mike Bourgeois is currently offline Mike Bourgeois
Messages: 6
Registered: July 2009
Junior Member
Hi,
We have created a project facet that adds resources to dynamic web
projects. The resources we add templates that use in generating web
applications. These templates have a lot of errors and warnings from the
validators. Is there a programmatic way to shut off Validation on a
project? Or maybe just some validators?

Thank you for your consideration,

bouge
Re: Turning off validation [message #199128 is a reply to message #199087] Wed, 29 August 2007 20:54 Go to previous messageGo to next message
Zhaoming Lin is currently offline Zhaoming Lin
Messages: 2
Registered: July 2009
Junior Member
In your facet Delegate class, you can disable the validators. The following
code snippets are used for disable the JSLint validator.
public static void disableJSLintValidator(){
try {
GlobalConfiguration globalConfiguration =
ConfigurationManager.getManager().getGlobalConfiguration();
ValidatorMetaData[] currentValidators =
globalConfiguration.getBuildEnabledValidators();
Vector vector = new Vector();
for (int i = 0; i < currentValidators.length; i++) {
ValidatorMetaData data = (ValidatorMetaData) currentValidators[i];
if (!data.getValidatorUniqueName().equals(JSLint_Validator_UNIQ UE_NAME))
{
vector.add(data);
}
}
// If JSLint Validator is Build Enabled, set the global gonfiguration.
if (vector.size() != currentValidators.length) {
ValidatorMetaData[] newValidators = new ValidatorMetaData[vector
.size()];
for (int i = 0; i < vector.size(); i++) {
newValidators[i] = (ValidatorMetaData) vector.get(i);
}
globalConfiguration.setEnabledBuildValidators(newValidators) ;
globalConfiguration.store();
}
} catch (InvocationTargetException ex) {
log.exception(ex);
}
}

"Mike" <mike.bourgeois@us.ibm.com> wrote in message
news:044f9cf236ac24a46df4c4d646473fae$1@www.eclipse.org...
> Hi,
> We have created a project facet that adds resources to dynamic web
> projects. The resources we add templates that use in generating web
> applications. These templates have a lot of errors and warnings from the
> validators. Is there a programmatic way to shut off Validation on a
> project? Or maybe just some validators?
>
> Thank you for your consideration,
>
> bouge
>
>
>
>
>
Re: Turning off validation [message #199147 is a reply to message #199087] Thu, 30 August 2007 09:18 Go to previous messageGo to next message
Lawrence Mandel is currently offline Lawrence Mandel
Messages: 486
Registered: July 2009
Senior Member
If you want to disable validation from within the UI simply right click on
the project, select Properties -> Validation, select to override
validation preferences and you can enable/disable each specific validator.

Lawrence
Re: Turning off validation [message #199155 is a reply to message #199128] Thu, 30 August 2007 09:40 Go to previous messageGo to next message
Mike Bourgeois is currently offline Mike Bourgeois
Messages: 6
Registered: July 2009
Junior Member
This is great thanks! I see that it also sets validation at the
preference level, is there a way to do it only on the project you are
working on?

Thanks again!
bouge
Re: Turning off validation [message #199170 is a reply to message #199155] Thu, 30 August 2007 09:45 Go to previous messageGo to next message
Mike Bourgeois is currently offline Mike Bourgeois
Messages: 6
Registered: July 2009
Junior Member
Sorry, just found the answer to my question.
ConfigurationManager.getManager().getProjectConfiguration(pr oject) appears
to be at the project level. Thanks again!
bouge
Re: Turning off validation [message #219448 is a reply to message #199128] Wed, 20 August 2008 10:08 Go to previous messageGo to next message
bouge is currently offline bouge
Messages: 13
Registered: July 2009
Junior Member
Hi Again,
We took a slightly different approach and turned off the validators on the
project only by using the ProjectConfiguration (see below). Worked great
in eclipse 3.2 and 3.3, but in 3.4 I'm seeing that this code no longer
enables the project to override the global preferences, as well the html
and jsp validators are not in the list of validators that I can turn off.
In the UI they got there own pages. Any ideas on how to enable project
override, and how to get to the html and jsp validators?

Thanks again!
bouge

// Get the project configuration, set it to override the preferences.
ProjectConfiguration projectConfiguration =
ConfigurationManager.getManager().getProjectConfiguration(pr oject);

projectConfiguration.setDoesProjectOverride(true);


// Get the current list of validators.ValidatorMetaData[]
currentValidators = projectConfiguration.getEnabledValidators();

Vector vector = new Vector();

// Iterate through the current list of validators, removing the jsp and
html validators.
for(int i = 0; i < currentValidators.length; i++)
{
ValidatorMetaData vmd = currentValidators[i];
String uniqueName = vmd.getValidatorUniqueName();
System.out.println(uniqueName);

if(!uniqueName.equals(JSP_VALIDATOR) &&
!uniqueName.equals(HTML_VALIDATOR)
&& !uniqueName.equals(XML_VALIDATOR) &&
!uniqueName.equals(WAR_VALIDATOR))
{
vector.add(vmd);
}
}

// Create a new array of validators with only the ones we want.
ValidatorMetaData[] newValidators = new ValidatorMetaData[vector.size()];
for (int i = 0; i < vector.size(); i++)
{
newValidators[i] = (ValidatorMetaData) vector.get(i);
}

// Set the new array of validators back to the project and
save.
projectConfiguration.setEnabledBuildValidators(newValidators );
projectConfiguration.setEnabledManualValidators(newValidator s);
projectConfiguration.store();
Re: Turning off validation [message #219455 is a reply to message #219448] Wed, 20 August 2008 10:10 Go to previous message
bouge is currently offline bouge
Messages: 13
Registered: July 2009
Junior Member
Sorry, I was trying to reply this thread:
http://www.eclipse.org/newsportal/article.php?id=14620&g roup=eclipse.webtools#14620
Previous Topic:Generic EMF Editor editing xml data
Next Topic:Trying to spec. JS library, but use XDR to load from CDN
Goto Forum:
  


Current Time: Sat Jul 26 01:13:54 EDT 2014

Powered by FUDForum. Page generated in 0.31710 seconds