Commit 71fe0d83 authored by Sarah Grebing's avatar Sarah Grebing

Initial Tab for scriptArea

parent 504cd092
Pipeline #10991 failed with stage
in 2 minutes and 18 seconds
...@@ -7,12 +7,10 @@ package edu.kit.formal.gui; ...@@ -7,12 +7,10 @@ package edu.kit.formal.gui;
*/ */
import de.uka.ilkd.key.util.KeYConstants; import de.uka.ilkd.key.util.KeYConstants;
import edu.kit.formal.gui.controller.DebuggerMainWindowController;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.SceneBuilder;
import javafx.stage.Stage; import javafx.stage.Stage;
import java.io.IOException; import java.io.IOException;
......
...@@ -10,7 +10,9 @@ import javafx.scene.layout.VBox; ...@@ -10,7 +10,9 @@ import javafx.scene.layout.VBox;
import lombok.Getter; import lombok.Getter;
/** /**
* WozardPane to dosplay all available contracts * WizardPane to display all available contracts
* @author S. Grebing
* @author A. Weigl
*/ */
public class ContractChooser extends Dialog<Contract> { public class ContractChooser extends Dialog<Contract> {
@Getter @Getter
...@@ -52,14 +54,14 @@ public class ContractChooser extends Dialog<Contract> { ...@@ -52,14 +54,14 @@ public class ContractChooser extends Dialog<Contract> {
return items.get(); return items.get();
} }
public ObjectProperty<ObservableList<Contract>> itemsProperty() {
return items;
}
public void setItems(ObservableList<Contract> items) { public void setItems(ObservableList<Contract> items) {
this.items.set(items); this.items.set(items);
} }
public ObjectProperty<ObservableList<Contract>> itemsProperty() {
return items;
}
private class ContractListCell extends ListCell<Contract> { private class ContractListCell extends ListCell<Contract> {
ContractListCell(ListView<Contract> contractListView) { ContractListCell(ListView<Contract> contractListView) {
itemProperty().addListener((observable, oldValue, newValue) -> render()); itemProperty().addListener((observable, oldValue, newValue) -> render());
......
...@@ -18,6 +18,7 @@ import edu.kit.formal.interpreter.data.State; ...@@ -18,6 +18,7 @@ import edu.kit.formal.interpreter.data.State;
import edu.kit.formal.proofscriptparser.Facade; import edu.kit.formal.proofscriptparser.Facade;
import edu.kit.formal.proofscriptparser.ast.ProofScript; import edu.kit.formal.proofscriptparser.ast.ProofScript;
import javafx.beans.Observable; import javafx.beans.Observable;
import javafx.beans.binding.StringBinding;
import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableBooleanValue; import javafx.beans.value.ObservableBooleanValue;
...@@ -55,23 +56,23 @@ import java.util.concurrent.Executors; ...@@ -55,23 +56,23 @@ import java.util.concurrent.Executors;
* @author Alexander Weigl * @author Alexander Weigl
*/ */
public class DebuggerMainWindowController implements Initializable { public class DebuggerMainWindowController implements Initializable {
private final PuppetMaster blocker = new PuppetMaster();
private SimpleBooleanProperty debugMode = new SimpleBooleanProperty(false); private SimpleBooleanProperty debugMode = new SimpleBooleanProperty(false);
private GoalOptionsMenu goalOptionsMenu = new GoalOptionsMenu(); private GoalOptionsMenu goalOptionsMenu = new GoalOptionsMenu();
@FXML @FXML
private Pane rootPane; private Pane rootPane;
@FXML @FXML
private SplitPane splitPane; private SplitPane splitPane;
/*********************************************************************************************************** /***********************************************************************************************************
* Code Area * Code Area
* **********************************************************************************************************/ * **********************************************************************************************************/
@FXML
private ScrollPane scrollPaneCode;
@FXML @FXML
private ScriptArea scriptArea; private ScriptArea scriptArea;
@FXML
private TabPane tabPane;
@FXML
private Tab startTab;
/*********************************************************************************************************** /***********************************************************************************************************
* MenuBar * MenuBar
* **********************************************************************************************************/ * **********************************************************************************************************/
...@@ -98,22 +99,17 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -98,22 +99,17 @@ public class DebuggerMainWindowController implements Initializable {
private ExecutorService executorService = Executors.newFixedThreadPool(2); private ExecutorService executorService = Executors.newFixedThreadPool(2);
private KeYProofFacade facade = new KeYProofFacade(); private KeYProofFacade facade = new KeYProofFacade();
private ContractLoaderService contractLoaderService = new ContractLoaderService(); private ContractLoaderService contractLoaderService = new ContractLoaderService();
/** /**
* Model for the DebuggerController containing the neccessary * Model for the DebuggerController containing the neccessary
* references to objects needed for controlling backend through UI * references to objects needed for controlling backend through UI
*/ */
private RootModel model = new RootModel(); private RootModel model = new RootModel();
@FXML @FXML
private Label lblStatusMessage; private Label lblStatusMessage;
@FXML @FXML
private Label lblCurrentNodes; private Label lblCurrentNodes;
@FXML @FXML
private Label lblFilename; private Label lblFilename;
private final PuppetMaster blocker = new PuppetMaster();
private File initialDirectory; private File initialDirectory;
@FXML @FXML
...@@ -126,6 +122,35 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -126,6 +122,35 @@ public class DebuggerMainWindowController implements Initializable {
private ObservableBooleanValue executeNotPossible = interpreterService.runningProperty().or(facade.readyToExecuteProperty().not()); private ObservableBooleanValue executeNotPossible = interpreterService.runningProperty().or(facade.readyToExecuteProperty().not());
public static void showExceptionDialog(String title, String headerText, String contentText, Throwable ex) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(title);
alert.setHeaderText(headerText);
alert.setContentText(contentText);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
String exceptionText = sw.toString();
Label label = new Label("The exception stacktrace was:");
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
alert.getDialogPane().setExpandableContent(expContent);
alert.showAndWait();
}
/** /**
* @param location * @param location
...@@ -185,8 +210,25 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -185,8 +210,25 @@ public class DebuggerMainWindowController implements Initializable {
}); });
goalView.setCellFactory(GoalNodeListCell::new); goalView.setCellFactory(GoalNodeListCell::new);
startTab.textProperty().bind(new StringBinding() {
{
super.bind(model.scriptFileProperty());
}
@Override
protected String computeValue() {
if (model.scriptFileProperty().getValue() != null) {
System.out.println(model.scriptFileProperty());
return model.scriptFileProperty().get().getName();
} else {
return "Untitled";
}
} }
});
}
//region Actions: Execution //region Actions: Execution
@FXML @FXML
...@@ -213,6 +255,7 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -213,6 +255,7 @@ public class DebuggerMainWindowController implements Initializable {
public void executeInDebugMode() { public void executeInDebugMode() {
executeScript(facade.buildInterpreter(), true); executeScript(facade.buildInterpreter(), true);
} }
//endregion
private void executeScript(InterpreterBuilder ib, boolean debugMode) { private void executeScript(InterpreterBuilder ib, boolean debugMode) {
this.debugMode.set(debugMode); this.debugMode.set(debugMode);
...@@ -235,7 +278,6 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -235,7 +278,6 @@ public class DebuggerMainWindowController implements Initializable {
showExceptionDialog("Antlr Exception", "", "Could not parse scripts.", e); showExceptionDialog("Antlr Exception", "", "Could not parse scripts.", e);
} }
} }
//endregion
//region Actions: Menu //region Actions: Menu
@FXML @FXML
...@@ -322,7 +364,9 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -322,7 +364,9 @@ public class DebuggerMainWindowController implements Initializable {
public void saveProof(ActionEvent actionEvent) { public void saveProof(ActionEvent actionEvent) {
} }
//endregion
//region Santa's Little Helper
@FXML @FXML
protected void loadJavaFile() { protected void loadJavaFile() {
...@@ -332,9 +376,6 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -332,9 +376,6 @@ public class DebuggerMainWindowController implements Initializable {
contractLoaderService.start(); contractLoaderService.start();
} }
} }
//endregion
//region Santa's Little Helper
/** /**
* Creates a filechooser dialog * Creates a filechooser dialog
...@@ -382,6 +423,32 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -382,6 +423,32 @@ public class DebuggerMainWindowController implements Initializable {
goalOptionsMenu.show(n, actionEvent.getScreenX(), actionEvent.getScreenY()); goalOptionsMenu.show(n, actionEvent.getScreenX(), actionEvent.getScreenY());
} }
public KeYProofFacade getFacade() {
return facade;
}
//region Property
public boolean isDebugMode() {
return debugMode.get();
}
//endregion
public void setDebugMode(boolean debugMode) {
this.debugMode.set(debugMode);
}
public SimpleBooleanProperty debugModeProperty() {
return debugMode;
}
public Boolean getExecuteNotPossible() {
return executeNotPossible.get();
}
public ObservableBooleanValue executeNotPossibleProperty() {
return executeNotPossible;
}
public class ContractLoaderService extends Service<List<Contract>> { public class ContractLoaderService extends Service<List<Contract>> {
@Override @Override
protected Task<List<Contract>> createTask() { protected Task<List<Contract>> createTask() {
...@@ -397,7 +464,7 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -397,7 +464,7 @@ public class DebuggerMainWindowController implements Initializable {
protected void succeeded() { protected void succeeded() {
lblStatusMessage.setText("Contract loaded"); lblStatusMessage.setText("Contract loaded");
model.getLoadedContracts().setAll(getValue()); model.getLoadedContracts().setAll(getValue());
//FIXME //FIXME model braucht contracts nicht
ContractChooser cc = new ContractChooser(facade.getService(), model.loadedContractsProperty()); ContractChooser cc = new ContractChooser(facade.getService(), model.loadedContractsProperty());
cc.showAndWait().ifPresent(result -> { cc.showAndWait().ifPresent(result -> {
...@@ -412,54 +479,6 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -412,54 +479,6 @@ public class DebuggerMainWindowController implements Initializable {
} }
} }
public KeYProofFacade getFacade() {
return facade;
}
public static void showExceptionDialog(String title, String headerText, String contentText, Throwable ex) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(title);
alert.setHeaderText(headerText);
alert.setContentText(contentText);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
String exceptionText = sw.toString();
Label label = new Label("The exception stacktrace was:");
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
alert.getDialogPane().setExpandableContent(expContent);
alert.showAndWait();
}
//endregion
//region Property
public boolean isDebugMode() {
return debugMode.get();
}
public SimpleBooleanProperty debugModeProperty() {
return debugMode;
}
public void setDebugMode(boolean debugMode) {
this.debugMode.set(debugMode);
}
private class GoalNodeListCell extends ListCell<GoalNode<KeyData>> { private class GoalNodeListCell extends ListCell<GoalNode<KeyData>> {
public GoalNodeListCell(ListView<GoalNode<KeyData>> goalNodeListView) { public GoalNodeListCell(ListView<GoalNode<KeyData>> goalNodeListView) {
...@@ -481,14 +500,6 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -481,14 +500,6 @@ public class DebuggerMainWindowController implements Initializable {
} }
} }
public Boolean getExecuteNotPossible() {
return executeNotPossible.get();
}
public ObservableBooleanValue executeNotPossibleProperty() {
return executeNotPossible;
}
private class InterpretingService extends Service<State<KeyData>> { private class InterpretingService extends Service<State<KeyData>> {
private final SimpleObjectProperty<Interpreter<KeyData>> interpreter = new SimpleObjectProperty<>(); private final SimpleObjectProperty<Interpreter<KeyData>> interpreter = new SimpleObjectProperty<>();
private final SimpleObjectProperty<ProofScript> mainScript = new SimpleObjectProperty<>(); private final SimpleObjectProperty<ProofScript> mainScript = new SimpleObjectProperty<>();
...@@ -511,6 +522,10 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -511,6 +522,10 @@ public class DebuggerMainWindowController implements Initializable {
} }
private void updateView() { private void updateView() {
//check proof
// check state for empty/error goal nodes leer
//currentGoals.set(state.getGoals());
//currentSelectedGoal.set(state.getSelectedGoalNode());
blocker.publishState(); blocker.publishState();
} }
......
...@@ -10,6 +10,7 @@ import edu.kit.formal.proofscriptparser.ast.*; ...@@ -10,6 +10,7 @@ import edu.kit.formal.proofscriptparser.ast.*;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentSkipListSet; import java.util.concurrent.ConcurrentSkipListSet;
...@@ -22,17 +23,13 @@ import java.util.concurrent.locks.ReentrantLock; ...@@ -22,17 +23,13 @@ import java.util.concurrent.locks.ReentrantLock;
* Created by weigl on 21.05.2017. * Created by weigl on 21.05.2017.
*/ */
public class PuppetMaster { public class PuppetMaster {
private Interpreter<KeyData> puppet;
private AtomicInteger stepUntilBlock = new AtomicInteger(-1);
private Set<Integer> brkpnts = new ConcurrentSkipListSet<>();
private final Lock lock = new ReentrantLock(); private final Lock lock = new ReentrantLock();
private final Condition block = lock.newCondition(); private final Condition block = lock.newCondition();
private final SimpleObjectProperty<List<GoalNode<KeyData>>> currentGoals = new SimpleObjectProperty<>(); private final SimpleObjectProperty<List<GoalNode<KeyData>>> currentGoals = new SimpleObjectProperty<>();
private final SimpleObjectProperty<GoalNode<KeyData>> currentSelectedGoal = new SimpleObjectProperty<>(); private final SimpleObjectProperty<GoalNode<KeyData>> currentSelectedGoal = new SimpleObjectProperty<>();
private Interpreter<KeyData> puppet;
private AtomicInteger stepUntilBlock = new AtomicInteger(-1);
private Set<Integer> brkpnts = new ConcurrentSkipListSet<>();
private Visitor<Void> entryListener = new EntryListener(); private Visitor<Void> entryListener = new EntryListener();
private Visitor<Void> exitListener = new ExitListener(); private Visitor<Void> exitListener = new ExitListener();
...@@ -58,6 +55,8 @@ public class PuppetMaster { ...@@ -58,6 +55,8 @@ public class PuppetMaster {
} }
public Void checkForHalt(ASTNode node) { public Void checkForHalt(ASTNode node) {
System.out.println("node = [" + node + "]");
//<0 run
if (stepUntilBlock.get() > 0) if (stepUntilBlock.get() > 0)
stepUntilBlock.decrementAndGet(); stepUntilBlock.decrementAndGet();
...@@ -76,11 +75,25 @@ public class PuppetMaster { ...@@ -76,11 +75,25 @@ public class PuppetMaster {
public void publishState() { public void publishState() {
System.out.println("PuppetMaster.publishState"); System.out.println("PuppetMaster.publishState");
//puppet is null if sucessful interprter state and publish state
if (puppet != null) {
final State<KeyData> state = puppet.getCurrentState().copy(); final State<KeyData> state = puppet.getCurrentState().copy();
System.out.println(state);
Platform.runLater(() -> { Platform.runLater(() -> {
currentGoals.set(state.getGoals()); currentGoals.set(state.getGoals());
currentSelectedGoal.set(state.getSelectedGoalNode()); currentSelectedGoal.set(state.getSelectedGoalNode());
}); });
} else {
//if puppet is null an empty state may be reached therefore state get goals etc returns null
Platform.runLater(() -> {
currentGoals.set(Collections.emptyList());
currentSelectedGoal.set(null);
});
}
} }
/** /**
...@@ -115,26 +128,26 @@ public class PuppetMaster { ...@@ -115,26 +128,26 @@ public class PuppetMaster {
return currentSelectedGoal.get(); return currentSelectedGoal.get();
} }
public SimpleObjectProperty<GoalNode<KeyData>> currentSelectedGoalProperty() {
return currentSelectedGoal;
}
public void setCurrentSelectedGoal(GoalNode<KeyData> currentSelectedGoal) { public void setCurrentSelectedGoal(GoalNode<KeyData> currentSelectedGoal) {
this.currentSelectedGoal.set(currentSelectedGoal); this.currentSelectedGoal.set(currentSelectedGoal);
} }
public List<GoalNode<KeyData>> getCurrentGoals() { public SimpleObjectProperty<GoalNode<KeyData>> currentSelectedGoalProperty() {
return currentGoals.get(); return currentSelectedGoal;
} }
public SimpleObjectProperty<List<GoalNode<KeyData>>> currentGoalsProperty() { public List<GoalNode<KeyData>> getCurrentGoals() {
return currentGoals; return currentGoals.get();
} }
public void setCurrentGoals(List<GoalNode<KeyData>> currentGoals) { public void setCurrentGoals(List<GoalNode<KeyData>> currentGoals) {
this.currentGoals.set(currentGoals); this.currentGoals.set(currentGoals);
} }
public SimpleObjectProperty<List<GoalNode<KeyData>>> currentGoalsProperty() {
return currentGoals;
}
public Set<Integer> getBreakpoints() { public Set<Integer> getBreakpoints() {
return brkpnts; return brkpnts;
} }
......
...@@ -4,7 +4,6 @@ package edu.kit.formal.gui.model; ...@@ -4,7 +4,6 @@ package edu.kit.formal.gui.model;
import de.uka.ilkd.key.speclang.Contract; import de.uka.ilkd.key.speclang.Contract;
import edu.kit.formal.interpreter.data.GoalNode; import edu.kit.formal.interpreter.data.GoalNode;
import edu.kit.formal.interpreter.data.KeyData; import edu.kit.formal.interpreter.data.KeyData;
import edu.kit.formal.interpreter.data.State;
import javafx.beans.property.ListProperty; import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty; import javafx.beans.property.SimpleListProperty;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
...@@ -19,11 +18,13 @@ import java.io.File; ...@@ -19,11 +18,13 @@ import java.io.File;
* @author S. Grebing * @author S. Grebing
*/ */
public class RootModel { public class RootModel {
/** /**
* Property: current loaded ScriptFile * Property: current loaded ScriptFile
*/ */
private final SimpleObjectProperty<File> scriptFile = new SimpleObjectProperty<>(); private final SimpleObjectProperty<File> scriptFile = new SimpleObjectProperty<>();
/** /**
* Property: current loaded javaFile * Property: current loaded javaFile
*/ */
...@@ -54,6 +55,7 @@ public class RootModel { ...@@ -54,6 +55,7 @@ public class RootModel {
private final SimpleObjectProperty<Contract> chosenContract = new SimpleObjectProperty<>(); private final SimpleObjectProperty<Contract> chosenContract = new SimpleObjectProperty<>();
public RootModel() { public RootModel() {
} }