Commit f2597ce9 authored by Lulu Luong's avatar Lulu Luong

#45

parent 587cb51a
Pipeline #31419 failed with stages
......@@ -20,6 +20,7 @@ import edu.kit.iti.formal.psdbg.examples.Examples;
import edu.kit.iti.formal.psdbg.fmt.DefaultFormatter;
import edu.kit.iti.formal.psdbg.gui.ProofScriptDebugger;
import edu.kit.iti.formal.psdbg.gui.controls.*;
import edu.kit.iti.formal.psdbg.gui.controls.ScriptTree.AbstractTreeNode;
import edu.kit.iti.formal.psdbg.gui.graph.Graph;
import edu.kit.iti.formal.psdbg.gui.graph.GraphView;
import edu.kit.iti.formal.psdbg.gui.model.DebuggerMainModel;
......@@ -1325,7 +1326,7 @@ public class DebuggerMain implements Initializable {
if(startnode == null) return;
stg.createGraph(startnode, FACADE.getProof().root());
TreeItem<TreeNode> item = (stg.toView());
TreeItem<AbstractTreeNode> item = (stg.toView());
scriptTreeView.setTree(item);
......
......@@ -29,7 +29,7 @@ public class AbstractTreeNode {
}
public TreeNode toTreeNode() {
return new TreeNode("no to string method yet", null);
return new TreeNode("Proof", null);
}
}
......@@ -44,10 +44,7 @@ public class ScriptTreeGraph {
private HashMap<Node, PTreeNode> foreachNodes;
/**
* Contains color of nodes
*/
public MapProperty<Node, String> colorOfNodes = new SimpleMapProperty<Node, String>(FXCollections.observableHashMap());
public void createGraph(PTreeNode<KeyData> rootPTreeNode, Node root) {
......@@ -174,30 +171,30 @@ public class ScriptTreeGraph {
}
mapping.size();
mapping.forEach((node, abstractTreeNode) -> System.out.println("node.serialNr() = " + node.serialNr() + " " + abstractTreeNode.toTreeNode().label));
// mapping.forEach((node, abstractTreeNode) -> System.out.println("node.serialNr() = " + node.serialNr() + " " + abstractTreeNode.toTreeNode().label));
}
/**
* returns treeItem that represents current Script tree
* @return
*/
public TreeItem<TreeNode> toView () {
TreeItem<TreeNode> treeItem;
public TreeItem<AbstractTreeNode> toView () {
TreeItem<AbstractTreeNode> treeItem;
if(rootNode == null) {
treeItem = new TreeItem<>(new TreeNode("Proof", null));
treeItem = new TreeItem<>(new AbstractTreeNode(null));
DummyGoalNode dummy = new DummyGoalNode(null, false);
treeItem.getChildren().add(new TreeItem<>(dummy.toTreeNode()));
treeItem.getChildren().add(new TreeItem<>(dummy));
return treeItem;
}
treeItem = new TreeItem<>(new TreeNode("Proof", rootNode.getNode()));
treeItem = new TreeItem<>(new AbstractTreeNode(null));
List<AbstractTreeNode> children = mapping.get(rootNode.getNode()).getChildren();
if (children == null) return treeItem;
treeItem.getChildren().add(new TreeItem<>(mapping.get(rootNode.getNode()).toTreeNode()));
treeItem.getChildren().add(new TreeItem<>(mapping.get(rootNode.getNode())));
while (children.size() == 1) {
treeItem.getChildren().add(new TreeItem<>(children.get(0).toTreeNode()));
treeItem.getChildren().add(new TreeItem<>(children.get(0)));
children = children.get(0).getChildren();
if(children == null) return treeItem;
}
......@@ -209,15 +206,15 @@ public class ScriptTreeGraph {
return treeItem;
}
private TreeItem<TreeNode> rekursiveToView (AbstractTreeNode current){
TreeItem<TreeNode> treeItem = new TreeItem<>(current.toTreeNode()); //
private TreeItem<AbstractTreeNode> rekursiveToView (AbstractTreeNode current){
TreeItem<AbstractTreeNode> treeItem = new TreeItem<>(current); //
List<AbstractTreeNode> children = current.getChildren();
while (children != null && children.size() == 1) {
if(children.get(0) == null) return treeItem;
treeItem.getChildren().add(new TreeItem<>(children.get(0).toTreeNode()));
treeItem.getChildren().add(new TreeItem<>(children.get(0)));
children = children.get(0).getChildren();
}
if (children == null) {
......@@ -554,8 +551,6 @@ public class ScriptTreeGraph {
}
colorOfNodes.putIfAbsent(branchlabels.get(i).getNode(), "gray");
}
......@@ -580,54 +575,9 @@ public class ScriptTreeGraph {
front.forEach(k -> replacePlaceholder(k, new DummyGoalNode(k, k.isClosed())));
}
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;
}
private void repaint(TextFieldTreeCell<TreeNode> tftc) {
TreeNode item = tftc.getItem();
Node n = item.node;
tftc.setStyle("");
if (n != null) {
if (n.leaf() && !item.label.contains("BRANCH")) {
if (n.isClosed()) {
colorOfNodes.putIfAbsent(n, "lightseagreen");
//tftc.setStyle("-fx-background-color: greenyellow");
} else {
colorOfNodes.putIfAbsent(n, "indianred");
}
if (colorOfNodes.containsKey(n)) {
tftc.setStyle("-fx-background-color: " + colorOfNodes.get(n) + ";");
}
}
//TODO for Screenshot tftc.setStyle("-fx-font-size: 18pt");
/* if (colorOfNodes.containsKey(n)) {
tftc.setStyle("-fx-border-color: "+colorOfNodes.get(n)+";");
}*/
}
//expandRootToItem(tftc.getTreeItem());
}
}
......
......@@ -2,10 +2,7 @@ package edu.kit.iti.formal.psdbg.gui.controls;
import de.uka.ilkd.key.proof.Node;
import edu.kit.iti.formal.psdbg.gui.controller.DebuggerMain;
import edu.kit.iti.formal.psdbg.gui.controls.ScriptTree.AbstractTreeNode;
import edu.kit.iti.formal.psdbg.gui.controls.ScriptTree.BranchLabelNode;
import edu.kit.iti.formal.psdbg.gui.controls.ScriptTree.DummyGoalNode;
import edu.kit.iti.formal.psdbg.gui.controls.ScriptTree.ScriptTreeNode;
import edu.kit.iti.formal.psdbg.gui.controls.ScriptTree.*;
import javafx.beans.property.MapProperty;
import javafx.beans.property.SimpleMapProperty;
import javafx.collections.FXCollections;
......@@ -26,9 +23,15 @@ public class ScriptTreeView extends BorderPane {
@Setter
private ScriptTreeGraph stg;
/**
* Contains color of nodes
*/
private MapProperty<Node, String> colorOfNodes = new SimpleMapProperty<Node, String>(FXCollections.observableHashMap());
@FXML
TreeView<TreeNode> treeView;
TreeView<AbstractTreeNode> treeView;
public ScriptTreeView(DebuggerMain main) {
Utils.createWithFXML(this);
......@@ -36,21 +39,21 @@ public class ScriptTreeView extends BorderPane {
}
public void setTree(TreeItem<TreeNode> tree) {
public void setTree(TreeItem<AbstractTreeNode> tree) {
treeView.setRoot(tree);
}
private TreeCell<TreeNode> cellFactory(TreeView<TreeNode> nodeTreeView) {
private TreeCell<AbstractTreeNode> cellFactory(TreeView<AbstractTreeNode> nodeTreeView) {
TextFieldTreeCell<TreeNode> tftc = new TextFieldTreeCell<>();
StringConverter<TreeNode> stringConverter = new StringConverter<TreeNode>() {
TextFieldTreeCell<AbstractTreeNode> tftc = new TextFieldTreeCell<>();
StringConverter<AbstractTreeNode> stringConverter = new StringConverter<AbstractTreeNode>() {
@Override
public String toString(TreeNode object) {
return object.label;
public String toString(AbstractTreeNode object) {
return object.toTreeNode().label;
}
@Override
public TreeNode fromString(String string) {
public AbstractTreeNode fromString(String string) {
return null;
}
};
......@@ -123,24 +126,35 @@ public class ScriptTreeView extends BorderPane {
return treeItem;
}
*/
private void repaint(TextFieldTreeCell<TreeNode> tftc) {
TreeNode item = tftc.getItem();
Node n = item.node;
private void repaint(TextFieldTreeCell<AbstractTreeNode> tftc) {
AbstractTreeNode item = tftc.getItem();
Node n = item.getNode();
tftc.setStyle("");
if (n != null) {
if (n.leaf() && !item.label.contains("BRANCH")) {
if(item instanceof ScriptTreeNode) {
tftc.setStyle("-fx-text-fill: grey");
} else if (item instanceof BranchLabelNode) {
tftc.setStyle("-fx-text-fill: blue");
} else if (item instanceof ForeachTreeNode) {
} else if (item instanceof DummyGoalNode) {
if (n.isClosed()) {
stg.colorOfNodes.putIfAbsent(n, "lightseagreen");
//tftc.setStyle("-fx-background-color: greenyellow");
tftc.setStyle("-fx-background-color: lightgreen");
} else {
stg.colorOfNodes.putIfAbsent(n, "indianred");
}
if (stg.colorOfNodes.containsKey(n)) {
tftc.setStyle("-fx-background-color: " + stg.colorOfNodes.get(n) + ";");
tftc.setStyle("-fx-background-color: indianred");
//colorOfNodes.putIfAbsent(n, "indianred");
}
}
//tftc.setStyle("-fx-background-color: greenyellow");
//tftc.setStyle("-fx-background-color: " + stg.colorOfNodes.get(n) + ";");
}
}
}
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