From b55dd5d787f69b718108324ad29def545b3ca729 Mon Sep 17 00:00:00 2001 From: BetaSteward Date: Sun, 26 Jun 2011 22:41:45 -0400 Subject: [PATCH] another Server Console fix --- .../mage/server/console/ConsoleFrame.java | 3 +- .../mage/server/console/ConsolePanel.java | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java b/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java index 7d1faec2e6..207db3c52d 100644 --- a/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java +++ b/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java @@ -90,7 +90,6 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { public boolean connect(Connection connection) { if (session.connect(connection)) { - this.consolePanel1.start(); return true; } @@ -221,6 +220,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { @Override public void disconnected() { if (SwingUtilities.isEventDispatchThread()) { + consolePanel1.stop(); setStatusText("Not connected"); disableButtons(); } @@ -228,6 +228,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { + consolePanel1.stop(); setStatusText("Not connected"); disableButtons(); } diff --git a/Mage.Server.Console/src/main/java/mage/server/console/ConsolePanel.java b/Mage.Server.Console/src/main/java/mage/server/console/ConsolePanel.java index 186471f3bb..cc4aa69c8d 100644 --- a/Mage.Server.Console/src/main/java/mage/server/console/ConsolePanel.java +++ b/Mage.Server.Console/src/main/java/mage/server/console/ConsolePanel.java @@ -36,11 +36,14 @@ package mage.server.console; import java.util.Collection; import java.util.List; import java.util.UUID; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; import javax.swing.SwingWorker; import javax.swing.table.AbstractTableModel; import mage.remote.Session; import mage.view.TableView; import mage.view.UserView; +import org.apache.log4j.Logger; /** * @@ -48,6 +51,8 @@ import mage.view.UserView; */ public class ConsolePanel extends javax.swing.JPanel { + private final static Logger logger = Logger.getLogger(ConsolePanel.class); + private TableUserModel tableUserModel; private TableTableModel tableTableModel; private UpdateUsersTask updateUsersTask; @@ -394,6 +399,8 @@ class UpdateUsersTask extends SwingWorker> { private Session session; private ConsolePanel panel; + private final static Logger logger = Logger.getLogger(UpdateUsersTask.class); + UpdateUsersTask(Session session, ConsolePanel panel) { this.session = session; this.panel = panel; @@ -413,6 +420,16 @@ class UpdateUsersTask extends SwingWorker> { panel.update(view.get(0)); } + @Override + protected void done() { + try { + get(); + } catch (InterruptedException ex) { + logger.fatal("Update Users Task error", ex); + } catch (ExecutionException ex) { + logger.fatal("Update Users Task error", ex); + } catch (CancellationException ex) {} + } } class UpdateTablesTask extends SwingWorker> { @@ -421,6 +438,8 @@ class UpdateTablesTask extends SwingWorker> { private UUID roomId; private ConsolePanel panel; + private final static Logger logger = Logger.getLogger(UpdateTablesTask.class); + UpdateTablesTask(Session session, UUID roomId, ConsolePanel panel) { this.session = session; this.roomId = roomId; @@ -441,4 +460,14 @@ class UpdateTablesTask extends SwingWorker> { panel.update(view.get(0)); } + @Override + protected void done() { + try { + get(); + } catch (InterruptedException ex) { + logger.fatal("Update Tables Task error", ex); + } catch (ExecutionException ex) { + logger.fatal("Update Tables Task error", ex); + } catch (CancellationException ex) {} + } } \ No newline at end of file