You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2009/09/14 23:47:45 UTC

svn commit: r814877 [2/3] - in /ant/ivy/ivyde/trunk: ./ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontaine...

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java?rev=814877&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java Mon Sep 14 21:47:44 2009
@@ -0,0 +1,254 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.ivyde.eclipse.cpcontainer;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ivy.Ivy;
+import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+import org.apache.ivy.core.resolve.DownloadOptions;
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.workspaceresolver.WorkspaceResolver;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+
+/**
+ * This class is mapping the resolved artifacts between them. After a resolve process, this class
+ * will build the classpath based on the retrieved artifacts and will search for sources and
+ * javadocs and make them attached.
+ */
+public class IvyClasspathContainerMapper {
+
+    private final IProgressMonitor monitor;
+
+    private final Ivy ivy;
+
+    private final IvyClasspathContainerConfiguration conf;
+
+    public IvyClasspathContainerMapper(IProgressMonitor monitor, Ivy ivy,
+            IvyClasspathContainerConfiguration conf) {
+        this.monitor = monitor;
+        this.ivy = ivy;
+        this.conf = conf;
+    }
+
+    public IClasspathEntry[] map(Collection all, Map/*
+                                                     * <ModuleRevisionId, Artifact[]>
+                                                     */artifactsByDependency) {
+        IClasspathEntry[] classpathEntries;
+        Collection paths = new LinkedHashSet();
+
+        for (Iterator iter = all.iterator(); iter.hasNext();) {
+            ArtifactDownloadReport artifact = (ArtifactDownloadReport) iter.next();
+
+            if (artifact.getType().equals(WorkspaceResolver.ECLIPSE_PROJECT_TYPE)) {
+                // This is a java project in the workspace, add project path
+                paths.add(JavaCore.newProjectEntry(new Path(artifact.getName()), true));
+            } else if (artifact.getLocalFile() != null && accept(artifact.getArtifact())) {
+                Path classpathArtifact = new Path(artifact.getLocalFile().getAbsolutePath());
+                Path sourcesArtifact = getSourcesArtifactPath(artifact, all, artifactsByDependency);
+                Path javadocArtifact = getJavadocArtifactPath(artifact, all, artifactsByDependency);
+                paths.add(JavaCore.newLibraryEntry(classpathArtifact, getSourceAttachment(
+                    classpathArtifact, sourcesArtifact), getSourceAttachmentRoot(classpathArtifact,
+                    sourcesArtifact), null, getExtraAttribute(classpathArtifact, javadocArtifact),
+                    false));
+            }
+
+        }
+        classpathEntries = (IClasspathEntry[]) paths.toArray(new IClasspathEntry[paths.size()]);
+
+        return classpathEntries;
+    }
+
+    private Path getSourcesArtifactPath(ArtifactDownloadReport adr, Collection all,
+            Map/* <ModuleRevisionId, Artifact[]> */artifactsByDependency) {
+        Artifact artifact = adr.getArtifact();
+        monitor.subTask("searching sources for " + artifact);
+        for (Iterator iter = all.iterator(); iter.hasNext();) {
+            ArtifactDownloadReport otherAdr = (ArtifactDownloadReport) iter.next();
+            Artifact a = otherAdr.getArtifact();
+            if (otherAdr.getLocalFile() != null
+                    && isSourceArtifactName(artifact.getName(), a.getName())
+                    && a.getModuleRevisionId().equals(artifact.getModuleRevisionId())
+                    && isSources(a)) {
+                return new Path(otherAdr.getLocalFile().getAbsolutePath());
+            }
+        }
+        // we haven't found source artifact in resolved artifacts,
+        // let's look in the module declaring the artifact
+        ModuleRevisionId mrid = artifact.getId().getModuleRevisionId();
+        Artifact[] artifacts = (Artifact[]) artifactsByDependency.get(mrid);
+        if (artifacts != null) {
+            for (int i = 0; i < artifacts.length; i++) {
+                Artifact metaArtifact = artifacts[i];
+                if (isSourceArtifactName(artifact.getName(), metaArtifact.getName())
+                        && isSources(metaArtifact)) {
+                    // we've found the source artifact, let's provision it
+                    ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(metaArtifact,
+                        new DownloadOptions());
+                    if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) {
+                        return new Path(metaAdr.getLocalFile().getAbsolutePath());
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    private Path getJavadocArtifactPath(ArtifactDownloadReport adr, Collection all,
+            Map/* <ModuleRevisionId, Artifact[]> */artifactsByDependency) {
+        Artifact artifact = adr.getArtifact();
+        monitor.subTask("searching javadoc for " + artifact);
+        for (Iterator iter = all.iterator(); iter.hasNext();) {
+            ArtifactDownloadReport otherAdr = (ArtifactDownloadReport) iter.next();
+            Artifact a = otherAdr.getArtifact();
+            if (otherAdr.getLocalFile() != null
+                    && isJavadocArtifactName(artifact.getName(), a.getName())
+                    && a.getModuleRevisionId().equals(artifact.getModuleRevisionId())
+                    && isJavadoc(a)) {
+                return new Path(otherAdr.getLocalFile().getAbsolutePath());
+            }
+        }
+        // we haven't found javadoc artifact in resolved artifacts,
+        // let's look in the module declaring the artifact
+        ModuleRevisionId mrid = artifact.getId().getModuleRevisionId();
+        Artifact[] artifacts = (Artifact[]) artifactsByDependency.get(mrid);
+        if (artifacts != null) {
+            for (int i = 0; i < artifacts.length; i++) {
+                Artifact metaArtifact = artifacts[i];
+                if (isJavadocArtifactName(artifact.getName(), metaArtifact.getName())
+                        && isJavadoc(metaArtifact)) {
+                    // we've found the javadoc artifact, let's provision it
+                    ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(metaArtifact,
+                        new DownloadOptions());
+                    if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) {
+                        return new Path(metaAdr.getLocalFile().getAbsolutePath());
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    private IPath getSourceAttachment(Path classpathArtifact, Path sourcesArtifact) {
+        IPath sourceAttachment = IvyPlugin.getDefault().getPackageFragmentExtraInfo()
+                .getSourceAttachment(classpathArtifact);
+        if (sourceAttachment == null) {
+            sourceAttachment = sourcesArtifact;
+        }
+        return sourceAttachment;
+    }
+
+    private IPath getSourceAttachmentRoot(Path classpathArtifact, Path sourcesArtifact) {
+        IPath sourceAttachment = IvyPlugin.getDefault().getPackageFragmentExtraInfo()
+                .getSourceAttachmentRoot(classpathArtifact);
+        if (sourceAttachment == null && sourcesArtifact != null) {
+            sourceAttachment = sourcesArtifact;
+        }
+        return sourceAttachment;
+    }
+
+    private IClasspathAttribute[] getExtraAttribute(Path classpathArtifact, Path javadocArtifact) {
+        List result = new ArrayList();
+        URL url = IvyPlugin.getDefault().getPackageFragmentExtraInfo().getDocAttachment(
+            classpathArtifact);
+
+        if (url == null) {
+            Path path = javadocArtifact;
+            if (path != null) {
+                String u;
+                try {
+                    u = "jar:" + path.toFile().toURL().toExternalForm() + "!/";
+                    try {
+                        url = new URL(u);
+                    } catch (MalformedURLException e) {
+                        // this should not happen
+                        IvyPlugin.log(IStatus.ERROR,
+                            "The jar URL for the javadoc is not formed correctly " + u, e);
+                    }
+                } catch (MalformedURLException e) {
+                    // this should not happen
+                    IvyPlugin.log(IStatus.ERROR, "The path has not a correct URL: " + path, e);
+                }
+            }
+        }
+
+        if (url != null) {
+            result.add(JavaCore.newClasspathAttribute(
+                IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, url.toExternalForm()));
+        }
+        return (IClasspathAttribute[]) result.toArray(new IClasspathAttribute[result.size()]);
+    }
+
+    public boolean isJavadocArtifactName(String jar, String javadoc) {
+        return isArtifactName(jar, javadoc, conf.getInheritedJavadocSuffixes());
+    }
+
+    public boolean isSourceArtifactName(String jar, String source) {
+        return isArtifactName(jar, source, conf.getInheritedSourceSuffixes());
+    }
+
+    private boolean isArtifactName(String jar, String name, Collection/* <String> */suffixes) {
+        if (name.equals(jar)) {
+            return true;
+        }
+        Iterator it = suffixes.iterator();
+        while (it.hasNext()) {
+            if (name.equals(jar + it.next())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Check if the artifact is an artifact which can be added to the classpath container
+     * 
+     * @param artifact
+     *            the artifact to check
+     * @return <code>true</code> if the artifact can be added
+     */
+    public boolean accept(Artifact artifact) {
+        return conf.getInheritedAcceptedTypes().contains(artifact.getType())
+                && !conf.getInheritedSourceTypes().contains(artifact.getType())
+                && !conf.getInheritedJavadocTypes().contains(artifact.getType());
+    }
+
+    public boolean isSources(Artifact artifact) {
+        return conf.getInheritedSourceTypes().contains(artifact.getType());
+    }
+
+    public boolean isJavadoc(Artifact artifact) {
+        return conf.getInheritedJavadocTypes().contains(artifact.getType());
+    }
+
+}

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java?rev=814877&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java Mon Sep 14 21:47:44 2009
@@ -0,0 +1,418 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.ivyde.eclipse.cpcontainer;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.apache.ivy.Ivy;
+import org.apache.ivy.core.cache.DefaultRepositoryCacheManager;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
+import org.apache.ivy.util.Message;
+import org.apache.ivyde.eclipse.FakeProjectManager;
+import org.apache.ivyde.eclipse.IvyDEException;
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.workspaceresolver.WorkspaceIvySettings;
+import org.apache.ivyde.eclipse.workspaceresolver.WorkspaceResolver;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.BundleContext;
+
+/**
+ * This class is a front end to the container configuration. It computes the configuration status,
+ * build the Ivy bean on demand and can cache it.
+ */
+public class IvyClasspathContainerState {
+
+    private static final String PROJECT_SCHEME_PREFIX = "project://";
+
+    private static final int PROJECT_SCHEME_PREFIX_LENGTH = PROJECT_SCHEME_PREFIX.length();
+
+    private Ivy ivy;
+
+    private long ivySettingsLastModified = -1;
+
+    private ModuleDescriptor md;
+
+    private IvyClasspathContainerConfiguration conf;
+
+    public IvyClasspathContainerState(IvyClasspathContainerConfiguration conf) {
+        this.conf = conf;
+    }
+
+    public void setConf(IvyClasspathContainerConfiguration conf) {
+        this.conf = conf;
+        md = null;
+        ivy = null;
+        ivySettingsLastModified = -1;
+    }
+
+    public void setIvySettingsLastModified(long ivySettingsLastModified) {
+        this.ivySettingsLastModified = ivySettingsLastModified;
+    }
+
+    private void setConfStatus(IvyDEException ex) {
+        if (ex != null) {
+            setResolveStatus(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
+                    ex.getMessage(), ex.getCause()));
+        } else {
+            setResolveStatus(Status.OK_STATUS);
+        }
+    }
+
+    public void setResolveStatus(IStatus status) {
+        if (FakeProjectManager.isFake(conf.getJavaProject())) {
+            return;
+        }
+        IProject p = conf.getJavaProject().getProject();
+        try {
+            p.deleteMarkers(IvyPlugin.MARKER_ID, true, IResource.DEPTH_INFINITE);
+            if (status == Status.OK_STATUS) {
+                return;
+            }
+            IResource r = conf.getJavaProject().getProject().getFile(conf.getIvyXmlPath());
+            if (!r.exists()) {
+                r = p;
+            }
+            IMarker marker = r.createMarker(IvyPlugin.MARKER_ID);
+            marker.setAttribute(IMarker.MESSAGE, status.getMessage());
+            switch (status.getSeverity()) {
+                case IStatus.ERROR:
+                    marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+                    break;
+                case IStatus.WARNING:
+                    marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
+                    break;
+                case IStatus.INFO:
+                    marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
+                    break;
+                default:
+                    IvyPlugin.log(IStatus.WARNING, "Unsupported resolve status: "
+                            + status.getSeverity(), null);
+            }
+        } catch (CoreException e) {
+            IvyPlugin.log(e);
+        }
+    }
+
+    public Ivy getCachedIvy() throws IvyDEException {
+        if (ivy != null) {
+            return ivy;
+        }
+        return getIvy();
+    }
+
+    public Ivy getIvy() throws IvyDEException {
+        try {
+            return doGetIvy();
+        } catch (IvyDEException e) {
+            e.contextualizeMessage("Error while resolving the ivy instance for " + this.toString());
+            throw e;
+        }
+    }
+
+    private Ivy doGetIvy() throws IvyDEException {
+        String settingsPath = conf.getInheritedIvySettingsPath();
+        if (settingsPath == null || settingsPath.trim().length() == 0) {
+            // no settings specified, so take the default one
+            if (ivy == null) {
+                IvySettings ivySettings = createIvySettings();
+                try {
+                    ivySettings.loadDefault();
+                } catch (ParseException e) {
+                    IvyDEException ex = new IvyDEException(
+                            "Parsing error of the default Ivy settings",
+                            "The default Ivy settings file could not be parsed: " + e.getMessage(),
+                            e);
+                    setConfStatus(ex);
+                    throw ex;
+                } catch (IOException e) {
+                    IvyDEException ex = new IvyDEException(
+                            "Read error of the default Ivy settings",
+                            "The default Ivy settings file could not be read: " + e.getMessage(), e);
+                    setConfStatus(ex);
+                    throw ex;
+                }
+                ivy = Ivy.newInstance(ivySettings);
+            }
+            setConfStatus(null);
+            return ivy;
+        }
+
+        if (settingsPath.startsWith(PROJECT_SCHEME_PREFIX)) {
+            int pathIndex = settingsPath.indexOf("/", PROJECT_SCHEME_PREFIX_LENGTH);
+            String projectName = settingsPath.substring(PROJECT_SCHEME_PREFIX_LENGTH, pathIndex);
+            String path = settingsPath.substring(pathIndex + 1);
+            if (projectName.equals("")) {
+                if (FakeProjectManager.isFake(conf.getJavaProject())) {
+                    // this is a fake project, we are in the launch config, project:// is forbidden
+                    IvyDEException ex = new IvyDEException("Invalid Ivy settings path",
+                            "the project:/// scheme is not allowed in the launch configurations '"
+                                    + settingsPath + "'", null);
+                    setConfStatus(ex);
+                    throw ex;
+                }
+                File file = conf.getJavaProject().getProject().getFile(path).getLocation().toFile();
+                if (!file.exists()) {
+                    IvyDEException ex = new IvyDEException("Ivy settings file not found",
+                            "The Ivy settings file '" + settingsPath + "' cannot be found", null);
+                    setConfStatus(ex);
+                    throw ex;
+                }
+                return getIvy(file);
+            } else {
+                IResource p = ResourcesPlugin.getWorkspace().getRoot().findMember(projectName);
+                if (p == null) {
+                    IvyDEException ex = new IvyDEException("Project '" + projectName
+                            + "' not found", "The project name '" + projectName + "' from '"
+                            + settingsPath + "' was not found", null);
+                    setConfStatus(ex);
+                    throw ex;
+                }
+                File file = p.getProject().getFile(path).getLocation().toFile();
+                if (!file.exists()) {
+                    IvyDEException ex = new IvyDEException("Ivy settings file not found",
+                            "The Ivy settings file '" + path + "' cannot be found in project '"
+                                    + projectName + "'", null);
+                    setConfStatus(ex);
+                    throw ex;
+                }
+                return getIvy(file);
+            }
+        }
+        // before returning the found ivy, try to refresh it if the settings changed
+        URL url;
+        try {
+            url = new URL(settingsPath);
+        } catch (MalformedURLException e) {
+            IvyDEException ex = new IvyDEException("Incorrect url of the Ivy settings",
+                    "The Ivy settings url '" + settingsPath + "' is incorrect: " + e.getMessage(),
+                    e);
+            setConfStatus(ex);
+            throw ex;
+        }
+        if (url.getProtocol().startsWith("file")) {
+            File file = new File(url.getPath());
+            return getIvy(file);
+        } else {
+            // an URL but not a file
+            if (ivy == null || ivySettingsLastModified == -1) {
+                IvySettings ivySettings = createIvySettings();
+                try {
+                    ivySettings.load(url);
+                    ivySettingsLastModified = 0;
+                } catch (ParseException e) {
+                    IvyDEException ex = new IvyDEException("Parsing error of the Ivy settings",
+                            "The ivy settings file '" + settingsPath + "' could not be parsed: "
+                                    + e.getMessage(), e);
+                    setConfStatus(ex);
+                    throw ex;
+                } catch (IOException e) {
+                    IvyDEException ex = new IvyDEException("Read error of the Ivy settings",
+                            "The ivy settings file '" + settingsPath + "' could not be read: "
+                                    + e.getMessage(), e);
+                    setConfStatus(ex);
+                    throw ex;
+                }
+                ivy = Ivy.newInstance(ivySettings);
+            }
+        }
+        setConfStatus(null);
+        return ivy;
+    }
+
+    private Ivy getIvy(File file) throws IvyDEException {
+        String ivySettingsPath = conf.getIvySettingsSetup().getIvySettingsPath();
+        if (!file.exists()) {
+            IvyDEException ex = new IvyDEException("Ivy settings file not found",
+                    "The Ivy settings file '" + ivySettingsPath + "' cannot be found", null);
+            setConfStatus(ex);
+            throw ex;
+        }
+
+        if (file.lastModified() != ivySettingsLastModified
+                || !conf.getInheritedLoadSettingsOnDemandPath()) {
+            IvySettings ivySettings = createIvySettings();
+            if (ivySettingsLastModified == -1) {
+                Message.info("\n\n");
+            } else {
+                Message.info("\n\nIVYDE: ivysettings has changed, configuring ivy again\n");
+            }
+            try {
+                ivySettings.load(file);
+            } catch (ParseException e) {
+                IvyDEException ex = new IvyDEException("Parsing error of the Ivy settings",
+                        "The ivy settings file '" + ivySettingsPath + "' could not be parsed: "
+                                + e.getMessage(), e);
+                setConfStatus(ex);
+                throw ex;
+            } catch (IOException e) {
+                IvyDEException ex = new IvyDEException("Read error of the Ivy settings",
+                        "The ivy settings file '" + ivySettingsPath + "' could not be read: "
+                                + e.getMessage(), e);
+                setConfStatus(ex);
+                throw ex;
+            }
+            ivy = Ivy.newInstance(ivySettings);
+            ivySettingsLastModified = file.lastModified();
+        }
+        return ivy;
+    }
+
+    private IvySettings createIvySettings() throws IvyDEException {
+        IvySettings ivySettings;
+        if (conf.isInheritedResolveInWorkspace()) {
+            ivySettings = new WorkspaceIvySettings(conf.getJavaProject());
+            DefaultRepositoryCacheManager cacheManager = new DefaultRepositoryCacheManager();
+            BundleContext bundleContext = IvyPlugin.getDefault().getBundleContext();
+            cacheManager.setBasedir(bundleContext.getDataFile("ivyde-workspace-resolver-cache"));
+            cacheManager.setCheckmodified(true);
+            cacheManager.setUseOrigin(true);
+            cacheManager.setName(WorkspaceResolver.CACHE_NAME);
+            ivySettings.addRepositoryCacheManager(cacheManager);
+        } else {
+            ivySettings = new IvySettings();
+        }
+        IPath location = conf.getJavaProject().getProject().getLocation();
+        if (location != null) {
+            ivySettings.setBaseDir(location.toFile());
+        }
+        Collection propFiles = conf.getInheritedPropertyFiles();
+        if (propFiles != null) {
+            Iterator iter = propFiles.iterator();
+            while (iter.hasNext()) {
+                String file = (String) iter.next();
+                InputStream is;
+                Path p = new Path(file);
+                if (conf.getJavaProject() != null && !p.isAbsolute()) {
+                    try {
+                        is = new FileInputStream(conf.getJavaProject().getProject().getFile(file)
+                                .getFullPath().toFile());
+                    } catch (FileNotFoundException e) {
+                        IvyDEException ex = new IvyDEException("Property file not found",
+                                "The property file '" + file + "' could not be found", e);
+                        setConfStatus(ex);
+                        throw ex;
+                    }
+                } else {
+                    try {
+                        is = new FileInputStream(file);
+                    } catch (FileNotFoundException e) {
+                        IvyDEException ex = new IvyDEException("Property file not found",
+                                "The property file '" + file + "' was not found", e);
+                        setConfStatus(ex);
+                        throw ex;
+                    }
+                }
+                Properties props = new Properties();
+                try {
+                    props.load(is);
+                } catch (IOException e) {
+                    IvyDEException ex = new IvyDEException("Not a property file",
+                            "The property file '" + file + "' could not be loaded", e);
+                    setConfStatus(ex);
+                    throw ex;
+                }
+                try {
+                    is.close();
+                } catch (IOException e) {
+                    // don't care
+                }
+
+                Iterator keys = props.keySet().iterator();
+                while (keys.hasNext()) {
+                    String key = (String) keys.next();
+                    String value = props.getProperty(key);
+                    ivySettings.setVariable(key, value);
+                }
+            }
+        }
+        return ivySettings;
+    }
+
+    public File getIvyFile() {
+        File file = new File(conf.getIvyXmlPath());
+        if (!file.isAbsolute() && !FakeProjectManager.isFake(conf.getJavaProject())) {
+            file = conf.getJavaProject().getProject().getFile(conf.getIvyXmlPath()).getLocation()
+                    .toFile();
+        }
+        return file;
+    }
+
+    public ModuleDescriptor getCachedModuleDescriptor() throws IvyDEException {
+        if (md != null) {
+            return md;
+        }
+        return getModuleDescriptor(getCachedIvy());
+    }
+
+    public ModuleDescriptor getModuleDescriptor() throws IvyDEException {
+        return getModuleDescriptor(getIvy());
+    }
+
+    public ModuleDescriptor getModuleDescriptor(Ivy i) throws IvyDEException {
+        File file = getIvyFile();
+        if (!file.exists()) {
+            IvyDEException ex = new IvyDEException("Ivy file not found", "The ivy.xml file '"
+                    + file.getAbsolutePath() + "' was not found", null);
+            setConfStatus(ex);
+            throw ex;
+        }
+        try {
+            md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(i.getSettings(),
+                file.toURL(), false);
+            setConfStatus(null);
+            return md;
+        } catch (MalformedURLException e) {
+            IvyDEException ex = new IvyDEException("Incorrect URL of the Ivy file",
+                    "The URL to the ivy.xml file is incorrect: '" + file.getAbsolutePath() + "'", e);
+            setConfStatus(ex);
+            throw ex;
+        } catch (ParseException e) {
+            IvyDEException ex = new IvyDEException("Parsing error of the Ivy file",
+                    "The ivy file '" + file.getAbsolutePath() + "' could not be parsed: "
+                            + e.getMessage(), e);
+            setConfStatus(ex);
+            throw ex;
+        } catch (IOException e) {
+            IvyDEException ex = new IvyDEException("Read error of the Ivy file", "The ivy file '"
+                    + file.getAbsolutePath() + "' could not be read: " + e.getMessage(), e);
+            setConfStatus(ex);
+            throw ex;
+        }
+    }
+
+}

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java?rev=814877&r1=814876&r2=814877&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java Mon Sep 14 21:47:44 2009
@@ -18,23 +18,21 @@
 package org.apache.ivyde.eclipse.cpcontainer;
 
 import org.apache.ivyde.eclipse.IvyPlugin;
-import org.apache.ivyde.eclipse.cpcontainer.fragmentinfo.IPackageFragmentExtraInfo;
-import org.apache.ivyde.eclipse.ui.preferences.IvyDEPreferenceStoreHelper;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jdt.core.ClasspathContainerInitializer;
+import org.eclipse.jdt.core.IClasspathAttribute;
 import org.eclipse.jdt.core.IClasspathContainer;
 import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.swt.widgets.Display;
 
 /**
  * Initializer the ivy class path container. It will create a container from the persisted class
- * path entries, and then schedule the refresh of the container.
+ * path entries (the .classpath file), and then schedule the refresh of the container.
  */
 public class IvyClasspathInitializer extends ClasspathContainerInitializer {
 
@@ -45,7 +43,7 @@
     public static final int ON_STARTUP_RESOLVE = 2;
 
     /**
-     * Initialize the container with the "persisted" class path entries, and then schedule the
+     * Initialize the container with the "persisted" classpath entries, and then schedule the
      * refresh
      */
     public void initialize(IPath containerPath, IJavaProject project) throws CoreException {
@@ -65,31 +63,36 @@
             try {
                 IvyClasspathContainer ivycp;
 
-                if (container == null) {
-                    ivycp = new IvyClasspathContainer(project, containerPath,
-                            new IClasspathEntry[0]);
-                } else if (!(container instanceof IvyClasspathContainer)) {
-                    // this might be the persisted one : reuse the persisted entries
-                    ivycp = new IvyClasspathContainer(project, containerPath, container
-                            .getClasspathEntries());
-                } else {
+                if (container instanceof IvyClasspathContainer) {
                     ivycp = (IvyClasspathContainer) container;
+                } else {
+
+                    IClasspathEntry entry =
+                            IvyClasspathUtil.getIvyClasspathEntry(containerPath, project);
+                    IClasspathAttribute[] attributes = null;
+                    if (entry != null) {
+                        attributes = entry.getExtraAttributes();
+                    }
+
+                    if (container == null) {
+                        ivycp = new IvyClasspathContainer(project, containerPath,
+                                new IClasspathEntry[0], attributes);
+                    } else {
+                        // this might be the persisted one : reuse the persisted entries
+                        ivycp = new IvyClasspathContainer(project, containerPath, container
+                                .getClasspathEntries(), attributes);
+                    }                    
                 }
 
+                // set the container
                 JavaCore.setClasspathContainer(containerPath, new IJavaProject[] {project},
                     new IClasspathContainer[] {ivycp}, null);
 
-                IvyDEPreferenceStoreHelper prefHelper = IvyPlugin.getPreferenceStoreHelper();
-                boolean refresh = true;
-
-                // if we have a non ivy cp, it means Eclipse is starting
-                // maybe we don't want to trigger the resolve
-                if (container != null && !(container instanceof IvyClasspathContainer)) {
-                    if (prefHelper.getResolveOnStartup() == ON_STARTUP_NOTHING) {
-                        return;
-                    }
-                    refresh = prefHelper.getResolveOnStartup() == ON_STARTUP_REFRESH;
+                int startupMode = IvyPlugin.getPreferenceStoreHelper().getResolveOnStartup();
+                if (startupMode == ON_STARTUP_NOTHING) {
+                    return;
                 }
+                boolean refresh = startupMode == ON_STARTUP_REFRESH;
 
                 // now refresh the container to be synchronized with the ivy.xml
                 ivycp.launchResolve(refresh, false, null);
@@ -102,44 +105,7 @@
     }
 
     public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) {
-        return true;
-    }
-
-    public void requestClasspathContainerUpdate(final IPath containerPath,
-            final IJavaProject project, IClasspathContainer containerSuggestion)
-            throws CoreException {
-        if (IvyClasspathUtil.isIvyClasspathContainer(containerPath)) {
-            IClasspathEntry[] ice = containerSuggestion.getClasspathEntries();
-            IPackageFragmentExtraInfo ei = IvyPlugin.getDefault().getPackageFragmentExtraInfo();
-            for (int i = 0; i < ice.length; i++) {
-                IClasspathEntry entry = ice[i];
-                IPath path = entry.getSourceAttachmentPath();
-                String entryPath = entry.getPath().toPortableString();
-                ei.setSourceAttachmentPath(containerPath, entryPath, path);
-                ei.setSourceAttachmentRootPath(containerPath, entryPath, path);
-                ei.setJavaDocLocation(containerPath, entryPath, IvyClasspathUtil
-                        .getLibraryJavadocLocation(entry));
-            }
-            // force refresh of ivy classpath entry in ui thread
-            Display.getDefault().asyncExec(new Runnable() {
-                public void run() {
-                    IClasspathContainer cp;
-                    try {
-                        cp = JavaCore.getClasspathContainer(containerPath, project);
-                    } catch (JavaModelException e) {
-                        IvyPlugin.log(e);
-                        return;
-                    }
-                    if (cp instanceof IvyClasspathContainer) {
-                        ((IvyClasspathContainer) cp).launchResolve(false, true, null);
-                    }
-                }
-            });
-        }
-    }
-
-    public String getDescription(IPath containerPath, IJavaProject project) {
-        return "my description";
+        return false;
     }
 
     public Object getComparisonID(IPath containerPath, IJavaProject project) {

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java?rev=814877&r1=814876&r2=814877&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java Mon Sep 14 21:47:44 2009
@@ -24,6 +24,7 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.ivyde.eclipse.FakeProjectManager;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.IPath;
@@ -105,7 +106,10 @@
      */
     public static List/* <IvyClasspathContainer> */getIvyClasspathContainers(
             IJavaProject javaProject) {
-        List/*<IvyClasspathContainer>*/ containers = new ArrayList();
+        List/* <IvyClasspathContainer> */containers = new ArrayList();
+        if (FakeProjectManager.isFake(javaProject)) {
+            return containers;
+        }
         try {
             IClasspathEntry[] entries = javaProject.getRawClasspath();
             for (int i = 0; i < entries.length; i++) {
@@ -127,9 +131,9 @@
         return containers;
     }
 
-    public static List/*<IvyClasspathContainer>*/ getIvyFileClasspathContainers(IFile ivyfile) {
+    public static List/* <IvyClasspathContainer> */getIvyFileClasspathContainers(IFile ivyfile) {
         IJavaProject javaProject = JavaCore.create(ivyfile.getProject());
-        List/*<IvyClasspathContainer>*/ containers = new ArrayList();
+        List/* <IvyClasspathContainer> */containers = new ArrayList();
         try {
             IClasspathEntry[] entries = javaProject.getRawClasspath();
             for (int i = 0; i < entries.length; i++) {
@@ -140,7 +144,8 @@
                         IClasspathContainer cp = JavaCore.getClasspathContainer(path, javaProject);
                         if (cp instanceof IvyClasspathContainer) {
                             IvyClasspathContainer ivycp = (IvyClasspathContainer) cp;
-                            if (ivycp.getConf().getIvyXmlPath().equals(ivyfile.getProjectRelativePath().toString())) {
+                            if (ivycp.getConf().getIvyXmlPath().equals(
+                                ivyfile.getProjectRelativePath().toString())) {
                                 containers.add(ivycp);
                             }
                         }
@@ -154,9 +159,10 @@
         return containers;
     }
 
-    public static List/*<IvyClasspathContainer>*/ getIvySettingsClasspathContainers(IFile ivySettings) {
+    public static List/* <IvyClasspathContainer> */getIvySettingsClasspathContainers(
+            IFile ivySettings) {
         IJavaProject javaProject = JavaCore.create(ivySettings.getProject());
-        List/*<IvyClasspathContainer>*/ containers = new ArrayList();
+        List/* <IvyClasspathContainer> */containers = new ArrayList();
         try {
             IClasspathEntry[] entries = javaProject.getRawClasspath();
             for (int i = 0; i < entries.length; i++) {
@@ -211,7 +217,8 @@
 
     /**
      * Just a verbatim copy of the internal Eclipse function:
-     * org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations#getLibraryJavadocLocation(IClasspathEntry)
+     * org.eclipse.jdt.internal.corext.javadoc
+     * .JavaDocLocations#getLibraryJavadocLocation(IClasspathEntry)
      * 
      * @param entry
      * @return
@@ -241,4 +248,34 @@
         return null;
     }
 
+    /**
+     * Search the Ivy classpath entry within the specified Java project with the specific path
+     * 
+     * @param containerPath
+     *            the path of the container
+     * @param javaProject
+     *            the project to search into
+     * @return the Ivy classpath container if found, otherwise return <code>null</code>
+     */
+    public static IClasspathEntry getIvyClasspathEntry(IPath containerPath, IJavaProject javaProject) {
+        if (FakeProjectManager.isFake(javaProject)) {
+            return null;
+        }
+        try {
+            IClasspathEntry[] entries = javaProject.getRawClasspath();
+            for (int i = 0; i < entries.length; i++) {
+                IClasspathEntry entry = entries[i];
+                if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
+                    if (containerPath.equals(entry.getPath())) {
+                        return entry;
+                    }
+                }
+            }
+        } catch (JavaModelException e) {
+            // unless there are issues with the JDT, this should never happen
+            IvyPlugin.log(e);
+        }
+        return null;
+    }
+
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java?rev=814877&r1=814876&r2=814877&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java Mon Sep 14 21:47:44 2009
@@ -17,191 +17,60 @@
  */
 package org.apache.ivyde.eclipse.cpcontainer;
 
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.ivy.Ivy;
-import org.apache.ivy.core.event.IvyEvent;
-import org.apache.ivy.core.event.IvyListener;
-import org.apache.ivy.core.event.download.EndArtifactDownloadEvent;
-import org.apache.ivy.core.event.download.PrepareDownloadEvent;
-import org.apache.ivy.core.event.download.StartArtifactDownloadEvent;
-import org.apache.ivy.core.event.resolve.EndResolveDependencyEvent;
-import org.apache.ivy.core.event.resolve.StartResolveDependencyEvent;
-import org.apache.ivy.core.module.descriptor.Artifact;
-import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
-import org.apache.ivy.core.module.id.ModuleRevisionId;
-import org.apache.ivy.core.report.ArtifactDownloadReport;
-import org.apache.ivy.core.report.ResolveReport;
-import org.apache.ivy.core.resolve.DownloadOptions;
-import org.apache.ivy.core.resolve.IvyNode;
-import org.apache.ivy.core.resolve.ResolveData;
-import org.apache.ivy.core.resolve.ResolveOptions;
-import org.apache.ivy.core.resolve.ResolvedModuleRevision;
-import org.apache.ivy.core.retrieve.RetrieveOptions;
-import org.apache.ivy.plugins.report.XmlReportParser;
-import org.apache.ivy.plugins.repository.TransferEvent;
-import org.apache.ivy.plugins.repository.TransferListener;
-import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.util.Message;
-import org.apache.ivy.util.filter.ArtifactTypeFilter;
+import org.apache.ivyde.eclipse.FakeProjectManager;
 import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
-import org.apache.ivyde.eclipse.workspaceresolver.WorkspaceResolver;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IResource;
 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.MultiStatus;
-import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.JavaCore;
 
 /**
  * Eclipse classpath container that will contain the ivy resolved entries.
  */
-public class IvyResolveJob extends Job implements TransferListener, IvyListener {
-    private static final int DOWNLOAD_MONITOR_LENGTH = 100;
-
-    private static final int KILO_BITS_UNIT = 1024;
-
-    private static final int MONITOR_LENGTH = 1000;
+public class IvyResolveJob extends Job {
 
     private static final int WAIT_FOR_JOIN = 100;
 
-    private long expectedTotalLength = 1;
-
-    private long currentLength = 0;
-
-    private IProgressMonitor monitor;
-
-    private IProgressMonitor dlmonitor;
-
     private boolean usePreviousResolveIfExist;
 
-    private int workPerArtifact = 100;
-
     private Ivy ivy;
 
     private final IvyClasspathContainerConfiguration conf;
 
     private final IvyClasspathContainer container;
 
-    private ModuleDescriptor md;
+    private IvyClasspathContainerState state;
 
     public IvyResolveJob(IvyClasspathContainer container, boolean usePreviousResolveIfExist) {
         super("Ivy resolve job of " + container.getConf());
         this.container = container;
         this.conf = container.getConf();
+        this.state = container.getState();
         this.usePreviousResolveIfExist = usePreviousResolveIfExist;
     }
 
-    public void transferProgress(TransferEvent evt) {
-        switch (evt.getEventType()) {
-            case TransferEvent.TRANSFER_INITIATED:
-                monitor.setTaskName("downloading " + evt.getResource());
-                break;
-            case TransferEvent.TRANSFER_STARTED:
-                currentLength = 0;
-                if (evt.isTotalLengthSet()) {
-                    expectedTotalLength = evt.getTotalLength();
-                    dlmonitor
-                            .beginTask("downloading " + evt.getResource(), DOWNLOAD_MONITOR_LENGTH);
-                }
-                break;
-            case TransferEvent.TRANSFER_PROGRESS:
-                if (expectedTotalLength > 1) {
-                    currentLength += evt.getLength();
-                    int progress = (int) (currentLength * DOWNLOAD_MONITOR_LENGTH / expectedTotalLength);
-                    dlmonitor.worked(progress);
-                    monitor.subTask((currentLength / KILO_BITS_UNIT) + " / "
-                            + (expectedTotalLength / KILO_BITS_UNIT) + "kB");
-                }
-                break;
-            default:
-        }
-    }
-
-    public void progress(IvyEvent event) {
-        if (event instanceof TransferEvent) {
-            if (dlmonitor != null) {
-                transferProgress((TransferEvent) event);
-            }
-        } else if (event instanceof PrepareDownloadEvent) {
-            PrepareDownloadEvent pde = (PrepareDownloadEvent) event;
-            Artifact[] artifacts = pde.getArtifacts();
-            if (artifacts.length > 0) {
-                workPerArtifact = MONITOR_LENGTH / artifacts.length;
-            }
-        } else if (event instanceof StartArtifactDownloadEvent) {
-            StartArtifactDownloadEvent evt = (StartArtifactDownloadEvent) event;
-            monitor.setTaskName("downloading " + evt.getArtifact());
-            if (dlmonitor != null) {
-                dlmonitor.done();
-            }
-            dlmonitor = new SubProgressMonitor(monitor, workPerArtifact);
-        } else if (event instanceof EndArtifactDownloadEvent) {
-            if (dlmonitor != null) {
-                dlmonitor.done();
-            }
-            monitor.subTask(" ");
-            dlmonitor = null;
-        } else if (event instanceof StartResolveDependencyEvent) {
-            StartResolveDependencyEvent ev = (StartResolveDependencyEvent) event;
-            monitor.subTask("resolving " + ev.getDependencyDescriptor().getDependencyRevisionId());
-        } else if (event instanceof EndResolveDependencyEvent) {
-            monitor.subTask(" ");
-        }
-    }
-
-    private Map/* <ModuleRevisionId, Artifact[]> */getArtifactsByDependency(ResolveReport r) {
-        Map result = new HashMap();
-        for (Iterator it = r.getDependencies().iterator(); it.hasNext();) {
-            IvyNode node = (IvyNode) it.next();
-            if (node.getDescriptor() != null) {
-                result.put(node.getResolvedId(), node.getDescriptor().getAllArtifacts());
-            }
-        }
-        return result;
-    }
-
-    protected IStatus run(IProgressMonitor m) {
+    protected IStatus run(IProgressMonitor monitor) {
         Message.info("resolving dependencies of " + conf);
-        this.monitor = m;
-        final IStatus[] status = new IStatus[1];
-        final IClasspathEntry[][] classpathEntries = new IClasspathEntry[1][];
 
         // Ivy use the SaxParserFactory, and we want it to instanciate the xerces parser which is in
         // the dependencies of IvyDE, so accessible via the current classloader
         ClassLoader old = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(IvyResolveJob.class.getClassLoader());
+        ModuleDescriptor md;
         try {
-            this.ivy = conf.getIvy();
+            this.ivy = state.getIvy();
             // IVYDE-168 : Ivy needs the IvyContext in the threadlocal in order to found the
             // default branch
             ivy.pushContext();
-            this.md = conf.getModuleDescriptor(ivy);
+            md = state.getModuleDescriptor(ivy);
         } catch (IvyDEException e) {
             return new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR, e.getMessage(), e);
         } catch (Throwable e) {
@@ -211,149 +80,8 @@
             Thread.currentThread().setContextClassLoader(old);
         }
 
-        Thread resolver = new Thread() {
-            public void run() {
-                try {
-                    ivy.pushContext();
-                    ivy.getEventManager().addIvyListener(IvyResolveJob.this);
-
-                    monitor.beginTask("resolving dependencies", MONITOR_LENGTH);
-                    monitor.setTaskName("resolving dependencies...");
-
-                    String[] confs;
-                    Collection/* <ArtifactDownloadReport> */all;
-                    List problemMessages;
-
-                    // context Classloader hook for commonlogging used by httpclient
-                    // It will also be used by the SaxParserFactory in Ivy
-                    ClassLoader old = Thread.currentThread().getContextClassLoader();
-                    Thread.currentThread().setContextClassLoader(
-                        IvyResolveJob.class.getClassLoader());
-                    try {
-                        Map/* <ModuleRevisionId, Artifact[]> */artifactsByDependency = new HashMap();
-                        Set configurations = new HashSet();
-                        configurations.addAll(conf.getConfs());
-                        if (conf.getInheritedDoRetrieve()) {
-                            configurations.addAll(Arrays.asList(conf.getInheritedRetrieveConfs()
-                                    .split(",")));
-                        }
-
-                        if (configurations.contains("*")) {
-                            confs = md.getConfigurationsNames();
-                        } else {
-                            confs = (String[]) configurations.toArray(new String[configurations
-                                    .size()]);
-                        }
-
-                        if (usePreviousResolveIfExist) {
-                            all = new LinkedHashSet();
-
-                            problemMessages = new ArrayList();
-                            // we check if all required configurations have been
-                            // resolved
-                            for (int i = 0; i < confs.length; i++) {
-                                File report = ivy.getResolutionCacheManager()
-                                        .getConfigurationResolveReportInCache(
-                                            ResolveOptions.getDefaultResolveId(md), confs[i]);
-                                boolean resolved = false;
-                                if (report.exists()) {
-                                    // found a report, try to parse it.
-                                    try {
-                                        XmlReportParser parser = new XmlReportParser();
-                                        parser.parse(report);
-                                        all.addAll(Arrays.asList(parser.getArtifactReports()));
-                                        resolved = true;
-                                        findAllArtifactOnRefresh(parser, artifactsByDependency);
-                                    } catch (ParseException e) {
-                                        Message.info("\n\nIVYDE: Error while parsing the report "
-                                                + report
-                                                + ". Falling back by doing a resolve again.");
-                                        // it fails, so let's try resolving
-                                    }
-                                }
-                                if (!resolved) {
-                                    // no resolve previously done for at least
-                                    // one conf... we do it now
-                                    Message.info("\n\nIVYDE: previous resolve of "
-                                            + md.getModuleRevisionId().getModuleId()
-                                            + " doesn't contain enough data: resolving again\n");
-                                    ResolveOptions resolveOption = new ResolveOptions()
-                                            .setConfs(confs);
-                                    resolveOption.setValidate(ivy.getSettings().doValidate());
-                                    ResolveReport r = ivy.resolve(md, resolveOption);
-                                    all.addAll(Arrays.asList(r.getArtifactsReports(null, false)));
-                                    confs = r.getConfigurations();
-                                    artifactsByDependency.putAll(getArtifactsByDependency(r));
-                                    problemMessages.addAll(r.getAllProblemMessages());
-                                    maybeRetrieve(md);
-
-                                    break;
-                                }
-                            }
-                        } else {
-                            Message.info("\n\nIVYDE: calling resolve on " + conf.ivyXmlPath + "\n");
-                            ResolveOptions resolveOption = new ResolveOptions().setConfs(confs);
-                            resolveOption.setValidate(ivy.getSettings().doValidate());
-                            ResolveReport report = ivy.resolve(md, resolveOption);
-                            problemMessages = report.getAllProblemMessages();
-                            all = new LinkedHashSet(Arrays.asList(report.getArtifactsReports(null,
-                                false)));
-                            confs = report.getConfigurations();
-
-                            artifactsByDependency.putAll(getArtifactsByDependency(report));
-
-                            if (monitor.isCanceled()) {
-                                status[0] = Status.CANCEL_STATUS;
-                                return;
-                            }
-
-                            maybeRetrieve(md);
-                        }
-
-                        warnIfDuplicates(all);
-
-                        classpathEntries[0] = artifacts2ClasspathEntries(all, artifactsByDependency);
-                    } catch (ParseException e) {
-                        String errorMsg = "Error while parsing the ivy file " + conf.ivyXmlPath
-                                + "\n" + e.getMessage();
-                        Message.error(errorMsg);
-                        status[0] = new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
-                                errorMsg, e);
-                        return;
-                    } catch (Exception e) {
-                        String errorMsg = "Error while resolving dependencies for "
-                                + conf.ivyXmlPath + "\n" + e.getMessage();
-                        Message.error(errorMsg);
-                        status[0] = new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
-                                errorMsg, e);
-                        return;
-                    } finally {
-                        Thread.currentThread().setContextClassLoader(old);
-                        monitor.done();
-                        ivy.getEventManager().removeIvyListener(IvyResolveJob.this);
-                    }
-
-                    if (!problemMessages.isEmpty()) {
-                        MultiStatus multiStatus = new MultiStatus(
-                                IvyPlugin.ID,
-                                IStatus.ERROR,
-                                "Impossible to resolve dependencies of " + md.getModuleRevisionId(),
-                                null);
-                        for (Iterator iter = problemMessages.iterator(); iter.hasNext();) {
-                            multiStatus.add(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
-                                    (String) iter.next(), null));
-                        }
-                        status[0] = multiStatus;
-                        return;
-                    }
-
-                    status[0] = Status.OK_STATUS;
-                } catch (Throwable e) {
-                    status[0] = new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
-                            "The resolve job of " + conf + " has unexpectedly stopped", e);
-                }
-            }
-        };
+        IvyResolveJobThread resolver = new IvyResolveJobThread(conf, ivy, md,
+                usePreviousResolveIfExist, monitor);
 
         try {
             resolver.start();
@@ -364,337 +92,57 @@
                     ivy.interrupt(resolver);
                     return Status.CANCEL_STATUS;
                 }
-                synchronized (status) { // ensure proper sharing of done var
-                    if (status[0] != null || !resolver.isAlive()) {
-                        break;
-                    }
+                if (resolver.getStatus() != null || !resolver.isAlive()) {
+                    break;
                 }
                 if (monitor.isCanceled()) {
                     ivy.interrupt(resolver);
                     return Status.CANCEL_STATUS;
                 }
             }
-            if (status[0] == Status.OK_STATUS) {
-                container.updateClasspathEntries(classpathEntries[0]);
+            if (resolver.getStatus() == Status.OK_STATUS) {
+                container.updateClasspathEntries(resolver.getClasspathEntries());
             }
-            setResolveStatus(status[0]);
-            return status[0];
+            setResolveStatus(resolver.getStatus());
+            return resolver.getStatus();
         } finally {
             container.resetJob();
             IvyPlugin.log(IStatus.INFO, "resolved dependencies of " + conf, null);
         }
     }
 
-    /**
-     * Populate the map of artifact. The map should be populated by metadata in cache as this is
-     * called in the refresh process.
-     * 
-     * @param parser
-     * @param artifactsByDependency
-     * @throws ParseException
-     */
-    private void findAllArtifactOnRefresh(XmlReportParser parser, Map/*
-                                                                      * <ModuleRevisionId,
-                                                                      * Artifact[]>
-                                                                      */artifactsByDependency)
-            throws ParseException {
-        ModuleRevisionId[] dependencyMrdis = parser.getDependencyRevisionIds();
-        for (int iDep = 0; iDep < dependencyMrdis.length; iDep++) {
-            DependencyResolver depResolver = ivy.getSettings().getResolver(dependencyMrdis[iDep]);
-            DefaultDependencyDescriptor depDescriptor = new DefaultDependencyDescriptor(
-                    dependencyMrdis[iDep], false);
-            ResolveOptions options = new ResolveOptions();
-            options.setRefresh(true);
-            options.setUseCacheOnly(true);
-            ResolvedModuleRevision dependency = depResolver.getDependency(depDescriptor,
-                new ResolveData(ivy.getResolveEngine(), options));
-            if (dependency != null) {
-                artifactsByDependency.put(dependencyMrdis[iDep], dependency.getDescriptor()
-                        .getAllArtifacts());
-            }
-        }
-    }
-
     private void setResolveStatus(IStatus status) {
-        if (conf.javaProject != null) {
-            IFile ivyFile = conf.javaProject.getProject().getFile(conf.ivyXmlPath);
-            if (!ivyFile.exists()) {
-                return;
-            }
-            try {
-                ivyFile.deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
-                if (status == Status.OK_STATUS) {
-                    return;
-                }
-                IMarker marker = ivyFile.createMarker(IMarker.PROBLEM);
-                marker.setAttribute(IMarker.MESSAGE, status.getMessage());
-                switch (status.getSeverity()) {
-                    case IStatus.ERROR:
-                        marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
-                        break;
-                    case IStatus.WARNING:
-                        marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
-                        break;
-                    case IStatus.INFO:
-                        marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
-                        break;
-                    default:
-                        IvyPlugin.log(IStatus.WARNING, "Unsupported resolve status: "
-                                + status.getSeverity(), null);
-                }
-            } catch (CoreException e) {
-                IvyPlugin.log(e);
-            }
-        }
-    }
-
-    /**
-     * Trigger a warn if there are duplicates entries due to configuration conflict.
-     * <p>
-     * TODO: the algorithm can be more clever and find which configuration are conflicting.
-     * 
-     * @param all
-     *            the resolved artifacts
-     */
-    private void warnIfDuplicates(Collection/* <ArtifactDownloadReport> */all) {
-        ArtifactDownloadReport[] reports = (ArtifactDownloadReport[]) all
-                .toArray(new ArtifactDownloadReport[all.size()]);
-        Set duplicates = new HashSet();
-        for (int i = 0; i < reports.length - 1; i++) {
-            if (accept(reports[i].getArtifact())) {
-                ModuleRevisionId mrid1 = reports[i].getArtifact().getModuleRevisionId();
-                for (int j = i + 1; j < reports.length; j++) {
-                    if (accept(reports[j].getArtifact())) {
-                        ModuleRevisionId mrid2 = reports[j].getArtifact().getModuleRevisionId();
-                        if (mrid1.getModuleId().equals(mrid2.getModuleId())
-                                && !mrid1.getRevision().equals(mrid2.getRevision())) {
-                            duplicates.add(mrid1.getModuleId());
-                            break;
-                        }
-                    }
-                }
-            }
+        if (FakeProjectManager.isFake(conf.getJavaProject())) {
+            return;
         }
-        if (!duplicates.isEmpty()) {
-            StringBuffer buffer = new StringBuffer(
-                    "There are some duplicates entries due to conflicts"
-                            + " between the resolved configurations " + conf.confs);
-            buffer.append(":\n  - ");
-            Iterator it = duplicates.iterator();
-            while (it.hasNext()) {
-                buffer.append(it.next());
-                if (it.hasNext()) {
-                    buffer.append("\n  - ");
-                }
-            }
-            ivy.getLoggerEngine().log(buffer.toString(), Message.MSG_WARN);
-        }
-    }
-
-    private void maybeRetrieve(ModuleDescriptor md) throws IOException {
-        if (conf.getInheritedDoRetrieve()) {
-            String pattern = conf.javaProject.getProject().getLocation().toPortableString() + "/"
-                    + conf.getInheritedRetrievePattern();
-            monitor.setTaskName("retrieving dependencies in " + pattern);
-            RetrieveOptions c = new RetrieveOptions();
-            c.setSync(conf.getInheritedRetrieveSync());
-            c.setConfs(conf.getInheritedRetrieveConfs().split(","));
-            String inheritedRetrieveTypes = conf.getInheritedRetrieveTypes();
-            if (inheritedRetrieveTypes != null && !inheritedRetrieveTypes.equals("*")) {
-                c.setArtifactFilter(new ArtifactTypeFilter(IvyClasspathUtil
-                        .split(inheritedRetrieveTypes)));
-            }
-            ivy.retrieve(md.getModuleRevisionId(), pattern, c);
+        IFile ivyFile = conf.getJavaProject().getProject().getFile(conf.getIvyXmlPath());
+        if (!ivyFile.exists()) {
+            return;
         }
-    }
-
-    private IClasspathEntry[] artifacts2ClasspathEntries(Collection all,
-            Map/* <ModuleRevisionId, Artifact[]> */artifactsByDependency) {
-        IClasspathEntry[] classpathEntries;
-        Collection paths = new LinkedHashSet();
-
-        for (Iterator iter = all.iterator(); iter.hasNext();) {
-            ArtifactDownloadReport artifact = (ArtifactDownloadReport) iter.next();
-
-            if (artifact.getType().equals(WorkspaceResolver.ECLIPSE_PROJECT_TYPE)) {
-                // This is a java project in the workspace, add project path
-                paths.add(JavaCore.newProjectEntry(new Path(artifact.getName()), true));
-            } else if (artifact.getLocalFile() != null && accept(artifact.getArtifact())) {
-                Path classpathArtifact = new Path(artifact.getLocalFile().getAbsolutePath());
-                Path sourcesArtifact = getSourcesArtifactPath(artifact, all, artifactsByDependency);
-                Path javadocArtifact = getJavadocArtifactPath(artifact, all, artifactsByDependency);
-                paths.add(JavaCore.newLibraryEntry(classpathArtifact, getSourceAttachment(
-                    classpathArtifact, sourcesArtifact), getSourceAttachmentRoot(classpathArtifact,
-                    sourcesArtifact), null, getExtraAttribute(classpathArtifact, javadocArtifact),
-                    false));
-            }
-
-        }
-        classpathEntries = (IClasspathEntry[]) paths.toArray(new IClasspathEntry[paths.size()]);
-
-        return classpathEntries;
-    }
-
-    private Path getSourcesArtifactPath(ArtifactDownloadReport adr, Collection all,
-            Map/* <ModuleRevisionId, Artifact[]> */artifactsByDependency) {
-        Artifact artifact = adr.getArtifact();
-        monitor.subTask("searching sources for " + artifact);
-        for (Iterator iter = all.iterator(); iter.hasNext();) {
-            ArtifactDownloadReport otherAdr = (ArtifactDownloadReport) iter.next();
-            Artifact a = otherAdr.getArtifact();
-            if (otherAdr.getLocalFile() != null
-                    && isSourceArtifactName(artifact.getName(), a.getName())
-                    && a.getModuleRevisionId().equals(artifact.getModuleRevisionId())
-                    && isSources(a)) {
-                return new Path(otherAdr.getLocalFile().getAbsolutePath());
-            }
-        }
-        // we haven't found source artifact in resolved artifacts,
-        // let's look in the module declaring the artifact
-        ModuleRevisionId mrid = artifact.getId().getModuleRevisionId();
-        Artifact[] artifacts = (Artifact[]) artifactsByDependency.get(mrid);
-        if (artifacts != null) {
-            for (int i = 0; i < artifacts.length; i++) {
-                Artifact metaArtifact = artifacts[i];
-                if (isSourceArtifactName(artifact.getName(), metaArtifact.getName())
-                        && isSources(metaArtifact)) {
-                    // we've found the source artifact, let's provision it
-                    ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(metaArtifact,
-                        new DownloadOptions());
-                    if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) {
-                        return new Path(metaAdr.getLocalFile().getAbsolutePath());
-                    }
-                }
-            }
-        }
-        return null;
-    }
-
-    private Path getJavadocArtifactPath(ArtifactDownloadReport adr, Collection all,
-            Map/* <ModuleRevisionId, Artifact[]> */artifactsByDependency) {
-        Artifact artifact = adr.getArtifact();
-        monitor.subTask("searching javadoc for " + artifact);
-        for (Iterator iter = all.iterator(); iter.hasNext();) {
-            ArtifactDownloadReport otherAdr = (ArtifactDownloadReport) iter.next();
-            Artifact a = otherAdr.getArtifact();
-            if (otherAdr.getLocalFile() != null
-                    && isJavadocArtifactName(artifact.getName(), a.getName())
-                    && a.getModuleRevisionId().equals(artifact.getModuleRevisionId())
-                    && isJavadoc(a)) {
-                return new Path(otherAdr.getLocalFile().getAbsolutePath());
-            }
-        }
-        // we haven't found javadoc artifact in resolved artifacts,
-        // let's look in the module declaring the artifact
-        ModuleRevisionId mrid = artifact.getId().getModuleRevisionId();
-        Artifact[] artifacts = (Artifact[]) artifactsByDependency.get(mrid);
-        if (artifacts != null) {
-            for (int i = 0; i < artifacts.length; i++) {
-                Artifact metaArtifact = artifacts[i];
-                if (isJavadocArtifactName(artifact.getName(), metaArtifact.getName())
-                        && isJavadoc(metaArtifact)) {
-                    // we've found the javadoc artifact, let's provision it
-                    ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(metaArtifact,
-                        new DownloadOptions());
-                    if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) {
-                        return new Path(metaAdr.getLocalFile().getAbsolutePath());
-                    }
-                }
-            }
-        }
-        return null;
-    }
-
-    private IPath getSourceAttachment(Path classpathArtifact, Path sourcesArtifact) {
-        IPath sourceAttachment = IvyPlugin.getDefault().getPackageFragmentExtraInfo()
-                .getSourceAttachment(classpathArtifact);
-        if (sourceAttachment == null) {
-            sourceAttachment = sourcesArtifact;
-        }
-        return sourceAttachment;
-    }
-
-    private IPath getSourceAttachmentRoot(Path classpathArtifact, Path sourcesArtifact) {
-        IPath sourceAttachment = IvyPlugin.getDefault().getPackageFragmentExtraInfo()
-                .getSourceAttachmentRoot(classpathArtifact);
-        if (sourceAttachment == null && sourcesArtifact != null) {
-            sourceAttachment = sourcesArtifact;
-        }
-        return sourceAttachment;
-    }
-
-    private IClasspathAttribute[] getExtraAttribute(Path classpathArtifact, Path javadocArtifact) {
-        List result = new ArrayList();
-        URL url = IvyPlugin.getDefault().getPackageFragmentExtraInfo().getDocAttachment(
-            classpathArtifact);
-
-        if (url == null) {
-            Path path = javadocArtifact;
-            if (path != null) {
-                String u;
-                try {
-                    u = "jar:" + path.toFile().toURL().toExternalForm() + "!/";
-                    try {
-                        url = new URL(u);
-                    } catch (MalformedURLException e) {
-                        // this should not happen
-                        IvyPlugin.log(IStatus.ERROR,
-                            "The jar URL for the javadoc is not formed correctly " + u, e);
-                    }
-                } catch (MalformedURLException e) {
-                    // this should not happen
-                    IvyPlugin.log(IStatus.ERROR, "The path has not a correct URL: " + path, e);
-                }
+        try {
+            ivyFile.deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
+            if (status == Status.OK_STATUS) {
+                return;
             }
-        }
-
-        if (url != null) {
-            result.add(JavaCore.newClasspathAttribute(
-                IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, url.toExternalForm()));
-        }
-        return (IClasspathAttribute[]) result.toArray(new IClasspathAttribute[result.size()]);
-    }
-
-    public boolean isJavadocArtifactName(String jar, String javadoc) {
-        return isArtifactName(jar, javadoc, conf.getInheritedJavadocSuffixes());
-    }
-
-    public boolean isSourceArtifactName(String jar, String source) {
-        return isArtifactName(jar, source, conf.getInheritedSourceSuffixes());
-    }
-
-    private boolean isArtifactName(String jar, String name, Collection/* <String> */suffixes) {
-        if (name.equals(jar)) {
-            return true;
-        }
-        Iterator it = suffixes.iterator();
-        while (it.hasNext()) {
-            if (name.equals(jar + it.next())) {
-                return true;
+            IMarker marker = ivyFile.createMarker(IMarker.PROBLEM);
+            marker.setAttribute(IMarker.MESSAGE, status.getMessage());
+            switch (status.getSeverity()) {
+                case IStatus.ERROR:
+                    marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+                    break;
+                case IStatus.WARNING:
+                    marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
+                    break;
+                case IStatus.INFO:
+                    marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
+                    break;
+                default:
+                    IvyPlugin.log(IStatus.WARNING, "Unsupported resolve status: "
+                            + status.getSeverity(), null);
             }
+        } catch (CoreException e) {
+            IvyPlugin.log(e);
         }
-        return false;
-    }
-
-    /**
-     * Check if the artifact is an artifact which can be added to the classpath container
-     * 
-     * @param artifact
-     *            the artifact to check
-     * @return <code>true</code> if the artifact can be added
-     */
-    public boolean accept(Artifact artifact) {
-        return conf.getInheritedAcceptedTypes().contains(artifact.getType())
-                && !conf.getInheritedSourceTypes().contains(artifact.getType())
-                && !conf.getInheritedJavadocTypes().contains(artifact.getType());
-    }
-
-    public boolean isSources(Artifact artifact) {
-        return conf.getInheritedSourceTypes().contains(artifact.getType());
-    }
-
-    public boolean isJavadoc(Artifact artifact) {
-        return conf.getInheritedJavadocTypes().contains(artifact.getType());
     }
 
 }

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJobListener.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJobListener.java?rev=814877&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJobListener.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJobListener.java Mon Sep 14 21:47:44 2009
@@ -0,0 +1,116 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.ivyde.eclipse.cpcontainer;
+
+import org.apache.ivy.core.event.IvyEvent;
+import org.apache.ivy.core.event.IvyListener;
+import org.apache.ivy.core.event.download.EndArtifactDownloadEvent;
+import org.apache.ivy.core.event.download.PrepareDownloadEvent;
+import org.apache.ivy.core.event.download.StartArtifactDownloadEvent;
+import org.apache.ivy.core.event.resolve.EndResolveDependencyEvent;
+import org.apache.ivy.core.event.resolve.StartResolveDependencyEvent;
+import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.plugins.repository.TransferEvent;
+import org.apache.ivy.plugins.repository.TransferListener;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+public class IvyResolveJobListener implements TransferListener, IvyListener {
+
+    private static final int DOWNLOAD_MONITOR_LENGTH = 100;
+
+    private static final int KILO_BITS_UNIT = 1024;
+
+    private static final int MONITOR_LENGTH = 1000;
+
+    private static final int WORK_PER_ARTIFACT = 100;
+
+    private long expectedTotalLength = 1;
+
+    private int workPerArtifact = WORK_PER_ARTIFACT;
+
+    private long currentLength = 0;
+
+    private final IProgressMonitor monitor;
+
+    private IProgressMonitor dlmonitor;
+
+    public IvyResolveJobListener(IProgressMonitor monitor) {
+        this.monitor = monitor;
+    }
+
+    public void transferProgress(TransferEvent evt) {
+        switch (evt.getEventType()) {
+            case TransferEvent.TRANSFER_INITIATED:
+                monitor.setTaskName("downloading " + evt.getResource());
+                break;
+            case TransferEvent.TRANSFER_STARTED:
+                currentLength = 0;
+                if (evt.isTotalLengthSet()) {
+                    expectedTotalLength = evt.getTotalLength();
+                    dlmonitor
+                            .beginTask("downloading " + evt.getResource(), DOWNLOAD_MONITOR_LENGTH);
+                }
+                break;
+            case TransferEvent.TRANSFER_PROGRESS:
+                if (expectedTotalLength > 1) {
+                    currentLength += evt.getLength();
+                    int progress = (int) (currentLength * DOWNLOAD_MONITOR_LENGTH
+                            / expectedTotalLength);
+                    dlmonitor.worked(progress);
+                    monitor.subTask((currentLength / KILO_BITS_UNIT) + " / "
+                            + (expectedTotalLength / KILO_BITS_UNIT) + "kB");
+                }
+                break;
+            default:
+        }
+    }
+
+    public void progress(IvyEvent event) {
+        if (event instanceof TransferEvent) {
+            if (dlmonitor != null) {
+                transferProgress((TransferEvent) event);
+            }
+        } else if (event instanceof PrepareDownloadEvent) {
+            PrepareDownloadEvent pde = (PrepareDownloadEvent) event;
+            Artifact[] artifacts = pde.getArtifacts();
+            if (artifacts.length > 0) {
+                workPerArtifact = MONITOR_LENGTH / artifacts.length;
+            }
+        } else if (event instanceof StartArtifactDownloadEvent) {
+            StartArtifactDownloadEvent evt = (StartArtifactDownloadEvent) event;
+            monitor.setTaskName("downloading " + evt.getArtifact());
+            if (dlmonitor != null) {
+                dlmonitor.done();
+            }
+            dlmonitor = new SubProgressMonitor(monitor, workPerArtifact);
+        } else if (event instanceof EndArtifactDownloadEvent) {
+            if (dlmonitor != null) {
+                dlmonitor.done();
+            }
+            monitor.subTask(" ");
+            dlmonitor = null;
+        } else if (event instanceof StartResolveDependencyEvent) {
+            StartResolveDependencyEvent ev = (StartResolveDependencyEvent) event;
+            monitor.subTask("resolving " + ev.getDependencyDescriptor().getDependencyRevisionId());
+        } else if (event instanceof EndResolveDependencyEvent) {
+            monitor.subTask(" ");
+        }
+    }
+
+}

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJobListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJobListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJobListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain