|  | 
| 58 | 58 | import org.eclipse.jface.resource.JFaceResources; | 
| 59 | 59 | import org.eclipse.jface.text.BadLocationException; | 
| 60 | 60 | import org.eclipse.jface.text.CursorLinePainter; | 
|  | 61 | +import org.eclipse.jface.text.Document; | 
| 61 | 62 | import org.eclipse.jface.text.IDocument; | 
| 62 | 63 | import org.eclipse.jface.text.IRegion; | 
| 63 | 64 | import org.eclipse.jface.text.source.CompositeRuler; | 
| @@ -688,7 +689,6 @@ private Label createLabels(Composite parent) { | 
| 688 | 689 | 		progressLabel = new Label(labels, SWT.RIGHT); | 
| 689 | 690 | 		gd = new GridData(GridData.FILL_HORIZONTAL); | 
| 690 | 691 | 		progressLabel.setLayoutData(gd); | 
| 691 |  | -		createButton(labels, REFRESH_BUTTON_ID, Messages.QuickSearchDialog_Refresh, false); | 
| 692 | 692 | 
 | 
| 693 | 693 | 		labels.setLayoutData(gd); | 
| 694 | 694 | 		return listLabel; | 
| @@ -813,14 +813,20 @@ public void getName(AccessibleEvent e) { | 
| 813 | 813 | 		GridDataFactory.fillDefaults().span(6,1).grab(true, false).applyTo(pattern); | 
| 814 | 814 | 
 | 
| 815 | 815 | 		Composite searchInComposite = createNestedComposite(inputRow, 2, false); | 
| 816 |  | -		GridDataFactory.fillDefaults().span(4,1).grab(true, false).applyTo(searchInComposite); | 
|  | 816 | +		GridDataFactory.fillDefaults().span(3,1).grab(true, false).applyTo(searchInComposite); | 
| 817 | 817 | 		Label searchInLabel = new Label(searchInComposite, SWT.NONE); | 
| 818 | 818 | 		searchInLabel.setText(Messages.QuickSearchDialog_In); | 
| 819 | 819 | 		GridDataFactory.swtDefaults().indent(5, 0).applyTo(searchInLabel); | 
| 820 | 820 | 		searchIn = new Combo(searchInComposite, SWT.SINGLE | SWT.BORDER | SWT.ICON_CANCEL); | 
| 821 | 821 | 		searchIn.setToolTipText(Messages.QuickSearchDialog_InTooltip); | 
| 822 | 822 | 		GridDataFactory.fillDefaults().grab(true, false).indent(5, 0).applyTo(searchIn); | 
| 823 | 823 | 
 | 
|  | 824 | +		// Refresh button next to pattern field towards extreme right | 
|  | 825 | +		Button refreshButton = new Button(inputRow, SWT.PUSH); | 
|  | 826 | +		refreshButton.setText(Messages.QuickSearchDialog_Refresh); | 
|  | 827 | +		GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(false, false).applyTo(refreshButton); | 
|  | 828 | +		refreshButton.addListener(SWT.Selection, e -> refreshButtonPressed()); | 
|  | 829 | + | 
| 824 | 830 | 		listLabel = createLabels(content); | 
| 825 | 831 | 
 | 
| 826 | 832 | 		sashForm = new SashForm(content, SWT.VERTICAL); | 
| @@ -1173,6 +1179,9 @@ private void refreshDetails() { | 
| 1173 | 1179 | 							viewer.revealRange(rangeStart, rangeEnd - rangeStart); | 
| 1174 | 1180 | 
 | 
| 1175 | 1181 | 							var targetLineFirstMatch = getQuery().findFirst(document.get(item.getOffset(), contextLenght - (item.getOffset() - start))); | 
|  | 1182 | +							if (targetLineFirstMatch == null) { | 
|  | 1183 | +							    return; // nothing to refresh | 
|  | 1184 | +							} | 
| 1176 | 1185 | 							int targetLineFirstMatchStart = item.getOffset() + targetLineFirstMatch.getOffset(); | 
| 1177 | 1186 | 							// sets caret position | 
| 1178 | 1187 | 							viewer.setSelectedRange(targetLineFirstMatchStart, 0); | 
| @@ -1289,6 +1298,10 @@ public void refreshWidgets() { | 
| 1289 | 1298 | 				//element is available in the list. | 
| 1290 | 1299 | 				openButton.setEnabled(itemCount>0); | 
| 1291 | 1300 | 			} | 
|  | 1301 | +			//Auto-select the first search result for preview to be shown. | 
|  | 1302 | +			if (itemCount >= 1 && list.getSelection().isEmpty()) { | 
|  | 1303 | +	            list.getTable().select(0); | 
|  | 1304 | +	        } | 
| 1292 | 1305 | 			refreshDetails(); | 
| 1293 | 1306 | 		} | 
| 1294 | 1307 | 	} | 
| @@ -1484,6 +1497,14 @@ public void update(LineItem match) { | 
| 1484 | 1497 | 		} else { | 
| 1485 | 1498 | 			//The QuickTextSearcher is already active update the query | 
| 1486 | 1499 | 			this.searcher.setQuery(newFilter, force); | 
|  | 1500 | +			if(newFilter.getPatternString().trim().isEmpty()) { | 
|  | 1501 | +				//When pattern is cleared, clear the preview section | 
|  | 1502 | +				viewer.setDocument(new Document("")); //$NON-NLS-1$ | 
|  | 1503 | +			    if (lineNumberColumn != null) { | 
|  | 1504 | +			        viewer.removeVerticalRulerColumn(lineNumberColumn); | 
|  | 1505 | +			        viewer.addVerticalRulerColumn(lineNumberColumn); | 
|  | 1506 | +			    } | 
|  | 1507 | +			} | 
| 1487 | 1508 | 		} | 
| 1488 | 1509 | 		if (progressJob!=null) { | 
| 1489 | 1510 | 			progressJob.schedule(); | 
|  | 
0 commit comments