Lines 46-52
Link Here
|
46 |
* Returns a set of external path to external folders referred to on the given classpath. |
46 |
* Returns a set of external path to external folders referred to on the given classpath. |
47 |
* Returns null if none. |
47 |
* Returns null if none. |
48 |
*/ |
48 |
*/ |
49 |
public static HashSet getExternalFolders(IClasspathEntry[] classpath) { |
49 |
public static HashSet getExternalFolders(IClasspathEntry[] classpath) { |
50 |
if (classpath == null) |
50 |
if (classpath == null) |
51 |
return null; |
51 |
return null; |
52 |
HashSet folders = null; |
52 |
HashSet folders = null; |
Lines 258-263
Link Here
|
258 |
/* |
258 |
/* |
259 |
* Refreshes the external folders referenced on the classpath of the given source project |
259 |
* Refreshes the external folders referenced on the classpath of the given source project |
260 |
*/ |
260 |
*/ |
|
|
261 |
public void refreshReferences(final IProject[] sourceProjects, IProgressMonitor monitor) { |
262 |
IProject externalProject = getExternalFoldersProject(); |
263 |
try { |
264 |
HashSet externalFolders = null; |
265 |
for (int index = 0; index < sourceProjects.length; index++) { |
266 |
if (sourceProjects[index].equals(externalProject)) |
267 |
continue; |
268 |
if (!JavaProject.hasJavaNature(sourceProjects[index])) |
269 |
continue; |
270 |
|
271 |
HashSet foldersInProject = getExternalFolders(((JavaProject) JavaCore.create(sourceProjects[index])).getResolvedClasspath()); |
272 |
|
273 |
if (foldersInProject == null || foldersInProject.size() == 0) |
274 |
continue; |
275 |
if (externalFolders == null) |
276 |
externalFolders = new HashSet(); |
277 |
|
278 |
externalFolders.addAll(foldersInProject); |
279 |
} |
280 |
if (externalFolders == null) |
281 |
return; |
282 |
|
283 |
Iterator iterator = externalFolders.iterator(); |
284 |
Job refreshJob = new RefreshJob(iterator); |
285 |
refreshJob.schedule(); |
286 |
} catch (CoreException e) { |
287 |
Util.log(e, "Exception while refreshing external project"); //$NON-NLS-1$ |
288 |
} |
289 |
return; |
290 |
} |
261 |
public void refreshReferences(IProject source, IProgressMonitor monitor) { |
291 |
public void refreshReferences(IProject source, IProgressMonitor monitor) { |
262 |
IProject externalProject = getExternalFoldersProject(); |
292 |
IProject externalProject = getExternalFoldersProject(); |
263 |
if (source.equals(externalProject)) |
293 |
if (source.equals(externalProject)) |
Lines 268-292
Link Here
|
268 |
HashSet externalFolders = getExternalFolders(((JavaProject) JavaCore.create(source)).getResolvedClasspath()); |
298 |
HashSet externalFolders = getExternalFolders(((JavaProject) JavaCore.create(source)).getResolvedClasspath()); |
269 |
if (externalFolders == null) |
299 |
if (externalFolders == null) |
270 |
return; |
300 |
return; |
271 |
final Iterator iterator = externalFolders.iterator(); |
301 |
Iterator iterator = externalFolders.iterator(); |
272 |
Job refreshJob = new Job(Messages.refreshing_external_folders) { |
302 |
|
273 |
public boolean belongsTo(Object family) { |
303 |
Job refreshJob = new RefreshJob(iterator); |
274 |
return family == ResourcesPlugin.FAMILY_MANUAL_REFRESH; |
|
|
275 |
} |
276 |
protected IStatus run(IProgressMonitor pm) { |
277 |
try { |
278 |
while (iterator.hasNext()) { |
279 |
IPath externalPath = (IPath) iterator.next(); |
280 |
IFolder folder = getFolder(externalPath); |
281 |
if (folder != null) |
282 |
folder.refreshLocal(IResource.DEPTH_INFINITE, pm); |
283 |
} |
284 |
} catch (CoreException e) { |
285 |
return e.getStatus(); |
286 |
} |
287 |
return Status.OK_STATUS; |
288 |
} |
289 |
}; |
290 |
refreshJob.schedule(); |
304 |
refreshJob.schedule(); |
291 |
} catch (CoreException e) { |
305 |
} catch (CoreException e) { |
292 |
Util.log(e, "Exception while refreshing external project"); //$NON-NLS-1$ |
306 |
Util.log(e, "Exception while refreshing external project"); //$NON-NLS-1$ |
Lines 298-302
Link Here
|
298 |
return (IFolder) getFolders().remove(externalFolderPath); |
312 |
return (IFolder) getFolders().remove(externalFolderPath); |
299 |
} |
313 |
} |
300 |
|
314 |
|
301 |
|
315 |
class RefreshJob extends Job { |
|
|
316 |
Iterator externalFolders = null; |
317 |
RefreshJob(Iterator externalFolders){ |
318 |
super(Messages.refreshing_external_folders); |
319 |
this.externalFolders = externalFolders; |
320 |
} |
321 |
|
322 |
public boolean belongsTo(Object family) { |
323 |
return family == ResourcesPlugin.FAMILY_MANUAL_REFRESH; |
324 |
} |
325 |
|
326 |
protected IStatus run(IProgressMonitor pm) { |
327 |
try { |
328 |
while (this.externalFolders.hasNext()) { |
329 |
IPath externalPath = (IPath) this.externalFolders.next(); |
330 |
IFolder folder = getFolder(externalPath); |
331 |
if (folder != null) { |
332 |
folder.refreshLocal(IResource.DEPTH_INFINITE, pm); |
333 |
} |
334 |
} |
335 |
} catch (CoreException e) { |
336 |
return e.getStatus(); |
337 |
} |
338 |
return Status.OK_STATUS; |
339 |
} |
340 |
} |
341 |
|
302 |
} |
342 |
} |