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; ...@@ -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.SavePoint;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment; import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement; 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.Getter;
import lombok.Setter; import lombok.Setter;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -13,6 +16,11 @@ import org.apache.logging.log4j.Logger; ...@@ -13,6 +16,11 @@ import org.apache.logging.log4j.Logger;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.io.IOException; 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 class SaveCommand implements CommandHandler<KeyData> {
public static final String SAVE_COMMAND_NAME = "#save"; public static final String SAVE_COMMAND_NAME = "#save";
...@@ -47,10 +55,28 @@ public class SaveCommand implements CommandHandler<KeyData> { ...@@ -47,10 +55,28 @@ public class SaveCommand implements CommandHandler<KeyData> {
consoleLogger.info("(Safepoint) Location to be saved to = " + newFile.getAbsolutePath()); consoleLogger.info("(Safepoint) Location to be saved to = " + newFile.getAbsolutePath());
try { 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 //TODO Call to key persistend facade
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} }
} }
......
...@@ -25,7 +25,11 @@ public class SavePoint { ...@@ -25,7 +25,11 @@ public class SavePoint {
if (isSaveCommand(call)) { if (isSaveCommand(call)) {
Parameters p = call.getParameters(); Parameters p = call.getParameters();
name = evalAsText(p, "#2", "not-available"); 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 { try {
startOffset = call.getRuleContext().getStart().getStartIndex(); startOffset = call.getRuleContext().getStart().getStartIndex();
......
...@@ -8,6 +8,7 @@ import edu.kit.iti.formal.psdbg.interpreter.KeYProofFacade; ...@@ -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.KeyInterpreter;
import edu.kit.iti.formal.psdbg.interpreter.data.SavePoint; import edu.kit.iti.formal.psdbg.interpreter.data.SavePoint;
import edu.kit.iti.formal.psdbg.interpreter.dbg.Breakpoint; 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.ProofScript;
import edu.kit.iti.formal.psdbg.parser.ast.Statements; import edu.kit.iti.formal.psdbg.parser.ast.Statements;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
...@@ -153,6 +154,7 @@ public class ScriptExecutionController { ...@@ -153,6 +154,7 @@ public class ScriptExecutionController {
private void executeScript0(InterpreterBuilder ib, private void executeScript0(InterpreterBuilder ib,
Collection<? extends Breakpoint> breakpoints, Collection<? extends Breakpoint> breakpoints,
ProofScript ms, boolean addInitBreakpoint) { ProofScript ms, boolean addInitBreakpoint) {
ib.setProblemPath(mainCtrl.getFacade().getFilepath());
KeyInterpreter interpreter = ib.build(); KeyInterpreter interpreter = ib.build();
mainCtrl.createDebuggerFramework(breakpoints, ms, addInitBreakpoint, interpreter); 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