|
Lines 427-441
Link Here
|
| 427 |
*/ |
427 |
*/ |
| 428 |
public int open() { |
428 |
public int open() { |
| 429 |
|
429 |
|
| 430 |
try { |
430 |
// try { |
| 431 |
ensureConsistency(); |
431 |
// ensureConsistency(); |
| 432 |
} catch (InvocationTargetException e) { |
432 |
// } catch (InvocationTargetException e) { |
| 433 |
ExceptionHandler.handle(e, JavaUIMessages.TypeSelectionDialog_error3Title, JavaUIMessages.TypeSelectionDialog_error3Message); |
433 |
// ExceptionHandler.handle(e, JavaUIMessages.TypeSelectionDialog_error3Title, JavaUIMessages.TypeSelectionDialog_error3Message); |
| 434 |
return CANCEL; |
434 |
// return CANCEL; |
| 435 |
} catch (InterruptedException e) { |
435 |
// } catch (InterruptedException e) { |
| 436 |
// cancelled by user |
436 |
// // cancelled by user |
| 437 |
return CANCEL; |
437 |
// return CANCEL; |
| 438 |
} |
438 |
// } |
| 439 |
|
439 |
|
| 440 |
if (getInitialPattern() == null) { |
440 |
if (getInitialPattern() == null) { |
| 441 |
IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); |
441 |
IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); |
|
Lines 556-593
Link Here
|
| 556 |
fSearchScope= scope; |
556 |
fSearchScope= scope; |
| 557 |
} |
557 |
} |
| 558 |
|
558 |
|
| 559 |
private void ensureConsistency() throws InvocationTargetException, InterruptedException { |
559 |
/* |
| 560 |
// we only have to ensure history consistency here since the search engine |
560 |
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#reloadCache(boolean, org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.GranualProgressMonitor) |
| 561 |
// takes care of working copies. |
561 |
*/ |
| 562 |
class ConsistencyRunnable implements IRunnableWithProgress { |
562 |
public void reloadCache(boolean checkDuplicates, IProgressMonitor monitor) { |
| 563 |
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |
563 |
ConsistencyRunnable runnable= new ConsistencyRunnable(); |
| 564 |
if (fgFirstTime) { |
564 |
IProgressMonitor remainingMonitor; |
| 565 |
// Join the initialize after load job. |
565 |
if (runnable.needsExecution()) { |
| 566 |
IJobManager manager= Job.getJobManager(); |
566 |
monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 10); |
| 567 |
manager.join(JavaUI.ID_PLUGIN, monitor); |
567 |
try { |
| 568 |
} |
568 |
runnable.run(new SubProgressMonitor(monitor, 1)); |
| 569 |
OpenTypeHistory history= OpenTypeHistory.getInstance(); |
569 |
} catch (InvocationTargetException e) { |
| 570 |
if (fgFirstTime || history.isEmpty()) { |
570 |
ExceptionHandler.handle(e, JavaUIMessages.TypeSelectionDialog_error3Title, JavaUIMessages.TypeSelectionDialog_error3Message); |
| 571 |
monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 100); |
571 |
close(); |
| 572 |
if (history.needConsistencyCheck()) { |
572 |
return; |
| 573 |
refreshSearchIndices(new SubProgressMonitor(monitor, 90)); |
573 |
} catch (InterruptedException e) { |
| 574 |
history.checkConsistency(new SubProgressMonitor(monitor, 10)); |
574 |
// cancelled by user |
| 575 |
} else { |
575 |
close(); |
| 576 |
refreshSearchIndices(monitor); |
576 |
return; |
| 577 |
} |
577 |
} |
| 578 |
monitor.done(); |
578 |
remainingMonitor= new SubProgressMonitor(monitor, 9); |
| 579 |
fgFirstTime= false; |
579 |
} else { |
|
|
580 |
remainingMonitor= monitor; |
| 581 |
} |
| 582 |
super.reloadCache(checkDuplicates, remainingMonitor); |
| 583 |
monitor.done(); |
| 584 |
} |
| 585 |
|
| 586 |
private static class ConsistencyRunnable implements IRunnableWithProgress { |
| 587 |
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |
| 588 |
if (fgFirstTime) { |
| 589 |
// Join the initialize after load job. |
| 590 |
IJobManager manager= Job.getJobManager(); |
| 591 |
manager.join(JavaUI.ID_PLUGIN, monitor); |
| 592 |
} |
| 593 |
OpenTypeHistory history= OpenTypeHistory.getInstance(); |
| 594 |
if (fgFirstTime || history.isEmpty()) { |
| 595 |
monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 100); |
| 596 |
if (history.needConsistencyCheck()) { |
| 597 |
refreshSearchIndices(new SubProgressMonitor(monitor, 90)); |
| 598 |
history.checkConsistency(new SubProgressMonitor(monitor, 10)); |
| 580 |
} else { |
599 |
} else { |
| 581 |
history.checkConsistency(monitor); |
600 |
refreshSearchIndices(monitor); |
| 582 |
} |
601 |
} |
|
|
602 |
monitor.done(); |
| 603 |
fgFirstTime= false; |
| 604 |
} else { |
| 605 |
history.checkConsistency(monitor); |
| 583 |
} |
606 |
} |
| 584 |
public boolean needsExecution() { |
607 |
} |
| 585 |
OpenTypeHistory history= OpenTypeHistory.getInstance(); |
608 |
public boolean needsExecution() { |
| 586 |
return fgFirstTime || history.isEmpty() || history.needConsistencyCheck(); |
609 |
OpenTypeHistory history= OpenTypeHistory.getInstance(); |
| 587 |
} |
610 |
return fgFirstTime || history.isEmpty() || history.needConsistencyCheck(); |
| 588 |
private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException { |
611 |
} |
| 589 |
try { |
612 |
private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException { |
| 590 |
new SearchEngine().searchAllTypeNames( |
613 |
try { |
|
|
614 |
new SearchEngine().searchAllTypeNames( |
| 591 |
null, |
615 |
null, |
| 592 |
0, |
616 |
0, |
| 593 |
// make sure we search a concrete name. This is faster according to Kent |
617 |
// make sure we search a concrete name. This is faster according to Kent |
|
Lines 598-608
Link Here
|
| 598 |
new TypeNameRequestor() {}, |
622 |
new TypeNameRequestor() {}, |
| 599 |
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, |
623 |
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, |
| 600 |
monitor); |
624 |
monitor); |
| 601 |
} catch (JavaModelException e) { |
625 |
} catch (JavaModelException e) { |
| 602 |
throw new InvocationTargetException(e); |
626 |
throw new InvocationTargetException(e); |
| 603 |
} |
|
|
| 604 |
} |
627 |
} |
| 605 |
} |
628 |
} |
|
|
629 |
} |
| 630 |
|
| 631 |
private void ensureConsistency() throws InvocationTargetException, InterruptedException { |
| 632 |
// we only have to ensure history consistency here since the search engine |
| 633 |
// takes care of working copies. |
| 606 |
ConsistencyRunnable runnable= new ConsistencyRunnable(); |
634 |
ConsistencyRunnable runnable= new ConsistencyRunnable(); |
| 607 |
if (!runnable.needsExecution()) |
635 |
if (!runnable.needsExecution()) |
| 608 |
return; |
636 |
return; |