简体   繁体   中英

Stencil based editor component for Java/Swing?

I'm looking for a stencil based text editor for my swing application. (SWT component would be OK too)

If you don't know what a "stencil based" editor is, have a look on the stencil based editor in Alice: 在此输入图像描述

So you just drop the stencil of the block you want to add to your code, like a if or a loop, and can only add compatible expressions in the "holes" in the stencil.

(I need it for an end user programming tool so auto complete is not enough to get the user started fast.)

The source code of an old Alice version is online on github , but the code is undocumented and pretty huge so that would be my last resort.

Swing's StyledDocument has just two levels of styles: paragraph and character level, but they are set based, so you have a kind of nesting. I would use the HTMLEditorKit (nested HTML), a read-only JTextPane, and caret position based contextual insertion. Having an XML schema of possible document structure and using that to insert <div class='myX'> and such. So at the caret position have a stack of nested elements.

Recently I stumbled upon some projects using and creating such editors:

For C/C++ programmers Scratch would be a good point to start but for Java developers there's openblocks . There doesn't seem to be a real name convention yet but you definitly find more projects by the terms "visual programming" and "block editor" than "stencil based editor".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM