ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r987724 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse: ./ cpcontainer/ ui/actions/ workspaceresolver/
Date Sat, 21 Aug 2010 11:01:40 GMT
Author: hibou
Date: Sat Aug 21 11:01:40 2010
New Revision: 987724

URL: http://svn.apache.org/viewvc?rev=987724&view=rev
Log:
IVYDE-177: add a resolve queue
 * so the workspace build should only happen at the end of the batch resolves
 * the queue should be smart enough to properly order the resolves regarding the project inter
dependencies
... to be heavy tested

Added:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ResolveRequest.java
  (with props)
Removed:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyMultiResolveJob.java
Modified:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAllAction.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java?rev=987724&r1=987723&r2=987724&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java
Sat Aug 21 11:01:40 2010
@@ -19,6 +19,7 @@ package org.apache.ivyde.eclipse;
 
 import org.apache.ivy.util.Message;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.dialogs.MessageDialog;
 
 /**
@@ -109,6 +110,20 @@ public class IvyDEException extends Exce
     }
 
     /**
+     * Convert the exception into an Eclipse status
+     * 
+     * @param status
+     *            the status of the exception (error, waring or info)
+     * @param preMsg
+     *            the message to display before the actual error message
+     * @return the eclipse status, never <code>null</code>
+     */
+    public IStatus asStatus(int status, String preMsg) {
+        String msg = (preMsg == null ? "" : preMsg) + getMessage();
+        return new Status(status, IvyPlugin.ID, 0, msg, this);
+    }
+
+    /**
      * Show the exception in the Ivy console
      * 
      * @param status

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java?rev=987724&r1=987723&r2=987724&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
Sat Aug 21 11:01:40 2010
@@ -27,6 +27,7 @@ import java.util.ResourceBundle;
 import org.apache.ivyde.common.ivyfile.IvyFileResourceListener;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
 import org.apache.ivyde.eclipse.cpcontainer.fragmentinfo.IPackageFragmentExtraInfo;
 import org.apache.ivyde.eclipse.cpcontainer.fragmentinfo.PreferenceStoreInfo;
 import org.apache.ivyde.eclipse.ui.console.IvyConsole;
@@ -84,6 +85,8 @@ public class IvyPlugin extends AbstractU
 
     private ColorManager colorManager;
 
+    private IvyResolveJob ivyResolveJob;
+
     /**
      * The constructor.
      */
@@ -99,6 +102,7 @@ public class IvyPlugin extends AbstractU
         super.start(context);
         this.bundleContext = context;
         log(IStatus.INFO, "starting IvyDE plugin", null);
+        ivyResolveJob = new IvyResolveJob();
         javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
         colorManager = new ColorManager();
         colorManager.refreshFromStore(getPreferenceStore());
@@ -155,6 +159,7 @@ public class IvyPlugin extends AbstractU
         plugin = null;
         resourceBundle = null;
         colorManager = null;
+        ivyResolveJob = null;
         // if (console != null)
         // console.shutdown();
     }
@@ -339,4 +344,8 @@ public class IvyPlugin extends AbstractU
     public ColorManager getColorManager() {
         return colorManager;
     }
+
+    public IvyResolveJob getIvyResolveJob() {
+        return ivyResolveJob;
+    }
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java?rev=987724&r1=987723&r2=987724&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
Sat Aug 21 11:01:40 2010
@@ -31,7 +31,6 @@ import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
 import org.eclipse.jdt.core.ElementChangedEvent;
 import org.eclipse.jdt.core.IClasspathAttribute;
 import org.eclipse.jdt.core.IClasspathContainer;
@@ -61,8 +60,6 @@ public class IvyClasspathContainer imple
 
     private IPath path;
 
-    private IvyResolveJob job;
-
     private IvyClasspathContainerConfiguration conf;
 
     private final IvyClasspathContainerState state;
@@ -130,37 +127,15 @@ public class IvyClasspathContainer imple
         return classpathEntries;
     }
 
-    private static final ISchedulingRule RESOLVE_EVENT_RULE = new ISchedulingRule() {
-        public boolean contains(ISchedulingRule rule) {
-            return rule == this;
-        }
-
-        public boolean isConflicting(ISchedulingRule rule) {
-            return rule == this;
-        }
-    };
-
-    private IvyResolveJob createResolveJob(final boolean usePreviousResolveIfExist,
-            boolean isUser) {
-        synchronized (this) {
-            if (job != null) {
-                // resolve job already running
-                return job;
-            }
-            job = new IvyResolveJob(this, usePreviousResolveIfExist);
-            job.setUser(isUser);
-            job.setRule(RESOLVE_EVENT_RULE);
-            return job;
-        }
-    }
-
     public IStatus launchResolve(boolean usePreviousResolveIfExist, boolean isUser,
             IProgressMonitor monitor) {
-        IvyResolveJob j = createResolveJob(usePreviousResolveIfExist, isUser);
+        ResolveRequest request = new ResolveRequest(this, usePreviousResolveIfExist);
+        IvyResolveJob resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
+        resolveJob.setUser(isUser);
         if (monitor != null) {
-            return j.run(monitor);
+            return resolveJob.launchRequest(request, monitor);
         }
-        j.schedule();
+        resolveJob.addRequest(request);
         return Status.OK_STATUS;
     }
 
@@ -257,10 +232,6 @@ public class IvyClasspathContainer imple
         }
     }
 
-    public void resetJob() {
-        job = null;
-    }
-
     public void reloadSettings() {
         state.setIvySettingsLastModified(-1);
         launchResolve(false, true, 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=987724&r1=987723&r2=987724&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
Sat Aug 21 11:01:40 2010
@@ -17,18 +17,31 @@
  */
 package org.apache.ivyde.eclipse.cpcontainer;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.ivy.Ivy;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
-import org.apache.ivy.util.Message;
+import org.apache.ivy.core.sort.ModuleDescriptorSorter;
+import org.apache.ivy.core.sort.WarningNonMatchingVersionReporter;
+import org.apache.ivy.plugins.circular.CircularDependencyStrategy;
+import org.apache.ivy.plugins.circular.WarnCircularDependencyStrategy;
+import org.apache.ivy.plugins.version.LatestVersionMatcher;
+import org.apache.ivy.plugins.version.VersionMatcher;
 import org.apache.ivyde.eclipse.FakeProjectManager;
 import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IResource;
+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.MultiStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 
@@ -39,38 +52,63 @@ public class IvyResolveJob extends Job {
 
     private static final int WAIT_FOR_JOIN = 100;
 
-    private boolean usePreviousResolveIfExist;
-
-    private Ivy ivy;
-
-    private final IvyClasspathContainerConfiguration conf;
+    private final List resolveQueue = new ArrayList();
 
-    private final IvyClasspathContainer container;
+    public IvyResolveJob() {
+        super("Ivy resolve job");
+        // computing the classpath is somehow building
+        setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
+    }
 
-    private IvyClasspathContainerState state;
+    public IStatus launchRequest(ResolveRequest request, IProgressMonitor monitor) {
+        synchronized (resolveQueue) {
+            resolveQueue.add(request);
+        }
+        return run(monitor);
+    }
 
-    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 addRequest(ResolveRequest request) {
+        synchronized (resolveQueue) {
+            resolveQueue.add(request);
+        }
+        schedule(1000);
     }
 
     protected IStatus run(IProgressMonitor monitor) {
-        Message.info("resolving dependencies of " + conf);
+        List toResolve;
+        synchronized (resolveQueue) {
+            toResolve = new ArrayList(resolveQueue);
+            resolveQueue.clear();
+        }
+
+        Map/* <ModuleDescriptor, ResolveRequest> */inworkspaceModules = new LinkedHashMap();
+        List/* <ResolveRequest> */otherModules = new ArrayList();
 
         // 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 = state.getIvy();
-            // IVYDE-168 : Ivy needs the IvyContext in the threadlocal in order to found
the
-            // default branch
-            ivy.pushContext();
-            md = state.getModuleDescriptor(ivy);
+            Iterator itRequests = toResolve.iterator();
+            while (itRequests.hasNext()) {
+                ResolveRequest request = (ResolveRequest) itRequests.next();
+                IvyClasspathContainerState state = request.getContainer().getState();
+                Ivy ivy = state.getIvy();
+                // IVYDE-168 : Ivy needs the IvyContext in the threadlocal in order to found
the
+                // default branch
+                ivy.pushContext();
+                ModuleDescriptor md;
+                try {
+                    md = state.getModuleDescriptor(ivy);
+                } finally {
+                    ivy.popContext();
+                }
+                if (request.getContainer().getConf().isInheritedResolveInWorkspace()) {
+                    inworkspaceModules.put(md, request);
+                } else {
+                    otherModules.add(request);
+                }
+            }
         } catch (IvyDEException e) {
             return new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR, e.getMessage(),
e);
         } catch (Throwable e) {
@@ -80,38 +118,111 @@ public class IvyResolveJob extends Job {
             Thread.currentThread().setContextClassLoader(old);
         }
 
-        IvyResolveJobThread resolver = new IvyResolveJobThread(conf, ivy, md,
-                usePreviousResolveIfExist, monitor);
+        MultiStatus errorsStatus = new MultiStatus(IvyPlugin.ID, IStatus.ERROR,
+                "Some projects fail to be resolved", null);
 
-        try {
-            resolver.start();
-            while (true) {
-                try {
-                    resolver.join(WAIT_FOR_JOIN);
-                } catch (InterruptedException e) {
-                    ivy.interrupt(resolver);
+        if (!inworkspaceModules.isEmpty()) {
+            // for the modules which are using the workspace resolver, make sure
+            // we resolve them in the correct order
+            // TODO which version matcher we should actually used here ?
+            VersionMatcher versionMatcher = new LatestVersionMatcher();
+            WarningNonMatchingVersionReporter nonMatchingVersionReporter = new WarningNonMatchingVersionReporter();
+            CircularDependencyStrategy circularDependencyStrategy = WarnCircularDependencyStrategy
+                    .getInstance();
+            ModuleDescriptorSorter sorter = new ModuleDescriptorSorter(inworkspaceModules.values(),
+                    versionMatcher, nonMatchingVersionReporter, circularDependencyStrategy);
+            List sortedModuleDescriptors = sorter.sortModuleDescriptors();
+
+            Iterator it = sortedModuleDescriptors.iterator();
+            while (it.hasNext()) {
+                ResolveRequest request = (ResolveRequest) inworkspaceModules.get(it.next());
+                boolean canceled = launchResolveThread(request, monitor, errorsStatus);
+                if (canceled) {
                     return Status.CANCEL_STATUS;
                 }
-                if (resolver.getStatus() != null || !resolver.isAlive()) {
-                    break;
-                }
-                if (monitor.isCanceled()) {
-                    ivy.interrupt(resolver);
+            }
+        }
+
+        if (!otherModules.isEmpty()) {
+            Iterator it = otherModules.iterator();
+            while (it.hasNext()) {
+                ResolveRequest request = (ResolveRequest) it.next();
+                boolean canceled = launchResolveThread(request, monitor, errorsStatus);
+                if (canceled) {
                     return Status.CANCEL_STATUS;
                 }
             }
-            if (resolver.getStatus() == Status.OK_STATUS) {
-                container.updateClasspathEntries(resolver.getClasspathEntries());
+        }
+
+        if (errorsStatus.getChildren().length != 0) {
+            return errorsStatus;
+        }
+
+        return Status.OK_STATUS;
+    }
+
+    private boolean launchResolveThread(ResolveRequest request, IProgressMonitor monitor,
+            MultiStatus errorsStatus) {
+        IStatus jobStatus = launchResolveThread(request, monitor);
+        switch (jobStatus.getCode()) {
+            case IStatus.CANCEL:
+                return true;
+            case IStatus.OK:
+            case IStatus.INFO:
+                break;
+            case IStatus.ERROR:
+                errorsStatus.add(jobStatus);
+                break;
+            default:
+                IvyPlugin.log(IStatus.WARNING, "Unknown IStatus: " + jobStatus.getCode(),
null);
+        }
+        return false;
+    }
+
+    private IStatus launchResolveThread(ResolveRequest request, IProgressMonitor monitor)
{
+        if (monitor.isCanceled()) {
+            return Status.CANCEL_STATUS;
+        }
+
+        IvyClasspathContainerConfiguration conf = request.getContainer().getConf();
+        Ivy ivy;
+        ModuleDescriptor md;
+        try {
+            // here we expect to find the ivy and the md we have just computed
+            ivy = request.getContainer().getState().getCachedIvy();
+            md = request.getContainer().getState().getCachedModuleDescriptor();
+        } catch (IvyDEException e) {
+            return new Status(IStatus.ERROR, IvyPlugin.ID, "Unexpected error");
+        }
+        boolean usePreviousResolveIfExist = request.isUsePreviousResolveIfExist();
+        IvyResolveJobThread resolver = new IvyResolveJobThread(conf, ivy, md,
+                usePreviousResolveIfExist, monitor);
+
+        resolver.start();
+        while (true) {
+            try {
+                resolver.join(WAIT_FOR_JOIN);
+            } catch (InterruptedException e) {
+                ivy.interrupt(resolver);
+                return Status.CANCEL_STATUS;
+            }
+            if (resolver.getStatus() != null || !resolver.isAlive()) {
+                break;
+            }
+            if (monitor.isCanceled()) {
+                ivy.interrupt(resolver);
+                return Status.CANCEL_STATUS;
             }
-            setResolveStatus(resolver.getStatus());
-            return resolver.getStatus();
-        } finally {
-            container.resetJob();
-            IvyPlugin.log(IStatus.INFO, "resolved dependencies of " + conf, null);
         }
+        if (resolver.getStatus() == Status.OK_STATUS) {
+            request.getContainer().updateClasspathEntries(resolver.getClasspathEntries());
+        }
+        setResolveStatus(conf, resolver.getStatus());
+        return resolver.getStatus();
+
     }
 
-    private void setResolveStatus(IStatus status) {
+    private void setResolveStatus(IvyClasspathContainerConfiguration conf, IStatus status)
{
         if (FakeProjectManager.isFake(conf.getJavaProject())) {
             return;
         }

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ResolveRequest.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ResolveRequest.java?rev=987724&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ResolveRequest.java
(added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ResolveRequest.java
Sat Aug 21 11:01:40 2010
@@ -0,0 +1,38 @@
+/*
+ *  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;
+
+public class ResolveRequest {
+
+    private final IvyClasspathContainer ivycp;
+
+    private final boolean usePreviousResolveIfExist;
+
+    public ResolveRequest(IvyClasspathContainer ivycp, boolean usePreviousResolveIfExist)
{
+        this.ivycp = ivycp;
+        this.usePreviousResolveIfExist = usePreviousResolveIfExist;
+    }
+
+    public IvyClasspathContainer getContainer() {
+        return ivycp;
+    }
+
+    public boolean isUsePreviousResolveIfExist() {
+        return usePreviousResolveIfExist;
+    }
+}

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

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

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

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java?rev=987724&r1=987723&r2=987724&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java
Sat Aug 21 11:01:40 2010
@@ -17,13 +17,14 @@
  */
 package org.apache.ivyde.eclipse.ui.actions;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Iterator;
 
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
-import org.apache.ivyde.eclipse.cpcontainer.IvyMultiResolveJob;
+import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
+import org.apache.ivyde.eclipse.cpcontainer.ResolveRequest;
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.action.Action;
 
 public class ProjectResolveAction extends Action {
@@ -36,13 +37,14 @@ public class ProjectResolveAction extend
     }
 
     public void run() {
-        List allContainers = new ArrayList();
+        IvyResolveJob resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
         for (int i = 0; i < projects.length; i++) {
-            allContainers.addAll(IvyClasspathUtil.getIvyClasspathContainers(projects[i]));
+            Iterator it = IvyClasspathUtil.getIvyClasspathContainers(projects[i]).iterator();
+            while (it.hasNext()) {
+                IvyClasspathContainer ivycp = (IvyClasspathContainer) it.next();
+                ResolveRequest request = new ResolveRequest(ivycp, false);
+                resolveJob.addRequest(request);
+            }
         }
-
-        Job multipleResolveJob = new IvyMultiResolveJob(allContainers);
-        multipleResolveJob.setUser(true);
-        multipleResolveJob.schedule();
     }
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAllAction.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAllAction.java?rev=987724&r1=987723&r2=987724&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAllAction.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAllAction.java
Sat Aug 21 11:01:40 2010
@@ -17,13 +17,14 @@
  */
 package org.apache.ivyde.eclipse.ui.actions;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Iterator;
 
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
-import org.apache.ivyde.eclipse.cpcontainer.IvyMultiResolveJob;
+import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
+import org.apache.ivyde.eclipse.cpcontainer.ResolveRequest;
 import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jdt.core.IJavaModel;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
@@ -45,14 +46,15 @@ public class ResolveAllAction implements
             return;
         }
 
-        List allContainers = new ArrayList();
+        IvyResolveJob resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
         for (int i = 0; i < projects.length; i++) {
-            allContainers.addAll(IvyClasspathUtil.getIvyClasspathContainers(projects[i]));
+            Iterator it = IvyClasspathUtil.getIvyClasspathContainers(projects[i]).iterator();
+            while (it.hasNext()) {
+                IvyClasspathContainer ivycp = (IvyClasspathContainer) it.next();
+                ResolveRequest request = new ResolveRequest(ivycp, false);
+                resolveJob.addRequest(request);
+            }
         }
-
-        Job resolveAllJob = new IvyMultiResolveJob(allContainers);
-        resolveAllJob.setUser(true);
-        resolveAllJob.schedule();
     }
 
     public void selectionChanged(IAction action, ISelection selection) {

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java?rev=987724&r1=987723&r2=987724&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java
Sat Aug 21 11:01:40 2010
@@ -26,7 +26,8 @@ import java.util.List;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
-import org.apache.ivyde.eclipse.cpcontainer.IvyMultiResolveJob;
+import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
+import org.apache.ivyde.eclipse.cpcontainer.ResolveRequest;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
@@ -34,14 +35,12 @@ import org.eclipse.core.resources.IResou
 import org.eclipse.core.resources.IResourceChangeEvent;
 import org.eclipse.core.resources.IResourceChangeListener;
 import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceRuleFactory;
 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.IStatus;
 import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
 import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
@@ -107,15 +106,15 @@ public class WorkspaceResourceChangeList
         // Found an Ivy container in this project -- notify dependent projects
         // to perform fresh resolve
 
-        // Let's try to be nice and use the workspace method to schedule resolves in
-        // dependent projects after the close operation has finished.
-        IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
-        ISchedulingRule modifyRule = ruleFactory.modifyRule(javaProject.getCorrespondingResource());
         List affectedContainers = getAffectedContainers(javaProject.getPath());
-        IvyMultiResolveJob multiResolveJob = new IvyMultiResolveJob(affectedContainers);
-        multiResolveJob.setRule(modifyRule);
-        multiResolveJob.schedule();
 
+        IvyResolveJob resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
+        Iterator it = affectedContainers.iterator();
+        while (it.hasNext()) {
+            IvyClasspathContainer ivycp = (IvyClasspathContainer) it.next();
+            ResolveRequest request = new ResolveRequest(ivycp, false);
+            resolveJob.addRequest(request);
+        }
     }
 
     private void projectOpened(IResourceChangeEvent event) {
@@ -156,13 +155,15 @@ public class WorkspaceResourceChangeList
 
         // Let's try to be nice and use the workspace method to schedule resolves in
         // dependent projects after the open operation has finished.
-        IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
-        ISchedulingRule modifyRule = ruleFactory.modifyRule(ResourcesPlugin.getWorkspace()
-                .getRoot());
         List allContainers = getAllContainersExcludingProjects(projects);
-        IvyMultiResolveJob multiResolveJob = new IvyMultiResolveJob(allContainers);
-        multiResolveJob.setRule(modifyRule);
-        multiResolveJob.schedule();
+
+        IvyResolveJob resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
+        Iterator it = allContainers.iterator();
+        while (it.hasNext()) {
+            IvyClasspathContainer ivycp = (IvyClasspathContainer) it.next();
+            ResolveRequest request = new ResolveRequest(ivycp, false);
+            resolveJob.addRequest(request);
+        }
     }
 
     /**



Mime
View raw message