fxmisc / undofx Goto Github PK
View Code? Open in Web Editor NEWUndo manager for JavaFX
License: BSD 2-Clause "Simplified" License
Undo manager for JavaFX
License: BSD 2-Clause "Simplified" License
It would be great if you could also show an example on how to undo / redo changes on collections.
I would like to be able to listen to the Undo/Redo events.
Hello,
I am experimenting with mark(); and isAtMarkedPosition();
I type in some text let's say word "hello" and set the mark(); position at that point.
When I type an extra character (it takes me to a different step) and do control+z to undo, the isAtMarkedPosition() returns false (it should be returning true). Also, when I type in a character and remove that character, then it also isAtMarkedPosition() returns false. The only time when isAtMarkedPosition(); returns false is when you type in "hello", mark();, and then do undo (control + z) and then do redo (control+shift+z). In all other cases, it returns false.
I just started using UndoFX, and I consistently got an IllegalStateException
without knowing why.
Through much debugging and by looking at #7, I finally figured out that the parameter of the apply
function is supposed to be reinserted into the event stream inside the apply function. This is however nowhere documented.
UndoManagerImpl
) C change = changeToApply.get();
this.expectedChange = change;
performingAction.suspendWhile(() -> apply.accept(change));
if(this.expectedChange != null) {
throw new IllegalStateException("Expected change not received:\n"
+ this.expectedChange);
}
Many minor things can be added to improve this situation:
performingAction.suspendWhile(() -> apply.accept(change));
undo
(I think it is not needed for redo
)README
, at best in the section for the apply
functionany or all of which detailing that the change is expected to be reinserted in the event stream during the undo action.
As you can see here:
http://search.maven.org/#artifactdetails%7Corg.fxmisc.undo%7Cundofx%7C1.0.0%7Cjar
The defined dependency:
<dependency>
<groupId>org.reactfx</groupId>
<artifactId>reactfx</artifactId>
<version>1.0+</version>
<scope>compile</scope>
</dependency>
Has a plus sign which makes the dependency corrupt.
I will no longer be maintaining this project.
See FXMisc/RichTextFX#768 for more info.
When fetching org.fxmisc.undo/undofx from Maven central, I get the following checksum error:
Could not find metadata org.fxmisc.undo:undofx/maven-metadata.xml in local (/Users/mtnygard/.m2/repository)
Could not transfer metadata org.fxmisc.undo:undofx/maven-metadata.xml from/to central (https://repo1.maven.org/maven2/): Checksum validation failed, expected 5aa23ca89ce7f15b4e877d85d2dca9b554f44b18 but is 8805fc8f574b9614ac518a4c71bc17ae08a64007
We are reaching this dependency via RichTextFX version 0.6.4
This would allow FXMisc/RichTextFX#574 to be implemented.
I'm using Scala 2.11.7 with UndoFX in my project, and when I try to compile, the compile fails with assertion failed: TVar<?0=null>
.
This only happens with UndoFX 1.2, and it was fine before on UndoFX 1.1.1, and the only changes I've made are to comply with 1.2's new interface. I've even changed from using SAM conversion to instantiate the undo manager to anonymous classes, and the failure still takes place. Even a stacktrace simply spits out internal Scala compiler errors, so I can't quite debug what's causing the error.
My build tool is Gradle 2.7, if it means anything.
I've also tried this on a fresh Gradle Scala project, and the same error results.
This is the sample code for the fresh project that fails to compile:
import java.util.function.{Consumer, Function}
import org.fxmisc.undo.UndoManagerFactory
import org.reactfx.EventSource
object Main {
val changes = new EventSource[Change]
val undoManager = UndoManagerFactory.unlimitedHistoryUndoManager(
changes,
new Function[Change, Change] {
override def apply(t: Change): Change = t.invert
},
new Consumer[Change] {
override def accept(t: Change): Unit = t.apply()
}
)
}
case class Change(oldVal: Boolean, newVal: Boolean) {
def invert: Change = Change(newVal, oldVal)
def apply(): Unit = println(newVal)
}
Coming from FXMisc/RichTextFX#486 (more specifically, Tomas comment on how to solve an issue):
Another option is to give the
UndoManager
a way to know whether merge resulted in an empty change. This could be done for example by adding an extra parameterPredicate<C> isEmpty
to the factory method create above. Undo manager would then test changes for emptiness and automatically discard empty changes without trying to apply them.
This is probably me not understanding the changes in 1.2, but when I undo an action, then redo it, and then try to take a new action, the undo manager crashes with an Unexpected change received
.
Am I supposed to send redone changes to the change stream as well?
If forgetHistory discards all previous history, should it invalidate the undoAvailable and redoAvailable properties? Also, should it automatically update the marked position to ensure it isn't pointing to some old, forgotten position?
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?
Can you change the return results for undoAvailableProperty and redoAvailableProperty to BooleanExpression or BooleanBinding? This would simplify binding Button.disableProperty().bind(UndoManager.undoAvailableProperty().not()) in RichTextFX
Coming from FXMisc/RichTextFX#362, and its solution (FXMisc/RichTextFX#530)...
We only need to add a Duration
parameter to the UndoManagerImpl
's constructor, so that the UndoManager
's subscription
will also unsubscribe the Subscription
returned from changeSource.successionEnds(delay).subscribe(ignore -> preventMerge());
It would be nice if changes could be named so that an undo / redo UI could display the name of the last change that will be undone or redone, e.g. "Undo 'Move Object'".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.