Commit 61e259a6 authored by Alexander Weigl's avatar Alexander Weigl

Taclet apps in rule context menu

parent f1bf6cce
......@@ -55,8 +55,8 @@ public class DebuggerMainWindowController implements Initializable {
private final ProofTreeController proofTreeController = new ProofTreeController();
private final InspectionViewsController inspectionViewsController = new InspectionViewsController();
private final ExecutorService executorService = Executors.newFixedThreadPool(2);
private final KeYProofFacade facade = new KeYProofFacade();
private final ContractLoaderService contractLoaderService = new ContractLoaderService();
public static final KeYProofFacade FACADE = new KeYProofFacade();
public final ContractLoaderService contractLoaderService = new ContractLoaderService();
/**
* Property: current loaded javaFile
*/
......@@ -89,7 +89,7 @@ public class DebuggerMainWindowController implements Initializable {
/**
* True, iff the execution is not possible
*/
private ObservableBooleanValue executeNotPossible = proofTreeController.executeNotPossibleProperty().or(facade.readyToExecuteProperty().not());
private ObservableBooleanValue executeNotPossible = proofTreeController.executeNotPossibleProperty().or(FACADE.readyToExecuteProperty().not());
/**
*
......@@ -117,7 +117,6 @@ public class DebuggerMainWindowController implements Initializable {
//statusBar.publishMessage("File: " + (newValue != null ? newValue.getAbsolutePath() : "n/a"));
//Debugging
Utils.addDebugListener(javaCode);
Utils.addDebugListener(executeNotPossible, "executeNotPossible");
......@@ -186,12 +185,12 @@ public class DebuggerMainWindowController implements Initializable {
//region Actions: Execution
@FXML
public void executeScript() {
executeScript(facade.buildInterpreter(), false);
executeScript(FACADE.buildInterpreter(), false);
}
@FXML
public void executeScriptFromCursor() {
InterpreterBuilder ib = facade.buildInterpreter();
InterpreterBuilder ib = FACADE.buildInterpreter();
// ib.inheritState(interpreterService.interpreterProperty().get());
///*
// LineMapping lm = new LineMapping(scriptArea.getText());
......@@ -204,7 +203,7 @@ public class DebuggerMainWindowController implements Initializable {
@FXML
public void executeInDebugMode() {
executeScript(facade.buildInterpreter(), true);
executeScript(FACADE.buildInterpreter(), true);
}
//endregion
......@@ -271,7 +270,7 @@ public class DebuggerMainWindowController implements Initializable {
public void openScript(File scriptFile) {
assert scriptFile != null;
setInitialDirectory(scriptFile.getParentFile() );
setInitialDirectory(scriptFile.getParentFile());
try {
String code = FileUtils.readFileToString(scriptFile, Charset.defaultCharset());
ScriptArea area = scriptController.createNewTab(scriptFile);
......@@ -291,10 +290,10 @@ public class DebuggerMainWindowController implements Initializable {
if (keyFile != null) {
setKeyFile(keyFile);
setInitialDirectory(keyFile.getParentFile());
Task<Void> task = facade.loadKeyFileTask(keyFile);
Task<Void> task = FACADE.loadKeyFileTask(keyFile);
task.setOnSucceeded(event -> {
statusBar.publishMessage("Loaded key sourceName: %s", keyFile);
getInspectionViewsController().getActiveInspectionViewTab().getModel().getGoals().setAll(facade.getPseudoGoals());
getInspectionViewsController().getActiveInspectionViewTab().getModel().getGoals().setAll(FACADE.getPseudoGoals());
});
task.setOnFailed(event -> {
......@@ -335,6 +334,7 @@ public class DebuggerMainWindowController implements Initializable {
loadJavaFile();
showCodeDock(null);
}
/**
* Creates a filechooser dialog
*
......@@ -385,7 +385,7 @@ public class DebuggerMainWindowController implements Initializable {
public KeYProofFacade getFacade() {
return facade;
return FACADE;
}
//region Property
......@@ -552,7 +552,7 @@ public class DebuggerMainWindowController implements Initializable {
public class ContractLoaderService extends Service<List<Contract>> {
@Override
protected Task<List<Contract>> createTask() {
return facade.getContractsForJavaFileTask(getJavaFile());
return FACADE.getContractsForJavaFileTask(getJavaFile());
}
@Override
......@@ -564,13 +564,13 @@ public class DebuggerMainWindowController implements Initializable {
protected void succeeded() {
statusBar.publishMessage("Contract loaded");
List<Contract> contracts = getValue();
ContractChooser cc = new ContractChooser(facade.getService(), contracts);
ContractChooser cc = new ContractChooser(FACADE.getService(), contracts);
cc.showAndWait().ifPresent(result -> {
setChosenContract(result);
try {
facade.activateContract(result);
getInspectionViewsController().getActiveInspectionViewTab().getModel().getGoals().setAll(facade.getPseudoGoals());
FACADE.activateContract(result);
getInspectionViewsController().getActiveInspectionViewTab().getModel().getGoals().setAll(FACADE.getPseudoGoals());
} catch (ProofInputException e) {
Utils.showExceptionDialog("", "", "", e);
}
......
......@@ -43,7 +43,7 @@ public class InspectionView extends BorderPane {
(observable, oldValue, newValue) -> {
goalView.getSelectionModel().select(newValue);
if (newValue != null && newValue.getData() != null) {
getSequentView().setNode(newValue.getData().getNode());
getSequentView().setNode(newValue.getData().getGoal());
// TODO weigl: get marked lines of the program, and set it
model.get().highlightedJavaLinesProperty().get()
.clear();
......
......@@ -4,10 +4,12 @@ import de.uka.ilkd.key.java.Services;
import de.uka.ilkd.key.logic.NamespaceSet;
import de.uka.ilkd.key.logic.Sequent;
import de.uka.ilkd.key.pp.*;
import de.uka.ilkd.key.proof.Node;
import de.uka.ilkd.key.proof.Goal;
import de.uka.ilkd.key.settings.ProofIndependentSettings;
import edu.kit.formal.interpreter.KeYProofFacade;
import javafx.beans.Observable;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
......@@ -26,7 +28,9 @@ public class SequentView extends CodeArea {
private LogicPrinter lp;
private IdentitySequentPrintFilter filter;
private LogicPrinter.PosTableStringBackend backend;
private SimpleObjectProperty<de.uka.ilkd.key.proof.Node> node = new SimpleObjectProperty<>();
private SimpleObjectProperty<de.uka.ilkd.key.proof.Goal> node = new SimpleObjectProperty<>();
private KeYProofFacade keYProofFacade;
private TacletContextMenu menu;
public SequentView() {
......@@ -34,11 +38,11 @@ public class SequentView extends CodeArea {
setEditable(false);
node.addListener(this::update);
setOnMouseMoved(this::hightlight);
setOnMouseClicked(this::onMouseClick);
}
private void hightlight(MouseEvent mouseEvent) {
if (backend == null) return;
CharacterHit hit = hit(mouseEvent.getX(), mouseEvent.getY());
int insertionPoint = hit.getInsertionIndex();
PosInSequent pis = backend.getInitialPositionTable().getPosInSequent(insertionPoint, filter);
......@@ -51,14 +55,26 @@ public class SequentView extends CodeArea {
mouseEvent.consume();
}
public void mouseClick(MouseEvent e) {
public void onMouseClick(MouseEvent e) {
if (menu != null && menu.isShowing()) {
menu.hide();
}
if (backend == null) {
return;
}
CharacterHit hit = hit(e.getX(), e.getY());
int insertionPoint = hit.getInsertionIndex();
PosInSequent pis = backend.getInitialPositionTable().getPosInSequent(insertionPoint, filter);
if (e.getButton() == MouseButton.SECONDARY) {
CharacterHit hit = hit(e.getX(), e.getY());
int insertionPoint = hit.getInsertionIndex();
PosInSequent pis = backend.getInitialPositionTable().getPosInSequent(insertionPoint, filter);
if (pis == null) return;
menu = new TacletContextMenu(keYProofFacade, pis, node.get());
menu.setAutoFix(true);
menu.setAutoHide(true);
menu.show(this, e.getScreenX(), e.getScreenY());
e.consume();
}
/*
Goal g = new Goal(node, null);
ImmutableList<NoPosTacletApp> rules = g.ruleAppIndex().getFindTaclet(new TacletFilter() {
......@@ -109,21 +125,29 @@ public class SequentView extends CodeArea {
clear();
insertText(0, backend.getString());
if (node.get().isClosed()) {
if (node.get().node().isClosed()) {
this.setBorder(new Border(new BorderStroke(Color.RED, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
this.getStyleClass().add("closed-sequent-view");
}
}
public Node getNode() {
public Goal getNode() {
return node.get();
}
public void setNode(Node node) {
public SimpleObjectProperty<Goal> nodeProperty() {
return node;
}
public void setNode(Goal node) {
this.node.set(node);
}
public SimpleObjectProperty<Node> nodeProperty() {
return node;
public KeYProofFacade getKeYProofFacade() {
return keYProofFacade;
}
public void setKeYProofFacade(KeYProofFacade keYProofFacade) {
this.keYProofFacade = keYProofFacade;
}
}
......@@ -21,6 +21,7 @@ import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URL;
import java.util.Random;
/**
......@@ -121,9 +122,12 @@ public class Utils {
}
public static void createWithFXML(Object node) {
FXMLLoader loader = new FXMLLoader(
node.getClass().getResource(node.getClass().getSimpleName() + ".fxml")
);
URL resource = node.getClass().getResource(node.getClass().getSimpleName() + ".fxml");
if (resource == null) {
throw new IllegalArgumentException("Could not find FXML resource: " + node.getClass().getSimpleName() + ".fxml");
}
FXMLLoader loader = new FXMLLoader(resource);
loader.setController(node);
loader.setRoot(node);
try {
......
package edu.kit.formal.interpreter.data;
import de.uka.ilkd.key.control.KeYEnvironment;
import de.uka.ilkd.key.proof.Goal;
import de.uka.ilkd.key.proof.Node;
import de.uka.ilkd.key.proof.Proof;
import lombok.*;
......@@ -18,7 +19,6 @@ import java.util.function.Function;
@RequiredArgsConstructor
public class KeyData {
private static final String SEPARATOR = " // ";
private final Node node;
private final KeYEnvironment env;
private final Proof proof;
......@@ -27,13 +27,28 @@ public class KeyData {
programLinesLabel,
programStatementsLabel,
nameLabel;
private Goal goal;
public KeyData(KeyData data, Node node) {
public KeyData(KeyData data, Goal node) {
env = data.env;
//proofApi = data.proofApi;
//scriptApi = data.scriptApi;
this.proof = data.proof;
this.node = node;
this.goal = node;
}
public KeyData(Goal g, KeYEnvironment environment, Proof proof) {
goal = g;
env = environment;
this.proof = proof;
}
public KeyData(Node root, KeYEnvironment environment, Proof proof) {
this(proof.getGoal(root), environment, proof);
}
public KeyData(KeyData kd, Node node) {
this(kd, kd.getProof().getGoal(node));
}
public String getRuleLabel() {
......@@ -45,10 +60,10 @@ public class KeyData {
private String constructLabel(Function<Node, String> projection) {
StringBuilder sb = new StringBuilder();
Node cur = node;
Node cur = getNode();
do {
try {
String section = projection.apply(node);
String section = projection.apply(getNode());
if (section != null) {
sb.append(section);
sb.append(SEPARATOR);
......@@ -93,4 +108,11 @@ public class KeyData {
}
public Goal getGoal() {
return goal;
}
public Node getNode() {
return getGoal().node();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import edu.kit.formal.gui.controls.TacletContextMenu?>
<?import javafx.scene.control.*?>
<fx:root fx:id="rootMenu" xmlns="http://javafx.com/javafx/8.0.111"
xmlns:fx="http://javafx.com/fxml/1" type="edu.kit.formal.gui.controls.TacletContextMenu">
<items>
<MenuItem mnemonicParsing="false" fx:id="noRules" visible="false"
text="No rules applicable."/>
<!-- <fx:include fx:id="insertHidden" visible="false" source="InsertHiddenMenuView.fxml"/>-->
<Menu fx:id="moreRules" visible="false" text="More rules"/>
<SeparatorMenuItem/>
<MenuItem mnemonicParsing="false" onAction="#handleFocussedRuleApplication"
text="Apply rules automatically here"/>
<!--
<fx:include fx:id="proofMacroMenu" source="ProofMacroMenuView.fxml"/>
-->
<SeparatorMenuItem/>
<MenuItem mnemonicParsing="false" fx:id="copyToClipboard"
onAction="#handleCopyToClipboard" text="Copy to clipboard"/>
<MenuItem mnemonicParsing="false" fx:id="createAbbr" visible="false"
onAction="#handleCreateAbbreviation" text="Create abbreviation"/>
<MenuItem mnemonicParsing="false" fx:id="enableAbbr" visible="false"
onAction="#handleEnableAbbreviation" text="Enable abbreviation"/>
<MenuItem mnemonicParsing="false" fx:id="disableAbbr"
visible="false" onAction="#handleDisableAbbreviation" text="Disable abbreviation"/>
<MenuItem mnemonicParsing="false" fx:id="changeAbbr" visible="false"
onAction="#handleChangeAbbreviation" text="Change abbreviation"/>
</items>
</fx:root>
......@@ -118,14 +118,6 @@
/**********************************************************************************************************************/
.context-menu {
-fx-skin: "com.sun.javafx.scene.control.skin.ContextMenuSkin";
-fx-font-family: sans-serif;
-fx-font-size: 9pt;
}
.breakpoint-menu {
-fx-skin: "com.sun.javafx.scene.control.skin.ContextMenuSkin";
-fx-font-family: sans-serif;
......@@ -223,11 +215,12 @@
.sequent-view {
-fx-font-size: 14pt;
-fx-background-color: @base01;
-fx-background-color: @base2;
-fx-fill: black;
.sequent-highlight {
-rtfx-background-color: @base1;
-fx-fill: @violet
-rtfx-background-color: @base0;
-fx-fill: black;
}
}
......@@ -287,4 +280,11 @@
&.POSTMORTEM {
-fx-background-color: blueviolet;
}
}
\ No newline at end of file
}
/**********************************************************************************************************************/
.context-menu {
-fx-skin: "com.sun.javafx.scene.control.skin.ContextMenuSkin";
-fx-font-family: sans-serif;
-fx-font-size: 9pt;
}
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