summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimeon Andreev2018-09-07 09:00:58 -0400
committerJonah Graham2018-09-14 06:25:12 -0400
commita8a29d195a71321a76fa6e645411b663e3fede02 (patch)
tree72fb82da4787b719492f48aea80ac9ee7db45b3c
parent094543644b409d3fd939df9202373028c9fdefe0 (diff)
downloadorg.eclipse.cdt-a8a29d195a71321a76fa6e645411b663e3fede02.tar.gz
org.eclipse.cdt-a8a29d195a71321a76fa6e645411b663e3fede02.tar.xz
org.eclipse.cdt-a8a29d195a71321a76fa6e645411b663e3fede02.zip
Bug 538849 - Select Processes dialog filter field improvements
This change ensures that the Select Processes dialog remembers the filter field input. This helps attaching to the same application without having to input the filter text on each debug attach. Furthermore with this change its possible to match a process name with suffixes, without resorting to pattern matching symbols. E.g. match "Eclipse" by typing "lipse". Change-Id: I07a3bb1504f2f5e9626023d1097fcad78dfa9ac7 Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java
index 517ac691ef..fa146c5139 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java
@@ -27,7 +27,9 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.FilteredList;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.dialogs.SearchPattern;
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
/**
@@ -41,12 +43,57 @@ public class ProcessPrompterDialog extends TwoPaneElementSelector {
private static final String DIALOG_SETTINGS_SECTION_ID = "processPrompterDialog"; //$NON-NLS-1$
+ private static final String DIALOG_SETTINGS_FILTER_KEY = "filter"; //$NON-NLS-1$
+
+ private final ILabelProvider elementRenderer;
+
public ProcessPrompterDialog(Shell parent, ILabelProvider elementRenderer,
ILabelProvider qualifierRenderer) {
super(parent, elementRenderer, qualifierRenderer);
+ this.elementRenderer = elementRenderer;
setDialogBoundsSettings(getDialogBoundsSettings(), Dialog.DIALOG_PERSISTSIZE);
+ setFilter(getFilterFromDialogSetting());
}
+ @Override
+ protected FilteredList createFilteredList(Composite parent) {
+ FilteredList list = super.createFilteredList(parent);
+
+ list.setFilterMatcher(new FilteredList.FilterMatcher() {
+ private SearchPattern matcher;
+
+ @Override
+ public void setFilter(String pattern, boolean ignoreCase, boolean ignoreWildCards) {
+
+ if (pattern == null) {
+ pattern = ""; //$NON-NLS-1$
+ }
+
+ if (! pattern.startsWith("*")) { //$NON-NLS-1$
+ pattern = "*" + pattern; //$NON-NLS-1$
+ }
+
+ int rules = SearchPattern.RULE_BLANK_MATCH | SearchPattern.RULE_PREFIX_MATCH;
+ if (! ignoreCase) {
+ rules |= SearchPattern.RULE_CASE_SENSITIVE;
+ }
+
+ if (! ignoreWildCards) {
+ rules |= SearchPattern.RULE_PATTERN_MATCH;
+ }
+ matcher = new SearchPattern(rules);
+ matcher.setPattern(pattern);
+ }
+
+ @Override
+ public boolean match(Object element) {
+ return matcher.matches(elementRenderer.getText(element));
+ }
+ });
+
+ return list;
+ }
+
/*
* The result should be every selected element.
*/
@@ -127,6 +174,10 @@ public class ProcessPrompterDialog extends TwoPaneElementSelector {
@Override
protected IDialogSettings getDialogBoundsSettings() {
+ return getDialogSettings();
+ }
+
+ protected IDialogSettings getDialogSettings() {
IDialogSettings settings = GdbUIPlugin.getDefault().getDialogSettings();
IDialogSettings section = settings.getSection(DIALOG_SETTINGS_SECTION_ID);
if (section == null) {
@@ -134,4 +185,19 @@ public class ProcessPrompterDialog extends TwoPaneElementSelector {
}
return section;
}
+
+ private String getFilterFromDialogSetting() {
+ String filter = getDialogSettings().get(DIALOG_SETTINGS_FILTER_KEY);
+ return filter == null ? "" : filter; //$NON-NLS-1$
+ }
+
+ private void storeDialogSetting() {
+ getDialogSettings().put(DIALOG_SETTINGS_FILTER_KEY, getFilter());
+ }
+
+ @Override
+ public boolean close() {
+ storeDialogSetting();
+ return super.close();
+ }
}