Commit 80ff5047 authored by Sarah Grebing's avatar Sarah Grebing
Browse files

Fixed connection with java area

parent 30dd90d3
Pipeline #11985 failed with stage
in 4 minutes and 16 seconds
...@@ -4,6 +4,7 @@ import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; ...@@ -4,6 +4,7 @@ import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView; import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView;
import de.uka.ilkd.key.proof.init.ProofInputException; import de.uka.ilkd.key.proof.init.ProofInputException;
import de.uka.ilkd.key.speclang.Contract; import de.uka.ilkd.key.speclang.Contract;
import edu.kit.formal.gui.ProofScriptDebugger;
import edu.kit.formal.gui.controls.*; import edu.kit.formal.gui.controls.*;
import edu.kit.formal.gui.model.InspectionModel; import edu.kit.formal.gui.model.InspectionModel;
import edu.kit.formal.interpreter.Interpreter; import edu.kit.formal.interpreter.Interpreter;
...@@ -23,6 +24,8 @@ import javafx.event.ActionEvent; ...@@ -23,6 +24,8 @@ import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.ProgressBar; import javafx.scene.control.ProgressBar;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import org.antlr.v4.runtime.RecognitionException; import org.antlr.v4.runtime.RecognitionException;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
...@@ -49,43 +52,38 @@ import java.util.concurrent.Executors; ...@@ -49,43 +52,38 @@ import java.util.concurrent.Executors;
*/ */
public class DebuggerMainWindowController implements Initializable { public class DebuggerMainWindowController implements Initializable {
protected static final Logger LOGGER = LogManager.getLogger(DebuggerMainWindowController.class); protected static final Logger LOGGER = LogManager.getLogger(DebuggerMainWindowController.class);
private ScriptController scriptController;
private final ProofTreeController proofTreeController = new ProofTreeController(); private final ProofTreeController proofTreeController = new ProofTreeController();
private final InspectionViewsController inspectionViewsController = new InspectionViewsController(); private final InspectionViewsController inspectionViewsController = new InspectionViewsController();
private final ExecutorService executorService = Executors.newFixedThreadPool(2); private final ExecutorService executorService = Executors.newFixedThreadPool(2);
private final KeYProofFacade facade = new KeYProofFacade(); private final KeYProofFacade facade = new KeYProofFacade();
private final ContractLoaderService contractLoaderService = new ContractLoaderService(); private final ContractLoaderService contractLoaderService = new ContractLoaderService();
@FXML
private DebuggerStatusBar statusBar;
@FXML
private DockPane dockStation;
private JavaArea javaArea = new JavaArea();
private DockNode javaAreaDock = new DockNode(javaArea, "Java Source",
new MaterialDesignIconView(MaterialDesignIcon.CODEPEN)
);
private WelcomePane welcomePane = new WelcomePane(this);
private DockNode welcomePaneDock = new DockNode(welcomePane, "Welcome", new MaterialDesignIconView(MaterialDesignIcon.ACCOUNT));
private DockNode activeInspectorDock = inspectionViewsController.getActiveInterpreterTabDock();
//-----------------------------------------------------------------------------------------------------------------
/** /**
* Property: current loaded javaFile * Property: current loaded javaFile
*/ */
private final ObjectProperty<File> javaFile = new SimpleObjectProperty<>(this, "javaFile"); private final ObjectProperty<File> javaFile = new SimpleObjectProperty<>(this, "javaFile");
/** /**
* Property: current loaded KeY File * Property: current loaded KeY File
*/ */
private final ObjectProperty<File> keyFile = new SimpleObjectProperty<>(this, "keyFile"); private final ObjectProperty<File> keyFile = new SimpleObjectProperty<>(this, "keyFile");
/** /**
* Chosen contract for problem * Chosen contract for problem
*/ */
private final ObjectProperty<Contract> chosenContract = new SimpleObjectProperty<>(this, "chosenContract"); private final ObjectProperty<Contract> chosenContract = new SimpleObjectProperty<>(this, "chosenContract");
private ScriptController scriptController;
@FXML
private DebuggerStatusBar statusBar;
@FXML
private DockPane dockStation;
private JavaArea javaArea = new JavaArea();
private DockNode javaAreaDock = new DockNode(javaArea, "Java Source",
new MaterialDesignIconView(MaterialDesignIcon.CODEPEN)
);
//-----------------------------------------------------------------------------------------------------------------
private WelcomePane welcomePane = new WelcomePane(this);
private DockNode welcomePaneDock = new DockNode(welcomePane, "Welcome", new MaterialDesignIconView(MaterialDesignIcon.ACCOUNT));
private DockNode activeInspectorDock = inspectionViewsController.getActiveInterpreterTabDock();
private BooleanProperty debugMode = new SimpleBooleanProperty(this, "debugMode", false); private BooleanProperty debugMode = new SimpleBooleanProperty(this, "debugMode", false);
/** /**
...@@ -118,16 +116,7 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -118,16 +116,7 @@ public class DebuggerMainWindowController implements Initializable {
marriageProofTreeControllerWithActiveInspectionView(); marriageProofTreeControllerWithActiveInspectionView();
//statusBar.publishMessage("File: " + (newValue != null ? newValue.getAbsolutePath() : "n/a")); //statusBar.publishMessage("File: " + (newValue != null ? newValue.getAbsolutePath() : "n/a"));
javaCode.addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
try {
javaArea.setText(newValue);
} catch (Exception e) {
LOGGER.catching(e);
}
}
});
//Debugging //Debugging
Utils.addDebugListener(javaCode); Utils.addDebugListener(javaCode);
...@@ -158,6 +147,26 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -158,6 +147,26 @@ public class DebuggerMainWindowController implements Initializable {
scriptController.getDebugPositionHighlighter().highlight(newValue); scriptController.getDebugPositionHighlighter().highlight(newValue);
}); });
javaFileProperty().addListener((observable, oldValue, newValue) -> {
showCodeDock(null);
try {
String code = FileUtils.readFileToString(newValue, Charset.defaultCharset());
javaCode.set(code);
} catch (IOException e) {
e.printStackTrace();
}
});
javaCode.addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
try {
javaArea.setText(newValue);
} catch (Exception e) {
LOGGER.catching(e);
}
}
});
Utils.addDebugListener(proofTreeController.currentGoalsProperty()); Utils.addDebugListener(proofTreeController.currentGoalsProperty());
Utils.addDebugListener(proofTreeController.currentSelectedGoalProperty()); Utils.addDebugListener(proofTreeController.currentSelectedGoalProperty());
Utils.addDebugListener(proofTreeController.currentHighlightNodeProperty()); Utils.addDebugListener(proofTreeController.currentHighlightNodeProperty());
...@@ -322,6 +331,10 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -322,6 +331,10 @@ public class DebuggerMainWindowController implements Initializable {
} }
} }
public void openJavaFile() {
loadJavaFile();
showCodeDock(null);
}
/** /**
* Creates a filechooser dialog * Creates a filechooser dialog
* *
...@@ -440,36 +453,18 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -440,36 +453,18 @@ public class DebuggerMainWindowController implements Initializable {
return activeInspectorDock; return activeInspectorDock;
} }
public class ContractLoaderService extends Service<List<Contract>> { public void showHelpText() {
@Override
protected Task<List<Contract>> createTask() {
return facade.getContractsForJavaFileTask(getJavaFile());
}
@Override WebView browser = new WebView();
protected void failed() { WebEngine webEngine = browser.getEngine();
Utils.showExceptionDialog("", "", "", exceptionProperty().get()); String url = ProofScriptDebugger.class.getResource("intro.html").toExternalForm();
} webEngine.load(url);
DockNode dn = new DockNode(browser);
@Override this.dockStation.getChildren().add(dn);
protected void succeeded() {
statusBar.publishMessage("Contract loaded");
List<Contract> contracts = getValue();
ContractChooser cc = new ContractChooser(facade.getService(), contracts);
cc.showAndWait().ifPresent(result -> {
setChosenContract(result);
try {
facade.activateContract(result);
getInspectionViewsController().getActiveInspectionViewTab().getModel().getGoals().setAll(facade.getPseudoGoals());
} catch (ProofInputException e) {
Utils.showExceptionDialog("", "", "", e);
}
});
}
} }
public ScriptController getScriptController() { public ScriptController getScriptController() {
return scriptController; return scriptController;
} }
...@@ -510,6 +505,10 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -510,6 +505,10 @@ public class DebuggerMainWindowController implements Initializable {
return javaFile.get(); return javaFile.get();
} }
public void setJavaFile(File javaFile) {
this.javaFile.set(javaFile);
}
public ObjectProperty<File> javaFileProperty() { public ObjectProperty<File> javaFileProperty() {
return javaFile; return javaFile;
} }
...@@ -518,6 +517,10 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -518,6 +517,10 @@ public class DebuggerMainWindowController implements Initializable {
return keyFile.get(); return keyFile.get();
} }
public void setKeyFile(File keyFile) {
this.keyFile.set(keyFile);
}
public ObjectProperty<File> keyFileProperty() { public ObjectProperty<File> keyFileProperty() {
return keyFile; return keyFile;
} }
...@@ -526,32 +529,53 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -526,32 +529,53 @@ public class DebuggerMainWindowController implements Initializable {
return chosenContract.get(); return chosenContract.get();
} }
public ObjectProperty<Contract> chosenContractProperty() {
return chosenContract;
}
public void setJavaFile(File javaFile) {
this.javaFile.set(javaFile);
}
public void setKeyFile(File keyFile) {
this.keyFile.set(keyFile);
}
public void setChosenContract(Contract chosenContract) { public void setChosenContract(Contract chosenContract) {
this.chosenContract.set(chosenContract); this.chosenContract.set(chosenContract);
} }
public ObjectProperty<Contract> chosenContractProperty() {
return chosenContract;
}
public File getInitialDirectory() { public File getInitialDirectory() {
return initialDirectory.get(); return initialDirectory.get();
} }
public void setInitialDirectory(File initialDirectory) {
this.initialDirectory.set(initialDirectory);
}
public ObjectProperty<File> initialDirectoryProperty() { public ObjectProperty<File> initialDirectoryProperty() {
return initialDirectory; return initialDirectory;
} }
public void setInitialDirectory(File initialDirectory) { public class ContractLoaderService extends Service<List<Contract>> {
this.initialDirectory.set(initialDirectory); @Override
protected Task<List<Contract>> createTask() {
return facade.getContractsForJavaFileTask(getJavaFile());
}
@Override
protected void failed() {
Utils.showExceptionDialog("", "", "", exceptionProperty().get());
}
@Override
protected void succeeded() {
statusBar.publishMessage("Contract loaded");
List<Contract> contracts = getValue();
ContractChooser cc = new ContractChooser(facade.getService(), contracts);
cc.showAndWait().ifPresent(result -> {
setChosenContract(result);
try {
facade.activateContract(result);
getInspectionViewsController().getActiveInspectionViewTab().getModel().getGoals().setAll(facade.getPseudoGoals());
} catch (ProofInputException e) {
Utils.showExceptionDialog("", "", "", e);
}
});
}
} }
//endregion //endregion
......
...@@ -89,7 +89,7 @@ public class ScriptController { ...@@ -89,7 +89,7 @@ public class ScriptController {
private DockNode createDockNode(ScriptArea area) { private DockNode createDockNode(ScriptArea area) {
DockNode dockNode = new DockNode(area, area.getFilePath().getName(), new MaterialDesignIconView(MaterialDesignIcon.FILE_DOCUMENT)); DockNode dockNode = new DockNode(area, area.getFilePath().getName(), new MaterialDesignIconView(MaterialDesignIcon.FILE_DOCUMENT));
dockNode.closedProperty().addListener(o -> { dockNode.closableProperty().addListener(o -> {
openScripts.remove(area); openScripts.remove(area);
}); });
area.filePathProperty().addListener((observable, oldValue, newValue) -> dockNode.setTitle(newValue.getName())); area.filePathProperty().addListener((observable, oldValue, newValue) -> dockNode.setTitle(newValue.getName()));
......
...@@ -35,8 +35,24 @@ public class WelcomePane extends AnchorPane { ...@@ -35,8 +35,24 @@ public class WelcomePane extends AnchorPane {
proofScriptDebugger.openScript( proofScriptDebugger.openScript(
new File("src/test/resources/edu/kit/formal/interpreter/dbg.kps") new File("src/test/resources/edu/kit/formal/interpreter/dbg.kps")
); );
proofScriptDebugger.openJavaFile( proofScriptDebugger.openJavaFile(
new File("src/test/resources/edu/kit/formal/interpreter/javaExample/TwoWaySwap.java")); new File("src/test/resources/edu/kit/formal/interpreter/javaExample/TwoWaySwap.java"));
} }
public void loadHelpPage(ActionEvent event) {
proofScriptDebugger.getWelcomePaneDock().close();
proofScriptDebugger.showHelpText();
}
public void loadJavaProblem(ActionEvent event) {
proofScriptDebugger.getWelcomePaneDock().close();
proofScriptDebugger.showActiveInspector(null);
proofScriptDebugger.openJavaFile();
proofScriptDebugger.openScript();
}
} }
...@@ -34,6 +34,7 @@ public class KeYMatcher implements MatcherApi<KeyData> { ...@@ -34,6 +34,7 @@ public class KeYMatcher implements MatcherApi<KeyData> {
@Override @Override
public List<VariableAssignment> matchLabel(GoalNode<KeyData> currentState, public List<VariableAssignment> matchLabel(GoalNode<KeyData> currentState,
String label) { String label) {
return null; return null;
} }
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView?> <?import de.jensd.fx.glyphs.materialdesignicons.*?>
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?> <?import javafx.scene.control.*?>
<?import javafx.scene.control.Label?> <?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<fx:root xmlns:fx="http://javafx.com/fxml/1" prefHeight="400.0" prefWidth="600.0" type="AnchorPane"
<fx:root prefHeight="400.0" prefWidth="600.0" type="AnchorPane" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"> xmlns="http://javafx.com/javafx/8.0.112">
<children> <children>
<Label layoutX="14.0" layoutY="14.0" text="Welcome to the ProofScriptDebugger"> <Label layoutX="14.0" layoutY="14.0" text="Welcome to the ProofScriptDebugger">
<font> <font>
<Font size="24.0" /> <Font size="24.0" />
</font> </font>
</Label> </Label>
<Label alignment="TOP_LEFT" layoutX="14.0" layoutY="71.0" prefHeight="129.0" prefWidth="573.0" text="Bla&#10;Bla&#10;Bla&#10;Bla&#10;Bla" wrapText="true" /> <Label alignment="TOP_LEFT" layoutX="14.0" layoutY="71.0" prefHeight="129.0" prefWidth="573.0"
text="This application is the Proof Script debugger for the KeY system." wrapText="true"/>
<HBox fillHeight="true" layoutX="117.0" layoutY="200.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" spacing="25.0"> <HBox fillHeight="true" layoutX="117.0" layoutY="200.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" spacing="25.0">
<padding> <padding>
...@@ -63,11 +58,20 @@ ...@@ -63,11 +58,20 @@
<MaterialDesignIconView glyphName="NEW_BOX" size="24" /> <MaterialDesignIconView glyphName="NEW_BOX" size="24" />
</graphic> </graphic>
</Button> </Button>
<Button contentDisplay="TOP" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" text="Introduction" GridPane.columnIndex="2" GridPane.rowIndex="1"> <Button contentDisplay="TOP" maxHeight="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" onAction="#loadJavaProblem" text="Load Java Problem"
GridPane.columnIndex="2" GridPane.rowIndex="0">
<graphic> <graphic>
<MaterialDesignIconView glyphName="HELP_CIRCLE" size="24" /> <MaterialDesignIconView glyphName="HELP_CIRCLE" size="24" />
</graphic> </graphic>
</Button> </Button>
<Button contentDisplay="TOP" maxHeight="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" onAction="#loadHelpPage" text="Introduction"
GridPane.columnIndex="2" GridPane.rowIndex="1">
<graphic>
<MaterialDesignIconView glyphName="HELP_CIRCLE" size="24"/>
</graphic>
</Button>
</children> </children>
<StackPane.margin> <StackPane.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
......
<html>
<head>
<title>Introduction to Proof Scripting Language for the KeY system</title>
<meta content="">
<style></style>
</head>
<body>Test</body>
</html>
\ No newline at end of file
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