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,13 +8,11 @@ import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
public abstract class GuiWindow implements Initializable{
private Scene scene;
private Stage stage;
/**
* constructor
@ -34,16 +32,16 @@ public abstract class GuiWindow implements Initializable{
public void showOnStage(Stage stage){
stage.setScene(scene);
stage.setTitle(getTitle());
this.stage = stage;
//this.stage = stage;
willShow();
stage.show();
}
/**
* show a modal dialog
* @param parent The dialogs parent
*/
public void showModal(Stage parent){
/* public void showModal(Stage parent){
Stage modalStage = new Stage();
modalStage.initModality(Modality.WINDOW_MODAL);
modalStage.initOwner(parent);
@ -53,12 +51,15 @@ public abstract class GuiWindow implements Initializable{
willShow();
modalStage.showAndWait();
}
*/
public void hide(){
/* public void hide(){
if(stage != null){
this.stage.hide();
}
}
*/
protected abstract String getTitle();
@ -72,4 +73,6 @@ public abstract class GuiWindow implements Initializable{
*/
public abstract void initialize(URL fxmlFileLocation, ResourceBundle resources);
public abstract void setErrorMessage(String msg);
}

View file

@ -67,6 +67,13 @@ public class EditorWindow extends GuiWindow {
}
}
@FXML
protected void chageProject(ActionEvent event){
for(EditorWindowListener listener : listsners){
listener.changeProject();
}
}
private void setupFileTreeView(){
fileTreeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>() {
@Override
@ -118,4 +125,10 @@ public class EditorWindow extends GuiWindow {
return "Coder Client";
}
@Override
public void setErrorMessage(String msg) {
// TODO Auto-generated method stub
}
}

View file

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

View file

@ -101,6 +101,7 @@ public class LoginDialog extends GuiWindow {
return "Login";
}
@Override
public void setErrorMessage(String msg) {
errorLabel.setText(msg);
}

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="159.0" prefWidth="319.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Button fx:id="cancelButton" layoutX="60.0" layoutY="67.0" mnemonicParsing="false" onAction="#cancel" text="cancel" />
<Button fx:id="createButton" defaultButton="true" disable="true" layoutX="195.0" layoutY="67.0" mnemonicParsing="false" onAction="#create" text="create" />
</children>
</AnchorPane>

View file

@ -0,0 +1,82 @@
package com.coder.client.gui.newProject;
import java.io.IOException;
import java.net.URL;
import java.util.HashSet;
import java.util.ResourceBundle;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import zutil.log.LogUtil;
import com.coder.client.gui.GuiWindow;
import com.coder.server.message.ConfigData;
public class NewProjectDialog extends GuiWindow {
public static final Logger logger = LogUtil.getLogger();
private HashSet<NewProjectDialogListener> listeners;
@FXML private Button createButton;
@FXML private Button cancelButton;
public NewProjectDialog() throws IOException {
super(NewProjectDialog.class.getResource("NewProjectDialog.fxml"));
listeners = new HashSet<NewProjectDialogListener>();
}
@Override
protected void willShow() {
for(NewProjectDialogListener listener : this.listeners){
listener.willShow();
}
}
@Override
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
// TODO Auto-generated method stub
}
@FXML
protected void create(ActionEvent event){
for(NewProjectDialogListener listener : this.listeners){
listener.create("Project Name", "Project Type");
}
}
@FXML
protected void cancel(ActionEvent event){
for(NewProjectDialogListener listener : this.listeners){
listener.cancel();
}
}
@Override
protected String getTitle() {
return "New Project";
}
public void addNewProjectDialogListener(NewProjectDialogListener newProjectDialogListener) {
this.listeners.add(newProjectDialogListener);
}
public void addProjectTypeToList(String typeName, ConfigData typeData) {
// TODO Auto-generated method stub
}
public void clearProjectTypeList() {
// TODO Auto-generated method stub
}
@Override
public void setErrorMessage(String errorMsg) {
// TODO Auto-generated method stub
}
}

View file

@ -0,0 +1,11 @@
package com.coder.client.gui.newProject;
public interface NewProjectDialogListener {
public void willShow();
public void create(String projectName, String projectType);
public void cancel();
}

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);
}
}

View file

@ -5,15 +5,15 @@
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<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="248.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="248.0" prefWidth="396.0" AnchorPane.bottomAnchor="57.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<ListView fx:id="serverListView" onKeyPressed="#keyPressed" onMouseClicked="#mouseClickedOnList" prefHeight="200.0" prefWidth="200.0" />
</content>
</ScrollPane>
<GridPane layoutY="171.0" prefHeight="50.0" prefWidth="396.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<Label fx:id="errorLabel" text="Error Message" textFill="RED" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="3.0" AnchorPane.rightAnchor="3.0" />
<GridPane layoutY="171.0" 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 +22,8 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<HBox alignment="CENTER_RIGHT" maxHeight="-Infinity" minHeight="-Infinity" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1">
<HBox alignment="CENTER_LEFT" prefWidth="200.0" />
<HBox alignment="TOP_RIGHT" prefWidth="200.0" GridPane.columnIndex="1">
<children>
<Button fx:id="exitButton" mnemonicParsing="false" onAction="#exit" text="Exit">
<HBox.margin>
@ -36,7 +37,6 @@
</Button>
</children>
</HBox>
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" />
</children>
</GridPane>
</children>

View file

@ -14,6 +14,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;
@ -37,6 +38,7 @@ public class SelectServerDialog extends GuiWindow {
@FXML private ListView<ServerListItem> serverListView;
@FXML private Button exitButton;
@FXML private Button connectButton;
@FXML private Label errorLabel;
public SelectServerDialog() throws IOException {
super(SelectServerDialog.class.getResource("SelectServerDialog.fxml"));
@ -57,6 +59,7 @@ public class SelectServerDialog extends GuiWindow {
@Override
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
errorLabel.setText("");
serverList = FXCollections.observableArrayList();
serverListView.setItems(serverList);
serverListView.setCellFactory(new Callback<ListView<ServerListItem>, ListCell<ServerListItem>>(){
@ -146,4 +149,9 @@ public class SelectServerDialog extends GuiWindow {
serverList.clear();
}
@Override
public void setErrorMessage(String errorMsg) {
this.errorLabel.setText(errorMsg);
}
}