From 5c94d4f9a0648fcd36db3292abf229fb0767698a Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Thu, 5 May 2011 19:49:59 +0200 Subject: Implemented Connection creation in event classes git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@151 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/util/Event.java | 10 ++++++++-- src/jrummikub/util/Event1.java | 10 ++++++++-- src/jrummikub/util/Event2.java | 10 ++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/jrummikub/util/Event.java b/src/jrummikub/util/Event.java index f76b861..491e10f 100644 --- a/src/jrummikub/util/Event.java +++ b/src/jrummikub/util/Event.java @@ -7,9 +7,15 @@ public class Event implements IEvent { private HashSet listeners = new HashSet(); @Override - public Connection add(IListener listener) { + public Connection add(final IListener listener) { listeners.add(listener); - return null; + return new Connection() { + + @Override + public void remove() { + Event.this.remove(listener); + } + }; } @Override diff --git a/src/jrummikub/util/Event1.java b/src/jrummikub/util/Event1.java index ff6c037..d721a7e 100644 --- a/src/jrummikub/util/Event1.java +++ b/src/jrummikub/util/Event1.java @@ -12,9 +12,15 @@ public class Event1 implements IEvent1 { private HashSet> listeners = new HashSet>(); @Override - public Connection add(IListener1 listener) { + public Connection add(final IListener1 listener) { listeners.add(listener); - return null; + return new Connection() { + + @Override + public void remove() { + Event1.this.remove(listener); + } + }; } @Override diff --git a/src/jrummikub/util/Event2.java b/src/jrummikub/util/Event2.java index 4b6575f..7087975 100644 --- a/src/jrummikub/util/Event2.java +++ b/src/jrummikub/util/Event2.java @@ -14,9 +14,15 @@ public class Event2 implements IEvent2 { private HashSet> listeners = new HashSet>(); @Override - public Connection add(IListener2 listener) { + public Connection add(final IListener2 listener) { listeners.add(listener); - return null; + return new Connection() { + + @Override + public void remove() { + Event2.this.remove(listener); + } + }; } @Override -- cgit v1.2.3