Commit fe78f6e4 authored by Sarah Grebing's avatar Sarah Grebing

Highlighting of node in proof tree, interactive mode now working a bit better

parent e9617e80
Pipeline #15277 failed with stages
in 103 minutes and 11 seconds
...@@ -128,7 +128,7 @@ public class DebuggerMain implements Initializable { ...@@ -128,7 +128,7 @@ public class DebuggerMain implements Initializable {
private CheckMenuItem miProofTree; private CheckMenuItem miProofTree;
@FXML @FXML
private Button btnIM; private ToggleButton btnInteractiveMode;
private JavaArea javaArea = new JavaArea(); private JavaArea javaArea = new JavaArea();
...@@ -199,6 +199,7 @@ public class DebuggerMain implements Initializable { ...@@ -199,6 +199,7 @@ public class DebuggerMain implements Initializable {
model.setDebugMode(false); model.setDebugMode(false);
scriptController = new ScriptController(dockStation); scriptController = new ScriptController(dockStation);
interactiveModeController = new InteractiveModeController(scriptController); interactiveModeController = new InteractiveModeController(scriptController);
btnInteractiveMode.setSelected(false);
inspectionViewsController = new InspectionViewsController(dockStation); inspectionViewsController = new InspectionViewsController(dockStation);
activeInspectorDock = inspectionViewsController.getActiveInterpreterTabDock(); activeInspectorDock = inspectionViewsController.getActiveInterpreterTabDock();
//register the welcome dock in the center //register the welcome dock in the center
...@@ -499,7 +500,7 @@ public class DebuggerMain implements Initializable { ...@@ -499,7 +500,7 @@ public class DebuggerMain implements Initializable {
Platform.runLater(() -> { Platform.runLater(() -> {
scriptController.getDebugPositionHighlighter().remove(); scriptController.getDebugPositionHighlighter().remove();
statusBar.publishSuccessMessage("Interpreter finished."); statusBar.publishSuccessMessage("Interpreter finished.");
btnIM.setDisable(false); btnInteractiveMode.setDisable(false);
assert model.getDebuggerFramework() != null; assert model.getDebuggerFramework() != null;
PTreeNode<KeyData> statePointer = model.getDebuggerFramework().getStatePointer(); PTreeNode<KeyData> statePointer = model.getDebuggerFramework().getStatePointer();
State<KeyData> lastState = statePointer.getStateAfterStmt(); State<KeyData> lastState = statePointer.getStateAfterStmt();
...@@ -858,8 +859,12 @@ public class DebuggerMain implements Initializable { ...@@ -858,8 +859,12 @@ public class DebuggerMain implements Initializable {
@FXML @FXML
public void interactiveMode(ActionEvent actionEvent) { public void interactiveMode(ActionEvent actionEvent) {
interactiveModeController.setActivated(true); if (btnInteractiveMode.isSelected()) {
interactiveModeController.start(getFacade().getProof(), getInspectionViewsController().getActiveInspectionViewTab().getModel()); interactiveModeController.start(getFacade().getProof(), getInspectionViewsController().getActiveInspectionViewTab().getModel());
} else {
interactiveModeController.stop();
}
} }
......
...@@ -67,6 +67,7 @@ public class InteractiveModeController { ...@@ -67,6 +67,7 @@ public class InteractiveModeController {
public void stop() { public void stop() {
Events.unregister(this); Events.unregister(this);
String c = getCasesAsString(); String c = getCasesAsString();
scriptController.getDockNode(scriptArea).close();
Events.fire(new Events.InsertAtTheEndOfMainScript(c)); Events.fire(new Events.InsertAtTheEndOfMainScript(c));
} }
......
...@@ -309,17 +309,19 @@ public class ProofTree extends BorderPane { ...@@ -309,17 +309,19 @@ public class ProofTree extends BorderPane {
} }
if (n.childrenCount() == 0) { if (n.childrenCount() == 0) {
ti.getChildren().add(new TreeItem<>(new TreeNode( TreeItem<TreeNode> e = new TreeItem<>(new TreeNode(
n.isClosed() ? "CLOSED GOAL" : "OPEN GOAL", null))); n.isClosed() ? "CLOSED GOAL" : "OPEN GOAL", null));
ti.getChildren().add(e);
return ti; return ti;
} }
Node node = n.child(0); Node node = n.child(0);
if (n.childrenCount() == 1) { if (n.childrenCount() == 1) {
ti.getChildren().add(new TreeItem<>(new TreeNode(toString(node), node))); ti.getChildren().add(new TreeItem<>(new TreeNode(node.serialNr() + ": " + toString(node), node)));
while (node.childrenCount() == 1) { while (node.childrenCount() == 1) {
node = node.child(0); node = node.child(0);
ti.getChildren().add(new TreeItem<>(new TreeNode(toString(node), node))); ti.getChildren().add(new TreeItem<>(new TreeNode(node.serialNr() + ": " + toString(node), node)));
} }
} }
...@@ -364,20 +366,24 @@ public class ProofTree extends BorderPane { ...@@ -364,20 +366,24 @@ public class ProofTree extends BorderPane {
} }
}; };
tftc.setConverter(stringConverter); tftc.setConverter(stringConverter);
tftc.itemProperty().addListener((p, o, n) -> {
//tftc.itemProperty().addListener((p, o, n) -> repaint(tftc)); if (n != null)
repaint(tftc);
});
//colorOfNodes.addListener((InvalidationListener) o -> repaint(tftc)); //colorOfNodes.addListener((InvalidationListener) o -> repaint(tftc));
return tftc; return tftc;
} }
/*private void repaint(TextFieldTreeCell<TreeNode> tftc) { private void repaint(TextFieldTreeCell<TreeNode> tftc) {
Node n = tftc.getItem().node; Node n = tftc.getItem().node;
tftc.setStyle(""); tftc.setStyle("");
if (n != null) { if (n != null && n.leaf()) {
if (n.isClosed()) { if (n.isClosed()) {
colorOfNodes.putIfAbsent(n, "green"); colorOfNodes.putIfAbsent(n, "seagreen");
//tftc.setStyle("-fx-background-color: greenyellow"); //tftc.setStyle("-fx-background-color: greenyellow");
} else {
colorOfNodes.putIfAbsent(n, "darkred");
} }
if (colorOfNodes.containsKey(n)) { if (colorOfNodes.containsKey(n)) {
tftc.setStyle("-fx-background-color: " + colorOfNodes.get(n) + ";"); tftc.setStyle("-fx-background-color: " + colorOfNodes.get(n) + ";");
...@@ -385,7 +391,7 @@ public class ProofTree extends BorderPane { ...@@ -385,7 +391,7 @@ public class ProofTree extends BorderPane {
} }
expandRootToItem(tftc.getTreeItem()); expandRootToItem(tftc.getTreeItem());
}*/ }
public Object getColorOfNodes() { public Object getColorOfNodes() {
return colorOfNodes.get(); return colorOfNodes.get();
......
...@@ -15,8 +15,6 @@ import javafx.beans.value.ChangeListener; ...@@ -15,8 +15,6 @@ import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableMap; import javafx.collections.ObservableMap;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -122,46 +120,6 @@ public class ScriptController { ...@@ -122,46 +120,6 @@ public class ScriptController {
return getDockNode(findEditor(filepath)); return getDockNode(findEditor(filepath));
} }
private DockNode getDockNode(ScriptArea editor) {
if (editor == null) {
return null;
}
return openScripts.get(editor);
}
/**
* Create a new Tab in the ScriptTabPane containing the contents of the file given as argument
*
* @param filePath to file that should be loaded to new tab
* @return refernce to new scriptArea in new tab
* @throws IOException if an Exception occurs while loading file
*/
public ScriptArea createNewTab(File filePath) throws IOException {
filePath = filePath.getAbsoluteFile();
if (findEditor(filePath) == null) {
ScriptArea area = new ScriptArea();
area.mainScriptProperty().bindBidirectional(mainScript);
area.setFilePath(filePath);
DockNode dockNode = createDockNode(area);
openScripts.put(area, dockNode);
if (filePath.exists()) {
String code = FileUtils.readFileToString(filePath, "utf-8");
if (!area.textProperty().getValue().isEmpty()) {
area.deleteText(0, area.textProperty().getValue().length());
}
area.setText(code);
}
return area;
} else {
logger.info("File already exists. Will not load it again");
ScriptArea area = findEditor(filePath);
return area;
}
}
/** /**
* Create new DockNode for ScriptArea Tab * Create new DockNode for ScriptArea Tab
* *
...@@ -178,7 +136,7 @@ public class ScriptController { ...@@ -178,7 +136,7 @@ public class ScriptController {
if (lastScriptArea == null) if (lastScriptArea == null)
dockNode.dock(parent, DockPos.LEFT); dockNode.dock(parent, DockPos.LEFT);
else else
dockNode.dock(parent, DockPos.LEFT, getDockNode(lastScriptArea)); dockNode.dock(parent, DockPos.CENTER, getDockNode(lastScriptArea));
area.dirtyProperty().addListener(new ChangeListener<Boolean>() { area.dirtyProperty().addListener(new ChangeListener<Boolean>() {
@Override @Override
...@@ -200,6 +158,46 @@ public class ScriptController { ...@@ -200,6 +158,46 @@ public class ScriptController {
return dockNode; return dockNode;
} }
/**
* Create a new Tab in the ScriptTabPane containing the contents of the file given as argument
*
* @param filePath to file that should be loaded to new tab
* @return refernce to new scriptArea in new tab
* @throws IOException if an Exception occurs while loading file
*/
public ScriptArea createNewTab(File filePath) throws IOException {
filePath = filePath.getAbsoluteFile();
if (findEditor(filePath) == null) {
ScriptArea area = new ScriptArea();
area.mainScriptProperty().bindBidirectional(mainScript);
area.setFilePath(filePath);
DockNode dockNode = createDockNode(area);
openScripts.put(area, dockNode);
if (filePath.exists()) {
String code = FileUtils.readFileToString(filePath, "utf-8");
if (!area.textProperty().getValue().isEmpty()) {
area.deleteText(0, area.textProperty().getValue().length());
}
area.setText(code);
}
return area;
} else {
logger.info("File already exists. Will not load it again");
ScriptArea area = findEditor(filePath);
return area;
}
}
public DockNode getDockNode(ScriptArea editor) {
if (editor == null) {
return null;
}
return openScripts.get(editor);
}
/** /**
* Get all breakpoints in the current area * Get all breakpoints in the current area
* *
......
...@@ -6,15 +6,25 @@ script test(){ ...@@ -6,15 +6,25 @@ script test(){
exLeft; exLeft;
andLeft; andLeft;
eqSymm formula = `agatha = butler`; eqSymm formula = `agatha = butler`;
nnf_imp2or formula=`\foral S w6;(hates(agatha,w6) -> hates(butler,w6))`; nnf_imp2or formula=`\forall S w6;(hates(agatha,w6) -> hates(butler,w6))`;
} }
script SolveAgathaRiddle_1() { script SolveAgathaRiddle_1() {
impRight; impRight;
andLeft; andLeft;
notLeft; notLeft;
repeat { andLeft; }
exLeft;
andLeft;
eqSymm formula = `agatha = butler`;
auto;
}
script SolveAgathaRiddle_2() {
impRight;
andLeft;
notLeft;
andLeft; andLeft;
andLeft; andLeft;
...@@ -31,23 +41,7 @@ script SolveAgathaRiddle_1() { ...@@ -31,23 +41,7 @@ script SolveAgathaRiddle_1() {
exLeft; exLeft;
andLeft; andLeft;
eqSymm formula = `agatha = butler`; eqSymm formula = `agatha = butler`;
nnf_imp2or formula=`\forall S w6;(hates(agatha,w6) -> hates(butler,w6))`;
auto; auto;
//nnf_imp2or on= `hates(agatha, w6) -> hates(butler, w6)`;
//nnf_imp2or; -> wirft hier ScriptCommandNotApplicableException
//wirft ansonsten immer java.lang.RuntimeException: de.uka.ilkd.key.macros.scripts.meta.ConversionException: Could not convert value hates(agatha, w6) -> hates(butler, w6) to type interface de.uka.ilkd.key.logic.Term
// at
//nnf_imp2or formula= `hates(agatha, w6) -> hates(butler, w6)`;
//nnf_imp2or on = `hates(agatha, w6) -> hates(butler, w6)` formula=` \forall S w6; (hates(agatha, w6) -> hates(butler, w6))`;
} }
script SolveAgathaRiddle_2() {
impRight;
andLeft;
notLeft;
repeat { andLeft; }
exLeft;
andLeft;
eqSymm formula = `agatha = butler`;
auto;
}
\ No newline at end of file
...@@ -9,8 +9,7 @@ class Bubblesort { ...@@ -9,8 +9,7 @@ class Bubblesort {
@*/ @*/
public int[] bubbleSort(int[] arr) { public int[] bubbleSort(int[] arr) {
int temp = 0; int temp = 0;
/*@ /*@
@ loop_invariant 0 <= i && i <= arr.length; @ loop_invariant 0 <= i && i <= arr.length;
@ loop_invariant (\forall int a,b; a >= arr.length - i && b <= arr.length && a < b && i > 0; arr[a] <= arr[b]); @ loop_invariant (\forall int a,b; a >= arr.length - i && b <= arr.length && a < b && i > 0; arr[a] <= arr[b]);
...@@ -18,7 +17,6 @@ class Bubblesort { ...@@ -18,7 +17,6 @@ class Bubblesort {
@ decreases arr.length - i; @ decreases arr.length - i;
@*/ @*/
for(int i=0; i < arr.length; i++){ for(int i=0; i < arr.length; i++){
/*@ /*@
@ loop_invariant 1 <= j && j <= arr.length - i + 1; @ loop_invariant 1 <= j && j <= arr.length - i + 1;
@ assignable arr[*], temp; @ assignable arr[*], temp;
...@@ -41,7 +39,7 @@ class Bubblesort { ...@@ -41,7 +39,7 @@ class Bubblesort {
/*@ public normal_behaviour /*@ public normal_behaviour
@ requires arr != null; @ requires arr != null;
@ requires arr.length > 0; @ requires arr.length > 0;
@ ensures true; @ ensures \result == true;
@*/ @*/
public boolean test(int[] arr) { public boolean test(int[] arr) {
arr = bubbleSort(arr); arr = bubbleSort(arr);
......
...@@ -3,36 +3,8 @@ script t1(){ ...@@ -3,36 +3,8 @@ script t1(){
cases{ cases{
case match `?X >= 0,?X > 0 ==>`: case match `?X >= 0,?X > 0 ==>`:
cut `?X = 0`[?X \ X]; cut `?X = 0`[?X \ X];
auto; foreach{
auto;
}
} }
//foreach{
// auto;
//}
}
script t2(){
symbex;
cases{
case match '.*x.*':
auto;
default:
auto;
}
}
script t(){
symbex;
foreach{
simp_heap;
}
} }
...@@ -275,7 +275,7 @@ ...@@ -275,7 +275,7 @@
</tooltip> </tooltip>
</Button> </Button>
<Button fx:id="btnIM" onAction="#interactiveMode" disable="true"> <ToggleButton fx:id="btnInteractiveMode" onAction="#interactiveMode" disable="true">
<!--disable="${! controller.debugMode}"--> <!--disable="${! controller.debugMode}"-->
<graphic> <graphic>
<MaterialDesignIconView glyphName="HAND_POINTING_RIGHT" size="24.0"/> <MaterialDesignIconView glyphName="HAND_POINTING_RIGHT" size="24.0"/>
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
<tooltip> <tooltip>
<Tooltip text="Start/Stop Interactive Mode"/> <Tooltip text="Start/Stop Interactive Mode"/>
</tooltip> </tooltip>
</Button> </ToggleButton>
<Pane HBox.hgrow="ALWAYS"/> <Pane HBox.hgrow="ALWAYS"/>
<Label text="Windows:"/> <Label text="Windows:"/>
......
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