-
Notifications
You must be signed in to change notification settings - Fork 259
Filtered tree is implemented for Marker Support Views. #4208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
raghucssit
wants to merge
1
commit into
eclipse-platform:master
Choose a base branch
from
raghucssit:markers_view_filtered_tree
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...les/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerPatternFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 Advantest Europe GmbH and others. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * Raghunandana Murthappa - initial API and implementation | ||
| ******************************************************************************/ | ||
|
|
||
| package org.eclipse.ui.internal.views.markers; | ||
|
|
||
| import org.eclipse.e4.ui.dialogs.filteredtree.PatternFilter; | ||
| import org.eclipse.jface.viewers.Viewer; | ||
| import org.eclipse.ui.views.markers.MarkerField; | ||
| import org.eclipse.ui.views.markers.MarkerItem; | ||
|
|
||
| /** | ||
| * Matches a marker against the values of every field currently visible in a | ||
| * Markers view, so that typing in the view's search box filters the markers by | ||
| * any of the values shown in their columns (description, resource, path, | ||
| * location, type, ...). | ||
| */ | ||
| class MarkerPatternFilter extends PatternFilter { | ||
|
|
||
| private final ExtendedMarkersView view; | ||
|
|
||
| MarkerPatternFilter(ExtendedMarkersView view) { | ||
| this.view = view; | ||
| // so that a marker matches when the typed text occurs anywhere in one of | ||
| // its values, not only at the beginning of it | ||
| setIncludeLeadingWildcard(true); | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean isLeafMatch(Viewer viewer, Object element) { | ||
| if (!(element instanceof MarkerSupportItem item) || !item.isConcrete()) { | ||
| // categories are never a leaf match themselves, they stay visible | ||
| // through isParentMatch(...) as long as any of their markers match | ||
| return false; | ||
| } | ||
| for (MarkerField field : view.getVisibleFields()) { | ||
| if (matches(field, item)) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Returns whether the given item's value for the given field matches the | ||
| * current pattern. | ||
| */ | ||
| private boolean matches(MarkerField field, MarkerItem item) { | ||
| String value; | ||
| try { | ||
| value = field.getValue(item); | ||
| } catch (RuntimeException e) { | ||
| // a field can fail for markers it does not understand, or whose | ||
| // underlying resource vanished meanwhile - it simply does not match | ||
| // then, filtering must never break the view | ||
| return false; | ||
| } | ||
| return value != null && wordMatches(value); | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
...les/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersFilteredTree.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 Advantest Europe GmbH and others. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * Raghunandana Murthappa - initial API and implementation | ||
| ******************************************************************************/ | ||
|
|
||
| package org.eclipse.ui.internal.views.markers; | ||
|
|
||
| import org.eclipse.e4.ui.dialogs.filteredtree.FilteredTree; | ||
| import org.eclipse.e4.ui.dialogs.filteredtree.PatternFilter; | ||
| import org.eclipse.jface.viewers.TreeViewer; | ||
| import org.eclipse.swt.widgets.Composite; | ||
|
|
||
| /** | ||
| * A {@link FilteredTree} hosting the {@link MarkersTreeViewer} of a Markers | ||
| * view, so that the shown markers can be narrowed down with the search box | ||
| * displayed above the tree. | ||
| */ | ||
| class MarkersFilteredTree extends FilteredTree { | ||
|
|
||
| MarkersFilteredTree(Composite parent, int treeStyle, PatternFilter filter) { | ||
| super(parent, treeStyle, filter); | ||
| } | ||
|
|
||
| @Override | ||
| protected TreeViewer doCreateTreeViewer(Composite parent, int style) { | ||
|
Check warning on line 34 in bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersFilteredTree.java
|
||
| // the Markers views rely on their own viewer implementation, which | ||
| // among others clears the item caches while updating the UI | ||
| return new MarkersTreeViewer(parent, style); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename the parameter, see compiler warning below which fails the build validation.