public abstract class DMXAbstractController extends Object implements DMXController, ModelChangeAware
Abstract implementation of DMXController
. Clients can extends this class in order to reuse
common functionality found in most controllers, and only implement business logic methods.
In addition, this class implements ModelChangeAware
interface, which enables it to notify listeners about changes in
model. This is used to track progress for long-running tasks.
Modifier and Type | Field and Description |
---|---|
protected Map<String,Object> |
dataMap
Mapping of model data names and values.
|
protected List<ModelChangeListener> |
modelChangeListenersList
List of model changes listeners.
|
Constructor and Description |
---|
DMXAbstractController()
Creates new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addModelChangeListener(ModelChangeListener listener)
Add new listener.
|
Map<String,Object> |
getControllerDataMap()
Returns
dataMap that represents model data mapping. |
Set<String> |
getControllerDataNames()
Returns a set of names of data registered with this controller.
|
String |
getMapping()
Returns a mapping for this controller.
|
String |
getNextViewId()
This method assumes that no next view is defines, and thus returns an empty string.
|
void |
notifyDataChanged(Map<String,Object> data)
Notify listeners that model data is changed.
|
void |
removeModelChangeListener(ModelChangeListener listener)
Remove specified listener.
|
protected abstract void |
updateDataMapFromFields()
This method is called before model is updated.
|
Map<String,Object> |
updateModel()
Updates model with values of this class's fields.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
execute, updateFromModel
protected List<ModelChangeListener> modelChangeListenersList
public String getNextViewId()
getNextViewId
in interface DMXController
public String getMapping()
getMapping
in interface DMXController
protected abstract void updateDataMapFromFields()
This method is called before model is updated. Implementations should use this method as extension point to update with values of fields from this class which represent values of model data.
Example usage:
private int myInt;
................
protected void updateDataMapFromFields(){
dataMap.put("myIntMapping", myInt);
}
public final Map<String,Object> updateModel()
Updates model with values of this class's fields. This method actually returns dataMap
,
but it first calls updateDataMapFromFields()
to update dataMap
.
updateModel
in interface DMXController
public final Map<String,Object> getControllerDataMap()
dataMap
that represents model data mapping.getControllerDataMap
in interface DMXController
public Set<String> getControllerDataNames()
DMXController
getControllerDataNames
in interface DMXController
public void addModelChangeListener(ModelChangeListener listener)
ModelChangeAware
addModelChangeListener
in interface ModelChangeAware
listener
- listener to addpublic void removeModelChangeListener(ModelChangeListener listener)
ModelChangeAware
removeModelChangeListener
in interface ModelChangeAware
listener
- listener to addpublic void notifyDataChanged(Map<String,Object> data)
ModelChangeAware
notifyDataChanged
in interface ModelChangeAware
data
- changed dataCopyright © 2012-2014 Vektor Software. All Rights Reserved.