|
22 | 22 |
|
23 | 23 | import static org.eclipse.jface.resource.JFaceResources.TEXT_FONT; |
24 | 24 |
|
| 25 | +import java.awt.event.ItemEvent; |
25 | 26 | import java.util.ArrayList; |
26 | 27 | import java.util.Arrays; |
27 | 28 | import java.util.Collections; |
| 29 | +import java.util.Deque; |
28 | 30 | import java.util.List; |
29 | 31 |
|
30 | 32 | import org.eclipse.core.commands.AbstractHandler; |
|
41 | 43 | import org.eclipse.jface.action.IMenuManager; |
42 | 44 | import org.eclipse.jface.action.LegacyActionTools; |
43 | 45 | import org.eclipse.jface.action.MenuManager; |
| 46 | +import org.eclipse.jface.dialogs.DialogSettings; |
44 | 47 | import org.eclipse.jface.dialogs.IDialogConstants; |
45 | 48 | import org.eclipse.jface.dialogs.IDialogSettings; |
46 | 49 | import org.eclipse.jface.layout.GridDataFactory; |
|
83 | 86 | import org.eclipse.swt.layout.GridData; |
84 | 87 | import org.eclipse.swt.layout.GridLayout; |
85 | 88 | import org.eclipse.swt.widgets.Button; |
| 89 | +import org.eclipse.swt.widgets.Combo; |
86 | 90 | import org.eclipse.swt.widgets.Composite; |
87 | 91 | import org.eclipse.swt.widgets.Control; |
88 | 92 | import org.eclipse.swt.widgets.Display; |
@@ -369,7 +373,7 @@ public void update(ViewerCell cell) { |
369 | 373 | private Label headerLabel; |
370 | 374 |
|
371 | 375 | private IWorkbenchWindow window; |
372 | | - private Text searchIn; |
| 376 | + private Combo searchIn; |
373 | 377 | private Label listLabel; |
374 | 378 |
|
375 | 379 | /** |
@@ -409,16 +413,23 @@ public void create() { |
409 | 413 | */ |
410 | 414 | protected void restoreDialog(IDialogSettings settings) { |
411 | 415 | try { |
412 | | - if (initialPatternText==null) { |
413 | | - String lastSearch = settings.get(DIALOG_LAST_QUERY); |
| 416 | + DialogSettings dialogSettings = (DialogSettings) settings; |
| 417 | + |
| 418 | + if (initialPatternText==null && dialogSettings.getLastFilters() != null) { |
| 419 | + String lastSearch = dialogSettings.get(DIALOG_LAST_QUERY); |
| 420 | + |
414 | 421 | if (lastSearch==null) { |
415 | 422 | lastSearch = EMPTY_STRING; |
416 | 423 | } |
417 | 424 | pattern.setText(lastSearch); |
418 | 425 | pattern.selectAll(); |
419 | 426 | } |
420 | | - if (settings.get(DIALOG_PATH_FILTER)!=null) { |
421 | | - String filter = settings.get(DIALOG_PATH_FILTER); |
| 427 | + if (dialogSettings.getLastFilters() != null) { |
| 428 | + Deque<String> lastSearches = dialogSettings.getLastFilters(); |
| 429 | + |
| 430 | + String filter = lastSearches.getFirst(); |
| 431 | + |
| 432 | + searchIn.setItems(filterOutBlanks(lastSearches).toArray(String[]::new)); |
422 | 433 | searchIn.setText(filter); |
423 | 434 | } |
424 | 435 |
|
@@ -452,6 +463,12 @@ protected void restoreDialog(IDialogSettings settings) { |
452 | 463 | } |
453 | 464 | } |
454 | 465 |
|
| 466 | + private Deque<String> filterOutBlanks(Deque<String> lastFiveSearches) { |
| 467 | + lastFiveSearches.removeIf(str -> str.isBlank()); |
| 468 | + return lastFiveSearches; |
| 469 | + |
| 470 | + } |
| 471 | + |
455 | 472 | private class ToggleKeepOpenAction extends Action { |
456 | 473 | public ToggleKeepOpenAction(IDialogSettings settings) { |
457 | 474 | super( |
@@ -531,9 +548,10 @@ public boolean close() { |
531 | 548 | * settings used to store dialog |
532 | 549 | */ |
533 | 550 | protected void storeDialog(IDialogSettings settings) { |
534 | | - String currentSearch = pattern.getText(); |
535 | | - settings.put(DIALOG_LAST_QUERY, currentSearch); |
536 | | - settings.put(DIALOG_PATH_FILTER, searchIn.getText()); |
| 551 | + ((DialogSettings)settings).inputNewSearchFilter(searchIn.getText()); |
| 552 | + |
| 553 | + settings.put(DIALOG_LAST_QUERY, pattern.getText()); |
| 554 | + |
537 | 555 | if (toggleCaseSensitiveAction!=null) { |
538 | 556 | settings.put(CASE_SENSITIVE, toggleCaseSensitiveAction.isChecked()); |
539 | 557 | } |
@@ -755,7 +773,7 @@ public void getName(AccessibleEvent e) { |
755 | 773 | Label searchInLabel = new Label(searchInComposite, SWT.NONE); |
756 | 774 | searchInLabel.setText(Messages.QuickSearchDialog_In); |
757 | 775 | GridDataFactory.swtDefaults().indent(5, 0).applyTo(searchInLabel); |
758 | | - searchIn = new Text(searchInComposite, SWT.SINGLE | SWT.BORDER | SWT.ICON_CANCEL); |
| 776 | + searchIn = new Combo(searchInComposite, SWT.SINGLE | SWT.BORDER | SWT.ICON_CANCEL); |
759 | 777 | searchIn.setToolTipText(Messages.QuickSearchDialog_InTooltip); |
760 | 778 | GridDataFactory.fillDefaults().grab(true, false).indent(5, 0).applyTo(searchIn); |
761 | 779 |
|
|
0 commit comments