Module Client : ajout d'un affichage d'erreur minimaliste dans la startup frame

This commit is contained in:
Notmoo-PC\Notmoo 2017-10-26 22:21:38 +02:00
parent 183f99d25b
commit aaa0cac636
4 changed files with 42 additions and 12 deletions

View File

@ -340,6 +340,10 @@ public class GUIStringTool {
return "Compte";
}
public static String getErrorConsoleSectionTitleLabel() {
return "Informations";
}
public static String getServerHostLabel() {
return "Host : ";
}
@ -347,6 +351,15 @@ public class GUIStringTool {
public static String getServerPortLabel() {
return "Port : ";
}
public static IObjectStringRenderer<Exception> getExceptionFormatter() {
return e->{
if(e.getMessage()==null || e.getMessage().isEmpty())
return String.format("%s", e.getClass().getName());
else
return String.format("%s : %s", e.getClass().getName(), e.getMessage());
};
}
}

View File

@ -1,5 +1,6 @@
package com.pqt.client.gui.startup_frame;
import com.pqt.client.gui.ressources.strings.GUIStringTool;
import com.pqt.client.gui.startup_frame.listeners.frame.IStartupFrameModelListener;
public class StartupFrameController implements IStartupFrameModelListener {
@ -27,14 +28,16 @@ public class StartupFrameController implements IStartupFrameModelListener {
public void onValidation() {
if(!model.isStartupProcessRunning()){
//TODO catch following exceptions and update GUI when needed :
//NullPointerException && IllegalArgumentException
model.beginStartupProcess(
view.getServerHostTextFieldContent(),
view.getServerPortTextFieldContent(),
view.getAccountUsernameTextFieldContent(),
view.getAccountPasswordTextFieldContent()
);
try {
model.beginStartupProcess(
view.getServerHostTextFieldContent(),
view.getServerPortTextFieldContent(),
view.getAccountUsernameTextFieldContent(),
view.getAccountPasswordTextFieldContent()
);
}catch(NullPointerException | IllegalArgumentException e){
view.displayError(GUIStringTool.getExceptionFormatter().render(e));
}
}
}

View File

@ -4,6 +4,7 @@ import com.pqt.client.gui.ressources.components.generics.IFXComponent;
import com.pqt.client.gui.ressources.strings.GUIStringTool;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.scene.text.Text;
public class StartupFrameView implements IFXComponent{
@ -16,6 +17,7 @@ public class StartupFrameView implements IFXComponent{
private TextField passwordTextField;
private Button validationButton;
private Text infoText;
public StartupFrameView(StartupFrameController ctrl) {
this.ctrl = ctrl;
@ -58,7 +60,12 @@ public class StartupFrameView implements IFXComponent{
ctrl.onValidation();
});
mainPane.getChildren().addAll(serverTitledPane, accountTitledPane, validationButton);
infoText = new Text("");
infoText.getStyleClass().add("text-displayer");
TitledPane errorConsoleTitledPane = new TitledPane(GUIStringTool.getErrorConsoleSectionTitleLabel(), infoText);
infoText.textProperty().addListener((obs, oldValue, newValue)->errorConsoleTitledPane.setExpanded(true));
mainPane.getChildren().addAll(serverTitledPane, accountTitledPane, errorConsoleTitledPane, validationButton);
}catch(Exception e){
//TODO Shutdown software on exception
e.printStackTrace();
@ -101,4 +108,8 @@ public class StartupFrameView implements IFXComponent{
public void clearPasswordField() {
passwordTextField.setText("");
}
public void displayError(String errorMsg) {
infoText.setText(errorMsg);
}
}

View File

@ -122,13 +122,16 @@
}
.titled-pane, .titled-pane > .title, .titled-pane > *.content, .text-field,
.password-field, .choice-box, .text-area, .combo-box, .button, .label {
-fx-font-size: 12pt;
-fx-font-family: "Segoe UI Semibold";
.password-field, .choice-box, .text-area, .combo-box, .button, .label, .text-displayer {
-fx-font: 12pt "Segoe UI Semibold";
-fx-background-color: #1d1d1d;
-fx-text-fill: #d8d8d8;
}
.text-displayer {
-fx-fill: #d8d8d8;
}
.titled-pane, .titled-pane > .title, .titled-pane > *.content {
-fx-border-width: 0;
}