package model.events;

import java.util.ArrayList;
import java.util.EventObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import api.IEventListener;
import javafx.beans.property.StringProperty;

// @Deprecated
// BASED OFF OF IEventSystem
/*
 * Links EventObjects and IEventListeners Utilized to call the relevant event
 * handlers when given an event object
 */
public class EventSystem {

	private Map<EventNotifier, List<IEventListener>> eventMap = new HashMap<EventNotifier, List<IEventListener>>();
	private StringProperty message;

	/*
	 * Adds the IEventListener to the list of triggers for the given EventObject
	 */
	public void registerTrigger(EventNotifier event, IEventListener trigger) {
		if (!eventMap.containsKey(event)) {
			eventMap.put(event, new ArrayList<IEventListener>());
		}
		eventMap.get(event).add(trigger);
	}

	/*
	 * Takes the given event and "deregisters" it so it is no longer considered
	 * for event handling purposes
	 */
	public void deregisterTrigger(EventNotifier event) {
		eventMap.remove(event);
	}

	/*
	 * Given an event, handles it if there exists a handler for it If no handler
	 * is registered for the event, nothing happens
	 */
	public void handleEvent(EventNotifier event) {
		
//		if (eventMap.containsKey(event)) {
//			for (IEventListener listener : eventMap.get(event)) {
//				listener.handleEvent();
//			}
//			// NEED TO MODIFY HOW MESSAGE IS SET
//			this.message = "Event handled";
//		}
	}

	/**
	 * Method that gets the most recent message from the event handler Useful
	 * for testing purposes
	 * 
	 * @return last message received from event handler
	 */
	public StringProperty getLastMessage() {
		return message;
	}

	
	public void publish(String message) {
		
	}
	
}

@@ -177,57 +177,9 @@
 er;%0A
-import javafx.beans.property.StringProperty;%0A%0A// 
+%0A
 @Dep
@@ -381,32 +381,30 @@
 te Map%3CEvent
-Notifier
+Object
 , List%3CIEven
@@ -443,24 +443,22 @@
 ap%3CEvent
-Notifier
+Object
 , List%3CI
@@ -491,24 +491,16 @@
 e String
-Property
  message
@@ -619,32 +619,30 @@
 rigger(Event
-Notifier
+Object
  event, IEve
@@ -952,32 +952,30 @@
 rigger(Event
-Notifier
+Object
  event) %7B%0A%09%09
@@ -1172,16 +1172,14 @@
 vent
-Notifier
+Object
  eve
@@ -1188,13 +1188,8 @@
 ) %7B%0A
-%09%09%0A//
 %09%09if
@@ -1221,18 +1221,16 @@
 ent)) %7B%0A
-//
 %09%09%09for (
@@ -1278,18 +1278,16 @@
 ent)) %7B%0A
-//
 %09%09%09%09list
@@ -1310,17 +1310,13 @@
 ();%0A
-//
 %09%09%09%7D%0A
-//
 %09%09%09/
@@ -1351,18 +1351,16 @@
  IS SET%0A
-//
 %09%09%09this.
@@ -1386,18 +1386,16 @@
 ndled%22;%0A
-//
 %09%09%7D%0A%09%7D%0A%0A
@@ -1580,16 +1580,8 @@
 ring
-Property
  get
@@ -1622,55 +1622,5 @@
 %09%7D%0A%0A
-%09%0A%09public void publish(String message) %7B%0A%09%09%0A%09%7D%0A%09%0A%7D%0A
+%7D

Make EventSystem same as in master