Index: LutinGeneratorEclipsePlugin/src/org/codelutin/eclipse/generator/core/LutinGeneratorProject.java diff -u /dev/null LutinGeneratorEclipsePlugin/src/org/codelutin/eclipse/generator/core/LutinGeneratorProject.java:1.1 --- /dev/null Wed Jun 20 12:40:40 2007 +++ LutinGeneratorEclipsePlugin/src/org/codelutin/eclipse/generator/core/LutinGeneratorProject.java Wed Jun 20 12:40:35 2007 @@ -0,0 +1,122 @@ +/* *##% + * Copyright (C) 2007 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package org.codelutin.eclipse.generator.core; + +import org.eclipse.core.resources.ICommand; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IProjectNature; +import org.eclipse.core.runtime.CoreException; + +/** + * LutinGeneratorProject.java + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * @deprecated Essai non concluant de compilation en utilisant lutinprocessor + * + * Last update : $Date: 2007/06/20 12:40:35 $ + * By : $Author: chatellier $ + */ +public class LutinGeneratorProject implements IProjectNature { + + public final static String BUILDER_ID = "org.codelutin.eclipse.generator.LutinGeneratorBuilder"; + + private IProject project; + + /** + * @param parent + */ + public LutinGeneratorProject() { + super(); + } + + /* (non-Javadoc) + * @see org.eclipse.jdt.core.IJavaProject#getProject() + */ + public IProject getProject() { + // TODO Auto-generated method stub + return project; + } + + /* (non-Javadoc) + * @see org.eclipse.core.resources.IProjectNature#configure() + */ + public void configure() throws CoreException { + + System.out.println("configure called"); + + // nature + try { + IProjectDescription description = project.getDescription(); + String[] natures = description.getNatureIds(); + String[] newNatures = new String[natures.length + 1]; + System.arraycopy(natures, 0, newNatures, 0, natures.length); + newNatures[natures.length] = "org.codelutin.eclipse.generator.core.LutinGeneratorProject"; + description.setNatureIds(newNatures); + project.setDescription(description, null); + } catch (CoreException e) { + // Something went wrong + } + + + + // builder + IProjectDescription desc = project.getDescription(); + ICommand[] commands = desc.getBuildSpec(); + boolean found = false; + + for (int i = 0; i < commands.length; ++i) { + if (commands[i].getBuilderName().equals(BUILDER_ID)) { + found = true; + break; + } + } + if (!found) { + //add builder to project + ICommand command = desc.newCommand(); + command.setBuilderName(BUILDER_ID); + ICommand[] newCommands = new ICommand[commands.length + 1]; + + // Add it before other builders. + System.arraycopy(commands, 0, newCommands, 1, commands.length); + newCommands[0] = command; + desc.setBuildSpec(newCommands); + project.setDescription(desc, null); + } + + } + + /* (non-Javadoc) + * @see org.eclipse.core.resources.IProjectNature#deconfigure() + */ + public void deconfigure() throws CoreException { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject) + */ + public void setProject(IProject project) { + this.project = project; + } + +}