public static File importDirectory(ContentItem item, final Shell shell, boolean promptForDownload,
SubMonitor monitor) throws CoreException, InterruptedException {
Assert.isNotNull(item);
String id = item.getId();
ContentManager manager = ContentPlugin.getDefault().getManager();
if (item.needsDownload()) {
final ContentItem finalItem = item;
final boolean[] response = { true };
if (promptForDownload) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
response[0] = promptForDownload(shell, finalItem);
}
});
}
if (response[0]) {
TemplateDownloader downloader = getTemplateDownloader(finalItem);
IStatus status = downloader.downloadTemplate(monitor);
if (!status.isOK()) {
String message = NLS.bind("Download of template ''{0}'' failed: {1}", id, status.getMessage());
throw new CoreException(new Status(IStatus.ERROR, WizardPlugin.PLUGIN_ID, message));
}
// re-get template project since it may changed
item = manager.getItem(id);
if (item == null) {
return null;
}
}
else if (!item.isLocal()) {
return null;
}
}
File baseDir = manager.getInstallDirectory();
if (item.isRuntimeDefined()) {
File directory = new File(baseDir, item.getPath());
String projectName = item.getLocalDescriptor().getUrl();
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);