Skip to content
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

Implement filter-based TableViewer as a counterpart to the FilteredTree #2567

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ptziegler
Copy link
Contributor

@ptziegler ptziegler commented Dec 2, 2024

Projects such as PDE currently use the FilteredTree in combination with a child-less ITreeContentProvider to simulate a filtered table. This approach brings a big performance overhead, as the tree still has to handle functionality such as expansion and contraction of the (flat) tree structure which especially large trees/tables causes a significant overhead.

@ptziegler
Copy link
Contributor Author

ptziegler commented Dec 2, 2024

See eclipse-pde/eclipse.pde#1497 for a potential use-case.

Note: This also works with virtual tables:

recording.webm

@vogella
Copy link
Contributor

vogella commented Dec 2, 2024

Did you also consider the FilteredTree from the E4 package? This way this class could also be used in pure e4 rcp apps.

@ptziegler
Copy link
Contributor Author

Did you also consider the FilteredTree from the E4 package? This way this class could also be used in pure e4 rcp apps.

Not for the time being. And looking at it, it really is just a copy-paste of the E3 class. So ideally, I'd like to get some feedback on the current implementation before I repeat the same for the E4 one.

@vogella
Copy link
Contributor

vogella commented Dec 2, 2024

IIRC we copied it and removed the E3 reference (IIRC the help system) and added the option to enable/ disable the filter at runtime.

If it's functionality is the same I think we should only add one class ( to the E4 package so that it can be used in ide and E4 RCP).

Copy link
Contributor

github-actions bot commented Dec 2, 2024

Test Results

 1 821 files  +3   1 821 suites  +3   1h 27m 3s ⏱️ -54s
 7 716 tests +1   7 488 ✅ +2  228 💤 ±0  0 ❌  - 1 
24 309 runs  +3  23 560 ✅ +4  749 💤 ±0  0 ❌  - 1 

Results for commit 1354ba4. ± Comparison against base commit 3eaaeb6.

♻️ This comment has been updated with latest results.

@ptziegler
Copy link
Contributor Author

Is there an E4 counterpart for the TextMatcher? Would it perhaps make sense to move it to e.g. org.eclipse.text?

@ptziegler ptziegler marked this pull request as draft December 2, 2024 20:39
@vogella
Copy link
Contributor

vogella commented Dec 3, 2024

Is there an E4 counterpart for the TextMatcher? Would it perhaps make sense to move it to e.g. org.eclipse.text?

I'm not aware of an e4 counterpart. Would be great to move this to an API package that everyone can use.

@laeubi
Copy link
Contributor

laeubi commented Dec 3, 2024

Is there an E4 counterpart for the TextMatcher? Would it perhaps make sense to move it to e.g. org.eclipse.text?

I'm not aware of an e4 counterpart. Would be great to move this to an API package that everyone can use.

By the way it is confusing to talk about E3/E4 "counterparts" here as these are completely independent from the used technique (e.g. it does not require any DI at all nor does it requires E3 extension points). So making the class somewhere more generic available would be beneficial and as it is a final class let the "old" extend the "new" should work flawlessly.

*
* @since 3.135
*/
public non-sealed class FilteredTable extends AbstractFilteredViewer {
Copy link
Contributor

@laeubi laeubi Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an idea but maybe having a JFace FilteredTableViewer could be a better place for this so it can be used even outside of Eclipse Platform in SWT/JFace Applications.

Maybe even one can abstract the whole thing to use a StructuredViewer then it can be used with any table/tree/grid ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an idea but maybe having a JFace FilteredTableViewer could be a better place for this so it can be used even outside of Eclipse Platform in SWT/JFace Applications.

The FilteredTable/FilteredTree depend on the WorkbenchJob/BasicUIJob, so there is an inherent dependency to the E3/E4 workbench, which effectively prevents them to be moved to JFace.

Though it might be possible to specify a plain Job in the abstract base class and then have the implementations provide their respective instances... This would at the very least avoid the code duplication.

Maybe even one can abstract the whole thing to use a StructuredViewer then it can be used with any table/tree/grid ...

The base class only specifies a ColumnViewer but one could probably go even lower...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it a little bit more and in general, it still holds that the dependency to the Eclipse runtime prevents those filters to be moved to org.eclipse.jface. However, it would be possible to move them to e.g. org.eclipse.jface.text. I'm certainly not a huge fan of having a separate copy specifically for pure E4 applications. wdyt?

@vogella
Copy link
Contributor

vogella commented Dec 3, 2024

By the way it is confusing to talk about E3/E4 "counterparts"

It is not, new elements which can be used in E3 and pure E4 must of have dependencies to the old workbench implementation, as the e3 initialization code does not run in pure E4.

@laeubi
Copy link
Contributor

laeubi commented Dec 3, 2024

It is not, new elements which can be used in E3 and pure E4 must of have dependencies to the old workbench implementation, as the e3 initialization code does not run in pure E4.

Them mentioned class do not have any dependencies to a (E3 or E4) workbench as far as I can see...

@ptziegler
Copy link
Contributor Author

In principle, the TextMatcher class should work regardless of whether an E3 or E4 workbench is used. I've therefore moved the class from org.eclipse.ui.workbench to org.eclipse.jface.text. The same is true for the abstract base class I've created for the FilteredTable/Tree, so that I don't have to duplicate the implementation for the E4 classes.

Though I still have to think about how to best adapt the E4 classes...

@eclipse-platform-bot
Copy link
Contributor

eclipse-platform-bot commented Dec 3, 2024

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

bundles/org.eclipse.e4.ui.workbench.swt/META-INF/MANIFEST.MF
bundles/org.eclipse.ui.views.log/META-INF/MANIFEST.MF
tests/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From 06c72e0eb15cdae0de05e76be08eda32ad309626 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <[email protected]>
Date: Fri, 6 Dec 2024 17:01:13 +0000
Subject: [PATCH] Version bump(s) for 4.35 stream


diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.workbench.swt/META-INF/MANIFEST.MF
index 82460de1c8..ce6c8ca9a4 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-SymbolicName: org.eclipse.e4.ui.workbench.swt;singleton:=true
-Bundle-Version: 0.17.600.qualifier
+Bundle-Version: 0.17.700.qualifier
 Bundle-Name: %pluginName
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.ui.views.log/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.views.log/META-INF/MANIFEST.MF
index ed0cb5c714..6c5780ce50 100644
--- a/bundles/org.eclipse.ui.views.log/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.ui.views.log/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %name
 Bundle-SymbolicName: org.eclipse.ui.views.log;singleton:=true
-Bundle-Version: 1.4.600.qualifier
+Bundle-Version: 1.4.700.qualifier
 Bundle-Activator: org.eclipse.ui.internal.views.log.Activator
 Bundle-Vendor: %provider-name
 Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
diff --git a/tests/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF
index 510688556a..e0b12814d6 100644
--- a/tests/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Plugin.name
 Bundle-SymbolicName: org.eclipse.jface.text.tests
-Bundle-Version: 3.13.700.qualifier
+Bundle-Version: 3.13.800.qualifier
 Bundle-Vendor: %Plugin.providerName
 Bundle-Localization: plugin
 Export-Package: 
-- 
2.47.1

Further information are available in Common Build Issues - Missing version increments.

@laeubi
Copy link
Contributor

laeubi commented Dec 4, 2024

Is there an E4 counterpart for the TextMatcher? Would it perhaps make sense to move it to e.g. org.eclipse.text?

Interestingly enough I found we already have org.eclipse.core.text.StringMatcher so maybe that's another place to put a generic TextMatcher ...

@ptziegler ptziegler marked this pull request as ready for review December 6, 2024 17:02
@ptziegler
Copy link
Contributor Author

Interestingly enough I found we already have org.eclipse.core.text.StringMatcher so maybe that's another place to put a generic TextMatcher ...

Given that this is an internal class in can be freely moved to wherever it's needed. But as far as I know, it's only used for UI stuff, so I don't think it makes sense to move it out of the UI repo.

@ptziegler
Copy link
Contributor Author

I've tought about this PR a little bit more and I'd like to split it into three parts:

  1. Move TextMatcher to Platform
  2. Move common components of the FilteredTree's into an abstract base class
  3. Implement a FilteredTable using this base class.

@HannesWell
Copy link
Member

  1. Move TextMatcher to Platform

I have probably oversaw something, but can you please explain why this is necessary?
org.eclipse.text doesn't have any UI dependency so using it in a non-UI app is perfectly fine. In fact there are already bundles, that reside in eclipse-platform that depend on it, like org.eclipse.core.filebuffers. The situation that org.eclipse.text is placed in platform-ui is indeed sub-optimal and misleading and that there are circular dependencies between platform and platform-ui is bad, but that's the situation and o.e.text is usable. IIRC there was even a discussion to move it.

@vogella
Copy link
Contributor

vogella commented Jan 7, 2025

@ptziegler with the Equinox change in, can you update this PR?

ptziegler added a commit to ptziegler/eclipse.platform.ui that referenced this pull request Jan 7, 2025
The functionality of the TextMatcher has been integrated in the
StringMatcher class from the Equinox bundle, which allows this class to
be used without a dependency to the Eclipse UI bundle.

Note: To get the same behavior as the TextMatcher, one needs to call
matchWords() instead of match(). Furthermore, the pattern needs to be
trimmed explicitly, where needed.

Contributes to
eclipse-platform#2567
ptziegler added a commit to ptziegler/eclipse.platform.ui that referenced this pull request Jan 7, 2025
The functionality of the TextMatcher has been integrated in the
StringMatcher class from the Equinox bundle, which allows this class to
be used without a dependency to the Eclipse UI bundle.

Note: To get the same behavior as the TextMatcher, one needs to call
matchWords() instead of match(). Furthermore, the pattern needs to be
trimmed explicitly, where needed.

Contributes to
eclipse-platform#2567
vogella pushed a commit that referenced this pull request Jan 8, 2025
The functionality of the TextMatcher has been integrated in the
StringMatcher class from the Equinox bundle, which allows this class to
be used without a dependency to the Eclipse UI bundle.

Note: To get the same behavior as the TextMatcher, one needs to call
matchWords() instead of match(). Furthermore, the pattern needs to be
trimmed explicitly, where needed.

Contributes to
#2567
ptziegler added a commit to ptziegler/eclipse.platform.ui that referenced this pull request Jan 14, 2025
This moves the duplicate code of the E3.x and E4.x based FilteredTree
class and moves it into an AbstractFilteredViewerComposite class located
in the JFace component.

The base class is currently only implementing a tree-based filter, but
is structured in such a way that it can easily be extended to also
support e.g. table-based filters.

Due to being unused, the following fields and methods have been marked
as deprecated:
- filterToolBar
- clearButtonControl
- updateToolbar(boolean)

Contributes to
eclipse-platform#2567
vogella pushed a commit that referenced this pull request Jan 15, 2025
This moves the duplicate code of the E3.x and E4.x based FilteredTree
class and moves it into an AbstractFilteredViewerComposite class located
in the JFace component.

The base class is currently only implementing a tree-based filter, but
is structured in such a way that it can easily be extended to also
support e.g. table-based filters.

Due to being unused, the following fields and methods have been marked
as deprecated:
- filterToolBar
- clearButtonControl
- updateToolbar(boolean)

Contributes to
#2567
@ptziegler ptziegler force-pushed the filtered-table branch 2 times, most recently from e78984c to 121a156 Compare January 20, 2025 20:02
@ptziegler ptziegler changed the title Implement filter-based table viewer via the new FilterTable class Implement filter-based TableViewer as a counterpart to the FilteredTree Jan 20, 2025
Comment on lines +1 to +11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.e4.ui.dialogs" version="2">
<resource path="src/org/eclipse/e4/ui/dialogs/filteredtree/FilteredTable.java" type="org.eclipse.e4.ui.dialogs.filteredtree.FilteredTable$NotifyingTableViewer">
<filter id="571473929">
<message_arguments>
<message_argument value="TableViewer"/>
<message_argument value="NotifyingTableViewer"/>
</message_arguments>
</filter>
</resource>
</component>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to handle the API warning because the UI bundles are implementing the JFace viewers directly (just like the existing FilteredTree does).
Reason being that the filter cache is not properly cleared when e.g. a node is no longer filtered. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=187200

Projects such as PDE currently use the FilteredTree in combination with
a child-less ITreeContentProvider to simulate a filtered table. This
approach brings a big performance overhead, as the tree still has to
handle functionality such as expansion and contraction of the (flat)
tree structure which especially large trees/tables causes a significant
overhead.
@ptziegler
Copy link
Contributor Author

That should hopefully be all. I've rebased everything and adapted the code to use the new API introduced in previous commits.

@vogella
Copy link
Contributor

vogella commented Jan 21, 2025

Could the new FilteredTable also live in the e4 bundle?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants