-
Notifications
You must be signed in to change notification settings - Fork 5
/
QuizTagSwitcher.java
50 lines (40 loc) · 1.68 KB
/
QuizTagSwitcher.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package org.genericsystem.quiz.utils;
import org.genericsystem.reactor.Context;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.context.TagSwitcher;
import org.genericsystem.reactor.contextproperties.SelectionDefaults;
import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
import javafx.beans.value.ObservableValue;
public class QuizTagSwitcher {
public static class ACTIVE_QUIZ implements TagSwitcher {
@Override
public ObservableValue<Boolean> apply(Context context, Tag tag) {
Property<Context> selectionProperty = ((SelectionDefaults) tag).getSelectionProperty(context);
return Bindings.createBooleanBinding(() -> selectionProperty.getValue() != null, selectionProperty);
}
}
public static class NO_ACTIVE_QUIZ implements TagSwitcher {
@Override
public ObservableValue<Boolean> apply(Context context, Tag tag) {
Property<Context> selectionProperty = ((SelectionDefaults) tag).getSelectionProperty(context);
return Bindings.createBooleanBinding(() -> selectionProperty.getValue() == null, selectionProperty);
}
}
public static class QUIZ_END implements TagSwitcher {
@Override
public ObservableValue<Boolean> apply(Context context, Tag tag) {
return tag.getProperty("Quiz Done", context);
}
}
public static class QUIZ_RUNNING implements TagSwitcher {
@Override
public ObservableValue<Boolean> apply(Context context, Tag tag) {
Property<Boolean> selectionProperty = tag.getProperty("Quiz Done", context);
return Bindings.createBooleanBinding(() -> {
System.out.println("Etat de Quiz Done : " + selectionProperty.getValue());
return selectionProperty.getValue() == false;
}, selectionProperty);
}
}
}