|
|
@@ -0,0 +1,73 @@
|
|
|
+package com.example.application.views.list;
|
|
|
+
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.vaadin.flow.component.Component;
|
|
|
+import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
|
|
+import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
|
|
+import com.vaadin.flow.component.textfield.TextField;
|
|
|
+import com.vaadin.flow.router.PageTitle;
|
|
|
+import com.vaadin.flow.router.Route;
|
|
|
+
|
|
|
+import java.io.BufferedWriter;
|
|
|
+import java.io.FileWriter;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+
|
|
|
+@PageTitle("Spotting")
|
|
|
+@Route(value = "spotting")
|
|
|
+public class Spotting extends HorizontalLayout {
|
|
|
+ private BufferedWriter writer;
|
|
|
+ //left
|
|
|
+ VerticalLayout left = new VerticalLayout(Alignment.END);
|
|
|
+ TextField left_one = new TextField("Pfeil 1");
|
|
|
+ TextField left_two = new TextField("Pfeil 2");
|
|
|
+ TextField left_three = new TextField("Pfeil 3");
|
|
|
+
|
|
|
+
|
|
|
+ //right
|
|
|
+ VerticalLayout right = new VerticalLayout(Alignment.START);
|
|
|
+ TextField right_one = new TextField("Pfeil 1");
|
|
|
+ TextField right_two = new TextField("Pfeil 2");
|
|
|
+ TextField right_three = new TextField("Pfeil 3");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public Spotting(){
|
|
|
+
|
|
|
+ left.add(left_one,left_two,left_three);
|
|
|
+ right.add(right_one,right_two,right_three);
|
|
|
+ init_listeners();
|
|
|
+ add(left,right);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void init_listeners(){
|
|
|
+ for (Component c : left.getChildren().toList()){
|
|
|
+ if(c instanceof TextField)
|
|
|
+ ((TextField)c).addValueChangeListener(textFieldStringComponentValueChangeEvent -> write());
|
|
|
+ }
|
|
|
+ for (Component c : right.getChildren().toList()){
|
|
|
+ if(c instanceof TextField)
|
|
|
+ ((TextField)c).addValueChangeListener(textFieldStringComponentValueChangeEvent -> write());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void write(){
|
|
|
+ Gson gson = new Gson();
|
|
|
+ String vals[] = {left_one.getValue(),left_two.getValue(),left_three.getValue(),right_one.getValue(),right_two.getValue(),right_two.getValue()};
|
|
|
+ for (String s : vals)
|
|
|
+ System.out.println(s);
|
|
|
+ try {
|
|
|
+ System.out.println("writey ditey");
|
|
|
+ writer = new BufferedWriter(new FileWriter("C:/tst/test.txt"));
|
|
|
+ writer.write(gson.toJson(vals));
|
|
|
+ writer.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ System.out.println("fooook");
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|