Author: hibou
Date: Thu Aug 14 06:00:50 2008
New Revision: 685878
URL: http://svn.apache.org/viewvc?rev=685878&view=rev
Log:
IVYDE-78:
- marker added on the container if there is any issue with its
configuration. This maker is just an overlay on the container
image.
- marker added on the ivy xml files when there is a issue with a
configuration issue, or a resolve problem. This maker also add
an entry in the prolem view, and the error marker is propagated
among the parent containers (project, working set)
Added:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java
(with props)
Modified:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml
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/IvyClasspathUtil.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/OpenIvyFileAction.java
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt?rev=685878&r1=685877&r2=685878&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt Thu Aug 14
06:00:50 2008
@@ -5,6 +5,7 @@
==========================
- NEW: settings files code completion support (IVYDE-22)
- NEW: Option to resolve to local eclipse projects (IVYDE-89) (thanks to
Antony James Wilkins and Matt Goldspink)
+- NEW: Add errors marker to the Ivy container (IVYDE-78)
- IMPROVE: Retrieve after resolve feature does not clean target directory
first (IVYDE-105)
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml?rev=685878&r1=685877&r2=685878&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml Thu Aug 14 06:00:50
2008
@@ -177,6 +177,17 @@
id="org.apache.ivyde.eclipse.ui.actions.resolveAll">
</command>
</extension>
+ <extension
+ point="org.eclipse.ui.decorators">
+ <decorator
+ adaptable="true"
+
class="org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainerDecorator"
+ id="org.apache.ivyde.eclipse.cpcontainer.decorator"
+ label="IvyDE classpath decoration"
+ location="BOTTOM_LEFT"
+ state="true">
+ </decorator>
+ </extension>
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=685878&r1=685877&r2=685878&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
Thu Aug 14 06:00:50 2008
@@ -23,6 +23,7 @@
import java.util.ResourceBundle;
import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainerDecorator;
import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
import
org.apache.ivyde.eclipse.cpcontainer.fragmentinfo.IPackageFragmentExtraInfo;
import org.apache.ivyde.eclipse.cpcontainer.fragmentinfo.PreferenceStoreInfo;
@@ -70,6 +71,8 @@
private BundleContext bundleContext;
+ private IvyClasspathContainerDecorator containerDecorator;
+
/**
* The constructor.
*/
@@ -274,6 +277,14 @@
return console;
}
+ public void setContainerDecorator(IvyClasspathContainerDecorator
containerDecorator) {
+ this.containerDecorator = containerDecorator;
+ }
+
+ public IvyClasspathContainerDecorator getContainerDecorator() {
+ return containerDecorator;
+ }
+
public IPackageFragmentExtraInfo getPackageFragmentExtraInfo() {
if (_packageExtraInfo == null) {
_packageExtraInfo = new PreferenceStoreInfo(getPreferenceStore());
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=685878&r1=685877&r2=685878&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
Thu Aug 14 06:00:50 2008
@@ -17,7 +17,6 @@
*/
package org.apache.ivyde.eclipse.cpcontainer;
-import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -31,7 +30,6 @@
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;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -62,10 +60,6 @@
IClasspathEntry[] classpathEntries;
- private IJavaProject javaProject;
-
- private File ivyXmlFile;
-
private IPath path;
IvyResolveJob job;
@@ -97,18 +91,14 @@
public IvyClasspathContainer(IJavaProject javaProject, IPath path,
IClasspathEntry[] classpathEntries) throws MalformedURLException,
ParseException,
IOException {
- this.javaProject = javaProject;
this.path = path;
conf = new IvyClasspathContainerConfiguration(javaProject, path);
- ivyXmlFile = resolveFile(conf.ivyXmlPath);
this.classpathEntries = classpathEntries;
}
public IvyClasspathContainer(IvyClasspathContainer cp) {
- javaProject = cp.javaProject;
path = cp.path;
conf = cp.conf;
- ivyXmlFile = cp.ivyXmlFile;
classpathEntries = cp.classpathEntries;
}
@@ -116,47 +106,18 @@
return conf;
}
- public IFile getIvyFile() {
- return javaProject.getProject().getFile(conf.ivyXmlPath);
- }
-
- private File resolveFile(String path) {
- IFile iFile = javaProject.getProject().getFile(path);
- return new File(iFile.getLocation().toOSString());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jdt.core.IClasspathContainer#getDescription()
- */
public String getDescription() {
return conf.ivyXmlPath + " " + conf.confs;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jdt.core.IClasspathContainer#getKind()
- */
public int getKind() {
return K_APPLICATION;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jdt.core.IClasspathContainer#getPath()
- */
public IPath getPath() {
return path;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jdt.core.IClasspathContainer#getClasspathEntries()
- */
public IClasspathEntry[] getClasspathEntries() {
return classpathEntries;
}
@@ -171,11 +132,6 @@
}
};
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jdt.core.IClasspathContainer#getClasspathEntries()
- */
private IvyResolveJob computeClasspathEntries(final boolean
usePreviousResolveIfExist,
boolean isUser) {
try {
@@ -184,15 +140,7 @@
// resolve job already running
return job;
}
- Ivy ivy = conf.getIvy();
- if (ivy == null) {
- return null;
- }
- ModuleDescriptor md = conf.getModuleDescriptor();
- if (md == null) {
- return null;
- }
- job = new IvyResolveJob(this, usePreviousResolveIfExist, conf,
ivy, md);
+ job = new IvyResolveJob(this, usePreviousResolveIfExist);
job.setUser(isUser);
job.setRule(RESOLVE_EVENT_RULE);
return job;
@@ -215,7 +163,8 @@
}
}
- public void launchResolve(boolean usePreviousResolveIfExist, boolean
isUser, IProgressMonitor monitor) {
+ public void launchResolve(boolean usePreviousResolveIfExist, boolean
isUser,
+ IProgressMonitor monitor) {
IvyResolveJob j = computeClasspathEntries(usePreviousResolveIfExist,
isUser);
if (j != null) {
if (monitor != null) {
@@ -255,7 +204,7 @@
void notifyUpdateClasspathEntries() {
try {
- JavaCore.setClasspathContainer(path, new IJavaProject[]
{javaProject},
+ JavaCore.setClasspathContainer(path, new IJavaProject[]
{conf.javaProject},
new IClasspathContainer[] {new
IvyClasspathContainer(IvyClasspathContainer.this)},
null);
@@ -279,7 +228,7 @@
IElementChangedListener[] listeners =
state.elementChangedListeners;
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] instanceof
PackageExplorerContentProvider) {
- JavaElementDelta delta = new
JavaElementDelta(javaProject);
+ JavaElementDelta delta = new
JavaElementDelta(conf.javaProject);
delta.changed(IJavaElementDelta.F_CLASSPATH_CHANGED);
listeners[i].elementChanged(new
ElementChangedEvent(delta,
ElementChangedEvent.POST_CHANGE));
@@ -319,8 +268,4 @@
}
}
- public IJavaProject getProject() {
- return javaProject;
- }
-
}
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=685878&r1=685877&r2=685878&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
Thu Aug 14 06:00:50 2008
@@ -36,10 +36,14 @@
import org.apache.ivyde.eclipse.IvyDEException;
import org.apache.ivyde.eclipse.IvyPlugin;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaProject;
/**
@@ -83,6 +87,8 @@
long ivySettingsLastModified = -1;
+ boolean confOk;
+
/**
* Constructor
*
@@ -114,7 +120,7 @@
}
public String toString() {
- return (javaProject == null ? "" : "project '" +
javaProject.getElementName()
+ return (javaProject == null ? "" : "project '" +
javaProject.getProject().getName()
+ "' and ivy file '")
+ ivyXmlPath + (javaProject == null ? "" : "'");
}
@@ -278,6 +284,49 @@
return javaProject;
}
+ private void setConfStatus(IvyDEException e) {
+ if (confOk != (e == null)) {
+ confOk = (e == null);
+ IvyPlugin.getDefault().getContainerDecorator().statusChaged(this);
+ if (e != null) {
+ setResolveStatus(new Status(IStatus.ERROR, IvyPlugin.ID,
IStatus.ERROR, e
+ .getMessage(), e.getCause()));
+ } else {
+ setResolveStatus(Status.OK_STATUS);
+ }
+ }
+ }
+
+ public void setResolveStatus(IStatus status) {
+ if (javaProject != null) {
+ IFile ivyFile = javaProject.getProject().getFile(ivyXmlPath);
+ if (!ivyFile.exists()) {
+ return;
+ }
+ try {
+ ivyFile.deleteMarkers(IMarker.PROBLEM, true,
IResource.DEPTH_INFINITE);
+ if (status == Status.OK_STATUS) {
+ return;
+ }
+ IMarker marker = ivyFile.createMarker(IMarker.PROBLEM);
+ marker.setAttribute(IMarker.MESSAGE, status.getMessage());
+ switch (status.getSeverity()) {
+ case IStatus.ERROR:
+ marker.setAttribute(IMarker.SEVERITY,
IMarker.SEVERITY_ERROR);
+ break;
+ case IStatus.WARNING:
+ marker.setAttribute(IMarker.SEVERITY,
IMarker.SEVERITY_WARNING);
+ break;
+ case IStatus.INFO:
+ marker.setAttribute(IMarker.SEVERITY,
IMarker.SEVERITY_INFO);
+ break;
+ }
+ } catch (CoreException e) {
+ IvyPlugin.log(e);
+ }
+ }
+ }
+
public Ivy getIvy() throws IvyDEException {
String ivySettingsPath = getInheritedIvySettingsPath();
if (ivySettingsPath == null || ivySettingsPath.trim().length() == 0) {
@@ -287,15 +336,22 @@
try {
ivy.configureDefault();
} catch (ParseException e) {
- throw new IvyDEException("Parsing error of the default Ivy
settings",
+ IvyDEException ex = new IvyDEException(
+ "Parsing error of the default Ivy settings",
"The default Ivy settings file could not be parsed
(" + this.toString()
+ ")", e);
+ setConfStatus(ex);
+ throw ex;
} catch (IOException e) {
- throw new IvyDEException("Read error of the default Ivy
settings",
+ IvyDEException ex = new IvyDEException(
+ "Read error of the default Ivy settings",
"The default Ivy settings file could not be read
(" + this.toString()
+ ")", e);
+ setConfStatus(ex);
+ throw ex;
}
}
+ setConfStatus(null);
return ivy;
}
@@ -304,15 +360,21 @@
try {
url = new URL(ivySettingsPath);
} catch (MalformedURLException e) {
- throw new IvyDEException("Incorrect url of the Ivy settings", "The
Ivy settings url '" + ivySettingsPath
- + "' is incorrect (" + this.toString() + ")", e);
+ IvyDEException ex = new IvyDEException("Incorrect url of the Ivy
settings",
+ "The Ivy settings url '" + ivySettingsPath + "' is
incorrect ("
+ + this.toString() + ")", e);
+ setConfStatus(ex);
+ throw ex;
}
if (url.getProtocol().startsWith("file")) {
File file = new File(url.getPath());
if (!file.exists()) {
- throw new IvyDEException("Ivy settings file not found", "The
Ivy settings file '"
- + ivySettingsPath + "' cannot be found (" +
this.toString() + ")", null);
+ IvyDEException ex = new IvyDEException("Ivy settings file not
found",
+ "The Ivy settings file '" + ivySettingsPath + "'
cannot be found ("
+ + this.toString() + ")", null);
+ setConfStatus(ex);
+ throw ex;
}
if (file.lastModified() != ivySettingsLastModified) {
@@ -325,12 +387,17 @@
try {
ivy.configure(file);
} catch (ParseException e) {
- throw new IvyDEException("Parsing error of the Ivy
settings", "The ivy settings file '"
- + ivySettingsPath + "' could not be parsed (" +
this.toString() + ")",
- e);
+ IvyDEException ex = new IvyDEException("Parsing error of
the Ivy settings",
+ "The ivy settings file '" + ivySettingsPath + "'
could not be parsed ("
+ + this.toString() + ")", e);
+ setConfStatus(ex);
+ throw ex;
} catch (IOException e) {
- throw new IvyDEException("Read error of the Ivy settings",
"The ivy settings file '"
- + ivySettingsPath + "' could not be read (" +
this.toString() + ")", e);
+ IvyDEException ex = new IvyDEException("Read error of the
Ivy settings",
+ "The ivy settings file '" + ivySettingsPath + "'
could not be read ("
+ + this.toString() + ")", e);
+ setConfStatus(ex);
+ throw ex;
}
ivySettingsLastModified = file.lastModified();
}
@@ -343,15 +410,21 @@
ivy.configure(url);
ivySettingsLastModified = 0;
} catch (ParseException e) {
- throw new IvyDEException("Parsing error of the Ivy
settings", "The ivy settings file '"
- + ivySettingsPath + "' could not be parsed (" +
this.toString() + ")",
- e);
+ IvyDEException ex = new IvyDEException("Parsing error of
the Ivy settings",
+ "The ivy settings file '" + ivySettingsPath + "'
could not be parsed ("
+ + this.toString() + ")", e);
+ setConfStatus(ex);
+ throw ex;
} catch (IOException e) {
- throw new IvyDEException("Read error of the Ivy settings",
"The ivy settings file '"
- + ivySettingsPath + "' could not be read (" +
this.toString() + ")", e);
+ IvyDEException ex = new IvyDEException("Read error of the
Ivy settings",
+ "The ivy settings file '" + ivySettingsPath + "'
could not be read ("
+ + this.toString() + ")", e);
+ setConfStatus(ex);
+ throw ex;
}
}
}
+ setConfStatus(null);
return ivy;
}
@@ -461,7 +534,7 @@
return ivySettingsPath != null;
}
- File getIvyFile() {
+ public File getIvyFile() {
File file;
if (javaProject != null) {
IFile f = javaProject.getProject().getFile(ivyXmlPath);
@@ -475,25 +548,34 @@
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);
+ IvyDEException ex = new IvyDEException("Ivy file not found", "The
ivy.xml file '"
+ + file.getAbsolutePath() + "' was not found (" +
this.toString() + ")", null);
+ setConfStatus(ex);
+ throw ex;
}
try {
Ivy i = getIvy();
- if (i == null) {
- return null;
- }
- return
ModuleDescriptorParserRegistry.getInstance().parseDescriptor(i.getSettings(),
- file.toURL(), false);
+ ModuleDescriptor md =
ModuleDescriptorParserRegistry.getInstance().parseDescriptor(
+ i.getSettings(), file.toURL(), false);
+ setConfStatus(null);
+ return md;
} catch (MalformedURLException e) {
- throw new IvyDEException("Incorrect URL of the Ivy file", "The URL
to the ivy.xml file is incorrect: '"
- + file.getAbsolutePath() + "' (" + this.toString() + ")",
e);
+ IvyDEException ex = new IvyDEException("Incorrect URL of the Ivy
file",
+ "The URL to the ivy.xml file is incorrect: '" +
file.getAbsolutePath() + "' ("
+ + this.toString() + ")", e);
+ setConfStatus(ex);
+ throw ex;
} catch (ParseException e) {
- throw new IvyDEException("Parsing error of the Ivy file", "The ivy
file '" + file.getAbsolutePath()
- + "' could not be parsed (" + this.toString() + ")", e);
+ IvyDEException ex = new IvyDEException("Parsing error of the Ivy
file",
+ "The ivy file '" + file.getAbsolutePath() + "' could not
be parsed ("
+ + this.toString() + ")", e);
+ setConfStatus(ex);
+ throw ex;
} catch (IOException e) {
- throw new IvyDEException("Read error of the Ivy file", "The ivy
file '" + file.getAbsolutePath()
- + "' could not be read (" + this.toString() + ")", e);
+ IvyDEException ex = new IvyDEException("Read error of the Ivy
file", "The ivy file '"
+ + file.getAbsolutePath() + "' could not be read (" +
this.toString() + ")", e);
+ setConfStatus(ex);
+ throw ex;
}
}
Added:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java?rev=685878&view=auto
==============================================================================
---
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java
(added)
+++
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java
Thu Aug 14 06:00:50 2008
@@ -0,0 +1,101 @@
+/*
+ * 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.ivyde.eclipse.IvyPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.ui.JavaPluginImages;
+import org.eclipse.jdt.internal.ui.packageview.ClassPathContainer;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DecorationOverlayIcon;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.swt.graphics.Image;
+
+public class IvyClasspathContainerDecorator implements ILabelDecorator {
+
+ private ListenerList listenerList;
+
+ public IvyClasspathContainerDecorator() {
+ IvyPlugin.getDefault().setContainerDecorator(this);
+ }
+
+ public String decorateText(String text, Object element) {
+ return text;
+ }
+
+ public Image decorateImage(Image image, Object obj) {
+ ImageDescriptor overlay = getOverlay(obj);
+ if (overlay == null) {
+ return null;
+ }
+ return new DecorationOverlayIcon(image, overlay,
IDecoration.BOTTOM_LEFT).createImage();
+ }
+
+ protected ImageDescriptor getOverlay(Object obj) {
+ if (obj instanceof ClassPathContainer) {
+ IvyClasspathContainer ivycp =
IvyClasspathUtil.jdt2IvyCPC((ClassPathContainer) obj);
+ if (ivycp != null) {
+ if (!ivycp.getConf().confOk) {
+ return JavaPluginImages.DESC_OVR_ERROR;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void dispose() {
+ // nothing to do
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return true;
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ if (listenerList == null) {
+ listenerList = new ListenerList();
+ }
+ listenerList.add(listener);
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ if (listenerList != null) {
+ listenerList.remove(listener);
+ }
+ }
+
+ public void statusChaged(IvyClasspathContainerConfiguration conf) {
+ if (listenerList != null && !listenerList.isEmpty()) {
+ ClassPathContainer elem = new ClassPathContainer(conf.javaProject,
JavaCore
+ .newContainerEntry(conf.getPath()));
+ LabelProviderChangedEvent event = new
LabelProviderChangedEvent(this, elem);
+ Object[] listeners = listenerList.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ ((ILabelProviderListener)
listeners[i]).labelProviderChanged(event);
+ }
+ }
+ }
+
+}
Propchange:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerDecorator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java?rev=685878&r1=685877&r2=685878&view=diff
==============================================================================
---
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
(original)
+++
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
Thu Aug 14 06:00:50 2008
@@ -36,6 +36,7 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.packageview.ClassPathContainer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -141,12 +142,34 @@
if (element instanceof ClassPathContainer) {
// FIXME: we shouldn't check against internal JDT API but
there are not adaptable to
// useful class
- return getIvyClasspathContainer(((ClassPathContainer)
element).getJavaProject());
+ return jdt2IvyCPC((ClassPathContainer) element);
}
}
return null;
}
+ /**
+ * Work around the non adaptability of ClassPathContainer
+ *
+ * @param cpc
+ * the container to transform into an IvyClasspathContainer
+ * @return the IvyClasspathContainer is such, null, if not
+ */
+ public static IvyClasspathContainer jdt2IvyCPC(ClassPathContainer cpc) {
+ IClasspathEntry entry = cpc.getClasspathEntry();
+ try {
+ IClasspathContainer icp =
JavaCore.getClasspathContainer(entry.getPath(), cpc
+ .getJavaProject());
+ if (icp instanceof IvyClasspathContainer) {
+ return (IvyClasspathContainer) icp;
+ }
+ } catch (JavaModelException e) {
+ // unless there are issues with the JDT, this should never happen
+ IvyPlugin.log(e);
+ }
+ return null;
+ }
+
public static boolean isIvyClasspathContainer(IPath containerPath) {
return
containerPath.segment(0).equals(IvyClasspathContainer.IVY_CLASSPATH_CONTAINER_ID);
}
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=685878&r1=685877&r2=685878&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
Thu Aug 14 06:00:50 2008
@@ -61,7 +61,11 @@
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.IMarker;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -100,17 +104,14 @@
final ModuleDescriptor md;
- public IvyResolveJob(IvyClasspathContainer container, boolean
usePreviousResolveIfExist,
- IvyClasspathContainerConfiguration conf, Ivy ivy, ModuleDescriptor
md) {
- super("Resolve "
- + (conf.getJavaProject() == null ? "" :
conf.getJavaProject().getProject()
- .getName()
- + "/") + conf.ivyXmlPath + " dependencies");
+ public IvyResolveJob(IvyClasspathContainer container, boolean
usePreviousResolveIfExist)
+ throws IvyDEException {
+ super("Resolve " + container.getConf() + " dependencies");
this.container = container;
- this.ivy = ivy;
- this.md = md;
+ this.conf = container.getConf();
+ this.ivy = conf.getIvy();
+ this.md = conf.getModuleDescriptor();
_usePreviousResolveIfExist = usePreviousResolveIfExist;
- this.conf = conf;
}
public void transferProgress(TransferEvent evt) {
@@ -340,6 +341,7 @@
if (status[0] == Status.OK_STATUS) {
container.updateClasspathEntries(classpathEntries[0]);
}
+ setResolveStatus(status[0]);
return status[0];
} finally {
container.job = null;
@@ -350,6 +352,36 @@
}
}
+ private void setResolveStatus(IStatus status) {
+ if (conf.javaProject != null) {
+ IFile ivyFile =
conf.javaProject.getProject().getFile(conf.ivyXmlPath);
+ if (!ivyFile.exists()) {
+ return;
+ }
+ try {
+ ivyFile.deleteMarkers(IMarker.PROBLEM, true,
IResource.DEPTH_INFINITE);
+ if (status == Status.OK_STATUS) {
+ return;
+ }
+ IMarker marker = ivyFile.createMarker(IMarker.PROBLEM);
+ marker.setAttribute(IMarker.MESSAGE, status.getMessage());
+ switch (status.getSeverity()) {
+ case IStatus.ERROR:
+ marker.setAttribute(IMarker.SEVERITY,
IMarker.SEVERITY_ERROR);
+ break;
+ case IStatus.WARNING:
+ marker.setAttribute(IMarker.SEVERITY,
IMarker.SEVERITY_WARNING);
+ break;
+ case IStatus.INFO:
+ marker.setAttribute(IMarker.SEVERITY,
IMarker.SEVERITY_INFO);
+ break;
+ }
+ } catch (CoreException e) {
+ IvyPlugin.log(e);
+ }
+ }
+ }
+
/**
* Trigger a warn if there are duplicates entries due to configuration
conflict.
* <p>
Modified:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/OpenIvyFileAction.java
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/OpenIvyFileAction.java?rev=685878&r1=685877&r2=685878&view=diff
==============================================================================
---
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/OpenIvyFileAction.java
(original)
+++
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/OpenIvyFileAction.java
Thu Aug 14 06:00:50 2008
@@ -18,6 +18,7 @@
package org.apache.ivyde.eclipse.ui.actions;
import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainerConfiguration;
import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
@@ -54,7 +55,11 @@
IvyClasspathContainer cp =
IvyClasspathUtil.getIvyClasspathContainer(IvyClasspathUtil
.getSelectionInJavaPackageView());
if (cp != null) {
- IFile file = cp.getIvyFile();
+ IvyClasspathContainerConfiguration conf = cp .getConf();
+ if (conf.getJavaProject() == null) {
+ return;
+ }
+ IFile file =
conf.getJavaProject().getProject().getFile(conf.getIvyXmlPath());
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage();
if (file != null) {