This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 258518 - the wrapping model for JTree OptionsFilter$FilteringTreeModel doesn't delegate addition/removal of listeners to the underlying model
Summary: the wrapping model for JTree OptionsFilter$FilteringTreeModel doesn't delegat...
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Options (show other bugs)
Version: 8.2
Hardware: All All
: P3 normal (vote)
Assignee: Milutin Kristofic
URL:
Keywords:
Depends on:
Blocks: 258503 267267
  Show dependency tree
 
Reported: 2016-03-24 10:29 UTC by ilia
Modified: 2016-08-27 02:20 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
patch (1.35 KB, patch)
2016-03-24 10:31 UTC, ilia
Details | Diff
Suggestion for (3.33 KB, patch)
2016-07-26 14:20 UTC, Milutin Kristofic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ilia 2016-03-24 10:29:26 UTC
I have a custom implementation of TreeModel (named ExtendedModel), which is used in Editor->Hints->C/C++.
When initializing a JTree I use OptionsFilter to add a filtering functionality:

  ((OptionsFilter) filter).installFilteringModel(errorTree, model, new AcceptorImpl());

The OptionsFilter$FilteringTreeModel wraps my model and properly delegates methods like isLeaf(Object node), getRoot(), etc.
But the problem is that it's not delegating addTreeModelListener/removeTreeModelListener methods to the underlying model.

This is critical because JTree itself and some other classes like BasicTreeUI adds theirs listeners to model.
What happens: imagine the structure of nodes was changed in ExtendedModel. To properly redraw the tree I should notify all related UI components of JTree that the branch was changed. But the addition of this listeners was not correctly delegated to my model, thus UI is not redrawn.

Fix attached:
  * delegate listeners to the inner model
  * remove UOE from treeNodes* methods
Comment 1 ilia 2016-03-24 10:31:04 UTC
Created attachment 158990 [details]
patch
Comment 2 ilia 2016-03-31 09:45:18 UTC
Can you review and apply the fix, please?
Comment 3 Milutin Kristofic 2016-06-17 14:07:57 UTC
Thank you ilia for patch and patience. I am sorry for waiting. Here is pushed into repository. http://hg.netbeans.org/jet-main/rev/7820b6906e42
Comment 4 ilia 2016-06-17 14:38:37 UTC
Thanks, Milutin!
Comment 5 Svata Dedic 2016-07-25 09:03:22 UTC
The change causes issue #267267; since the event comes to filtered model client from the original unfiltered source, integer indices are broken - from the filered point of view.
Comment 6 Milutin Kristofic 2016-07-26 14:20:39 UTC
Created attachment 161452 [details]
Suggestion for

Hi Ilia,
this change is causing problem with filtering tree, since it triggers tree changes in Handler. I have not find solution with leaving delegate listeners as are in your patch. 

Maybe we can do something like I am suggesting in patch. What do you think?
Comment 7 ilia 2016-08-15 14:18:18 UTC
Hi Milutin,

Fix looks safe.
I believe spec. version in module's properties should be incremented too because this is an API change.
Comment 8 Milutin Kristofic 2016-08-15 15:03:54 UTC
Great,thank you.
I push patch to repository. http://hg.netbeans.org/jet-main/rev/64fa8c731fa9 

After discussion with Svata, I changed implementation to overload.

Best,
Milutin
Comment 9 Quality Engineering 2016-08-27 02:20:00 UTC
Integrated into 'main-silver', will be available in build *201608270002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/64fa8c731fa9
User: Milutin Kristofic <mkristofic@netbeans.org>
Log: #258518 - the wrapping model for JTree OptionsFilter$FilteringTreeModel doesn't delegate addition/removal of listeners to the underlying model