-
Notifications
You must be signed in to change notification settings - Fork 5
/
GeoSearchDatalist.java
53 lines (45 loc) · 2.08 KB
/
GeoSearchDatalist.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
51
52
53
package org.genericsystem.geography.app;
import org.genericsystem.common.Generic;
import org.genericsystem.geography.app.GeoSearchDatalist.SearchInputDatalist;
import org.genericsystem.geography.model.AdministrativeTerritory;
import org.genericsystem.geography.model.Building;
import org.genericsystem.geography.model.City;
import org.genericsystem.geography.model.Country;
import org.genericsystem.reactor.Context;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.annotations.BindText;
import org.genericsystem.reactor.annotations.Children;
import org.genericsystem.reactor.annotations.DependsOnModel;
import org.genericsystem.reactor.annotations.DirectSelect;
import org.genericsystem.reactor.appserver.ApplicationServer;
import org.genericsystem.reactor.context.StringExtractor;
import org.genericsystem.reactor.context.TextBinding;
import org.genericsystem.reactor.gscomponents.HtmlTag.HtmlDatalist;
import org.genericsystem.reactor.gscomponents.HtmlTag.HtmlOption;
import org.genericsystem.reactor.gscomponents.InputWithDatalist;
import org.genericsystem.reactor.gscomponents.RootTagImpl;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.beans.value.ObservableValue;
@DependsOnModel({ AdministrativeTerritory.class, Country.class, City.class, Building.class })
@Children(SearchInputDatalist.class)
public class GeoSearchDatalist extends RootTagImpl {
public static void main(String[] mainArgs) {
ApplicationServer.startSimpleGenericApp(mainArgs, GeoSearchDatalist.class, "/GeoApp");
}
public static class GENERIC_TEXT implements TextBinding {
@Override
public ObservableValue<String> apply(Context context, Tag tag) {
Generic g = context.getGeneric();
String str = StringExtractor.SIMPLE_CLASS_EXTRACTOR.apply(g);
while (g.getBaseComponent() != null) {
g = g.getBaseComponent();
str += ", " + g.getValue();
}
return new ReadOnlyStringWrapper(str);
}
}
@DirectSelect(City.class)
@BindText(path = { HtmlDatalist.class, HtmlOption.class }, value = GENERIC_TEXT.class)
public static class SearchInputDatalist extends InputWithDatalist {
}
}