|
Lines 353-425
Link Here
|
| 353 |
* @param manager TODO |
353 |
* @param manager TODO |
| 354 |
* @return |
354 |
* @return |
| 355 |
*/ |
355 |
*/ |
| 356 |
protected IWorkbenchPart createPart() { |
356 |
protected IWorkbenchPart createErrorPart(Exception exception) { |
| 357 |
|
|
|
| 358 |
PartInitException exception = null; |
| 359 |
|
357 |
|
| 360 |
IWorkbenchPart result = null; |
358 |
IWorkbenchPart result = null; |
|
|
359 |
|
| 360 |
IStatus originalStatus = WorkbenchPlugin.getStatus(exception); |
| 361 |
IStatus logStatus = StatusUtil.newStatus(originalStatus, |
| 362 |
NLS.bind("Unable to create editor ID {0}: {1}", //$NON-NLS-1$ |
| 363 |
getId(), originalStatus.getMessage())); |
| 364 |
WorkbenchPlugin.log(logStatus); |
| 365 |
|
| 366 |
IStatus displayStatus = StatusUtil.newStatus(originalStatus, |
| 367 |
NLS.bind(WorkbenchMessages.EditorManager_unableToCreateEditor, |
| 368 |
originalStatus.getMessage())); |
| 369 |
|
| 370 |
ErrorEditorPart part = new ErrorEditorPart(displayStatus); |
| 371 |
|
| 372 |
IEditorInput input; |
| 373 |
try { |
| 374 |
input = getEditorInput(); |
| 375 |
} catch (PartInitException e1) { |
| 376 |
input = new NullEditorInput(); |
| 377 |
} |
| 378 |
|
| 379 |
EditorPane pane = (EditorPane)getPane(); |
| 380 |
|
| 381 |
pane.createControl((Composite) manager.page.getEditorPresentation().getLayoutPart().getControl()); |
| 382 |
|
| 383 |
EditorDescriptor descr = getDescriptor(); |
| 361 |
|
384 |
|
| 362 |
// Try to restore the editor -- this does the real work of restoring the editor |
385 |
EditorSite site = new EditorSite(this, part, manager.page, descr); |
| 363 |
// |
386 |
|
|
|
387 |
site.setActionBars(new EditorActionBars(new NullActionBars(), getId())); |
| 364 |
try { |
388 |
try { |
| 365 |
result = createPartHelper(); |
389 |
part.init(site, input); |
| 366 |
} catch (PartInitException e) { |
390 |
} catch (PartInitException e) { |
| 367 |
exception = e; |
391 |
WorkbenchPlugin.log(e); |
|
|
392 |
return null; |
| 368 |
} |
393 |
} |
| 369 |
|
394 |
|
|
|
395 |
Composite parent = (Composite)pane.getControl(); |
| 396 |
Composite content = new Composite(parent, SWT.NONE); |
| 397 |
content.setLayout(new FillLayout()); |
| 370 |
|
398 |
|
| 371 |
// If unable to create the part, create an error part instead |
399 |
try { |
| 372 |
if (exception != null) { |
400 |
part.createPartControl(content); |
| 373 |
|
401 |
} catch (Exception e) { |
| 374 |
IStatus originalStatus = exception.getStatus(); |
402 |
content.dispose(); |
| 375 |
IStatus logStatus = StatusUtil.newStatus(originalStatus, |
403 |
WorkbenchPlugin.log(e); |
| 376 |
NLS.bind("Unable to create editor ID {0}: {1}", //$NON-NLS-1$ |
404 |
return null; |
| 377 |
getId(), originalStatus.getMessage())); |
|
|
| 378 |
WorkbenchPlugin.log(logStatus); |
| 379 |
|
| 380 |
IStatus displayStatus = StatusUtil.newStatus(originalStatus, |
| 381 |
NLS.bind(WorkbenchMessages.EditorManager_unableToCreateEditor, |
| 382 |
originalStatus.getMessage())); |
| 383 |
|
| 384 |
ErrorEditorPart part = new ErrorEditorPart(displayStatus); |
| 385 |
|
| 386 |
IEditorInput input; |
| 387 |
try { |
| 388 |
input = getEditorInput(); |
| 389 |
} catch (PartInitException e1) { |
| 390 |
input = new NullEditorInput(); |
| 391 |
} |
| 392 |
|
| 393 |
EditorPane pane = (EditorPane)getPane(); |
| 394 |
|
| 395 |
pane.createControl((Composite) manager.page.getEditorPresentation().getLayoutPart().getControl()); |
| 396 |
|
| 397 |
EditorDescriptor descr = getDescriptor(); |
| 398 |
|
| 399 |
EditorSite site = new EditorSite(this, part, manager.page, descr); |
| 400 |
|
| 401 |
site.setActionBars(new EditorActionBars(new NullActionBars(), getId())); |
| 402 |
try { |
| 403 |
part.init(site, input); |
| 404 |
} catch (PartInitException e) { |
| 405 |
WorkbenchPlugin.log(e); |
| 406 |
return null; |
| 407 |
} |
| 408 |
|
| 409 |
Composite parent = (Composite)pane.getControl(); |
| 410 |
Composite content = new Composite(parent, SWT.NONE); |
| 411 |
content.setLayout(new FillLayout()); |
| 412 |
|
| 413 |
try { |
| 414 |
part.createPartControl(content); |
| 415 |
} catch (Exception e) { |
| 416 |
content.dispose(); |
| 417 |
WorkbenchPlugin.log(e); |
| 418 |
return null; |
| 419 |
} |
| 420 |
|
| 421 |
result = part; |
| 422 |
} |
405 |
} |
|
|
406 |
|
| 407 |
result = part; |
| 423 |
|
408 |
|
| 424 |
return result; |
409 |
return result; |
| 425 |
} |
410 |
} |
|
Lines 514-520
Link Here
|
| 514 |
} |
499 |
} |
| 515 |
} |
500 |
} |
| 516 |
|
501 |
|
| 517 |
private IEditorPart createPartHelper() throws PartInitException { |
502 |
/** |
|
|
503 |
* Creates the real part. Returns the newly created part or throws an exception on failure. |
| 504 |
* This method will not create an error part. |
| 505 |
* |
| 506 |
* @return the newly created part |
| 507 |
* @throws PartInitException if part creation was aborted due to a PartInitException thrown |
| 508 |
* from IEditorPart.init |
| 509 |
* @throws PartCreationException if part creation was aborted due to an unanticipated error |
| 510 |
*/ |
| 511 |
protected IWorkbenchPart createPart() throws PartInitException, PartCreationException { |
| 518 |
|
512 |
|
| 519 |
// Things that will need to be disposed if an exception occurs (listed in the order they |
513 |
// Things that will need to be disposed if an exception occurs (listed in the order they |
| 520 |
// need to be disposed, and set to null if they haven't been created yet) |
514 |
// need to be disposed, and set to null if they haven't been created yet) |
|
Lines 531-537
Link Here
|
| 531 |
EditorDescriptor desc = getDescriptor(); |
525 |
EditorDescriptor desc = getDescriptor(); |
| 532 |
|
526 |
|
| 533 |
if (desc == null) { |
527 |
if (desc == null) { |
| 534 |
throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_missing_editor_descriptor, editorID)); //$NON-NLS-1$ |
528 |
throw new PartCreationException(NLS.bind(WorkbenchMessages.EditorManager_missing_editor_descriptor, editorID)); //$NON-NLS-1$ |
| 535 |
} |
529 |
} |
| 536 |
|
530 |
|
| 537 |
IEditorPart part; |
531 |
IEditorPart part; |
|
Lines 551-560
Link Here
|
| 551 |
part = ComponentSupport.getSystemInPlaceEditor(); |
545 |
part = ComponentSupport.getSystemInPlaceEditor(); |
| 552 |
|
546 |
|
| 553 |
if (part == null) { |
547 |
if (part == null) { |
| 554 |
throw new PartInitException(WorkbenchMessages.EditorManager_no_in_place_support); //$NON-NLS-1$ |
548 |
throw new PartCreationException(WorkbenchMessages.EditorManager_no_in_place_support); //$NON-NLS-1$ |
| 555 |
} |
549 |
} |
| 556 |
} else { |
550 |
} else { |
| 557 |
throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_invalid_editor_descriptor, editorID)); //$NON-NLS-1$ |
551 |
throw new PartCreationException(NLS.bind(WorkbenchMessages.EditorManager_invalid_editor_descriptor, editorID)); //$NON-NLS-1$ |
| 558 |
} |
552 |
} |
| 559 |
// Create a pane for this part |
553 |
// Create a pane for this part |
| 560 |
PartPane pane = getPane(); |
554 |
PartPane pane = getPane(); |
|
Lines 630-636
Link Here
|
| 630 |
} |
624 |
} |
| 631 |
} |
625 |
} |
| 632 |
|
626 |
|
| 633 |
throw new PartInitException(StatusUtil.getLocalizedMessage(e), StatusUtil.getCause(e)); |
627 |
if (e instanceof PartInitException) { |
|
|
628 |
throw (PartInitException)e; |
| 629 |
} |
| 630 |
|
| 631 |
throw new PartCreationException(StatusUtil.getLocalizedMessage(e), StatusUtil.getCause(e)); |
| 634 |
} |
632 |
} |
| 635 |
|
633 |
|
| 636 |
} |
634 |
} |