diff --git a/src/main/java/edu/kit/formal/gui/controller/DebuggerMainWindowController.java b/src/main/java/edu/kit/formal/gui/controller/DebuggerMainWindowController.java index bf39c91361e93d6ebe6b8f07e7bb9a039131653e..3ffde4866a301bdc7d6d3d3349fbb10d990ae334 100644 --- a/src/main/java/edu/kit/formal/gui/controller/DebuggerMainWindowController.java +++ b/src/main/java/edu/kit/formal/gui/controller/DebuggerMainWindowController.java @@ -15,7 +15,6 @@ import edu.kit.formal.interpreter.data.State; import edu.kit.formal.proofscriptparser.Facade; import edu.kit.formal.proofscriptparser.ast.ProofScript; import javafx.beans.Observable; -import javafx.beans.binding.StringBinding; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.value.ObservableBooleanValue; @@ -64,12 +63,12 @@ public class DebuggerMainWindowController implements Initializable { * Code Area * **********************************************************************************************************/ + //@FXML + //private ScriptArea scriptArea; @FXML - private ScriptArea scriptArea; - @FXML - private TabPane tabPane; - @FXML - private Tab startTab; + private ScriptTabsController tabPane; + //@FXML + //private Tab startTab; /*********************************************************************************************************** * MenuBar * **********************************************************************************************************/ @@ -180,7 +179,9 @@ public class DebuggerMainWindowController implements Initializable { javaSourceCode.insertText(0, writer.toString()); }); - scriptArea.getMarkedLines().addListener(new SetChangeListener() { +// scriptArea.getMarkedLines().addListener(new SetChangeListener() { + tabPane.getActiveScriptAreaTab().getScriptArea().getMarkedLines().addListener(new SetChangeListener() { + @Override public void onChanged(Change change) { blocker.getBreakpoints().clear(); @@ -209,7 +210,8 @@ public class DebuggerMainWindowController implements Initializable { goalView.setCellFactory(GoalNodeListCell::new); CustomTabPaneSkin skin = new CustomTabPaneSkin(tabPane); - startTab.textProperty().bind(new StringBinding() { + + /* startTab.textProperty().bind(new StringBinding() { { super.bind(model.scriptFileProperty()); } @@ -224,7 +226,8 @@ public class DebuggerMainWindowController implements Initializable { } } - }); + });*/ + } @@ -243,7 +246,7 @@ public class DebuggerMainWindowController implements Initializable { int line = lm.getLine(scriptArea.getCaretPosition()); int inLine = lm.getCharInLine(scriptArea.getCaretPosition()); */ - ib.ignoreLinesUntil(scriptArea.getCaretPosition()); + ib.ignoreLinesUntil(tabPane.getActiveScriptAreaTab().getScriptArea().getCaretPosition()); executeScript(ib, true); @@ -260,7 +263,7 @@ public class DebuggerMainWindowController implements Initializable { blocker.deinstall(); lblStatusMessage.setText("Parse ..."); try { - List scripts = Facade.getAST(scriptArea.getText()); + List scripts = Facade.getAST(tabPane.getActiveScriptAreaTab().getScriptArea().getText()); lblStatusMessage.setText("Creating new Interpreter instance ..."); ib.setScripts(scripts); ib.captureHistory(); @@ -305,7 +308,7 @@ public class DebuggerMainWindowController implements Initializable { private void saveScript(File scriptFile) { try { - FileUtils.write(scriptFile, scriptArea.getText(), Charset.defaultCharset()); + FileUtils.write(scriptFile, tabPane.getActiveScriptAreaTab().getScriptArea().getText(), Charset.defaultCharset()); } catch (IOException e) { showExceptionDialog("Could not save file", "blubb", "...fsfsfsf fsa", e); } @@ -323,7 +326,8 @@ public class DebuggerMainWindowController implements Initializable { assert scriptFile != null; try { String code = FileUtils.readFileToString(scriptFile, Charset.defaultCharset()); - openScript(code); + tabPane.createNewTab(scriptFile.getAbsolutePath()); + openScript(code, tabPane.getActiveScriptAreaTab().getScriptArea()); model.setScriptFile(scriptFile); } catch (IOException e) { showExceptionDialog("Exception occured", "", @@ -331,10 +335,14 @@ public class DebuggerMainWindowController implements Initializable { } } - private void openScript(String code) { + private void openScript(String code, ScriptArea area) { model.setScriptFile(null); - scriptArea.clear(); - scriptArea.setText(code); + if (area.textProperty().getValue() != "") { + System.out.println(area.textProperty().getValue()); + area.deleteText(0, area.textProperty().getValue().length()); + } + area.setText(code); + } @FXML diff --git a/src/main/java/edu/kit/formal/gui/controls/InspectionViewControl.java b/src/main/java/edu/kit/formal/gui/controls/InspectionViewControl.java new file mode 100644 index 0000000000000000000000000000000000000000..99355289846e5f69eddff809c1aec60cd4b01230 --- /dev/null +++ b/src/main/java/edu/kit/formal/gui/controls/InspectionViewControl.java @@ -0,0 +1,31 @@ +package edu.kit.formal.gui.controls; + +import edu.kit.formal.gui.model.InspectionModel; +import javafx.fxml.FXMLLoader; +import javafx.scene.control.Tab; + +import java.io.IOException; + +/** + * Right part of the splitpane that displays the different parts of a state + */ +public class InspectionViewControl extends Tab { + public final InspectionModel inspectionModel; + + public InspectionViewControl(InspectionModel inspectionModel) { + super(); + this.inspectionModel = inspectionModel; + FXMLLoader loader = new FXMLLoader(getClass().getResource("InspectionView.fxml")); + loader.setRoot(this); + loader.setController(this); + try { + loader.load(); + } catch (IOException e) { + e.printStackTrace(); + } + + + } + + +} diff --git a/src/main/java/edu/kit/formal/gui/controls/ScriptArea.java b/src/main/java/edu/kit/formal/gui/controls/ScriptArea.java index e5ec572bdd5efae46578d3d1662c52ea4edb906a..b0ad25cac14ba7a1a4809dd3065dc15c30a645cb 100644 --- a/src/main/java/edu/kit/formal/gui/controls/ScriptArea.java +++ b/src/main/java/edu/kit/formal/gui/controls/ScriptArea.java @@ -36,7 +36,7 @@ import java.util.Collections; import java.util.function.IntFunction; /** - * Created by sarah on 5/27/17. + * ScriptArea is the textarea on the left side of the GUI. It displays the script code and allows highlighting of lines and setting of breakpoints */ public class ScriptArea extends CodeArea { private ObservableSet markedLines = FXCollections.observableSet(); @@ -58,8 +58,10 @@ public class ScriptArea extends CodeArea { //getStylesheets().add(getClass().getResource("script-keywords.css").toExternalForm()); getStyleClass().add("script-area"); textProperty().addListener((prop, oldValue, newValue) -> { - clearStyle(0, newValue.length()); - setStyleSpans(0, highlighter.highlight(newValue)); + if (newValue.length() != 0) { + clearStyle(0, newValue.length()); + setStyleSpans(0, highlighter.highlight(newValue)); + } highlightProblems(); }); /* .successionEnds(Duration.ofMillis(100)) @@ -151,14 +153,12 @@ public class ScriptArea extends CodeArea { } public class GutterFactory implements IntFunction { - private Insets defaultInsets = new Insets(0.0, 5.0, 0.0, 5.0); - private Paint defaultTextFill = Color.web("#666"); - private Font defaultFont = Font.font("monospace", FontPosture.ITALIC, 13); private final Background defaultBackground = new Background(new BackgroundFill(Color.web("#ddd"), null, null)); - private final Val nParagraphs; - + private Insets defaultInsets = new Insets(0.0, 5.0, 0.0, 5.0); + private Paint defaultTextFill = Color.web("#666"); + private Font defaultFont = Font.font("monospace", FontPosture.ITALIC, 13); private ObservableList> lineAnnotations = new SimpleListProperty<>(FXCollections.observableArrayList()); diff --git a/src/main/java/edu/kit/formal/gui/controls/ScriptAreaTab.java b/src/main/java/edu/kit/formal/gui/controls/ScriptAreaTab.java new file mode 100644 index 0000000000000000000000000000000000000000..e84a0ade2a60946d79ca486d2bf846c9c7f6c55d --- /dev/null +++ b/src/main/java/edu/kit/formal/gui/controls/ScriptAreaTab.java @@ -0,0 +1,35 @@ +package edu.kit.formal.gui.controls; + +import javafx.beans.NamedArg; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.control.Tab; + +import java.io.IOException; + +/** + * Tab with a ScriptArea + */ +public class ScriptAreaTab extends Tab { + + + @FXML + private ScriptArea scriptArea; + + public ScriptAreaTab(@NamedArg("text") String title) { + super(title); + FXMLLoader loader = new FXMLLoader(getClass().getResource("TabScriptArea.fxml")); + loader.setRoot(this); + loader.setController(this); + try { + loader.load(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + public ScriptArea getScriptArea() { + return scriptArea; + } +} diff --git a/src/main/java/edu/kit/formal/gui/controls/ScriptTabsController.java b/src/main/java/edu/kit/formal/gui/controls/ScriptTabsController.java new file mode 100644 index 0000000000000000000000000000000000000000..e48ce6d2ec02afcc0b297f1c719e80d020b87115 --- /dev/null +++ b/src/main/java/edu/kit/formal/gui/controls/ScriptTabsController.java @@ -0,0 +1,82 @@ +package edu.kit.formal.gui.controls; + +import javafx.beans.property.SimpleObjectProperty; +import javafx.fxml.FXMLLoader; +import javafx.scene.control.Tab; +import javafx.scene.control.TabPane; + +import java.io.IOException; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Iterator; + +/** + * Controller for TabPane + */ +public class ScriptTabsController extends TabPane { + /** + * String is filepath; if string already exists if new tab should be created nothing happens + * If wished for, instead of filepath an object with omre script information may be used + */ + private HashMap mappingOfTabs = new HashMap(); + + + private SimpleObjectProperty activeTab = new SimpleObjectProperty<>(); + + public ScriptTabsController() { + super(); + FXMLLoader loader = new FXMLLoader(getClass().getResource("TabPaneScriptArea.fxml")); + loader.setRoot(this); + loader.setController(this); + try { + loader.load(); + } catch (IOException e) { + e.printStackTrace(); + } + + activeTab.bind(this.getSelectionModel().selectedItemProperty()); + + + } + + /** + * Create a new tab with the specified title + * + * @param + */ + public void createNewTab(String filePath) { + if (!mappingOfTabs.containsKey(filePath)) { + ScriptAreaTab newTab = new ScriptAreaTab(Paths.get(filePath).getFileName().toString()); + mappingOfTabs.put(filePath, newTab); + this.getTabs().add(newTab); + this.getSelectionModel().select(mappingOfTabs.get(filePath)); + + } else { + System.out.println("File already exists. Will not load it again"); + this.getSelectionModel().select(mappingOfTabs.get(filePath)); + } + } + + /** + * Get the tab with the specified filename as title + * + * @param title + * @return + */ + public ScriptArea getTabContent(String title) { + Iterator iter = this.getTabs().iterator(); + while (iter.hasNext()) { + ScriptAreaTab currentTab = (ScriptAreaTab) iter.next(); + if (currentTab.getText().equals(title)) { + return currentTab.getScriptArea(); + } + } + return null; + } + + public ScriptAreaTab getActiveScriptAreaTab() { + return (ScriptAreaTab) activeTab.get(); + + } + +} diff --git a/src/main/java/edu/kit/formal/gui/controls/TabPaneScriptArea.java b/src/main/java/edu/kit/formal/gui/controls/TabPaneScriptArea.java deleted file mode 100644 index b9fc0cf4a25deb12c28b06140282f5bfd00b7d48..0000000000000000000000000000000000000000 --- a/src/main/java/edu/kit/formal/gui/controls/TabPaneScriptArea.java +++ /dev/null @@ -1,24 +0,0 @@ -package edu.kit.formal.gui.controls; - -import javafx.fxml.FXMLLoader; -import javafx.scene.layout.VBox; - -import java.io.IOException; - -/** - * Created by sarah on 6/8/17. - */ -public class TabPaneScriptArea extends VBox { - public TabPaneScriptArea() { - super(); - FXMLLoader loader = new FXMLLoader(getClass().getResource("SectionPane.fxml")); - loader.setRoot(this); - loader.setController(this); - try { - loader.load(); - } catch (IOException e) { - e.printStackTrace(); - } - - } -} diff --git a/src/main/resources/DebuggerMain.fxml b/src/main/resources/DebuggerMain.fxml index e634c39db71098e1f270695a5255058c49cca731..0a5c87b5307e1bdc50e256242d7ab04992dbc35e 100644 --- a/src/main/resources/DebuggerMain.fxml +++ b/src/main/resources/DebuggerMain.fxml @@ -97,16 +97,18 @@ - - - - - - - - - + + diff --git a/src/main/resources/edu/kit/formal/gui/controls/InspectionView.fxml b/src/main/resources/edu/kit/formal/gui/controls/InspectionView.fxml new file mode 100644 index 0000000000000000000000000000000000000000..2ee862004cc6a303374f07247d3167591a893306 --- /dev/null +++ b/src/main/resources/edu/kit/formal/gui/controls/InspectionView.fxml @@ -0,0 +1,48 @@ + + + + + + + + + + + +
+ +
+
+ + + + + + + + + + +
+ +
+
+ +
+ +
+
+
+
+ +
\ No newline at end of file diff --git a/src/main/resources/edu/kit/formal/gui/controls/TabPaneScriptArea.fxml b/src/main/resources/edu/kit/formal/gui/controls/TabPaneScriptArea.fxml index 5ba3e8699d0efd7cdbed55b09d76c4514b6b9fcc..d0926e93d998ef5b75b35ab4ea5503caa0ad59d2 100644 --- a/src/main/resources/edu/kit/formal/gui/controls/TabPaneScriptArea.fxml +++ b/src/main/resources/edu/kit/formal/gui/controls/TabPaneScriptArea.fxml @@ -1,22 +1,23 @@ - - - - + + - - - - - - - - - - - + type="ScriptTabsController" xmlns="http://javafx.com/javafx/8.0.112"> + + + + + \ No newline at end of file diff --git a/src/main/resources/edu/kit/formal/gui/controls/TabScriptArea.fxml b/src/main/resources/edu/kit/formal/gui/controls/TabScriptArea.fxml new file mode 100644 index 0000000000000000000000000000000000000000..733b73c6874b54b2e3b1f4a10b5aa6c170688ea0 --- /dev/null +++ b/src/main/resources/edu/kit/formal/gui/controls/TabScriptArea.fxml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file