Improved create project disabled button logic

This commit is contained in:
Ziver Koc 2015-11-02 16:55:48 +01:00 committed by Ziver Koc
parent de1eba7164
commit 4bcd9aa2a3
3 changed files with 19 additions and 10 deletions

View file

@ -3,6 +3,7 @@ package com.coder.client;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -263,7 +264,7 @@ public class CoderClient extends Application{
if(projectSelectionWindow != null){
projectSelectionWindow.setErrorMessage("");
}
ConfigData projectConfig = projectRspMsg.config;
Properties projectConfig = projectRspMsg.config;
String projectDescription = projectRspMsg.description;
List<String> projectFileList = projectRspMsg.fileList;
String projectName = projectRspMsg.name;

View file

@ -7,7 +7,7 @@
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="112.0" prefWidth="382.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ComboBox fx:id="projectTypeComboBox" layoutX="58.0" layoutY="39.0" prefHeight="25.0" prefWidth="196.0" promptText="Select a Project Type" AnchorPane.leftAnchor="55.0" AnchorPane.rightAnchor="10.0" />
<ComboBox fx:id="projectTypeComboBox" layoutX="58.0" layoutY="39.0" onAction="#typeSelection" prefHeight="25.0" prefWidth="196.0" promptText="Select a Project Type" AnchorPane.leftAnchor="55.0" AnchorPane.rightAnchor="10.0" />
<Label fx:id="errorMessageLabel" alignment="TOP_LEFT" layoutX="14.0" layoutY="71.0" prefHeight="17.0" prefWidth="237.0" text="Error Message" textFill="RED" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="135.0" AnchorPane.topAnchor="71.0" />
<TextField fx:id="projectNameTextField" layoutX="58.0" layoutY="10.0" onKeyPressed="#keyPressed" prefHeight="25.0" prefWidth="314.0" promptText="Project Name" AnchorPane.leftAnchor="55.0" AnchorPane.rightAnchor="10.0" />
<Label layoutX="14.0" layoutY="14.0" text="Name" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="14.0" />

View file

@ -81,21 +81,29 @@ public class NewProjectDialog extends GuiWindow {
}
}
@FXML
protected void keyPressed(KeyEvent event){
if(projectNameTextField.getText() != null && !projectNameTextField.getText().isEmpty()){
if(projectTypeComboBox.getValue() != null && !projectTypeComboBox.getValue().isEmpty()){
createButton.setDisable(false);
}
}
enableDisableButton();
if(event.getCode().equals(KeyCode.ENTER)){
createButton.fire();
}else if(event.getCode().equals(KeyCode.ESCAPE)){
cancelButton.fire();
}
}
//TODO: react to combo box changes
@FXML
protected void typeSelection(ActionEvent event){
enableDisableButton();
}
protected void enableDisableButton(){
createButton.setDisable(true);
if(projectNameTextField.getText() != null && !projectNameTextField.getText().isEmpty()){
if(projectTypeComboBox.getValue() != null && !projectTypeComboBox.getValue().isEmpty()){
createButton.setDisable(false);
}
}
}
@Override
protected String getTitle() {