Java Swing JTextPane in intellij framework

Answered

Hi,

I'm creating a Pycharm Plugin with a simple JTextPane (plain text). If I paste (CTRL+V) a multi-line text into it, it always pastes it into a single line replacing any type of EOL to spaces. Also the keys HOME or END jump to the start or the end of the document, not start/end of a current line. Is there a way to set some property that this behavior changes?

If I use the JTextPane outside the intellij framework, everything works as expected. Do I need to change something in the EditorKit properties?

4 comments
Comment actions Permalink

Hi Miloslav,

It's hard to tell what is the reason. Is there any chance to share the project sources?

Also, depending on your use case, please consider using Editor Component.

0
Comment actions Permalink

Hi Karol,

I originally wanted to use the EditorTextField, because of the code completion. But the problem is, I need custom TransferHandler to drag&drop custom data. If I use setTransferHandler on the EditorTextField, nothing happens. Is there a way to implement my own Transfer handler and my own copy/paste actions?

0
Comment actions Permalink

I would try to implement com.intellij.ide.PasteProvider.

You can check the example implementation that pastes Markdown markup when a file is dropped on the editor:
https://github.com/JetBrains/intellij-community/blob/master/plugins/markdown/core/src/org/intellij/plugins/markdown/editor/paste/FileLinkPasteProvider.kt

0
Comment actions Permalink

Hi Karol great, the paste function works perfect now.

 

But how about the drag-feature from the EditorTextField? Pycharm Editors have the drag feature - the text is cut and pasted. In my EditorText Field the dragging does not work. How do I do the dragging text from my editor somewhere else, which would perform copy. That is, it keeps the source content intact.

0

Please sign in to leave a comment.