|
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; |
|
41 | 42 | import org.eclipse.jface.action.IMenuManager; |
42 | 43 | import org.eclipse.jface.action.LegacyActionTools; |
43 | 44 | import org.eclipse.jface.action.MenuManager; |
| 45 | +import org.eclipse.jface.dialogs.DialogSettings; |
44 | 46 | import org.eclipse.jface.dialogs.IDialogConstants; |
45 | 47 | import org.eclipse.jface.dialogs.IDialogSettings; |
46 | 48 | import org.eclipse.jface.layout.GridDataFactory; |
|
83 | 85 | import org.eclipse.swt.layout.GridData; |
84 | 86 | import org.eclipse.swt.layout.GridLayout; |
85 | 87 | import org.eclipse.swt.widgets.Button; |
| 88 | +import org.eclipse.swt.widgets.Combo; |
86 | 89 | import org.eclipse.swt.widgets.Composite; |
87 | 90 | import org.eclipse.swt.widgets.Control; |
88 | 91 | import org.eclipse.swt.widgets.Display; |
@@ -369,7 +372,7 @@ public void update(ViewerCell cell) { |
369 | 372 | private Label headerLabel; |
370 | 373 |
|
371 | 374 | private IWorkbenchWindow window; |
372 | | - private Text searchIn; |
| 375 | + private Combo searchIn; |
373 | 376 | private Label listLabel; |
374 | 377 |
|
375 | 378 | /** |
@@ -409,16 +412,20 @@ public void create() { |
409 | 412 | */ |
410 | 413 | protected void restoreDialog(IDialogSettings settings) { |
411 | 414 | try { |
412 | | - if (initialPatternText==null) { |
413 | | - String lastSearch = settings.get(DIALOG_LAST_QUERY); |
| 415 | + DialogSettings dialogSettings = (DialogSettings) settings; |
| 416 | + |
| 417 | + if (initialPatternText==null && dialogSettings.getLastSearches() != null) { |
| 418 | + String lastSearch = dialogSettings.getLastSearches().getFirst()[0]; |
| 419 | + |
414 | 420 | if (lastSearch==null) { |
415 | 421 | lastSearch = EMPTY_STRING; |
416 | 422 | } |
417 | 423 | pattern.setText(lastSearch); |
418 | 424 | pattern.selectAll(); |
419 | 425 | } |
420 | | - if (settings.get(DIALOG_PATH_FILTER)!=null) { |
421 | | - String filter = settings.get(DIALOG_PATH_FILTER); |
| 426 | + if (dialogSettings.getLastSearches() != null && dialogSettings.getLastSearches().getFirst()[1]!=null ) { |
| 427 | + String filter = dialogSettings.getLastSearches().getFirst()[1]; |
| 428 | + searchIn.setItems(searchInStrings(dialogSettings.getLastSearches())); |
422 | 429 | searchIn.setText(filter); |
423 | 430 | } |
424 | 431 |
|
@@ -452,6 +459,14 @@ protected void restoreDialog(IDialogSettings settings) { |
452 | 459 | } |
453 | 460 | } |
454 | 461 |
|
| 462 | + private String[] searchInStrings (List<String[]> list) { |
| 463 | + String[] strings = new String[list.size()]; |
| 464 | + for(int i = 0; i < list.size(); i++) { |
| 465 | + strings[i] = list.get(i)[1]; |
| 466 | + } |
| 467 | + return strings; |
| 468 | + } |
| 469 | + |
455 | 470 | private class ToggleKeepOpenAction extends Action { |
456 | 471 | public ToggleKeepOpenAction(IDialogSettings settings) { |
457 | 472 | super( |
@@ -531,9 +546,9 @@ public boolean close() { |
531 | 546 | * settings used to store dialog |
532 | 547 | */ |
533 | 548 | 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()); |
| 549 | + DialogSettings dialogSettings = (DialogSettings) settings; |
| 550 | + dialogSettings.inputNewSearch(pattern.getText(), searchIn.getText()); |
| 551 | + |
537 | 552 | if (toggleCaseSensitiveAction!=null) { |
538 | 553 | settings.put(CASE_SENSITIVE, toggleCaseSensitiveAction.isChecked()); |
539 | 554 | } |
@@ -755,7 +770,7 @@ public void getName(AccessibleEvent e) { |
755 | 770 | Label searchInLabel = new Label(searchInComposite, SWT.NONE); |
756 | 771 | searchInLabel.setText(Messages.QuickSearchDialog_In); |
757 | 772 | GridDataFactory.swtDefaults().indent(5, 0).applyTo(searchInLabel); |
758 | | - searchIn = new Text(searchInComposite, SWT.SINGLE | SWT.BORDER | SWT.ICON_CANCEL); |
| 773 | + searchIn = new Combo(searchInComposite, SWT.SINGLE | SWT.BORDER | SWT.ICON_CANCEL); |
759 | 774 | searchIn.setToolTipText(Messages.QuickSearchDialog_InTooltip); |
760 | 775 | GridDataFactory.fillDefaults().grab(true, false).indent(5, 0).applyTo(searchIn); |
761 | 776 |
|
|
0 commit comments