Bug 226368 - API between code folding and BaseCaret
API between code folding and BaseCaret
Status: RESOLVED FIXED
Product: editor
Classification: Unclassified
Component: Painting & Printing
7.4
PC Linux
: P2 (vote)
: 7.4
Assigned To: Svata Dedic
issues@editor
: API, API_REVIEW_FAST
Depends on:
Blocks: 226413
  Show dependency treegraph
 
Reported: 2013-02-19 22:13 UTC by Svata Dedic
Modified: 2013-05-10 17:59 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
:


Attachments
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 http://hg.netbeans.org/jet-main/rev/c1b657407e68
Comment 5 Quality Engineering 2013-03-13 02:09:49 UTC
Integrated into 'main-golden', will be available in build *201303122300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/c1b657407e68
User: Svata Dedic <sdedic@netbeans.org>
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.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo