From b6f0db01a94805a4a9621e949e03439da41c02e3 Mon Sep 17 00:00:00 2001 From: "Notmoo-PC\\Notmoo" Date: Sun, 21 Jan 2018 18:19:11 +0100 Subject: [PATCH] =?UTF-8?q?[CLIENT]=20Issue=20#9=20:=20ajout=20d'un=20reto?= =?UTF-8?q?ur=20quand=20la=20connexion=20=C3=A9choue=20suite=20=C3=A0=20au?= =?UTF-8?q?tre=20chose=20qu'une=20exception=20interne?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/pqt/client/gui/FrameManager.java | 12 +++++++++++- .../frames/startup_frame/StartupFrameController.java | 8 ++++++++ .../gui/frames/startup_frame/StartupFrameModel.java | 3 ++- .../gui/frames/startup_frame/StartupFrameView.java | 4 ++++ .../frame/IStartupFrameModelEventFirerer.java | 1 + .../listeners/frame/IStartupFrameModelListener.java | 1 + .../frame/SimpleStartupFrameModelEventFirerer.java | 6 ++++++ 7 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/FrameManager.java b/Workspace/client/src/main/java/com/pqt/client/gui/FrameManager.java index 3eb21e04..e925b627 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/FrameManager.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/FrameManager.java @@ -50,7 +50,17 @@ public class FrameManager { } private IStartupFrameModelListener getStartupFrameListener(){ - return () -> Platform.runLater(()->trySwitchScene(stage, mainFrameScene, true)); + return new IStartupFrameModelListener() { + @Override + public void onStartupValidated() { + Platform.runLater(() -> trySwitchScene(stage, mainFrameScene, true)); + } + + @Override + public void onStartupFailed() { + + } + }; } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameController.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameController.java index 2d4b2a82..ca486f2e 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameController.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameController.java @@ -43,6 +43,14 @@ public class StartupFrameController implements IStartupFrameModelListener { @Override public void onStartupValidated() { + view.clearErrorField(); + view.clearPasswordField(); + } + + @Override + public void onStartupFailed() { + view.clearErrorField(); + view.displayError("Echec de la connexion"); view.clearPasswordField(); } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameModel.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameModel.java index 3e64123a..08e74e76 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameModel.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameModel.java @@ -63,7 +63,8 @@ public class StartupFrameModel { public void onStartupProcedureFinishedEvent(boolean success) { if(success) firerer.fireStartupValidated(); - + else + firerer.fireStartupFailed(); startupProcessBegan = false; } }) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameView.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameView.java index 747b3948..13195383 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameView.java @@ -122,4 +122,8 @@ public class StartupFrameView implements IFXComponent{ public void displayError(String errorMsg) { infoText.setText(errorMsg); } + + public void clearErrorField() { + infoText.setText(""); + } } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/frame/IStartupFrameModelEventFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/frame/IStartupFrameModelEventFirerer.java index 7637abea..e385df38 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/frame/IStartupFrameModelEventFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/frame/IStartupFrameModelEventFirerer.java @@ -2,6 +2,7 @@ package com.pqt.client.gui.frames.startup_frame.listeners.frame; public interface IStartupFrameModelEventFirerer { void fireStartupValidated(); + void fireStartupFailed(); void addListener(IStartupFrameModelListener l); void removeListener(IStartupFrameModelListener l); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/frame/IStartupFrameModelListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/frame/IStartupFrameModelListener.java index 28e67398..c076759b 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/frame/IStartupFrameModelListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/frame/IStartupFrameModelListener.java @@ -4,4 +4,5 @@ import java.util.EventListener; public interface IStartupFrameModelListener extends EventListener { void onStartupValidated(); + void onStartupFailed(); } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/frame/SimpleStartupFrameModelEventFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/frame/SimpleStartupFrameModelEventFirerer.java index 4dad0b34..358e5b08 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/frame/SimpleStartupFrameModelEventFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/frame/SimpleStartupFrameModelEventFirerer.java @@ -17,6 +17,12 @@ public class SimpleStartupFrameModelEventFirerer implements IStartupFrameModelEv .forEach(IStartupFrameModelListener::onStartupValidated); } + @Override + public void fireStartupFailed() { + Arrays.stream(listenerList.getListeners(IStartupFrameModelListener.class)) + .forEach(IStartupFrameModelListener::onStartupFailed); + } + @Override public void addListener(IStartupFrameModelListener l) { listenerList.add(IStartupFrameModelListener.class, l);