Commit cce67d91 authored by Alexander Weigl's avatar Alexander Weigl
Browse files

Merge branch 'docking'

* docking:
  docking framework seems good
  set to correct module
  remove submodules
  embedd a docking framework
parents 2c0303f2 ca4ce23b
[submodule "doc"]
path = doc
url = git@git.scc.kit.edu:xt9634/ProofScriptParser.wiki.git
[submodule "lib/DockFX"]
path = lib/DockFX
url = https://github.com/ClearControl/DockFX.git
Subproject commit bbbc57653d6a0bc7463539de30fec075443c0843
......@@ -72,6 +72,49 @@
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>released-version</id>
<goals>
<goal>released-version</goal>
</goals>
</execution>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>lib/DockFX/src/main/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>lib/DockFX/src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
......
......@@ -14,6 +14,7 @@ import javafx.scene.Scene;
import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dockfx.DockNode;
import java.io.IOException;
import java.util.Locale;
......@@ -33,15 +34,14 @@ public class ProofScriptDebugger extends Application {
public void start(Stage primaryStage) {
Locale.setDefault(Locale.ENGLISH);
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/DebuggerMain.fxml"));
Parent root = fxmlLoader.load();
//DebuggerMainWindowController controller = fxmlLoader.<DebuggerMainWindowController>getController();
Scene scene = new Scene(root);
scene.getStylesheets().addAll(
getClass().getResource("debugger-ui.css").toExternalForm()
getClass().getResource("debugger-ui.css").toExternalForm(),
DockNode.class.getResource("default.css").toExternalForm()
);
primaryStage.setTitle(NAME + " (" + VERSION + ") with KeY:" + KEY_VERSION);
primaryStage.setScene(scene);
......
package edu.kit.formal.gui.controller;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView;
import de.uka.ilkd.key.proof.init.ProofInputException;
import de.uka.ilkd.key.speclang.Contract;
import edu.kit.formal.gui.controls.*;
......@@ -20,6 +22,7 @@ import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
......@@ -28,6 +31,10 @@ import org.antlr.v4.runtime.RecognitionException;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dockfx.DockNode;
import org.dockfx.DockPane;
import org.dockfx.DockPos;
import org.dockfx.demo.DockFX;
import java.io.File;
import java.io.IOException;
......@@ -54,14 +61,18 @@ public class DebuggerMainWindowController implements Initializable {
@FXML
private Pane rootPane;
@FXML
private SplitPane splitPane;
private DockPane dockStation;
//@FXML
//private SplitPane splitPane;
/***********************************************************************************************************
* Code Area
* **********************************************************************************************************/
@FXML
private ScriptTabPane tabPane;
//@FXML
private ScriptController scriptController;
/***********************************************************************************************************
* MenuBar
......@@ -85,8 +96,17 @@ public class DebuggerMainWindowController implements Initializable {
* GoalView
* **********************************************************************************************************/
@FXML
private InspectionViewTabPane inspectionViewTabPane;
private final InspectionViewsController inspectionViewsController = new InspectionViewsController();
/**
*
*/
private JavaArea javaArea = new JavaArea();
private DockNode javaAreaDock = new DockNode(javaArea, "Java Source",
new MaterialDesignIconView(MaterialDesignIcon.CODEPEN)
);
private ExecutorService executorService = Executors.newFixedThreadPool(2);
private KeYProofFacade facade = new KeYProofFacade();
private ContractLoaderService contractLoaderService = new ContractLoaderService();
......@@ -111,6 +131,10 @@ public class DebuggerMainWindowController implements Initializable {
//TODO
private ObservableBooleanValue executeNotPossible = pc.executeNotPossibleProperty().or(facade.readyToExecuteProperty().not());
private WelcomePane welcomePane = new WelcomePane(this);
private DockNode welcomePaneDock = new DockNode(welcomePane, "Welcome", new MaterialDesignIconView(MaterialDesignIcon.ACCOUNT));
private DockNode activeInspectorDock = inspectionViewsController.getActiveInterpreterTabDock();
public static void showExceptionDialog(String title, String headerText, String contentText, Throwable ex) {
Alert alert = new Alert(Alert.AlertType.ERROR);
......@@ -149,11 +173,17 @@ public class DebuggerMainWindowController implements Initializable {
@Override
public void initialize(URL location, ResourceBundle resources) {
setDebugMode(false);
scriptController = new ScriptController(dockStation);
Image dockImage = new Image(DockFX.class.getResource("docknode.png").toExternalForm());
welcomePaneDock.dock(dockStation, DockPos.LEFT);
/*
toolbar.getChildrenUnmodifiable().forEach(
n -> n.setOnMouseEntered(statusBar.getTooltipHandler()));
buttonStartInterpreter.setOnMouseEntered(statusBar.getTooltipHandler());
*/
model.scriptFileProperty().addListener((observable, oldValue, newValue) -> {
statusBar.publishMessage("File: " + (newValue != null ? newValue.getAbsolutePath() : "n/a"));
......@@ -162,29 +192,25 @@ public class DebuggerMainWindowController implements Initializable {
/**
* create a new inspectionviewtab that is the main tab and not closable
*/
inspectionViewTabPane.createNewInspectionViewTab(model, true);
inspectionViewsController.connectActiveView(model);
//TODO this does not work any more
/*tabPane.getActiveScriptAreaTab().getScriptArea().getMarkedLines().addListener((SetChangeListener<Integer>) change -> {
blocker.getBreakpoints().clear();
blocker.getBreakpoints().addAll(change.getSet());
});*/
/*pc.currentGoalsProperty().addListener((o, old, fresh) -> {
/*pc.goalsProperty().addListener((o, old, fresh) -> {
model.currentGoalNodesProperty().setAll(fresh);
});
model.currentSelectedGoalNodeProperty().bind(pc.currentSelectedGoalProperty());*/
//model.currentGoalNodesProperty().bind(pc.currentGoalsProperty());
CustomTabPaneSkin skin = new CustomTabPaneSkin(tabPane);
//model.currentGoalNodesProperty().bind(pc.goalsProperty());
//CustomTabPaneSkin skin = new CustomTabPaneSkin(scriptController);
}
//region Actions: Execution
@FXML
public void executeScript() {
public void executeScript() {.
Bitte ändere nichts am Stepping (also die beiden Graphenerstellungen
etc.) und an der Labelsache, da ich hier das selber machen möchte.
executeScript(facade.buildInterpreter(), false);
}
......@@ -197,7 +223,7 @@ public class DebuggerMainWindowController implements Initializable {
// int line = lm.getLine(scriptArea.getCaretPosition());
// int inLine = lm.getCharInLine(scriptArea.getCaretPosition());
//*/
// ib.ignoreLinesUntil(tabPane.getSelectedScriptArea().getCaretPosition());
// ib.ignoreLinesUntil(scriptController.getSelectedScriptArea().getCaretPosition());
// executeScript(ib, true);
}
......@@ -217,7 +243,7 @@ public class DebuggerMainWindowController implements Initializable {
this.debugMode.set(debugMode);
statusBar.publishMessage("Parse ...");
try {
List<ProofScript> scripts = Facade.getAST(tabPane.getSelectedScriptArea().getText());
List<ProofScript> scripts = scriptController.getCombinedAST();
statusBar.publishMessage("Creating new Interpreter instance ...");
ib.setScripts(scripts);
......@@ -240,19 +266,11 @@ public class DebuggerMainWindowController implements Initializable {
}
});
pc.startHighlightPositionPropertyProperty().addListener((observable, oldValue, newValue) -> {
if (newValue.getLineNumber() > -1) {
tabPane.getSelectedScriptArea().highlightStmt(newValue.getLineNumber(), "line-highlight-postmortem");
}
if (oldValue.getLineNumber() > -1) {
tabPane.getSelectedScriptArea().removeHighlightStmt(oldValue.getLineNumber());
}
pc.currentHighlightNodeProperty().addListener((observable, oldValue, newValue) -> {
scriptController.getPostMortemHighlighter().highlight(newValue);
});
//highlight signature of main script
tabPane.getSelectedScriptArea().setDebugMark(scripts.get(0).getStartPosition().getLineNumber());
//scriptController.setDebugMark(scripts.get(0).getStartPosition().getLineNumber());
} catch (RecognitionException e) {
showExceptionDialog("Antlr Exception", "", "Could not parse scripts.", e);
}
......@@ -284,7 +302,7 @@ public class DebuggerMainWindowController implements Initializable {
private void saveScript(File scriptFile) {
try {
FileUtils.write(scriptFile, tabPane.getSelectedScriptArea().getText(), Charset.defaultCharset());
scriptController.saveCurrentScriptAs(scriptFile);
} catch (IOException e) {
showExceptionDialog("Could not save sourceName", "blubb", "...fsfsfsf fsa", e);
}
......@@ -302,7 +320,7 @@ public class DebuggerMainWindowController implements Initializable {
assert scriptFile != null;
try {
String code = FileUtils.readFileToString(scriptFile, Charset.defaultCharset());
ScriptArea area = tabPane.createNewTab(scriptFile);
ScriptArea area = scriptController.createNewTab(scriptFile);
openScript(code, area);
model.setScriptFile(scriptFile);
} catch (IOException e) {
......@@ -311,7 +329,7 @@ public class DebuggerMainWindowController implements Initializable {
}
}
private void openScript(String code, ScriptArea area) {
public void openScript(String code, ScriptArea area) {
model.setScriptFile(null);
if (!area.textProperty().getValue().isEmpty()) {
area.deleteText(0, area.textProperty().getValue().length());
......@@ -323,8 +341,12 @@ public class DebuggerMainWindowController implements Initializable {
@FXML
protected void loadKeYFile() {
File keyFile = openFileChooserOpenDialog("Select KeY File", "KeY Files", "key", "script");
this.model.setKeYFile(keyFile);
openKeyFile(keyFile);
}
public void openKeyFile(File keyFile) {
if (keyFile != null) {
this.model.setKeYFile(keyFile);
Task<Void> task = facade.loadKeyFileTask(keyFile);
task.setOnSucceeded(event -> {
statusBar.publishMessage("Loaded key sourceName: %s", keyFile);
......@@ -354,6 +376,10 @@ public class DebuggerMainWindowController implements Initializable {
@FXML
protected void loadJavaFile() {
File javaFile = openFileChooserOpenDialog("Select Java File", "Java Files", "java");
openJavaFile(javaFile);
}
public void openJavaFile(File javaFile) {
if (javaFile != null) {
model.setJavaFile(javaFile);
contractLoaderService.start();
......@@ -370,7 +396,7 @@ public class DebuggerMainWindowController implements Initializable {
*/
private File openFileChooserSaveDialog(String title, String description, String... fileEndings) {
FileChooser fileChooser = getFileChooser(title, description, fileEndings);
// File sourceName = fileChooser.showSaveDialog(inspectionViewTabPane.getInspectionViewTab().getGoalView().getScene().getWindow());
// File sourceName = fileChooser.showSaveDialog(inspectionViewsController.getInspectionViewTab().getGoalView().getScene().getWindow());
File file = fileChooser.showOpenDialog(statusBar.getScene().getWindow());
if (file != null) initialDirectory = file.getParentFile();
return file;
......@@ -378,7 +404,7 @@ public class DebuggerMainWindowController implements Initializable {
private File openFileChooserOpenDialog(String title, String description, String... fileEndings) {
FileChooser fileChooser = getFileChooser(title, description, fileEndings);
//File sourceName = fileChooser.showOpenDialog(inspectionViewTabPane.getInspectionViewTab().getGoalView().getScene().getWindow());
//File sourceName = fileChooser.showOpenDialog(inspectionViewsController.getInspectionViewTab().getGoalView().getScene().getWindow());
File file = fileChooser.showOpenDialog(statusBar.getScene().getWindow());
if (file != null) initialDirectory = file.getParentFile();
return file;
......@@ -438,8 +464,43 @@ public class DebuggerMainWindowController implements Initializable {
public void stopDebugMode(ActionEvent actionEvent) {
tabPane.getSelectedScriptArea().removeDebugHighlight();
//linenumberMainscript from model?
//tabPane.getActiveScriptAreaTab().getScriptArea().removeHighlightStmt(lineNumberMainScript);
//inspectionViewTabPane.getInspectionViewTab.clear();
//scriptController.getActiveScriptAreaTab().getScriptArea().removeHighlightStmt(lineNumberMainScript);
//inspectionViewsController.getInspectionViewTab.clear();
}
public void newScript(ActionEvent actionEvent) {
scriptController.newScript();
}
public void showCodeDock(ActionEvent actionEvent) {
if (!javaAreaDock.isDocked()) {
javaAreaDock.dock(dockStation, DockPos.RIGHT);
}
}
public void showWelcomeDock(ActionEvent actionEvent) {
if (!welcomePaneDock.isDocked()) {
welcomePaneDock.dock(dockStation, DockPos.CENTER);
}
}
public void showActiveInspector(ActionEvent actionEvent) {
if (!activeInspectorDock.isDocked() &&
!activeInspectorDock.isFloating()) {
activeInspectorDock.dock(dockStation, DockPos.CENTER);
}
}
public DockNode getJavaAreaDock() {
return javaAreaDock;
}
public DockNode getWelcomePaneDock() {
return welcomePaneDock;
}
public DockNode getActiveInspectorDock() {
return activeInspectorDock;
}
public class ContractLoaderService extends Service<List<Contract>> {
......
package edu.kit.formal.gui.controls;
import com.sun.org.apache.xpath.internal.operations.Mod;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView;
import de.uka.ilkd.key.logic.op.IProgramMethod;
import de.uka.ilkd.key.pp.ProgramPrinter;
import edu.kit.formal.gui.model.InspectionModel;
import edu.kit.formal.gui.model.RootModel;
import edu.kit.formal.interpreter.data.GoalNode;
import edu.kit.formal.interpreter.data.KeyData;
import javafx.beans.Observable;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.SplitPane;
import javafx.scene.control.Tab;
import javafx.scene.input.MouseEvent;
import java.io.IOException;
import java.io.StringWriter;
import javafx.scene.layout.BorderPane;
/**
* Right part of the splitpane that displays the different parts of a state
*
* @author S. Grebing
*/
public class InspectionViewTab extends Tab {
public class InspectionViewTab extends BorderPane {
public GoalOptionsMenu goalOptionsMenu = new GoalOptionsMenu();
@FXML
private SectionPane sectionPaneJavaCode;
@FXML
private SplitPane lowerSplitPane;
@FXML
private SequentView sequentView;
@FXML
private JavaArea javaSourceCode;
@FXML
private ListView goalView;
private ObjectProperty<Mode> mode = new SimpleObjectProperty<>();
@FXML
private ListView<GoalNode<KeyData>> goalView;
private BooleanProperty showCode = new SimpleBooleanProperty(true);
private ObjectProperty<InspectionModel> model = new SimpleObjectProperty<>(
new InspectionModel()
);
public InspectionViewTab() {
super();
Utils.createWithFXML(this);
getGoalView().getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null && newValue.getData() != null) {
getSequentView().setNode(newValue.getData().getNode());
}
});
model.get().selectedGoalNodeToShowProperty().bind(
goalView.getSelectionModel().selectedItemProperty()
);
model.get().selectedGoalNodeToShowProperty().addListener(
(observable, oldValue, newValue) -> {
goalView.getSelectionModel().select(newValue);
if (newValue != null && newValue.getData() != null) {
getSequentView().setNode(newValue.getData().getNode());
// TODO weigl: get marked lines of the program, and set it
model.get().highlightedJavaLinesProperty().get()
.clear();
}
});
model.get().goalsProperty().bindBidirectional(goalView.itemsProperty());
getGoalView().setCellFactory(GoalNodeListCell::new);
/*TODO redefine CSS bases on selected mode
mode.addListener(o -> {
getStyleClass().removeAll(
Mode.DEAD.name(),
......@@ -65,34 +67,14 @@ public class InspectionViewTab extends Tab {
Mode.POSTMORTEM.name()
);
getStyleClass().add(mode.get().name());
if (mode.get() == Mode.LIVING) {
MaterialDesignIconView icon = new MaterialDesignIconView(MaterialDesignIcon.RUN);
setClosable(false);
setGraphic(icon);
} else {
setGraphic(null);
setClosable(true);
}
});
showCode.addListener(o -> {
if (showCode.get())
lowerSplitPane.getItems().add(sectionPaneJavaCode);
else
lowerSplitPane.getItems().remove(sectionPaneJavaCode);
});
showCode.set(false);
*/
}
public SequentView getSequentView() {
return sequentView;
}
public JavaArea getJavaSourceCode() {
return javaSourceCode;
}
public ListView<GoalNode<KeyData>> getGoalView() {
return goalView;
......@@ -107,16 +89,8 @@ public class InspectionViewTab extends Tab {
goalOptionsMenu.show(n, actionEvent.getScreenX(), actionEvent.getScreenY());
}
public void initialize(InspectionModel model) {
System.out.println("model");
}
public void refresh(RootModel model) {
IProgramMethod method = (IProgramMethod) model.getChosenContract().getTarget();
getJavaSourceCode().clear();
getJavaSourceCode().getLineToClass().clear();
//javaSourceCode.clear();
//javaSourceCode.getLineToClass().clear();
/* IProgramMethod method = (IProgramMethod) model.getChosenContract().getTarget();
StringWriter writer = new StringWriter();
ProgramPrinter pp = new ProgramPrinter(writer);
try {
......@@ -126,39 +100,10 @@ public class InspectionViewTab extends Tab {
} catch (IOException e) {
e.printStackTrace();
}
getJavaSourceCode().insertText(0, writer.toString());
// javaSourceCode.insertText(0, writer.toString());
*/
}
public Mode getMode() {
return mode.get();
}
public void setMode(Mode mode) {
this.mode.set(mode);
}
public ObjectProperty<Mode> modeProperty() {
return mode;
}
public boolean isShowCode() {
return showCode.get();
}
public void setShowCode(boolean showCode) {
this.showCode.set(showCode);
}
public BooleanProperty showCodeProperty() {
return showCode;
}
enum Mode {
LIVING, DEAD, POSTMORTEM,
}
/**
* Cells for GoalView
*/
......@@ -182,4 +127,12 @@ public class InspectionViewTab extends Tab {
setText(text);
}
}
public InspectionModel getModel() {
return model.get();
}
public ReadOnlyObjectProperty<InspectionModel> modelProperty() {
return model;
}
}
package edu.kit.formal.gui.controls;
import edu.kit.formal.gui.model.RootModel;
import javafx.beans.property.SimpleMapProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableMap;
import org.dockfx.DockNode;
/**
* TabPane on the right side of the GUI containing the inspection view as tabs
*/
public class InspectionViewsController {
/**
* active tab in which the interpreter resp. Debugger state is shown.
* This tab can be changed and later on in this tab it should be possible to select proof commands
* All other tabs are only post morten tabs which cannot be shown
*/
private final InspectionViewTab activeInterpreterTab = new InspectionViewTab();
private final DockNode activeInterpreterTabDock = new DockNode(activeInterpreterTab, "Active");
private final ObservableMap<InspectionViewTab, DockNode> inspectionViews = new SimpleMapProperty<>(FXCollections.observableHashMap());