On Mon, 30 Sep 2024 19:08:22 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
>> Incubating a new feature - rich text control, **RichTextArea**, intended to >> bridge the functional gap with Swing and its StyledEditorKit/JEditorPane. >> The main design goal is to provide a control that is complete enough to be >> useful out-of-the box, as well as open to extension by the application >> developers. >> >> This is a complex feature with a large API surface that would be nearly >> impossible to get right the first time, even after an extensive review. We >> are, therefore, introducing this in an incubating module, >> **jfx.incubator.richtext**. This will allow us to evolve the API in future >> releases without the strict compatibility constraints that other JavaFX >> modules have. >> >> Please check out two manual test applications - one for RichTextArea >> (**RichTextAreaDemoApp**) and one for the CodeArea (**CodeAreaDemoApp**). >> Also, a small example provides a standalone rich text editor, see >> **RichEditorDemoApp**. >> >> Because it's an incubating module, please focus on the public APIs rather >> than implementation. There **will be** changes to the implementation >> once/if the module is promoted to the core by popular demand. The goal of >> the incubator is to let the app developers try the new feature out. >> >> **References** >> >> - Proposal: >> https://github.com/andy-goryachev-oracle/Test/blob/main/doc/RichTextArea/RichTextArea.md >> - Discussion points: >> https://github.com/andy-goryachev-oracle/Test/blob/main/doc/RichTextArea/RichTextAreaDiscussion.md >> - API specification (javadoc): >> https://cr.openjdk.org/~angorya/RichTextArea/javadoc >> - RichTextArea RFE: https://bugs.openjdk.org/browse/JDK-8301121 >> - Behavior doc: >> https://github.com/andy-goryachev-oracle/jfx/blob/8301121.RichTextArea/doc-files/behavior/RichTextAreaBehavior.md >> - CSS Reference: >> https://cr.openjdk.org/~angorya/RichTextArea/javadoc/javafx.graphics/javafx/scene/doc-files/cssref.html >> - InputMap (v3): >> https://github.com/andy-goryachev-oracle/Test/blob/main/doc/InputMap/InputMapV3.md >> - Previous Draft PR: https://github.com/openjdk/jfx/pull/1374 > > Andy Goryachev has updated the pull request incrementally with one additional > commit since the last revision: > > file operations A few additional comments. modules/jfx.incubator.richtext/src/main/java/jfx/incubator/scene/control/richtext/RichTextArea.java line 1038: > 1036: * @return the text position at the end of the appended text, or > null if editing is disabled > 1037: * @throws NullPointerException if the model is {@code null} > 1038: * @throws UnsupportedOperationException if the model is not {@link > StyledTextModel#isWritable() writable} This matches what we had previous discussed. To capture some additional thinking I have around this, there are two possible exceptions we could throw here: `UnsupportedOperationException` or `IllegalStateException`. Given the reason we are throwing the exception, they are similar in meaning to each other. Typically UOE means "this is illegal for this instance of this object" while ISE mean "this is illegal at this time given the current state of the object (or some other state)". For similar methods in the _model_, UOE is clearly the right thing to throw, since that model is not writable (and won't be). For the RichTextArea control, it isn't a clear cut. While unlikely, the model is a property of the control that you can change at runtime if you want to (NB: has this been tested?), which would suggest ISE might be more clear. However, since this exception is basically rethrowing an exception from the model, having it be a different exception class might be unexpected. Let's leave it as you have it for now. I don't expect we will revisit it unless someone comes up with a compelling reason. modules/jfx.incubator.richtext/src/main/java/jfx/incubator/scene/control/richtext/RichTextArea.java line 1138: > 1136: * by the model. > 1137: * <p> > 1138: * This method does nothing when the caret position is {@code null}. What does it do if the model is null? modules/jfx.incubator.richtext/src/main/java/jfx/incubator/scene/control/richtext/RichTextArea.java line 1166: > 1164: * This method does nothing if the model or the caret position is > {@code null}. > 1165: * The default implementation may throw an {@code > UnsupportedOperationException} > 1166: * if the control is not editable. When this happens, the copying > to clipboard will succeed. Same question here (and elsewhere so I won't repeat after this) : should this throw an exception here since it is the target of an input function tag? If so, then it should throw on a null model rather than doing nothing; as it stands, it is inconsistent. ------------- PR Review: https://git.openjdk.org/jfx/pull/1524#pullrequestreview-2338497775 PR Review Comment: https://git.openjdk.org/jfx/pull/1524#discussion_r1781693413 PR Review Comment: https://git.openjdk.org/jfx/pull/1524#discussion_r1781733535 PR Review Comment: https://git.openjdk.org/jfx/pull/1524#discussion_r1781736060