Commit 7d7f0b21 authored by Lulu Luong's avatar Lulu Luong

Script Tree:

TODO: working view
branch labels
matches
colouring
parent 8d4f4cc3
Pipeline #24723 passed with stages
in 91 minutes and 53 seconds
......@@ -145,6 +145,8 @@ public class DebuggerMain implements Initializable {
@FXML
private CheckMenuItem miProofTree;
@FXML
private CheckMenuItem miScriptTree;
@FXML
private ToggleButton btnInteractiveMode;
@FXML
......@@ -158,6 +160,12 @@ public class DebuggerMain implements Initializable {
//-----------------------------------------------------------------------------------------------------------------
private ProofTree proofTree = new ProofTree(this);
private DockNode proofTreeDock = new DockNode(proofTree, "Proof Tree");
//TODO: anpassen
private ScriptTreeGraph scriptTreeGraph = new ScriptTreeGraph();
private ScriptTreeView scriptTreeView = new ScriptTreeView();
private DockNode scriptTreeDock = new DockNode(scriptTreeView,"Script Tree");
private WelcomePane welcomePane = new WelcomePane(this);
private DockNode welcomePaneDock = new DockNode(welcomePane, "Welcome", new MaterialDesignIconView(MaterialDesignIcon.ACCOUNT));
private DockNode activeInspectorDock;
......@@ -165,6 +173,7 @@ public class DebuggerMain implements Initializable {
private DockNode commandHelpDock = new DockNode(commandHelp, "DebuggerCommand Help");
private InteractiveModeController interactiveModeController;
private ScriptExecutionController scriptExecutionController;
@FXML
private Menu examplesMenu;
private Timer interpreterThreadTimer;
......@@ -1302,6 +1311,22 @@ public class DebuggerMain implements Initializable {
}
}
@FXML
public void showScriptTree(ActionEvent actionEvent) {
// FXML
//TODO: anpassen
if (!scriptTreeDock.isDocked() && !scriptTreeDock.isFloating()) {
scriptTreeDock.dock(dockStation, DockPos.CENTER);
}
ScriptTreeGraph stg = new ScriptTreeGraph();
stg.createGraph(model.getDebuggerFramework().getPtreeManager().getStartNode(), FACADE.getProof().root());
scriptTreeView.setTree(stg.toView());
}
public DockNode getJavaAreaDock() {
return javaAreaDock;
}
......
package edu.kit.iti.formal.psdbg.gui.controls.ScriptTree;
import edu.kit.iti.formal.psdbg.gui.controls.TreeNode;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
public class AbstractTreeNode {
@Getter @Setter
private AbstractTreeNode parent;
@Getter @Setter
private List<AbstractTreeNode> children;
@Getter @Setter
private boolean isMatchEx = false; //is a match expression
@Getter @Setter
private boolean isSucc = true; //applied successfully
public TreeNode toTreeNode() {
return new TreeNode("no to string method yet", null);
}
}
package edu.kit.iti.formal.psdbg.gui.controls.ScriptTree;
import de.uka.ilkd.key.proof.Node;
import edu.kit.iti.formal.psdbg.gui.controls.ScriptTree.AbstractTreeNode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
......
package edu.kit.iti.formal.psdbg.gui.controls.ScriptTree;
import edu.kit.iti.formal.psdbg.gui.controls.ScriptTree.AbstractTreeNode;
import de.uka.ilkd.key.proof.Node;
import edu.kit.iti.formal.psdbg.gui.controls.TreeNode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
......@@ -10,4 +11,11 @@ public class DummyGoalNode extends AbstractTreeNode {
@Getter
private final boolean closedGoal;
@Getter
private final Node node;
@Override
public TreeNode toTreeNode() {
return new TreeNode((closedGoal? "CLOSED":"OPEN"), node); //TODO:
}
}
package edu.kit.iti.formal.psdbg.gui.controls.ScriptTree;
import de.uka.ilkd.key.proof.Node;
import edu.kit.iti.formal.psdbg.gui.controls.ScriptTree.AbstractTreeNode;
import edu.kit.iti.formal.psdbg.gui.controls.TreeNode;
import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.dbg.PTreeNode;
import lombok.Getter;
......@@ -18,10 +18,26 @@ public class ScriptTreeNode extends AbstractTreeNode {
private final PTreeNode<KeyData> scriptState;
@Getter
private final Node keyNode;
@Getter @Setter
private final int linenr;
@Override
public String toString(){
return scriptState.getStatement().toString()+" with ID "+scriptState.getId();
}
@Override
public TreeNode toTreeNode() {
String label;
if (isMatchEx()) {
label = "match in line " + linenr;
} else {
label = scriptState.getStatement().getNodeName() + " (line " + linenr + ")";
}
if (!isSucc()) {
label += " (failed)";
}
return new TreeNode(label, keyNode);
}
}
package edu.kit.iti.formal.psdbg.gui.controls;
import javafx.fxml.FXML;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.control.cell.TextFieldTreeCell;
import javafx.scene.layout.BorderPane;
import javafx.util.StringConverter;
public class ScriptTreeView extends BorderPane {
@FXML
TreeView<TreeNode> treeView;
public ScriptTreeView() {
Utils.createWithFXML(this);
treeView = new TreeView<>();
treeView.setCellFactory(this::cellFactory);
}
public void setTree(TreeItem<TreeNode> tree) {
treeView.setRoot(tree);
treeView.refresh();
}
private TreeCell<TreeNode> cellFactory(TreeView<TreeNode> nodeTreeView) {
TextFieldTreeCell<TreeNode> tftc = new TextFieldTreeCell<>();
StringConverter<TreeNode> stringConverter = new StringConverter<TreeNode>() {
@Override
public String toString(TreeNode object) {
return object.label;
}
@Override
public TreeNode fromString(String string) {
return null;
}
};
tftc.setConverter(stringConverter);
/*
tftc.itemProperty().addListener((p, o, n) -> {
if (n != null)
repaint(tftc);
}); */
//colorOfNodes.addListener((InvalidationListener) o -> repaint(tftc));
return tftc;
}
}
......@@ -181,6 +181,11 @@
<MaterialDesignIconView glyphName="TREE" size="24.0"/>
</graphic>
</CheckMenuItem>
<CheckMenuItem fx:id="miScriptTree" onAction="#showScriptTree" text="Show Script Tree">
<graphic>
<MaterialDesignIconView glyphName="TREE" size="24.0"/>
</graphic>
</CheckMenuItem>
<CheckMenuItem fx:id="miCommandHelp" onAction="#showCommandHelp"
accelerator="F1"
text="Show Command Help">
......
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<fx:root type="javafx.scene.layout.BorderPane" xmlns:fx="http://javafx.com/fxml/1" fx:id="rootPane" xmlns="http://javafx.com/javafx/8.0.112">
<center>
<TreeView fx:id="treeView" editable="false">
</TreeView>
</center>
</fx:root>
\ No newline at end of file
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