Re: [Graymail] How to implement editor-fold in netbeans editor

Svata Dedic <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <[email protected]>
You don't need to implement the FoldManager yourself; there's a stock
implementation which recognizes <editor-fold> pseudo-tags in comment
tokens for you.

You need to register for your MIME type
(Editors/text/x-whatever/FoldManager) something like:

                    <file name="CustomFoldManager.instance">
                        <attr name="instanceOf"
stringvalue="org.netbeans.spi.editor.fold.FoldManagerFactory"/>
                        <attr name="instanceCreate"
methodvalue="org.netbeans.api.editor.fold.FoldingSupport.userFoldManagerFactory"/>
                    </file>

If primaryCategory() of comment token IDs  produced by your lexer start
with "comment", you're set up. Otherwise you need to pass "tokenId"
attribute to the instance with your comment's primaryCategory prefix.

-S.

Dne 10.3.2016 v 17:20 Volodymyr napsal(a):
> Thanks for your answer.
> 
> I have the FoldManager implemented, but cannot figure out this exact
> folding. I suppose I have to implement two new tokens two match the
> opening and closing of <editor-fold>. But which type FoldType it has to
> be, USER? It looks really great in Java Editor, I want it to look the
> same)).
> 
> Thanks.
> 
> 10 березня 2016, 16:29:19, від "Ingleby, Graeme"
> <[email protected] <mailto:[email protected]>>:
> 
>     There is a section in this tutorial that shows how to create folds
>     for comments, maybe this will help:
> 
>      
> 
>     https://platform.netbeans.org/tutorials/nbm-javacc-parser.html#fold-feature
> 
>      
> 
>      
> 
>     *From:*Volodymyr [mailto:[email protected]]
>     *Sent:* Thursday, March 10, 2016 8:20 AM
>     *To:* NetBeans support
>     *Subject:* [Graymail] [platform-dev] How to implement editor-fold in
>     netbeans editor
> 
>      
> 
>     Hello,
> 
>     There is a great functionality in NetBeans, editor-fold, but I
>     cannot figure out how to implement its support for my custom
>     language. Does anybody know?
> 
>     Thanks.
> 
>     // <editor-fold defaultstate="collapsed" desc=" My methods ">
>     // </editor-fold>
> 
>     Regards,
>     Volodymyr.
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.