-
Notifications
You must be signed in to change notification settings - Fork 3
/
TestGUI2.recaf
60 lines (49 loc) · 1.23 KB
/
TestGUI2.recaf
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
54
55
56
57
58
59
60
package generated;
import recaf.demo.direct.GUI;
import recaf.demo.direct.GUI.Render;
import recaf.demo.direct.GUI.Handle;
import java.util.stream.IntStream;
import java.util.Iterator;
import java.io.StringWriter;
public class TestGUI2 {
private recaf GUI alg;
public TestGUI2(GUI alg) {
this.alg = alg;
}
recaf void h2(String title) {
tag ("h2") {
echo! title;
}
}
static Iterable<Integer> range(int n) {
return new Iterable<Integer>() {
public Iterator<Integer> iterator() {
return IntStream.range(0, n).iterator();
}
};
}
static void println(String x) {
System.out.println(x);
}
static
//BEGIN_HELLOES
void hello(recaf GUI alg, int n) {
tag ("div")
for (int i: range(n))
button ("Click " + i)
println("clicked " + i);
}
//END_HELLOES
static void sendToServer(String x) {
System.out.println(x);
}
public static void main(String args[]) {
//BEGIN_CLIENT_GUI
StringWriter w = new StringWriter();
hello(new Render(w), 10);
sendToServer(w.toString());
// ... receive the clicked id; assume it's "id2"
hello(new Handle("id2"), 10); // prints out "clicked 2"
//END_CLIENT_GUI
}
}