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