Adding 'exit' and 'change project' buttons to the editor window

This commit is contained in:
dcollin 2015-11-05 14:42:40 +01:00
parent d5b40053fb
commit eb754aecf9
4 changed files with 82 additions and 31 deletions

View file

@ -410,6 +410,11 @@ public class CoderClient extends Application{
selectProjectDialog.setProject(null); selectProjectDialog.setProject(null);
selectProjectDialog.showOnStage(mainStage); selectProjectDialog.showOnStage(mainStage);
} }
@Override
public void exit() {
closeCurrentSession();
Platform.exit();
}
}); });
} }

View file

@ -6,42 +6,78 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<SplitPane dividerPositions="0.26588628762541805, 0.7391304347826086" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<items> <AnchorPane xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" SplitPane.resizableWithParent="false"> <children>
<SplitPane dividerPositions="0.26588628762541805, 0.7391304347826086" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" SplitPane.resizableWithParent="false">
<children>
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefHeight="398.0" prefWidth="156.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<TreeView fx:id="fileTreeView" prefHeight="398.0" prefWidth="156.0" />
</content>
</ScrollPane>
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<ScrollPane fitToHeight="true" fitToWidth="true" prefHeight="398.0" prefWidth="271.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<TextArea fx:id="editTextArea" prefHeight="398.0" prefWidth="271.0" />
</content>
</ScrollPane>
</children>
</AnchorPane>
<AnchorPane prefHeight="200.0" prefWidth="200.0" SplitPane.resizableWithParent="false">
<children>
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<PropertySheet fx:id="propertySheet" modeSwitcherVisible="false" searchBoxVisible="false" />
</content>
</ScrollPane>
</children>
</AnchorPane>
</items>
</SplitPane>
<GridPane maxHeight="-Infinity" minHeight="-Infinity" prefHeight="40.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children> <children>
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefHeight="398.0" prefWidth="156.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <HBox alignment="CENTER_LEFT" maxHeight="50.0" prefHeight="50.0" prefWidth="200.0">
<content> <children>
<TreeView fx:id="fileTreeView" prefHeight="398.0" prefWidth="156.0" /> <Button fx:id="exitButton" mnemonicParsing="false" onAction="#handleExit" text="Exit">
</content> <HBox.margin>
</ScrollPane> <Insets left="10.0" />
</children></AnchorPane> </HBox.margin>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> </Button>
<children> <Button fx:id="changeProjectButton" mnemonicParsing="false" onAction="#handleChangeProject" text="Change Project">
<ScrollPane fitToHeight="true" fitToWidth="true" prefHeight="398.0" prefWidth="271.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <HBox.margin>
<content> <Insets left="10.0" />
<TextArea fx:id="editTextArea" prefHeight="398.0" prefWidth="271.0" /> </HBox.margin>
</content> </Button>
</ScrollPane> </children>
</children></AnchorPane> </HBox>
<AnchorPane prefHeight="200.0" prefWidth="200.0" SplitPane.resizableWithParent="false"> <HBox alignment="CENTER_RIGHT" maxHeight="50.0" prefHeight="50.0" prefWidth="200.0" GridPane.columnIndex="1">
<children>
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="50.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<PropertySheet fx:id="propertySheet" modeSwitcherVisible="false" searchBoxVisible="false" />
</content>
</ScrollPane>
<HBox alignment="CENTER" maxHeight="50.0" prefHeight="50.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children> <children>
<Button fx:id="compileButton" mnemonicParsing="false" onAction="#handleCompile" text="Compile"> <Button fx:id="compileButton" mnemonicParsing="false" onAction="#handleCompile" text="Compile">
<HBox.margin> <HBox.margin>
<Insets right="15.0" /> <Insets right="10.0" />
</HBox.margin>
</Button>
<Button fx:id="runButton" mnemonicParsing="false" onAction="#handleRun" text="Run">
<HBox.margin>
<Insets right="10.0" />
</HBox.margin> </HBox.margin>
</Button> </Button>
<Button fx:id="runButton" mnemonicParsing="false" onAction="#handleRun" text="Run" />
</children> </children>
</HBox> </HBox>
</children> </children>
</AnchorPane> </GridPane>
</items> </children>
</SplitPane> </AnchorPane>

View file

@ -34,6 +34,8 @@ public class EditorWindow extends GuiWindow {
@FXML private PropertySheet propertySheet; @FXML private PropertySheet propertySheet;
@FXML private Button compileButton; @FXML private Button compileButton;
@FXML private Button runButton; @FXML private Button runButton;
@FXML private Button exitButton;
@FXML private Button changeProjectButton;
public EditorWindow() throws IOException{ public EditorWindow() throws IOException{
super(EditorWindow.class.getResource("EditorWindow.fxml")); super(EditorWindow.class.getResource("EditorWindow.fxml"));
@ -68,12 +70,19 @@ public class EditorWindow extends GuiWindow {
} }
@FXML @FXML
protected void chageProject(ActionEvent event){ protected void handleChangeProject(ActionEvent event){
for(EditorWindowListener listener : listsners){ for(EditorWindowListener listener : listsners){
listener.changeProject(); listener.changeProject();
} }
} }
@FXML
protected void handleExit(ActionEvent event){
for(EditorWindowListener listener : listsners){
listener.exit();
}
}
private void setupFileTreeView(){ private void setupFileTreeView(){
fileTreeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>() { fileTreeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>() {
@Override @Override

View file

@ -6,5 +6,6 @@ public interface EditorWindowListener {
public void compile(); public void compile();
public void run(); public void run();
public void changeProject(); public void changeProject();
public void exit();
} }