// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/ProjectConfigurationException.java
// public class ProjectConfigurationException extends AndroidMavenException {
// 
//     private static final long serialVersionUID = -4510508504367403748L;
// 
//     public ProjectConfigurationException(String message) {
//         super(message);
//     }
// 
//     public ProjectConfigurationException(Throwable cause) {
//         super(cause);
//     }
// 
//     public ProjectConfigurationException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
// }


import me.gladwell.eclipse.m2e.android.configuration.ProjectConfigurationException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
import org.eclipse.m2e.jdt.IClasspathDescriptor;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import com.google.inject.Inject;
    private final BundleContext osgi;

    @Inject
    public MultiToolkitEclipseAndroidProjectFactory(IWorkspace workspace, IMavenProjectRegistry registry, BundleContext osgi) {
        super();
        this.workspace = workspace;
        this.registry = registry;
        this.osgi = osgi;
    }

    public IDEAndroidProject createAndroidProject(IProject target) {
        ToolkitAdaptor adaptor = findToolkitAdaptor();
        return new EclipseAndroidProject(adaptor , registry, workspace, target);
    }

    public IDEAndroidProject createAndroidProject(IProject target, IClasspathDescriptor classpath) {
        ToolkitAdaptor adaptor = findToolkitAdaptor();
        return new EclipseAndroidProject(adaptor , registry, target, classpath);
    }

    private ToolkitAdaptor findToolkitAdaptor() {
        for(Toolkit toolkit : Toolkit.values()) {
            if(searchBundles(toolkit.pluginId())) {
                if(toolkit.equals(Toolkit.ADT)) {
                    return new AdtToolkitAdaptor();
                } else if(toolkit.equals(Toolkit.Andmore)) {
                    return new AndmoreToolkitAdaptor();
                }
            }
        }
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/ProjectConfigurationException.java
// public class ProjectConfigurationException extends AndroidMavenException {
// 
//     private static final long serialVersionUID = -4510508504367403748L;
// 
//     public ProjectConfigurationException(String message) {
//         super(message);
//     }
// 
//     public ProjectConfigurationException(Throwable cause) {
//         super(cause);
//     }
// 
//     public ProjectConfigurationException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
// }


// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/MultiToolkitEclipseAndroidProjectFactory.java
import me.gladwell.eclipse.m2e.android.configuration.ProjectConfigurationException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
import org.eclipse.m2e.jdt.IClasspathDescriptor;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import com.google.inject.Inject;

    private final BundleContext osgi;

    @Inject
    public MultiToolkitEclipseAndroidProjectFactory(IWorkspace workspace, IMavenProjectRegistry registry, BundleContext osgi) {
        super();
        this.workspace = workspace;
        this.registry = registry;
        this.osgi = osgi;
    }

    public IDEAndroidProject createAndroidProject(IProject target) {
        ToolkitAdaptor adaptor = findToolkitAdaptor();
        return new EclipseAndroidProject(adaptor , registry, workspace, target);
    }

    public IDEAndroidProject createAndroidProject(IProject target, IClasspathDescriptor classpath) {
        ToolkitAdaptor adaptor = findToolkitAdaptor();
        return new EclipseAndroidProject(adaptor , registry, target, classpath);
    }

    private ToolkitAdaptor findToolkitAdaptor() {
        for(Toolkit toolkit : Toolkit.values()) {
            if(searchBundles(toolkit.pluginId())) {
                if(toolkit.equals(Toolkit.ADT)) {
                    return new AdtToolkitAdaptor();
                } else if(toolkit.equals(Toolkit.Andmore)) {
                    return new AndmoreToolkitAdaptor();
                }
            }
        }
        throw new ProjectConfigurationException("no installed toolkit found");