try {
getContainer().run(false, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
boolean autobuild = workspace.isAutoBuilding();
try {
if (autobuild) {
// Disable auto build during project setup.
final IWorkspaceDescription wsDescription = workspace.getDescription();
autobuild = wsDescription.isAutoBuilding();
wsDescription.setAutoBuilding(false);
workspace.setDescription(wsDescription);
}
final List<AndroidProject> projects = page2.getSelectedProjects();
monitor.beginTask("Creating projects", projects.size());
for (final AndroidProject androidProject : projects) {
monitor.subTask(androidProject.getName());
androidProject.create(monitor);
monitor.worked(1);
}
monitor.done();
if (autobuild) {
// re-enable auto build
final IWorkspaceDescription wsDescription = workspace.getDescription();
wsDescription.setAutoBuilding(true);
workspace.setDescription(wsDescription);
}
} catch (final CoreException e) {
throw new InvocationTargetException(e);
}
}