ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r685245 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse: ./ cpcontainer/ ui/editors/xml/ ui/views/
Date Tue, 12 Aug 2008 17:57:04 GMT
Author: hibou
Date: Tue Aug 12 10:57:03 2008
New Revision: 685245

URL: http://svn.apache.org/viewvc?rev=685245&view=rev
Log:
IVYDE-112:
 - Change the way the Ivy instance are managed: no more shared between projects, but maintained
close to the container
 - the propagation or errors is now done via an exception to have better control on when and
how to display errors

Added:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java
  (with props)
Modified:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/editors/xml/EclipseIvyModelSettings.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/views/ReportView.java

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java?rev=685245&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java
(added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java
Tue Aug 12 10:57:03 2008
@@ -0,0 +1,105 @@
+/*
+ *  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 org.apache.ivy.util.Message;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.MessageDialog;
+
+/**
+ * Exception that will be displayed somehow to the end user.
+ * 
+ * Once catched, depending of the context the error could be popuped or just logged
+ * 
+ */
+public class IvyDEException extends Exception {
+
+    public IvyDEException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+
+    /**
+     * Create a popup window to display the exception to the end user.
+     * 
+     * @param status
+     *            the status of the exception (error, waring or info)
+     * @param title
+     *            the title of the window
+     * @param preMsg
+     *            the message to display before the actual exception message
+     */
+    public void show(final int status, final String title, String preMsg) {
+        final String msg = (preMsg == null ? "" : preMsg + "\n\n")
+                + getMessage()
+                + (getCause() == null ? "" : "\n\nUnderlying error ("
+                        + getCause().getClass().getCanonicalName() + "): "
+                        + getCause().getMessage());
+        IvyPlugin.getDefault().getWorkbench().getDisplay().syncExec(new Runnable() {
+            public void run() {
+                switch (status) {
+                    case IStatus.ERROR:
+                        MessageDialog.openError(IvyPlugin.getActiveWorkbenchShell(), title,
msg);
+                        return;
+                    case IStatus.WARNING:
+                        MessageDialog.openWarning(IvyPlugin.getActiveWorkbenchShell(), title,
msg);
+                        return;
+                    case IStatus.INFO:
+                        MessageDialog.openInformation(IvyPlugin.getActiveWorkbenchShell(),
title,
+                            msg);
+                        return;
+                }
+            }
+        });
+    }
+
+    /**
+     * Log the exception in Eclipse log system.
+     * 
+     * @param status
+     *            the status of the exception (error, waring or info)
+     * @param preMsg
+     *            the message to display before the actual error message
+     */
+    public void log(int status, String preMsg) {
+        String msg = (preMsg == null ? "" : preMsg) + getMessage();
+        IvyPlugin.log(status, msg, getCause());
+    }
+
+    /**
+     * Show the exception in the Ivy console
+     * 
+     * @param status
+     *            the status of the exception (error, waring or info)
+     * @param preMsg
+     *            the message to display before the actual error message
+     */
+    public void print(int status, String preMsg) {
+        String msg = (preMsg == null ? "" : preMsg) + getMessage();
+        switch (status) {
+            case IStatus.ERROR:
+                Message.error("IVYDE: " + msg);
+                return;
+            case IStatus.WARNING:
+                Message.warn("IVYDE: " + msg);
+                return;
+            case IStatus.INFO:
+                Message.info("IVYDE: " + msg);
+                return;
+        }
+    }
+}

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

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

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

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=685245&r1=685244&r2=685245&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
Tue Aug 12 10:57:03 2008
@@ -17,20 +17,11 @@
  */
 package org.apache.ivyde.eclipse;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URL;
-import java.text.ParseException;
 import java.util.Collections;
 import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
-import org.apache.ivy.Ivy;
-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;
@@ -270,14 +261,6 @@
         return AbstractUIPlugin.imageDescriptorFromPlugin(ID, path);
     }
 
-    private static class IvyConfig {
-        Ivy ivy;
-
-        long configTime = -1;
-    }
-
-    private Map/* <String, IvyConfig> */ivyBySettings = new HashMap();
-
     private PreferenceStoreInfo _packageExtraInfo;
 
     /**
@@ -287,128 +270,6 @@
         return plugin.prefStoreHelper;
     }
 
-    /**
-     * Get the Ivy instance for the specified project.
-     * 
-     * @param javaProject
-     *            the Java project
-     * @return the configured Ivy instance, <code>null</code> if there is no
Ivy for this project
-     * @throws IOException
-     * @throws ParseException
-     * @throws FileNotFoundException
-     */
-    public static synchronized Ivy getIvy(IJavaProject javaProject) {
-        IvyClasspathContainer cp = IvyClasspathUtil.getIvyClasspathContainer(javaProject);
-        if (cp == null) {
-            return null;
-        }
-        return getIvy(cp.getConf().getInheritedIvySettingsPath());
-    }
-
-    /**
-     * Get the Ivy instance for the specified project and the specified settings
-     * <p>
-     * 
-     * @param ivySettingsPath
-     *            the settings to use
-     * @return the configured Ivy instance, <code>null</code> if it failed
-     */
-    public static synchronized Ivy getIvy(String ivySettingsPath) {
-        IvyConfig ic;
-        try {
-            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());
-
-                if (!file.exists()) {
-                    MessageDialog
-                            .openWarning(
-                                getActiveWorkbenchShell(),
-                                "No ivy settings found",
-                                ivySettingsPath
-                                        + " ivy settings 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.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 {
-                // an URL but not a file
-                if (ic.ivy == null) {
-                    ic.ivy = new Ivy();
-                    ic.ivy.configure(url);
-                }
-            }
-            return ic.ivy;
-        } catch (Throwable e) {
-            // catching Throwable in case of class path errors, some NoClassDefFoundError
can be
-            // raised (IVYDE-85)
-            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");
-            plugin.ivyBySettings.remove(ivySettingsPath);
-            return null;
-        }
-    }
-
-    private static Ivy getDefaultIvy() {
-        IvyConfig ic = (IvyConfig) plugin.ivyBySettings.get(null);
-        if (ic == null) {
-            ic = new IvyConfig();
-            ic.ivy = new Ivy();
-            try {
-                ic.ivy.configureDefault();
-                plugin.ivyBySettings.put(null, ic);
-            } catch (Exception ex) {
-                MessageDialog
-                        .openWarning(
-                            getActiveWorkbenchShell(),
-                            "Impossible to configure Ivy",
-                            "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 ic.ivy;
-    }
-
     public IvyConsole getConsole() {
         return console;
     }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java?rev=685245&r1=685244&r2=685245&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
Tue Aug 12 10:57:03 2008
@@ -29,6 +29,7 @@
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.resolve.ResolveOptions;
 import org.apache.ivy.util.Message;
+import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.IPath;
@@ -47,6 +48,7 @@
 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.jface.dialogs.MessageDialog;
 import org.eclipse.swt.widgets.Display;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
@@ -182,11 +184,11 @@
                     // resolve job already running
                     return job;
                 }
-                Ivy ivy = IvyPlugin.getIvy(conf.getInheritedIvySettingsPath());
+                Ivy ivy = conf.getIvy();
                 if (ivy == null) {
                     return null;
                 }
-                ModuleDescriptor md = conf.getModuleDescriptor(ivy);
+                ModuleDescriptor md = conf.getModuleDescriptor();
                 if (md == null) {
                     return null;
                 }
@@ -195,10 +197,17 @@
                 job.setRule(RESOLVE_EVENT_RULE);
                 return job;
             }
+        } catch (IvyDEException e) {
+            e.print(IStatus.ERROR, "The resolve job could not be lauched: ");
+            e.log(IStatus.ERROR, "The resolve job could not be lauched: ");
+            e.show(IStatus.ERROR, "Resolve failed", "The resolve job could not be lauched:
");
+            return null;
         } catch (Throwable e) {
-            // IVYDE-79 : catch Throwable in order to catch java.lang.NoClassDefFoundError
too 
+            // IVYDE-79 : catch Throwable in order to catch java.lang.NoClassDefFoundError
too
             Message.error(e.getMessage());
             IvyPlugin.log(IStatus.ERROR, "The creation of the job failed", e);
+            MessageDialog.openError(IvyPlugin.getActiveWorkbenchShell(), "Resolve failed",
e
+                    .getMessage());
             return null;
         }
     }
@@ -266,7 +275,8 @@
                 null);
 
             // the following code was imported from:
-            // http://svn.codehaus.org/m2eclipse/trunk/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/BuildPathManager.java
+            //http://svn.codehaus.org/m2eclipse/trunk/org.maven.ide.eclipse/src/org/maven/ide/eclipse
+            // /embedder/BuildPathManager.java
             // revision: 370; function setClasspathContainer; line 215
 
             // XXX In Eclipse 3.3, changes to resolved classpath are not announced by JDT
Core
@@ -311,23 +321,16 @@
         return jdtVersion;
     }
 
-    public URL getReportUrl() {
-        Ivy ivy = IvyPlugin.getIvy(conf.getInheritedIvySettingsPath());
-        if (ivy == null) {
-            return null;
-        }
-        ModuleDescriptor md = conf.getModuleDescriptorSafely(ivy);
-        if (md == null) {
-            return null;
-        }
+    public URL getReportUrl() throws IvyDEException {
+        Ivy ivy = conf.getIvy();
+        ModuleDescriptor md = conf.getModuleDescriptor();
         String resolveId = ResolveOptions.getDefaultResolveId(md);
         try {
             return ivy.getResolutionCacheManager().getConfigurationResolveReportInCache(resolveId,
                 md.getConfigurationsNames()[0]).toURL();
         } catch (MalformedURLException e) {
             // should never happen
-            IvyPlugin.log(IStatus.ERROR, "The URL generated by Ivy is incorrect", e);
-            return null;
+            throw new RuntimeException(e);
         }
     }
 

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java?rev=685245&r1=685244&r2=685245&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java
Tue Aug 12 10:57:03 2008
@@ -32,6 +32,8 @@
 import org.apache.ivy.Ivy;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
+import org.apache.ivy.util.Message;
+import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
@@ -39,7 +41,6 @@
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jface.dialogs.MessageDialog;
 
 /**
  * path: org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER? ivyXmlPath=ivy.xml &confs=default
@@ -78,12 +79,15 @@
 
     boolean resolveInWorkspace;
 
+    private Ivy ivy;
+
+    private long ivySettingsLastModified = -1;
+
     /**
      * Constructor
      * 
      * @param javaProject
-     *            the classpath container's Java project, <code>null</code> is
not bind to a
-     *            project
+     *            the classpath container's Java project, <code>null</code> is
not bind to a project
      * @param ivyXmlPath
      *            the path to the ivy.xml
      */
@@ -96,8 +100,7 @@
      * Constructor
      * 
      * @param javaProject
-     *            the classpath container's Java project, <code>null</code> is
not bind to a
-     *            project
+     *            the classpath container's Java project, <code>null</code> is
not bind to a project
      * @param path
      *            the path of the classpath container
      */
@@ -110,6 +113,12 @@
         }
     }
 
+    public String toString() {
+        return (javaProject == null ? "" : "project '" + javaProject.getElementName()
+                + "' and ivy file '")
+                + ivyXmlPath + (javaProject == null ? "" : "'");
+    }
+
     /**
      * Load the pre-IVYDE-70 configuration
      * 
@@ -269,6 +278,78 @@
         return javaProject;
     }
 
+    public Ivy getIvy() throws IvyDEException {
+        String ivySettingsPath = getInheritedIvySettingsPath();
+        if (ivySettingsPath == null || ivySettingsPath.trim().length() == 0) {
+            // no settings specified, so take the default one
+            if (ivy == null) {
+                ivy = new Ivy();
+                try {
+                    ivy.configureDefault();
+                } catch (ParseException e) {
+                    throw new IvyDEException("The default ivy settings file could not be
parsed ("
+                            + this.toString() + ")", e);
+                } catch (IOException e) {
+                    throw new IvyDEException("The default ivy settings file could not be
read ("
+                            + this.toString() + ")", e);
+                }
+            }
+            return ivy;
+        }
+
+        // before returning the found ivy, try to refresh it if the settings changed
+        URL url;
+        try {
+            url = new URL(ivySettingsPath);
+        } catch (MalformedURLException e) {
+            throw new IvyDEException("The ivy settings url '" + ivySettingsPath
+                    + "' is incorrect (" + this.toString() + ")", e);
+        }
+        if (url.getProtocol().startsWith("file")) {
+            File file = new File(url.getPath());
+
+            if (!file.exists()) {
+                throw new IvyDEException("The ivy settings file '" + ivySettingsPath
+                        + "' cannot be found (" + this.toString() + ")", null);
+            }
+
+            if (file.lastModified() != ivySettingsLastModified) {
+                ivy = new Ivy();
+                if (ivySettingsLastModified == -1) {
+                    Message.info("\n\n");
+                } else {
+                    Message.info("\n\nIVYDE: ivysettings has changed, configuring ivy again\n");
+                }
+                try {
+                    ivy.configure(file);
+                } catch (ParseException e) {
+                    throw new IvyDEException("The ivy settings file '" + ivySettingsPath
+                            + "' could not be parsed (" + this.toString() + ")", e);
+                } catch (IOException e) {
+                    throw new IvyDEException("The ivy settings file '" + ivySettingsPath
+                            + "' could not be read (" + this.toString() + ")", e);
+                }
+                ivySettingsLastModified = file.lastModified();
+            }
+
+        } else {
+            // an URL but not a file
+            if (ivy == null) {
+                ivy = new Ivy();
+                try {
+                    ivy.configure(url);
+                } catch (ParseException e) {
+                    throw new IvyDEException("The ivy settings file '" + ivySettingsPath
+                            + "' could not be parsed (" + this.toString() + ")", e);
+                } catch (IOException e) {
+                    throw new IvyDEException("The ivy settings file '" + ivySettingsPath
+                            + "' could not be read (" + this.toString() + ")", e);
+                }
+            }
+        }
+        return ivy;
+    }
+
     public String getInheritedIvySettingsPath() {
         if (ivySettingsPath == null) {
             return IvyPlugin.getPreferenceStoreHelper().getIvySettingsPath();
@@ -375,20 +456,6 @@
         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);
-    }
-
     File getIvyFile() {
         File file;
         if (javaProject != null) {
@@ -400,37 +467,25 @@
         return file;
     }
 
-    public ModuleDescriptor getModuleDescriptorSafely(Ivy ivy) {
+    public ModuleDescriptor getModuleDescriptor() throws IvyDEException {
         File file = getIvyFile();
         try {
-            return getModuleDescriptor(ivy);
+            Ivy i = getIvy();
+            if (i == null) {
+                return null;
+            }
+            return ModuleDescriptorParserRegistry.getInstance().parseDescriptor(i.getSettings(),
+                file.toURL(), false);
         } catch (MalformedURLException e) {
-            MessageDialog.openWarning(IvyPlugin.getActiveWorkbenchShell(), "Incorrect path",
-                "The path to the ivy.xml file is incorrect: '" + file.getAbsolutePath()
-                        + "'. \nError:" + e.getMessage());
-            return null;
+            throw new IvyDEException("The path to the ivy.xml file is incorrect: '"
+                    + file.getAbsolutePath() + "' (" + this.toString() + ")", e);
         } catch (ParseException e) {
-            MessageDialog.openWarning(IvyPlugin.getActiveWorkbenchShell(), "Incorrect ivy
file",
-                "The ivy file '" + file.getAbsolutePath() + "' could not be parsed. \nError:"
-                        + e.getMessage());
-            return null;
+            throw new IvyDEException("The ivy file '" + file.getAbsolutePath()
+                    + "' could not be parsed (" + this.toString() + ")", e);
         } catch (IOException e) {
-            MessageDialog.openWarning(IvyPlugin.getActiveWorkbenchShell(), "Read error",
-                "The ivy file '" + file.getAbsolutePath() + "' could not be read. \nError:"
-                        + e.getMessage());
-            return null;
+            throw new IvyDEException("The ivy file '" + file.getAbsolutePath()
+                    + "' could not be read (" + this.toString() + ")", e);
         }
     }
 
-    public ModuleDescriptor getModuleDescriptor(Ivy ivy) throws MalformedURLException,
-            ParseException, IOException {
-        return getModuleDescriptor(ivy, getIvyFile());
-    }
-
-    public ModuleDescriptor getModuleDescriptor(Ivy ivy, File ivyFile)
-            throws MalformedURLException, ParseException, IOException {
-        return ModuleDescriptorParserRegistry.getInstance().parseDescriptor(ivy.getSettings(),
-            ivyFile.toURL(), false);
-    }
-
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java?rev=685245&r1=685244&r2=685245&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
Tue Aug 12 10:57:03 2008
@@ -59,6 +59,7 @@
 import org.apache.ivy.plugins.repository.TransferEvent;
 import org.apache.ivy.plugins.repository.TransferListener;
 import org.apache.ivy.util.Message;
+import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IPath;
@@ -475,13 +476,11 @@
             return null;
         }
         try {
-            return cp.getConf().getModuleDescriptor(ivy);
-        } catch (MalformedURLException e) {
-            IvyPlugin.log(IStatus.WARNING, "The path of the ivy.xml of the project " + javaProject
+ " is not a valid URL", e);
-        } catch (ParseException e) {
-            IvyPlugin.log(IStatus.WARNING, "The ivy.xml of the project " + javaProject +
" has a syntax error: ", e);
-        } catch (IOException e) {
-            IvyPlugin.log(IStatus.WARNING, "The ivy.xml of the project " + javaProject +
" could not be read: ", e);
+            return cp.getConf().getModuleDescriptor();
+        } catch (IvyDEException e) {
+            e.log(IStatus.WARNING, "IvyDE could not found out if the project "
+                    + javaProject.getElementName() + " should be included in " + conf
+                    + " classpath: ");
         }
         return null;
     }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java?rev=685245&r1=685244&r2=685245&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
Tue Aug 12 10:57:03 2008
@@ -18,16 +18,14 @@
 package org.apache.ivyde.eclipse.cpcontainer;
 
 import java.io.File;
-import java.io.IOException;
 import java.net.MalformedURLException;
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import org.apache.ivy.Ivy;
 import org.apache.ivy.core.module.descriptor.Configuration;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.ui.preferences.IvyDEPreferenceStoreHelper;
 import org.apache.ivyde.eclipse.ui.preferences.IvyPreferencePage;
@@ -119,8 +117,6 @@
 
     private IClasspathEntry entry;
 
-    private String ivyXmlError;
-
     private ModuleDescriptor md;
 
     private Button retrieveSyncButton;
@@ -137,11 +133,6 @@
         String error;
         if (ivyFilePathText.getText().length() == 0) {
             error = "Choose an ivy file";
-        } else if (ivyXmlError != null) {
-            error = ivyXmlError;
-        } else if (confTableViewer.getCheckedElements().length == 0 && md != null
-                && md.getConfigurations().length != 0) {
-            error = "Choose at least one configuration";
         } else {
             error = null;
         }
@@ -167,15 +158,6 @@
             conf.ivySettingsPath = null;
         }
         entry = JavaCore.newContainerEntry(conf.getPath());
-        try {
-            IClasspathContainer cp = JavaCore.getClasspathContainer(entry.getPath(), project);
-            if (cp instanceof IvyClasspathContainer) {
-                ((IvyClasspathContainer) cp).scheduleResolve();
-            }
-        } catch (JavaModelException e) {
-            // unless there are issues with the JDT, this should never happen
-            IvyPlugin.log(e);
-        }
         return true;
     }
 
@@ -240,8 +222,6 @@
         ivyFilePathText.addModifyListener(new ModifyListener() {
             public void modifyText(ModifyEvent e) {
                 conf.ivyXmlPath = ivyFilePathText.getText();
-                resolveModuleDescriptor();
-                refreshConfigurationTable();
                 checkCompleted();
             }
         });
@@ -295,8 +275,6 @@
                 if (path != null) {
                     conf.ivyXmlPath = path;
                     ivyFilePathText.setText(path);
-                    resolveModuleDescriptor();
-                    refreshConfigurationTable();
                     checkCompleted();
                 }
             }
@@ -321,7 +299,6 @@
             new GridData(GridData.FILL, GridData.FILL, true, true));
         confTableViewer.setContentProvider(new IStructuredContentProvider() {
             public Object[] getElements(Object inputElement) {
-                resolveModuleDescriptor();
                 if (md != null) {
                     return md.getConfigurations();
                 }
@@ -347,7 +324,13 @@
         Button refreshConf = new Button(composite, SWT.NONE);
         refreshConf.setText("Refresh");
         refreshConf.addSelectionListener(new SelectionAdapter() {
-            public void widgetSelected(SelectionEvent e) {
+            public void widgetSelected(SelectionEvent ev) {
+                try {
+                    md = conf.getModuleDescriptor();
+                } catch (IvyDEException e) {
+                    e.show(IStatus.ERROR, "Configuration error",
+                        "The configurations of the ivy.xml could not be retrieved: ");
+                }
                 confTableViewer.setInput(ivyFilePathText.getText());
             }
         });
@@ -501,7 +484,8 @@
 
         retrieveSyncButton = new Button(configComposite, SWT.CHECK);
         retrieveSyncButton.setText("Delete old retrieved artifacts");
-        retrieveSyncButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false,
false, 2, 1));
+        retrieveSyncButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false,
false,
+                2, 1));
         retrieveSyncButton.setEnabled(doRetrieveButton.getSelection());
 
         doRetrieveButton.addSelectionListener(new SelectionAdapter() {
@@ -531,7 +515,12 @@
     private void loadFromConf() {
         ivyFilePathText.setText(conf.ivyXmlPath);
 
-        resolveModuleDescriptor();
+        try {
+            md = conf.getModuleDescriptor();
+        } catch (IvyDEException e) {
+            e.log(IStatus.WARNING, "Failed to resolve the module descriptor "
+                    + "while entering in the configuration panel");
+        }
 
         confTableViewer.setInput(conf.ivyXmlPath);
         initTableSelection();
@@ -601,25 +590,6 @@
         return null;
     }
 
-    void resolveModuleDescriptor() {
-        ivyXmlError = null;
-        md = null;
-        Ivy ivy = IvyPlugin.getIvy(conf.getInheritedIvySettingsPath());
-        if (ivy == null) {
-            ivyXmlError = "Error while confiuraing Ivy";
-            return;
-        }
-        try {
-            md = conf.getModuleDescriptor(ivy);
-        } catch (MalformedURLException e) {
-            ivyXmlError = "The path of the ivy.xml is not a valid URL";
-        } catch (ParseException e) {
-            ivyXmlError = "The ivy.xml has a syntax error: " + e.getMessage();
-        } catch (IOException e) {
-            ivyXmlError = "The ivy.xml could not be read: " + e.getMessage();
-        }
-    }
-
     /**
      * @param ivyFile
      */

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/editors/xml/EclipseIvyModelSettings.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/editors/xml/EclipseIvyModelSettings.java?rev=685245&r1=685244&r2=685245&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/editors/xml/EclipseIvyModelSettings.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/editors/xml/EclipseIvyModelSettings.java
Tue Aug 12 10:57:03 2008
@@ -19,17 +19,23 @@
 
 import org.apache.ivy.Ivy;
 import org.apache.ivyde.common.model.IvyModelSettings;
+import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
 import org.apache.ivyde.eclipse.ui.preferences.PreferenceConstants;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jdt.core.IJavaProject;
 
 public class EclipseIvyModelSettings implements IvyModelSettings {
     
     private IJavaProject javaProject;
+    private IvyClasspathContainer cp;
     
     public EclipseIvyModelSettings(IJavaProject javaProject) {
         this.javaProject = javaProject;
+        cp = IvyClasspathUtil.getIvyClasspathContainer(javaProject);
     }
 
     public String getDefaultOrganization() {
@@ -43,7 +49,12 @@
     }
 
     public Ivy getIvyInstance() {
-        return IvyPlugin.getIvy(javaProject);
+        try {
+            return cp.getConf().getIvy();
+        } catch (IvyDEException e) {
+            e.log(IStatus.WARNING, null);
+            return null;
+        }
     }
 
     public void logError(String message, Exception e) {

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/views/ReportView.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/views/ReportView.java?rev=685245&r1=685244&r2=685245&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/views/ReportView.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/views/ReportView.java
Tue Aug 12 10:57:03 2008
@@ -20,8 +20,10 @@
 import java.net.URL;
 
 import org.apache.ivy.util.Message;
+import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.SWT;
@@ -54,13 +56,17 @@
                     .getIvyClasspathContainer((IStructuredSelection) sel);
             if (ivycp != null) {
                 _browser.setUrl("");
-                URL report = ivycp.getReportUrl();
-                if (report != null) {
-                    if (!_browser.setUrl(report.toExternalForm())) {
-                        _browser.setUrl("");
-                        Message.warn("impossible to set report view url to "
-                                + report.toExternalForm());
-                    }
+                URL report;
+                try {
+                    report = ivycp.getReportUrl();
+                } catch (IvyDEException e) {
+                    e.log(IStatus.WARNING, "Impossible show the report for " + ivycp.getConf());
+                    e.show(IStatus.WARNING, "Show report failure", "Impossible show the report
for " + ivycp.getConf());
+                    return;
+                }
+                if (!_browser.setUrl(report.toExternalForm())) {
+                    _browser.setUrl("");
+                    Message.warn("impossible to set report view url to " + report.toExternalForm());
                 }
             }
         }



Mime
View raw message