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

When deleting a Check, the Decorator is not deleted #43

Open
goshik81 opened this issue Oct 31, 2024 · 4 comments
Open

When deleting a Check, the Decorator is not deleted #43

goshik81 opened this issue Oct 31, 2024 · 4 comments

Comments

@goshik81
Copy link

Hi. I try apply validations for Table.
But when i remove Check object Decoration is not Deleted.

Untitled video - Made with Clipchamp
ValidationTest.zip

How can I use ValidatorFX for each row in TableView?
Thanks.

@effad
Copy link
Owner

effad commented Nov 4, 2024

I am not sure what the problem is here. You could try to call validator.validate() explicetly after validator.remove(check);. This should trigger a re-evaluation of the validation.

@goshik81
Copy link
Author

goshik81 commented Nov 4, 2024

I added check.clear();
now I have code like this:

    private void removeCheck() {
        if (check != null) {
            check.clear();
            validator.remove(check);
            check = null;
            checkedItem = null;
        }
    }

But after row deletion I have an error:

Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at javafx.base@21/com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:88)
at javafx.base@21/com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:314)
at javafx.graphics@21/javafx.scene.Parent.layout(Parent.java:1212)
at javafx.graphics@21/javafx.scene.Scene.doLayoutPass(Scene.java:594)
at javafx.graphics@21/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2600)
at javafx.graphics@21/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:401)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at javafx.graphics@21/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:400)
at javafx.graphics@21/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:430)
at javafx.graphics@21/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:592)
at javafx.graphics@21/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:572)
at javafx.graphics@21/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:565)
at javafx.graphics@21/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:352)
at javafx.graphics@21/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at javafx.graphics@21/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics@21/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:185)
at java.base/java.lang.Thread.run(Thread.java:1583)

Also if I add 10+ records and try scroll records up and down, I have this error:

Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index 8 out of bounds for length 8
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at javafx.base@21/com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:88)
at javafx.base@21/com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:314)
at javafx.graphics@21/javafx.scene.Parent.layout(Parent.java:1212)
at javafx.graphics@21/javafx.scene.Scene.doLayoutPass(Scene.java:594)
at javafx.graphics@21/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2600)
at javafx.graphics@21/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:401)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at javafx.graphics@21/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:400)
at javafx.graphics@21/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:430)
at javafx.graphics@21/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:592)
at javafx.graphics@21/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:572)
at javafx.graphics@21/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:565)
at javafx.graphics@21/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:352)
at javafx.graphics@21/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at javafx.graphics@21/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics@21/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:185)
at java.base/java.lang.Thread.run(Thread.java:1583)

Do you have an example how use validations with TableView?

@effad
Copy link
Owner

effad commented Nov 4, 2024

This smells like a "update outside JavaFX-Thread"-Problem (which it cannot be from the sources you sent me). Maybe the updateItem()-call happens within a rendering-pulse and we're not allowed to modify the scene graph at that time. But I must admit, this is guesswork. Interestingly enough though, there is no "net.synedra..." in the stack traces above.

Unfortunately I do not have an example of how to use validations inside TableView.

@goshik81
Copy link
Author

goshik81 commented Nov 4, 2024

There are no problems with decoration "StyleClassDecoration"
For now I create "class TableRowDecoration extends StyleClassDecoration"

and use it like this:

.decoratingWith(TableRowDecoration::createRowDecoration)

ValidationTest.zip

But I think it is necessary to fix the class. "GraphicDecoration"

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

No branches or pull requests

2 participants