Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Turning off validation
Turning off validation [message #199087] Wed, 29 August 2007 19:24 Go to next message
Mike Bourgeois is currently offline Mike BourgeoisFriend
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] Thu, 30 August 2007 00:54 Go to previous messageGo to next message
Zhaoming Lin is currently offline Zhaoming LinFriend
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 13:18 Go to previous messageGo to next message
Lawrence Mandel is currently offline Lawrence MandelFriend
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 13:40 Go to previous messageGo to next message
Mike Bourgeois is currently offline Mike BourgeoisFriend
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 13:45 Go to previous messageGo to next message
Mike Bourgeois is currently offline Mike BourgeoisFriend
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 14:08 Go to previous messageGo to next message
bouge is currently offline bougeFriend
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 14:10 Go to previous message
bouge is currently offline bougeFriend
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: Fri Apr 26 18:33:25 GMT 2024

Powered by FUDForum. Page generated in 0.03290 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top