Bug 237359 - [DataBinding] Create snippet for p2 filtered/checkbox/async tree
Summary: [DataBinding] Create snippet for p2 filtered/checkbox/async tree
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 222991
Blocks: 186425 233269
  Show dependency tree
 
Reported: 2008-06-16 17:02 EDT by Boris Bokowski CLA
Modified: 2019-09-06 16:11 EDT (History)
7 users (show)

See Also:


Attachments
work in progress (21.45 KB, patch)
2008-06-16 17:04 EDT, Boris Bokowski CLA
no flags Details | Diff
now with filtering (31.92 KB, patch)
2008-06-17 17:05 EDT, Boris Bokowski CLA
no flags Details | Diff
updated patch after merging conflicting changes (31.97 KB, patch)
2008-07-03 12:11 EDT, Boris Bokowski CLA
no flags Details | Diff
Updated patch using getRealizedElements() (24.41 KB, patch)
2008-09-04 18:55 EDT, Matthew Hall CLA
no flags Details | Diff
Fixed to apply properly (22.19 KB, patch)
2008-10-02 15:02 EDT, Matthew Bisson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Bokowski CLA 2008-06-16 17:02:56 EDT
 
Comment 1 Boris Bokowski CLA 2008-06-16 17:04:51 EDT
Created attachment 105085 [details]
work in progress

Just capturing my work so far - this snippet demonstrates async and checkbox, but does not have filtering support. It also needs clean up.
Comment 2 Boris Bokowski CLA 2008-06-16 18:35:29 EDT
Susan - if you have time, could you give this a try and run the snippet? It would be good to know if I got it right at least so far...
Comment 3 Susan McCourt CLA 2008-06-16 18:55:10 EDT
so far, so good.  Already better than what p2 has.

I like that the check on a parent starts the async fetch right away without having to expand anything.  Also that you can play with the state of the pending node during the fetch and have that state honored.
Comment 4 Boris Bokowski CLA 2008-06-17 17:05:03 EDT
Created attachment 105213 [details]
now with filtering

Other than an occasional gray-check state that I haven't tracked down, this seems to be working now.

Before I go and clean up the code, it would be good to know if the behaviour is correct. (Note that for testing refresh, you can trigger it by double-clicking on a repository node.)
Comment 5 Susan McCourt CLA 2008-06-17 17:32:25 EDT
This looks really promising.
Some things I noticed right away:

- FilteredTree causes an expansion of elements when it filters, so the user sees immediately the effects of filtering.  So SDK users are used to this behavior in the pref dialog, show view, p2, etc.  In this example, the expansion state does not change on filtering.  I think it's safe to assume that the filtered items should be made visible with whatever mechanism makes the most sense

- If I expand a site and checkmark the "Pending..." node, the pending node and the site get a checkmark (good).  But when "Pending..." is replaced with the actual categories, they are not checkmarked, but the site remains checked.  If I expand the categories, then the items show up with checkmarks and the category gets check marked.  The end state is correct, but the visuals are wrong until the category is expanded.

- I'm hoping/assuming I can make use of the bold label providers that automatically bold the filtered items.  I'll try this.

As a next step, I will look more closely at the client-side/example code and see how to integrate into an alternate version of the p2 available IU group.  That will surface the next level of issues.
Comment 6 Boris Bokowski CLA 2008-07-03 12:11:55 EDT
Created attachment 106468 [details]
updated patch after merging conflicting changes
Comment 7 Susan McCourt CLA 2008-07-03 13:04:14 EDT
Thanks, Boris.  I've been away from this patch for a little while dealing with other things and taking a little vacation but plan to return to it next week.
Comment 8 Matthew Hall CLA 2008-07-08 18:50:48 EDT
(In reply to comment #5)
> - If I expand a site and checkmark the "Pending..." node, the pending node and
> the site get a checkmark (good).  But when "Pending..." is replaced with the
> actual categories, they are not checkmarked, but the site remains checked.  If I
> expand the categories, then the items show up with checkmarks and the category
> gets check marked.  The end state is correct, but the visuals are wrong until
> the category is expanded.

This is caused by the test for instanceof IU in the known elements set listener.  Remove the instanceof test and the items are checked as expected.
Comment 9 Susan McCourt CLA 2008-07-09 12:47:10 EDT
Thanks, Matt, I'll have a look at that.
Comment 10 Susan McCourt CLA 2008-07-21 11:50:21 EDT
Boris, the snippet uses a timer exec to fake the delay, so the long op is still happening the UI thread.  In my case I am doing network access and can't tie up the UI thread.  Is it my responsibility then, to start a background job and when it is complete, I would add the result to the observable in the UI thread?  I haven't quite groked what the deferred observable changes are doing for me...
Comment 11 Boris Bokowski CLA 2008-07-21 11:55:49 EDT
(In reply to comment #10)
> Boris, the snippet uses a timer exec to fake the delay, so the long op is still
> happening the UI thread.  In my case I am doing network access and can't tie up
> the UI thread.  Is it my responsibility then, to start a background job and
> when it is complete, I would add the result to the observable in the UI thread?

Yes - I used timerExec to simulate a background thread that does some work and then uses asyncExec to update state in the UI thread.
Comment 12 Matthew Hall CLA 2008-07-21 12:08:00 EDT
(In reply to comment #10)
> I haven't quite groked what the deferred observable changes are doing for
> me...

The problem is that you are wanting to set the check state of elements as they are added to the viewer, but getKnownElements() is updated before the elements have been realized.  getKnownElements() was originally written to support label providers so we have to populate the set before we add new elements to the viewer, so that the correct labels will be available.

The solution that we are contemplating now (and there is some disagreement about this approach) is to introduce another set, getRealizedElements(), which is updated while the element is present in the viewer.  Thus by monitoring this set you will be able to set the check state of new elements right after they are added, and save the check state of elements right before they are removed.
Comment 13 Matthew Hall CLA 2008-09-04 18:55:28 EDT
Created attachment 111741 [details]
Updated patch using getRealizedElements()
Comment 14 Matthew Bisson CLA 2008-10-02 15:02:13 EDT
Created attachment 114127 [details]
Fixed to apply properly

I tried the latest patch, and had trouble applying it. Attached is an updated version which should apply properly.

I ran it, and there seem to be some noticeable problems with the logic. Here are some examples:

- Check Eclipse SDK Update Site, then expand. After the delay, its children are unchecked.

- Type "abc" into the textbox and the console spills stack traces for NPEs then crashes.

- Due to the crashing, I'm having trouble reproducing this one, but often the filtering/unfiltering causes inconsistent checkbox states.
Comment 15 Susan McCourt CLA 2008-11-26 22:56:26 EST
Boris, see bug #233269.  I elected in the end not to use data binding for my problems, mainly because the success wasn't instant enough for me to bite off learning how to debug and work through the issues I had.  So I ended up doing a refactoring/simplification on the p2 side.

I still think it's useful/important to support filtering/checkbox/async retrieval in data binding and if I were already using data binding, I would have pushed harder on this.  

(I also think it's important to address the selection maintenance problems that plague ContainerCheckedTreeViewer, but I think there is a different bug for that, and I am able to work around that.)

Thanks for your time on this.
Comment 16 Eclipse Webmaster CLA 2019-09-06 16:11:28 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.