another Server Console fix

This commit is contained in:
BetaSteward 2011-06-26 22:41:45 -04:00
parent 4657ea0352
commit b55dd5d787
2 changed files with 31 additions and 1 deletions

View file

@ -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();
}

View file

@ -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<Void, List<UserView>> {
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<Void, List<UserView>> {
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<Void, Collection<TableView>> {
@ -421,6 +438,8 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
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<Void, Collection<TableView>> {
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) {}
}
}