From ada8c1869c5b2b007e690e4c028fd20b34a41706 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 22 Jun 2011 07:04:15 +0200 Subject: Add proper handling for lost server connections git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@581 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/impl/StartTurnPanel.java | 12 ++++++++++++ src/jrummikub/view/impl/View.java | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src/jrummikub/view/impl') diff --git a/src/jrummikub/view/impl/StartTurnPanel.java b/src/jrummikub/view/impl/StartTurnPanel.java index d3f139d..4f1a8e4 100644 --- a/src/jrummikub/view/impl/StartTurnPanel.java +++ b/src/jrummikub/view/impl/StartTurnPanel.java @@ -33,6 +33,7 @@ class StartTurnPanel extends JPanel { private Event startTurnEvent = new Event(); private Event acknowledgeInvalidEvent = new Event(); + private Event acknowledgeConnectionLostEvent = new Event(); private Event buttonEvent = startTurnEvent; private BottomPanelType type; @@ -97,6 +98,10 @@ class StartTurnPanel extends JPanel { return acknowledgeInvalidEvent; } + IEvent getAcknowledgeConnectionLostEvent() { + return acknowledgeConnectionLostEvent; + } + private void rescale() { Insets insets = getInsets(); int x = insets.left, y = insets.top, width = getWidth() - insets.left @@ -184,6 +189,13 @@ class StartTurnPanel extends JPanel { startTurnButton.setText("N\u00E4chster Spieler"); buttonEvent = acknowledgeInvalidEvent; break; + + case NETWORK_SERVER_CONNECTION_LOST_PANEL: + startTurnLabel.setIcon(null); + startTurnLabel.setText("Die Verbindung zum Server wurde getrennt."); + startTurnButton.setText("OK"); + buttonEvent = acknowledgeConnectionLostEvent; + break; } rescale(); diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java index 34ae800..06e2721 100644 --- a/src/jrummikub/view/impl/View.java +++ b/src/jrummikub/view/impl/View.java @@ -604,6 +604,11 @@ public class View extends JFrame implements IView { return startTurnPanel.getAcknowledgeInvalidEvent(); } + @Override + public IEvent getAcknowledgeConnectionLostEvent() { + return startTurnPanel.getAcknowledgeConnectionLostEvent(); + } + @Override public IEvent getNewRoundEvent() { return roundEndPanel.getNewRoundEvent(); @@ -667,7 +672,8 @@ public class View extends JFrame implements IView { private void doSetBottomPanel(BottomPanelType type) { boolean showStartTurnPanel = (type == BottomPanelType.START_TURN_PANEL || type == BottomPanelType.START_REDEAL_TURN_PANEL - || type == BottomPanelType.START_LAST_TURN_PANEL || type == BottomPanelType.INVALID_TURN_PANEL); + || type == BottomPanelType.START_LAST_TURN_PANEL + || type == BottomPanelType.INVALID_TURN_PANEL || type == BottomPanelType.NETWORK_SERVER_CONNECTION_LOST_PANEL); startTurnPanel.setType(type); startTurnPanel.setVisible(showStartTurnPanel); -- cgit v1.2.3