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 2008/03/25 18:08:46 UTC

svn commit: r640899 [1/2] - in /ant/ivy/ivyde/trunk: ./ src/java/org/apache/ivyde/eclipse/ src/java/org/apache/ivyde/eclipse/cpcontainer/ src/java/org/apache/ivyde/eclipse/ui/actions/ src/java/org/apache/ivyde/eclipse/ui/console/ src/java/org/apache/iv...

Author: hibou
Date: Tue Mar 25 10:08:30 2008
New Revision: 640899

URL: http://svn.apache.org/viewvc?rev=640899&view=rev
Log:
IVYDE-70: The project ivy configuration is not taken into account on the first run
 - the configuration is no longer in the preference store but in the .classpath
 - the configuration pane is now unique
 - the configuration inheritance is not by properties anymore ("Enable project specific settings" way of overriding global configuration)

Added:
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java   (with props)
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java   (with props)
Modified:
    ant/ivy/ivyde/trunk/CHANGES.txt
    ant/ivy/ivyde/trunk/plugin.xml
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathEntry.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/RefreshAction.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAction.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/actions/ResolveAllAction.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/console/IvyConsole.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/editors/IvyEditor.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/editors/xml/IvyContentAssistProcessor.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyPreferencePage.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java
    ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/ui/properties/IvyProjectPropertyPage.java

Modified: ant/ivy/ivyde/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/CHANGES.txt?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/CHANGES.txt (original)
+++ ant/ivy/ivyde/trunk/CHANGES.txt Tue Mar 25 10:08:30 2008
@@ -17,6 +17,7 @@
 - FIX: "Add Ivy library" not working in eclipse 3.3 (IVYDE-57)
 - FIX: Automatic javadoc attachment is not working (IVYDE-55)
 - FIX: On startup IvyIDE can freeze eclipse (IVYDE-63) (thanks to Nicolas Lalevée)
+- FIX: The project ivy configuration is not taken into account on the first run: the configuration is no longer stored in the preferences but in the .classpath (IVYDE-70)
 
 - moved to apache, packages renamed to org.apache.ivyde
   				

Modified: ant/ivy/ivyde/trunk/plugin.xml
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/plugin.xml?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/plugin.xml (original)
+++ ant/ivy/ivyde/trunk/plugin.xml Tue Mar 25 10:08:30 2008
@@ -113,31 +113,6 @@
       </initializer>
    </extension>
    
-   <extension
-         point="org.eclipse.ui.propertyPages">
-      <page
-            objectClass="org.eclipse.core.resources.IProject"
-            class="org.apache.ivyde.eclipse.ui.properties.IvyProjectPropertyPage"
-            id="org.apache.ivyde.eclipse.properties.ivyProjectPropertyPage"
-            name="Ivy">
-         <filter
-               name="nature"
-               value="org.eclipse.jdt.core.javanature">
-         </filter>
-         <keywordReference id="org.eclipse.jdt.ui.buildpath"/>
-      </page>
-      <page
-            objectClass="org.eclipse.jdt.core.IJavaProject"
-            class="org.apache.ivyde.eclipse.ui.properties.IvyProjectPropertyPage"
-            id="org.apache.ivyde.eclipse.properties.ivyProjectPropertyPage"
-            name="Ivy">
-         <filter
-               name="nature"
-               value="org.eclipse.jdt.core.javanature">
-         </filter>
-         <keywordReference id="org.eclipse.jdt.ui.buildpath"/>
-      </page>
-   </extension>
    
 	<extension 
 	   point="org.eclipse.ui.views">

Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java Tue Mar 25 10:08:30 2008
@@ -1,35 +1,45 @@
+/*
+ *  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;
 
 import java.io.File;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
-import java.util.Set;
 
 import org.apache.ivy.Ivy;
-import org.apache.ivy.core.module.descriptor.Artifact;
 import org.apache.ivy.util.Message;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+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.ui.console.IvyConsole;
+import org.apache.ivyde.eclipse.ui.preferences.IvyDEPreferenceStoreHelper;
 import org.apache.ivyde.eclipse.ui.preferences.PreferenceConstants;
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
 import org.eclipse.jdt.core.IJavaModel;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
@@ -38,26 +48,20 @@
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
-import org.osgi.service.prefs.BackingStoreException;
 
 /**
  * The main plugin class to be used in the desktop.
  */
 public class IvyPlugin extends AbstractUIPlugin {
-    public static final String ID = "org.apache.ivyde.eclipse";
-
-    public static final String PREF_CONSOLE_DEBUG_COLOR = ID + ".console.color.debug";
-
-    public static final String PREF_CONSOLE_VERBOSE_COLOR = ID + ".console.color.verbose";
 
-    public static final String PREF_CONSOLE_INFO_COLOR = ID + ".console.color.info";
-
-    public static final String PREF_CONSOLE_WARN_COLOR = ID + ".console.color.warn";
-
-    public static final String PREF_CONSOLE_ERROR_COLOR = ID + ".console.color.error";
+    /** The ID of IvyDE plugin */
+    public static final String ID = "org.apache.ivyde.eclipse";
 
     // The shared instance.
     private static IvyPlugin plugin;
@@ -67,8 +71,12 @@
 
     private IvyConsole console;
 
+    private IvyDEPreferenceStoreHelper prefStoreHelper;
+
     private IJavaModel javaModel;
 
+    private BundleContext bundleContext;
+
     /**
      * The constructor.
      */
@@ -82,6 +90,7 @@
      */
     public void start(BundleContext context) throws Exception {
         super.start(context);
+        this.bundleContext = context;
         log(IStatus.INFO, "starting IvyDE plugin", null);
         try {
             console = new IvyConsole();
@@ -89,19 +98,30 @@
             // Don't let the console bring down the CVS UI
             log(IStatus.ERROR, "Errors occurred starting the Ivy console", e);
         }
+        javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
+        prefStoreHelper = new IvyDEPreferenceStoreHelper(getPreferenceStore());
         getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
             public void propertyChange(PropertyChangeEvent event) {
-                if (event.getProperty() == PreferenceConstants.IVYCONF_PATH) {
-                    ivyConfPathChanged();
-                }
-                if (event.getProperty() == PreferenceConstants.ACCEPTED_TYPES
-                        || event.getProperty() == PreferenceConstants.SOURCES_TYPES
-                        || event.getProperty() == PreferenceConstants.JAVADOC_TYPES) {
-                    typesChanged(event.getProperty());
+                try {
+                    if (event.getProperty() == PreferenceConstants.IVYSETTINGS_PATH
+                            || event.getProperty() == PreferenceConstants.ACCEPTED_TYPES
+                            || event.getProperty() == PreferenceConstants.SOURCES_TYPES
+                            || event.getProperty() == PreferenceConstants.JAVADOC_TYPES
+                            || event.getProperty() == PreferenceConstants.SOURCES_SUFFIXES
+                            || event.getProperty() == PreferenceConstants.JAVADOC_SUFFIXES
+                            || event.getProperty() == PreferenceConstants.DO_RETRIEVE
+                            || event.getProperty() == PreferenceConstants.RETRIEVE_PATTERN
+                            || event.getProperty() == PreferenceConstants.ALPHABETICAL_ORDER) {
+                        prefStoreChanged();
+                    }
+                } catch (JavaModelException e) {
+                    MessageDialog.openError(IvyPlugin.getDefault().getWorkbench()
+                            .getActiveWorkbenchWindow().getShell(),
+                        "Unable to trigger the update the IvyDE classpath containers", e
+                                .getMessage());
                 }
             }
         });
-        javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
         log(IStatus.INFO, "IvyDE plugin started", null);
     }
 
@@ -116,6 +136,16 @@
         // console.shutdown();
     }
 
+    void prefStoreChanged() throws JavaModelException {
+        IJavaProject[] projects = plugin.javaModel.getJavaProjects();
+        for (int i = 0; i < projects.length; i++) {
+            IvyClasspathContainer cp = IvyClasspathUtil.getIvyClasspathContainer(projects[i]);
+            if (cp != null && !cp.getConf().isProjectSpecific()) {
+                cp.scheduleRefresh(false);
+            }
+        }
+    }
+
     /**
      * Convenience method for logging statuses to the plugin log
      * 
@@ -139,12 +169,56 @@
 
     /**
      * Returns the shared instance.
+     * 
+     * @return the plugin instance
      */
     public static IvyPlugin getDefault() {
         return plugin;
     }
 
     /**
+     * Returns the active workbench shell
+     * 
+     * @return the active workbench shell
+     */
+    public static Shell getActiveWorkbenchShell() {
+        IWorkbenchWindow workBenchWindow = getActiveWorkbenchWindow();
+        if (workBenchWindow == null) {
+            return null;
+        }
+        return workBenchWindow.getShell();
+    }
+
+    /**
+     * Returns the active workbench page or <code>null</code> if none.
+     * 
+     * @return the active workbench page
+     */
+    public static IWorkbenchPage getActivePage() {
+        IWorkbenchWindow window = getActiveWorkbenchWindow();
+        if (window != null) {
+            return window.getActivePage();
+        }
+        return null;
+    }
+
+    /**
+     * Returns the active workbench window
+     * 
+     * @return the active workbench window
+     */
+    public static IWorkbenchWindow getActiveWorkbenchWindow() {
+        if (getDefault() == null) {
+            return null;
+        }
+        IWorkbench workBench = getDefault().getWorkbench();
+        if (workBench == null) {
+            return null;
+        }
+        return workBench.getActiveWorkbenchWindow();
+    }
+
+    /**
      * Returns the string from the plugin's resource bundle, or 'key' if not found.
      */
     public static String getResourceString(String key) {
@@ -162,7 +236,7 @@
     public ResourceBundle getResourceBundle() {
         try {
             if (resourceBundle == null)
-                resourceBundle = ResourceBundle.getBundle("org.apache.ivyde.IvyPluginResources");
+                resourceBundle = ResourceBundle.getBundle("org.apache.ivyde.eclipse.IvyPluginResources");
         } catch (MissingResourceException x) {
             resourceBundle = new ResourceBundle() {
                 protected Object handleGetObject(String key) {
@@ -186,424 +260,172 @@
      * @return the image descriptor
      */
     public static ImageDescriptor getImageDescriptor(String path) {
-        return AbstractUIPlugin.imageDescriptorFromPlugin("org.apache.ivyde", path);
+        return AbstractUIPlugin.imageDescriptorFromPlugin(ID, path);
     }
 
     private static class IvyConfig {
         Ivy ivy;
 
         long configTime = -1;
-
-        public IvyConfig() {
-        }
-
-        public IvyConfig(Ivy ivy) {
-            this.ivy = ivy;
-        }
     }
 
-    private static Map _ivysByProject = new HashMap(); // Map (IJavaProject -> IvyConfig)
-
-    private static Map _ivysByConf = new HashMap(); // Map (configPath -> IvyConfig)
-
-    private static boolean _inChange;
-
-    private static Set _todo = new HashSet();
+    private Map/* <String, IvyConfig> */ivyBySettings = new HashMap();
 
     private PreferenceStoreInfo _packageExtraInfo;
 
-    private Map _containers = new HashMap();
-
-    public static Ivy getIvy(IJavaProject javaProject) {
-        Ivy ivy = refreshIvyConfiguration(javaProject, getIvyconfURL(javaProject));
-        return ivy == null ? new Ivy() : ivy;
+    /**
+     * @return the helper around the plugin preference store
+     */
+    public static IvyDEPreferenceStoreHelper getPreferenceStoreHelper() {
+        return plugin.prefStoreHelper;
     }
 
-    public static void ivyConfPathChanged() {
+    /**
+     * Get the Ivy instance for the specified project and the settings of the configured container
+     * on the project.
+     * 
+     * @param javaProject
+     *            the Java project
+     * @param ivySettingsPath
+     *            the settings to use
+     * @return the configured Ivy instance, <code>null</code> if it failed
+     */
+    // TODO: check that every caller of this function can properly handle a returned null
+    public static synchronized Ivy getIvy(IJavaProject javaProject) {
+        IvyClasspathContainer cp;
         try {
-            IJavaProject[] projects = plugin.javaModel.getJavaProjects();
-            String defaultConfURL = getIvyconfURL();
-            for (int i = 0; i < projects.length; i++) {
-                if (getStrictIvyconfURL(projects[i]) == null) {
-                    resolve(projects[i]);
-                }
-            }
+            cp = IvyClasspathUtil.getIvyClassPathContainer(javaProject);
         } catch (JavaModelException e) {
+            // TODO log and better handle the error
+            return null;
         }
-    }
-
-    public static void typesChanged(String typesCode) {
-        try {
-            IJavaProject[] projects = plugin.javaModel.getJavaProjects();
-            String defaultConfURL = getIvyconfURL();
-            for (int i = 0; i < projects.length; i++) {
-                if ("[inherited]".equals(getInheritablePreferenceString(projects[i], typesCode))) {
-                    resolve(projects[i]);
-                }
-            }
-        } catch (JavaModelException e) {
+        if (cp == null) {
+            return null;
         }
+        return getIvy(javaProject, cp.getConf().getIvySettingsPath());
     }
 
-    private static synchronized Ivy refreshIvyConfiguration(IJavaProject javaProject,
-            String configPath) {
+    /**
+     * Get the Ivy instance for the specified project and the specified settings
+     * <p>
+     * 
+     * @param javaProject
+     *            the Java project
+     * @param ivySettingsPath
+     *            the settings to use
+     * @return the configured Ivy instance, <code>null</code> if it failed
+     */
+    // TODO: check that every caller of this function can properly handle a returned null
+    public static synchronized Ivy getIvy(IJavaProject javaProject, String ivySettingsPath) {
+        IvyConfig ic;
         try {
-            if (configPath == null || configPath.trim().length() == 0
-                    || "default".equals(configPath)) {
-                return defaultIvyConfigure(javaProject);
-            } else {
-                IvyConfig ic = (IvyConfig) _ivysByProject.get(javaProject);
-                if (ic == null) {
-                    ic = (IvyConfig) _ivysByConf.get(configPath);
-                    if (ic == null) {
-                        ic = new IvyConfig();
-                        _ivysByProject.put(javaProject, ic);
-                        _ivysByConf.put(configPath, ic);
-                    }
+            if (ivySettingsPath == null || ivySettingsPath.trim().length() == 0) {
+                // no settings specified, so take the default one
+                return getDefaultIvy();
+            }
+
+            ic = (IvyConfig) plugin.ivyBySettings.get(ivySettingsPath);
+            if (ic == null) {
+                ic = new IvyConfig();
+                plugin.ivyBySettings.put(ivySettingsPath, ic);
+            }
+
+            // before returning the found ivy, try to refresh it if the settings changed
+
+            URL url = new URL(ivySettingsPath);
+            if (url.getProtocol().startsWith("file")) {
+                File file = new File(url.getPath());
+
+                // BEGIN - JIRA: IVYDE-25 by Peter Chanthamynavong
+                // Getting an Absolute Filename Path from a Relative Filename Path for the
+                // current project
+                if (!file.exists()) {
+                    IProject project = javaProject.getProject();
+                    File loc = project.getLocation().toFile();
+                    file = new File(loc, url.getPath());
+                    Message.info("\n\nIVYDE: ivysettings from relative path: "
+                            + file.getAbsolutePath());
                 }
+                // END - JIRA: IVYDE-25
 
-                URL url = new URL(configPath);
-                if (url.getProtocol().startsWith("file")) {
-                    File file = new File(url.getPath());
-
-                    // BEGIN - JIRA: IVYDE-25 by Peter Chanthamynavong
-                    // Getting an Absolute Filename Path from a Relative Filename Path for the
-                    // current project
-                    if (!file.exists()) {
-                        IProject project = javaProject.getProject();
-                        File loc = project.getLocation().toFile();
-                        file = new File(loc, url.getPath());
-                        Message.info("\n\nIVYDE: ivysettings from relative path: "
-                                + file.getAbsolutePath());
-                    }
-                    // END - JIRA: IVYDE-25
+                if (!file.exists()) {
+                    MessageDialog
+                            .openWarning(
+                                getActiveWorkbenchShell(),
+                                "No ivyConf found",
+                                ivySettingsPath
+                                        + " ivyconf cannot be found.\nPlease set your ivy conf url in the preference or in your project properties to be able to use IvyDE");
+                    return null;
+                }
 
-                    if (!file.exists()) {
-                        MessageDialog
-                                .openWarning(
-                                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
-                                    "No ivyConf found",
-                                    configPath
-                                            + " ivyconf cannot be found.\nPlease set your ivy conf url in the preference or in your project properties to be able to use IvyDE");
-                        if (ic.ivy == null) {
-                            ic.ivy = new Ivy();
-                        }
+                if (file.lastModified() != ic.configTime) {
+                    ic.ivy = new Ivy();
+                    if (ic.configTime == -1) {
+                        Message.info("\n\n");
                     } else {
-                        if (file.lastModified() != ic.configTime) {
-                            ic.ivy = new Ivy();
-                            if (ic.configTime == -1) {
-                                Message.info("\n\n");
-                            } else {
-                                Message
-                                        .info("\n\nIVYDE: ivysettings has changed, configuring ivy again\n");
-                            }
-                            ic.ivy.configure(file);
-                            ic.configTime = file.lastModified();
-                        }
-                    }
-                } else {
-                    if (ic.ivy == null) {
-                        ic.ivy = new Ivy();
-                        ic.ivy.configure(url);
+                        Message.info("\n\nIVYDE: ivysettings has changed, configuring ivy again\n");
                     }
+                    ic.ivy.configure(file);
+                    ic.configTime = file.lastModified();
+                }
+
+            } else {
+                // an URL but not a file
+                if (ic.ivy == null) {
+                    ic.ivy = new Ivy();
+                    ic.ivy.configure(url);
                 }
-                return ic.ivy;
             }
+            return ic.ivy;
         } catch (Exception e) {
-            try {
-                MessageDialog
-                        .openWarning(
-                            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
-                            "Bad ivyConf found",
-                            "Problem occured while using "
-                                    + configPath
-                                    + " to configure Ivy.\nPlease set your ivy conf url properly in the preference or in the project properties to be able to use IvyDE.\nException message: "
-                                    + e.getMessage());
-            } catch (Exception ex) {
-            }
-            log(IStatus.WARNING, "Problem occured while using " + configPath + " to configure Ivy",
-                e);
-            Message.warn("IVYDE: Problem occured while using " + configPath
+            MessageDialog
+                    .openWarning(
+                        getActiveWorkbenchShell(),
+                        "Bad ivySetting found",
+                        "Problem occured while using "
+                                + ivySettingsPath
+                                + " to configure Ivy.\n"
+                                + "Please set your ivy settings url properly in the preference or in the project properties to be able to use IvyDE.\n"
+                                + "Exception message: " + e.getMessage());
+            log(IStatus.WARNING, "Problem occured while using " + ivySettingsPath
+                    + " to configure Ivy", e);
+            Message.warn("IVYDE: Problem occured while using " + ivySettingsPath
                     + " to configure Ivy. See error log for details");
-            _ivysByProject.remove(javaProject);
-            _ivysByConf.remove(configPath);
-            return new Ivy();
+            plugin.ivyBySettings.remove(ivySettingsPath);
+            return null;
         }
     }
 
-    private static Ivy defaultIvyConfigure(IJavaProject javaProject) {
-        IvyConfig ic = (IvyConfig) _ivysByProject.get(javaProject);
+    private static Ivy getDefaultIvy() {
+        IvyConfig ic = (IvyConfig) plugin.ivyBySettings.get(null);
         if (ic == null) {
-            ic = (IvyConfig) _ivysByConf.get("default");
-        }
-        Ivy ivy = ic == null ? null : ic.ivy;
-        if (ivy == null) {
-            ivy = new Ivy();
+            ic = new IvyConfig();
+            ic.ivy = new Ivy();
             try {
-                ivy.configureDefault();
-                IvyConfig ivyConfig = new IvyConfig(ivy);
-                _ivysByProject.put(javaProject, ivyConfig);
-                _ivysByConf.put("default", ivyConfig);
+                ic.ivy.configureDefault();
+                plugin.ivyBySettings.put(null, ic);
             } catch (Exception ex) {
                 MessageDialog
                         .openWarning(
-                            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+                            getActiveWorkbenchShell(),
                             "Impossible to configure Ivy",
-                            "Problem occured while configuring Ivy with its default settings.\nPlease set an ivy settings url properly in the preference or in the project properties to be able to use IvyDE.\nException message: "
-                                    + ex.getMessage());
+                            "Problem occured while configuring Ivy with its default settings.\n"
+                                    + "Please set an ivy settings url properly in the preference or in the project properties to be able to use IvyDE.\n"
+                                    + "Exception message: " + ex.getMessage());
                 log(IStatus.WARNING,
                     "Problem occured while configuring Ivy with its default settings.", ex);
                 Message
                         .warn("IVYDE: Problem occured while configuring Ivy with its default settings. See error log for details");
+                return null;
             }
         }
-        return ivy;
-    }
-
-    public static String getIvyconfURL(IJavaProject project) {
-        String ivyconf = getStrictIvyconfURL(project);
-        if (ivyconf == null) {
-            return getIvyconfURL();
-        } else {
-            return ivyconf;
-        }
-    }
-
-    public static String getStrictIvyconfURL(IJavaProject project) {
-        if (project == null) {
-            return null;
-        }
-        String opt = IvyPlugin.getDefault().getProjectPreferences(project).get(
-            PreferenceConstants.IVYCONF_PATH, null);
-        if (opt == null || opt.trim().length() == 0 || "inherited".equals(opt)) {
-            return null;
-        } else {
-            return opt.trim();
-        }
-    }
-
-    public static String getIvyconfURL() {
-        String configPath = IvyPlugin.getDefault().getPreferenceStore().getString(
-            PreferenceConstants.IVYCONF_PATH);
-        if (configPath == null || configPath.trim().length() == 0) {
-            return "default";
-        } else {
-            return configPath.trim();
-        }
-    }
-
-    public static void setIvyconfURL(IJavaProject project, String ivyconfURL) {
-        _ivysByProject.remove(project);
-        if (ivyconfURL == null) {
-            IvyPlugin.getDefault().getProjectPreferences(project).put(
-                PreferenceConstants.IVYCONF_PATH, "inherited");
-        } else {
-            IvyPlugin.getDefault().getProjectPreferences(project).put(
-                PreferenceConstants.IVYCONF_PATH, ivyconfURL);
-        }
-        flushProjectPreferences(project);
-
-        resolve(project);
-    }
-
-    /**
-     * Check if the artifact is an artifact which can be added to the classpath container
-     * 
-     * @param project
-     *            the project containing the ivy container
-     * @param artifact
-     *            the artifact to check
-     * @return <code>true</code> if the artifact can be added
-     */
-    public static boolean accept(IJavaProject project, Artifact artifact) {
-        return getAcceptedTypes(project).contains(artifact.getType())
-                && !getSourcesTypes(project).contains(artifact.getType())
-                && !getJavadocTypes(project).contains(artifact.getType());
-    }
-
-    private static Collection getAcceptedTypes(IJavaProject project) {
-        return getInheritablePreferenceList(project, PreferenceConstants.ACCEPTED_TYPES, "jar");
-    }
-
-    public static String getAcceptedTypesString(IJavaProject project) {
-        return getInheritablePreferenceString(project, PreferenceConstants.ACCEPTED_TYPES);
-    }
-
-    public static void setAcceptedTypes(IJavaProject project, String types) {
-        setInheritablePreferenceString(project, types, PreferenceConstants.ACCEPTED_TYPES);
-    }
-
-    public static boolean isSources(IJavaProject project, Artifact artifact) {
-        return getSourcesTypes(project).contains(artifact.getType());
-    }
-
-    private static Collection getSourcesTypes(IJavaProject project) {
-        return getInheritablePreferenceList(project, PreferenceConstants.SOURCES_TYPES, "source");
-    }
-
-    public static String getSourcesTypesString(IJavaProject project) {
-        return getInheritablePreferenceString(project, PreferenceConstants.SOURCES_TYPES);
-    }
-
-    public static void setSourcesTypes(IJavaProject project, String types) {
-        setInheritablePreferenceString(project, types, PreferenceConstants.SOURCES_TYPES);
-    }
-
-    public static boolean isSourceArtifactName(IJavaProject project, String jar, String source) {
-        if (source.equals(jar)) {
-            return true;
-        }
-        Iterator it = getSourcesSuffixes(project).iterator();
-        while (it.hasNext()) {
-            if (source.equals(jar + it.next())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private static Collection getSourcesSuffixes(IJavaProject project) {
-        return getInheritablePreferenceList(project, PreferenceConstants.SOURCES_SUFFIXES, "-source, -sources, -src");
-    }
-
-    public static String getSourcesSuffixesString(IJavaProject project) {
-        return getInheritablePreferenceString(project, PreferenceConstants.SOURCES_SUFFIXES);
-    }
-
-    public static void setSourcesSuffixes(IJavaProject project, String types) {
-        setInheritablePreferenceString(project, types, PreferenceConstants.SOURCES_SUFFIXES);
-    }
-
-    public static boolean isJavadoc(IJavaProject project, Artifact artifact) {
-        return getJavadocTypes(project).contains(artifact.getType());
-    }
-
-    private static Collection getJavadocTypes(IJavaProject project) {
-        return getInheritablePreferenceList(project, PreferenceConstants.JAVADOC_TYPES, "javadoc");
-    }
-
-    public static String getJavadocTypesString(IJavaProject project) {
-        return getInheritablePreferenceString(project, PreferenceConstants.JAVADOC_TYPES);
-    }
-
-    public static void setJavadocTypes(IJavaProject project, String types) {
-        setInheritablePreferenceString(project, types, PreferenceConstants.JAVADOC_TYPES);
-    }
-
-    public static boolean isJavadocArtifactName(IJavaProject project, String jar, String javadoc) {
-        if (javadoc.equals(jar)) {
-            return true;
-        }
-        Iterator it = getJavadocSuffixes(project).iterator();
-        while (it.hasNext()) {
-            if (javadoc.equals(jar + it.next())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private static Collection getJavadocSuffixes(IJavaProject project) {
-        return getInheritablePreferenceList(project, PreferenceConstants.JAVADOC_SUFFIXES, "-javadoc, -javadocs, -doc, -docs");
-    }
-
-    public static String getJavadocSuffixesString(IJavaProject project) {
-        return getInheritablePreferenceString(project, PreferenceConstants.JAVADOC_SUFFIXES);
-    }
-
-    public static void setJavadocSuffixes(IJavaProject project, String types) {
-        setInheritablePreferenceString(project, types, PreferenceConstants.JAVADOC_SUFFIXES);
-    }
-
-    private static Collection getInheritablePreferenceList(IJavaProject project, String code, String defaultValues) {
-        String types = getInheritablePreferenceString(project, code);
-
-        if ("[inherited]".equals(types)) {
-            String workspaceTypes = IvyPlugin.getDefault().getPreferenceStore()
-                    .getString(code);
-            if (workspaceTypes == null || workspaceTypes.trim().length() == 0) {
-                types = defaultValues;
-            } else {
-                types = workspaceTypes.trim();
-            }
-        }
-        return split(types);
-    }
-
-    private static String getInheritablePreferenceString(IJavaProject project, String code) {
-        String values = IvyPlugin.getDefault().getProjectPreferences(project).get(code, null);
-        if (values == null || values.trim().length() == 0) {
-            return "[inherited]";
-        }
-        return values.trim();
-    }
-
-    private static void setInheritablePreferenceString(IJavaProject project, String values, String code) {
-        if (values == null || values.trim().length() == 0 || values.trim().startsWith("[inherited]")) {
-            IvyPlugin.getDefault().getProjectPreferences(project).put(code, "[inherited]");
-        } else {
-            IvyPlugin.getDefault().getProjectPreferences(project).put(code, values);
-        }
-        flushProjectPreferences(project);
-        resolve(project);
-    }
-
-    private static Collection split(String str) {
-        String[] t = str.split(",");
-        Collection ret = new ArrayList();
-        for (int i = 0; i < t.length; i++) {
-            if (t[i].trim().length() > 0) {
-                ret.add(t[i].trim());
-            }
-        }
-        return ret;
+        return ic.ivy;
     }
 
     public IvyConsole getConsole() {
         return console;
     }
 
-    public static String getRetreivePattern() {
-        if (IvyPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.DO_RETRIEVE)) {
-            String pattern = IvyPlugin.getDefault().getPreferenceStore().getString(
-                PreferenceConstants.RETRIEVE_PATTERN);
-            return pattern == null ? "" : pattern.trim();
-        } else {
-            return "";
-        }
-    }
-
-    public static String getRetreivePattern(IJavaProject project) {
-        String pattern = IvyPlugin.getDefault().getProjectPreferences(project).get(
-            PreferenceConstants.RETRIEVE_PATTERN, null);
-
-        return pattern == null ? "" : pattern.trim();
-    }
-
-    public static void setRetreivePattern(String pattern) {
-        IvyPlugin.getDefault().getPreferenceStore().putValue(PreferenceConstants.RETRIEVE_PATTERN,
-            pattern);
-    }
-
-    public static void setRetreivePattern(IJavaProject project, String pattern) {
-        if (pattern == null || pattern.trim().length() == 0) {
-            pattern = "none";
-        } else if (pattern.startsWith("[inherited]")) {
-            pattern = "[inherited]";
-        }
-        IvyPlugin.getDefault().getProjectPreferences(project).put(
-            PreferenceConstants.RETRIEVE_PATTERN, pattern);
-        flushProjectPreferences(project);
-    }
-
-    private static void flushProjectPreferences(IJavaProject project) {
-        try {
-            IvyPlugin.getDefault().getProjectPreferences(project).flush();
-        } catch (BackingStoreException e) {
-            log(IStatus.WARNING, "impossible to store IvyDE project preferences", e);
-        }
-    }
-
     public IPackageFragmentExtraInfo getPackageFragmentExtraInfo() {
         if (_packageExtraInfo == null) {
             _packageExtraInfo = new PreferenceStoreInfo(getPreferenceStore());
@@ -611,88 +433,7 @@
         return _packageExtraInfo;
     }
 
-    public static String getRetrievePatternHerited(IJavaProject project) {
-        String retreivePattern = getRetreivePattern(project);
-        if ("".equals(retreivePattern) || retreivePattern.startsWith("[inherited]")) {
-            retreivePattern = getRetreivePattern();
-            if (!"".equals(retreivePattern)) {
-                retreivePattern = "[inherited] " + retreivePattern;
-            }
-        } else if ("none".equals(retreivePattern)) {
-            retreivePattern = "";
-        }
-        return retreivePattern.trim();
-    }
-
-    public static String getFullRetrievePatternHerited(IJavaProject project) {
-        String retreivePattern = getRetrievePatternHerited(project);
-        if (!"".equals(retreivePattern)) {
-            if (retreivePattern.startsWith("[inherited] ")) {
-                retreivePattern = retreivePattern.substring("[inherited] ".length());
-            }
-            return project.getProject().getLocation().toPortableString() + "/" + retreivePattern;
-        } else {
-            return "";
-        }
-    }
-
-    public static boolean shouldDoRetrieve(IJavaProject project) {
-        return !"".equals(getRetrievePatternHerited(project));
-    }
-
-    public static boolean isAlphaOrder(IJavaProject javaProject) {
-        return IvyPlugin.getDefault().getProjectPreferences(javaProject).getBoolean(
-            PreferenceConstants.APHABETICAL_ORDER, false);
-    }
-
-    public static void setAlphaOrder(IJavaProject project, boolean alphaOrder) {
-        IvyPlugin.getDefault().getProjectPreferences(project).putBoolean(
-            PreferenceConstants.APHABETICAL_ORDER, alphaOrder);
-    }
-
-    public static boolean shouldTestNonDeclaredSources(IJavaProject project) {
-        return true; // TODO: add settings for that
-    }
-
-    public static boolean shouldTestNonDeclaredJavadocs(IJavaProject project) {
-        return true; // TODO: add settings for that
-    }
-
-    public IEclipsePreferences getProjectPreferences(final IJavaProject project) {
-        IScopeContext projectScope = new ProjectScope(project.getProject());
-        IEclipsePreferences projectNode = projectScope.getNode(ID);
-        return projectNode;
-
-    }
-
-    public static void beginChanges() {
-        _inChange = true;
+    public BundleContext getBundleContext() {
+      return this.bundleContext;
     }
-
-    public static void commitChanges() {
-        _inChange = false;
-        for (Iterator iter = _todo.iterator(); iter.hasNext();) {
-            IJavaProject project = (IJavaProject) iter.next();
-            IvyClasspathContainer.resolve(project);
-        }
-    }
-
-    private static void resolve(IJavaProject project) {
-        if (_inChange) {
-            _todo.add(project);
-        } else {
-            IvyClasspathContainer.resolve(project);
-        }
-    }
-
-    public void register(IvyClasspathContainer container) {
-        _containers.put(container.getProject().getProject().getName() + "/" + container.getPath(),
-            container);
-    }
-
-    public Collection getAllContainers() {
-        Message.debug("all known ivy classpath containers are: " + _containers.keySet());
-        return _containers.values();
-    }
-
 }

Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java Tue Mar 25 10:08:30 2008
@@ -1,3 +1,20 @@
+/*
+ *  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;
@@ -51,15 +68,22 @@
 import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.core.runtime.jobs.ISchedulingRule;
 import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.ElementChangedEvent;
 import org.eclipse.jdt.core.IClasspathAttribute;
 import org.eclipse.jdt.core.IClasspathContainer;
 import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IElementChangedListener;
+import org.eclipse.jdt.core.IJavaElementDelta;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.core.ClasspathEntry;
+import org.eclipse.jdt.internal.core.DeltaProcessingState;
+import org.eclipse.jdt.internal.core.JavaElementDelta;
 import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider;
 import org.eclipse.swt.widgets.Display;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
 
 /**
  * Eclipse classpath container that will contain the ivy resolved entries.
@@ -75,20 +99,20 @@
 
         private IProgressMonitor _dlmonitor;
 
-        private Ivy _ivy;
-
         private boolean _usePreviousResolveIfExist;
 
         private int _workPerArtifact = 100;
 
         private boolean _notify;
 
-        public IvyResolveJob(Ivy ivy, boolean usePreviousResolveIfExist, boolean notify) {
-            super("Resolve " + _javaProject.getProject().getName() + "/" + _ivyXmlPath
+        private Ivy _ivy;
+
+        public IvyResolveJob(boolean usePreviousResolveIfExist, boolean notify) {
+            super("Resolve " + _javaProject.getProject().getName() + "/" + conf.ivyXmlPath
                     + " dependencies");
-            _ivy = ivy;
             _usePreviousResolveIfExist = usePreviousResolveIfExist;
             _notify = notify;
+            _ivy = IvyPlugin.getIvy(_javaProject, conf.getInheritedIvySettingsPath());
         }
 
         public void transferProgress(TransferEvent evt) {
@@ -166,7 +190,7 @@
                     try {
                         ivyURL = _ivyXmlFile.toURL();
                     } catch (MalformedURLException e) {
-                        status[0] = new Status(Status.ERROR, IvyPlugin.ID, Status.ERROR,
+                        status[0] = new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
                                 "The path of ivy.xml is not a valid URL", e);
                         return;
                     }
@@ -185,10 +209,11 @@
                         if (_usePreviousResolveIfExist) {
                             md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(
                                 _ivy.getSettings(), ivyURL, false);
-                            if (_confs.length == 1 && "*".equals(_confs[0])) {
+                            if (conf.confs.size() == 1 && "*".equals(conf.confs.get(0))) {
                                 confs = md.getConfigurationsNames();
                             } else {
-                                confs = _confs;
+                                confs = (String[]) conf.confs
+                                        .toArray(new String[conf.confs.size()]);
                             }
 
                             all = new LinkedHashSet();
@@ -222,7 +247,8 @@
                                             + md.getModuleRevisionId().getModuleId()
                                             + " doesn't contain enough data: resolving again\n");
                                     ResolveReport r = _ivy.resolve(ivyURL, new ResolveOptions()
-                                            .setConfs(_confs));
+                                            .setConfs((String[]) conf.confs
+                                                    .toArray(new String[conf.confs.size()])));
                                     all.addAll(Arrays.asList(r.getArtifactsReports(null, false)));
                                     confs = r.getConfigurations();
                                     problemMessages.addAll(r.getAllProblemMessages());
@@ -234,7 +260,8 @@
                         } else {
                             Message.info("\n\nIVYDE: calling resolve on " + ivyURL + "\n");
                             ResolveReport report = _ivy.resolve(ivyURL, new ResolveOptions()
-                                    .setConfs(_confs));
+                                    .setConfs((String[]) conf.confs.toArray(new String[conf.confs
+                                            .size()])));
                             problemMessages = report.getAllProblemMessages();
                             all = new LinkedHashSet(Arrays.asList(report.getArtifactsReports(null,
                                 false)));
@@ -263,8 +290,8 @@
                         String errorMsg = "Error while resolving dependencies for " + _ivyXmlFile
                                 + "\n" + e.getMessage();
                         Message.error(errorMsg);
-                        status[0] = new Status(Status.ERROR, IvyPlugin.ID, Status.ERROR, errorMsg,
-                                e);
+                        status[0] = new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
+                                errorMsg, e);
                         return;
                     } finally {
                         Thread.currentThread().setContextClassLoader(old);
@@ -336,12 +363,13 @@
                     .toArray(new ArtifactDownloadReport[all.size()]);
             Set duplicates = new HashSet();
             for (int i = 0; i < reports.length - 1; i++) {
-                if (IvyPlugin.accept(_javaProject, reports[i].getArtifact())) {
+                if (accept(reports[i].getArtifact())) {
                     ModuleRevisionId mrid1 = reports[i].getArtifact().getModuleRevisionId();
                     for (int j = i + 1; j < reports.length; j++) {
-                        if (IvyPlugin.accept(_javaProject, reports[j].getArtifact())) {
+                        if (accept(reports[j].getArtifact())) {
                             ModuleRevisionId mrid2 = reports[j].getArtifact().getModuleRevisionId();
-                            if (mrid1.getModuleId().equals(mrid2.getModuleId()) && !mrid1.getRevision().equals(mrid2.getRevision())) {
+                            if (mrid1.getModuleId().equals(mrid2.getModuleId())
+                                    && !mrid1.getRevision().equals(mrid2.getRevision())) {
                                 duplicates.add(mrid1.getModuleId());
                                 break;
                             }
@@ -351,14 +379,9 @@
             }
             if (!duplicates.isEmpty()) {
                 StringBuffer buffer = new StringBuffer(
-                        "There are some duplicates entries due to conflicts between the resolved configurations (");
-                for (int i = 0; i < _confs.length; i++) {
-                    buffer.append(_confs[i]);
-                    if (i < _confs.length - 1) {
-                        buffer.append(", ");
-                    }
-                }
-                buffer.append("):\n  - ");
+                        "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());
@@ -371,12 +394,11 @@
         }
 
         private void maybeRetrieve(ModuleDescriptor md, String[] confs) throws IOException {
-            // call retrieve if required
-            if (IvyPlugin.shouldDoRetrieve(_javaProject)) {
-                _monitor.setTaskName("retrieving dependencies in "
-                        + IvyPlugin.getFullRetrievePatternHerited(_javaProject));
-                _ivy.retrieve(md.getModuleRevisionId(), IvyPlugin
-                        .getFullRetrievePatternHerited(_javaProject), new RetrieveOptions()
+            if (conf.getInheritedDoRetrieve()) {
+                String pattern = _javaProject.getProject().getLocation().toPortableString() + "/"
+                        + conf.getInheritedRetrievePattern();
+                _monitor.setTaskName("retrieving dependencies in " + pattern);
+                _ivy.retrieve(md.getModuleRevisionId(), pattern, new RetrieveOptions()
                         .setConfs(confs));
             }
         }
@@ -386,15 +408,14 @@
             Collection paths = new LinkedHashSet();
             for (Iterator iter = all.iterator(); iter.hasNext();) {
                 ArtifactDownloadReport artifact = (ArtifactDownloadReport) iter.next();
-                if (artifact.getLocalFile() != null
-                        && IvyPlugin.accept(_javaProject, artifact.getArtifact())) {
+                if (artifact.getLocalFile() != null && accept(artifact.getArtifact())) {
                     Path classpathArtifact = new Path(artifact.getLocalFile().getAbsolutePath());
                     Path sourcesArtifact = getSourcesArtifactPath(artifact, all);
                     Path javadocArtifact = getJavadocArtifactPath(artifact, all);
                     paths.add(JavaCore.newLibraryEntry(classpathArtifact, getSourceAttachment(
                         classpathArtifact, sourcesArtifact), getSourceAttachmentRoot(
-                        classpathArtifact, sourcesArtifact), ClasspathEntry.NO_ACCESS_RULES,
-                        getExtraAttribute(classpathArtifact, javadocArtifact), false));
+                        classpathArtifact, sourcesArtifact), null, getExtraAttribute(
+                        classpathArtifact, javadocArtifact), false));
                 }
             }
             classpathEntries = (IClasspathEntry[]) paths.toArray(new IClasspathEntry[paths.size()]);
@@ -409,13 +430,13 @@
                 ArtifactDownloadReport otherAdr = (ArtifactDownloadReport) iter.next();
                 Artifact a = otherAdr.getArtifact();
                 if (otherAdr.getLocalFile() != null
-                        && IvyPlugin.isSourceArtifactName(_javaProject, artifact.getName(), a.getName())
+                        && isSourceArtifactName(artifact.getName(), a.getName())
                         && a.getId().getRevision().equals(artifact.getId().getRevision())
-                        && IvyPlugin.isSources(_javaProject, a)) {
+                        && isSources(a)) {
                     return new Path(otherAdr.getLocalFile().getAbsolutePath());
                 }
             }
-            if (IvyPlugin.shouldTestNonDeclaredSources(_javaProject)) {
+            if (shouldTestNonDeclaredSources()) {
                 return getMetaArtifactPath(adr, "source", "sources");
             } else {
                 return null;
@@ -429,14 +450,13 @@
                 ArtifactDownloadReport otherAdr = (ArtifactDownloadReport) iter.next();
                 Artifact a = otherAdr.getArtifact();
                 if (otherAdr.getLocalFile() != null
-                        && IvyPlugin.isJavadocArtifactName(_javaProject, artifact.getName(), a.getName())
+                        && isJavadocArtifactName(artifact.getName(), a.getName())
                         && a.getModuleRevisionId().equals(artifact.getModuleRevisionId())
-                        && a.getId().equals(artifact.getId())
-                        && IvyPlugin.isJavadoc(_javaProject, a)) {
+                        && a.getId().equals(artifact.getId()) && isJavadoc(a)) {
                     return new Path(otherAdr.getLocalFile().getAbsolutePath());
                 }
             }
-            if (IvyPlugin.shouldTestNonDeclaredSources(_javaProject)) {
+            if (shouldTestNonDeclaredJavadocs()) {
                 return getMetaArtifactPath(adr, "javadoc", "javadoc");
             } else {
                 return null;
@@ -486,8 +506,8 @@
                 }
             } else {
                 Message.info("checking " + metaType + " for " + artifact);
-                ArtifactDownloadReport metaAdr = _ivy.getResolveEngine()
-                    .download(metaArtifact, new DownloadOptions());
+                ArtifactDownloadReport metaAdr = _ivy.getResolveEngine().download(metaArtifact,
+                    new DownloadOptions());
                 if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) {
                     return new Path(metaAdr.getLocalFile().getAbsolutePath());
                 } else {
@@ -551,14 +571,14 @@
 
     private File _ivyXmlFile;
 
-    private String _ivyXmlPath;
-
-    private String[] _confs = new String[] {"default"};
-
     private IPath _path;
 
     private IvyResolveJob _job;
 
+    IvyClasspathContainerConfiguration conf;
+
+    private String jdtVersion;
+
     /**
      * Create an Ivy class path container from some predefined classpath entries. The provided class
      * path entries should come from the default "persisted" classpath container. Note that no
@@ -568,7 +588,7 @@
      * @param javaProject
      *            the project of containing this container
      * @param path
-     *            the path the project
+     *            the path the container
      * @param ivyFile
      *            the path to the ivy file
      * @param confs
@@ -576,16 +596,29 @@
      * @param classpathEntries
      *            the entries to start with
      */
-    public IvyClasspathContainer(IJavaProject javaProject, IPath path, String ivyFile,
-            String[] confs, IClasspathEntry[] classpathEntries) {
-        _javaProject = javaProject;
+    public IvyClasspathContainer(IJavaProject javaProject, IPath path,
+            IClasspathEntry[] classpathEntries) {
+        this._javaProject = javaProject;
         _path = path;
-
-        _ivyXmlPath = ivyFile;
-        _ivyXmlFile = resolveFile(ivyFile);
-        _confs = confs;
+        conf = new IvyClasspathContainerConfiguration(path);
+        _ivyXmlFile = resolveFile(conf.ivyXmlPath);
         _classpathEntries = classpathEntries;
-        IvyPlugin.getDefault().register(this);
+    }
+
+    public IvyClasspathContainer(IvyClasspathContainer cp) {
+        _javaProject = cp._javaProject;
+        _path = cp._path;
+        conf = cp.conf;
+        _ivyXmlFile = cp._ivyXmlFile;
+        _classpathEntries = cp._classpathEntries;
+    }
+
+    public IvyClasspathContainerConfiguration getConf() {
+        return conf;
+    }
+
+    public IFile getIvyFile() {
+        return _javaProject.getProject().getFile(conf.ivyXmlPath);
     }
 
     private File resolveFile(String path) {
@@ -599,7 +632,7 @@
      * @see org.eclipse.jdt.core.IClasspathContainer#getDescription()
      */
     public String getDescription() {
-        return _ivyXmlPath + " " + Arrays.asList(_confs);
+        return conf.ivyXmlPath + " " + conf.confs;
     }
 
     /*
@@ -647,14 +680,12 @@
     private IvyResolveJob computeClasspathEntries(final boolean usePreviousResolveIfExist,
             boolean notify, boolean isUser) {
         try {
-            Ivy ivy = IvyPlugin.getIvy(_javaProject);
-
             // resolve job already running
             synchronized (this) {
                 if (_job != null) {
                     return _job;
                 }
-                _job = new IvyResolveJob(ivy, usePreviousResolveIfExist, notify);
+                _job = new IvyResolveJob(usePreviousResolveIfExist, notify);
                 _job.setUser(isUser);
                 _job.setRule(RESOLVE_EVENT_RULE);
                 return _job;
@@ -675,18 +706,14 @@
         computeClasspathEntries(false, true, true).run(monitor);
     }
 
-    public void resolve() {
+    public void scheduleResolve() {
         computeClasspathEntries(false, true, true).schedule();
     }
 
-    public void refresh(boolean isUser) {
+    public void scheduleRefresh(boolean isUser) {
         computeClasspathEntries(true, true, isUser).schedule();
     }
 
-    public void refresh() {
-        refresh(true);
-    }
-
     private void updateClasspathEntries(boolean notify, final IClasspathEntry[] classpathEntries) {
         IClasspathEntry[] entries;
         if (classpathEntries != null) {
@@ -700,10 +727,11 @@
     private void setClasspathEntries(final IClasspathEntry[] entries, final boolean notify) {
         Display.getDefault().asyncExec(new Runnable() {
             public void run() {
-                if (IvyPlugin.isAlphaOrder(_javaProject)) {
+                if (conf.isInheritedAlphaOrder()) {
                     Arrays.sort(entries, new Comparator() {
                         public int compare(Object o1, Object o2) {
-                            return ((IClasspathEntry) o1).getPath().lastSegment().compareTo(((IClasspathEntry) o2).getPath().lastSegment());
+                            return ((IClasspathEntry) o1).getPath().lastSegment().compareTo(
+                                ((IClasspathEntry) o2).getPath().lastSegment());
                         }
                     });
                 }
@@ -717,105 +745,80 @@
 
     private void notifyUpdateClasspathEntries() {
         try {
-            JavaModelManager manager = JavaModelManager.getJavaModelManager();
-            manager.containerPut(_javaProject, _path, null);
             JavaCore.setClasspathContainer(_path, new IJavaProject[] {_javaProject},
-                new IClasspathContainer[] {IvyClasspathContainer.this}, null);
+                new IClasspathContainer[] {new IvyClasspathContainer(IvyClasspathContainer.this)},
+                null);
         } catch (JavaModelException e) {
             Message.error(e.getMessage());
         }
     }
 
-    public static String[] getConfigurations(IPath containerPath) {
-        return containerPath.lastSegment().split(",");
+    public URL getReportUrl() {
+        try {
+            Ivy ivy = IvyPlugin.getIvy(_javaProject, conf.getInheritedIvySettingsPath());
+            URL ivyURL = _ivyXmlFile.toURL();
+            ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(
+                ivy.getSettings(), ivyURL, false);
+            String resolveId = ResolveOptions.getDefaultResolveId(md);
+            return ivy.getResolutionCacheManager().getConfigurationResolveReportInCache(resolveId,
+                md.getConfigurationsNames()[0]).toURL();
+        } catch (Exception ex) {
+            return null;
+        }
     }
 
-    public static String getConfigurationsText(IPath containerPath) {
-        return containerPath.lastSegment();
+    public IJavaProject getProject() {
+        return _javaProject;
     }
 
-    public static String getIvyFilePath(IPath containerPath) {
-        return ((IPath) containerPath.clone()).removeFirstSegments(1).removeLastSegments(1)
-                .toString();
+    public boolean shouldTestNonDeclaredSources() {
+        return true; // TODO: add settings for that
     }
 
-    public static boolean isIvyClasspathContainer(IPath containerPath) {
-        return containerPath.segmentCount() >= 3
-                && IvyClasspathContainer.IVY_CLASSPATH_CONTAINER_ID
-                        .equals(containerPath.segment(0));
+    public boolean shouldTestNonDeclaredJavadocs() {
+        return true; // TODO: add settings for that
     }
 
-    /**
-     * Resolves the classpath container corresponding to the given ivy file, if any.
-     * 
-     * @param file
-     */
-    public static void resolveIfNeeded(IFile file) {
-        IJavaProject javaProject = JavaCore.create(file.getProject());
-        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) {
-                    IPath path = entry.getPath();
-                    if (isIvyClasspathContainer(path)
-                            && file.getProjectRelativePath().toString()
-                                    .equals(getIvyFilePath(path))) {
-                        IClasspathContainer cp = JavaCore.getClasspathContainer(path, javaProject);
-
-                        if (cp instanceof IvyClasspathContainer) {
-                            IvyClasspathContainer c = (IvyClasspathContainer) cp;
-                            c.resolve();
-                        }
-                    }
-                }
-            }
-        } catch (JavaModelException e) {
-            Message.error(e.getMessage());
-        }
+    public boolean isJavadocArtifactName(String jar, String javadoc) {
+        return isArtifactName(jar, javadoc, conf.getInheritedJavadocSuffixes());
     }
 
-    public static void resolve(IJavaProject javaProject) {
-        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) {
-                    IPath path = entry.getPath();
-                    if (isIvyClasspathContainer(path)) {
-                        IClasspathContainer cp = JavaCore.getClasspathContainer(path, javaProject);
-
-                        if (cp instanceof IvyClasspathContainer) {
-                            IvyClasspathContainer c = (IvyClasspathContainer) cp;
-                            c.resolve();
-                        }
-                    }
-                }
+    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;
             }
-        } catch (JavaModelException e) {
-            Message.error(e.getMessage());
         }
+        return false;
     }
 
-    public IFile getIvyFile() {
-        return _javaProject.getProject().getFile(_ivyXmlPath);
+    /**
+     * 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 URL getReportUrl() {
-        try {
-            Ivy ivy = IvyPlugin.getIvy(_javaProject);
-            URL ivyURL = _ivyXmlFile.toURL();
-            ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(
-                ivy.getSettings(), ivyURL, false);
-            String resolveId = ResolveOptions.getDefaultResolveId(md);
-            return ivy.getResolutionCacheManager().getConfigurationResolveReportInCache(resolveId,
-                md.getConfigurationsNames()[0]).toURL();
-        } catch (Exception ex) {
-            return null;
-        }
+    public boolean isSources(Artifact artifact) {
+        return conf.getInheritedSourceTypes().contains(artifact.getType());
     }
 
-    public IJavaProject getProject() {
-        return _javaProject;
+    public boolean isJavadoc(Artifact artifact) {
+        return conf.getInheritedJavadocTypes().contains(artifact.getType());
     }
+
 }

Added: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java?rev=640899&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java (added)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java Tue Mar 25 10:08:30 2008
@@ -0,0 +1,339 @@
+/*
+ *  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.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+/**
+ * path:
+ * org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/ivy.xml/conf/ivysetting.xml/acceptedTypes/sourceTypes/javadocTypes/sourceSuffixes/javadocSuffixes/doRetrieve/retrievePattern/order
+ */
+public class IvyClasspathContainerConfiguration {
+
+    String ivyXmlPath;
+
+    List/* <String> */confs = Arrays.asList(new String[] {"default"});
+
+    String ivySettingsPath;
+
+    List/* <String> */acceptedTypes;
+
+    List/* <String> */sourceTypes;
+
+    List/* <String> */javadocTypes;
+
+    List/* <String> */sourceSuffixes;
+
+    List/* <String> */javadocSuffixes;
+
+    boolean doRetrieve;
+
+    String retrievePattern;
+
+    boolean alphaOrder;
+
+    public IvyClasspathContainerConfiguration(String ivyXmlPath, List confs) {
+        this.ivyXmlPath = ivyXmlPath;
+        this.confs = confs;
+    }
+
+    public IvyClasspathContainerConfiguration(IPath path) {
+        if (path.segmentCount() > 2) {
+            loadV0(path);
+        } else {
+            loadV1(path);
+        }
+    }
+
+    /**
+     * Load the pre-IVYDE-70 configuration
+     * 
+     * @param path
+     *            the path of the container
+     */
+    private void loadV0(IPath path) {
+        // load some configuration that can be loaded
+        ivyXmlPath = path.removeFirstSegments(1).removeLastSegments(1).toString();
+        confs = IvyClasspathUtil.split(path.lastSegment());
+        // the last part of the configuration coming from the preferences cannot be loaded due to
+        // the bug described in IVYDE-70, so the configuration is let as the default one
+    }
+
+    /**
+     * Load the post-IVYDE-70 configuration
+     * 
+     * @param path
+     *            the path of the container
+     */
+    private void loadV1(IPath path) {
+        String url = path.segment(1).substring(1);
+        String[] parameters = url.split("&");
+        boolean isProjectSpecific = false;
+        for (int i = 0; i < parameters.length; i++) {
+            String[] parameter = parameters[i].split("=");
+            if (parameter == null || parameter.length == 0) {
+                continue;
+            }
+            String value;
+            try {
+                value = parameter.length > 1 ? URLDecoder.decode(parameter[1], "UTF-8") : "";
+            } catch (UnsupportedEncodingException e) {
+                // TODO this should not happend, but if it happend it can break eclipse, a project
+                // can be displayed abnormally. This exception should be raised at the UI level,
+                // either in the error log or in an popup to the user
+                throw new RuntimeException(e);
+            }
+            if (parameter[0].equals("ivyXmlPath")) {
+                ivyXmlPath = value;
+            } else if (parameter[0].equals("confs")) {
+                confs = IvyClasspathUtil.split(value);
+            } else if (parameter[0].equals("ivySettingsPath")) {
+                ivySettingsPath = value;
+                isProjectSpecific = true;
+            } else if (parameter[0].equals("acceptedTypes")) {
+                acceptedTypes = IvyClasspathUtil.split(value);
+                isProjectSpecific = true;
+            } else if (parameter[0].equals("sourceTypes")) {
+                sourceTypes = IvyClasspathUtil.split(value);
+                isProjectSpecific = true;
+            } else if (parameter[0].equals("javadocTypes")) {
+                javadocTypes = IvyClasspathUtil.split(value);
+                isProjectSpecific = true;
+            } else if (parameter[0].equals("sourceSuffixes")) {
+                sourceSuffixes = IvyClasspathUtil.split(value);
+                isProjectSpecific = true;
+            } else if (parameter[0].equals("javadocSuffixes")) {
+                javadocSuffixes = IvyClasspathUtil.split(value);
+                isProjectSpecific = true;
+            } else if (parameter[0].equals("doRetrieve")) {
+                // if the value is not actually "true" or "false", the Boolean class ensure to
+                // return false, so it is fine
+                doRetrieve = Boolean.valueOf(value).booleanValue();
+                isProjectSpecific = true;
+            } else if (parameter[0].equals("retrievePattern")) {
+                retrievePattern = value;
+                isProjectSpecific = true;
+            } else if (parameter[0].equals("alphaOrder")) {
+                // if the value is not actually "true" or "false", the Boolean class ensure to
+                // return false, so it is fine
+                alphaOrder = Boolean.valueOf(value).booleanValue();
+                isProjectSpecific = true;
+            }
+        }
+        if (isProjectSpecific) {
+            // in this V1 version, it is just some paranoïd check
+            checkNonNullConf();
+        }
+    }
+
+    private void checkNonNullConf() {
+        if (ivySettingsPath == null) {
+            ivySettingsPath = IvyPlugin.getPreferenceStoreHelper().getIvySettingsPath();
+        }
+        if (acceptedTypes == null) {
+            acceptedTypes = IvyPlugin.getPreferenceStoreHelper().getAcceptedTypes();
+        }
+        if (sourceTypes == null) {
+            sourceTypes = IvyPlugin.getPreferenceStoreHelper().getSourceTypes();
+        }
+        if (javadocTypes == null) {
+            javadocTypes = IvyPlugin.getPreferenceStoreHelper().getJavadocTypes();
+        }
+        if (sourceSuffixes == null) {
+            sourceSuffixes = IvyPlugin.getPreferenceStoreHelper().getSourceSuffixes();
+        }
+        if (javadocSuffixes == null) {
+            javadocSuffixes = IvyPlugin.getPreferenceStoreHelper().getJavadocSuffixes();
+        }
+        if (retrievePattern == null) {
+            retrievePattern = IvyPlugin.getPreferenceStoreHelper().getRetrievePattern();
+        }
+    }
+
+    public IPath getPath() {
+        StringBuffer path = new StringBuffer();
+        path.append('?');
+        path.append("ivyXmlPath=");
+        try {
+            path.append(URLEncoder.encode(ivyXmlPath, "UTF-8"));
+            path.append("&confs=");
+            path.append(URLEncoder.encode(IvyClasspathUtil.concat(confs), "UTF-8"));
+            if (ivySettingsPath != null) {
+                path.append("&ivySettingsPath=");
+                path.append(URLEncoder.encode(ivySettingsPath, "UTF-8"));
+                path.append("&acceptedTypes=");
+                path.append(URLEncoder.encode(IvyClasspathUtil.concat(acceptedTypes), "UTF-8"));
+                path.append("&sourceTypes=");
+                path.append(URLEncoder.encode(IvyClasspathUtil.concat(sourceTypes), "UTF-8"));
+                path.append("&javadocTypes=");
+                path.append(URLEncoder.encode(IvyClasspathUtil.concat(javadocTypes), "UTF-8"));
+                path.append("&sourceSuffixes=");
+                path.append(URLEncoder.encode(IvyClasspathUtil.concat(sourceSuffixes), "UTF-8"));
+                path.append("&javadocSuffixes=");
+                path.append(URLEncoder.encode(IvyClasspathUtil.concat(javadocSuffixes), "UTF-8"));
+                path.append("&doRetrieve=");
+                path.append(URLEncoder.encode(Boolean.toString(doRetrieve), "UTF-8"));
+                path.append("&retrievePattern=");
+                path.append(URLEncoder.encode(retrievePattern, "UTF-8"));
+                path.append("&alphaOrder=");
+                path.append(URLEncoder.encode(Boolean.toString(alphaOrder), "UTF-8"));
+            }
+        } catch (UnsupportedEncodingException e) {
+            // TODO this should not happend, but if it happend it can break eclipse, a project
+            // can be displayed abnormally. This exception should be raised at the UI level,
+            // either in the error log or in an popup to the user
+            throw new RuntimeException(e);
+        }
+        return new Path(IvyClasspathContainer.IVY_CLASSPATH_CONTAINER_ID).append(path.toString());
+    }
+
+    public String getInheritedIvySettingsPath() {
+        if (ivySettingsPath == null) {
+            return IvyPlugin.getPreferenceStoreHelper().getIvySettingsPath();
+        }
+        return ivySettingsPath;
+    }
+
+    public Collection getInheritedAcceptedTypes() {
+        if (ivySettingsPath == null) {
+            return IvyPlugin.getPreferenceStoreHelper().getAcceptedTypes();
+        }
+        return acceptedTypes;
+    }
+
+    public Collection getInheritedSourceTypes() {
+        if (ivySettingsPath == null) {
+            return IvyPlugin.getPreferenceStoreHelper().getSourceTypes();
+        }
+        return sourceTypes;
+    }
+
+    public Collection getInheritedSourceSuffixes() {
+        if (ivySettingsPath == null) {
+            return IvyPlugin.getPreferenceStoreHelper().getSourceSuffixes();
+        }
+        return sourceSuffixes;
+    }
+
+    public Collection getInheritedJavadocTypes() {
+        if (ivySettingsPath == null) {
+            return IvyPlugin.getPreferenceStoreHelper().getJavadocTypes();
+        }
+        return javadocTypes;
+    }
+
+    public Collection getInheritedJavadocSuffixes() {
+        if (ivySettingsPath == null) {
+            return IvyPlugin.getPreferenceStoreHelper().getJavadocSuffixes();
+        }
+        return javadocSuffixes;
+    }
+
+    public boolean getInheritedDoRetrieve() {
+        if (ivySettingsPath == null) {
+            return IvyPlugin.getPreferenceStoreHelper().getDoRetrieve();
+        }
+        return doRetrieve;
+    }
+
+    public String getInheritedRetrievePattern() {
+        if (ivySettingsPath == null) {
+            return IvyPlugin.getPreferenceStoreHelper().getRetrievePattern();
+        }
+        return retrievePattern;
+    }
+
+    public boolean isInheritedAlphaOrder() {
+        if (ivySettingsPath == null) {
+            return IvyPlugin.getPreferenceStoreHelper().isAlphOrder();
+        }
+        return alphaOrder;
+    }
+
+    public List getAcceptedTypes() {
+        return acceptedTypes;
+    }
+
+    public List getConfs() {
+        return confs;
+    }
+
+    public boolean getDoRetrieve() {
+        return doRetrieve;
+    }
+
+    public String getIvySettingsPath() {
+        return ivySettingsPath;
+    }
+
+    public String getIvyXmlPath() {
+        return ivyXmlPath;
+    }
+
+    public List getJavadocSuffixes() {
+        return javadocSuffixes;
+    }
+
+    public List getJavadocTypes() {
+        return javadocTypes;
+    }
+
+    public boolean isAlphaOrder() {
+        return alphaOrder;
+    }
+
+    public String getRetrievePattern() {
+        return retrievePattern;
+    }
+
+    public List getSourceSuffixes() {
+        return sourceSuffixes;
+    }
+
+    public List getSourceTypes() {
+        return sourceTypes;
+    }
+
+    public boolean isProjectSpecific() {
+        return ivySettingsPath != null;
+    }
+
+    private String getInheritablePreferenceString(String value) {
+        if (value == null || value.startsWith("[inherited]")) {
+            return null;
+        }
+        return value;
+    }
+
+    private List getInheritablePreferenceList(String values) {
+        if (values == null || values.startsWith("[inherited]")) {
+            return null;
+        }
+        return IvyClasspathUtil.split(values);
+    }
+
+}

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

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

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

Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathEntry.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathEntry.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathEntry.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathEntry.java Tue Mar 25 10:08:30 2008
@@ -1,72 +0,0 @@
-package org.apache.ivyde.eclipse.cpcontainer;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IAccessRule;
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-
-public class IvyClasspathEntry implements IClasspathEntry {
-
-    Path path_;
-
-    IvyClasspathEntry(Path path) {
-        path_ = path;
-    }
-
-    public int getContentKind() {
-        return IPackageFragmentRoot.K_BINARY;
-    }
-
-    public int getEntryKind() {
-        return CPE_LIBRARY;
-    }
-
-    public IPath[] getExclusionPatterns() {
-        return null;
-    }
-
-    public IPath[] getInclusionPatterns() {
-        return null;
-    }
-
-    public IPath getOutputLocation() {
-        return null;
-    }
-
-    public IPath getPath() {
-        return path_;
-    }
-
-    public IClasspathEntry getResolvedEntry() {
-        return this;
-    }
-
-    public IPath getSourceAttachmentPath() {
-        return null;
-    }
-
-    public IPath getSourceAttachmentRootPath() {
-        return null;
-    }
-
-    public boolean isExported() {
-        return false;
-    }
-
-    public boolean combineAccessRules() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    public IAccessRule[] getAccessRules() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public IClasspathAttribute[] getExtraAttributes() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-}

Modified: ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java?rev=640899&r1=640898&r2=640899&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java (original)
+++ ant/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java Tue Mar 25 10:08:30 2008
@@ -1,3 +1,20 @@
+/*
+ *  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.util.Message;
@@ -26,9 +43,7 @@
      * refresh
      */
     public void initialize(IPath containerPath, IJavaProject project) throws CoreException {
-        if (IvyClasspathContainer.isIvyClasspathContainer(containerPath)) {
-            String ivyFilePath = IvyClasspathContainer.getIvyFilePath(containerPath);
-            String[] confs = IvyClasspathContainer.getConfigurations(containerPath);
+        if (IvyClasspathUtil.isIvyClasspathContainer(containerPath)) {
 
             // try to get an existing one
             IClasspathContainer container = null;
@@ -41,12 +56,12 @@
             }
 
             if (container == null) {
-                container = new IvyClasspathContainer(project, containerPath, ivyFilePath, confs,
+                container = new IvyClasspathContainer(project, containerPath,
                         new IClasspathEntry[0]);
             } else if (!(container instanceof IvyClasspathContainer)) {
                 // this might be the persisted one : reuse the persisted entries
-                container = new IvyClasspathContainer(project, containerPath, ivyFilePath, confs,
-                        container.getClasspathEntries());
+                container = new IvyClasspathContainer(project, containerPath, container
+                        .getClasspathEntries());
             }
 
             try {
@@ -58,7 +73,7 @@
             }
 
             // now refresh the container to be synchronized with the ivy.xml
-            ((IvyClasspathContainer) container).refresh(false);
+            ((IvyClasspathContainer) container).scheduleRefresh(false);
         }
     }
 
@@ -78,7 +93,7 @@
      */
     public void requestClasspathContainerUpdate(IPath containerPath, final IJavaProject project,
             IClasspathContainer containerSuggestion) throws CoreException {
-        if (IvyClasspathContainer.isIvyClasspathContainer(containerPath)) {
+        if (IvyClasspathUtil.isIvyClasspathContainer(containerPath)) {
             IClasspathEntry ice[] = containerSuggestion.getClasspathEntries();
             IPackageFragmentExtraInfo ei = IvyPlugin.getDefault().getPackageFragmentExtraInfo();
             for (int i = 0; i < ice.length; i++) {
@@ -101,7 +116,7 @@
                         return;
                     }
                     if (ivycp != null) {
-                        ivycp.refresh();
+                        ivycp.scheduleRefresh(true);
                     }
                 }
             });