diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF b/tmf/org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF index 3ddb659da0..ac10727697 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF +++ b/tmf/org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-Vendor: %Bundle-Vendor -Bundle-Version: 9.1.2.qualifier +Bundle-Version: 9.2.0.qualifier Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.tracecompass.tmf.ui;singleton:=true Bundle-Activator: org.eclipse.tracecompass.internal.tmf.ui.Activator diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/pom.xml b/tmf/org.eclipse.tracecompass.tmf.ui/pom.xml index ab8e98c03c..9b6550ddd4 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/pom.xml +++ b/tmf/org.eclipse.tracecompass.tmf.ui/pom.xml @@ -20,7 +20,7 @@ org.eclipse.tracecompass.tmf.ui - 9.1.2-SNAPSHOT + 9.2.0-SNAPSHOT eclipse-plugin diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractSelectTreeViewer2.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractSelectTreeViewer2.java index 3a89939880..6740e36922 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractSelectTreeViewer2.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractSelectTreeViewer2.java @@ -220,7 +220,7 @@ public String getColumnText(Object element, int columnIndex) { * @param legendColumnIndex * index of the legend column (-1 if none) */ - private AbstractSelectTreeViewer2(Composite parent, TriStateFilteredCheckboxTree checkboxTree, + protected AbstractSelectTreeViewer2(Composite parent, TriStateFilteredCheckboxTree checkboxTree, int legendIndex, String id) { super(parent, checkboxTree.getViewer()); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractSelectTreeViewer3.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractSelectTreeViewer3.java new file mode 100644 index 0000000000..28c015abb1 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractSelectTreeViewer3.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2025 Hong Anh + * + * All rights reserved. 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 + *******************************************************************************/ + +package org.eclipse.tracecompass.tmf.ui.viewers.tree; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataProvider; +import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.dialogs.SpecificColumnPatternFilter; +import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.dialogs.TriStateFilteredCheckboxTree; + +/** + * An abstract tree viewer that supports selection with filtering capabilities. + * + * This viewer extends + * {@link AbstractSelectTreeViewer2} + * to allow filtering based on a specific column index. + * + * @author Hong Anh + * @since 9.2 + */ +public abstract class AbstractSelectTreeViewer3 extends AbstractSelectTreeViewer2 { + /** + * Constructor + * + * @param parent + * Parent composite + * @param legendIndex + * index of the legend column (-1 if none) + * @param id + * {@link ITmfTreeDataProvider} ID + * @param indexColumnFilter + * the index of the column to apply the filter on + */ + public AbstractSelectTreeViewer3(Composite parent, int legendIndex, String id, int indexColumnFilter) { + // Initialize the tree viewer with a filtered checkbox tree and column-based filtering + super(parent, new TriStateFilteredCheckboxTree(parent, + SWT.MULTI | SWT.H_SCROLL | SWT.FULL_SELECTION, + new SpecificColumnPatternFilter(indexColumnFilter), true, false), legendIndex, id); + } +} diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/MultiTreePatternFilter.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/MultiTreePatternFilter.java index 73fb40826d..9a0490aeb8 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/MultiTreePatternFilter.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/MultiTreePatternFilter.java @@ -74,8 +74,8 @@ protected boolean isLeafMatch(Viewer viewer, Object element) { // Ensure the tree element and its parent(s) match the filter text for (Predicate p : fPredicates) { - // Retrieve tree element text and make verification. Text is at column 0 - String labelText = labelProvider.getColumnText(node, 0); + // Get the text of the element in the specified column and verify against the predicate + String labelText = labelProvider.getColumnText(node, this.getIndexColumnFilter()); if (labelText == null || !p.test(labelText)) { return false; } @@ -85,4 +85,13 @@ protected boolean isLeafMatch(Viewer viewer, Object element) { } return true; } + + /** + * Returns the index of the column used for filtering. + * @return the column index (default is 0) + * @since 9.2 + */ + protected int getIndexColumnFilter() { + return 0; + } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/SpecificColumnPatternFilter.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/SpecificColumnPatternFilter.java new file mode 100644 index 0000000000..bf7d16dab4 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/SpecificColumnPatternFilter.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2025 Hong Anh + * + * All rights reserved. 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 + *******************************************************************************/ + +package org.eclipse.tracecompass.tmf.ui.widgets.timegraph.dialogs; + + +/** + * A filter that extends {@link MultiTreePatternFilter} to allow filtering + * based on a specific column index. + * + * This implementation enables users to apply multiple patterns (separated by '/') + * while specifying which column of the tree should be used for matching. + * + * @author Hong Anh + * @since 9.2 + */ + +public class SpecificColumnPatternFilter extends MultiTreePatternFilter { + private int index = 0; + + /** + * Creates a new filter with the specified column index. + * @param indexColumnFilter the index of the column to apply the filter on + */ + + public SpecificColumnPatternFilter(int indexColumnFilter) { + this.index = indexColumnFilter; + } + + /** + * Returns the index of the column used for filtering. + * @return the column index specified during construction + */ + @Override + protected int getIndexColumnFilter() { + return this.index; + } +}