M - the specific type of modelpublic class ModelEvents<M extends IModel>
extends java.lang.Object
ModelManagement.| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<M,java.util.List<IModelListener<M>>> |
modelListeners |
private java.util.Map<ModelInfo<M>,java.util.List<IModelProcessingListener<M>>> |
modelProcessingListeners |
private java.util.Map<M,java.util.List<IModelReloadListener<M>>> |
modelReloadListeners |
| Constructor and Description |
|---|
ModelEvents()
Prevents creation outside this package.
|
| Modifier and Type | Method and Description |
|---|---|
private static <T,I> void |
add(I identifier,
java.util.Map<I,java.util.List<T>> listeners,
T listener)
Adds the
listener for identifier to listeners. |
void |
addModelListener(M model,
IModelListener<M> listener)
Adds a model listener for the specified model.
|
void |
addProcessingListener(ModelInfo<M> info,
IModelProcessingListener<M> listener)
Adds a model processing listener for the specified model information object.
|
void |
addReloadListener(M model,
IModelReloadListener<M> listener)
Adds a model reload listener for the specified model.
|
void |
notifyModelProcessing(ModelInfo<M> info,
boolean start,
IModelProcessingListener.Type type)
Notifies about model processing events.
|
(package private) void |
notifyModelReloadFailed(M model)
Notifies registered listeners about a failed model reload.
|
(package private) void |
notifyModelReplacement(M oldModel,
M newModel)
Notifies registered listeners about replacing a model instance.
|
private static <T,I> boolean |
remove(I identifier,
java.util.Map<I,java.util.List<T>> listeners,
T listener)
Removes the
listener for identifier from listeners. |
(package private) void |
removeAllListeners(M model)
Removes all listeners (no processing listeners).
|
boolean |
removeModelListener(M model,
IModelListener<M> listener)
Removes a model listener from the specified model.
|
boolean |
removeModelReloadListener(M model,
IModelReloadListener<M> listener)
Removes a model reload listener from the specified model.
|
boolean |
removeProcessingListener(ModelInfo<M> info,
IModelProcessingListener<M> listener)
Removes a model processing listener for the specified model information object.
|
private <T> void |
updateListeners(java.util.List<T> oldListeners,
java.util.Map<M,java.util.List<T>> listeners,
M oldModel,
M newModel)
Updates the listeners if a model is replaced.
|
private java.util.Map<M extends IModel,java.util.List<IModelListener<M extends IModel>>> modelListeners
private java.util.Map<M extends IModel,java.util.List<IModelReloadListener<M extends IModel>>> modelReloadListeners
void notifyModelReloadFailed(M model)
model - the model that cannot be reloadedpublic void notifyModelProcessing(ModelInfo<M> info, boolean start, IModelProcessingListener.Type type)
info - the model information objectstart - whether processing started or endedtype - the type of the processingvoid notifyModelReplacement(M oldModel, M newModel)
oldModel - the old model being replacednewModel - the new model replacing oldModelprivate <T> void updateListeners(java.util.List<T> oldListeners,
java.util.Map<M,java.util.List<T>> listeners,
M oldModel,
M newModel)
T - the listener typeoldListeners - list of listeners that were listening to the old modellisteners - map of all listeners currently registeredoldModel - the old model being replacednewModel - the new model replacing oldModellvoid removeAllListeners(M model)
model - the model to remove all listeners forpublic void addModelListener(M model, IModelListener<M> listener)
ModelManagement.updateModel(IModel, java.net.URI, IModelLoader) before. A listener may be added
multiple times (whyever).model - the model to add the listener forlistener - the listenerpublic void addProcessingListener(ModelInfo<M> info, IModelProcessingListener<M> listener)
info - the information object to be informed aboutlistener - the listenerpublic boolean removeModelListener(M model, IModelListener<M> listener)
model - the model to remove the listener fromlistener - the listenertrue if the listener was removed,
false if not (for any reason)public void addReloadListener(M model, IModelReloadListener<M> listener)
ModelManagement.reload(IModel). A listener may be added
multiple times (whyever).model - the model to add the listener forlistener - the listenerpublic boolean removeModelReloadListener(M model, IModelReloadListener<M> listener)
model - the model to remove the listener fromlistener - the listenertrue if the listener was removed,
false if not (for any reason)public boolean removeProcessingListener(ModelInfo<M> info, IModelProcessingListener<M> listener)
info - the information object to be removedlistener - the listenertrue if the listener was removed,
false if not (for any reason)private static <T,I> void add(I identifier,
java.util.Map<I,java.util.List<T>> listeners,
T listener)
listener for identifier to listeners.T - the listener typeI - the identifier typeidentifier - the identifierlisteners - the listeners maplistener - the listener to be removedprivate static <T,I> boolean remove(I identifier,
java.util.Map<I,java.util.List<T>> listeners,
T listener)
listener for identifier from listeners.T - the listener typeI - the identifier typeidentifier - the identifierlisteners - the listeners maplistener - the listener to be removedtrue if the listener was removed,
false if not (for any reason)Copyright © 2009 - 2018 SSE. All Rights Reserved.