package de.prob2.ui.consoles.b;

import java.io.File;
import java.util.ResourceBundle;

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

import de.prob2.ui.consoles.Console;
import de.prob2.ui.prob2fx.CurrentTrace;

@Singleton
public final class BConsole extends Console {
	@Inject
	private BConsole(BInterpreter bInterpreter, ResourceBundle bundle, CurrentTrace currentTrace) {
		super(bundle, bundle.getString("consoles.b.header"), bundle.getString("consoles.b.prompt.classicalB"), bInterpreter);
		
		currentTrace.addListener((o, from, to) -> {
			final String message;
			if (to == null) {
				message = bundle.getString("consoles.b.message.modelUnloaded");
			} else {
				final File modelFile = to.getStateSpace().getModel().getModelFile();
				final String name = modelFile == null ? to.getStateSpace().getMainComponent().toString() : modelFile.getName();
				message = String.format(bundle.getString("consoles.b.message.modelLoaded"), name);
			}
			this.insertText(this.getLineNumber(), 0, message + '\n');
			this.requestFollowCaret();
		});
	}
}

package de.prob2.ui.consoles.b;

import java.io.File;
import java.util.ResourceBundle;

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

import de.prob2.ui.consoles.Console;
import de.prob2.ui.prob2fx.CurrentTrace;

@Singleton
public final class BConsole extends Console {
	@Inject
	private BConsole(BInterpreter bInterpreter, ResourceBundle bundle, CurrentTrace currentTrace) {
		super(bundle, bundle.getString("consoles.b.header"), bundle.getString("consoles.b.prompt.classicalB"), bInterpreter);
		
		currentTrace.stateSpaceProperty().addListener((o, from, to) -> {
			final String message;
			if (to == null) {
				message = bundle.getString("consoles.b.message.modelUnloaded");
			} else {
				final File modelFile = to.getModel().getModelFile();
				final String name = modelFile == null ? to.getMainComponent().toString() : modelFile.getName();
				message = String.format(bundle.getString("consoles.b.message.modelLoaded"), name);
			}
			this.insertText(this.getLineNumber(), 0, message + '\n');
			this.requestFollowCaret();
		});
	}
}

Fix "Model loaded" messages appearing when animating
Fix "Model loaded" messages appearing when animating
