mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-11-22 00:03:20 +00:00
Module Client : ajout d'un affichage d'erreur minimaliste dans la startup frame
This commit is contained in:
parent
183f99d25b
commit
aaa0cac636
@ -340,6 +340,10 @@ public class GUIStringTool {
|
|||||||
return "Compte";
|
return "Compte";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getErrorConsoleSectionTitleLabel() {
|
||||||
|
return "Informations";
|
||||||
|
}
|
||||||
|
|
||||||
public static String getServerHostLabel() {
|
public static String getServerHostLabel() {
|
||||||
return "Host : ";
|
return "Host : ";
|
||||||
}
|
}
|
||||||
@ -347,6 +351,15 @@ public class GUIStringTool {
|
|||||||
public static String getServerPortLabel() {
|
public static String getServerPortLabel() {
|
||||||
return "Port : ";
|
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());
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.pqt.client.gui.startup_frame;
|
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;
|
import com.pqt.client.gui.startup_frame.listeners.frame.IStartupFrameModelListener;
|
||||||
|
|
||||||
public class StartupFrameController implements IStartupFrameModelListener {
|
public class StartupFrameController implements IStartupFrameModelListener {
|
||||||
@ -27,14 +28,16 @@ public class StartupFrameController implements IStartupFrameModelListener {
|
|||||||
|
|
||||||
public void onValidation() {
|
public void onValidation() {
|
||||||
if(!model.isStartupProcessRunning()){
|
if(!model.isStartupProcessRunning()){
|
||||||
//TODO catch following exceptions and update GUI when needed :
|
try {
|
||||||
//NullPointerException && IllegalArgumentException
|
model.beginStartupProcess(
|
||||||
model.beginStartupProcess(
|
view.getServerHostTextFieldContent(),
|
||||||
view.getServerHostTextFieldContent(),
|
view.getServerPortTextFieldContent(),
|
||||||
view.getServerPortTextFieldContent(),
|
view.getAccountUsernameTextFieldContent(),
|
||||||
view.getAccountUsernameTextFieldContent(),
|
view.getAccountPasswordTextFieldContent()
|
||||||
view.getAccountPasswordTextFieldContent()
|
);
|
||||||
);
|
}catch(NullPointerException | IllegalArgumentException e){
|
||||||
|
view.displayError(GUIStringTool.getExceptionFormatter().render(e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.pqt.client.gui.ressources.components.generics.IFXComponent;
|
|||||||
import com.pqt.client.gui.ressources.strings.GUIStringTool;
|
import com.pqt.client.gui.ressources.strings.GUIStringTool;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.layout.*;
|
import javafx.scene.layout.*;
|
||||||
|
import javafx.scene.text.Text;
|
||||||
|
|
||||||
public class StartupFrameView implements IFXComponent{
|
public class StartupFrameView implements IFXComponent{
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ public class StartupFrameView implements IFXComponent{
|
|||||||
private TextField passwordTextField;
|
private TextField passwordTextField;
|
||||||
|
|
||||||
private Button validationButton;
|
private Button validationButton;
|
||||||
|
private Text infoText;
|
||||||
|
|
||||||
public StartupFrameView(StartupFrameController ctrl) {
|
public StartupFrameView(StartupFrameController ctrl) {
|
||||||
this.ctrl = ctrl;
|
this.ctrl = ctrl;
|
||||||
@ -58,7 +60,12 @@ public class StartupFrameView implements IFXComponent{
|
|||||||
ctrl.onValidation();
|
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){
|
}catch(Exception e){
|
||||||
//TODO Shutdown software on exception
|
//TODO Shutdown software on exception
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -101,4 +108,8 @@ public class StartupFrameView implements IFXComponent{
|
|||||||
public void clearPasswordField() {
|
public void clearPasswordField() {
|
||||||
passwordTextField.setText("");
|
passwordTextField.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void displayError(String errorMsg) {
|
||||||
|
infoText.setText(errorMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,13 +122,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.titled-pane, .titled-pane > .title, .titled-pane > *.content, .text-field,
|
.titled-pane, .titled-pane > .title, .titled-pane > *.content, .text-field,
|
||||||
.password-field, .choice-box, .text-area, .combo-box, .button, .label {
|
.password-field, .choice-box, .text-area, .combo-box, .button, .label, .text-displayer {
|
||||||
-fx-font-size: 12pt;
|
-fx-font: 12pt "Segoe UI Semibold";
|
||||||
-fx-font-family: "Segoe UI Semibold";
|
|
||||||
-fx-background-color: #1d1d1d;
|
-fx-background-color: #1d1d1d;
|
||||||
-fx-text-fill: #d8d8d8;
|
-fx-text-fill: #d8d8d8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-displayer {
|
||||||
|
-fx-fill: #d8d8d8;
|
||||||
|
}
|
||||||
|
|
||||||
.titled-pane, .titled-pane > .title, .titled-pane > *.content {
|
.titled-pane, .titled-pane > .title, .titled-pane > *.content {
|
||||||
-fx-border-width: 0;
|
-fx-border-width: 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user