[CLIENT] Issue #9 : ajout d'un retour quand la connexion échoue suite à autre chose qu'une exception interne

This commit is contained in:
Notmoo-PC\Notmoo 2018-01-21 18:19:11 +01:00
parent 1ba5025a2e
commit b6f0db01a9
7 changed files with 33 additions and 2 deletions

View File

@ -50,7 +50,17 @@ public class FrameManager {
} }
private IStartupFrameModelListener getStartupFrameListener(){ 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() {
}
};
} }

View File

@ -43,6 +43,14 @@ public class StartupFrameController implements IStartupFrameModelListener {
@Override @Override
public void onStartupValidated() { public void onStartupValidated() {
view.clearErrorField();
view.clearPasswordField();
}
@Override
public void onStartupFailed() {
view.clearErrorField();
view.displayError("Echec de la connexion");
view.clearPasswordField(); view.clearPasswordField();
} }
} }

View File

@ -63,7 +63,8 @@ public class StartupFrameModel {
public void onStartupProcedureFinishedEvent(boolean success) { public void onStartupProcedureFinishedEvent(boolean success) {
if(success) if(success)
firerer.fireStartupValidated(); firerer.fireStartupValidated();
else
firerer.fireStartupFailed();
startupProcessBegan = false; startupProcessBegan = false;
} }
}) })

View File

@ -122,4 +122,8 @@ public class StartupFrameView implements IFXComponent{
public void displayError(String errorMsg) { public void displayError(String errorMsg) {
infoText.setText(errorMsg); infoText.setText(errorMsg);
} }
public void clearErrorField() {
infoText.setText("");
}
} }

View File

@ -2,6 +2,7 @@ package com.pqt.client.gui.frames.startup_frame.listeners.frame;
public interface IStartupFrameModelEventFirerer { public interface IStartupFrameModelEventFirerer {
void fireStartupValidated(); void fireStartupValidated();
void fireStartupFailed();
void addListener(IStartupFrameModelListener l); void addListener(IStartupFrameModelListener l);
void removeListener(IStartupFrameModelListener l); void removeListener(IStartupFrameModelListener l);

View File

@ -4,4 +4,5 @@ import java.util.EventListener;
public interface IStartupFrameModelListener extends EventListener { public interface IStartupFrameModelListener extends EventListener {
void onStartupValidated(); void onStartupValidated();
void onStartupFailed();
} }

View File

@ -17,6 +17,12 @@ public class SimpleStartupFrameModelEventFirerer implements IStartupFrameModelEv
.forEach(IStartupFrameModelListener::onStartupValidated); .forEach(IStartupFrameModelListener::onStartupValidated);
} }
@Override
public void fireStartupFailed() {
Arrays.stream(listenerList.getListeners(IStartupFrameModelListener.class))
.forEach(IStartupFrameModelListener::onStartupFailed);
}
@Override @Override
public void addListener(IStartupFrameModelListener l) { public void addListener(IStartupFrameModelListener l) {
listenerList.add(IStartupFrameModelListener.class, l); listenerList.add(IStartupFrameModelListener.class, l);