public class ClickFacetInstallDelegate implements IDelegate {
public void execute(IProject project, IProjectFacetVersion fv,
Object cfg, IProgressMonitor monitor) throws CoreException {
try {
IDataModel config = null;
if (cfg != null) {
config = (IDataModel) cfg;
}
if (monitor != null) {
int totalTasks = 3;
if(config.getBooleanProperty(ClickFacetInstallDataModelProvider.USE_SPRING)){
totalTasks++;
}
if(config.getBooleanProperty(ClickFacetInstallDataModelProvider.USE_CAYENNE)){
totalTasks++;
}
monitor.beginTask("", totalTasks); //$NON-NLS-1$
}
// Add Click JARs to WEB-INF/lib
deployClickFiles(project, config, monitor);
// Update web model
createServletAndModifyWebXML(project, config, monitor,
config.getBooleanProperty(ClickFacetInstallDataModelProvider.USE_SPRING),
config.getBooleanProperty(ClickFacetInstallDataModelProvider.USE_CAYENNE),
config.getBooleanProperty(ClickFacetInstallDataModelProvider.USE_PERFORMANCE_FILTER));
if (monitor != null) {
monitor.worked(1);
}
// Add the nature
ClickProjectNature.addNatute(project);
if (monitor != null) {
monitor.worked(1);
}
// Disable HTML validator
try {
ProjectConfiguration projectConfig
= ConfigurationManager.getManager().getProjectConfiguration(project);
ValidatorMetaData[] meta = projectConfig.getValidators();
List enables = new ArrayList();
for(int i=0;i<meta.length;i++){
if(!meta[i].getValidatorUniqueName().equals(HTMLValidator.class.getName())){
enables.add(meta[i]);
}
}
projectConfig.setDoesProjectOverride(true);
projectConfig.setEnabledManualValidators(
(ValidatorMetaData[])enables.toArray(new ValidatorMetaData[enables.size()]));
projectConfig.setEnabledBuildValidators(
(ValidatorMetaData[])enables.toArray(new ValidatorMetaData[enables.size()]));
} catch(Exception ex){
//ex.printStackTrace();
}
if (monitor != null) {
monitor.worked(1);
}
// Install Spring
if(config.getBooleanProperty(ClickFacetInstallDataModelProvider.USE_SPRING)){
deploySpringFiles(project, config, monitor);
if (monitor != null) {
monitor.worked(1);
}
}
// Install Cayenne
if(config.getBooleanProperty(ClickFacetInstallDataModelProvider.USE_CAYENNE)){
deployCayenneFiles(project, config, monitor);
if (monitor != null) {
monitor.worked(1);
}
}