FXMisc / UndoFX

Undo manager for JavaFX
BSD 2-Clause "Simplified" License
98 stars 17 forks source link

Dynamic event stream for UndoManager #16

Closed dlemmermann closed 7 years ago

dlemmermann commented 7 years ago

I was wondering if it is possible to add and remove event streams from the stream that is being used by the UndoManager. In my use case the user is creating a flow diagram and keeps adding nodes to it. Each node has an x and a y property. I want to "monitor" these coordinates via the help of two event streams and I want to add them to the event stream of the undo manager without loosing the current history. How can I do this?

TomasMikula commented 7 years ago

Is EventStreams.merge what you are looking for?

dlemmermann commented 7 years ago

No because it always returns a new stream. I can not update the stream used by the undo manager. Tomas Mikula notifications@github.com schrieb am Mo. 24. Apr. 2017 um 20:54:

Is EventStreams.merge http://www.reactfx.org/javadoc/2.0-M5/org/reactfx/EventStreams.html#merge-javafx.collections.ObservableSet- what you are looking for?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/TomasMikula/UndoFX/issues/16#issuecomment-296788907, or mute the thread https://github.com/notifications/unsubscribe-auth/AJF7XU6emj00r1aiuRu5NnJOgRk3U2Gtks5rzO_ZgaJpZM4NGNjV .

TomasMikula commented 7 years ago

I can not update the stream used by the undo manager.

You don't need to.

ObservableSet<EventStream<MyChange>> streamSet = FXCollections.observableSet();
EventStream<MyChange> changes = EventStreams.merge(streamSet);
UndoManager undoManager = UndoManagerFactory.unlimitedHistoryUndoManager(changes, ...);

// later
EventStream<MyChange> newChangeStream = ???;
streamSet.add(newChangeStream);
dlemmermann commented 7 years ago

Ah perfect. Thank you!

Am 24.04.2017 um 21:54 schrieb Tomas Mikula notifications@github.com:

I can not update the stream used by the undo manager.

You don't need to.

ObservableSet<EventStream> streamSet = FXCollections.observableSet(); EventStream changes = EventStreams.merge(streamSet); UndoManager undoManager = UndoManagerFactory.unlimitedHistoryUndoManager(changes, ...);

// later EventStream newChangeStream = ???; streamSet.add(newChangeStream); — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/TomasMikula/UndoFX/issues/16#issuecomment-296804046, or mute the thread https://github.com/notifications/unsubscribe-auth/AJF7XRSuC3Qwk4xUMWwm7gXp7OcOuGiiks5rzP3ggaJpZM4NGNjV.