M - the class type of the model of the view controlledV - the class type of the view controlledpublic abstract class AbstractBaseController<M extends Model,V extends View<M,?,?>> extends Object implements Controller<M,V>, EventAdapter
EventAdapter.Linker| Modifier and Type | Field and Description |
|---|---|
private Map<EventType<? extends Event>,EventHandler<? extends Event>> |
eventHandlerMap
Store all event handler according to the event type.
|
private V |
view
The view component.
|
| Constructor and Description |
|---|
AbstractBaseController(V view)
Default Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
activate()
Activate the controller by initializing all event handler.
|
protected void |
addAdapter(EventAdapter eventAdapter)
Add an event adapter and automatically generate the associated event handler.
|
private <E extends Event> |
buildEventHandler(Class<? extends EventAdapter> adapterClass,
Class<? extends EventHandler<E>> handlerClass)
Build an event handler by reflection using the Controller object as eventAdapter.
|
protected void |
finalize() |
protected <E extends Event> |
getHandler(EventType<E> eventType)
Return an
EventHandler. |
M |
getModel() |
Node |
getRootNode() |
V |
getView() |
protected abstract void |
initEventAdapters()
Custom method used to initialize event Adapters.
|
protected abstract void |
initEventHandlers()
Custom method used to initialize event handlers.
|
protected void |
initInternalEventAdapters()
Initialize event Adapters.
|
protected void |
initInternalEventHandlers()
Initialize event Handlers.
|
private boolean |
isEventType(EventType<? extends Event> testEventType,
EventType<? extends Event> anyEventType)
Check the event type given and check the super level if necessary to always return the ANy event type.
|
private <E extends Event> |
wrapbuildHandler(EventAdapter eventAdapter,
Class<? extends EventAdapter> adapterClass,
Class<? extends EventHandler<E>> handlerClass)
Build an event handler by reflection to wrap the event adapter given.
|
private final Map<EventType<? extends Event>,EventHandler<? extends Event>> eventHandlerMap
public AbstractBaseController(V view) throws CoreException
view - the controlled viewCoreException - if an error occurred while creating event handlerspublic final void activate()
throws CoreException
activate in interface Controller<M extends Model,V extends View<M,?,?>>CoreException - if activation failsprotected final void initInternalEventAdapters()
throws CoreException
initEventAdapters() method to prepare your controller.CoreException - if an error occurred while creating event adaptersprotected abstract void initEventAdapters()
throws CoreException
CoreException - if an error occurred while creating event adaptersprotected final void initInternalEventHandlers()
throws CoreException
initEventHandlers() method to prepare your controller.CoreException - if an error occurred while creating event handlersprotected abstract void initEventHandlers()
throws CoreException
CoreException - if an error occurred while creating event handlerspublic final V getView()
public final M getModel()
public final Node getRootNode()
getRootNode in interface Controller<M extends Model,V extends View<M,?,?>>protected final void addAdapter(EventAdapter eventAdapter) throws CoreException
getHandler(EventType)eventAdapter - the EventAdapter used to route eventCoreException - it the local api contract is not respectedprotected final <E extends Event> EventHandler<E> getHandler(EventType<E> eventType) throws CoreException
EventHandler.E - the Event type to manageeventType - the event type of the handler we want to returnCoreException - an exception if the current class doesn't implement the right EventAdapter interface.private <E extends Event> EventHandler<E> wrapbuildHandler(EventAdapter eventAdapter, Class<? extends EventAdapter> adapterClass, Class<? extends EventHandler<E>> handlerClass) throws CoreException
E - the Event type to manageeventAdapter - the instance of an eventAdapteradapterClass - the adapter class used by the handler constructorhandlerClass - the handler class to buildCoreException - if an error occurred while creating the event handlerprivate <E extends Event> EventHandler<E> buildEventHandler(Class<? extends EventAdapter> adapterClass, Class<? extends EventHandler<E>> handlerClass) throws CoreException
E - the Event type to manageadapterClass - the event adapter class to usedhandlerClass - the event handler class to usedCoreException - if the local api contract is not respectedprivate boolean isEventType(EventType<? extends Event> testEventType, EventType<? extends Event> anyEventType)
testEventType - the sub event type or any instanceanyEventType - the eventype.ANY instanceCopyright © 2011–2014 JRebirth OSS. All rights reserved.