| 363 | | } |
|---|
| 364 | | |
|---|
| | 378 | |
|---|
| | 379 | IProgressMonitor rememberedProgressMonitor= null; |
|---|
| | 380 | |
|---|
| | 381 | IDocumentProvider provider= getDocumentProvider(); |
|---|
| | 382 | if (provider != null) { |
|---|
| | 383 | provider.removeElementStateListener(fElementStateListener); |
|---|
| | 384 | if (provider instanceof IDocumentProviderExtension2) { |
|---|
| | 385 | IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) provider; |
|---|
| | 386 | rememberedProgressMonitor= extension.getProgressMonitor(); |
|---|
| | 387 | extension.setProgressMonitor(null); |
|---|
| | 388 | } |
|---|
| | 389 | } |
|---|
| | 390 | |
|---|
| | 391 | setDocumentProvider(input); |
|---|
| | 392 | |
|---|
| | 393 | provider= getDocumentProvider(); |
|---|
| | 394 | if (provider != null) { |
|---|
| | 395 | provider.addElementStateListener(fElementStateListener); |
|---|
| | 396 | if (provider instanceof IDocumentProviderExtension2) { |
|---|
| | 397 | IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) provider; |
|---|
| | 398 | extension.setProgressMonitor(rememberedProgressMonitor); |
|---|
| | 399 | } |
|---|
| | 400 | } |
|---|
| | 401 | |
|---|
| | 402 | |
|---|
| | 403 | |
|---|
| | 404 | if (fElementStateListener instanceof IElementStateListenerExtension) |
|---|
| | 405 | { |
|---|
| | 406 | IElementStateListenerExtension extension= (IElementStateListenerExtension) fElementStateListener; |
|---|
| | 407 | extension.elementStateValidationChanged(input, false); |
|---|
| | 408 | } |
|---|
| | 409 | |
|---|
| | 410 | } |
|---|
| | 411 | |
|---|
| | 412 | |
|---|
| | 413 | |
|---|
| | 458 | /** |
|---|
| | 459 | * Internal element state listener. |
|---|
| | 460 | */ |
|---|
| | 461 | class ElementStateListener |
|---|
| | 462 | implements IElementStateListener //, IElementStateListenerExtension |
|---|
| | 463 | { |
|---|
| | 464 | |
|---|
| | 465 | private Display fDisplay; |
|---|
| | 466 | |
|---|
| | 467 | /* |
|---|
| | 468 | * @see IElementStateListener#elementDirtyStateChanged(Object, boolean) |
|---|
| | 469 | */ |
|---|
| | 470 | public void elementDirtyStateChanged(Object element, boolean isDirty) { |
|---|
| | 471 | } |
|---|
| | 472 | |
|---|
| | 473 | /* |
|---|
| | 474 | * @see IElementStateListener#elementContentAboutToBeReplaced(Object) |
|---|
| | 475 | */ |
|---|
| | 476 | public void elementContentAboutToBeReplaced(Object element) |
|---|
| | 477 | { |
|---|
| | 478 | } |
|---|
| | 479 | |
|---|
| | 480 | /* |
|---|
| | 481 | * @see IElementStateListener#elementContentReplaced(Object) |
|---|
| | 482 | */ |
|---|
| | 483 | public void elementContentReplaced(Object element) |
|---|
| | 484 | { |
|---|
| | 485 | } |
|---|
| | 486 | |
|---|
| | 487 | /* |
|---|
| | 488 | * @see IElementStateListener#elementDeleted(Object) |
|---|
| | 489 | */ |
|---|
| | 490 | public void elementDeleted(Object deletedElement) |
|---|
| | 491 | { |
|---|
| | 492 | if (deletedElement != null && deletedElement.equals(getEditorInput())) |
|---|
| | 493 | { |
|---|
| | 494 | Runnable r= new Runnable() |
|---|
| | 495 | { |
|---|
| | 496 | public void run() |
|---|
| | 497 | { |
|---|
| | 498 | close(false); |
|---|
| | 499 | } |
|---|
| | 500 | }; |
|---|
| | 501 | execute(r, false); |
|---|
| | 502 | } |
|---|
| | 503 | } |
|---|
| | 504 | |
|---|
| | 505 | /* |
|---|
| | 506 | * @see IElementStateListener#elementMoved(Object, Object) |
|---|
| | 507 | */ |
|---|
| | 508 | public void elementMoved(final Object originalElement, final Object movedElement) |
|---|
| | 509 | { |
|---|
| | 510 | if (originalElement != null && originalElement.equals(getEditorInput())) |
|---|
| | 511 | { |
|---|
| | 512 | Runnable r= new Runnable() |
|---|
| | 513 | { |
|---|
| | 514 | public void run() |
|---|
| | 515 | { |
|---|
| | 516 | close(true); |
|---|
| | 517 | } |
|---|
| | 518 | }; |
|---|
| | 519 | execute(r, false); |
|---|
| | 520 | } |
|---|
| | 521 | } |
|---|
| | 522 | |
|---|
| | 523 | |
|---|
| | 524 | /** |
|---|
| | 525 | * Executes the given runnable in the UI thread. |
|---|
| | 526 | * <p> |
|---|
| | 527 | * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=76765 for details |
|---|
| | 528 | * about why the parameter <code>postAsync</code> has been |
|---|
| | 529 | * introduced in the course of 3.1. |
|---|
| | 530 | * |
|---|
| | 531 | * @param runnable runnable to be executed |
|---|
| | 532 | * @param postAsync <code>true</code> if the runnable must be posted asynchronous, <code>false</code> otherwise |
|---|
| | 533 | * @since 3.0 |
|---|
| | 534 | */ |
|---|
| | 535 | private void execute(Runnable runnable, boolean postAsync) |
|---|
| | 536 | { |
|---|
| | 537 | if (postAsync || Display.getCurrent() == null) |
|---|
| | 538 | { |
|---|
| | 539 | if (fDisplay == null) |
|---|
| | 540 | fDisplay= getSite().getShell().getDisplay(); |
|---|
| | 541 | fDisplay.asyncExec(runnable); |
|---|
| | 542 | } |
|---|
| | 543 | else |
|---|
| | 544 | runnable.run(); |
|---|
| | 545 | } |
|---|
| | 546 | } |
|---|
| | 547 | |
|---|