|
Lines 33-38
Link Here
|
| 33 |
import org.eclipse.core.runtime.IExecutableExtension; |
33 |
import org.eclipse.core.runtime.IExecutableExtension; |
| 34 |
import org.eclipse.core.runtime.IProgressMonitor; |
34 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 35 |
import org.eclipse.core.runtime.NullProgressMonitor; |
35 |
import org.eclipse.core.runtime.NullProgressMonitor; |
|
|
36 |
import org.eclipse.core.runtime.SubProgressMonitor; |
| 36 |
import org.eclipse.core.runtime.Platform; |
37 |
import org.eclipse.core.runtime.Platform; |
| 37 |
import org.eclipse.core.runtime.content.IContentType; |
38 |
import org.eclipse.core.runtime.content.IContentType; |
| 38 |
import org.eclipse.core.runtime.content.IContentTypeManager; |
39 |
import org.eclipse.core.runtime.content.IContentTypeManager; |
|
Lines 226-244
Link Here
|
| 226 |
fConfigElement= config; |
227 |
fConfigElement= config; |
| 227 |
} |
228 |
} |
| 228 |
|
229 |
|
|
|
230 |
private IProgressMonitor createProjectMonitor; |
| 231 |
|
| 229 |
private IRunnableWithProgress getRunnable(boolean _defaults, final boolean onFinish) { |
232 |
private IRunnableWithProgress getRunnable(boolean _defaults, final boolean onFinish) { |
| 230 |
final boolean defaults = _defaults; |
233 |
final boolean defaults = _defaults; |
| 231 |
return new IRunnableWithProgress() { |
234 |
return new IRunnableWithProgress() { |
| 232 |
public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException { |
235 |
public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException { |
|
|
236 |
final Exception except[] = new Exception[1]; |
| 233 |
getShell().getDisplay().syncExec(new Runnable() { |
237 |
getShell().getDisplay().syncExec(new Runnable() { |
| 234 |
public void run() { |
238 |
public void run() { |
|
|
239 |
IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() { |
| 240 |
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |
| 241 |
final IProgressMonitor fMonitor; |
| 242 |
if (monitor == null) { |
| 243 |
fMonitor= new NullProgressMonitor(); |
| 244 |
} else { |
| 245 |
fMonitor = monitor; |
| 246 |
} |
| 247 |
fMonitor.beginTask(CUIPlugin.getResourceString("CProjectWizard.op_description"), 100); //$NON-NLS-1$ |
| 248 |
fMonitor.worked(10); |
| 249 |
try { |
| 250 |
createProjectMonitor = new SubProgressMonitor(fMonitor, 60); |
| 251 |
newProject = createIProject(lastProjectName, lastProjectLocation); |
| 252 |
if (newProject != null) |
| 253 |
fMainPage.h_selected.createProject(newProject, defaults, onFinish); |
| 254 |
fMonitor.worked(30); |
| 255 |
} catch (CoreException e) { CUIPlugin.log(e); } |
| 256 |
finally { |
| 257 |
fMonitor.done(); |
| 258 |
} |
| 259 |
} |
| 260 |
}); |
| 235 |
try { |
261 |
try { |
| 236 |
newProject = createIProject(lastProjectName, lastProjectLocation); |
262 |
getContainer().run(false, true, op); |
| 237 |
if (newProject != null) |
263 |
} catch (InvocationTargetException e) { |
| 238 |
fMainPage.h_selected.createProject(newProject, defaults, onFinish); |
264 |
except[0] = e; |
| 239 |
} catch (CoreException e) { CUIPlugin.log(e); } |
265 |
} catch (InterruptedException e) { |
|
|
266 |
except[0] = e; |
| 267 |
} |
| 240 |
} |
268 |
} |
| 241 |
}); |
269 |
}); |
|
|
270 |
if (except[0] != null) { |
| 271 |
if (except[0] instanceof InvocationTargetException) { |
| 272 |
throw (InvocationTargetException)except[0]; |
| 273 |
} |
| 274 |
if (except[0] instanceof InterruptedException) { |
| 275 |
throw (InterruptedException)except[0]; |
| 276 |
} |
| 277 |
throw new InvocationTargetException(except[0]); |
| 278 |
} |
| 242 |
} |
279 |
} |
| 243 |
}; |
280 |
}; |
| 244 |
} |
281 |
} |
|
Lines 247-252
Link Here
|
| 247 |
* |
284 |
* |
| 248 |
*/ |
285 |
*/ |
| 249 |
public IProject createIProject(final String name, final URI location) throws CoreException{ |
286 |
public IProject createIProject(final String name, final URI location) throws CoreException{ |
|
|
287 |
IProgressMonitor monitor = new NullProgressMonitor(); |
| 288 |
if (createProjectMonitor != null) |
| 289 |
monitor = createProjectMonitor; |
| 290 |
|
| 291 |
monitor.beginTask("createIProject", 100); //$NON-NLS-1$ |
| 292 |
|
| 250 |
if (newProject != null) return newProject; |
293 |
if (newProject != null) return newProject; |
| 251 |
|
294 |
|
| 252 |
IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
295 |
IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
|
Lines 260-285
Link Here
|
| 260 |
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); |
303 |
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); |
| 261 |
if(location != null) |
304 |
if(location != null) |
| 262 |
description.setLocationURI(location); |
305 |
description.setLocationURI(location); |
| 263 |
newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new NullProgressMonitor()); |
306 |
newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new SubProgressMonitor(monitor,25)); |
| 264 |
} else { |
307 |
} else { |
| 265 |
IWorkspaceRunnable runnable = new IWorkspaceRunnable() { |
308 |
IWorkspaceRunnable runnable = new IWorkspaceRunnable() { |
| 266 |
public void run(IProgressMonitor monitor) throws CoreException { |
309 |
public void run(IProgressMonitor monitor) throws CoreException { |
| 267 |
newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor); |
310 |
newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor); |
| 268 |
} |
311 |
} |
| 269 |
}; |
312 |
}; |
| 270 |
NullProgressMonitor monitor = new NullProgressMonitor(); |
313 |
workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, new SubProgressMonitor(monitor,25)); |
| 271 |
workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, monitor); |
|
|
| 272 |
newProject = newProjectHandle; |
314 |
newProject = newProjectHandle; |
| 273 |
} |
315 |
} |
| 274 |
|
316 |
|
| 275 |
// Open the project if we have to |
317 |
// Open the project if we have to |
| 276 |
if (!newProject.isOpen()) { |
318 |
if (!newProject.isOpen()) { |
| 277 |
newProject.open(new NullProgressMonitor()); |
319 |
newProject.open(new SubProgressMonitor(monitor,25)); |
| 278 |
} |
320 |
} |
| 279 |
return continueCreation(newProject); |
321 |
|
|
|
322 |
IProject proj = continueCreation(newProject); |
| 323 |
monitor.worked(25); |
| 324 |
|
| 325 |
monitor.done(); |
| 326 |
|
| 327 |
return proj; |
| 280 |
} |
328 |
} |
| 281 |
|
329 |
|
| 282 |
protected abstract IProject continueCreation(IProject prj); |
330 |
protected abstract IProject continueCreation(IProject prj); |
|
|
331 |
|
| 283 |
public abstract String[] getNatures(); |
332 |
public abstract String[] getNatures(); |
| 284 |
|
333 |
|
| 285 |
@Override |
334 |
@Override |