Commit 591415cf authored by Alexander Weigl's avatar Alexander Weigl

working on new ProofTree view

parent 35f07285
Pipeline #22015 passed with stages
in 5 minutes and 32 seconds
package edu.kit.iti.formal.psdbg.parser;
import edu.kit.iti.formal.psdbg.parser.ast.*;
import javafx.util.Pair;
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement;
import edu.kit.iti.formal.psdbg.parser.ast.Parameters;
......
......@@ -166,4 +166,12 @@ public abstract class ASTNode<T extends ParserRuleContext>
public int hashCode() {
return Objects.hash(getRuleContext());
}
public int getSyntaxWidth() {
if (ruleContext != null) {
return ruleContext.stop.getStopIndex()
- ruleContext.start.getStartIndex();
}
return -1;
}
}
......@@ -16,7 +16,6 @@ import javafx.beans.binding.BooleanBinding;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.concurrent.Task;
import jdk.nashorn.internal.objects.annotations.Getter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.key_project.util.collection.ImmutableList;
......
......@@ -23,6 +23,8 @@ import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.data.State;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import edu.kit.iti.formal.psdbg.interpreter.exceptions.ScriptCommandNotApplicableException;
import edu.kit.iti.formal.psdbg.interpreter.exceptions.VariableNotDeclaredException;
import edu.kit.iti.formal.psdbg.interpreter.exceptions.VariableNotDefinedException;
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement;
import edu.kit.iti.formal.psdbg.parser.ast.Variable;
import lombok.Getter;
......@@ -154,7 +156,11 @@ public class RuleCommandHandler implements CommandHandler<KeyData> {
private Map<String, Object> createParameters(VariableAssignment assignments) {
Map<String, Object> params = new HashMap<>();
for (String s : MAGIC_PARAMETER_NAMES) {
params.put(s, assignments.getValue(new Variable(Variable.MAGIC_PREFIX + s)));
try {
params.put(s, assignments.getValue(new Variable(Variable.MAGIC_PREFIX + s)));
} catch (VariableNotDefinedException | VariableNotDeclaredException e) {
}
}
return params;
}
......
......@@ -4,6 +4,7 @@ import edu.kit.iti.formal.psdbg.ShortCommandPrinter;
import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode;
import edu.kit.iti.formal.psdbg.interpreter.data.State;
import edu.kit.iti.formal.psdbg.parser.ast.ASTNode;
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement;
import edu.kit.iti.formal.psdbg.parser.ast.CaseStatement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
......@@ -11,6 +12,7 @@ import lombok.Setter;
import javax.annotation.Nullable;
import java.util.*;
import java.util.stream.Collectors;
/**
* PTreeNode represents a node in the state graph.
......@@ -111,11 +113,21 @@ public class PTreeNode<T> {
/**
* Calculate a span of bytes of the syntactical representation.
*
* @return
*/
int getSyntaxWidth() {
return getStatement().getRuleContext().stop.getStopIndex()
- getStatement().getRuleContext().start.getStartIndex();
return getStatement().getSyntaxWidth();
}
public Collection<GoalNode<T>> getMutatedNodes() {
if (statement instanceof CallStatement) {//TODO better predicate for mutators
return Collections.emptyList();
}
assert stateAfterStmt != null && stateBeforeStmt != null;
ArrayList<PTreeNode<T>> list = new ArrayList<>();
GoalNode<T> incoming = stateBeforeStmt.getSelectedGoalNode();
return stateAfterStmt.getGoals().stream().filter(gn -> gn.getParent() == incoming).collect(Collectors.toList());
}
}
\ No newline at end of file
......@@ -19,11 +19,14 @@ lessCompile {
processResources.dependsOn lessCompile
dependencies {
compile group: 'de.jensd', name: 'fontawesomefx-materialdesignfont', version: '2.0.26-9.1.2'
compile group: 'de.jensd', name: 'fontawesomefx-commons', version: '9.1.2'
compile group: 'de.jensd', name: 'fontawesomefx-materialdesignfont', version: '1.7.22-4'
compile group: 'de.jensd', name: 'fontawesomefx-commons', version: '8.15'
// compile group: 'de.jensd', name: 'fontawesomefx-materialdesignfont', version: '2.0.26-9.1.2'
// compile group: 'de.jensd', name: 'fontawesomefx-commons', version: '9.1.2'
compile group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.9.0'
//compile group: 'org.fxmisc.richtext', name: 'richtextfx', version: '1.0.0-SNAPSHOT'
compile group: 'org.controlsfx', name: 'controlsfx', version: '9.0.0'
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.12'
compile group: 'org.antlr', name: 'antlr4', version: '4.7'
antlr group: 'org.antlr', name: 'antlr4', version: '4.7'
......@@ -36,7 +39,7 @@ dependencies {
def mainClassName = 'edu.kit.iti.formal.psdbg.gui.ProofScriptDebugger'
task runApp(type: JavaExec) {
jvmArgs << '-Dsun.awt.disablegrab=true' << '-Dglass.disableGrab=true'
/*applicationDefaultJvmArgs = [
// For accessing VirtualFlow field from the base class in GridViewSkin
"--add-opens=javafx.controls/javafx.scene.control.skin=ALL-UNNAMED",
......
......@@ -8,8 +8,6 @@ import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -32,10 +30,8 @@ public class ProofScriptDebugger extends Application {
public static final String VERSION = "Experimental-1.1";
public static final String KEY_VERSION = KeYConstants.VERSION;
private Logger logger = LogManager.getLogger("psdbg");
private static Logger consoleLogger = LogManager.getLogger("console");
private Logger logger = LogManager.getLogger("psdbg");
public static void main(String[] args) {
launch(args);
......@@ -50,11 +46,15 @@ public class ProofScriptDebugger extends Application {
DebuggerMain controller = fxmlLoader.getController();
Scene scene = new Scene(root);
primaryStage.setOnCloseRequest(event -> Platform.exit());
scene.getStylesheets().addAll(
getClass().getResource("debugger-ui.css").toExternalForm(),
DockNode.class.getResource("default.css").toExternalForm()
);
logger.info("Loading CSS class " + getClass().getResource("debugger-ui.css").toExternalForm());
try {
scene.getStylesheets().addAll(
getClass().getResource("debugger-ui.css").toExternalForm(),
DockNode.class.getResource("default.css").toExternalForm()
);
logger.info("Loading CSS class " + getClass().getResource("debugger-ui.css").toExternalForm());
} catch (NullPointerException e) {
consoleLogger.error(e);
}
primaryStage.setTitle(NAME + " (" + VERSION + ") with KeY:" + KEY_VERSION);
primaryStage.setScene(scene);
......
......@@ -155,7 +155,7 @@ public class DebuggerMain implements Initializable {
new MaterialDesignIconView(MaterialDesignIcon.CODEPEN)
);
//-----------------------------------------------------------------------------------------------------------------
private ProofTree proofTree = new ProofTree();
private ProofTree proofTree = new ProofTree(this);
private DockNode proofTreeDock = new DockNode(proofTree, "Proof Tree");
private WelcomePane welcomePane = new WelcomePane(this);
private DockNode welcomePaneDock = new DockNode(welcomePane, "Welcome", new MaterialDesignIconView(MaterialDesignIcon.ACCOUNT));
......@@ -1334,7 +1334,7 @@ public class DebuggerMain implements Initializable {
GoalNode<KeyData> beforeNode = original.getStateBeforeStmt().getSelectedGoalNode();
List<GoalNode<KeyData>> stateAfterStmt = original.getStateAfterStmt().getGoals();
ProofTree ptree = new ProofTree();
ProofTree ptree = new ProofTree(DebuggerMain.this);
Proof proof = beforeNode.getData().getProof();
Node pnode = beforeNode.getData().getNode();
......@@ -1342,7 +1342,7 @@ public class DebuggerMain implements Initializable {
ptree.setProof(proof);
ptree.setRoot(pnode);
ptree.addNodeColor(pnode, "blueviolet");
ptree.setNodeColor(pnode, "blueviolet");
ptree.setDeactivateRefresh(true);
if (stateAfterStmt.size() > 0) {
......@@ -1351,7 +1351,7 @@ public class DebuggerMain implements Initializable {
.map(Goal::node)
.collect(Collectors.toSet());
ptree.getSentinels().addAll(sentinels);
sentinels.forEach(node -> ptree.addNodeColor(node, "blueviolet"));
sentinels.forEach(node -> ptree.setNodeColor(node, "blueviolet"));
} else {
Set<Node> sentinels = new HashSet<>();
Iterator<Node> nodeIterator = beforeNode.getData().getNode().leavesIterator();
......@@ -1361,7 +1361,7 @@ public class DebuggerMain implements Initializable {
sentinels.add(next);
}
ptree.getSentinels().addAll(sentinels);
sentinels.forEach(node -> ptree.addNodeColor(node, "blueviolet"));
sentinels.forEach(node -> ptree.setNodeColor(node, "blueviolet"));
//traverseProofTreeAndAddSentinelsToLeaves();
}
......@@ -1391,7 +1391,7 @@ public class DebuggerMain implements Initializable {
GoalNode<KeyData> beforeNode = stepInvOver.getStateBeforeStmt().getSelectedGoalNode();
List<GoalNode<KeyData>> stateAfterStmt = stepInvOver.getStateAfterStmt().getGoals();
ProofTree ptree = new ProofTree();
ProofTree ptree = new ProofTree(DebuggerMain.this);
Proof proof = beforeNode.getData().getProof();
Node pnode = beforeNode.getData().getNode();
......@@ -1399,7 +1399,7 @@ public class DebuggerMain implements Initializable {
ptree.setProof(proof);
ptree.setRoot(pnode);
ptree.addNodeColor(pnode, "blueviolet");
ptree.setNodeColor(pnode, "blueviolet");
ptree.setDeactivateRefresh(true);
if (stateAfterStmt.size() > 0) {
......@@ -1408,7 +1408,7 @@ public class DebuggerMain implements Initializable {
.map(Goal::node)
.collect(Collectors.toSet());
ptree.getSentinels().addAll(sentinels);
sentinels.forEach(node -> ptree.addNodeColor(node, "blueviolet"));
sentinels.forEach(node -> ptree.setNodeColor(node, "blueviolet"));
} else {
Set<Node> sentinels = new HashSet<>();
Iterator<Node> nodeIterator = beforeNode.getData().getNode().leavesIterator();
......@@ -1418,7 +1418,7 @@ public class DebuggerMain implements Initializable {
sentinels.add(next);
}
ptree.getSentinels().addAll(sentinels);
sentinels.forEach(node -> ptree.addNodeColor(node, "blueviolet"));
sentinels.forEach(node -> ptree.setNodeColor(node, "blueviolet"));
//traverseProofTreeAndAddSentinelsToLeaves();
}
......
package edu.kit.iti.formal.psdbg.gui.controls;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import de.uka.ilkd.key.java.Services;
import de.uka.ilkd.key.pp.LogicPrinter;
import de.uka.ilkd.key.proof.Node;
import de.uka.ilkd.key.proof.Proof;
import de.uka.ilkd.key.proof.ProofTreeEvent;
import de.uka.ilkd.key.proof.ProofTreeListener;
import edu.kit.iti.formal.psdbg.LabelFactory;
import edu.kit.iti.formal.psdbg.ShortCommandPrinter;
import edu.kit.iti.formal.psdbg.gui.controller.DebuggerMain;
import edu.kit.iti.formal.psdbg.gui.controller.Events;
import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.dbg.PTreeNode;
import edu.kit.iti.formal.psdbg.interpreter.dbg.ProofTreeManager;
import edu.kit.iti.formal.psdbg.parser.ast.ASTNode;
import javafx.application.Platform;
import javafx.beans.property.*;
import javafx.collections.FXCollections;
......@@ -17,42 +21,38 @@ import javafx.collections.ObservableList;
import javafx.collections.ObservableMap;
import javafx.collections.ObservableSet;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.ContextMenu;
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;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.val;
import lombok.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
/**
* KeY Proof Tree
*
* @author weigl
*/
public class ProofTree extends BorderPane {
@Getter
@Setter
private Services services;// = DebuggerMain.FACADE.getService();
private ObjectProperty<Proof> proof = new SimpleObjectProperty<>();
private ObjectProperty<Node> root = new SimpleObjectProperty<>();
private SetProperty<Node> sentinels = new SimpleSetProperty<>(FXCollections.observableSet());
private MapProperty<Node, String> colorOfNodes = new SimpleMapProperty<Node, String>(FXCollections.observableHashMap());
@FXML
private TreeView<TreeNode> treeProof;
private ContextMenu contextMenu;
@Getter @Setter
private Services services;// = DebuggerMain.FACADE.getService();
private BooleanProperty deactivateRefresh = new SimpleBooleanProperty();
private ProofTreeListener proofTreeListener = new ProofTreeListener() {
......@@ -106,9 +106,15 @@ public class ProofTree extends BorderPane {
}
};
private TreeTransformationKey treeCreation;
public ProofTree() {
public ProofTree(DebuggerMain main) {
Utils.createWithFXML(this);
//TODO remove this hack for a better solution
main.getModel().debuggerFrameworkProperty().addListener((p, n, m) -> {
treeCreation = new TreeTransformationScript(m.getPtreeManager());
});
treeProof.setCellFactory(this::cellFactory);
root.addListener(o -> init());
proof.addListener((prop, old, n) -> {
......@@ -129,8 +135,7 @@ public class ProofTree extends BorderPane {
*
* @param candidate
*/
private static void expandRootToItem(TreeItem candidate) {
private static void expandRootToItem(TreeItem<TreeNode> candidate) {
if (candidate != null) {
expandRootToItem(candidate.getParent());
if (!candidate.isLeaf()) {
......@@ -139,7 +144,7 @@ public class ProofTree extends BorderPane {
}
}
private static void expandRootToLeaves(TreeItem candidate) {
static void expandRootToLeaves(TreeItem candidate) {
if (candidate != null) {
if (!candidate.isLeaf()) {
candidate.setExpanded(true);
......@@ -150,15 +155,8 @@ public class ProofTree extends BorderPane {
}
}
public static String toString(Node object) {
if (object.getAppliedRuleApp() != null) {
return object.getAppliedRuleApp().rule().name().toString();
} else {
return object.isClosed() ? "CLOSED GOAL" : "OPEN GOAL";
}
}
public void addNodeColor(Node n, String color) {
public void setNodeColor(Node n, String color) {
this.colorOfNodes.put(n, color);
}
......@@ -176,7 +174,6 @@ public class ProofTree extends BorderPane {
//expandRootToLeaves(getTreeProof().getRoot());
}
public TreeView<TreeNode> getTreeProof() {
return treeProof;
}
......@@ -194,115 +191,7 @@ public class ProofTree extends BorderPane {
public ContextMenu getContextMenu() {
if (contextMenu == null) {
MenuItem refresh = new MenuItem("Refresh");
refresh.setOnAction(event -> repopulate());
refresh.setGraphic(new MaterialDesignIconView(MaterialDesignIcon.REFRESH));
MenuItem copyBranchLabel = new MenuItem("Branch Label");
copyBranchLabel.setOnAction(evt -> consumeNode(n -> Utils.intoClipboard(
LabelFactory.getBranchingLabel(n)), "Copied!"));
MenuItem copyProgramLines = new MenuItem("Program Lines");
copyProgramLines.setOnAction(evt -> {
consumeNode(n -> {
Utils.intoClipboard(
LabelFactory.getProgramLines(n));
}, "Copied!");
});
MenuItem copySequent = new MenuItem("Sequent");
copySequent.setOnAction(evt -> {
consumeNode(n -> {
assert services != null : "set KeY services!";
String s = LogicPrinter.quickPrintSequent(n.sequent(), services);
Utils.intoClipboard(s);
}, "Copied!");
});
MenuItem copyRulesLabel = new MenuItem("Rule labels");
copyRulesLabel.setOnAction(evt -> {
consumeNode(n -> {
Utils.intoClipboard(
LabelFactory.getRuleLabel(n));
}, "Copied!");
});
MenuItem copyProgramStatements = new MenuItem("Statements");
copyProgramStatements.setOnAction(event -> {
consumeNode(n -> {
Utils.intoClipboard(
LabelFactory.getProgramStatmentLabel(n));
}, "Copied!");
});
Menu copy = new Menu("Copy", new MaterialDesignIconView(MaterialDesignIcon.CONTENT_COPY),
copyBranchLabel, copyProgramLines,
copyProgramStatements, copyRulesLabel,
copySequent);
MenuItem createCases = new MenuItem("Created Case for Open Goals");
createCases.setOnAction((evt) ->
{
if (proof.get() != null) {
List<String[]> labels = LabelFactory.getLabelOfOpenGoals(proof.get(),
LabelFactory::getBranchingLabel);
String text;
if (labels.isEmpty()) {
text = "// no open goals";
} else if (labels.size() == 1) {
text = "// only one goal";
} else {
int upperLimit = 0;
/* trying to find the common suffix*/
try {
String[] ref = labels.get(0);
for (; true; upperLimit++) {
for (String[] lbl : labels) {
if (!lbl[upperLimit].equals(ref[upperLimit])) {
break;
}
}
upperLimit++;
}
} catch (ArrayIndexOutOfBoundsException e) {
}
int finalUpperLimit = upperLimit;
text = labels.stream()
.map(a -> Arrays.stream(a, finalUpperLimit, a.length))
.map(s -> s.reduce((a, b) -> b + LabelFactory.SEPARATOR + a).orElse("error"))
.map(s -> String.format("\tcase match \"%s\" :\n\t\t//commands", s))
.reduce((a, b) -> a + "\n" + b)
.orElse("ERROR");
}
String s = "cases {\n" + text + "\n}";
Events.fire(new Events.InsertAtTheEndOfMainScript(s));
Events.fire(new Events.PublishMessage("Copied to Clipboard"));
} else {
}
});
MenuItem showSequent = new MenuItem("Show Sequent");
showSequent.setOnAction((evt) ->
consumeNode(n -> Events.fire(new Events.ShowSequent(n)), ""));
MenuItem showGoal = new MenuItem("Show in Goal List");
showGoal.setOnAction((evt) -> {
consumeNode(n -> Events.fire(new Events.SelectNodeInGoalList(n)), "Found!");
});
MenuItem expandAllNodes = new MenuItem("Expand Tree");
expandAllNodes.setOnAction((event) -> {
expandRootToLeaves(treeProof.getRoot());
});
contextMenu = new ContextMenu(refresh, expandAllNodes, new SeparatorMenuItem(), copy, createCases, showSequent, showGoal);
contextMenu.setAutoFix(true);
contextMenu.setAutoHide(true);
contextMenu = new ProofTreeContextMenu(this);
}
return contextMenu;
}
......@@ -311,90 +200,6 @@ public class ProofTree extends BorderPane {
}
private void repopulate() {
if (deactivateRefresh.get())
return;
if (root.get() != null) {
TreeItem<TreeNode> item = populate("Proof", root.get());
treeProof.setRoot(item);
}
treeProof.refresh();
}
private TreeItem<TreeNode> populate(String label, Node n) {
val treeNode = new TreeNode(label, n);
TreeItem<TreeNode> ti = new TreeItem<>(treeNode);
// abort the traversing iff we have reached a sentinel!
if (sentinels.contains(n)) {
return ti;
}
if (label.equals("Proof")) { //we are at the root
TreeItem<TreeNode> self1 = new TreeItem<>(new TreeNode(n.serialNr() + ": " + toString(n), n));
ti.getChildren().add(self1);
}
//if we are at a leaf we need to check goal state
if (n.childrenCount() == 0) {
// TreeItem<TreeNode> e = new TreeItem<>(new TreeNode(
// n.isClosed() ? "CLOSED GOAL" : "OPEN GOAL", null));
/* if(!label.equals("Proof")) {
TreeItem<TreeNode> self = new TreeItem<>(new TreeNode(n.serialNr() + ": " + toString(n), n));
ti.getChildren().addCell(self);
}*/
// ti.getChildren().addCell(e);
return ti;
}
Node node = n.child(0);
if (n.childrenCount() == 1) {
ti.getChildren().add(new TreeItem<>(new TreeNode(node.serialNr() + ": " + toString(node), node)));
while (node.childrenCount() == 1) {
node = node.child(0);
ti.getChildren().add(new TreeItem<>(new TreeNode(node.serialNr() + ": " + toString(node), node)));
}
}
if (node.childrenCount() == 0) {
} else { // children count > 1
Iterator<Node> nodeIterator = node.childrenIterator();
Node childNode;
int branchCounter = 1;
while (nodeIterator.hasNext()) {
childNode = nodeIterator.next();
if (childNode.getNodeInfo().getBranchLabel() != null) {
TreeItem<TreeNode> populate = populate(childNode.getNodeInfo().getBranchLabel(), childNode);
// TreeItem<TreeNode> self = new TreeItem<>(new TreeNode(childNode.serialNr() + ": " + toString(childNode), childNode));
// populate.getChildren().addCell(0, self);
ti.getChildren().add(populate);
} else {
TreeItem<TreeNode> populate = populate("BRANCH " + branchCounter, childNode);
TreeItem<TreeNode> self = new TreeItem<>(new TreeNode(childNode.serialNr() + ": " + toString(childNode), childNode));
populate.getChildren().add(0, self);
ti.getChildren().add(populate);
branchCounter++;
}
}
/* node.childrenIterator().forEachRemaining(child -> ti.getChildren().addCell(
populate(child.getNodeInfo().getBranchLabel(), child)));
*/
//node.children().forEach(child ->
// ti.getChildren().addCell(populate(child.getNodeInfo().getBranchLabel(), child)));
}
return ti;
}
private TreeCell<TreeNode> cellFactory(TreeView<TreeNode> nodeTreeView) {
TextFieldTreeCell<TreeNode> tftc = new TextFieldTreeCell<>();
StringConverter<TreeNode> stringConverter = new StringConverter<TreeNode>() {
......@@ -434,7 +239,7 @@ public class ProofTree extends BorderPane {
tftc.setStyle("-fx-background-color: " + colorOfNodes.get(n) + ";");
}
}
//TODO for Screenshot tftc.setStyle("-fx-font-size: 18pt");
//TODO for Screenshot tftc.setStyle("-fx-font-size: 18pt");
/* if (colorOfNodes.containsKey(n)) {
tftc.setStyle("-fx-border-color: "+colorOfNodes.get(n)+";");
}*/
......@@ -444,7 +249,6 @@ public class ProofTree extends BorderPane {
}
public MapProperty<Node, String> colorOfNodesProperty() {
return colorOfNodes;
}
......@@ -461,7 +265,6 @@ public class ProofTree extends BorderPane {
return root.get();
}
public void setRoot(Node root) {
this.root.set(root);
......@@ -507,10 +310,164 @@ public class ProofTree extends BorderPane {
return deactivateRefresh;
}
private TreeItem<TreeNode> populate(String label, Node node) {
return null;
}
public void repopulate() {
if (deactivateRefresh.get())
return;
if (root.get() != null) {
TreeItem<TreeNode> item = treeCreation.create(proof.get());
treeProof.setRoot(item);
}
treeProof.refresh();
}
@AllArgsConstructor
private static class TreeNode {
String label;
Node node;
}
class TreeTransformationKey {
public TreeItem<TreeNode> create(Proof proof) {
TreeItem<TreeNode> self1 = new TreeItem<>(new TreeNode("Proof", null));
self1.getChildren().add(populate("Proof", proof.root()));
return self1;
}
protected TreeItem<TreeNode> itemFactory(Node n) {
return new TreeItem<>(new TreeNode(n.serialNr() + ": " + toString(n), n));
}
protected String toString(Node object) {
if (object.getAppliedRuleApp() != null) {
return object.getAppliedRuleApp().rule().name().toString();
} else {
return object.isClosed() ? "CLOSED GOAL" : "OPEN GOAL";
}
}
/**
* recursive population.
*
* @param label
* @param n
* @return
*/
protected TreeItem<TreeNode> populate(String label, Node n) {
val treeNode = new TreeNode(label, n);
TreeItem<TreeNode> currentItem = itemFactory(n);
new TreeItem<>(treeNode);