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 table viewer via the new FilterTable class #2567

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ptziegler
Copy link
Contributor

@ptziegler ptziegler commented Dec 2, 2024

This moves the viewer-agnostic components of the FilterTree widget into
an AbstractFilteredStructuredViewer base class, which is then used to
implement the FilterTable widget.

The base class has been moved to org.eclipse.jface.text together with
the TextMatcher, to allow it to be used together with both an E3 and E4
workbench.

For the AbstractFilteredStructuredViewer, following methods have been
added to support this abstraction:

  • isShowFilterControls()
  • isQuickSelectionMode()
  • init(int)

For the FilteredTree, following fields and methods have been marked as
for-removal:

  • filterToolBar
  • clearButtonControl
  • updateToolbar(boolean)

To avoid code-duplication as a result of bug 260664, the code of
clearText() has been moved to a separate doClearText() method, so that
the same code can be invoked inside the listeners, without having to
worry about clearText() being overridden by subclasses.

This change adds a dependency from org.eclipse.jface.text to
org.eclipse.ui.workbench.

@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 214 files  + 1 214   1 214 suites  +1 214   1h 34m 10s ⏱️ + 1h 34m 10s
 7 729 tests + 7 729   7 498 ✅ + 7 498  231 💤 +231  0 ❌ ±0 
16 232 runs  +16 232  15 719 ✅ +15 719  513 💤 +513  0 ❌ ±0 

Results for commit 4f58c84. ± Comparison against base commit 7adb4ef.

♻️ 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...

@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 ...

This moves the viewer-agnostic components of the FilterTree widget into
an AbstractFilteredStructuredViewer base class, which is then used to
implement the FilterTable widget.

The base class has been moved to org.eclipse.jface.text together with
the TextMatcher, to allow it to be used together with both an E3 and E4
workbench.

For the AbstractFilteredStructuredViewer, following methods have been
added to support this abstraction:
- isShowFilterControls()
- isQuickSelectionMode()
- init(int)

For the FilteredTree, following fields and methods have been marked as
for-removal:
- filterToolBar
- clearButtonControl
- updateToolbar(boolean)

To avoid code-duplication as a result of bug 260664, the code of
clearText() has been moved to a separate doClearText() method, so that
the same code can be invoked inside the listeners, without having to
worry about clearText() being overridden by subclasses.

This change adds a dependency from org.eclipse.jface.text to
org.eclipse.ui.workbench.
@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.

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