Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Reckord2018-08-20 09:19:19 +0000
committerCarsten Reckord2018-08-20 12:31:51 +0000
commitdc45f5b744c7ec545dd5cc3b1dce0d4747e3c6b6 (patch)
tree60d5c68842a7985ec41d10226452d1fbd4af1588 /bundles/org.eclipse.ui.workbench
parent154a81d904a73eeef9ea91b2094ac61b1c1fa6bf (diff)
downloadeclipse.platform.ui-dc45f5b744c7ec545dd5cc3b1dce0d4747e3c6b6.tar.gz
eclipse.platform.ui-dc45f5b744c7ec545dd5cc3b1dce0d4747e3c6b6.tar.xz
eclipse.platform.ui-dc45f5b744c7ec545dd5cc3b1dce0d4747e3c6b6.zip
Bug 537967 - [Quick Access] Commands not matched by descriptionI20180820-2000
Use new getMatchLabel() to get the text to match elements against. With the changes for preference pages, previous getLabel() and getSortLabel() had a target conflict regarding matching vs sorting vs display. The cleanest way to match against not displayed text seems to be to make the match string explicit instead of reusing these methods. Change-Id: I15ea22475d25e8007bcd1ae5663cbc6431cb508d Signed-off-by: Carsten Reckord <reckord@yatta.de>
Diffstat (limited to 'bundles/org.eclipse.ui.workbench')
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/PreferenceElement.java10
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessElement.java34
2 files changed, 29 insertions, 15 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/PreferenceElement.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/PreferenceElement.java
index 5c62ddb7e18..700c0a0b7ba 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/PreferenceElement.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/PreferenceElement.java
@@ -31,7 +31,7 @@ public class PreferenceElement extends QuickAccessElement {
private String prefix;
- private String sortLabelCache;
+ private String matchLabelCache;
/* package */PreferenceElement(IPreferenceNode preferenceNode, String prefix, PreferenceProvider preferenceProvider) {
super(preferenceProvider);
@@ -75,8 +75,8 @@ public class PreferenceElement extends QuickAccessElement {
}
@Override
- public String getSortLabel() {
- if (this.sortLabelCache == null) {
+ public String getMatchLabel() {
+ if (this.matchLabelCache == null) {
StringBuilder builder = new StringBuilder();
builder.append(super.getSortLabel());
if (preferenceNode instanceof WorkbenchPreferenceExtensionNode) {
@@ -85,9 +85,9 @@ public class PreferenceElement extends QuickAccessElement {
builder.append(label);
});
}
- this.sortLabelCache = builder.toString();
+ this.matchLabelCache = builder.toString();
}
- return this.sortLabelCache;
+ return this.matchLabelCache;
}
@Override
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessElement.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessElement.java
index be541809150..8478229e25a 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessElement.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessElement.java
@@ -74,6 +74,20 @@ public abstract class QuickAccessElement {
}
/**
+ * Return the label to be used for matching elements. The match string can
+ * contain additional text that should result in a match, but isn't shown in the
+ * quick access UI.
+ * <p>
+ * The match label should always be either identical to or a superset of the
+ * actual {@link #getLabel() label}.
+ *
+ * @return the match label
+ */
+ public String getMatchLabel() {
+ return getLabel();
+ }
+
+ /**
* @return Returns the provider.
*/
public QuickAccessProvider getProvider() {
@@ -176,14 +190,14 @@ public abstract class QuickAccessElement {
*/
public QuickAccessEntry match(String filter,
QuickAccessProvider providerForMatching) {
- String sortLabel = getSortLabel();
+ String matchLabel = getMatchLabel();
// first occurrence of filter
- int index = sortLabel.toLowerCase().indexOf(filter);
+ int index = matchLabel.toLowerCase().indexOf(filter);
if (index != -1) {
index = getLabel().toLowerCase().indexOf(filter);
if (index != -1) { // match actual label
- int quality = sortLabel.toLowerCase().equals(filter) ? QuickAccessEntry.MATCH_PERFECT
- : (sortLabel.toLowerCase().startsWith(filter) ? QuickAccessEntry.MATCH_EXCELLENT
+ int quality = matchLabel.toLowerCase().equals(filter) ? QuickAccessEntry.MATCH_PERFECT
+ : (matchLabel.toLowerCase().startsWith(filter) ? QuickAccessEntry.MATCH_EXCELLENT
: QuickAccessEntry.MATCH_GOOD);
return new QuickAccessEntry(this, providerForMatching,
new int[][] { { index, index + filter.length() - 1 } },
@@ -200,12 +214,12 @@ public abstract class QuickAccessElement {
// check for whitespaces
p = getWhitespacesPattern(filter);
}
- Matcher m = p.matcher(sortLabel);
+ Matcher m = p.matcher(matchLabel);
// if matches, return an entry
if (m.matches()) {
// and highlight match on the label only
String label = getLabel();
- if (!sortLabel.equals(label)) {
+ if (!matchLabel.equals(label)) {
m = p.matcher(getLabel());
if (!m.matches()) {
return new QuickAccessEntry(this, providerForMatching, EMPTY_INDICES, EMPTY_INDICES,
@@ -226,9 +240,9 @@ public abstract class QuickAccessElement {
EMPTY_INDICES, quality );
}
//
- String combinedSortLabel = (providerForMatching.getName() + " " + getSortLabel()); //$NON-NLS-1$
+ String combinedMatchLabel = (providerForMatching.getName() + " " + getMatchLabel()); //$NON-NLS-1$
String combinedLabel = (providerForMatching.getName() + " " + getLabel()); //$NON-NLS-1$
- index = combinedSortLabel.toLowerCase().indexOf(filter);
+ index = combinedMatchLabel.toLowerCase().indexOf(filter);
if (index != -1) { // match
index = combinedLabel.toLowerCase().indexOf(filter);
if (index != -1) { // compute highlight on label
@@ -249,7 +263,7 @@ public abstract class QuickAccessElement {
String camelCase = CamelUtil.getCamelCase(getLabel()); // use actual label for camelcase
index = camelCase.indexOf(filter);
if (index != -1) {
- int[][] indices = CamelUtil.getCamelCaseIndices(sortLabel, index, filter
+ int[][] indices = CamelUtil.getCamelCaseIndices(matchLabel, index, filter
.length());
return new QuickAccessEntry(this, providerForMatching, indices,
EMPTY_INDICES,
@@ -266,7 +280,7 @@ public abstract class QuickAccessElement {
return new QuickAccessEntry(
this,
providerForMatching,
- CamelUtil.getCamelCaseIndices(sortLabel, 0, lengthOfElementMatch),
+ CamelUtil.getCamelCaseIndices(matchLabel, 0, lengthOfElementMatch),
CamelUtil.getCamelCaseIndices(providerForMatching.getName(),
index,
filter.length() - lengthOfElementMatch),

Back to the top