summaryrefslogtreecommitdiffstats
path: root/src/jrummikub
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-05-05 19:56:47 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-05-05 19:56:47 +0200
commit8c65bafde4ec05718433791915bcbf3c838e90a6 (patch)
tree32295309bc6da46b16b0ba6dae92376dde07490e /src/jrummikub
parent5917f88a029c16c907616a991327d2e16ed5020b (diff)
downloadJRummikub-8c65bafde4ec05718433791915bcbf3c838e90a6.tar
JRummikub-8c65bafde4ec05718433791915bcbf3c838e90a6.zip
Changed TurnControl to use Connections to remove listeners
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@153 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub')
-rw-r--r--src/jrummikub/control/TurnControl.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java
index 417c7b4..840b0e9 100644
--- a/src/jrummikub/control/TurnControl.java
+++ b/src/jrummikub/control/TurnControl.java
@@ -1,7 +1,11 @@
package jrummikub.control;
+import java.util.ArrayList;
+import java.util.List;
+
import jrummikub.model.IHand;
import jrummikub.model.ITable;
+import jrummikub.util.Connection;
import jrummikub.util.Event;
import jrummikub.util.IEvent;
import jrummikub.util.IListener;
@@ -13,7 +17,7 @@ public class TurnControl {
private ITurnTimer timer;
private IView view;
private Event endOfTurnEvent = new Event();
- IListener endOfTurnListener;
+ List<Connection> connections = new ArrayList<Connection>();
public TurnControl(IHand hand, ITable table, IView view) {
this.hand = hand;
@@ -32,15 +36,15 @@ public class TurnControl {
public void startTurn() {
- endOfTurnListener = new IListener() {
+ IListener endOfTurnListener = new IListener() {
@Override
public void handle() {
endOfTurn();
}
};
- timer.getTimeRunOutEvent().add(endOfTurnListener);
- view.getPlayerPanel().getEndTurnEvent().add(endOfTurnListener);
+ connections.add(timer.getTimeRunOutEvent().add(endOfTurnListener));
+ connections.add(view.getPlayerPanel().getEndTurnEvent().add(endOfTurnListener));
view.getPlayerPanel().getHandPanel().setStones(hand.clone());
view.enableStartTurnPanel(false);
@@ -59,7 +63,9 @@ public class TurnControl {
private void endOfTurn() {
timer.stopTimer();
endOfTurnEvent.emit();
- view.getPlayerPanel().getEndTurnEvent().remove(endOfTurnListener);
+ for (Connection c : connections) {
+ c.remove();
+ }
}
public IEvent getEndOfTurnEvent() {