Commit a37fadf5 authored by Sarah Grebing's avatar Sarah Grebing

New Tabs loadable and concept for loading a file again is implementend: if...

New Tabs loadable and concept for loading a file again is implementend: if file is already laoded and loaded again, it is overwritten (Decision for the beginning)
parent 55375f3a
......@@ -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<Integer>() {
// scriptArea.getMarkedLines().addListener(new SetChangeListener<Integer>() {
tabPane.getActiveScriptAreaTab().getScriptArea().getMarkedLines().addListener(new SetChangeListener<Integer>() {
@Override
public void onChanged(Change<? extends Integer> 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<ProofScript> scripts = Facade.getAST(scriptArea.getText());
List<ProofScript> 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
......
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();
}
}
}
......@@ -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<Integer> 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<Node> {
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<Integer> 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<SimpleObjectProperty<Node>> lineAnnotations = new SimpleListProperty<>(FXCollections.observableArrayList());
......
package edu.kit.formal.gui.controls;
import javafx.beans.NamedArg;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.VBox;
import javafx.scene.control.Tab;
import java.io.IOException;
/**
* Created by sarah on 6/8/17.
* Tab with a ScriptArea
*/
public class TabPaneScriptArea extends VBox {
public TabPaneScriptArea() {
super();
FXMLLoader loader = new FXMLLoader(getClass().getResource("SectionPane.fxml"));
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 {
......@@ -21,4 +28,8 @@ public class TabPaneScriptArea extends VBox {
}
}
public ScriptArea getScriptArea() {
return scriptArea;
}
}
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<String, ScriptAreaTab> mappingOfTabs = new HashMap();
private SimpleObjectProperty<Tab> 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<Tab> 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();
}
}
......@@ -97,16 +97,18 @@
</Button>
</items>
</ToolBar>
<TabPane fx:id="tabPane" side="left" styleClass="tab-pane"
tabClosingPolicy="SELECTED_TAB" VBox.vgrow="ALWAYS">
<tabs>
<Tab fx:id="startTab" text="Untitled">
<content>
<ScriptArea fx:id="scriptArea" VBox.vgrow="ALWAYS"/>
</content>
</Tab>
</tabs>
</TabPane>
<ScriptTabsController fx:id="tabPane" side="left" styleClass="tab-pane"
tabClosingPolicy="SELECTED_TAB" VBox.vgrow="ALWAYS"/>
<!-- <TabPane fx:id="tabPane" side="left" styleClass="tab-pane"
tabClosingPolicy="SELECTED_TAB" VBox.vgrow="ALWAYS">
<tabs>
<Tab fx:id="startTab" text="Untitled">
<content>
<ScriptArea fx:id="scriptArea" VBox.vgrow="ALWAYS"/>
</content>
</Tab>
</tabs>
</TabPane>-->
</children>
......
<?xml version="1.0" encoding="UTF-8"?>
<?import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView?>
<?import edu.kit.formal.gui.controls.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<fx:root xmlns:fx="http://javafx.com/fxml"
xmlns="http://javafx.com/javafx"
type="javafx.scene.control.Tab">
<SectionPane title="Current Goals">
<headerRight>
<Button onMouseClicked="#showGoalOptions">
<graphic>
<MaterialDesignIconView glyphName="WRENCH"/>
</graphic>
</Button>
</headerRight>
<center>
<ListView fx:id="goalView"/>
</center>
</SectionPane>
<SplitPane>
<padding>
<Insets top="5" left="5" right="5" bottom="5"/>
</padding>
<items>
<SectionPane title="Sequent">
<headerRight>
<Button>
<graphic>
<MaterialDesignIconView glyphName="WRENCH"/>
</graphic>
</Button>
</headerRight>
<center>
<SequentView fx:id="sequentView"/>
</center>
</SectionPane>
<SectionPane title="Source Code">
<center>
<JavaArea fx:id="javaSourceCode"/>
</center>
</SectionPane>
</items>
</SplitPane>
</fx:root>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<?import edu.kit.formal.gui.controls.ScriptArea?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.*?>
<?import edu.kit.formal.gui.controls.ScriptAreaTab?>
<?import edu.kit.formal.gui.controls.ScriptTabsController?>
<fx:root xmlns:fx="http://javafx.com/fxml/1" prefHeight="100" prefWidth="250" styleClass="tab-pane"
type="javafx.scene.layout.BorderPane" xmlns="http://javafx.com/javafx/8.0.112">
<VBox>
<TabPane fx:id="tabPane" side="left"
tabClosingPolicy="SELECTED_TAB" VBox.vgrow="ALWAYS">
<tabs>
<Tab fx:id="startTab" text="Untitled">
<content>
<ScriptArea fx:id="scriptArea" VBox.vgrow="ALWAYS"/>
</content>
</Tab>
</tabs>
</TabPane>
</VBox>
type="ScriptTabsController" xmlns="http://javafx.com/javafx/8.0.112">
<!-- <VBox> -->
<ScriptAreaTab text="Untitled"/>
<!-- <TabPane fx:id="tabPane" side="left"
tabClosingPolicy="SELECTED_TAB" VBox.vgrow="ALWAYS">
<tabs>
<ScriptAreaTab text="Untitled"></ScriptAreaTab>
<Tab fx:id="startTab" text="Untitled">
<content>
<ScriptArea fx:id="scriptArea" VBox.vgrow="ALWAYS"/>
</content>
</Tab>
</tabs>
</TabPane>-->
<!-- </VBox> -->
</fx:root>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<?import edu.kit.formal.gui.controls.ScriptArea?>
<?import edu.kit.formal.gui.controls.ScriptAreaTab?>
<fx:root xmlns:fx="http://javafx.com/fxml"
xmlns="http://javafx.com/javafx"
type="edu.kit.formal.gui.controls.ScriptAreaTab">
<content>
<ScriptArea fx:id="scriptArea"/>
</content>
</fx:root>
\ 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