Skip to content

Commit 532c0fb

Browse files
ptzieglerHannesWell
authored andcommitted
Restore ability to filter views by category
The ability to sort by categories was previously possible, but broke as part of 7275893. This seems to be unintentional, given that the linked bug [1] is about exposing the FilteredTree and likely a result of streamlining the implementation. [1] - https://bugs.eclipse.org/bugs/show_bug.cgi?id=74795 Fixes #2576
1 parent 816a056 commit 532c0fb

File tree

2 files changed

+10
-31
lines changed

2 files changed

+10
-31
lines changed

bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ViewPatternFilter.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2019 IBM Corporation and others.
2+
* Copyright (c) 2005, 2024 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
@@ -14,6 +14,7 @@
1414
*******************************************************************************/
1515
package org.eclipse.e4.ui.workbench.swt.internal.copy;
1616

17+
import java.util.stream.Stream;
1718
import org.eclipse.e4.core.contexts.IEclipseContext;
1819
import org.eclipse.e4.ui.dialogs.filteredtree.PatternFilter;
1920
import org.eclipse.e4.ui.model.LocalizationHelper;
@@ -42,20 +43,8 @@ public boolean isElementSelectable(Object element) {
4243

4344
@Override
4445
protected boolean isLeafMatch(Viewer viewer, Object element) {
45-
if (element instanceof String) {
46-
return false;
47-
}
48-
49-
String text = null;
50-
if (element instanceof MPartDescriptor) {
51-
MPartDescriptor desc = (MPartDescriptor) element;
52-
text = LocalizationHelper.getLocalized(desc.getLabel(), desc,
53-
context);
54-
if (wordMatches(text)) {
55-
return true;
56-
}
57-
}
58-
59-
return false;
46+
return element instanceof MPartDescriptor desc && Stream.of(desc.getLabel(), desc.getCategory()) //
47+
.map(text -> LocalizationHelper.getLocalized(text, desc, context)) //
48+
.anyMatch(this::wordMatches);
6049
}
6150
}

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/dialogs/ViewPatternFilter.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2014 IBM Corporation and others.
2+
* Copyright (c) 2005, 2024 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
@@ -14,6 +14,7 @@
1414
*******************************************************************************/
1515
package org.eclipse.ui.internal.dialogs;
1616

17+
import java.util.stream.Stream;
1718
import org.eclipse.e4.ui.model.LocalizationHelper;
1819
import org.eclipse.e4.ui.model.application.descriptor.basic.MPartDescriptor;
1920
import org.eclipse.jface.viewers.Viewer;
@@ -34,19 +35,8 @@ public boolean isElementSelectable(Object element) {
3435

3536
@Override
3637
protected boolean isLeafMatch(Viewer viewer, Object element) {
37-
if (element instanceof String) {
38-
return false;
39-
}
40-
41-
String text = null;
42-
if (element instanceof MPartDescriptor) {
43-
MPartDescriptor desc = (MPartDescriptor) element;
44-
text = LocalizationHelper.getLocalized(desc.getLabel(), desc);
45-
if (wordMatches(text)) {
46-
return true;
47-
}
48-
}
49-
50-
return false;
38+
return element instanceof MPartDescriptor desc && Stream.of(desc.getLabel(), desc.getCategory()) //
39+
.map(text -> LocalizationHelper.getLocalized(text, desc)) //
40+
.anyMatch(this::wordMatches);
5141
}
5242
}

0 commit comments

Comments
 (0)