From: <jsa...@us...> - 2008-11-12 21:44:33
|
Revision: 95 http://flexotask.svn.sourceforge.net/flexotask/?rev=95&view=rev Author: jsauerbach Date: 2008-11-12 21:44:28 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Fix flaw in method for determining that a project already has a flexotask classpath. It was always concluding 'yes' before. Modified Paths: -------------- trunk/flexotask-development/src/com/ibm/realtime/flexotask/development/wizards/ConvertToFlexotaskProject.java Modified: trunk/flexotask-development/src/com/ibm/realtime/flexotask/development/wizards/ConvertToFlexotaskProject.java =================================================================== --- trunk/flexotask-development/src/com/ibm/realtime/flexotask/development/wizards/ConvertToFlexotaskProject.java 2008-11-12 21:43:22 UTC (rev 94) +++ trunk/flexotask-development/src/com/ibm/realtime/flexotask/development/wizards/ConvertToFlexotaskProject.java 2008-11-12 21:44:28 UTC (rev 95) @@ -21,13 +21,15 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor; -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.jface.action.IAction; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; @@ -102,8 +104,7 @@ } } IJavaProject javaProject = JavaCore.create(project); - IClasspathContainer classpathContainer = JavaCore.getClasspathContainer(FlexotaskClasspathInitializer.CONTAINER_PATH, javaProject); - boolean haveLibraries = classpathContainer != null; /* Indicates that the project has the Flexotask libraries in its classpath */ + boolean haveLibraries = hasFlexotaskClasspath(javaProject); IFolder generated = project.getFolder("generated"); /* Present information to the user if some or all of the actions are unnecessary and get permission @@ -134,6 +135,26 @@ } /** + * Method to test whether a project already has a Flexotask classpath container + * @param project the IJavaProject to test + * @return true iff the Flexotask classpath container is configured + * @throws JavaModelException + */ + private boolean hasFlexotaskClasspath(IJavaProject project) throws JavaModelException { + IClasspathEntry[] entries = project.getRawClasspath(); + for (int i = 0; i < entries.length; i++) { + IClasspathEntry entry = entries[i]; + if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { + IPath containerPath = entry.getPath(); + if (containerPath.segmentCount() == 2 && FlexotaskClasspathInitializer.CONTAINER_ID.equals(containerPath.segment(0))) { + return true; + } + } + } + return false; + } + + /** * Interact with the user depending on the current state of the project. If the project is already fully converted, just inform the user * of that fact and do nothing. * @param haveNature true iff the project already has the FlexotaskNature This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |