Return-Path: Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: (qmail 2572 invoked from network); 23 Aug 2010 12:36:58 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 23 Aug 2010 12:36:58 -0000 Received: (qmail 7430 invoked by uid 500); 23 Aug 2010 12:36:58 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 7334 invoked by uid 500); 23 Aug 2010 12:36:57 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 7326 invoked by uid 99); 23 Aug 2010 12:36:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Aug 2010 12:36:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Aug 2010 12:36:53 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 66DE923889ED; Mon, 23 Aug 2010 12:35:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r988102 - /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java Date: Mon, 23 Aug 2010 12:35:35 -0000 To: notifications@ant.apache.org From: hibou@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100823123535.66DE923889ED@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: hibou Date: Mon Aug 23 12:35:35 2010 New Revision: 988102 URL: http://svn.apache.org/viewvc?rev=988102&view=rev Log: Add nature asynchronously, otherwise there are some concurrent modification errors happening on old project opening Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java?rev=988102&r1=988101&r2=988102&view=diff ============================================================================== --- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java (original) +++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java Mon Aug 23 12:35:35 2010 @@ -29,6 +29,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; +import org.eclipse.swt.widgets.Display; public class IvyNature implements IProjectNature { @@ -73,33 +74,44 @@ public class IvyNature implements IProje try { return project.hasNature(IVY_NATURE); } catch (CoreException e) { - IvyPlugin.log(IStatus.ERROR, "Unable to get the Ivy nature of the project " - + project.getName(), e); + IvyPlugin.log(IStatus.ERROR, + "Unable to get the Ivy nature of the project " + project.getName(), e); return false; } } public static void addNature(final IProject project) { - try { - if (hasNature(project)) { - return; - } + if (hasNature(project)) { + return; + } - final IProjectDescription description = project.getDescription(); - final String[] ids = description.getNatureIds(); + final IProjectDescription description; + try { + description = project.getDescription(); + } catch (CoreException e) { + IvyPlugin.log(IStatus.ERROR, + "Failed to add Ivy dependency management on " + project.getName(), e); + return; + } + final String[] ids = description.getNatureIds(); - final String[] newIds = new String[ids == null ? 1 : ids.length + 1]; - if (ids != null) { - System.arraycopy(ids, 0, newIds, 0, ids.length); + final String[] newIds = new String[ids == null ? 1 : ids.length + 1]; + if (ids != null) { + System.arraycopy(ids, 0, newIds, 0, ids.length); + } + newIds[ids == null ? 0 : ids.length] = IVY_NATURE; + + description.setNatureIds(newIds); + Display.getDefault().asyncExec(new Runnable() { + public void run() { + try { + project.setDescription(description, null); + } catch (CoreException e) { + IvyPlugin.log(IStatus.ERROR, "Failed to add Ivy dependency management on " + + project.getName(), e); + } } - newIds[ids == null ? 0 : ids.length] = IVY_NATURE; - - description.setNatureIds(newIds); - project.setDescription(description, null); - } catch (Exception e) { - IvyPlugin.log(IStatus.ERROR, "Failed to add Ivy dependency management on " - + project.getName(), e); - } + }); } public static void removeNature(final IProject project) { @@ -137,8 +149,8 @@ public class IvyNature implements IProje description.setNatureIds(newIds); project.setDescription(description, null); } catch (Exception e) { - IvyPlugin.log(IStatus.ERROR, "Failed to remove Ivy dependency management on " - + project.getName(), e); + IvyPlugin.log(IStatus.ERROR, + "Failed to remove Ivy dependency management on " + project.getName(), e); } }