|
|
@@ -6,14 +6,11 @@
|
|
|
*/
|
|
|
package net.ranides.assira.events;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
import net.ranides.assira.concurrent.SwingInvoker;
|
|
|
import net.ranides.assira.functional.special.AnyFunction;
|
|
|
import net.ranides.assira.functional.special.CancelableConsumer;
|
|
|
-import net.ranides.assira.reflection.IAttribute;
|
|
|
import net.ranides.assira.reflection.IClass;
|
|
|
import net.ranides.assira.reflection.IClasses;
|
|
|
import net.ranides.assira.reflection.IMethod;
|
|
|
@@ -79,7 +76,7 @@ public class EventObserver implements EventListener<Event> {
|
|
|
case EventHandler.LAZY:
|
|
|
return new LazyHandler(type, m.bind(delegator), info.delay());
|
|
|
default:
|
|
|
- return new NHandler(router, type, m.bind(delegator));
|
|
|
+ return new NamedHandler(router, type, m.bind(delegator));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -178,38 +175,38 @@ public class EventObserver implements EventListener<Event> {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private static final class NHandler extends IHandler {
|
|
|
+ private static final class NamedHandler extends IHandler {
|
|
|
|
|
|
private final EventRouter dispatcher;
|
|
|
|
|
|
- public NHandler(String name, IClass<?> type, AnyFunction<?> handle) {
|
|
|
+ public NamedHandler(String name, IClass<?> type, AnyFunction<?> handle) {
|
|
|
super(type);
|
|
|
this.dispatcher = EventDispatcher.find(name).orElseThrow(() -> {
|
|
|
return new IllegalStateException("There is no EventDispatcher with name: " + name);
|
|
|
});
|
|
|
- this.dispatcher.addEventListener(DEvent.class, new DEventListener(this, handle));
|
|
|
+ this.dispatcher.addEventListener(TaggedEvent.class, new TaggedListener(this, handle));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void call(Event event) {
|
|
|
- this.dispatcher.signalEvent(new DEvent(this, event));
|
|
|
+ this.dispatcher.signalEvent(new TaggedEvent(this, event));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- private static final class DEventListener implements EventListener<DEvent> {
|
|
|
+ private static final class TaggedListener implements EventListener<TaggedEvent> {
|
|
|
|
|
|
private final Object tag;
|
|
|
|
|
|
private final AnyFunction<?> handle;
|
|
|
|
|
|
- public DEventListener(Object tag, AnyFunction<?> handle) {
|
|
|
+ public TaggedListener(Object tag, AnyFunction<?> handle) {
|
|
|
this.tag = tag;
|
|
|
this.handle = handle;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void handleEvent(DEvent event) {
|
|
|
+ public void handleEvent(TaggedEvent event) {
|
|
|
if(event.tag == tag) {
|
|
|
handle.call(event.src);
|
|
|
}
|
|
|
@@ -217,13 +214,13 @@ public class EventObserver implements EventListener<Event> {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private static final class DEvent implements Event {
|
|
|
+ private static final class TaggedEvent implements Event {
|
|
|
|
|
|
public final Object tag;
|
|
|
|
|
|
public final Event src;
|
|
|
|
|
|
- public DEvent(Object tag, Event event) {
|
|
|
+ public TaggedEvent(Object tag, Event event) {
|
|
|
this.tag = tag;
|
|
|
this.src = event;
|
|
|
}
|