-
Notifications
You must be signed in to change notification settings - Fork 5
/
PageSwitcher.java
33 lines (26 loc) · 1.13 KB
/
PageSwitcher.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
package org.genericsystem.ir.gui.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 PageSwitcher {
public static final String PAGE = "page";
public static final String HOME_PAGE = "homePage";
public static final String FILTERS_STATISTICS = "filtersStatistics";
public static class HOME_PAGE implements TagSwitcher {
@Override
public ObservableValue<Boolean> apply(Context context, Tag tag) {
Property<String> pageProperty = tag.getContextProperty(PAGE, context);
return Bindings.createBooleanBinding(() -> HOME_PAGE.equals(pageProperty.getValue()), pageProperty);
}
}
public static class FILTERS_STATISTICS implements TagSwitcher {
@Override
public ObservableValue<Boolean> apply(Context context, Tag tag) {
Property<String> pageProperty = tag.getContextProperty(PAGE, context);
return Bindings.createBooleanBinding(() -> FILTERS_STATISTICS.equals(pageProperty.getValue()), pageProperty);
}
}
}