package de.prob2.ui.consoles.groovy;

import java.io.IOException;

import com.google.inject.Inject;
import com.google.inject.Singleton;

import de.prob2.ui.prob2fx.CurrentStage;

import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Singleton
public final class GroovyConsoleStage extends Stage {
	private static final Logger logger = LoggerFactory.getLogger(GroovyConsoleStage.class);

	@FXML private GroovyConsole groovyConsole;
	
	private final GroovyInterpreter interpreter;

	@Inject
	private GroovyConsoleStage(FXMLLoader loader, CurrentStage currentStage, GroovyInterpreter interpreter) {
		try {
			loader.setLocation(getClass().getResource("groovy_console_stage.fxml"));
			loader.setRoot(this);
			loader.setController(this);
			loader.load();
		} catch (IOException e) {
			logger.error("loading fxml failed", e);
		}
		this.interpreter = interpreter;
		
		currentStage.register(this);
	}
	
	@FXML
	public void initialize() {
		groovyConsole.setInterpreter(interpreter);
		this.setOnCloseRequest(e -> groovyConsole.closeObjectStage());
	}
}

@@ -678,16 +678,53 @@
 eter) %7B%0A
+%09%09this.interpreter = interpreter;%0A%09%09%0A
 %09%09try %7B%0A
@@ -952,42 +952,8 @@
 %09%09%7D%0A
-%09%09this.interpreter = interpreter;%0A
 %09%09%0A%09

Fix Groovy console interpreter not being set properly