-
Notifications
You must be signed in to change notification settings - Fork 5
/
QuizTagSwitcher.java
29 lines (24 loc) · 1.07 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
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);
}
}
}