Bug 400835 - Add search box to property sheet
Summary: Add search box to property sheet
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Simon Scholz CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2013-02-14 13:10 EST by Arieh Bibliowicz CLA
Modified: 2015-01-22 14:27 EST (History)
4 users (show)

See Also:


Attachments
PropertySheetViewer changes for gerrit CR (50.04 KB, application/octet-stream)
2014-02-05 16:06 EST, Arieh Bibliowicz CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arieh Bibliowicz CLA 2013-02-14 13:10:18 EST
It would be very cool to have a search box in the property sheet, just like the one in the preferences dialog. When a property sheet becomes large (for example EMF generator model properties), this could be very useful.
Comment 1 Lars Vogel CLA 2013-02-14 13:15:10 EST
Could you provide a patch for the suggested feature?
Comment 2 Paul Webster CLA 2013-02-15 15:29:08 EST
See http://wiki.eclipse.org/Platform_UI/How_to_Contribute

PW
Comment 3 Arieh Bibliowicz CLA 2013-02-17 05:01:40 EST
OK. Challenge taken :-)
Here is the functionality that I could implement:

https://github.com/vainolo/eclipse.platform.ui/tree/bug400835 
(clone of eclipse.platform.ui)

I created a new composite (FilterablePropertySheet) which contains a text-box for in which the user can enter the filter text. The property sheet pagebook is added to a composite below this text-box.
When the text in the text-box changes, the entries shown in the properties view change according to the text - only properties which contain the text in their display name or string value are displayed.
Would love to receive some feedback on the implementation. If this looks OK, I can extend it to manage regular expressions in the filter also.
Comment 4 Paul Webster CLA 2013-02-19 11:32:28 EST
(In reply to comment #3)
> OK. Challenge taken :-)
> Here is the functionality that I could implement:
> 
> https://github.com/vainolo/eclipse.platform.ui/tree/bug400835 
> (clone of eclipse.platform.ui)

Hi Arieh,

Some comments on your original implementation:

1) I wouldn't try and encapsulate the text box and label within FilterablePropertySheet.  The PropertySheet view should set that up within its createPartControl ... it can be grouped in a method call for clarity.

2) In the end the work has to be done by the PropertySheetViewer.  Have a look at org.eclipse.jface.viewers.StructuredViewer.setFilters(ViewerFilter[]), and the use of the ViewerFilter class.  This viewer only extends Viewer (so it's not already a structured viewer) but PropertySheetViewer should probably implement its filtering using the same/similar pattern as seen in StructuredViewer.

Thank you for your interest in this.

I'll just add that these are API classes, which means we can only add to them during M6 (the next 3 weeks or so) or after Kepler ships (July).

PW
Comment 5 Dani Megert CLA 2013-02-19 11:41:57 EST
(In reply to comment #4)
> I'll just add that these are API classes, which means we can only add to
> them during M6 (the next 3 weeks or so) or after Kepler ships (July).
> 
> PW

Also, I assume the patch will be larger than 250 lines, which means it needs an CQ. However, the deadline was last Friday for Kepler CQs. I suggest we take this slowly and target Kepler+1.
Comment 6 Lars Vogel CLA 2013-02-19 11:44:24 EST
Hi Arieh,

a bit more infos about Viewer filter can be found here:  http://www.vogella.com/articles/EclipseJFaceTableAdvanced/article.html#jfacetable_filter and http://www.vogella.com/articles/EclipseJFaceTableAdvanced/article.html#filtercontent

I think the example should be similar to your use case.
Comment 7 Lars Vogel CLA 2013-02-19 11:45:02 EST
Maybe you can make it under 250 lines... :-)
Comment 8 Paul Webster CLA 2013-02-19 11:54:26 EST
Another good place to start is org.eclipse.ui.dialogs.FilteredTree which is quite mature.

PW
Comment 9 Arieh Bibliowicz CLA 2013-02-20 03:55:53 EST
> 1) I wouldn't try and encapsulate the text box and label within
> FilterablePropertySheet.  The PropertySheet view should set that up within
> its createPartControl ... it can be grouped in a method call for clarity.

Do you mean doing this in PropertySheetViewer.java?
Comment 10 Arieh Bibliowicz CLA 2013-02-21 23:04:41 EST
Hi Everyone
Updated my solution to include only changes in the PropertySheetViewer.java file. A textbox was added above the property tree in which the user can enter the text to filter. I also added a "clear" button to clear the filter.

Some thoughts and answers to the comments made before:
1. While implementing a change similar to the functionality of a Structured viewer would be nice, it adds a lot of generic code to solve a specific problem. Does anyone think more filter types are going to the added in the future to this pane? if not, I don't think doing this is worth the time.
2. My implementation is very short (89 line changes overall), with no API changes.
3. I didn't add code to check if filtering is not needed (see the code in FilteredTree). I don't think this is necessary because it is a very small change, occupies little screen space and shouldn't bother anyone not using the feature.

Anyway, the updated code is again @github:
https://github.com/vainolo/eclipse.platform.ui/tree/a7c2ca2ab188c1fec47a7a6d3996b8a1139a4dee

Your comments are welcome

Arieh
Comment 11 Paul Webster CLA 2013-03-01 13:14:37 EST
Hi Arieh,

Thanks for the updated commit.  Some comments:

1) I get a compile error:

Description	Resource	Path	Location	Type
The method contains(String) is undefined for the type String	PropertySheetViewer.java	/org.eclipse.ui.views/src/org/eclipse/ui/views/properties	line 709	Java Problem

It's because the views plugin is compiled against J2SE-1.4.  You can see them as well, just go to Window>Preferences>Java>Installed JREs.  Add a JRE for each of 1.4, 1.5, 1.6, and 1.7.  Eclipse will then use the libraries from the appropriate JVM during compile

2) Please put braces around complex if statements as in org.eclipse.ui.views.properties.PropertySheetViewer.textFilteredEntries(List) ... preferrably around all if statements (it's our coding standard).

3) I get a ClassCastException in org.eclipse.ui.tests.multipageeditor.MultiPageEditorSelectionTest.testPropertiesView().  You've changed what getControl() returns (understandably) but internals might cast this to a Tree.  You would either have to search all callers of getControl(*) or still return the Tree contained within this viewer.

4) see how FilteredTree reacts to a ModifyListener in org.eclipse.ui.dialogs.FilteredTree.textChanged()

PW
Comment 12 Arieh Bibliowicz CLA 2013-03-11 16:08:32 EDT
Hi Paul for all the comments, and sorry for the time it took me to answer. Regarding your comments:

> 1) I get a compile error:
> 
> Description	Resource	Path	Location	Type
> The method contains(String) is undefined for the type String
> PropertySheetViewer.java
> /org.eclipse.ui.views/src/org/eclipse/ui/views/properties	line 709	Java
> Problem
> 
> It's because the views plugin is compiled against J2SE-1.4.  You can see
> them as well, just go to Window>Preferences>Java>Installed JREs.  Add a JRE
> for each of 1.4, 1.5, 1.6, and 1.7.  Eclipse will then use the libraries
> from the appropriate JVM during compile
> 

function contains(String) is supported since 1.5. Java 1.4 is EOL (as per the Oracle web site: http://www.oracle.com/technetwork/java/javase/index-jsp-138567.html). But anyway, changed my installed JRE and changed the code to match it (copied the implementation of contains from class String).

> 2) Please put braces around complex if statements as in
> org.eclipse.ui.views.properties.PropertySheetViewer.
> textFilteredEntries(List) ... preferrably around all if statements (it's our
> coding standard).

Done

> 
> 3) I get a ClassCastException in
> org.eclipse.ui.tests.multipageeditor.MultiPageEditorSelectionTest.
> testPropertiesView().  You've changed what getControl() returns
> (understandably) but internals might cast this to a Tree.  You would either
> have to search all callers of getControl(*) or still return the Tree
> contained within this viewer.

I think returning the tree is not a good option... It is just not right. I searched for references to the method and found a cast in the PropertySheetPage class (line 444). The only solution I could think of was to add a new method to the PropertySheetViewer that returns this tree and call this method from the PropertySheetPage. I made the method package scoped to limit its access. 
BTW, I tried running the tests but was unable to do so. Is there a guide somewhere where I can learn how to do this?

> 4) see how FilteredTree reacts to a ModifyListener in
> org.eclipse.ui.dialogs.FilteredTree.textChanged()

Sorry but I was unable to understand what I should get from there. If I understood it correctly, it uses an external job to manage refreshing of the list. Do you think this is needed here? isn't it an overkill?

Once again, thanks for your time and patience. The latest commit of the code is at:
https://github.com/vainolo/eclipse.platform.ui/tree/bug400835

Arieh
Comment 13 Paul Webster CLA 2013-03-11 19:32:30 EDT
(In reply to comment #12)
> > 
> > It's because the views plugin is compiled against J2SE-1.4.  You can see
> > them as well, just go to Window>Preferences>Java>Installed JREs.  Add a JRE
> > for each of 1.4, 1.5, 1.6, and 1.7.  Eclipse will then use the libraries
> > from the appropriate JVM during compile
> > 
> 
> function contains(String) is supported since 1.5. Java 1.4 is EOL (as per
> the Oracle web site:
> http://www.oracle.com/technetwork/java/javase/index-jsp-138567.html). But
> anyway, changed my installed JRE and changed the code to match it (copied
> the implementation of contains from class String).

We wouldn't be able to accept it if it's copied out of any GPLed or copyrighted classes.

But name.toLowerCase().indexOf(filter.toLowerCase())>=0 would be acceptable.  Could you check what you have and amend the commit?

Thanks for getting back to us.

PW
Comment 14 Arieh Bibliowicz CLA 2013-03-12 03:43:32 EDT
(In reply to comment #13)
> (In reply to comment #12)
> > > 
> > > It's because the views plugin is compiled against J2SE-1.4.  You can see
> > > them as well, just go to Window>Preferences>Java>Installed JREs.  Add a JRE
> > > for each of 1.4, 1.5, 1.6, and 1.7.  Eclipse will then use the libraries
> > > from the appropriate JVM during compile
> > > 
> > 
> > function contains(String) is supported since 1.5. Java 1.4 is EOL (as per
> > the Oracle web site:
> > http://www.oracle.com/technetwork/java/javase/index-jsp-138567.html). But
> > anyway, changed my installed JRE and changed the code to match it (copied
> > the implementation of contains from class String).
> 
> We wouldn't be able to accept it if it's copied out of any GPLed or
> copyrighted classes.
> 
> But name.toLowerCase().indexOf(filter.toLowerCase())>=0 would be acceptable.
> Could you check what you have and amend the commit?
> 
> Thanks for getting back to us.
> 
> PW

Done. You know where to find the code.

Arieh
Comment 15 Arieh Bibliowicz CLA 2013-04-29 05:15:33 EDT
Hi everyone... Did my work go to /dev/null?
Comment 16 Paul Webster CLA 2013-04-29 07:30:35 EDT
(In reply to comment #15)
> Hi everyone... Did my work go to /dev/null?

No, EclipseCon and now the endgame for Kepler.  Since we need a CQ and the date for that passed in Feb, I won't be able to look at this until June.

PW
Comment 17 Arieh Bibliowicz CLA 2013-05-01 12:43:21 EDT
OK. Thanks for the update. Will be waiting.
Comment 18 Paul Webster CLA 2013-12-12 16:28:18 EST
We would be able to get a CQ now, and you could sign your CLA (link beside your name in bugzilla)

PW
Comment 19 Lars Vogel CLA 2013-12-13 05:40:25 EST
Could you convert your change into a Gerrit review? The necessary process is described here: http://www.vogella.com/articles/Gerrit/article.html#eclipsegerritcontribution
Comment 20 Arieh Bibliowicz CLA 2013-12-14 13:26:58 EST
Signed my CLA.
Lars - is this a must? it's been like 8 months, and would require me to re-create my env. If there is no other way, I'll do it, but...
Comment 21 Paul Webster CLA 2013-12-16 05:42:03 EST
(In reply to Arieh Bibliowicz from comment #20)
> Signed my CLA.
> Lars - is this a must? it's been like 8 months, and would require me to
> re-create my env. If there is no other way, I'll do it, but...

You can hold off on that (I can push the initial change), but if we review it and send it back again for changes then you'll have to set up your env again.

PW
Comment 22 Lars Vogel CLA 2013-12-16 05:47:08 EST
(In reply to Arieh Bibliowicz from comment #20)
> Signed my CLA.
> Lars - is this a must? it's been like 8 months, and would require me to
> re-create my env. If there is no other way, I'll do it, but...

Not a must, but in my experience it speeds up the process of accepting patches. And of course it would be great to get more patches from you in the future, with Gerrit the feedback loop is relatively fast.
Comment 23 Arieh Bibliowicz CLA 2013-12-16 06:57:46 EST
(In reply to Lars Vogel from comment #22)
> (In reply to Arieh Bibliowicz from comment #20)
> > Signed my CLA.
> > Lars - is this a must? it's been like 8 months, and would require me to
> > re-create my env. If there is no other way, I'll do it, but...
> 
> Not a must, but in my experience it speeds up the process of accepting
> patches. And of course it would be great to get more patches from you in the
> future, with Gerrit the feedback loop is relatively fast.

(In reply to Paul Webster from comment #21)
> (In reply to Arieh Bibliowicz from comment #20)
> > Signed my CLA.
> > Lars - is this a must? it's been like 8 months, and would require me to
> > re-create my env. If there is no other way, I'll do it, but...
> 
> You can hold off on that (I can push the initial change), but if we review
> it and send it back again for changes then you'll have to set up your env
> again.
> 
> PW

Great guys. Thanks
Comment 24 Lars Vogel CLA 2013-12-16 07:07:27 EST
(In reply to Arieh Bibliowicz from comment #23)
> Great guys. Thanks

If you need help with the setup, please feel free to contact me via email or ask in this bug report. Sorry for letting you that long waiting, we try to get better and faster in accepting contributions with Gerrit.
Comment 25 Paul Webster CLA 2013-12-18 10:26:22 EST
I've uploaded the latest from https://github.com/vainolo/eclipse.platform.ui/tree/bug400835 as a single Gerrit change set:

https://git.eclipse.org/r/19982

We can review it there.  Arieh, if you haven't yet you should log into Gerrit at least once: https://git.eclipse.org/r/

PW
Comment 26 Arieh Bibliowicz CLA 2013-12-18 14:08:12 EST
(In reply to Paul Webster from comment #25)
> I've uploaded the latest from
> https://github.com/vainolo/eclipse.platform.ui/tree/bug400835 as a single
> Gerrit change set:
> 
> https://git.eclipse.org/r/19982
> 
> We can review it there.  Arieh, if you haven't yet you should log into
> Gerrit at least once: https://git.eclipse.org/r/
> 
> PW

Did the review. I saw there is also an "IP-Clean" column. Is this relevant? if so, how can I fill this?
thanks Paul for pushing the change for me!

Arieh
Comment 27 Paul Webster CLA 2014-01-28 19:31:01 EST
Latest comments applied to Gerrit review.

We have a couple of days of community contributions to get this in, then we're on to 4.3.2 building/testing.

PW
Comment 28 Arieh Bibliowicz CLA 2014-02-05 16:06:34 EST
Created attachment 239678 [details]
PropertySheetViewer changes for gerrit CR

Implemented desired changes from CR in change. 
* Didn't implement mouse listener because I don't handle default initial
text therefore no code is needed there.
* Didn't implement traverse listener because didn't understand what it
did in the FilteredTree class.
* Didn't change getControl method because it would disable the whole
property sheet.
Comment 29 Lars Vogel CLA 2014-11-28 14:44:19 EST
Simon, can we use the new FilteredTree implementation here?