Added NewProjectDialog, fixed some error handling and general stability fixes

This commit is contained in:
Daniel Collin 2015-10-23 13:44:11 +00:00
parent 34cf5865fe
commit 223fe1f136
13 changed files with 336 additions and 54 deletions

View file

@ -8,12 +8,13 @@
<AnchorPane xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefHeight="164.0" prefWidth="396.0" AnchorPane.bottomAnchor="50.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefHeight="164.0" prefWidth="396.0" AnchorPane.bottomAnchor="57.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<ListView fx:id="projectListView" onKeyPressed="#keyPressed" onMouseClicked="#mouseClickedOnList" prefHeight="200.0" prefWidth="200.0" />
</content>
</ScrollPane>
<GridPane maxHeight="-Infinity" minHeight="-Infinity" prefHeight="50.0" prefWidth="396.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<Label fx:id="errorLabel" layoutX="39.0" layoutY="164.0" text="Error Message" textFill="RED" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="3.0" AnchorPane.rightAnchor="3.0" />
<GridPane maxHeight="-Infinity" minHeight="-Infinity" prefHeight="35.0" prefWidth="396.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" />
@ -22,7 +23,7 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<HBox alignment="CENTER_RIGHT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1">
<HBox alignment="TOP_RIGHT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1">
<children>
<Button fx:id="cancelButton" mnemonicParsing="false" onAction="#cancel" text="Cancel">
<HBox.margin>
@ -36,7 +37,7 @@
</Button>
</children>
</HBox>
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<Button fx:id="newProjectButton" mnemonicParsing="false" onAction="#newProject" text="New Project">
<HBox.margin>

View file

@ -16,6 +16,7 @@ import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.input.KeyCode;
@ -36,6 +37,7 @@ public class SelectProjectDialog extends GuiWindow {
@FXML private Button newProjectButton;
@FXML private Button cancelButton;
@FXML private Button openButton;
@FXML private Label errorLabel;
private String projectName = null;
@ -54,10 +56,12 @@ public class SelectProjectDialog extends GuiWindow {
openButton.fire();
}
openButton.setDisable(true);
projectListView.requestFocus();
}
@Override
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
errorLabel.setText("");
projectList = FXCollections.observableArrayList();
projectListView.setItems(projectList);
projectListView.setCellFactory(new Callback<ListView<ProjectListItem>, ListCell<ProjectListItem>>(){
@ -164,5 +168,10 @@ public class SelectProjectDialog extends GuiWindow {
public void setProject(String project) {
this.projectName = project;
}
@Override
public void setErrorMessage(String errorMsg){
this.errorLabel.setText(errorMsg);
}
}