incubator-easyant-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1071768 [6/7] - in /incubator/easyant/easyant4e: ./ trunk/ trunk/org.apache.easyant/ trunk/org.apache.easyant/META-INF/ trunk/org.apache.easyant/lib/ trunk/org.apache.easyant4e.feature/ trunk/org.apache.easyant4e.releng/ trunk/org.apache.e...
Date Thu, 17 Feb 2011 20:23:04 GMT
Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreServiceImpl.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreServiceImpl.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreServiceImpl.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,210 @@
+/* 
+ *  Copyright 2008-2009 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+package org.apache.easyant4e.services;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.easyant.core.EasyAntConfiguration;
+import org.apache.easyant.core.EasyAntEngine;
+import org.apache.easyant.core.descriptor.PropertyDescriptor;
+import org.apache.easyant.core.factory.EasyantConfigurationFactory;
+import org.apache.easyant.core.report.EasyAntReport;
+import org.apache.easyant4e.Activator;
+import org.apache.easyant4e.ivyde.extension.RepositoryInstaller;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+
+import static org.apache.easyant4e.EasyAntConstants.EASYANT_BUILD_TYPES_ORG;
+import static org.apache.easyant4e.EasyAntConstants.EASYANT_BUILD_PLUGINS_ORG;
+import static org.apache.easyant4e.EasyAntConstants.PLUGINS_SETTINGS;
+
+import com.google.inject.Inject;
+
+/**
+ * 
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class EasyantCoreServiceImpl implements EasyantCoreService {
+
+	//TODO a déplacer dans pluginService
+	//TODO et ne pas recharger les settings à chaque fois ... faire un push du contexte
+	//TODO read workspace preference and project preference to Get the good Ivy instance for the EasyAnt Core
+	//IvySettings ivySettings = createIvySettingsForEACore(project);
+	//Ivy ivy = Ivy.newInstance(ivySettings);
+	//ivySettings.addRepositoryCacheManager(getRepositoryCacheManager());
+	//ivySettings.setBaseDir(getBaseDir(project));
+	
+/*
+	public Ivy getIvyInstance() {	
+		URL url = Activator.getDefault().getBundle().getResource(PLUGINS_SETTINGS);		
+		Ivy ivy = IvyContext.getContext().getIvy();
+		try{
+			ivy.configure(url);
+		} catch (ParseException e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot parse EasyAnt Ivy settings file: " + url, e);
+		} catch (IOException e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot read EasyAnt Ivy settings file: " + url, e);
+		}
+		IvySettings ivySettings = ivy.getSettings();
+		IvyContext ivyContext = IvyContext.pushNewContext();
+		ivyContext.setIvy(ivy);
+		return ivy;
+	}
+	*/
+	
+/*
+	private IvySettings createIvySettingsForEACore(IProject project) {
+		// Ivy ivy = IvyContext.pushNewCopyContext().getIvy();
+		// IvySettings ivySettings = ivy.getSettings();
+		IvySettings ivySettings = new IvySettings();
+
+		URL url = Activator.getDefault().getBundle().getResource(PLUGINS_SETTINGS);
+		try {
+			ivySettings.load(url);
+		} catch (ParseException e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot parse EasyAnt Ivy settings file: " + url, e);
+		} catch (IOException e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot read EasyAnt Ivy settings file: " + url, e);
+		}
+		//ivySettings.addRepositoryCacheManager(getRepositoryCacheManager());
+		ivySettings.setBaseDir(getBaseDir(project));
+		
+		return ivySettings;
+	}
+*/
+
+	public static final String CACHE_FILE = "easyant4e-cache-manager";
+	public static final String CACHE_NAME = "__easyant4e-cache-manager";
+
+/*	
+	// FIXME connect this on project instance
+	private static RepositoryCacheManager getRepositoryCacheManager() {
+		DefaultRepositoryCacheManager cacheManager = new DefaultRepositoryCacheManager();
+		BundleContext bundleContext = IvyPlugin.getDefault().getBundleContext();
+		cacheManager.setBasedir(bundleContext.getDataFile(CACHE_FILE));
+		cacheManager.setCheckmodified(true);
+		cacheManager.setUseOrigin(true);
+		cacheManager.setName(WorkspaceResolver.CACHE_NAME);
+		return cacheManager;
+	}
+*/
+	private EasyAntEngine easyAntEngine;
+	
+	@Inject
+	public void setEasyAntEngine(EasyAntEngine easyAntEngine){
+		this.easyAntEngine = easyAntEngine;
+	}
+	
+	//private static File getBaseDir(IProject project) {
+	//	return project.getLocation().toFile();
+	//}
+
+	public String getPluginsRepositoryPath() {
+		return pluginsRepository.getPath();
+	}
+
+	private File pluginsRepository;
+
+	public void installPluginsRepository() {
+		String userHome = System.getProperty("user.home");
+		File easyAntHome = new File(userHome, ".easyant");
+		if (!easyAntHome.exists()) {
+			boolean created = easyAntHome.mkdir();
+			if (!created) {
+				Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot create directory: " + easyAntHome);
+			}
+		}
+		this.pluginsRepository = new File(easyAntHome, "easyant-repository");
+		installLocalRepository();
+	}
+
+	private void installLocalRepository() {
+		if (!pluginsRepository.exists()) {
+			boolean created = pluginsRepository.mkdir();
+			if (!created) {
+				Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot create directory: " + pluginsRepository);
+			} else {
+				// populate the repository from the plugin
+				// TODO read preference to override default ivysettings.xml use
+				// to
+				// resolve build plugins
+				RepositoryInstaller repositoryInstaller = new RepositoryInstaller();
+				repositoryInstaller.install(pluginsRepository);
+			}
+		}
+		// HashMap<String, String> variables = new HashMap<String, String>();
+		// variables.put("easyant.repo.dir", pluginsRepository.getPath());
+		// ivySettings.addAllVariables(variables);
+	}
+
+	public String[] getAllCoreBuildTypes() {
+		try {
+			//getIvyInstance(null);
+			return easyAntEngine.getPluginService().searchModule(EASYANT_BUILD_TYPES_ORG, "*");
+		} catch (Exception e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, e.getMessage(), e);
+		}
+		return null;
+	}
+
+	public String[] getAllCorePlugins() {
+		try {
+			//getIvyInstance(null);
+			return easyAntEngine.getPluginService().searchModule(EASYANT_BUILD_PLUGINS_ORG, "*");
+		} catch (Exception e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, e.getMessage(), e);
+		}
+		return null;
+	}
+	
+	public List<PropertyDescriptor> getPropertiesForBuildType(String buildTypeName){
+		//getIvyInstance(null);
+		ArrayList<PropertyDescriptor> propertyDescriptors = new ArrayList<PropertyDescriptor>();
+		EasyAntReport eaReport = null;
+		try {
+			eaReport = easyAntEngine.getPluginService().getBuildTypeInfo(buildTypeName);
+		} catch (Exception e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, e.getMessage(), e);
+		}
+		if (eaReport != null) {
+			Map<String, PropertyDescriptor> properties = eaReport.getAvailableProperties();
+			for (Entry<String, PropertyDescriptor> entry : properties.entrySet()) {
+				PropertyDescriptor prop = entry.getValue();
+				propertyDescriptors.add(prop);
+			}
+		}
+		return propertyDescriptors;
+	}
+
+	public String getBuildTypeDescription(String buildTypeName) {
+		return easyAntEngine.getPluginService().getBuildTypeDescription(buildTypeName);
+	}
+
+	public String getPluginDescription(String pluginName) {
+		return easyAntEngine.getPluginService().getPluginDescription(pluginName);
+	}
+}

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantCoreServiceImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectService.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectService.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectService.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectService.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,79 @@
+/* 
+ *  Copyright 2008-2009 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+package org.apache.easyant4e.services;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.easyant.core.descriptor.EasyAntModuleDescriptor;
+import org.apache.easyant.core.descriptor.PropertyDescriptor;
+import org.apache.easyant.core.report.PhaseReport;
+import org.apache.easyant.core.report.TargetReport;
+import org.apache.easyant4e.EasyAntConstants;
+//import org.apache.ivy.Ivy;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * 
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public interface EasyantProjectService {
+
+	//Ivy getIvyInstance(IProject project);
+	
+	IProject importProject(IProjectDescription projectDescription, Shell messageShell, IProgressMonitor monitor);
+	
+	boolean hasEasyAntNature(IProject project);
+	
+	boolean hasEasyAntBuilder(IProject project);
+	
+	void addNature(IProject project);
+	
+	void removeNature(IProject project);
+	
+	/**
+	 * @param project
+	 * @param buildTaskName
+	 * @param logLevel @see {@link EasyAntConstants#ANT_LOGLEVEL_DEBUG}, ...
+	 * @param monitor
+	 */
+	void runBuild(IProject project, String buildTaskName, int logLevel, IProgressMonitor monitor);
+	
+	/**
+	 * @return a list of available phases
+	 */
+	List<PhaseReport> getPhases(IFile ivyFile);
+	
+	/**
+	 * @return a list of available targets
+	 */
+	List<TargetReport> getTargets(IFile ivyFile);
+	
+	EasyAntModuleDescriptor getEasyAntModuleDescriptor(File file);
+	
+	Map<String, PropertyDescriptor> getProperties(IProject project);
+	
+	PropertyDescriptor getProperty(IProject project, String name);
+	
+}

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectService.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectServiceImpl.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectServiceImpl.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectServiceImpl.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,378 @@
+/* 
+ *  Copyright 2008-2009 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+package org.apache.easyant4e.services;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Vector;
+
+import org.apache.easyant.core.EasyAntConfiguration;
+import org.apache.easyant.core.EasyAntEngine;
+import org.apache.easyant.core.EasyAntMagicNames;
+import org.apache.easyant.core.descriptor.EasyAntModuleDescriptor;
+import org.apache.easyant.core.descriptor.PropertyDescriptor;
+import org.apache.easyant.core.factory.EasyantConfigurationFactory;
+import org.apache.easyant.core.report.EasyAntReport;
+import org.apache.easyant.core.report.PhaseReport;
+import org.apache.easyant.core.report.TargetReport;
+import org.apache.easyant4e.Activator;
+import org.apache.easyant4e.EasyAntConstants;
+import org.apache.easyant4e.EasyAntPlugin;
+import org.apache.easyant4e.console.EasyAntConsole;
+import org.apache.easyant4e.natures.AddEasyAntNatureOperation;
+import org.apache.easyant4e.natures.EasyAntNature;
+import org.apache.easyant4e.natures.RemoveEasyAntNatureOperation;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+
+import com.google.inject.Inject;
+
+/**
+ * 
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class EasyantProjectServiceImpl implements EasyantProjectService{
+
+	private EasyAntConsole console;
+	
+	private EasyantCoreService easyantCoreService;
+	
+	private EasyAntEngine easyAntEngine;
+	
+	@Inject
+	public void setEasyAntEngine(EasyAntEngine easyAntEngine){
+		this.easyAntEngine = easyAntEngine;
+	}
+
+	@Inject
+	public void setEasyantCoreService(EasyantCoreService easyantCoreService) {
+		this.easyantCoreService = easyantCoreService;
+	}
+
+	@Inject 
+	public void setEasyAntConsole(EasyAntConsole console) {
+		this.console = console;
+	}
+
+/*	
+	public Ivy getIvyInstance(IProject project) {
+		//TODO read workspace and project preference to load good Ivy instance must be used by the given project
+		return easyantCoreService.getIvyInstance(project);// by default return the ivy instance used by Easyant core
+	}
+*/
+	public void runBuild(IProject project, String buildTaskName, int logLevel, IProgressMonitor monitor) {
+		console.show();
+		console.info("\n");
+		console.info(project.getName() + "$ easyant " + buildTaskName+"\n");
+		
+		IFile ivyFile = project.getFile("module.ivy");
+		String ivyFilePath = ivyFile.getLocation().toOSString();
+		File buildModule = new File(ivyFilePath);
+		
+		URL easyantIvySettingsUrl = Activator.getDefault().getBundle().getResource(EasyAntConstants.PLUGINS_SETTINGS);
+		
+		Properties properties = new Properties();
+		properties.put("basedir",project.getLocation().toOSString());
+		properties.put("build.compiler", "org.eclipse.jdt.core.JDTCompilerAdapter");
+		properties.put("easyant.modules.dir", easyantCoreService.getPluginsRepositoryPath());
+				
+		//junit plugin under eclipse
+		//if property is true : Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.
+		properties.put("test.run.fork", "false");
+		
+		EasyAntConfiguration configuration = EasyantConfigurationFactory.getInstance().createDefaultConfiguration();
+		configuration.setShowMemoryDetails(true);
+		//configuration.setBuildFile(buildFile); //TODO manage module.ant file
+		configuration.setBuildModule(buildModule);
+		configuration.setDefinedProps(properties);
+		configuration.setMsgOutputLevel(logLevel);
+		Vector<String> targets = new Vector<String>();
+		targets.add(buildTaskName);
+		configuration.setTargets(targets);
+		configuration.setEasyantIvySettingsUrl(easyantIvySettingsUrl.toString());
+		
+		PrintStream outStream = getConsoleOutStream();
+		configuration.setOut(outStream);
+		
+		PrintStream errStream = getConsoleErrStream();
+		configuration.setErr(errStream);
+		
+		//TODO lancer cela dans une WorkspaceModifyOperation
+		try{
+			EasyAntEngine.runBuild(configuration);
+		}catch (Exception be) {
+			Activator.getEasyAntPlugin().log(IStatus.WARNING, be.getMessage());
+		}
+		
+		outStream.close();
+		errStream.close();
+		
+	}
+
+	private PrintStream getConsoleOutStream(){		
+		console.show(true);
+		return new PrintStream(new OutputStream(){
+			private StringBuffer sb = new StringBuffer();
+			@Override
+			public void write(int b) throws IOException {
+				if(b!=10){
+					sb.append((char)b);
+				}else{
+					String message = sb.toString();
+					console.info(message);
+					sb = new StringBuffer();
+				}				
+			}
+			
+		});
+	}
+
+	private PrintStream getConsoleErrStream(){		
+		console.show(true);
+		return new PrintStream(new OutputStream(){
+			private StringBuffer sb = new StringBuffer();
+			@Override
+			public void write(int b) throws IOException {
+				if(b!=10){
+					sb.append((char)b);
+				}else{
+					String message = sb.toString();
+					console.error(message);
+					sb = new StringBuffer();
+				}				
+			}
+			
+		});
+	}
+
+	public boolean hasEasyAntNature(IProject project){
+		try {
+			return project.hasNature(EasyAntNature.NATURE_ID);
+		} catch (CoreException e) {
+			Activator.getEasyAntPlugin().log(e);
+		}
+		return false;
+	}
+	
+	public boolean hasEasyAntBuilder(IProject project){
+		ICommand[] commands=null;
+		try {
+			commands = project.getProject().getDescription().getBuildSpec();
+		} catch (CoreException e) {
+			Activator.getEasyAntPlugin().log(e);
+		}		
+		boolean found = false;
+		if(commands!=null){		
+			for (int i = 0; i < commands.length; ++i) {
+				if (commands[i].getBuilderName().equals(EasyAntNature.BUILDER_ID)){
+					found = true;
+				}
+			}	
+		}	
+		return found;
+	}
+	
+
+	public void addNature(IProject project) {
+		addNature(project, null, null);	
+	}
+	
+	private void addNature(IProject project, Shell shell, IProgressMonitor monitor) {
+
+		AddEasyAntNatureOperation addNature = new AddEasyAntNatureOperation(project);
+		try {
+			if(shell==null && monitor==null){
+				PlatformUI.getWorkbench().getProgressService().run(false, false, addNature);
+			}else{
+				addNature.run(monitor);
+			}
+		} catch (InvocationTargetException e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot add EasyAnt nature.", e);
+		} catch (InterruptedException e) {
+			Activator.getEasyAntPlugin().log(IStatus.CANCEL, "Add EasyAnt nature operation aborted!", e);
+		}
+		// TODO launch resolve (ask to user)
+		// TODO initialize IvyDE classpath container
+		// TODO maybe launch the first build ??	
+	}
+	
+	public void removeNature(IProject project) {
+		// Remove the nature on the given project
+		RemoveEasyAntNatureOperation removeNature = new RemoveEasyAntNatureOperation(project);
+		try {
+			PlatformUI.getWorkbench().getProgressService().run(false, false, removeNature);
+		} catch (InvocationTargetException e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot remove EasyAnt nature.", e);
+		} catch (InterruptedException e) {
+			Activator.getEasyAntPlugin().log(IStatus.CANCEL, "Remove EasyAnt nature operation aborted!", e);
+		}
+		// TODO remove IvyDE classpath container
+		
+	}
+
+	public IProject importProject(IProjectDescription projectDescription,  Shell messageShell, IProgressMonitor monitor) {
+		//String projectName = importProjectDescriptor.getProjectName();
+		//IProjectDescription projectDescription = importProjectDescriptor.getDescription();
+		String projectName = projectDescription.getName();
+		final IWorkspace workspace = ResourcesPlugin.getWorkspace();
+		final IProject project = workspace.getRoot().getProject(projectName);
+//		if (projectDescription == null) {
+//			// error case
+//			projectDescription = workspace.newProjectDescription(projectName);
+//			IPath locationPath = new Path(importProjectDescriptor.getProjectSystemFile().getAbsolutePath());
+//
+//			// If it is under the root use the default location
+//			if (Platform.getLocation().isPrefixOf(locationPath)) {
+//				projectDescription.setLocation(null);
+//			} else {
+//				projectDescription.setLocation(locationPath);
+//			}
+//		} else {
+//			projectDescription.setName(projectName);
+//		}
+
+//		if (importProjectDescriptor.isFromIvyDescription()) {
+			// import form Ivy description
+			File importSource = new File(projectDescription.getLocationURI());
+			IWorkspaceRoot rootWorkspace = workspace.getRoot();
+			ImportOperation importOperation = new ImportOperation(rootWorkspace.getFullPath(),importSource,FileSystemStructureProvider.INSTANCE, new IOverwriteQuery(){
+					public String queryOverwrite(String pathString) { return ALL; }
+			});
+			importOperation.setContext(messageShell);
+			try {
+				//PlatformUI.getWorkbench().getProgressService().run(false, false, importOperation);
+				importOperation.run(monitor);
+			} catch (InvocationTargetException e) {
+				Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot import project.", e);
+			} catch (InterruptedException e) {
+				Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot import project.", e);
+			}			
+//		}
+
+		try {
+			monitor.beginTask("Creating project ...", 100);
+			project.create(projectDescription, new SubProgressMonitor(monitor, 30));
+			project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 70));
+			// configure project, apply EasyAnt nature
+//			if (importProjectDescriptor.isFromIvyDescription()) {
+				addNature(project, messageShell, monitor);
+//			}
+		} catch (CoreException e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, "Cannot configure imported project.", e);
+			return null;
+		} finally {
+			monitor.done();		
+		}
+		return project;
+		
+	}
+	
+	public List<PhaseReport> getPhases(IFile ivyFile) {
+		EasyAntReport easyAntReport = null;
+		try {
+			//loadEasyAntIvySettings(ivyFile.getProject());
+			File f = new File(ivyFile.getLocation().toPortableString());
+			easyAntReport = easyAntEngine.getPluginService().generateEasyAntReport(f);
+		} catch (Exception e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, e.getMessage(), e);
+		}
+		if (easyAntReport != null) {
+			return easyAntReport.getAvailablePhases();
+		}
+		return Collections.emptyList();
+	}
+
+	//private File getBaseDir(IProject project) {
+	//	return project.getLocation().toFile();
+	//}
+	
+	public List<TargetReport> getTargets(IFile ivyFile) {
+		EasyAntReport easyAntReport = null;
+		try {
+			File f = new File(ivyFile.getLocation().toPortableString());
+			easyAntReport = easyAntEngine.getPluginService().generateEasyAntReport(f);
+		} catch (Exception e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, e.getMessage(), e);
+		}
+		if (easyAntReport != null) {
+			return easyAntReport.getUnboundTargets();
+		}
+		return Collections.emptyList();
+	}
+
+	public EasyAntModuleDescriptor getEasyAntModuleDescriptor(File file) {
+		EasyAntModuleDescriptor moduleDescriptor=null;
+		try {
+			moduleDescriptor = easyAntEngine.getPluginService().getEasyAntModuleDescriptor(file);
+		} catch (Exception e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, e.getMessage(), e);
+		}
+		return moduleDescriptor;
+	}
+	
+	public Map<String, PropertyDescriptor> getProperties(IProject project){
+		IFile ivyFile = project.getFile("module.ivy");
+		String ivyFilePath = ivyFile.getLocation().toOSString();
+		File moduleDescriptor = new File(ivyFilePath);
+		EasyAntReport easyAntReport=null;
+		try {
+			easyAntReport = easyAntEngine.getPluginService().generateEasyAntReport(moduleDescriptor);			
+		} catch (Exception e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, e.getMessage(), e);
+		}				
+		if(easyAntReport!=null){
+			return easyAntReport.getAvailableProperties();
+		}
+		return Collections.emptyMap();
+	}
+	
+	public PropertyDescriptor getProperty(IProject project, String name){
+		Map<String, PropertyDescriptor> properties = getProperties(project);
+		if(properties.containsKey(name)){
+			PropertyDescriptor propertyDescriptor = properties.get(name);			
+			return propertyDescriptor;
+		}else{
+			return null;
+		}
+	}
+	
+}

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/services/EasyantProjectServiceImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizard.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizard.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizard.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizard.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,70 @@
+/* 
+ *  Copyright 2008-2009 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+package org.apache.easyant4e.wizards;
+
+import org.apache.easyant4e.Activator;
+import org.apache.easyant4e.providers.ImageProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+import com.google.inject.Inject;
+
+/**
+ * 
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class EasyAntImportWizard extends Wizard implements IImportWizard {
+
+	private EasyAntImportWizardPage importPage;
+	
+	private ImageProvider imageProvider;
+	
+	public EasyAntImportWizard(){
+		Activator.getEasyAntPlugin().injectMembers(this);
+	}
+		
+	@Inject
+	public void setImageProvider(ImageProvider imageProvider) {
+		this.imageProvider = imageProvider;
+	}
+
+	@Inject 
+	void setEasyAntImportWizardPage(EasyAntImportWizardPage importPage){
+		this.importPage=importPage;
+	}
+	
+	public void addPages() {
+		//importPage = new EasyAntImportWizardPage();
+		super.addPage(importPage);
+	}
+
+	@Override
+	public boolean performFinish() {
+		return importPage.createProjects();
+	}
+
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+		setNeedsProgressMonitor(true);
+		setWindowTitle("Import EasyAnt Projects");		
+		setDefaultPageImageDescriptor(imageProvider.getLogoImageDescriptor());
+	}
+
+}

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizard.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizard.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizardPage.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizardPage.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizardPage.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizardPage.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,649 @@
+/* 
+ *  Copyright 2008-2009 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+package org.apache.easyant4e.wizards;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.easyant4e.Activator;
+import org.apache.easyant4e.natures.AddEasyAntNatureOperation;
+import org.apache.easyant4e.services.EasyantProjectService;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+
+import com.google.inject.Inject;
+
+//import com.google.inject.Inject;
+
+/**
+ * This wizard is used to import existing EasyAnt Projects
+ * 
+ * Inspired from WizardProjectsImportPage
+ * 
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class EasyAntImportWizardPage extends WizardPage {
+	
+	private EasyantProjectService easyantProjectService;
+	
+	@Inject
+	public void setEasyantProjectService(EasyantProjectService easyantProjectService) {
+		this.easyantProjectService = easyantProjectService;
+	}
+
+	public EasyAntImportWizardPage() {
+		super("Import EasyAnt projects");
+		setPageComplete(false);
+		setTitle("Import EasyAnt projects");
+		setDescription("Select a directory to search for existing EasyAnt projects.");
+	}
+
+	/**
+	 * The name of the folder containing metadata information for the workspace.
+	 */
+	public static final String METADATA_FOLDER = ".metadata"; //$NON-NLS-1$
+	//FIXME hard coded the folder name ?
+	public static final String TARGET_FOLDER = "target"; //$NON-NLS-1$
+	
+	
+	private Text directoryPathField;
+
+	private CheckboxTreeViewer projectsList;
+
+	private ProjectRecord[] selectedProjects = new ProjectRecord[0];
+
+	// Keep track of the directory that we browsed to last time
+	// the wizard was invoked.
+	private static String previouslyBrowsedDirectory = ""; //$NON-NLS-1$
+
+	private Button browseDirectoriesButton;
+
+	private IProject[] wsProjects;
+
+	// The last selected path to minimize searches
+	private String lastPath;
+	// The last time that the file or folder at the selected path was modified
+	// to mimize searches
+	private long lastModified;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+	 * .Composite)
+	 */
+	public void createControl(Composite parent) {
+
+		initializeDialogUnits(parent);
+
+		Composite workArea = new Composite(parent, SWT.NONE);
+		setControl(workArea);
+
+		workArea.setLayout(new GridLayout());
+		workArea.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
+
+		createProjectsRoot(workArea);
+		createProjectsList(workArea);
+		createOptionsArea(workArea);
+		Dialog.applyDialogFont(workArea);
+
+	}
+
+	/**
+	 * Create the area with the extra options.
+	 * 
+	 * @param workArea
+	 */
+	private void createOptionsArea(Composite workArea) {
+		Composite optionsGroup = new Composite(workArea, SWT.NONE);
+		optionsGroup.setLayout(new GridLayout());
+		optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+	}
+
+	/**
+	 * Create the checkbox list for the found projects.
+	 * 
+	 * @param workArea
+	 */
+	private void createProjectsList(Composite workArea) {
+
+		Label title = new Label(workArea, SWT.NONE);		
+		title.setText("EasyAnt Projects:");
+
+		Composite listComposite = new Composite(workArea, SWT.NONE);
+		GridLayout layout = new GridLayout();
+		layout.numColumns = 2;
+		layout.marginWidth = 0;
+		layout.makeColumnsEqualWidth = false;
+		listComposite.setLayout(layout);
+
+		listComposite
+				.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
+
+		projectsList = new CheckboxTreeViewer(listComposite, SWT.BORDER);
+		GridData listData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
+		projectsList.getControl().setLayoutData(listData);
+
+		projectsList.setContentProvider(new ITreeContentProvider() {
+			public Object[] getChildren(Object parentElement) {
+				return null;
+			}
+
+			public Object[] getElements(Object inputElement) {
+				return getValidProjects();
+			}
+
+			public boolean hasChildren(Object element) {
+				return false;
+			}
+
+			public Object getParent(Object element) {
+				return null;
+			}
+
+			public void dispose() {
+
+			}
+
+			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+			}
+
+		});
+
+		projectsList.setLabelProvider(new LabelProvider() {
+			public String getText(Object element) {
+				return ((ProjectRecord) element).getProjectLabel();
+			}
+		});
+
+		projectsList.addCheckStateListener(new ICheckStateListener() {
+			public void checkStateChanged(CheckStateChangedEvent event) {
+				setPageComplete(projectsList.getCheckedElements().length > 0);
+			}
+		});
+		projectsList.setInput(this);
+		projectsList.setComparator(new ViewerComparator());
+		createSelectionButtons(listComposite);
+	}
+
+	/**
+	 * Create the selection buttons in the listComposite.
+	 * 
+	 * @param listComposite
+	 */
+	private void createSelectionButtons(Composite listComposite) {
+		Composite buttonsComposite = new Composite(listComposite, SWT.NONE);
+		GridLayout layout = new GridLayout();
+		layout.marginWidth = 0;
+		layout.marginHeight = 0;
+		buttonsComposite.setLayout(layout);
+
+		buttonsComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+
+		Button selectAll = new Button(buttonsComposite, SWT.PUSH);
+		selectAll.setText("Select All");
+		selectAll.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				projectsList.setCheckedElements(selectedProjects);
+				setPageComplete(projectsList.getCheckedElements().length > 0);
+			}
+		});
+		Dialog.applyDialogFont(selectAll);
+		setButtonLayoutData(selectAll);
+
+		Button deselectAll = new Button(buttonsComposite, SWT.PUSH);
+		deselectAll.setText("Deselect All");
+		deselectAll.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+
+				projectsList.setCheckedElements(new Object[0]);
+				setPageComplete(false);
+			}
+		});
+		Dialog.applyDialogFont(deselectAll);
+		setButtonLayoutData(deselectAll);
+
+		Button refresh = new Button(buttonsComposite, SWT.PUSH);
+		refresh.setText("Refresh");
+		refresh.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				updateProjectsList(directoryPathField.getText().trim());
+			}
+		});
+		Dialog.applyDialogFont(refresh);
+		setButtonLayoutData(refresh);
+	}
+
+	/**
+	 * Create the area where you select the root directory for the projects.
+	 * 
+	 * @param workArea
+	 *            Composite
+	 */
+	private void createProjectsRoot(Composite workArea) {
+		// project specification group
+		Composite projectGroup = new Composite(workArea, SWT.NONE);
+		GridLayout layout = new GridLayout();
+		layout.numColumns = 3;
+		layout.makeColumnsEqualWidth = false;
+		layout.marginWidth = 0;
+		projectGroup.setLayout(layout);
+		projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+		// project location entry field
+		this.directoryPathField = new Text(projectGroup, SWT.BORDER);
+
+		this.directoryPathField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
+
+		// browse button
+		browseDirectoriesButton = new Button(projectGroup, SWT.PUSH);
+		browseDirectoriesButton.setText("Browse");
+		setButtonLayoutData(browseDirectoriesButton);
+
+		browseDirectoriesButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				handleLocationDirectoryButtonPressed();
+			}
+
+		});
+
+		directoryPathField.addTraverseListener(new TraverseListener() {
+			public void keyTraversed(TraverseEvent e) {
+				if (e.detail == SWT.TRAVERSE_RETURN) {
+					e.doit = false;
+					updateProjectsList(directoryPathField.getText().trim());
+				}
+			}
+
+		});
+
+		directoryPathField.addFocusListener(new FocusAdapter() {
+			public void focusLost(org.eclipse.swt.events.FocusEvent e) {
+				updateProjectsList(directoryPathField.getText().trim());
+			}
+
+		});
+	}
+
+	/*
+	 * (non-Javadoc) Method declared on IDialogPage. Set the focus on path
+	 * fields when page becomes visible.
+	 */
+	public void setVisible(boolean visible) {
+		super.setVisible(visible);
+		if (visible) {
+			this.directoryPathField.setFocus();
+		}
+	}
+
+	/**
+	 * Update the list of projects based on path. Method declared public only
+	 * for test suite.
+	 * 
+	 * @param path
+	 */
+	public void updateProjectsList(final String path) {
+		// on an empty path empty selectedProjects
+		if (path == null || path.length() == 0) {
+			setMessage("Import Projects Description");
+			selectedProjects = new ProjectRecord[0];
+			projectsList.refresh(true);
+			projectsList.setCheckedElements(selectedProjects);
+			setPageComplete(projectsList.getCheckedElements().length > 0);
+			lastPath = path;
+			return;
+		}
+
+		final File directory = new File(path);
+		long modified = directory.lastModified();
+		if (path.equals(lastPath) && lastModified == modified) {
+			// since the file/folder was not modified and the path did not
+			// change, no refreshing is required
+			return;
+		}
+
+		lastPath = path;
+		lastModified = modified;
+
+		// We can't access the radio button from the inner class so get the
+		// status beforehand
+		// final boolean dirSelected =
+		// this.projectFromDirectoryRadio.getSelection();
+		try {
+			getContainer().run(true, true, new IRunnableWithProgress() {
+
+				public void run(IProgressMonitor monitor) {
+					monitor.beginTask("Searching", 100);
+					selectedProjects = new ProjectRecord[0];
+					Collection files = new ArrayList();
+					monitor.worked(10);
+					if (directory.isDirectory()) {
+
+						if (!collectProjectFilesFromDirectory(files, directory, null, monitor)) {
+							return;
+						}
+						Iterator filesIterator = files.iterator();
+						selectedProjects = new ProjectRecord[files.size()];
+						int index = 0;
+						monitor.worked(50);
+						monitor.subTask("Processing");
+						while (filesIterator.hasNext()) {
+							File file = (File) filesIterator.next();
+							ProjectRecord projectRecord = new ProjectRecord(file, lastPath);							
+							selectedProjects[index] = projectRecord;
+							index++;
+						}
+					} else {
+						monitor.worked(60);
+					}
+					monitor.done();
+				}
+
+			});
+		} catch (InvocationTargetException e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, e.getMessage());
+		} catch (InterruptedException e) {
+			// Nothing to do if the user interrupts.
+		}
+
+		projectsList.refresh(true);
+		projectsList.setCheckedElements(getValidProjects());
+		if (getValidProjects().length < selectedProjects.length) {
+			setMessage("Projects in workspace", WARNING);
+		} else {
+			setMessage("Import projects description");
+		}
+		setPageComplete(projectsList.getCheckedElements().length > 0);
+	}
+
+	/**
+	 * Display an error dialog with the specified message.
+	 * 
+	 * @param message
+	 *            the error message
+	 */
+	protected void displayErrorDialog(String message) {
+		MessageDialog.openError(getContainer().getShell(), getErrorDialogTitle(), message);
+	}
+
+	/**
+	 * Get the title for an error dialog. Subclasses should override.
+	 */
+	protected String getErrorDialogTitle() {
+		// FIXME
+		return "internalErrorTitle";
+	}
+
+	/**
+	 * Collect the list of .project files that are under directory into files.
+	 * 
+	 * @param files
+	 * @param directory
+	 * @param directoriesVisited
+	 *            Set of canonical paths of directories, used as recursion guard
+	 * @param monitor
+	 *            The monitor to report to
+	 * @return boolean <code>true</code> if the operation was completed.
+	 */
+	private boolean collectProjectFilesFromDirectory(Collection files, File directory, Set directoriesVisited,
+			IProgressMonitor monitor) {
+
+		if (monitor.isCanceled()) {
+			return false;
+		}
+		monitor.subTask("Collect project files from "+ directory.getPath());
+		File[] contents = directory.listFiles();
+		if (contents == null){
+			return false;
+		}
+
+		// Initialize recursion guard for recursive symbolic links
+		if (directoriesVisited == null) {
+			directoriesVisited = new HashSet();
+			try {
+				directoriesVisited.add(directory.getCanonicalPath());
+			} catch (IOException exception) {
+				Activator.getEasyAntPlugin().log(IStatus.ERROR, exception.getMessage(), exception);
+			}
+		}
+		// first look for EasyAnt description files
+		for (int i = 0; i < contents.length; i++) {
+			File file = contents[i];
+			if (file.isFile() && file.getName().endsWith("ivy")) {
+				files.add(file);				
+			}else if (contents[i].isDirectory()) {
+				if (!contents[i].getName().equals(METADATA_FOLDER) && !contents[i].getName().equals(TARGET_FOLDER)) {
+					try {
+						String canonicalPath = contents[i].getCanonicalPath();
+						if (!directoriesVisited.add(canonicalPath)) {
+							// already been here --> do not recurse
+							continue;
+						}
+					} catch (IOException exception) {
+						Activator.getEasyAntPlugin().log(IStatus.ERROR, exception.getMessage(), exception);
+
+					}
+					collectProjectFilesFromDirectory(files, contents[i], directoriesVisited, monitor);
+				}
+			}
+		}
+		return true;
+	}
+	/**
+	 * The browse button has been selected. Select the location.
+	 */
+	protected void handleLocationDirectoryButtonPressed() {
+		DirectoryDialog dialog = new DirectoryDialog(directoryPathField.getShell());
+		dialog.setMessage("Select directory to scan");
+
+		String dirName = directoryPathField.getText().trim();
+		if (dirName.length() == 0) {
+			dirName = previouslyBrowsedDirectory;
+		}
+
+		if (dirName.length() == 0) {
+			dialog.setFilterPath(Activator.getEasyAntPlugin().getPluginWorkspace().getRoot().getLocation().toOSString());
+		} else {
+			File path = new File(dirName);
+			if (path.exists()) {
+				dialog.setFilterPath(new Path(dirName).toOSString());
+			}
+		}
+
+		String selectedDirectory = dialog.open();
+		if (selectedDirectory != null) {
+			previouslyBrowsedDirectory = selectedDirectory;
+			directoryPathField.setText(previouslyBrowsedDirectory);
+			updateProjectsList(selectedDirectory);
+		}
+
+	}
+
+
+	/**
+	 * Create the selected projects
+	 * 
+	 * @return boolean <code>true</code> if all project creations were
+	 *         successful.
+	 */
+	public boolean createProjects() {		
+		final Object[] selected = projectsList.getCheckedElements();
+		WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+			protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+				try {
+					monitor.beginTask("", selected.length); //$NON-NLS-1$
+					if (monitor.isCanceled()) {
+						throw new OperationCanceledException();
+					}
+					for (int i = 0; i < selected.length; i++) {
+						createExistingProject((ProjectRecord) selected[i], new SubProgressMonitor(monitor, 1));
+					}
+				} finally {
+					monitor.done();
+				}
+			}
+		};
+		// run the new project creation operation
+		try {
+			getContainer().run(true, true, op);
+		} catch (InterruptedException e) {
+			return false;
+		} catch (InvocationTargetException e) {
+			// one of the steps resulted in a core exception
+			Throwable t = e.getTargetException();
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, t.getMessage(), t);
+			String message = "Cannot import project";
+			IStatus status;
+			if (t instanceof CoreException) {
+				status = ((CoreException) t).getStatus();
+			} else {
+				status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 1, message, t);
+			}
+			ErrorDialog.openError(getShell(), message, null, status);
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * Create the project described in record. If it is successful return true.
+	 * 
+	 * @param record
+	 * @return boolean <code>true</code> if successful
+	 * @throws InterruptedException
+	 */
+	private IProject createExistingProject(final ProjectRecord record, IProgressMonitor monitor)
+			throws InvocationTargetException, InterruptedException {		
+		return easyantProjectService.importProject(record.getDescription(), getShell(), monitor);
+	}
+
+	/**
+	 * Method used for test suite.
+	 * 
+	 * @return CheckboxTreeViewer the viewer containing all the projects found
+	 */
+	public CheckboxTreeViewer getProjectsList() {
+		return projectsList;
+	}
+
+	/**
+	 * Retrieve all the projects in the current workspace.
+	 * 
+	 * @return IProject[] array of IProject in the current workspace
+	 */
+	private IProject[] getProjectsInWorkspace() {
+		if (wsProjects == null) {
+			wsProjects = Activator.getEasyAntPlugin().getPluginWorkspace().getRoot().getProjects();
+		}
+		return wsProjects;
+	}
+
+	/**
+	 * Get the array of valid project records that can be imported from the
+	 * source workspace or archive, selected by the user. If a project with the
+	 * same name exists in both the source workspace and the current workspace,
+	 * it will not appear in the list of projects to import and thus cannot be
+	 * selected for import.
+	 * 
+	 * Method declared public for test suite.
+	 * 
+	 * @return ProjectRecord[] array of projects that can be imported into the
+	 *         workspace
+	 */
+	public ProjectRecord[] getValidProjects() {
+		List validProjects = new ArrayList();
+		for (int i = 0; i < selectedProjects.length; i++) {
+			if (!isProjectInWorkspace(selectedProjects[i].getProjectName())) {
+				validProjects.add(selectedProjects[i]);
+			}
+		}
+		return (ProjectRecord[]) validProjects.toArray(new ProjectRecord[validProjects.size()]);
+	}
+
+	/**
+	 * Determine if the project with the given name is in the current workspace.
+	 * 
+	 * @param projectName
+	 *            String the project name to check
+	 * @return boolean true if the project with the given name is in this
+	 *         workspace
+	 */
+	private boolean isProjectInWorkspace(String projectName) {
+		if (projectName == null) {
+			return false;
+		}
+		IProject[] workspaceProjects = getProjectsInWorkspace();
+		for (int i = 0; i < workspaceProjects.length; i++) {
+			if (projectName.equals(workspaceProjects[i].getName())) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
+}

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizardPage.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/EasyAntImportWizardPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/ProjectRecord.java
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/ProjectRecord.java?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/ProjectRecord.java (added)
+++ incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/ProjectRecord.java Thu Feb 17 20:22:56 2011
@@ -0,0 +1,155 @@
+/* 
+ *  Copyright 2008-2009 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+package org.apache.easyant4e.wizards;
+
+import java.io.File;
+
+import org.apache.easyant.core.descriptor.EasyAntModuleDescriptor;
+import org.apache.easyant4e.Activator;
+import org.apache.easyant4e.services.EasyantProjectService;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+
+import com.google.inject.Inject;
+
+
+/**
+ * 
+ * @author <a href="mailto:jerome@benois.fr">Jerome Benois</a>
+ */
+public class ProjectRecord {
+	
+	private EasyantProjectService easyantProjectService;
+	
+	private String lastPath;
+	
+	private File projectSystemFile;
+
+	public File getProjectSystemFile() {
+		return projectSystemFile;
+	}
+
+	private String projectName;
+
+	private boolean fromIvyDescription = false;
+
+	private IProjectDescription description;
+
+	public IProjectDescription getDescription() {
+		return description;
+	}
+
+	@Inject
+	public void setEasyantProjectService(EasyantProjectService easyantProjectService){
+		this.easyantProjectService = easyantProjectService;
+	}
+
+	/**
+	 * Create a record for a project based on the info in the file.
+	 * 
+	 * @param file
+	 */
+	ProjectRecord(File file, String lastPath) {
+		Activator.getEasyAntPlugin().injectMembers(this);
+		this.projectSystemFile = file;
+		this.lastPath = lastPath;
+		setProjectName();
+	}
+
+	/**
+	 * Set the name of the project based on the projectFile.
+	 */
+	private void setProjectName() {
+		try {
+			// If we don't have the project name try again
+			IPath path = new Path(projectSystemFile.getPath());
+			if (projectName == null && !path.toOSString().endsWith("ivy")) {
+				// if the file is in the default location, use the directory
+				// name as the project name
+				if (isDefaultLocation(path)) {
+					projectName = path.segment(path.segmentCount() - 2);
+					description = Activator.getEasyAntPlugin().getPluginWorkspace().newProjectDescription(projectName);
+				} else {
+					description = Activator.getEasyAntPlugin().getPluginWorkspace().loadProjectDescription(path);
+					projectName = description.getName();
+				}
+
+			} else if (path.toOSString().endsWith("ivy")) {
+				fromIvyDescription = true;
+				// Load EasyantFile
+				File f = new File(path.toPortableString());
+				EasyAntModuleDescriptor moduleDescriptor = easyantProjectService.getEasyAntModuleDescriptor(f);
+				projectName = moduleDescriptor.getName();
+				description = Activator.getEasyAntPlugin().getPluginWorkspace().newProjectDescription(projectName);					
+				if(lastPath.endsWith(projectName)){
+					description.setLocation(new Path(lastPath));
+				}else{
+					description.setLocation(new Path(lastPath+"/"+ projectName));
+				}
+				description.setComment(moduleDescriptor.getDescription());
+				String[] newNatures= {};
+				description.setNatureIds(newNatures);					
+			}
+		} catch (Exception e) {
+			Activator.getEasyAntPlugin().log(IStatus.ERROR, e.getMessage(), e);
+		}
+	}
+
+	/**
+	 * Returns whether the given project description file path is in the
+	 * default location for a project
+	 * 
+	 * @param path
+	 *            The path to examine
+	 * @return Whether the given path is the default location for a project
+	 */
+	private boolean isDefaultLocation(IPath path) {
+		// The project description file must at least be within the project,
+		// which is within the workspace location
+		if (path.segmentCount() < 2)
+			return false;
+		return path.removeLastSegments(2).toFile().equals(Platform.getLocation().toFile());
+	}
+
+	/**
+	 * Get the name of the project
+	 * 
+	 * @return String
+	 */
+	public String getProjectName() {
+		return projectName;
+	}
+
+	/**
+	 * Gets the label to be used when rendering this project record in the
+	 * UI.
+	 * 
+	 * @return String the label
+	 */
+	public String getProjectLabel() {
+		return projectName;
+	}
+
+	public boolean isFromIvyDescription() {
+		return fromIvyDescription;
+	}
+}
\ No newline at end of file

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/ProjectRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/ProjectRecord.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/org/apache/easyant4e/wizards/ProjectRecord.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/repository.zip
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/repository.zip?rev=1071768&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/easyant/easyant4e/trunk/org.apache.easyant4e/src/repository.zip
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/easyant/easyant4e/trunk/quality/.project
URL: http://svn.apache.org/viewvc/incubator/easyant/easyant4e/trunk/quality/.project?rev=1071768&view=auto
==============================================================================
--- incubator/easyant/easyant4e/trunk/quality/.project (added)
+++ incubator/easyant/easyant4e/trunk/quality/.project Thu Feb 17 20:22:56 2011
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>quality</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+	</buildSpec>
+	<natures>
+	</natures>
+</projectDescription>

Propchange: incubator/easyant/easyant4e/trunk/quality/.project
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/easyant4e/trunk/quality/.project
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/easyant4e/trunk/quality/.project
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message