ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1374771 - in /ant/ivy/ivyde/trunk: doc/ org.apache.ivyde.eclipse/META-INF/ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ org.apache.ivyde.eclipse/src/jav...
Date Sun, 19 Aug 2012 15:32:02 GMT
Author: hibou
Date: Sun Aug 19 15:32:02 2012
New Revision: 1374771

URL: http://svn.apache.org/viewvc?rev=1374771&view=rev
Log:
Source and Javadoc attachements can now be edited jar by jar

Added:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyAttachementManager.java
  (with props)
Removed:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/fragmentinfo/
Modified:
    ant/ivy/ivyde/trunk/doc/release-notes.html
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF
    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/IvyClasspathContainerMapper.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java

Modified: ant/ivy/ivyde/trunk/doc/release-notes.html
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/doc/release-notes.html?rev=1374771&r1=1374770&r2=1374771&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/doc/release-notes.html (original)
+++ ant/ivy/ivyde/trunk/doc/release-notes.html Sun Aug 19 15:32:02 2012
@@ -129,6 +129,7 @@ List of changes since <a href="/ivy/ivyd
     <li>NEW: Retrieve list does not resolve workspace projects (IVYDE-308) (thanks
to Peter Oxenham)</li>
     <li>NEW: Allow to set the Ivy user directory globally or project by project (IVYDE-311)</li>
     <li>NEW: Add support for the OSGi access rules</li>
+    <li>NEW: Source and Javadoc attachements can now be edited jar by jar</li>
 </ul>
 <ul>
     <li>IMPROVE: The properties file paths can now be edited</li>

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF?rev=1374771&r1=1374770&r2=1374771&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF Sun Aug 19 15:32:02
2012
@@ -8,7 +8,6 @@ Bundle-Activator: org.apache.ivyde.eclip
 Bundle-Vendor: Apache Software Foundation
 Export-Package: org.apache.ivyde.eclipse,
  org.apache.ivyde.eclipse.cpcontainer,
- org.apache.ivyde.eclipse.cpcontainer.fragmentinfo,
  org.apache.ivyde.eclipse.ui.console,
  org.apache.ivyde.eclipse.ui.core,
  org.apache.ivyde.eclipse.ui.editors,

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=1374771&r1=1374770&r2=1374771&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
Sun Aug 19 15:32:02 2012
@@ -26,11 +26,10 @@ import java.util.MissingResourceExceptio
 import java.util.ResourceBundle;
 
 import org.apache.ivyde.common.ivyfile.IvyFileResourceListener;
+import org.apache.ivyde.eclipse.cpcontainer.IvyAttachementManager;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainerSerializer;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
-import org.apache.ivyde.eclipse.cpcontainer.fragmentinfo.IPackageFragmentExtraInfo;
-import org.apache.ivyde.eclipse.cpcontainer.fragmentinfo.PreferenceStoreInfo;
 import org.apache.ivyde.eclipse.resolve.IvyResolveJob;
 import org.apache.ivyde.eclipse.retrieve.RetrieveSetupManager;
 import org.apache.ivyde.eclipse.ui.console.IvyConsole;
@@ -103,6 +102,8 @@ public class IvyPlugin extends AbstractU
 
     private IvyClasspathContainerSerializer ivyCpcSerializer;
 
+    private IvyAttachementManager ivyAttachementManager;
+
     /**
      * The constructor.
      */
@@ -166,11 +167,14 @@ public class IvyPlugin extends AbstractU
         ivyMarkerManager = new IvyMarkerManager();
 
         File stateLocation = getStateLocation().toFile();
+        ivyAttachementManager = new IvyAttachementManager(new File(stateLocation,
+                "attachements.properties"));
         File containersStateDir = new File(stateLocation, "cpstates");
         if (!containersStateDir.exists()) {
             containersStateDir.mkdirs();
         }
-        ivyCpcSerializer = new IvyClasspathContainerSerializer(containersStateDir);
+        ivyCpcSerializer = new IvyClasspathContainerSerializer(containersStateDir,
+                ivyAttachementManager);
 
         log(IStatus.INFO, "IvyDE plugin started", null);
 
@@ -188,6 +192,7 @@ public class IvyPlugin extends AbstractU
     public void stop(BundleContext context) throws Exception {
         super.stop(context);
         ivyCpcSerializer = null;
+        ivyAttachementManager = null;
         resourceBundle = null;
         IWorkspace workspace = ResourcesPlugin.getWorkspace();
         workspace.removeSaveParticipant(this);
@@ -368,8 +373,6 @@ public class IvyPlugin extends AbstractU
         return AbstractUIPlugin.imageDescriptorFromPlugin(ID, path);
     }
 
-    private PreferenceStoreInfo packageExtraInfo;
-
     /**
      * @return the helper around the plugin preference store
      */
@@ -381,13 +384,6 @@ public class IvyPlugin extends AbstractU
         return console;
     }
 
-    public IPackageFragmentExtraInfo getPackageFragmentExtraInfo() {
-        if (packageExtraInfo == null) {
-            packageExtraInfo = new PreferenceStoreInfo(getPreferenceStore());
-        }
-        return packageExtraInfo;
-    }
-
     public BundleContext getBundleContext() {
         return this.bundleContext;
     }
@@ -404,6 +400,10 @@ public class IvyPlugin extends AbstractU
         return ivyCpcSerializer;
     }
 
+    public IvyAttachementManager getIvyAttachementManager() {
+        return ivyAttachementManager;
+    }
+
     public IvyResolveJob getIvyResolveJob() {
         return ivyResolveJob;
     }

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyAttachementManager.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyAttachementManager.java?rev=1374771&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyAttachementManager.java
(added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyAttachementManager.java
Sun Aug 19 15:32:02 2012
@@ -0,0 +1,195 @@
+/*
+ *  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.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+
+public class IvyAttachementManager {
+
+    private static final String SRC_SUFFIX = "-src";
+
+    private static final String SRCROOT_SUFFIX = "-srcroot";
+
+    private static final String DOC_SUFFIX = "-doc";
+
+    private Properties prop = new Properties();
+
+    private File containersAttachementFile;
+
+    public IvyAttachementManager(File containersAttachementFile) {
+        this.containersAttachementFile = containersAttachementFile;
+        try {
+            FileInputStream in = new FileInputStream(containersAttachementFile);
+            try {
+                prop.load(in);
+            } finally {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    // don't care
+                }
+            }
+        } catch (IOException ioe) {
+            IvyPlugin.log(IStatus.WARNING, "IvyDE attachement properties could not be loaded",
ioe);
+        }
+    }
+
+    public void updateAttchements(IJavaProject project, IPath containerPath,
+            IClasspathContainer containerSuggestion) {
+        Properties newProps = new Properties();
+
+        IClasspathEntry[] newEntries = containerSuggestion.getClasspathEntries();
+        for (int i = 0; i < newEntries.length; i++) {
+            IClasspathEntry entry = newEntries[i];
+            if (IClasspathEntry.CPE_LIBRARY == entry.getEntryKind()) {
+                String path = entry.getPath().toPortableString();
+                if (entry.getSourceAttachmentPath() != null) {
+                    newProps.put(path + SRC_SUFFIX, entry.getSourceAttachmentPath()
+                            .toPortableString());
+                }
+                if (entry.getSourceAttachmentRootPath() != null) {
+                    newProps.put(path + SRCROOT_SUFFIX, entry.getSourceAttachmentRootPath()
+                            .toPortableString());
+                }
+                String javadocUrl = getJavadocLocation(entry);
+                if (javadocUrl != null) {
+                    newProps.put(path + DOC_SUFFIX, javadocUrl);
+                }
+            }
+        }
+
+        IvyClasspathContainer ivycp = IvyClasspathUtil.getIvyClasspathContainer(containerPath,
+            project);
+        if (ivycp == null) {
+            // something wrong happened, give up
+            return;
+        }
+        IClasspathEntry[] existingEntries = ivycp.getClasspathEntries();
+        for (int i = 0; i < existingEntries.length; i++) {
+            IClasspathEntry entry = existingEntries[i];
+            if (IClasspathEntry.CPE_LIBRARY == entry.getEntryKind()) {
+                String path = entry.getPath().toPortableString();
+                String value = (String) prop.get(path + SRC_SUFFIX);
+                if (value != null && entry.getSourceAttachmentPath() != null
+                        && value.equals(entry.getSourceAttachmentPath().toPortableString()))
{
+                    newProps.remove(path + SRC_SUFFIX);
+                }
+                value = (String) prop.get(path + SRCROOT_SUFFIX);
+                if (value != null && entry.getSourceAttachmentRootPath() != null
+                        && value.equals(entry.getSourceAttachmentRootPath().toPortableString()))
{
+                    newProps.remove(path + SRCROOT_SUFFIX);
+                }
+            }
+        }
+
+        // copy the actually new overrided properties
+        prop.putAll(newProps);
+
+        // now update the ivyde container for real
+        ivycp.updateClasspathEntries(newEntries);
+
+        // store the global result
+        try {
+            FileOutputStream out = new FileOutputStream(containersAttachementFile);
+            try {
+                prop.store(out, "");
+            } finally {
+                try {
+                    out.close();
+                } catch (IOException e) {
+                    // don't care
+                }
+            }
+        } catch (IOException ioe) {
+            IvyPlugin.log(IStatus.WARNING, "IvyDE attachement properties could not be saved",
ioe);
+        }
+    }
+
+    public IPath getSourceAttachment(IPath path) {
+        String srcPath = prop.getProperty(path.toPortableString() + SRC_SUFFIX);
+        if (!"".equals(srcPath)) {
+            return new Path(srcPath);
+        }
+        return null;
+    }
+
+    public IPath getSourceAttachmentRoot(IPath path) {
+        String srcPath = prop.getProperty(path.toPortableString() + SRCROOT_SUFFIX);
+        if (!"".equals(srcPath)) {
+            return new Path(srcPath);
+        }
+        return null;
+    }
+
+    public URL getDocAttachment(IPath path) {
+        String srcPath = prop.getProperty(path.toPortableString() + DOC_SUFFIX);
+        if (!"".equals(srcPath)) {
+            try {
+                return new URL(srcPath);
+            } catch (MalformedURLException e) {
+                IvyPlugin.log(IStatus.WARNING,
+                    "The path for the doc attachement is not a valid URL", e);
+                return null;
+            }
+        }
+        return null;
+    }
+
+    public IPath getSourceAttachment(IPath classpathArtifact, IPath sourcesArtifact) {
+        IPath sourceAttachment = getSourceAttachment(classpathArtifact);
+        if (sourceAttachment == null) {
+            sourceAttachment = sourcesArtifact;
+        }
+        return sourceAttachment;
+    }
+
+    public IPath getSourceAttachmentRoot(IPath classpathArtifact, IPath sourcesArtifact)
{
+        IPath sourceAttachment = getSourceAttachmentRoot(classpathArtifact);
+        if (sourceAttachment == null && sourcesArtifact != null) {
+            sourceAttachment = sourcesArtifact;
+        }
+        return sourceAttachment;
+    }
+
+    public String getJavadocLocation(IClasspathEntry entry) {
+        IClasspathAttribute[] attributes = entry.getExtraAttributes();
+        for (int j = 0; j < attributes.length; j++) {
+            IClasspathAttribute attribute = attributes[j];
+            if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attribute.getName()))
{
+                return attribute.getValue();
+            }
+        }
+        return null;
+    }
+
+}

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

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

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

Modified: 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=1374771&r1=1374770&r2=1374771&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
Sun Aug 19 15:32:02 2012
@@ -83,6 +83,9 @@ public class IvyClasspathContainerMapper
 
     private boolean osgiAvailable;
 
+    private IvyAttachementManager attachementManager = IvyPlugin.getDefault()
+            .getIvyAttachementManager();
+
     public IvyClasspathContainerMapper(IProgressMonitor monitor, Ivy ivy,
             IvyClasspathContainerConfiguration conf, ResolveResult resolveResult) {
         this.monitor = monitor;
@@ -113,16 +116,20 @@ public class IvyClasspathContainerMapper
                         null, true));
                 }
             } else if (artifact.getLocalFile() != null && accept(artifact.getArtifact()))
{
-                Path classpathArtifact = getArtifactPath(artifact);
-                Path sourcesArtifact = getArtifactPath(artifact, sourceArtifactMatcher,
+                IPath classpathArtifact = getArtifactPath(artifact);
+                IPath sourcesArtifact = getArtifactPath(artifact, sourceArtifactMatcher,
                     mapping.isMapIfOnlyOneSource());
-                Path javadocArtifact = getArtifactPath(artifact, javadocArtifactMatcher,
+                IPath javadocArtifact = getArtifactPath(artifact, javadocArtifactMatcher,
                     mapping.isMapIfOnlyOneJavadoc());
                 IAccessRule[] rules = getAccessRules(classpathArtifact);
-                paths.add(JavaCore.newLibraryEntry(classpathArtifact,
-                    getSourceAttachment(classpathArtifact, sourcesArtifact),
-                    getSourceAttachmentRoot(classpathArtifact, sourcesArtifact), rules,
-                    getExtraAttribute(classpathArtifact, javadocArtifact), false));
+                IPath sources = attachementManager.getSourceAttachment(classpathArtifact,
+                    sourcesArtifact);
+                IPath sourcesRoot = attachementManager.getSourceAttachmentRoot(classpathArtifact,
+                    sourcesArtifact);
+                IClasspathAttribute[] att = getExtraAttribute(classpathArtifact, javadocArtifact);
+
+                paths.add(JavaCore.newLibraryEntry(classpathArtifact, sources, sourcesRoot,
rules,
+                    att, false));
             }
 
         }
@@ -141,7 +148,7 @@ public class IvyClasspathContainerMapper
         return null;
     }
 
-    private IAccessRule[] getAccessRules(Path artifact) {
+    private IAccessRule[] getAccessRules(IPath artifact) {
         if (!osgiAvailable || !classpathSetup.isReadOSGiMetadata()) {
             return null;
         }
@@ -301,28 +308,9 @@ public class IvyClasspathContainerMapper
         return false;
     }
 
-    static IPath getSourceAttachment(IPath classpathArtifact, IPath sourcesArtifact) {
-        IPath sourceAttachment = IvyPlugin.getDefault().getPackageFragmentExtraInfo()
-                .getSourceAttachment(classpathArtifact);
-        if (sourceAttachment == null) {
-            sourceAttachment = sourcesArtifact;
-        }
-        return sourceAttachment;
-    }
-
-    static IPath getSourceAttachmentRoot(IPath classpathArtifact, IPath sourcesArtifact)
{
-        IPath sourceAttachment = IvyPlugin.getDefault().getPackageFragmentExtraInfo()
-                .getSourceAttachmentRoot(classpathArtifact);
-        if (sourceAttachment == null && sourcesArtifact != null) {
-            sourceAttachment = sourcesArtifact;
-        }
-        return sourceAttachment;
-    }
-
     private IClasspathAttribute[] getExtraAttribute(IPath classpathArtifact, IPath javadocArtifact)
{
         List result = new ArrayList();
-        URL url = IvyPlugin.getDefault().getPackageFragmentExtraInfo()
-                .getDocAttachment(classpathArtifact);
+        URL url = attachementManager.getDocAttachment(classpathArtifact);
 
         if (url == null) {
             IPath path = javadocArtifact;

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java?rev=1374771&r1=1374770&r2=1374771&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java
Sun Aug 19 15:32:02 2012
@@ -92,8 +92,11 @@ public class IvyClasspathContainerSerial
 
     private File containersStateDir;
 
-    public IvyClasspathContainerSerializer(File containersStateDir) {
+    private IvyAttachementManager ivyAttachementManager;
+
+    public IvyClasspathContainerSerializer(File containersStateDir, IvyAttachementManager
ivyAttachementManager) {
         this.containersStateDir = containersStateDir;
+        this.ivyAttachementManager = ivyAttachementManager;
     }
 
     public void save(IJavaProject project) {
@@ -371,11 +374,10 @@ public class IvyClasspathContainerSerial
                 entry = JavaCore.newProjectEntry(path, accessRules, true, cpAttrs, true);
                 break;
             case IClasspathEntry.CPE_LIBRARY:
-                sourcePath = IvyClasspathContainerMapper.getSourceAttachment(path, sourcePath);
-                IPath sourceRootPath = IvyClasspathContainerMapper.getSourceAttachmentRoot(path,
-                    sourcePath);
-                entry = JavaCore.newLibraryEntry(path, sourcePath, sourceRootPath, accessRules,
-                    cpAttrs, false);
+                IPath sources = ivyAttachementManager.getSourceAttachment(path, sourcePath);
+                IPath sourcesRoot = ivyAttachementManager.getSourceAttachmentRoot(path, sourcePath);
+                entry = JavaCore.newLibraryEntry(path, sources, sourcesRoot, accessRules,
cpAttrs,
+                    false);
                 break;
             default:
                 return null;

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=1374771&r1=1374770&r2=1374771&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
Sun Aug 19 15:32:02 2012
@@ -25,8 +25,10 @@ import java.util.Map;
 import org.apache.ivyde.eclipse.IvyPlugin;
 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.Status;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jdt.core.ClasspathContainerInitializer;
 import org.eclipse.jdt.core.IClasspathAttribute;
 import org.eclipse.jdt.core.IClasspathContainer;
@@ -86,7 +88,8 @@ public class IvyClasspathInitializer ext
                 } else {
                     if (container == null) {
                         // try what the IvyDE plugin saved
-                        IvyClasspathContainerSerializer serializer = IvyPlugin.getDefault().getIvyClasspathContainerSerializer();
+                        IvyClasspathContainerSerializer serializer = IvyPlugin.getDefault()
+                                .getIvyClasspathContainerSerializer();
                         Map ivycps = serializer.read(project);
                         if (ivycps != null) {
                             ivycp = (IvyClasspathContainer) ivycps.get(containerPath);
@@ -164,7 +167,19 @@ public class IvyClasspathInitializer ext
     }
 
     public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project)
{
-        return false;
+        return true;
+    }
+
+    public void requestClasspathContainerUpdate(final IPath containerPath,
+            final IJavaProject project, final IClasspathContainer containerSuggestion)
+            throws CoreException {
+        new Job("IvyDE attachement updater") {
+            protected IStatus run(IProgressMonitor monitor) {
+                IvyPlugin.getDefault().getIvyAttachementManager()
+                        .updateAttchements(project, containerPath, containerSuggestion);
+                return Status.OK_STATUS;
+            }
+        }.schedule();
     }
 
     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=1374771&r1=1374770&r2=1374771&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
Sun Aug 19 15:32:02 2012
@@ -279,6 +279,23 @@ public final class IvyClasspathUtil {
         return null;
     }
 
+    public static IvyClasspathContainer getIvyClasspathContainer(IPath containerPath,
+            IJavaProject javaProject) {
+        IClasspathContainer cp;
+        try {
+            cp = JavaCore.getClasspathContainer(containerPath, javaProject);
+        } catch (JavaModelException e) {
+            IvyPlugin.log(e);
+            return null;
+        }
+        if (!(cp instanceof IvyClasspathContainer)) {
+            IvyPlugin.log(IStatus.ERROR, "Expected an Ivy container but was "
+                    + cp.getClass().getName() + " for path " + containerPath, null);
+            return null;
+        }
+        return (IvyClasspathContainer) cp;
+    }
+
     /**
      * Search the Ivy classpath entry within the specified Java project with the specific
path
      * 



Mime
View raw message