Bugfix: relaunch the client when on settings validation (new login/password for example)

This commit is contained in:
Laurent Clouet
2015-01-27 21:44:32 +00:00
parent f1c5738dd5
commit c801835c83
4 changed files with 37 additions and 5 deletions

View File

@@ -48,6 +48,8 @@ public class GuiSwing extends JFrame implements Gui {
private boolean waitingForAuthentication; private boolean waitingForAuthentication;
private Client client; private Client client;
private ThreadClient threadClient;
public GuiSwing() { public GuiSwing() {
framesRendered = 0; framesRendered = 0;
@@ -158,6 +160,14 @@ public class GuiSwing extends JFrame implements Gui {
notifyAll(); notifyAll();
} }
if (threadClient != null && threadClient.isAlive()) {
System.out.println("Old thread client is alive, do not regenerate one");
}
else {
threadClient = new ThreadClient();
threadClient.start();
}
showActivity(ActivityType.WORKING); showActivity(ActivityType.WORKING);
} }
@@ -175,4 +185,15 @@ public class GuiSwing extends JFrame implements Gui {
setVisible(true); setVisible(true);
panel.repaint(); panel.repaint();
} }
public class ThreadClient extends Thread {
@Override
public void run() {
if (GuiSwing.this.client != null) {
int ret = GuiSwing.this.client.run();
System.out.println("Client.run return " + ret);
}
}
}
} }

View File

@@ -27,6 +27,8 @@ public class GuiText implements Gui {
private int framesRendered; private int framesRendered;
private Log log; private Log log;
private Client client;
public GuiText() { public GuiText() {
this.framesRendered = 0; this.framesRendered = 0;
this.log = Log.getInstance(null); this.log = Log.getInstance(null);
@@ -34,6 +36,10 @@ public class GuiText implements Gui {
@Override @Override
public void start() { public void start() {
if (client != null) {
client.run();
client.stop();
}
} }
@Override @Override
@@ -66,11 +72,12 @@ public class GuiText implements Gui {
@Override @Override
public void setClient(Client cli) { public void setClient(Client cli) {
client = cli;
} }
@Override @Override
public Client getClient() { public Client getClient() {
return null; return client;
} }
} }

View File

@@ -9,6 +9,8 @@ public class GuiTextOneLine implements Gui {
private String status; private String status;
private String line; private String line;
private Client client;
public GuiTextOneLine() { public GuiTextOneLine() {
rendered = 0; rendered = 0;
remaining = 0; remaining = 0;
@@ -18,6 +20,10 @@ public class GuiTextOneLine implements Gui {
@Override @Override
public void start() { public void start() {
if (client != null) {
client.run();
client.stop();
}
} }
@Override @Override
@@ -50,11 +56,12 @@ public class GuiTextOneLine implements Gui {
@Override @Override
public void setClient(Client cli) { public void setClient(Client cli) {
client = cli;
} }
@Override @Override
public Client getClient() { public Client getClient() {
return null; return client;
} }
private void updateLine() { private void updateLine() {

View File

@@ -291,8 +291,5 @@ public class Worker {
hook.attachShutDownHook(); hook.attachShutDownHook();
gui.start(); gui.start();
cli.run();
cli.stop();
} }
} }