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