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 226368 - API between code folding and BaseCaret
Summary: API between code folding and BaseCaret
Alias: None
Product: editor
Classification: Unclassified
Component: Painting & Printing (show other bugs)
Version: 7.4
Hardware: PC Linux
: P2 normal (vote)
Assignee: Svata Dedic
Depends on:
Blocks: 226413
  Show dependency tree
Reported: 2013-02-19 22:13 UTC by Svata Dedic
Modified: 2013-05-10 17:59 UTC (History)
0 users

See Also:
Exception Reporter:

Proposed changes (7.36 KB, patch)
2013-02-19 22:22 UTC, Svata Dedic
Details | Diff
Y01 implemented, added necessary portion of refactored classes (315.19 KB, patch)
2013-02-26 22:20 UTC, Svata Dedic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Svata Dedic 2013-02-19 22:13:47 UTC
This API change helps to separate folding from editor.lib module. Most of the caret - fold integration can be done using regular APIs. However when creating or folding, it is sometimes necessary to reposition the editor view, so that caret is still visible and the user is not disturbed. This is purpose of the refresh() method in to sync the view with the caret.

The second change is a friend pseudo-API, since editor.lib must not depend on editor.fold (dependencies in the other direction are already in place) and there's no suitable API or different possible clients so far to justificate proper API to be created. The BaseCaret uses Callable found in the client property "org.netbeans.api.fold.expander" to determine whether the area under caret is selectable. It is expected that the Callable's implementation will perform the fold expansion as a side effect.
Comment 1 Svata Dedic 2013-02-19 22:22:12 UTC
Created attachment 131587 [details]
Proposed changes
Comment 2 Jaroslav Tulach 2013-02-25 05:19:39 UTC
Y01 A test could ensure the Callable is really provided by the editor and it behaves as expected.
Comment 3 Svata Dedic 2013-02-26 22:20:45 UTC
Created attachment 131926 [details]
Y01 implemented, added necessary portion of refactored classes

Y01: testcase added, checked actual effect of fold-provided Callable.

Note: since dependencies changed (actually reversed between editor.fold and editor.lib), I had to provide refactored classes (moved from editor.lib to editor.fold) as part of the diff, so the code is compilable after patching. 

See issue #226413 for the scope of the refactoring.
Comment 4 Svata Dedic 2013-03-09 15:17:08 UTC
Implemented in
Comment 5 Quality Engineering 2013-03-13 02:09:49 UTC
Integrated into 'main-golden', will be available in build *201303122300* on (upload may still be in progress)
User: Svata Dedic <>
Log: #226413, #226368: Folds UI separated to a new module. editor.lib partially cleaned up from folding code.
Comment 6 280Z28 2013-05-10 16:48:01 UTC
The patch Y01 deprecates CodeFoldingSideBar with the following comment:

> You should use {@link FoldUtilities#createSidebarComponent(javax.swing.text.JTextComponent)} or {@link FoldUtilities#getFoldingSidebarFactory()} instead. Subclassing CodeFoldingSidebar is no longer actively supported, though still working.

Unfortunately the described methods do not exist. Based on the change to java.editor/src/org/netbeans/modules/java/editor/resources/layer.xml in commit c1b657407e68, it appears that in most cases the factory class used to create the sidebar component is simply no longer required. Removing my factory class and its registration in the layer.xml for my module left my code folding feature intact and removed the usage of deprecated API.
Comment 7 Svata Dedic 2013-05-10 17:59:44 UTC
Yes, sorry. I updated the linked Wiki page; since it was possible to register folding sidebar for all editors, and only display it when actually a foldmanager exists, the API becomes unnecessary - until of course someone requests more finer control over the sidebar construction.