-
Notifications
You must be signed in to change notification settings - Fork 5
/
QuizTagSwitcher.java
47 lines (35 loc) · 1.53 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
package org.genericsystem.quiz.utils;
import org.genericsystem.reactor.Context;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.context.TagSwitcher;
import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
import javafx.beans.value.ObservableValue;
public class QuizTagSwitcher {
public final static String PAGE = "Page";
public final static String HOME_PAGE = "HomePage";
public final static String QUESTION_PAGE = "QuestionPage";
public final static String RESULT_PAGE = "ResultPage";
// ************* NAVIGATION ENTRE LES PAGES **********************
public static class HOME_PAGE implements TagSwitcher {
@Override
public ObservableValue<Boolean> apply(Context context, Tag tag) {
Property<String> pageProperty = tag.getProperty(PAGE, context);
return Bindings.createBooleanBinding(() -> HOME_PAGE.equals(pageProperty.getValue()), pageProperty);
}
}
public static class QUESTION_PAGE implements TagSwitcher {
@Override
public ObservableValue<Boolean> apply(Context context, Tag tag) {
Property<String> pageProperty = tag.getProperty(PAGE, context);
return Bindings.createBooleanBinding(() -> QUESTION_PAGE.equals(pageProperty.getValue()), pageProperty);
}
}
public static class RESULT_PAGE implements TagSwitcher {
@Override
public ObservableValue<Boolean> apply(Context context, Tag tag) {
Property<String> pageProperty = tag.getProperty(PAGE, context);
return Bindings.createBooleanBinding(() -> RESULT_PAGE.equals(pageProperty.getValue()), pageProperty);
}
}
}