Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2+ Views (areas) share the same Model (document) #232

Merged
merged 10 commits into from
Dec 28, 2015
Merged

2+ Views (areas) share the same Model (document) #232

merged 10 commits into from
Dec 28, 2015

Conversation

JordanMartinez
Copy link
Contributor

This is the same result of the #231 but with a cleaner commit history.

…o refer to the same values as before (if they still exist) and to be within the area's bounds when a clone modifies the document
… document so that, when one modifies the underlying document, all of their suspendables are suspended. This insures that their values are always valid and correct.
@@ -446,26 +449,41 @@ public void setStyleCodecs(Codec<S> textStyleCodec, Codec<PS> paragraphStyleCode
* content model
*/
private final EditableStyledDocument<S, PS> content;
protected final EditableStyledDocument<S, PS> getCloneDocument() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably just call it getDocument().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would but there's already a method with that name (see Line 336).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. What about getContent()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I've updated the method name.

@TomasMikula
Copy link
Member

addSuspendable, removeSuspendable look a lot like adding/removing special kind of listeners. This suggests a question whether we can reuse some existing listener mechanism. We can! We can have a SuspendableNo beingUpdatedProperty() on EditableStyledDocument (in addition to the ones on StyledTextAreas) and add a listener that suspends the StyledTextArea's omniSuspendable. I added Suspendable.suspendWhen(condition) to ReactFX to make it easier, so that one can now do something like

manageSubscription(omniSuspendable.suspendWhen(content.beingUpdatedProperty()))

@JordanMartinez
Copy link
Contributor Author

Aye... that would be much cleaner. Did you make a new release so I can update the code?

@TomasMikula
Copy link
Member

Yes, I updated the snapshot release (2.0-SNAPSHOT).

@JordanMartinez
Copy link
Contributor Author

Great. I've had my first run-through it. If EditableStyledDocument has a beingUpdatedProperty() now, should I remove the StyledTextArea's beingUpdated SuspendableNo ? (I know we ported it to ESD in the previous PR's exploration, but I reported it back to STA because it didn't add any value at that time.)

@JordanMartinez
Copy link
Contributor Author

I ported beingUpdated to ESD. How's that?

@TomasMikula
Copy link
Member

Great. I've had my first run-through it. If EditableStyledDocument has a beingUpdatedProperty() now, should I remove the StyledTextArea's beingUpdated SuspendableNo ? (I know we ported it to ESD in the previous PR's exploration, but I reported it back to STA because it didn't add any value at that time.)

No, we need to keep another beingUpdated in STA, in order to guarantee the property that no change can be observed while beingUpdated is false. This way, the user can be sure that when beingUpdated changes from true to false, all other changes have been propagated and are thus consistent with each other (e.g. caret position, current paragraph, length, ...). Note that the order in which registered listeners are invoked is undefined (neither in JavaFX nor ReactFX). If STA observes the same beingUpdated as the user, the user could get the notification first, before STA releases the pending notifications.

@JordanMartinez
Copy link
Contributor Author

Ah... I see. Fixed it.

@TomasMikula
Copy link
Member

👍

TomasMikula added a commit that referenced this pull request Dec 28, 2015
2+ Views (areas) share the same Model (document)
@TomasMikula TomasMikula merged commit 87c2b30 into FXMisc:master Dec 28, 2015
@JordanMartinez
Copy link
Contributor Author

Cool 😃

@TomasMikula
Copy link
Member

So I merged this, but the supported use is limited. For example, if the document is edited from both areas, undo will not work very well. One area's undo will be regarded as a new edit in the other area. It is a complex problem on its own, so for now I would just say that such a use is not supported.

@JordanMartinez
Copy link
Contributor Author

Dang.... Yeah, that's quite a problem.

On another note, when will there be a new mainstream release (meaning, not a snapshot release)?

@JordanMartinez
Copy link
Contributor Author

if the document is edited from both areas, undo will not work very well. One area's undo will be regarded as a new edit in the other area. It is a complex problem on its own, so for now I would just say that such a use is not supported.

I'll open an issue for this as well, just so it's on file.

@TomasMikula
Copy link
Member

I can make a new release as soon as

  1. all known regressions introduced by these refactorings are resolved.
  2. all SNAPSHOT-versioned dependencies are released :)

@JordanMartinez
Copy link
Contributor Author

all known regressions introduced by these refactorings are resolved.

What are the known regressions? Would this include the Undo-related problem mentioned above?

all SNAPSHOT-versioned dependencies are released :)

:) What else needs to be done in Flowless and ReactFX before they get their releases?

@TomasMikula
Copy link
Member

What are the known regressions?

#210, #220, #234

Would this include the Undo-related problem mentioned above?

That's not really a regression, since that was not supported at all before.

What else needs to be done in Flowless and ReactFX before they get their releases?

They might be good to go.

@JordanMartinez
Copy link
Contributor Author

I've also noticed a problem in the richtextfx's build.gradle file. It lists UndoFX as a dependency twice: the first, with its transitive dependencies overrules the second, one without transitive dependencies. I've had to comment out the first instance or else I get compile warnings.

@TomasMikula
Copy link
Member

Yeah, the first one should have been deleted when the second one was added. This is a mistake. Anyway, the transitive = false options will be removed when all dependencies use the same version of ReactFX as RichTextFX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants