package SW9.model_canvas.querying;

import SW9.backend.BackendException;
import SW9.backend.UPPAALDriver;
import SW9.model_canvas.ModelContainer;
import SW9.model_canvas.Parent;
import SW9.utility.colors.Color;
import SW9.utility.helpers.LocationAware;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.geometry.Insets;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;

import java.util.function.Consumer;

public class QueryField extends Parent implements LocationAware {

    private final DoubleProperty xProperty = new SimpleDoubleProperty();
    private final DoubleProperty yProperty = new SimpleDoubleProperty();
    private final TextField textField = new TextField();
    private static final double FIELD_WIDTH = 500;

    public QueryField(final double x, final double y, final ModelContainer modelContainer) {
        xProperty().setValue(x);
        yProperty().setValue(y);

        textField.layoutXProperty().bind(xProperty());
        textField.layoutYProperty().bind(yProperty());
        textField.setPrefWidth(FIELD_WIDTH);
        textField.setBackground(new Background(new BackgroundFill(javafx.scene.paint.Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));

        addChild(textField);
        textField.setOnKeyPressed(event -> {

            if (event.getCode() != KeyCode.ENTER) return;

            final String query = textField.getText();

            for(int i = 0; i < 50; i++ ) {

                final int sager = i;
                final Consumer<Boolean> success = result -> {
                    final Color color = result ? Color.GREEN : Color.RED;
                    textField.setBackground(new Background(new BackgroundFill(color.getColor(Color.Intensity.I500), CornerRadii.EMPTY, Insets.EMPTY)));
                    textField.setStyle("-fx-text-fill: #ffffff;");
                    System.out.println(sager);
                };

                final Consumer<BackendException> failure = e -> {
                    textField.setStyle("-fx-text-fill: #ff0000;");
                    textField.setBackground(new Background(new BackgroundFill(javafx.scene.paint.Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
                };

                UPPAALDriver.verify(query, modelContainer, success, failure);
            }
        });
    }

    @Override
    public DoubleProperty xProperty() {
        return xProperty;
    }

    @Override
    public DoubleProperty yProperty() {
        return yProperty;
    }

}

@@ -250,54 +250,8 @@
 re;%0A
-import javafx.beans.property.BooleanProperty;%0A
 impo
@@ -1572,93 +1572,8 @@
 );%0A%0A
-            for(int i = 0; i %3C 50; i++ ) %7B%0A%0A                final int sager = i;%0A    
     
@@ -1622,28 +1622,24 @@
 result -%3E %7B%0A
-    
             
@@ -1704,36 +1704,32 @@
                 
-  
-  
 textField.setBac
@@ -1852,36 +1852,32 @@
                 
-    
 textField.setSty
@@ -1923,67 +1923,12 @@
     
-        System.out.println(sager);%0A                %7D;%0A%0A    
+%7D;%0A%0A
     
@@ -1993,36 +1993,32 @@
                 
-    
 textField.setSty
@@ -2044,28 +2044,24 @@
 #ff0000;%22);%0A
-    
             
@@ -2198,36 +2198,28 @@
             
-    %7D;%0A%0A    
+%7D;%0A%0A
             
@@ -2284,22 +2284,8 @@
 e);%0A
-            %7D%0A
     

Remove test loop (used to test threaded verification)