User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7
Hello,
this is my first post to the list and I hope I have come to the right
place. The last couple of weeks, I have tried to become familiar with
Java development in general and rich text editing in particular. Judging
by the many questions asked in various forums, RTF seems to be a popular
topic. I started out with Swing and found it to be pretty well designed
and basically suitable for my purposes. However I quickly saw the many
differences in look and behavior of the Swing UI elements compared to
the platform it was running on. As you probably know, Swing has support
for RTF, which extends also to pasting from the system clipboard. I was
very surprised to find out that pasting RTF content is only possible at
the end of a document, the current cursor position or selection is
ignored. It basically renders Swing useless for me, but luckily OpenJDK
is open source and problems could be fixed.
In any case, I really like what SWT has to offer in terms of truely
native look & feel and I also find it adequately designed. I am not yet
so convinced about many design decisions in JFace. By no means I could
claim to have a complete understanding, but from what I have learned so
far, it seems the text components in particular are very much targeted
at the needs of editors as can be found in Eclipse. The TextEditor SWT
example demonstrates that everything I need is technically possible with
the StyledText component, however it does not demonstrate these
capabilities in terms of JFace. There are some flaws which may or may
not expose the fact that syntax highlighting editors are the main
target, for example when defining a StyleRange for a range of text,
positioning the cursor in that range and typing will not use the
surounding TextStyle for the new text.
What I am wondering now is whether the JFace text framework and the
StyledText component is perfect for my needs. Even if I implement my own
IDocument, it seems to be inefficient to reset all the StyleRanges on
the StyledText widget upon every insertion (if I understand things
correctly). Perhaps it's a better idea to take all the related OpenJDK
Swing text stuff and reimplement the relevant backends to target a new
SWT widget. Judging by how many developers seem to face similar tasks as
myself, I wonder if something similar has not yet been done. I would
gladly receive some informed opinions and options. I would have no
problem to contribute my work, should it be the best approach to write
something new.
To recap: The users of my app would not be editing source code, I don't
need continuous re-parsing of the text to divide it into partitions for
syntax coloring. I would like to offer rich text editing and full
integration with the system clipboard, when the contents are in RTF.
Pretty much exactly what Swing offers with DefaultStyledDocument and
JEditorPane, only without killer flaws like only being able to paste at
the end of the document... and on top of SWT. :-)