From 5b644f63118bd5914b98cf24cfb907bc11e9427a Mon Sep 17 00:00:00 2001 From: Maximilian Wittmer Date: Fri, 27 Sep 2024 16:58:07 +0200 Subject: [PATCH 1/2] [QuickSearchDialog] remove commented-out code remove commented-out code thus improving code quality. --- .../internal/ui/QuickSearchDialog.java | 72 ------------------- 1 file changed, 72 deletions(-) diff --git a/bundles/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java b/bundles/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java index a2ddfbbef5b..43f77d75eb6 100644 --- a/bundles/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java +++ b/bundles/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java @@ -237,9 +237,6 @@ public void update(ViewerCell cell) { private Image getBlankImage() { if (blankImage==null) { blankImage = new Image(Display.getDefault(), 1, 1); -// GC gc = new GC(blankImage); -// gc.fillRectangle(0, 0, 16, 16); -// gc.dispose(); } return blankImage; } @@ -268,22 +265,6 @@ public void update(ViewerCell cell) { cell.setImage(getBlankImage()); super.update(cell); } - -// public String getToolTipText(Object element) { -// LineItem item = (LineItem) element; -// if (item!=null) { -// return ""+item.getFile().getFullPath(); -// } -// return ""; -// }; - -// public String getText(Object _item) { -// if (_item!=null) { -// LineItem item = (LineItem) _item; -// return item.getFile().getName().toString(); -// } -// return "?"; -// }; }; private static final String DIALOG_SETTINGS = QuickSearchDialog.class.getName()+".DIALOG_SETTINGS"; //$NON-NLS-1$ @@ -467,7 +448,6 @@ public ToggleKeepOpenAction(IDialogSettings settings) { @Override public void run() { - //setChecked(!isChecked()); } } @@ -489,7 +469,6 @@ public ToggleCaseSensitiveAction(IDialogSettings settings) { @Override public void run() { - //setChecked(!isChecked()); refreshHeaderLabel(); applyFilter(false); } @@ -505,7 +484,6 @@ public void run() { public boolean close() { this.progressJob.cancel(); this.progressJob = null; -// this.refreshProgressMessageJob.cancel(); if (showViewHandler != null) { IHandlerService service = PlatformUI .getWorkbench().getService(IHandlerService.class); @@ -766,7 +744,6 @@ public void getName(AccessibleEvent e) { list = new TableViewer(sashForm, (multi ? SWT.MULTI : SWT.SINGLE) | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL); -// ColumnViewerToolTipSupport.enableFor(list, ToolTip.NO_RECREATE); list.getTable().setHeaderVisible(true); list.getTable().setLinesVisible(true); @@ -781,8 +758,6 @@ public void getName(AccessibleEvent e) { } }); list.setContentProvider(contentProvider); -// new ScrollListener(list.getTable().getVerticalBar()); -// new SelectionChangedListener(list); TableViewerColumn col = new TableViewerColumn(list, SWT.RIGHT); col.setLabelProvider(LINE_NUMBER_LABEL_PROVIDER); @@ -1003,47 +978,6 @@ private StyledString highlightMatches(String visibleText) { return styledText; } -// Version using sourceviewer -// private void refreshDetails() { -// if (details!=null && list!=null && !list.getTable().isDisposed()) { -// if (documents==null) { -// documents = new DocumentFetcher(); -// } -// IStructuredSelection sel = (IStructuredSelection) list.getSelection(); -// if (sel!=null && !sel.isEmpty()) { -// //Not empty selection -// LineItem item = (LineItem) sel.getFirstElement(); -// IDocument document = documents.getDocument(item.getFile()); -// try { -// int line = item.getLineNumber()-1; //in document lines are 0 based. In search 1 based. -// int start = document.getLineOffset(Math.max(line-2, 0)); -// int end = document.getLength(); -// try { -// end = document.getLineOffset(line+3); -// } catch (BadLocationException e) { -// //Presumably line number is past the end of document. -// //ignore. -// } -// details.setDocument(document, start, end-start); -// -// String visibleText = document.get(start, end-start); -// List matches = getQuery().findAll(visibleText); -// Region visibleRegion = new Region(start, end-start); -// TextPresentation presentation = new TextPresentation(visibleRegion, 20); -// presentation.setDefaultStyleRange(new StyleRange(0, document.getLength(), null, null)); -// for (TextRange m : matches) { -// presentation.addStyleRange(new StyleRange(m.start+start, m.len, null, YELLOW)); -// } -// details.changeTextPresentation(presentation, true); -// -// return; -// } catch (BadLocationException e) { -// } -// } -// details.setDocument(null); -// } -// } - /** * Handle selection in the items list by updating labels of selected and * unselected items and refresh the details field using the selection. @@ -1121,8 +1055,6 @@ public void refreshWidgets() { */ public void scheduleRefresh() { refreshJob.schedule(); -// refreshCacheJob.cancelAll(); -// refreshCacheJob.schedule(); } /* @@ -1303,7 +1235,6 @@ public void update(LineItem match) { applyPathMatcher(); refreshWidgets(); } -// this.list.setInput(input) } else { //The QuickTextSearcher is already active update the query this.searcher.setQuery(newFilter, force); @@ -1344,9 +1275,6 @@ private class ContentProvider implements IStructuredContentProvider, ILazyConten */ public ContentProvider() { this.items = Collections.synchronizedList(new ArrayList(2048)); -// this.duplicates = Collections.synchronizedSet(new HashSet(256)); -// this.lastSortedItems = Collections.synchronizedList(new ArrayList( -// 2048)); } public void remove(LineItem match) { From f23bbd01286e670051b81288f397a47ec066cfe0 Mon Sep 17 00:00:00 2001 From: Maximilian Wittmer Date: Fri, 27 Sep 2024 17:43:13 +0200 Subject: [PATCH 2/2] [QuickSearchDialog] add history for "search in" --- .../org.eclipse.text.quicksearch/META-INF/MANIFEST.MF | 2 ++ .../quicksearch/internal/ui/QuickSearchDialog.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF b/bundles/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF index d656db96eda..20a1f099715 100644 --- a/bundles/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF @@ -26,5 +26,7 @@ Export-Package: org.eclipse.text.quicksearch.internal.core;x-internal:=true, Import-Package: org.eclipse.core.runtime;version="3.5.0", org.eclipse.core.runtime.jobs, org.eclipse.osgi.util;version="1.1.0", + org.eclipse.ui.internal.findandreplace, + org.eclipse.ui.internal.findandreplace.overlay, org.osgi.framework;version="1.9.0" Automatic-Module-Name: org.eclipse.text.quicksearch diff --git a/bundles/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java b/bundles/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java index 43f77d75eb6..12c4e5fde72 100644 --- a/bundles/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java +++ b/bundles/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java @@ -112,6 +112,8 @@ import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.internal.IWorkbenchGraphicConstants; import org.eclipse.ui.internal.WorkbenchImages; +import org.eclipse.ui.internal.findandreplace.HistoryStore; +import org.eclipse.ui.internal.findandreplace.overlay.HistoryTextWrapper; import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; import org.eclipse.ui.progress.UIJob; import org.osgi.framework.FrameworkUtil; @@ -350,7 +352,8 @@ public void update(ViewerCell cell) { private Label headerLabel; private IWorkbenchWindow window; - private Text searchIn; + private HistoryStore searchInHistory; + private HistoryTextWrapper searchIn; private Label listLabel; /** @@ -728,12 +731,14 @@ public void getName(AccessibleEvent e) { }); GridDataFactory.fillDefaults().span(6,1).grab(true, false).applyTo(pattern); + searchInHistory = new HistoryStore(getDialogSettings(), "searchinhistory", 5); //$NON-NLS-1$ + Composite searchInComposite = createNestedComposite(inputRow, 2, false); GridDataFactory.fillDefaults().span(4,1).grab(true, false).applyTo(searchInComposite); Label searchInLabel = new Label(searchInComposite, SWT.NONE); searchInLabel.setText(Messages.QuickSearchDialog_In); GridDataFactory.swtDefaults().indent(5, 0).applyTo(searchInLabel); - searchIn = new Text(searchInComposite, SWT.SINGLE | SWT.BORDER | SWT.ICON_CANCEL); + searchIn = new HistoryTextWrapper(searchInHistory, searchInComposite, SWT.SINGLE | SWT.BORDER | SWT.ICON_CANCEL); searchIn.setToolTipText(Messages.QuickSearchDialog_InTooltip); GridDataFactory.fillDefaults().grab(true, false).indent(5, 0).applyTo(searchIn); @@ -786,6 +791,7 @@ public void getName(AccessibleEvent e) { pattern.addModifyListener(e -> { applyFilter(false); + searchIn.storeHistory(); }); searchIn.addModifyListener(e -> {