Author: hibou
Date: Wed Aug 13 09:29:40 2008
New Revision: 685601

URL: http://svn.apache.org/viewvc?rev=685601&view=rev
Log:
IVYDE-112:
 - improvment of the error messages
 - now there is no more popups, add some error flag around the fields

Modified:
    
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java
    
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/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/IvydeContainerPage.java
    
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/views/ReportView.java

Modified: 
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java?rev=685601&r1=685600&r2=685601&view=diff
==============================================================================
--- 
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java
 (original)
+++ 
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEException.java
 Wed Aug 13 09:29:40 2008
@@ -29,8 +29,25 @@
  */
 public class IvyDEException extends Exception {
 
-    public IvyDEException(String msg, Throwable cause) {
+    private final String shortMsg;
+
+    /**
+     * Default constructor
+     * 
+     * @param shortMsg
+     *            a short description of the error, whcih doesn't need context 
information
+     * @param msg
+     *            full message, with context information like the full path 
and the project name
+     * @param cause
+     *            the underlying cause
+     */
+    public IvyDEException(String shortMsg, String msg, Throwable cause) {
         super(msg, cause);
+        this.shortMsg = shortMsg;
+    }
+
+    public String getShortMsg() {
+        return shortMsg;
     }
 
     /**

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=685601&r1=685600&r2=685601&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
 Wed Aug 13 09:29:40 2008
@@ -200,7 +200,7 @@
         } 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: ");
+            e.show(IStatus.ERROR, "IvyDE resolve failed", "The IvyDE resolve 
job could not be lauched: ");
             return null;
         } catch (Throwable e) {
             // IVYDE-79 : catch Throwable in order to catch 
java.lang.NoClassDefFoundError too

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=685601&r1=685600&r2=685601&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
 Wed Aug 13 09:29:40 2008
@@ -81,7 +81,7 @@
 
     private Ivy ivy;
 
-    private long ivySettingsLastModified = -1;
+    long ivySettingsLastModified = -1;
 
     /**
      * Constructor
@@ -287,11 +287,13 @@
                 try {
                     ivy.configureDefault();
                 } catch (ParseException e) {
-                    throw new IvyDEException("The default ivy settings file 
could not be parsed ("
-                            + this.toString() + ")", e);
+                    throw new IvyDEException("Parsing error of the default Ivy 
settings",
+                            "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);
+                    throw new IvyDEException("Read error of the default Ivy 
settings",
+                            "The default Ivy settings file could not be read 
(" + this.toString()
+                                    + ")", e);
                 }
             }
             return ivy;
@@ -302,15 +304,15 @@
         try {
             url = new URL(ivySettingsPath);
         } catch (MalformedURLException e) {
-            throw new IvyDEException("The ivy settings url '" + ivySettingsPath
+            throw new IvyDEException("Incorrect url of the Ivy settings", "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);
+                throw new IvyDEException("Ivy settings file not found", "The 
Ivy settings file '"
+                        + ivySettingsPath + "' cannot be found (" + 
this.toString() + ")", null);
             }
 
             if (file.lastModified() != ivySettingsLastModified) {
@@ -323,27 +325,30 @@
                 try {
                     ivy.configure(file);
                 } catch (ParseException e) {
-                    throw new IvyDEException("The ivy settings file '" + 
ivySettingsPath
-                            + "' could not be parsed (" + this.toString() + 
")", e);
+                    throw new IvyDEException("Parsing error of the Ivy 
settings", "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);
+                    throw new IvyDEException("Read error of the Ivy settings", 
"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) {
+            if (ivy == null || ivySettingsLastModified == -1) {
                 ivy = new Ivy();
                 try {
                     ivy.configure(url);
+                    ivySettingsLastModified = 0;
                 } catch (ParseException e) {
-                    throw new IvyDEException("The ivy settings file '" + 
ivySettingsPath
-                            + "' could not be parsed (" + this.toString() + 
")", e);
+                    throw new IvyDEException("Parsing error of the Ivy 
settings", "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);
+                    throw new IvyDEException("Read error of the Ivy settings", 
"The ivy settings file '"
+                            + ivySettingsPath + "' could not be read (" + 
this.toString() + ")", e);
                 }
             }
         }
@@ -469,6 +474,10 @@
 
     public ModuleDescriptor getModuleDescriptor() throws IvyDEException {
         File file = getIvyFile();
+        if (!file.exists()) {
+            throw new IvyDEException("Ivy file not found", "The ivy.xml file '"
+                + file.getAbsolutePath() + "' was not found (" + 
this.toString() + ")", null);
+        }
         try {
             Ivy i = getIvy();
             if (i == null) {
@@ -477,13 +486,13 @@
             return 
ModuleDescriptorParserRegistry.getInstance().parseDescriptor(i.getSettings(),
                 file.toURL(), false);
         } catch (MalformedURLException e) {
-            throw new IvyDEException("The path to the ivy.xml file is 
incorrect: '"
+            throw new IvyDEException("Incorrect URL of the Ivy file", "The URL 
to the ivy.xml file is incorrect: '"
                     + file.getAbsolutePath() + "' (" + this.toString() + ")", 
e);
         } catch (ParseException e) {
-            throw new IvyDEException("The ivy file '" + file.getAbsolutePath()
+            throw new IvyDEException("Parsing error of the Ivy file", "The ivy 
file '" + file.getAbsolutePath()
                     + "' could not be parsed (" + this.toString() + ")", e);
         } catch (IOException e) {
-            throw new IvyDEException("The ivy file '" + file.getAbsolutePath()
+            throw new IvyDEException("Read error of the Ivy file", "The ivy 
file '" + file.getAbsolutePath()
                     + "' could not be read (" + this.toString() + ")", e);
         }
     }

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=685601&r1=685600&r2=685601&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
 Wed Aug 13 09:29:40 2008
@@ -33,14 +33,14 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IClasspathContainer;
 import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
 import org.eclipse.jdt.ui.wizards.IClasspathContainerPage;
 import org.eclipse.jdt.ui.wizards.IClasspathContainerPageExtension;
 import org.eclipse.jdt.ui.wizards.NewElementWizardPage;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
 import org.eclipse.jface.preference.PreferenceDialog;
 import org.eclipse.jface.viewers.CheckboxTableViewer;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -121,6 +121,22 @@
 
     private Button retrieveSyncButton;
 
+    private ControlDecoration ivyFilePathTextDeco;
+
+    private IvyDEException ivyXmlError;
+
+    private Image errorDecoImage;
+
+    private ControlDecoration settingsTextDeco;
+
+    private IvyDEException settingsError;
+
+    private TabItem mainTab;
+
+    private TabFolder tabs;
+
+    private TabItem advancedTab;
+
     /**
      * Constructor
      * 
@@ -191,21 +207,39 @@
         setTitle("IvyDE Managed Libraries");
         setDescription("Choose ivy file and its configurations.");
 
-        TabFolder tabs = new TabFolder(parent, SWT.BORDER);
+        errorDecoImage = 
FieldDecorationRegistry.getDefault().getFieldDecoration(
+            FieldDecorationRegistry.DEC_ERROR).getImage();
+
+        tabs = new TabFolder(parent, SWT.BORDER);
         tabs.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, 
true));
 
-        TabItem mainTab = new TabItem(tabs, SWT.NONE);
+        mainTab = new TabItem(tabs, SWT.NONE);
         mainTab.setText("Main");
         mainTab.setControl(createMainTab(tabs));
 
-        TabItem advancedTab = new TabItem(tabs, SWT.NONE);
+        tabs.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                TabItem item = tabs.getSelection()[0];
+                if (item == mainTab && ivyXmlError != null) {
+                    
ivyFilePathTextDeco.showHoverText(ivyXmlError.getShortMsg());
+                    settingsTextDeco.showHoverText(null);
+                } else if (item == advancedTab &&  settingsError != null) {
+                    
settingsTextDeco.showHoverText(settingsError.getShortMsg());
+                    ivyFilePathTextDeco.showHoverText(null);
+                }
+            }
+        });
+
+        advancedTab = new TabItem(tabs, SWT.NONE);
         advancedTab.setText("Advanced");
         advancedTab.setControl(createAdvancedTab(tabs));
 
         setControl(tabs);
 
         loadFromConf();
+        ivyXmlPathUpdated();
         checkCompleted();
+        tabs.setFocus();
     }
 
     private Control createMainTab(Composite parent) {
@@ -220,9 +254,20 @@
         ivyFilePathText = new Text(composite, SWT.SINGLE | SWT.BORDER);
         ivyFilePathText.setLayoutData(new GridData(GridData.FILL, 
GridData.FILL, true, false));
         ivyFilePathText.addModifyListener(new ModifyListener() {
-            public void modifyText(ModifyEvent e) {
+            public void modifyText(ModifyEvent ev) {
                 conf.ivyXmlPath = ivyFilePathText.getText();
-                checkCompleted();
+                ivyXmlPathUpdated();
+            }
+        });
+        ivyFilePathTextDeco = new ControlDecoration(ivyFilePathText, SWT.LEFT 
| SWT.TOP);
+        ivyFilePathTextDeco.setMarginWidth(2);
+        ivyFilePathTextDeco.setImage(errorDecoImage);
+        ivyFilePathTextDeco.hide();
+        ivyFilePathTextDeco.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                if (ivyXmlError != null) {
+                    ivyXmlError.show(IStatus.ERROR, "IvyDE configuration 
problem", null);
+                }
             }
         });
 
@@ -275,7 +320,7 @@
                 if (path != null) {
                     conf.ivyXmlPath = path;
                     ivyFilePathText.setText(path);
-                    checkCompleted();
+                    ivyXmlPathUpdated();
                 }
             }
         });
@@ -328,7 +373,7 @@
                 try {
                     md = conf.getModuleDescriptor();
                 } catch (IvyDEException e) {
-                    e.show(IStatus.ERROR, "Configuration error",
+                    e.show(IStatus.ERROR, "Ivy configuration error",
                         "The configurations of the ivy.xml could not be 
retrieved: ");
                 }
                 confTableViewer.setInput(ivyFilePathText.getText());
@@ -353,6 +398,31 @@
         return composite;
     }
 
+    void ivyXmlPathUpdated() {
+        try {
+            md = conf.getModuleDescriptor();
+            setIvyXmlError(null);
+        } catch (IvyDEException e) {
+            md = null;
+            setIvyXmlError(e);
+        }
+        checkCompleted();
+    }
+
+    void setIvyXmlError(IvyDEException error) {
+        if (error == null) {
+            ivyXmlError = null;
+            ivyFilePathTextDeco.hide();
+            ivyFilePathTextDeco.hideHover();
+        } else if (!error.equals(ivyXmlError)) {
+            ivyXmlError = error;
+            ivyFilePathTextDeco.show();
+            if (ivyFilePathText.isVisible()) {
+                ivyFilePathTextDeco.showHoverText(error.getShortMsg());
+            }
+        }
+    }
+
     private Control createAdvancedTab(Composite parent) {
         Composite composite = new Composite(parent, SWT.NONE);
         composite.setLayout(new GridLayout());
@@ -368,7 +438,7 @@
             public void widgetSelected(SelectionEvent e) {
                 updateFieldsStatus();
                 conf.ivySettingsPath = settingsText.getText();
-                checkCompleted();
+                settingsUpdated();
             }
         });
 
@@ -401,7 +471,18 @@
         settingsText.addModifyListener(new ModifyListener() {
             public void modifyText(ModifyEvent e) {
                 conf.ivySettingsPath = settingsText.getText();
-                checkCompleted();
+                settingsUpdated();
+            }
+        });
+        settingsTextDeco = new ControlDecoration(settingsText, SWT.LEFT | 
SWT.TOP);
+        settingsTextDeco.setMarginWidth(2);
+        settingsTextDeco.setImage(errorDecoImage);
+        settingsTextDeco.hide();
+        settingsTextDeco.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                if (settingsError != null) {
+                    settingsError.show(IStatus.ERROR, "IvyDE configuration 
problem", null);
+                }
             }
         });
 
@@ -413,6 +494,7 @@
                 if (f != null) {
                     try {
                         settingsText.setText(f.toURL().toExternalForm());
+                        settingsUpdated();
                     } catch (MalformedURLException ex) {
                         // this cannot happen
                         IvyPlugin.log(IStatus.ERROR,
@@ -512,15 +594,34 @@
         return composite;
     }
 
-    private void loadFromConf() {
-        ivyFilePathText.setText(conf.ivyXmlPath);
-
+    void settingsUpdated() {
         try {
-            md = conf.getModuleDescriptor();
+            conf.ivySettingsLastModified = -1;
+            conf.getIvy();
+            setSettingsError(null);
         } catch (IvyDEException e) {
-            e.log(IStatus.WARNING, "Failed to resolve the module descriptor "
-                    + "while entering in the configuration panel");
+            md = null;
+            setSettingsError(e);
+        }
+        ivyXmlPathUpdated();
+    }
+
+    void setSettingsError(IvyDEException error) {
+        if (error == null) {
+            settingsError = null;
+            settingsTextDeco.hide();
+            settingsTextDeco.hideHover();
+        } else if (!error.equals(settingsError)) {
+            settingsError = error;
+            settingsTextDeco.show();
+            if (settingsText.isVisible()) {
+                settingsTextDeco.showHoverText(error.getShortMsg());
+            }
         }
+    }
+
+    private void loadFromConf() {
+        ivyFilePathText.setText(conf.ivyXmlPath);
 
         confTableViewer.setInput(conf.ivyXmlPath);
         initTableSelection();

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=685601&r1=685600&r2=685601&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
 Wed Aug 13 09:29:40 2008
@@ -61,7 +61,7 @@
                     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());
+                    e.show(IStatus.WARNING, "Show Ivy report failure", 
"Impossible show the report for " + ivycp.getConf());
                     return;
                 }
                 if (!_browser.setUrl(report.toExternalForm())) {


Reply via email to