Commit d1c3fb76 authored by Sarah Grebing's avatar Sarah Grebing

Added confirmation box

parent 15b00201
Pipeline #22006 passed with stages
in 5 minutes and 32 seconds
......@@ -5,6 +5,9 @@ import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.data.SavePoint;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import lombok.Getter;
import lombok.Setter;
import org.apache.logging.log4j.LogManager;
......@@ -13,6 +16,11 @@ import org.apache.logging.log4j.Logger;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;
public class SaveCommand implements CommandHandler<KeyData> {
public static final String SAVE_COMMAND_NAME = "#save";
......@@ -47,10 +55,28 @@ public class SaveCommand implements CommandHandler<KeyData> {
consoleLogger.info("(Safepoint) Location to be saved to = " + newFile.getAbsolutePath());
try {
interpreter.getSelectedNode().getData().getProof().saveToFile(newFile);
AtomicBoolean execute = new AtomicBoolean(sp.getForce() == SavePoint.ForceOption.YES);
if(sp.getForce() == SavePoint.ForceOption.INTERACTIVE){
Semaphore semaphore = new Semaphore(0);
Platform.runLater(() -> {
Alert a = new Alert(Alert.AlertType.CONFIRMATION);
a.setTitle("Foo");
Optional<ButtonType> buttonType = a.showAndWait();
if(buttonType.isPresent() && buttonType.get() == ButtonType.OK){
execute.set(true);
}
semaphore.release();
});
semaphore.acquire();
}
if(execute.get())
interpreter.getSelectedNode().getData().getProof().saveToFile(newFile);
//TODO Call to key persistend facade
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
......
......@@ -25,7 +25,11 @@ public class SavePoint {
if (isSaveCommand(call)) {
Parameters p = call.getParameters();
name = evalAsText(p, "#2", "not-available");
force = ForceOption.valueOf(evalAsText(p, "force", "yes").toUpperCase());
try{
force = ForceOption.valueOf(evalAsText(p, "force", "yes").toUpperCase());
} catch (IllegalArgumentException e){
}
try {
startOffset = call.getRuleContext().getStart().getStartIndex();
......
......@@ -8,6 +8,7 @@ import edu.kit.iti.formal.psdbg.interpreter.KeYProofFacade;
import edu.kit.iti.formal.psdbg.interpreter.KeyInterpreter;
import edu.kit.iti.formal.psdbg.interpreter.data.SavePoint;
import edu.kit.iti.formal.psdbg.interpreter.dbg.Breakpoint;
import edu.kit.iti.formal.psdbg.parser.Facade;
import edu.kit.iti.formal.psdbg.parser.ast.ProofScript;
import edu.kit.iti.formal.psdbg.parser.ast.Statements;
import javafx.scene.control.Alert;
......@@ -153,6 +154,7 @@ public class ScriptExecutionController {
private void executeScript0(InterpreterBuilder ib,
Collection<? extends Breakpoint> breakpoints,
ProofScript ms, boolean addInitBreakpoint) {
ib.setProblemPath(mainCtrl.getFacade().getFilepath());
KeyInterpreter interpreter = ib.build();
mainCtrl.createDebuggerFramework(breakpoints, ms, addInitBreakpoint, interpreter);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment