Skip to content

Commit 5a5410b

Browse files
SougandhSlaeubi
authored andcommitted
Add Filter text support in Export Launch Configurations
This commit adds a filter text field that allows users to quickly find and select launch configurations without manually expanding all launch types or scrolling through the list.
1 parent 75b8bca commit 5a5410b

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2007, 2017 IBM Corporation and others.
2+
* Copyright (c) 2007, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -52,6 +52,8 @@
5252
import org.eclipse.jface.viewers.CheckboxTreeViewer;
5353
import org.eclipse.jface.viewers.IStructuredSelection;
5454
import org.eclipse.jface.viewers.ITreeContentProvider;
55+
import org.eclipse.jface.viewers.Viewer;
56+
import org.eclipse.jface.viewers.ViewerFilter;
5557
import org.eclipse.jface.wizard.WizardPage;
5658
import org.eclipse.swt.SWT;
5759
import org.eclipse.swt.events.SelectionAdapter;
@@ -155,12 +157,44 @@ public void createControl(Composite parent) {
155157
* @param parent the parent to add the check table viewer to
156158
*/
157159
protected void createViewer(Composite parent) {
160+
Text filterText = new Text(parent, SWT.SEARCH | SWT.CANCEL);
161+
filterText.setMessage(WizardMessages.ImportLaunchTypeToFilter);
162+
filterText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
163+
ViewerFilter filter = new ViewerFilter() {
164+
@Override
165+
public boolean select(Viewer viewer2, Object parentElement, Object element) {
166+
String search = filterText.getText().toLowerCase();
167+
if (search.isEmpty()) {
168+
fViewer.collapseAll();
169+
return true;
170+
}
171+
if (element instanceof ILaunchConfiguration launchConfig) {
172+
return launchConfig.getName().toLowerCase().contains(search);
173+
}
174+
if (element instanceof ILaunchConfigurationType launchConfigType) {
175+
try {
176+
for (ILaunchConfiguration config2 : lm.getLaunchConfigurations(launchConfigType)) {
177+
if (config2.getName().toLowerCase().contains(search)) {
178+
return true;
179+
}
180+
}
181+
} catch (Exception e) {
182+
DebugPlugin.log(e);
183+
return false;
184+
}
185+
return false;
186+
}
187+
return true;
188+
}
189+
};
158190
SWTFactory.createWrapLabel(parent, WizardMessages.ExportLaunchConfigurationsWizardPage_3, 2);
159191
Tree tree = new Tree(parent, SWT.BORDER | SWT.SINGLE | SWT.CHECK);
160192
GridData gd = new GridData(GridData.FILL_BOTH);
161193
gd.horizontalSpan = 2;
162194
tree.setLayoutData(gd);
163195
fViewer = new CheckboxTreeViewer(tree);
196+
fViewer.addFilter(filter);
197+
164198
fViewer.setLabelProvider(DebugUITools.newDebugModelPresentation());
165199
fViewer.setComparator(new WorkbenchViewerComparator());
166200
fContentProvider = new ConfigContentProvider();
@@ -206,6 +240,10 @@ public void widgetSelected(SelectionEvent e) {
206240
setPageComplete(isComplete());
207241
}
208242
});
243+
filterText.addModifyListener(e -> {
244+
fViewer.refresh();
245+
fViewer.expandAll();
246+
});
209247
}
210248

211249
/**

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/WizardMessages.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2008 IBM Corporation and others.
2+
* Copyright (c) 2005, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -46,6 +46,7 @@ public class WizardMessages extends NLS {
4646
public static String ImportLaunchConfigurationsWizardPage_5;
4747
public static String ImportLaunchConfigurationsWizardPage_6;
4848
public static String ImportLaunchConfigurationsWizardPage_7;
49+
public static String ImportLaunchTypeToFilter;
4950
static {
5051
// initialize resource bundle
5152
NLS.initializeMessages(BUNDLE_NAME, WizardMessages.class);

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/WizardMessages.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###############################################################################
2-
# Copyright (c) 2005, 2008 IBM Corporation and others.
2+
# Copyright (c) 2005, 2025 IBM Corporation and others.
33
#
44
# This program and the accompanying materials
55
# are made available under the terms of the Eclipse Public License 2.0
@@ -40,3 +40,4 @@ ImportLaunchConfigurationsWizardPage_4=You must select at least one configuratio
4040
ImportLaunchConfigurationsWizardPage_5=Import launch configurations from the local file system
4141
ImportLaunchConfigurationsWizardPage_6=From &Directory:
4242
ImportLaunchConfigurationsWizardPage_7=Brows&e...
43+
ImportLaunchTypeToFilter=Type filter text

0 commit comments

Comments
 (0)