blob: dca5715a497e173aee5f6517ff3836a5350968d5 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2005, 2008 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.model;
import org.eclipse.core.resources.IProject;
import org.eclipse.wst.validation.Validator;
import org.eclipse.wst.validation.internal.ValManager;
import org.eclipse.wst.validation.internal.ValPrefManagerProject;
/**
* Validation preferences for a particular project.
* @author karasiuk
*
*/
public class ProjectPreferences {
/** false - Default setting for the "should all the validation be suspended" setting. */
public static final boolean DefaultSuspend = false;
/** false - Default setting for letting projects override the global settings. */
public static final boolean DefaultOverride = false;
private IProject _project;
private boolean _override = DefaultOverride;
private boolean _suspend = DefaultSuspend;
private Validator[] _validators;
public ProjectPreferences(IProject project){
_project = project;
}
public boolean getOverride() {
return _override;
}
public void setOverride(boolean override) {
_override = override;
}
public boolean getSuspend() {
return _suspend;
}
public void setSuspend(boolean suspend) {
_suspend = suspend;
}
/**
* Answer the validators that have been registered for this project.
* @return an empty array if there are no validators.
*/
public Validator[] getValidators() {
Validator[] vals = _validators;
if (vals == null){
vals = init();
_validators = vals;
}
return vals;
}
public void setValidators(Validator[] validators){
_validators = validators;
}
private Validator[] init(){
Validator[] vals = null;
ValPrefManagerProject vpm = new ValPrefManagerProject(_project);
if (vpm.hasProjectSpecificSettings()){
vpm.loadProjectPreferences(this);
vals = _validators;
}
else {
vals = ValManager.getDefault().getValidators();
}
if (vals == null)vals = new Validator[0];
return vals;
}
public IProject getProject() {
return _project;
}
}