Changes between Version 5 and Version 6 of mvc
- Timestamp:
- 06/13/22 10:41:53 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
mvc
v5 v6 16 16 The toolbox has a hierarchy of Models. This section describes the various standard models. 17 17 18 === Model and Submodels18 === Model and Compound Models. 19 19 At the root is the Model interface. A model basically is an object, which implicitly contains some values that can be adjusted. The interface only specifies that the object broadcasts Event objects whenever something changes in the model. 20 A Model can contain recursively contain sub-models. For instance a Personmodel may contain a StringModel containing the name, and a NumberModel containing the age.20 A Model is called a Compound Model if it contains sub-models. For instance a Person compound model may contain a StringModel containing the name, and a NumberModel containing the age. 21 21 22 22 === Event object … … 28 28 * Selected: a model (eg in a list) just got selected 29 29 30 === BasicModel 31 BasicModel is a generic implementation of Model ment to store primitive objects eg String or numbers. It introduces a getValue and setValue function. There also is a check() function. The intention of the check() function is that a Model throws an exception if the value passed into setValue does not meet additional requirements. 30 === Basic Models 31 * BasicModel is a generic implementation of Model ment to store primitive objects eg String or numbers. It introduces a getValue and setValue function. There also is a check() function. The intention of the check() function is that a Model throws an exception if the value passed into setValue does not meet additional requirements. 32 * StringModel is a BasicModel containing a String 33 * NumberModel is a BasicModel containing a Number. Actually it contains a BigDecimal, which allows arbitrary precision numbers to be entered and manipulated without loss of precision or rounding. 32 34 35 === ListModel 36 ListModel contains a list of Models and thus is a compound model. 37 38 === MapModel 39 The MapModel contains a Map, or dictionary, of values. Both key and value are a Model so this is a compound model. That key and value are a Model implies that both key and value can be manipulated directly, without calling the MapModel directly. All implementations of MapModel will listen to such changes and notify the change anyway. 40 MapModel provides a getValue(key) and a put(key,value) function. 41 42 DefaultMapModel is the basic implementation of MapModel. It is implemented using a LinkedHashMap, which helps keeping a fixed order in the elements. This fixed order is important to ensure the display of the elements in the GUI remains fixed. It also allows setting a minimum number of elements in the map 43 44 MapFromKeys is a special implementation of MapModel that generates a Map from a ListModel. The ListModel contains the Keys of the Map. MapFromKeys ensures that all keys always have a value. If needed, the create() function is called to automatically generate a new value for a key. When a key is removed and then later re-added, MapFromKeys may remember the old value, if isRetainValues is set. 45 46 === TypedModel and RealType 47 A TypedModel extends a Model by adding a RealType and the functions getCurrentValue and setCurrentValue to get/set the RealType contained by the model. 48 The RealType refers to the actual object contained in the model. This is especially relevant for Compound Models, such as the Person model described above. The getCurrentValue function now returns a Person. 49 The reason that the RealType is not included in Model is because we run into typing issues with the MapModel.