Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bundles/org.eclipse.ui.ide/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.20.0,4.0.0)";resol
org.eclipse.e4.ui.ide;bundle-version="[3.15.0,4.0.0)";visibility:=reexport,
org.eclipse.e4.core.di;bundle-version="[1.9.0,2.0.0)",
org.eclipse.e4.core.di.extensions;bundle-version="[0.18.0,1.0.0)",
org.eclipse.e4.ui.dialogs;bundle-version="[1.7.0,2.0.0)",
org.eclipse.ui.navigator;bundle-version="3.12.0"
Import-Package: jakarta.annotation;version="[2.0.0,4.0.0)",
jakarta.inject;version="[2.0.0,3.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ public class ExtendedMarkersView extends ViewPart {

private MarkersTreeViewer viewer;

/**
* Hosts {@link #viewer} and provides the search box used to filter the shown
* markers.
*/
private MarkersFilteredTree filteredTree;

private Action filterAction;

/**
Expand Down Expand Up @@ -258,8 +264,12 @@ private void addMarkers(MarkerSupportItem markerItem, Collection<IMarker> allMar
private void createViewer(Composite parent) {
parent.setLayout(new FillLayout());

viewer = new MarkersTreeViewer(new Tree(parent, SWT.H_SCROLL
/*| SWT.VIRTUAL */| SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION));
filteredTree = new MarkersFilteredTree(parent,
SWT.H_SCROLL /* | SWT.VIRTUAL */ | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION,
new MarkerPatternFilter(this));
filteredTree.setInitialText(MarkerMessages.MarkerView_searchFilterInitialText);

viewer = (MarkersTreeViewer) filteredTree.getViewer();
WorkbenchViewerSetup.setupViewer(viewer);
viewer.getTree().setLinesVisible(true);
viewer.setUseHashlookup(true);
Expand Down Expand Up @@ -1485,6 +1495,17 @@ TreeViewer getViewer() {
return viewer;
}

/**
* Returns the {@link MarkersFilteredTree} hosting {@link #getViewer() the
* viewer}, which provides the search box used to filter the shown markers.
*
* @return the filtered tree, or <code>null</code> if the view controls were
* not created yet
*/
MarkersFilteredTree getFilteredTree() {
return filteredTree;
}

/**
* The method should not be called directly, see
* {@link MarkerUpdateScheduler}
Expand Down
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);
}
}
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

View check run for this annotation

Jenkins - Eclipse Platform / Compiler

Name Shadowing Conflict

NORMAL: The parameter parent is hiding a field from type AbstractFilteredViewerComposite

Copy link
Copy Markdown
Member

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.

// 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public class MarkerMessages extends NLS {
public static String MarkerView_refreshing_counts;
public static String MarkerView_queueing_updates;
public static String MarkerView_processUpdates;
public static String MarkerView_searchFilterInitialText;

public static String MarkerView_18;
public static String MarkerView_19;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ MarkerView_waiting_on_changes=Waiting for workspace changes to finish
MarkerView_searching_for_markers=Searching for markers
MarkerView_refreshing_counts=Refreshing marker counts
MarkerView_queueing_updates=Queueing viewer updates
MarkerView_searchFilterInitialText=type filter text

MarkerView_18=Filtering on marker limit
MarkerView_19=Refreshing view
Expand Down
Loading