|
Lines 13-18
Link Here
|
| 13 |
import java.io.IOException; |
13 |
import java.io.IOException; |
| 14 |
import java.io.StringReader; |
14 |
import java.io.StringReader; |
| 15 |
import java.io.StringWriter; |
15 |
import java.io.StringWriter; |
|
|
16 |
import java.lang.reflect.InvocationTargetException; |
| 16 |
import java.text.MessageFormat; |
17 |
import java.text.MessageFormat; |
| 17 |
import java.util.ArrayList; |
18 |
import java.util.ArrayList; |
| 18 |
import java.util.Comparator; |
19 |
import java.util.Comparator; |
|
Lines 26-31
Link Here
|
| 26 |
import org.eclipse.core.runtime.IStatus; |
27 |
import org.eclipse.core.runtime.IStatus; |
| 27 |
import org.eclipse.core.runtime.Platform; |
28 |
import org.eclipse.core.runtime.Platform; |
| 28 |
import org.eclipse.core.runtime.Status; |
29 |
import org.eclipse.core.runtime.Status; |
|
|
30 |
import org.eclipse.core.runtime.SubProgressMonitor; |
| 31 |
import org.eclipse.core.runtime.jobs.IJobManager; |
| 32 |
import org.eclipse.core.runtime.jobs.Job; |
| 29 |
|
33 |
|
| 30 |
import org.eclipse.swt.graphics.Image; |
34 |
import org.eclipse.swt.graphics.Image; |
| 31 |
import org.eclipse.swt.layout.GridData; |
35 |
import org.eclipse.swt.layout.GridData; |
|
Lines 39-44
Link Here
|
| 39 |
import org.eclipse.jface.dialogs.IDialogSettings; |
43 |
import org.eclipse.jface.dialogs.IDialogSettings; |
| 40 |
import org.eclipse.jface.dialogs.MessageDialog; |
44 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 41 |
import org.eclipse.jface.operation.IRunnableContext; |
45 |
import org.eclipse.jface.operation.IRunnableContext; |
|
|
46 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
| 42 |
import org.eclipse.jface.resource.ImageDescriptor; |
47 |
import org.eclipse.jface.resource.ImageDescriptor; |
| 43 |
import org.eclipse.jface.util.IPropertyChangeListener; |
48 |
import org.eclipse.jface.util.IPropertyChangeListener; |
| 44 |
import org.eclipse.jface.util.PropertyChangeEvent; |
49 |
import org.eclipse.jface.util.PropertyChangeEvent; |
|
Lines 71-76
Link Here
|
| 71 |
import org.eclipse.jdt.core.search.SearchEngine; |
76 |
import org.eclipse.jdt.core.search.SearchEngine; |
| 72 |
import org.eclipse.jdt.core.search.TypeNameMatch; |
77 |
import org.eclipse.jdt.core.search.TypeNameMatch; |
| 73 |
import org.eclipse.jdt.core.search.TypeNameMatchRequestor; |
78 |
import org.eclipse.jdt.core.search.TypeNameMatchRequestor; |
|
|
79 |
import org.eclipse.jdt.core.search.TypeNameRequestor; |
| 74 |
|
80 |
|
| 75 |
import org.eclipse.jdt.internal.corext.util.Messages; |
81 |
import org.eclipse.jdt.internal.corext.util.Messages; |
| 76 |
import org.eclipse.jdt.internal.corext.util.OpenTypeHistory; |
82 |
import org.eclipse.jdt.internal.corext.util.OpenTypeHistory; |
|
Lines 84-89
Link Here
|
| 84 |
import org.eclipse.jdt.launching.LibraryLocation; |
90 |
import org.eclipse.jdt.launching.LibraryLocation; |
| 85 |
|
91 |
|
| 86 |
import org.eclipse.jdt.ui.JavaElementLabels; |
92 |
import org.eclipse.jdt.ui.JavaElementLabels; |
|
|
93 |
import org.eclipse.jdt.ui.JavaUI; |
| 87 |
import org.eclipse.jdt.ui.dialogs.ITypeInfoFilterExtension; |
94 |
import org.eclipse.jdt.ui.dialogs.ITypeInfoFilterExtension; |
| 88 |
import org.eclipse.jdt.ui.dialogs.ITypeInfoImageProvider; |
95 |
import org.eclipse.jdt.ui.dialogs.ITypeInfoImageProvider; |
| 89 |
import org.eclipse.jdt.ui.dialogs.TypeSelectionExtension; |
96 |
import org.eclipse.jdt.ui.dialogs.TypeSelectionExtension; |
|
Lines 92-97
Link Here
|
| 92 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
99 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
| 93 |
import org.eclipse.jdt.internal.ui.JavaUIMessages; |
100 |
import org.eclipse.jdt.internal.ui.JavaUIMessages; |
| 94 |
import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory; |
101 |
import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory; |
|
|
102 |
import org.eclipse.jdt.internal.ui.util.ExceptionHandler; |
| 95 |
import org.eclipse.jdt.internal.ui.util.TypeNameMatchLabelProvider; |
103 |
import org.eclipse.jdt.internal.ui.util.TypeNameMatchLabelProvider; |
| 96 |
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider; |
104 |
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider; |
| 97 |
import org.eclipse.jdt.internal.ui.workingsets.WorkingSetFilterActionGroup; |
105 |
import org.eclipse.jdt.internal.ui.workingsets.WorkingSetFilterActionGroup; |
|
Lines 129-134
Link Here
|
| 129 |
private ISelectionStatusValidator fValidator; |
137 |
private ISelectionStatusValidator fValidator; |
| 130 |
|
138 |
|
| 131 |
private TypeInfoUtil fTypeInfoUtil; |
139 |
private TypeInfoUtil fTypeInfoUtil; |
|
|
140 |
|
| 141 |
private IRunnableContext fRunnableContext; |
| 142 |
|
| 143 |
private static boolean fgFirstTime= true; |
| 132 |
|
144 |
|
| 133 |
/** |
145 |
/** |
| 134 |
* Creates new FilteredTypesSelectionDialog instance |
146 |
* Creates new FilteredTypesSelectionDialog instance |
|
Lines 185-190
Link Here
|
| 185 |
*/ |
197 |
*/ |
| 186 |
public FilteredTypesSelectionDialog(Shell shell, boolean multi, IRunnableContext context, IJavaSearchScope scope, int elementKinds, TypeSelectionExtension extension) { |
198 |
public FilteredTypesSelectionDialog(Shell shell, boolean multi, IRunnableContext context, IJavaSearchScope scope, int elementKinds, TypeSelectionExtension extension) { |
| 187 |
super(shell, multi); |
199 |
super(shell, multi); |
|
|
200 |
|
| 201 |
fRunnableContext= context; |
| 188 |
|
202 |
|
| 189 |
setSelectionHistory(new TypeSelectionHistory()); |
203 |
setSelectionHistory(new TypeSelectionHistory()); |
| 190 |
|
204 |
|
|
Lines 404-409
Link Here
|
| 404 |
* @see org.eclipse.jface.window.Window#open() |
418 |
* @see org.eclipse.jface.window.Window#open() |
| 405 |
*/ |
419 |
*/ |
| 406 |
public int open() { |
420 |
public int open() { |
|
|
421 |
|
| 422 |
try { |
| 423 |
ensureConsistency(); |
| 424 |
} catch (InvocationTargetException e) { |
| 425 |
ExceptionHandler.handle(e, JavaUIMessages.TypeSelectionDialog_error3Title, JavaUIMessages.TypeSelectionDialog_error3Message); |
| 426 |
return CANCEL; |
| 427 |
} catch (InterruptedException e) { |
| 428 |
// cancelled by user |
| 429 |
return CANCEL; |
| 430 |
} |
| 431 |
|
| 407 |
if (getInitialPattern() == null) { |
432 |
if (getInitialPattern() == null) { |
| 408 |
IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); |
433 |
IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); |
| 409 |
if (window != null) { |
434 |
if (window != null) { |
|
Lines 514-519
Link Here
|
| 514 |
private void setSearchScope(IJavaSearchScope scope) { |
539 |
private void setSearchScope(IJavaSearchScope scope) { |
| 515 |
fSearchScope= scope; |
540 |
fSearchScope= scope; |
| 516 |
} |
541 |
} |
|
|
542 |
|
| 543 |
private void ensureConsistency() throws InvocationTargetException, InterruptedException { |
| 544 |
// we only have to ensure history consistency here since the search engine |
| 545 |
// takes care of working copies. |
| 546 |
class ConsistencyRunnable implements IRunnableWithProgress { |
| 547 |
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |
| 548 |
if (fgFirstTime) { |
| 549 |
// Join the initialize after load job. |
| 550 |
IJobManager manager= Job.getJobManager(); |
| 551 |
manager.join(JavaUI.ID_PLUGIN, monitor); |
| 552 |
} |
| 553 |
OpenTypeHistory history= OpenTypeHistory.getInstance(); |
| 554 |
if (fgFirstTime || history.isEmpty()) { |
| 555 |
monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 100); |
| 556 |
if (history.needConsistencyCheck()) { |
| 557 |
refreshSearchIndices(new SubProgressMonitor(monitor, 90)); |
| 558 |
history.checkConsistency(new SubProgressMonitor(monitor, 10)); |
| 559 |
} else { |
| 560 |
refreshSearchIndices(monitor); |
| 561 |
} |
| 562 |
monitor.done(); |
| 563 |
fgFirstTime= false; |
| 564 |
} else { |
| 565 |
history.checkConsistency(monitor); |
| 566 |
} |
| 567 |
} |
| 568 |
public boolean needsExecution() { |
| 569 |
OpenTypeHistory history= OpenTypeHistory.getInstance(); |
| 570 |
return fgFirstTime || history.isEmpty() || history.needConsistencyCheck(); |
| 571 |
} |
| 572 |
private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException { |
| 573 |
try { |
| 574 |
new SearchEngine().searchAllTypeNames( |
| 575 |
null, |
| 576 |
0, |
| 577 |
// make sure we search a concrete name. This is faster according to Kent |
| 578 |
"_______________".toCharArray(), //$NON-NLS-1$ |
| 579 |
SearchPattern.RULE_EXACT_MATCH | SearchPattern.RULE_CASE_SENSITIVE, |
| 580 |
IJavaSearchConstants.ENUM, |
| 581 |
SearchEngine.createWorkspaceScope(), |
| 582 |
new TypeNameRequestor() {}, |
| 583 |
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, |
| 584 |
monitor); |
| 585 |
} catch (JavaModelException e) { |
| 586 |
throw new InvocationTargetException(e); |
| 587 |
} |
| 588 |
} |
| 589 |
} |
| 590 |
ConsistencyRunnable runnable= new ConsistencyRunnable(); |
| 591 |
if (!runnable.needsExecution()) |
| 592 |
return; |
| 593 |
IRunnableContext context= fRunnableContext != null |
| 594 |
? fRunnableContext |
| 595 |
: PlatformUI.getWorkbench().getProgressService(); |
| 596 |
context.run(true, true, runnable); |
| 597 |
} |
| 517 |
|
598 |
|
| 518 |
/** |
599 |
/** |
| 519 |
* The <code>ShowContainerForDuplicatesAction</code> provides means to |
600 |
* The <code>ShowContainerForDuplicatesAction</code> provides means to |