Commit 5fa9b68a authored by Sarah Grebing's avatar Sarah Grebing

Merge remote-tracking branch 'origin/grebing_luong_workbranch' into grebing_luong_workbranch

parents 5b801d08 a41d9894
......@@ -140,6 +140,22 @@ public class RuleCommandHandler implements CommandHandler<KeyData> {
state.getGoals().add(new GoalNode<>(expandedNode, kdn, kdn.getNode().isClosed()));
}
} catch (ScriptException e) {
//TODO: adding UserinteractionWindow
/*TODO: possible cases not applicable, because
command not recognized
command multiple matches -> need more specification with on + formula
command not complete -> missig parameters
solution:
if(e.getMessage().equals("Not a unique \\assumes instantiation")) {
//TODO: open UserinteractionWindow
//TODO: apply completed TacletApp
//TODO: insert into script
}
*/
if (interpreter.isStrictMode()) {
throw new ScriptCommandNotApplicableException(e, c, map);
} else {
......
package edu.kit.iti.formal.psdbg.examples.applyEq;
import edu.kit.iti.formal.psdbg.examples.Example;
public class ApplyEqExample extends Example {
public ApplyEqExample() {
setName("ApplyEq");
defaultInit(getClass());
}
}
......@@ -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;
......@@ -35,6 +36,7 @@ import edu.kit.iti.formal.psdbg.interpreter.data.SavePoint;
import edu.kit.iti.formal.psdbg.interpreter.data.State;
import edu.kit.iti.formal.psdbg.interpreter.dbg.*;
import edu.kit.iti.formal.psdbg.parser.ASTDiff;
import edu.kit.iti.formal.psdbg.parser.Facade;
import edu.kit.iti.formal.psdbg.parser.ast.ASTNode;
import edu.kit.iti.formal.psdbg.parser.ast.ProofScript;
import edu.kit.iti.formal.psdbg.storage.KeyPersistentFacade;
......@@ -50,12 +52,14 @@ import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.FileChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.commons.io.FileUtils;
......@@ -1325,14 +1329,29 @@ public class DebuggerMain implements Initializable {
if(startnode == null) return;
stg.createGraph(startnode, FACADE.getProof().root());
TreeItem<TreeNode> item = (stg.toView());
scriptTreeView.setModel(model);
scriptTreeView.setFACADE(FACADE);
scriptTreeView.setTree(item);
scriptTreeView.setStg(stg);
scriptTreeView.toView();
/*TreeItem<AbstractTreeNode> item = (stg.toView());
scriptTreeView.setTree(item);
*/
}
@FXML
public void showUserInteractionW(ActionEvent actionEvent) {
Stage stage = new Stage();
stage.setTitle("Userinteraction");
Scene scene = new Scene(new UserinteractionWindow());
stage.setScene(scene);
stage.show();
}
public DockNode getJavaAreaDock() {
return javaAreaDock;
......@@ -1405,7 +1424,7 @@ public class DebuggerMain implements Initializable {
keyWindow.makePrettyView();
keyWindow.setVisible(true);
} catch (SecurityException e) {
e.printStackTrace();
// e.printStackTrace();
}
......@@ -1565,7 +1584,7 @@ public class DebuggerMain implements Initializable {
private class KeYSecurityManager extends SecurityManager {
@Override public void checkExit(int status) {
throw new SecurityException();
throw new SecurityException("KeY window closed");
}
@Override public void checkPermission(Permission perm) {
......
......@@ -325,6 +325,14 @@ public class InteractiveModeController {
model.setSelectedGoalNodeToShow(last);
} catch (Exception e) {
if (e.getClass().equals(ScriptException.class)) {
if (e.getMessage().equals("Not a unique \\assumes instantiation")) {
//TODO: open UserinteractionWindow
//TODO: apply completed TacletApp
//TODO: insert into script
}
System.out.println("e.getMessage() = " + e.getMessage());
throw new ScriptCommandNotApplicableException(e, c, map);
......
......@@ -24,9 +24,7 @@ public class ProofTreeContextMenu extends javafx.scene.control.ContextMenu {
MenuItem showSequent = new MenuItem("Show Sequent");
MenuItem showGoal = new MenuItem("Show in Goal List");
MenuItem expandAllNodes = new MenuItem("Expand Tree");
MenuItem showScriptTree = new MenuItem("Show ScriptTree");
//TODO: zum Testen
private ProofTree proofTree;
......@@ -88,8 +86,7 @@ public class ProofTreeContextMenu extends javafx.scene.control.ContextMenu {
proofTree.expandRootToLeaves(proofTree.getTreeProof().getRoot());
});
//TODO SCRIPTTREE ACTION
//showScriptTree.setOnAction(event -> proofTree.getTreeScriptCreation().showScriptTree());
getItems().setAll(refresh, expandAllNodes, new SeparatorMenuItem(), copy, createCases, showSequent, showGoal, showScriptTree);
getItems().setAll(refresh, expandAllNodes, new SeparatorMenuItem(), copy, createCases, showSequent, showGoal);
setAutoFix(true);
setAutoHide(true);
}
......
......@@ -29,7 +29,7 @@ public class AbstractTreeNode {
}
public TreeNode toTreeNode() {
return new TreeNode("no to string method yet", null);
return new TreeNode("Proof", 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.TreeNode;
import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.dbg.PTreeNode;
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement;
import edu.kit.iti.formal.psdbg.parser.ast.GuardedCaseStatement;
import edu.kit.iti.formal.psdbg.parser.ast.MatchExpression;
import edu.kit.iti.formal.psdbg.parser.ast.TermLiteral;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
/**
* This calss represents a node in the script tree, whcih can be of different kinds.
* The scriptTreeNodes is the model calls for TreeNodes
*/
public class RepeatTreeNode extends AbstractTreeNode {
@Getter
private final PTreeNode<KeyData> scriptState;
@Getter @Setter
private final int linenr;
private final boolean repeatstart;
public RepeatTreeNode(Node node, PTreeNode<KeyData> scriptState, int linenr, boolean repeatstart) {
super(node);
this.scriptState = scriptState;
this.linenr = linenr;
this.repeatstart = repeatstart;
}
@Override
public String toString(){
return scriptState.getStatement().toString()+" with ID "+scriptState.getId();
}
@Override
public TreeNode toTreeNode() {
String label= (repeatstart)? "repeat in line " + linenr + " START": "repeat in line " + linenr + " END";
return new TreeNode(label, getNode());
}
}
\ No newline at end of file
package edu.kit.iti.formal.psdbg.gui.controls;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView;
import de.uka.ilkd.key.pp.LogicPrinter;
import edu.kit.iti.formal.psdbg.LabelFactory;
import edu.kit.iti.formal.psdbg.gui.controller.Events;
import javafx.collections.ObservableList;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.TreeItem;
public class ScriptTreeContextMenu extends javafx.scene.control.ContextMenu {
MenuItem copyBranchLabel = new MenuItem("Branch Label");
MenuItem copyProgramLines = new MenuItem("Program Lines");
MenuItem createCases = new MenuItem("Created Case for Open Goals");
MenuItem refresh = new MenuItem("Refresh (TOFIX)");
MenuItem showSequent = new MenuItem("Show Sequent");
MenuItem showGoal = new MenuItem("Show in Goal List");
MenuItem expandAllNodes = new MenuItem("Expand Tree");
private ScriptTreeView scriptTreeView;
public ScriptTreeContextMenu(ScriptTreeView scriptTreeView) {
this.scriptTreeView = scriptTreeView;
refresh.setOnAction(event -> scriptTreeView.setTree(scriptTreeView.toView()));
refresh.setGraphic(new MaterialDesignIconView(MaterialDesignIcon.REFRESH));
expandAllNodes.setOnAction((event) -> {
expandRootToLeaves(scriptTreeView.treeView.getRoot());
});
getItems().setAll(refresh, expandAllNodes); //, new SeparatorMenuItem(), createCases, showSequent, showGoal);
setAutoFix(true);
setAutoHide(true);
/*
copyBranchLabel.setOnAction(evt -> proofTree.consumeNode(n -> Utils.intoClipboard(
LabelFactory.getBranchingLabel(n)), "Copied!"));
copyProgramLines.setOnAction(evt -> {
proofTree.consumeNode(n -> {
Utils.intoClipboard(
LabelFactory.getProgramLines(n));
}, "Copied!");
});
MenuItem copySequent = new MenuItem("Sequent");
copySequent.setOnAction(evt -> {
proofTree.consumeNode(n -> {
assert proofTree.getServices() != null : "set KeY services!";
String s = LogicPrinter.quickPrintSequent(n.sequent(), proofTree.getServices());
Utils.intoClipboard(s);
}, "Copied!");
});
MenuItem copyRulesLabel = new MenuItem("Rule labels");
copyRulesLabel.setOnAction(evt -> {
proofTree.consumeNode(n -> {
Utils.intoClipboard(
LabelFactory.getRuleLabel(n));
}, "Copied!");
});
MenuItem copyProgramStatements = new MenuItem("Statements");
copyProgramStatements.setOnAction(event -> {
proofTree.consumeNode(n -> {
Utils.intoClipboard(
LabelFactory.getProgramStatmentLabel(n));
}, "Copied!");
});
Menu copy = new Menu("Copy", new MaterialDesignIconView(MaterialDesignIcon.CONTENT_COPY),
copyBranchLabel, copyProgramLines,
copyProgramStatements, copyRulesLabel,
copySequent);
createCases.setOnAction(this::onCreateCases);
showSequent.setOnAction((evt) ->
proofTree.consumeNode(n -> Events.fire(new Events.ShowSequent(n)), ""));
showGoal.setOnAction((evt) -> proofTree.consumeNode(n -> Events.fire(new Events.SelectNodeInGoalList(n)), "Found!"));
//TODO SCRIPTTREE ACTION
getItems().setAll(refresh, expandAllNodes, new SeparatorMenuItem(), copy, createCases, showSequent, showGoal);
setAutoFix(true);
setAutoHide(true);
*/
}
static void expandRootToLeaves(TreeItem candidate) {
if (candidate != null) {
if (!candidate.isLeaf()) {
candidate.setExpanded(true);
ObservableList<TreeItem> children = candidate.getChildren();
children.forEach(treeItem -> expandRootToLeaves(treeItem));
}
}
}
}
package edu.kit.iti.formal.psdbg.gui.controls;
import com.sun.javafx.css.Style;
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 edu.kit.iti.formal.psdbg.gui.model.DebuggerMainModel;
import edu.kit.iti.formal.psdbg.interpreter.KeYProofFacade;
import edu.kit.iti.formal.psdbg.interpreter.dbg.PTreeNode;
import javafx.beans.binding.Bindings;
import javafx.beans.property.MapProperty;
import javafx.beans.property.SimpleMapProperty;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.control.*;
import javafx.scene.control.cell.TextFieldTreeCell;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.CornerRadii;
import javafx.util.StringConverter;
import lombok.Setter;
import java.awt.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -26,30 +31,51 @@ public class ScriptTreeView extends BorderPane {
@Setter
private ScriptTreeGraph stg;
private ContextMenu contextMenu;
private ScriptTreeNode rootNode;
private Map<Node, AbstractTreeNode> mapping;
@Setter
private DebuggerMainModel model;
@Setter
private KeYProofFacade FACADE;
/**
* 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);
treeView.setCellFactory(this::cellFactory);
stg = new ScriptTreeGraph();
setOnContextMenuRequested(evt -> {
getContextMenu().show(this, evt.getScreenX(), evt.getScreenY());
});
}
public void setTree(TreeItem<TreeNode> tree) {
public void setTree(TreeItem<AbstractTreeNode> tree) {
treeView.setRoot(tree);
}
private TreeCell<TreeNode> cellFactory(TreeView<TreeNode> nodeTreeView) {
TextFieldTreeCell<TreeNode> tftc = new TextFieldTreeCell<>();
StringConverter<TreeNode> stringConverter = new StringConverter<TreeNode>() {
private TreeCell<AbstractTreeNode> cellFactory(TreeView<AbstractTreeNode> nodeTreeView) {
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;
}
};
......@@ -60,6 +86,7 @@ public class ScriptTreeView extends BorderPane {
repaint(tftc);
});
//colorOfNodes.addListener((InvalidationListener) o -> repaint(tftc));
return tftc;
}
......@@ -69,27 +96,46 @@ public class ScriptTreeView extends BorderPane {
* returns treeItem that represents current Script tree
* @return
*/
public TreeItem<AbstractTreeNode> toView() {
TreeItem<AbstractTreeNode> treeItem;
PTreeNode startnode;
try {
startnode = (model.getDebuggerFramework() != null) ?
model.getDebuggerFramework().getPtreeManager().getStartNode() :
null;
} catch (NullPointerException e) {
treeItem = new TreeItem<>(new AbstractTreeNode(null));
DummyGoalNode dummy = new DummyGoalNode(null, false);
treeItem.getChildren().add(new TreeItem<>(dummy));
/*
public TreeItem<TreeNode> toView () {
TreeItem<TreeNode> treeItem;
ScriptTreeNode rootNode = stg.getRootNode();
Map<Node, AbstractTreeNode> mapping = stg.getMapping();
if(rootNode == null) {
treeItem = new TreeItem<>(new TreeNode("Proof", null));
this.setTree(treeItem);
return treeItem;
}
//No script executed
if (startnode == null) {
System.out.println("Entered maybe redundaant toview(inside) method"); //TODO
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));
this.setTree(treeItem);
return treeItem;
}
treeItem = new TreeItem<>(new TreeNode("Proof", rootNode.getNode()));
stg.createGraph(startnode, FACADE.getProof().root());
rootNode = stg.getRootNode();
mapping = stg.getMapping();
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;
}
......@@ -97,18 +143,20 @@ public class ScriptTreeView extends BorderPane {
if (children.size() != 0) {
children.forEach(k -> treeItem.getChildren().add(rekursiveToView(k)));
}
this.setTree(treeItem);
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) {
......@@ -120,29 +168,42 @@ 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.styleProperty().unbind();
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(item instanceof ScriptTreeNode) {
if (!item.isSucc()) {
tftc.setStyle("-fx-text-fill: grey");
}
} else if (item instanceof BranchLabelNode) {
tftc.setStyle("-fx-text-fill: blue");
} else if (item instanceof ForeachTreeNode) {
if(stg.getMapping().get(n) instanceof BranchLabelNode){
colorOfNodes.putIfAbsent(n, "gray");
}
} else if (item instanceof DummyGoalNode) {
if (n.isClosed()) {
tftc.styleProperty().setValue("-fx-background-color: lightgreen");
//styleProperty().bind(tftc.styleProperty());
if (colorOfNodes.containsKey(n)) {
tftc.setStyle("-fx-background-color: " + colorOfNodes.get(n) + ";");
} else {
tftc.styleProperty().setValue("-fx-background-color: indianred");
//styleProperty().bind(tftc.styleProperty());
// tftc.setStyle("-fx-background-color: indianred");
//colorOfNodes.putIfAbsent(n, "indianred");
}
}
}
}
public ContextMenu getContextMenu() {
if (contextMenu == null) {
contextMenu = new ScriptTreeContextMenu(this);
}
return contextMenu;
}
}
package edu.kit.iti.formal.psdbg.gui.controls;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.layout.BorderPane;
public class UserinteractionWindow extends BorderPane {
@FXML
Button cancelButton;
@FXML
Button applyButton;
@FXML
TextArea tacletDescription;
public UserinteractionWindow() {
Utils.createWithFXML(this);
}
}
edu.kit.iti.formal.psdbg.examples.contraposition.ContrapositionExample
edu.kit.iti.formal.psdbg.examples.fol.FirstOrderLogicExample
edu.kit.iti.formal.psdbg.examples.applyEq.ApplyEqExample
edu.kit.iti.formal.psdbg.examples.java.simple.JavaSimpleExample
edu.kit.iti.formal.psdbg.examples.java.maxtriplet.MaxTripletExample
#edu.kit.iti.formal.psdbg.examples.java.transitive.PaperExample
......
// This file is part of KeY - Integrated Deductive Software Design
//
// Copyright (C) 2001-2011 Universitaet Karlsruhe (TH), Germany
// Universitaet Koblenz-Landau, Germany
// Chalmers University of Technology, Sweden
// Copyright (C) 2011-2013 Karlsruhe Institute of Technology, Germany
// Technical University Darmstadt, Germany
// Chalmers University of Technology, Sweden