@openui5/sap.ui.core 1.105.0 → 1.106.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (314) hide show
  1. package/.reuse/dep5 +20 -17
  2. package/THIRDPARTY.txt +31 -21
  3. package/package.json +1 -1
  4. package/src/jquery.sap.dom.js +10 -10
  5. package/src/jquery.sap.global.js +24 -216
  6. package/src/jquery.sap.history.js +1 -1
  7. package/src/jquery.sap.properties.js +2 -2
  8. package/src/jquery.sap.resources.js +1 -1
  9. package/src/jquery.sap.script.js +1 -1
  10. package/src/jquery.sap.storage.js +4 -4
  11. package/src/sap/base/i18n/ResourceBundle.js +7 -11
  12. package/src/sap/base/util/ObjectPath.js +1 -1
  13. package/src/sap/base/util/Properties.js +1 -1
  14. package/src/sap/base/util/fetch.js +8 -10
  15. package/src/sap/base/util/restricted/_CancelablePromise.js +1 -1
  16. package/src/sap/base/util/restricted/_castArray.js +1 -1
  17. package/src/sap/base/util/restricted/_compact.js +1 -1
  18. package/src/sap/base/util/restricted/_curry.js +1 -1
  19. package/src/sap/base/util/restricted/_debounce.js +1 -1
  20. package/src/sap/base/util/restricted/_difference.js +1 -1
  21. package/src/sap/base/util/restricted/_differenceBy.js +1 -1
  22. package/src/sap/base/util/restricted/_differenceWith.js +1 -1
  23. package/src/sap/base/util/restricted/_flatMap.js +1 -1
  24. package/src/sap/base/util/restricted/_flatMapDeep.js +1 -1
  25. package/src/sap/base/util/restricted/_flatMapDepth.js +1 -1
  26. package/src/sap/base/util/restricted/_flatten.js +1 -1
  27. package/src/sap/base/util/restricted/_flattenDeep.js +1 -1
  28. package/src/sap/base/util/restricted/_flattenDepth.js +1 -1
  29. package/src/sap/base/util/restricted/_intersection.js +1 -1
  30. package/src/sap/base/util/restricted/_intersectionBy.js +1 -1
  31. package/src/sap/base/util/restricted/_intersectionWith.js +1 -1
  32. package/src/sap/base/util/restricted/_isEqual.js +1 -1
  33. package/src/sap/base/util/restricted/_isEqualWith.js +1 -1
  34. package/src/sap/base/util/restricted/_isNil.js +1 -1
  35. package/src/sap/base/util/restricted/_max.js +1 -1
  36. package/src/sap/base/util/restricted/_merge.js +1 -1
  37. package/src/sap/base/util/restricted/_mergeWith.js +1 -1
  38. package/src/sap/base/util/restricted/_min.js +1 -1
  39. package/src/sap/base/util/restricted/_omit.js +1 -1
  40. package/src/sap/base/util/restricted/_pick.js +1 -1
  41. package/src/sap/base/util/restricted/_pickBy.js +1 -1
  42. package/src/sap/base/util/restricted/_throttle.js +1 -1
  43. package/src/sap/base/util/restricted/_toArray.js +1 -1
  44. package/src/sap/base/util/restricted/_union.js +1 -1
  45. package/src/sap/base/util/restricted/_unionBy.js +1 -1
  46. package/src/sap/base/util/restricted/_unionWith.js +1 -1
  47. package/src/sap/base/util/restricted/_uniq.js +1 -1
  48. package/src/sap/base/util/restricted/_uniqBy.js +1 -1
  49. package/src/sap/base/util/restricted/_uniqWith.js +1 -1
  50. package/src/sap/base/util/restricted/_without.js +1 -1
  51. package/src/sap/base/util/restricted/_xor.js +1 -1
  52. package/src/sap/base/util/restricted/_xorBy.js +1 -1
  53. package/src/sap/base/util/restricted/_xorWith.js +1 -1
  54. package/src/sap/base/util/restricted/_zipObject.js +1 -1
  55. package/src/sap/base/util/restricted/_zipObjectDeep.js +1 -1
  56. package/src/sap/base/util/syncFetch.js +9 -16
  57. package/src/sap/ui/Device.js +3 -3
  58. package/src/sap/ui/Global.js +7 -14
  59. package/src/sap/ui/VersionInfo.js +57 -54
  60. package/src/sap/ui/base/BindingInfo.js +198 -0
  61. package/src/sap/ui/base/DataType.js +1 -1
  62. package/src/sap/ui/base/Event.js +2 -2
  63. package/src/sap/ui/base/EventProvider.js +2 -2
  64. package/src/sap/ui/base/Interface.js +1 -1
  65. package/src/sap/ui/base/ManagedObject.js +209 -979
  66. package/src/sap/ui/base/ManagedObjectMetadata.js +6 -6
  67. package/src/sap/ui/base/Metadata.js +1 -1
  68. package/src/sap/ui/base/Object.js +1 -1
  69. package/src/sap/ui/base/ObjectPool.js +1 -1
  70. package/src/sap/ui/core/.library +13 -9
  71. package/src/sap/ui/core/BusyIndicator.js +1 -1
  72. package/src/sap/ui/core/Component.js +5 -5
  73. package/src/sap/ui/core/ComponentContainer.js +1 -1
  74. package/src/sap/ui/core/ComponentMetadata.js +5 -12
  75. package/src/sap/ui/core/ComponentSupport.js +1 -1
  76. package/src/sap/ui/core/Configuration.js +525 -336
  77. package/src/sap/ui/core/Control.js +1 -1
  78. package/src/sap/ui/core/Core.js +78 -125
  79. package/src/sap/ui/core/CustomData.js +1 -1
  80. package/src/sap/ui/core/DeclarativeSupport.js +1 -1
  81. package/src/sap/ui/core/Element.js +60 -4
  82. package/src/sap/ui/core/ElementMetadata.js +1 -1
  83. package/src/sap/ui/core/EnabledPropagator.js +1 -1
  84. package/src/sap/ui/core/EventBus.js +1 -1
  85. package/src/sap/ui/core/FocusHandler.js +29 -7
  86. package/src/sap/ui/core/Fragment.js +1 -1
  87. package/src/sap/ui/core/HTML.js +1 -1
  88. package/src/sap/ui/core/History.js +1 -1
  89. package/src/sap/ui/core/Icon.js +1 -1
  90. package/src/sap/ui/core/IconPool.js +8 -8
  91. package/src/sap/ui/core/IndicationColorSupport.js +2 -2
  92. package/src/sap/ui/core/IntervalTrigger.js +1 -1
  93. package/src/sap/ui/core/InvisibleMessage.js +1 -1
  94. package/src/sap/ui/core/InvisibleRenderer.js +1 -1
  95. package/src/sap/ui/core/InvisibleText.js +1 -1
  96. package/src/sap/ui/core/Item.js +1 -1
  97. package/src/sap/ui/core/LabelEnablement.js +1 -1
  98. package/src/sap/ui/core/LayoutData.js +1 -1
  99. package/src/sap/ui/core/ListItem.js +1 -1
  100. package/src/sap/ui/core/LocalBusyIndicator.js +1 -1
  101. package/src/sap/ui/core/Locale.js +1 -1
  102. package/src/sap/ui/core/LocaleData.js +5 -5
  103. package/src/sap/ui/core/Manifest.js +1 -1
  104. package/src/sap/ui/core/Message.js +1 -1
  105. package/src/sap/ui/core/Popup.js +13 -8
  106. package/src/sap/ui/core/RenderManager.js +7 -1
  107. package/src/sap/ui/core/Renderer.js +1 -1
  108. package/src/sap/ui/core/ResizeHandler.js +7 -7
  109. package/src/sap/ui/core/ScrollBar.js +1 -1
  110. package/src/sap/ui/core/SeparatorItem.js +1 -1
  111. package/src/sap/ui/core/Title.js +1 -1
  112. package/src/sap/ui/core/TooltipBase.js +12 -13
  113. package/src/sap/ui/core/UIArea.js +8 -9
  114. package/src/sap/ui/core/UIComponent.js +3 -3
  115. package/src/sap/ui/core/UIComponentMetadata.js +1 -1
  116. package/src/sap/ui/core/ValueStateSupport.js +2 -2
  117. package/src/sap/ui/core/VariantLayoutData.js +1 -1
  118. package/src/sap/ui/core/XMLComposite.js +2 -2
  119. package/src/sap/ui/core/XMLCompositeMetadata.js +1 -1
  120. package/src/sap/ui/core/XMLTemplateProcessor.js +7 -7
  121. package/src/sap/ui/core/_ConfigurationProvider.js +187 -0
  122. package/src/sap/ui/core/cache/CacheManager.js +2 -2
  123. package/src/sap/ui/core/cldr/es_BO.json +3 -3
  124. package/src/sap/ui/core/cldr/es_CL.json +3 -3
  125. package/src/sap/ui/core/cldr/es_MX.json +3 -3
  126. package/src/sap/ui/core/cldr/es_PE.json +3 -3
  127. package/src/sap/ui/core/cldr/es_UY.json +3 -3
  128. package/src/sap/ui/core/cldr/es_VE.json +2 -2
  129. package/src/sap/ui/core/delegate/ItemNavigation.js +1 -1
  130. package/src/sap/ui/core/delegate/ScrollEnablement.js +7 -6
  131. package/src/sap/ui/core/dnd/DragAndDrop.js +13 -9
  132. package/src/sap/ui/core/dnd/DragDropBase.js +1 -1
  133. package/src/sap/ui/core/dnd/DragDropInfo.js +1 -1
  134. package/src/sap/ui/core/dnd/DragInfo.js +1 -1
  135. package/src/sap/ui/core/dnd/DropInfo.js +1 -1
  136. package/src/sap/ui/core/format/DateFormat.js +5 -0
  137. package/src/sap/ui/core/format/NumberFormat.js +1 -1
  138. package/src/sap/ui/core/format/TimezoneUtil.js +1 -1
  139. package/src/sap/ui/core/hyphenation/Hyphenation.js +1 -1
  140. package/src/sap/ui/core/library.js +3 -3
  141. package/src/sap/ui/core/message/ControlMessageProcessor.js +1 -1
  142. package/src/sap/ui/core/message/Message.js +1 -1
  143. package/src/sap/ui/core/message/MessageManager.js +1 -1
  144. package/src/sap/ui/core/message/MessageParser.js +1 -1
  145. package/src/sap/ui/core/message/MessageProcessor.js +1 -1
  146. package/src/sap/ui/core/mvc/Controller.js +5 -0
  147. package/src/sap/ui/core/mvc/HTMLView.js +1 -1
  148. package/src/sap/ui/core/mvc/JSONView.js +1 -1
  149. package/src/sap/ui/core/mvc/JSView.js +2 -2
  150. package/src/sap/ui/core/mvc/TemplateView.js +1 -1
  151. package/src/sap/ui/core/mvc/View.js +1 -1
  152. package/src/sap/ui/core/mvc/XMLView.js +1 -1
  153. package/src/sap/ui/core/plugin/DeclarativeSupport.js +1 -1
  154. package/src/sap/ui/core/plugin/LessSupport.js +1 -1
  155. package/src/sap/ui/core/plugin/TemplatingSupport.js +1 -1
  156. package/src/sap/ui/core/postmessage/Bus.js +1 -1
  157. package/src/sap/ui/core/postmessage/confirmationDialog.js +1 -1
  158. package/src/sap/ui/core/routing/Router.js +1 -1
  159. package/src/sap/ui/core/rules/App.support.js +11 -13
  160. package/src/sap/ui/core/rules/Config.support.js +13 -13
  161. package/src/sap/ui/core/rules/CoreHelper.support.js +3 -3
  162. package/src/sap/ui/core/rules/Model.support.js +8 -8
  163. package/src/sap/ui/core/rules/Rendering.support.js +1 -1
  164. package/src/sap/ui/core/rules/Theming.support.js +8 -8
  165. package/src/sap/ui/core/rules/View.support.js +9 -9
  166. package/src/sap/ui/core/search/OpenSearchProvider.js +1 -1
  167. package/src/sap/ui/core/search/SearchProvider.js +1 -1
  168. package/src/sap/ui/core/service/Service.js +1 -1
  169. package/src/sap/ui/core/service/ServiceFactory.js +1 -1
  170. package/src/sap/ui/core/service/ServiceFactoryRegistry.js +1 -1
  171. package/src/sap/ui/core/support/Hotkeys.js +2 -3
  172. package/src/sap/ui/core/support/Plugin.js +1 -1
  173. package/src/sap/ui/core/support/Support.js +1 -1
  174. package/src/sap/ui/core/support/plugins/ControlTree.js +1 -1
  175. package/src/sap/ui/core/support/plugins/Debugging.js +3 -3
  176. package/src/sap/ui/core/support/plugins/Interaction.js +1 -1
  177. package/src/sap/ui/core/support/plugins/LocalStorage.js +1 -1
  178. package/src/sap/ui/core/support/plugins/Performance.js +1 -1
  179. package/src/sap/ui/core/support/plugins/Selector.js +1 -1
  180. package/src/sap/ui/core/support/plugins/TechInfo.js +1 -1
  181. package/src/sap/ui/core/support/plugins/Trace.js +1 -1
  182. package/src/sap/ui/core/support/plugins/ViewInfo.js +2 -2
  183. package/src/sap/ui/core/support/support.html +1 -1
  184. package/src/sap/ui/core/support/techinfo/TechnicalInfo.js +3 -3
  185. package/src/sap/ui/core/themes/base/shared.less +6 -0
  186. package/src/sap/ui/core/theming/Parameters.js +8 -15
  187. package/src/sap/ui/core/tmpl/DOMAttribute.js +1 -1
  188. package/src/sap/ui/core/tmpl/DOMElement.js +1 -1
  189. package/src/sap/ui/core/tmpl/HandlebarsTemplate.js +1 -1
  190. package/src/sap/ui/core/tmpl/Template.js +6 -4
  191. package/src/sap/ui/core/tmpl/TemplateControl.js +1 -1
  192. package/src/sap/ui/core/util/AsyncHintsHelper.js +1 -1
  193. package/src/sap/ui/core/util/Export.js +1 -1
  194. package/src/sap/ui/core/util/ExportCell.js +1 -1
  195. package/src/sap/ui/core/util/ExportColumn.js +1 -1
  196. package/src/sap/ui/core/util/ExportRow.js +1 -1
  197. package/src/sap/ui/core/util/ExportType.js +1 -1
  198. package/src/sap/ui/core/util/ExportTypeCSV.js +1 -1
  199. package/src/sap/ui/core/util/File.js +1 -1
  200. package/src/sap/ui/core/util/LibraryInfo.js +1 -1
  201. package/src/sap/ui/core/util/MockServer.js +45 -71
  202. package/src/sap/ui/core/util/PasteHelper.js +1 -1
  203. package/src/sap/ui/core/util/ResponsivePaddingsEnablement.js +4 -3
  204. package/src/sap/ui/core/util/XMLPreprocessor.js +2 -2
  205. package/src/sap/ui/core/util/reflection/BaseTreeModifier.js +1 -1
  206. package/src/sap/ui/core/util/serializer/HTMLViewSerializer.js +1 -1
  207. package/src/sap/ui/core/util/serializer/Serializer.js +1 -1
  208. package/src/sap/ui/core/util/serializer/ViewSerializer.js +1 -1
  209. package/src/sap/ui/core/util/serializer/XMLViewSerializer.js +1 -1
  210. package/src/sap/ui/core/util/serializer/delegate/Delegate.js +1 -1
  211. package/src/sap/ui/core/util/serializer/delegate/HTML.js +1 -1
  212. package/src/sap/ui/core/util/serializer/delegate/XML.js +1 -1
  213. package/src/sap/ui/core/ws/ReadyState.js +1 -1
  214. package/src/sap/ui/core/ws/SapPcpWebSocket.js +1 -1
  215. package/src/sap/ui/core/ws/WebSocket.js +1 -1
  216. package/src/sap/ui/debug/ControlTree.js +1 -1
  217. package/src/sap/ui/debug/DebugEnv.js +1 -1
  218. package/src/sap/ui/debug/PropertyList.css +1 -31
  219. package/src/sap/ui/debug/PropertyList.js +6 -250
  220. package/src/sap/ui/dom/getScrollbarSize.js +1 -1
  221. package/src/sap/ui/dom/jquery/control.js +1 -0
  222. package/src/sap/ui/events/jquery/EventSimulation.js +4 -4
  223. package/src/sap/ui/model/ClientModel.js +1 -1
  224. package/src/sap/ui/model/CompositeDataState.js +1 -1
  225. package/src/sap/ui/model/CompositeType.js +1 -1
  226. package/src/sap/ui/model/Context.js +3 -0
  227. package/src/sap/ui/model/ContextBinding.js +1 -1
  228. package/src/sap/ui/model/DataState.js +2 -2
  229. package/src/sap/ui/model/ListBinding.js +2 -2
  230. package/src/sap/ui/model/ManagedObjectBindingSupport.js +871 -0
  231. package/src/sap/ui/model/MetaModel.js +1 -1
  232. package/src/sap/ui/model/Model.js +16 -5
  233. package/src/sap/ui/model/SelectionModel.js +1 -1
  234. package/src/sap/ui/model/SimpleType.js +2 -2
  235. package/src/sap/ui/model/Sorter.js +2 -2
  236. package/src/sap/ui/model/TreeAutoExpandMode.js +1 -1
  237. package/src/sap/ui/model/Type.js +1 -1
  238. package/src/sap/ui/model/json/JSONModel.js +2 -2
  239. package/src/sap/ui/model/message/MessageModel.js +1 -1
  240. package/src/sap/ui/model/odata/AnnotationHelper.js +4 -4
  241. package/src/sap/ui/model/odata/ODataAnnotations.js +1 -1
  242. package/src/sap/ui/model/odata/ODataMessageParser.js +1 -1
  243. package/src/sap/ui/model/odata/ODataMetaModel.js +10 -10
  244. package/src/sap/ui/model/odata/ODataMetadata.js +1 -1
  245. package/src/sap/ui/model/odata/ODataModel.js +1 -1
  246. package/src/sap/ui/model/odata/ODataTreeBindingFlat.js +22 -29
  247. package/src/sap/ui/model/odata/type/Boolean.js +1 -1
  248. package/src/sap/ui/model/odata/type/Byte.js +1 -1
  249. package/src/sap/ui/model/odata/type/Currency.js +1 -1
  250. package/src/sap/ui/model/odata/type/Date.js +1 -1
  251. package/src/sap/ui/model/odata/type/DateTime.js +1 -1
  252. package/src/sap/ui/model/odata/type/DateTimeBase.js +1 -1
  253. package/src/sap/ui/model/odata/type/DateTimeOffset.js +1 -1
  254. package/src/sap/ui/model/odata/type/DateTimeWithTimezone.js +1 -1
  255. package/src/sap/ui/model/odata/type/Decimal.js +1 -1
  256. package/src/sap/ui/model/odata/type/Double.js +1 -1
  257. package/src/sap/ui/model/odata/type/Guid.js +1 -1
  258. package/src/sap/ui/model/odata/type/Int.js +1 -1
  259. package/src/sap/ui/model/odata/type/Int16.js +1 -1
  260. package/src/sap/ui/model/odata/type/Int32.js +1 -1
  261. package/src/sap/ui/model/odata/type/Int64.js +1 -1
  262. package/src/sap/ui/model/odata/type/ODataType.js +1 -1
  263. package/src/sap/ui/model/odata/type/Raw.js +1 -1
  264. package/src/sap/ui/model/odata/type/SByte.js +1 -1
  265. package/src/sap/ui/model/odata/type/Single.js +1 -1
  266. package/src/sap/ui/model/odata/type/Stream.js +1 -1
  267. package/src/sap/ui/model/odata/type/String.js +1 -1
  268. package/src/sap/ui/model/odata/type/Time.js +1 -1
  269. package/src/sap/ui/model/odata/type/TimeOfDay.js +1 -1
  270. package/src/sap/ui/model/odata/type/Unit.js +1 -1
  271. package/src/sap/ui/model/odata/v2/Context.js +5 -5
  272. package/src/sap/ui/model/odata/v2/ODataAnnotations.js +1 -1
  273. package/src/sap/ui/model/odata/v2/ODataContextBinding.js +1 -1
  274. package/src/sap/ui/model/odata/v2/ODataListBinding.js +1 -1
  275. package/src/sap/ui/model/odata/v2/ODataModel.js +4 -4
  276. package/src/sap/ui/model/odata/v2/ODataTreeBinding.js +1 -1
  277. package/src/sap/ui/model/odata/v4/AnnotationHelper.js +3 -3
  278. package/src/sap/ui/model/odata/v4/Context.js +88 -54
  279. package/src/sap/ui/model/odata/v4/ODataBinding.js +47 -4
  280. package/src/sap/ui/model/odata/v4/ODataContextBinding.js +86 -66
  281. package/src/sap/ui/model/odata/v4/ODataListBinding.js +96 -68
  282. package/src/sap/ui/model/odata/v4/ODataMetaModel.js +13 -10
  283. package/src/sap/ui/model/odata/v4/ODataModel.js +247 -27
  284. package/src/sap/ui/model/odata/v4/ODataParentBinding.js +23 -5
  285. package/src/sap/ui/model/odata/v4/ODataPropertyBinding.js +14 -8
  286. package/src/sap/ui/model/odata/v4/ODataUtils.js +7 -4
  287. package/src/sap/ui/model/odata/v4/lib/_AggregationCache.js +8 -8
  288. package/src/sap/ui/model/odata/v4/lib/_AggregationHelper.js +40 -6
  289. package/src/sap/ui/model/odata/v4/lib/_Cache.js +89 -69
  290. package/src/sap/ui/model/odata/v4/lib/_ConcatHelper.js +2 -3
  291. package/src/sap/ui/model/odata/v4/lib/_Helper.js +47 -35
  292. package/src/sap/ui/model/odata/v4/lib/_MinMaxHelper.js +2 -3
  293. package/src/sap/ui/model/odata/v4/lib/_Requestor.js +5 -0
  294. package/src/sap/ui/model/resource/ResourceModel.js +2 -2
  295. package/src/sap/ui/model/type/Boolean.js +1 -1
  296. package/src/sap/ui/model/type/Currency.js +2 -2
  297. package/src/sap/ui/model/type/Date.js +1 -1
  298. package/src/sap/ui/model/type/DateInterval.js +1 -1
  299. package/src/sap/ui/model/type/DateTime.js +1 -1
  300. package/src/sap/ui/model/type/DateTimeInterval.js +1 -1
  301. package/src/sap/ui/model/type/FileSize.js +1 -1
  302. package/src/sap/ui/model/type/Float.js +1 -1
  303. package/src/sap/ui/model/type/Integer.js +1 -1
  304. package/src/sap/ui/model/type/String.js +2 -2
  305. package/src/sap/ui/model/type/Time.js +1 -1
  306. package/src/sap/ui/model/type/TimeInterval.js +1 -1
  307. package/src/sap/ui/model/type/Unit.js +1 -1
  308. package/src/sap/ui/model/xml/XMLModel.js +1 -1
  309. package/src/sap/ui/qunit/QUnitUtils.js +1 -2
  310. package/src/sap/ui/qunit/utils/ControlIterator.js +1 -1
  311. package/src/sap/ui/qunit/utils/MemoryLeakCheck.js +1 -1
  312. package/src/sap/ui/test/OpaBuilder.js +1 -1
  313. package/src/sap/ui/test/generic/TestBase.js +1 -1
  314. package/src/sap/ui/util/Storage.js +1 -1
@@ -0,0 +1,871 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ /*eslint-disable max-len */
8
+ /*global */
9
+ sap.ui.define([
10
+ "./BindingMode",
11
+ "./StaticBinding",
12
+ "./CompositeBinding",
13
+ "./FormatException",
14
+ "./ParseException",
15
+ "./ValidateException",
16
+ "./Context",
17
+ "sap/base/Log",
18
+ "sap/base/assert",
19
+ "sap/ui/base/Object",
20
+ "sap/base/util/ObjectPath",
21
+ "sap/ui/base/SyncPromise",
22
+ "sap/ui/base/ManagedObject",
23
+ "sap/ui/base/ManagedObjectMetadata"
24
+ ], function(
25
+ BindingMode,
26
+ StaticBinding,
27
+ CompositeBinding,
28
+ FormatException,
29
+ ParseException,
30
+ ValidateException,
31
+ Context,
32
+ Log,
33
+ assert,
34
+ BaseObject,
35
+ ObjectPath,
36
+ SyncPromise,
37
+ ManagedObject,
38
+ ManagedObjectMetadata) {
39
+ "use strict";
40
+
41
+ /**
42
+ * Mixin for data binding support on the ManagedObject class.
43
+ * Comes as a dependency of the "sap/ui/model/Model" base class.
44
+ * The mixin is applied to the ManagedObject.prototype during the
45
+ * property propagation.
46
+ */
47
+ var ManagedObjectBindingSupport = {
48
+ /*
49
+ * ObjectBinding
50
+ */
51
+ _bindObject: function(oBindingInfo) {
52
+ var oBinding,
53
+ oContext,
54
+ sModelName,
55
+ oModel,
56
+ that = this;
57
+
58
+ var fnChangeHandler = function(oEvent) {
59
+ that.setElementBindingContext(oBinding.getBoundContext(), sModelName);
60
+ };
61
+
62
+ var fnDataStateChangeHandler = function(oEvent) {
63
+ var oDataState = oBinding.getDataState();
64
+ if (!oDataState) {
65
+ return;
66
+ }
67
+ //inform generic refreshDataState method
68
+ if (that.refreshDataState) {
69
+ that.refreshDataState('', oDataState);
70
+ }
71
+ };
72
+
73
+ sModelName = oBindingInfo.model;
74
+ oModel = this.getModel(sModelName);
75
+
76
+ oContext = this.getBindingContext(sModelName);
77
+
78
+ oBinding = oModel.bindContext(oBindingInfo.path, oContext, oBindingInfo.parameters);
79
+ if (oBindingInfo.suspended) {
80
+ oBinding.suspend(true);
81
+ }
82
+ oBinding.attachChange(fnChangeHandler);
83
+ oBindingInfo.binding = oBinding;
84
+ oBindingInfo.modelChangeHandler = fnChangeHandler;
85
+ oBindingInfo.dataStateChangeHandler = fnDataStateChangeHandler;
86
+
87
+ oBinding.attachEvents(oBindingInfo.events);
88
+
89
+ if (this.refreshDataState) {
90
+ oBinding.attachAggregatedDataStateChange(fnDataStateChangeHandler);
91
+ }
92
+
93
+ oBinding.initialize();
94
+ },
95
+
96
+ _unbindObject: function(oBindingInfo, sModelName, _bSkipUpdateBindingContext) {
97
+ if (oBindingInfo.binding) {
98
+ if (!this._bIsBeingDestroyed) {
99
+ this._detachObjectBindingHandlers(oBindingInfo);
100
+ }
101
+ oBindingInfo.binding.destroy();
102
+ }
103
+ delete this.mElementBindingContexts[sModelName];
104
+ if ( !_bSkipUpdateBindingContext ) {
105
+ this.updateBindingContext(false, sModelName);
106
+ this.propagateProperties(sModelName);
107
+ this.fireModelContextChange();
108
+ }
109
+ },
110
+
111
+ _detachObjectBindingHandlers: function(oBindingInfo) {
112
+ if (oBindingInfo.binding) {
113
+ oBindingInfo.binding.detachChange(oBindingInfo.modelChangeHandler);
114
+ oBindingInfo.binding.detachEvents(oBindingInfo.events);
115
+ if (this.refreshDataState) {
116
+ oBindingInfo.binding.detachAggregatedDataStateChange(oBindingInfo.dataStateChangeHandler);
117
+ }
118
+ }
119
+ },
120
+
121
+ /*
122
+ * Update Bindings
123
+ */
124
+ updateBindings: function(bUpdateAll, sModelName) {
125
+ var that = this,
126
+ sName,
127
+ bCanCreate,
128
+ oBindingInfo;
129
+
130
+ /*
131
+ * Checks whether the binding for the given oBindingInfo became invalid because
132
+ * of the current model change (as identified by bUpdateAll and sModelName).
133
+ *
134
+ * Precondition: oBindingInfo contains a 'binding' object
135
+ *
136
+ * @param {object} oBindingInfo
137
+ * @returns {boolean} Whether the binding info became invalid
138
+ * @private
139
+ */
140
+ function becameInvalid(oBindingInfo) {
141
+ var aParts = oBindingInfo.parts,
142
+ i;
143
+
144
+ if (aParts) {
145
+ if (aParts.length == 1) {
146
+ // simple property binding: invalid when the model has the same name (or updateall) and when the model instance differs
147
+ return (bUpdateAll || aParts[0].model == sModelName) && !oBindingInfo.binding.updateRequired(that.getModel(aParts[0].model));
148
+ } else {
149
+ // simple or composite binding: invalid when for any part the model has the same name (or updateall) and when the model instance for that part differs
150
+ for (i = 0; i < aParts.length; i++) {
151
+ if ( (bUpdateAll || aParts[i].model == sModelName) && !oBindingInfo.binding.aBindings[i].updateRequired(that.getModel(aParts[i].model)) ) {
152
+ return true;
153
+ }
154
+ }
155
+ }
156
+ } else {
157
+ // list or object binding: invalid when the model has the same name (or updateall) and when the model instance differs
158
+ return (bUpdateAll || oBindingInfo.model == sModelName) && !oBindingInfo.binding.updateRequired(that.getModel(oBindingInfo.model));
159
+ }
160
+ }
161
+
162
+ /*
163
+ * Checks whether a binding can be created for the given oBindingInfo.
164
+ *
165
+ * @param {object} oBindingInfo
166
+ * @returns {boolean} Whether a binding can be created
167
+ * @private
168
+ */
169
+ function canCreate(oBindingInfo) {
170
+ var aParts = oBindingInfo.parts,
171
+ i;
172
+
173
+ if (aParts) {
174
+ for (i = 0; i < aParts.length; i++) {
175
+ // check if model exists - ignore static bindings
176
+ if ( !that.getModel(aParts[i].model) && aParts[i].value === undefined) {
177
+ return false;
178
+ }
179
+ }
180
+ return true;
181
+ } else { // List or object binding
182
+ return !!that.getModel(oBindingInfo.model);
183
+ }
184
+ }
185
+
186
+ /*
187
+ * Remove binding, detach all events and destroy binding object
188
+ */
189
+ function removeBinding(oBindingInfo) {
190
+ var oBinding = oBindingInfo.binding;
191
+ // Also tell the Control that the messages have been removed (if any)
192
+ if (that.refreshDataState) {
193
+ that.refreshDataState(sName, oBinding.getDataState());
194
+ }
195
+
196
+ oBinding.detachChange(oBindingInfo.modelChangeHandler);
197
+ if (oBindingInfo.modelRefreshHandler) { // only list bindings currently have a refresh handler attached
198
+ oBinding.detachRefresh(oBindingInfo.modelRefreshHandler);
199
+ }
200
+ oBinding.detachEvents(oBindingInfo.events);
201
+ oBinding.destroy();
202
+ // remove all binding related data from the binding info
203
+ delete oBindingInfo.binding;
204
+ delete oBindingInfo.modelChangeHandler;
205
+ delete oBindingInfo.dataStateChangeHandler;
206
+ delete oBindingInfo.modelRefreshHandler;
207
+ }
208
+
209
+ // create object bindings if they don't exist yet
210
+ for ( sName in this.mObjectBindingInfos ) {
211
+ oBindingInfo = this.mObjectBindingInfos[sName];
212
+ bCanCreate = canCreate(oBindingInfo);
213
+ // if there is a binding and if it became invalid through the current model change, then remove it
214
+ if ( oBindingInfo.binding && becameInvalid(oBindingInfo) ) {
215
+ removeBinding(oBindingInfo);
216
+ // if model does not exists anymore, also delete the BindingContext
217
+ if (!bCanCreate) {
218
+ delete this.mElementBindingContexts[sName];
219
+ }
220
+ }
221
+
222
+ // if there is no binding and if all required information is available, create a binding object
223
+ if ( !oBindingInfo.binding && bCanCreate ) {
224
+ this._bindObject(oBindingInfo);
225
+ }
226
+ }
227
+
228
+ // create property and aggregation bindings if they don't exist yet
229
+ for ( sName in this.mBindingInfos ) {
230
+
231
+ oBindingInfo = this.mBindingInfos[sName];
232
+
233
+ // if there is a binding and if it became invalid through the current model change, then remove it
234
+ if ( oBindingInfo.binding && becameInvalid(oBindingInfo) ) {
235
+ if (this._observer) {
236
+ var sMember = oBindingInfo.factory ? "aggregation" : "property";
237
+ this._observer.bindingChange(this, sName, "remove", oBindingInfo, sMember);
238
+ }
239
+
240
+ removeBinding(oBindingInfo);
241
+ }
242
+
243
+ // if there is no binding and if all required information is available, create a binding object
244
+ if ( !oBindingInfo.binding && canCreate(oBindingInfo) ) {
245
+ if (oBindingInfo.factory) {
246
+ this._bindAggregation(sName, oBindingInfo);
247
+ } else {
248
+ this._bindProperty(sName, oBindingInfo);
249
+ }
250
+ }
251
+ }
252
+ },
253
+
254
+ updateProperty: function(sName) {
255
+ var oBindingInfo = this.mBindingInfos[sName],
256
+ oBinding = oBindingInfo.binding,
257
+ oPropertyInfo = this.getMetadata().getPropertyLikeSetting(sName),
258
+ that = this;
259
+
260
+ function handleException(oException) {
261
+ if (oException instanceof FormatException) {
262
+ that.fireFormatError({
263
+ element : that,
264
+ property : sName,
265
+ type : oBinding.getType(),
266
+ newValue : oBinding.getValue(),
267
+ oldValue : that[oPropertyInfo._sGetter](),
268
+ exception: oException,
269
+ message: oException.message
270
+ }, false, true); // bAllowPreventDefault, bEnableEventBubbling
271
+ Log.error("FormatException in property '" + sName + "' of '" + that + "': " + oException.message +
272
+ "\nHint: single properties referenced in composite bindings and within binding expressions are automatically converted " +
273
+ "into the type of the bound control property, unless a different 'targetType' is specified. targetType:'any' may avoid " +
274
+ "the conversion and lead to the expected behavior.");
275
+ oBindingInfo.skipModelUpdate++;
276
+ that.resetProperty(sName);
277
+ oBindingInfo.skipModelUpdate--;
278
+ } else {
279
+ throw oException;
280
+ }
281
+ }
282
+
283
+ // If model change was triggered by the property itself, don't call the setter again
284
+ if (oBindingInfo.skipPropertyUpdate) {
285
+ return;
286
+ }
287
+
288
+ SyncPromise.resolve().then(function() {
289
+ return oBinding.getExternalValue();
290
+ }).then(function(oValue) {
291
+ oBindingInfo.skipModelUpdate++;
292
+ that[oPropertyInfo._sMutator](oValue);
293
+ oBindingInfo.skipModelUpdate--;
294
+ }).catch(function(oException) {
295
+ handleException(oException);
296
+ }).unwrap();
297
+ },
298
+
299
+ updateModelProperty: function(sName, oValue, oOldValue){
300
+ var oBindingInfo, oBinding,
301
+ that = this;
302
+
303
+ function handleException(oException) {
304
+ var mErrorParameters = {
305
+ element: that,
306
+ property: sName,
307
+ type: oBinding.getType(),
308
+ newValue: oValue,
309
+ oldValue: oOldValue,
310
+ exception: oException,
311
+ message: oException.message
312
+ };
313
+ if (oException instanceof ParseException) {
314
+ that.fireParseError(mErrorParameters, false, true); // mParameters, bAllowPreventDefault, bEnableEventBubbling
315
+ } else if (oException instanceof ValidateException) {
316
+ that.fireValidationError(mErrorParameters, false, true); // mParameters, bAllowPreventDefault, bEnableEventBubbling
317
+ } else {
318
+ throw oException;
319
+ }
320
+ }
321
+
322
+ function handleSuccess() {
323
+ var mSuccessParameters = {
324
+ element: that,
325
+ property: sName,
326
+ type: oBinding.getType(),
327
+ newValue: oValue,
328
+ oldValue: oOldValue
329
+ };
330
+ // Only fire validation success, if a type is used
331
+ if (oBinding.hasValidation()) {
332
+ that.fireValidationSuccess(mSuccessParameters, false, true); // bAllowPreventDefault, bEnableEventBubbling
333
+ }
334
+ }
335
+
336
+ if (this.isBound(sName)) {
337
+ var oBindingInfo = this.mBindingInfos[sName],
338
+ oBinding = oBindingInfo.binding;
339
+
340
+ // If property change was triggered by the model, don't update the model again
341
+ if (oBindingInfo.skipModelUpdate || (oBinding && oBinding.isSuspended())) {
342
+ return;
343
+ }
344
+
345
+ // only two-way bindings allow model updates
346
+ if (oBinding && oBinding.getBindingMode() == BindingMode.TwoWay) {
347
+ oBindingInfo.skipPropertyUpdate++;
348
+ SyncPromise.resolve(oValue).then(function(oValue) {
349
+ return oBinding.setExternalValue(oValue);
350
+ }).then(function() {
351
+ oBindingInfo.skipPropertyUpdate--;
352
+ return oBinding.getExternalValue();
353
+ }).then(function(oExternalValue) {
354
+ if (oValue != oExternalValue) {
355
+ that.updateProperty(sName);
356
+ }
357
+ handleSuccess();
358
+ }).catch(function(oException) {
359
+ oBindingInfo.skipPropertyUpdate--;
360
+ handleException(oException);
361
+ }).unwrap();
362
+ }
363
+ }
364
+ },
365
+
366
+ updateAggregation: function(sName, sChangeReason, oEventInfo) {
367
+ var oBindingInfo = this.mBindingInfos[sName],
368
+ oBinding = oBindingInfo.binding,
369
+ fnFactory = oBindingInfo.factory,
370
+ oAggregationInfo = this.getMetadata().getAggregation(sName), // TODO fix handling of hidden aggregations
371
+ sGroup,
372
+ bGrouped,
373
+ aContexts,
374
+ sGroupFunction = oAggregationInfo._sMutator + "Group",
375
+ that = this;
376
+
377
+ function getIdSuffix(oControl, iIndex) {
378
+ if (that.bUseExtendedChangeDetection) {
379
+ return ManagedObjectMetadata.uid('clone');
380
+ } else {
381
+ return oControl.getId() + "-" + iIndex;
382
+ }
383
+ }
384
+
385
+ // Update a single aggregation with the array of contexts. Reuse existing children
386
+ // and just append or remove at the end, if some are missing or too many.
387
+ function update(oControl, aContexts, fnBefore, fnAfter) {
388
+ var aChildren = oControl[oAggregationInfo._sGetter]() || [],
389
+ oContext,
390
+ oClone;
391
+ if (aChildren.length > aContexts.length) {
392
+ for (var i = aContexts.length; i < aChildren.length; i++) {
393
+ oClone = aChildren[i];
394
+ oControl[oAggregationInfo._sRemoveMutator](oClone);
395
+ oClone.destroy("KeepDom");
396
+ }
397
+ }
398
+ for (var i = 0; i < aContexts.length; i++) {
399
+ oContext = aContexts[i];
400
+ oClone = aChildren[i];
401
+ if (fnBefore) {
402
+ fnBefore(oContext);
403
+ }
404
+ if (oClone) {
405
+ oClone.setBindingContext(oContext, oBindingInfo.model);
406
+ } else {
407
+ oClone = fnFactory(getIdSuffix(oControl, i), oContext);
408
+ oClone.setBindingContext(oContext, oBindingInfo.model);
409
+ oControl[oAggregationInfo._sMutator](oClone);
410
+ }
411
+ if (fnAfter) {
412
+ fnAfter(oContext, oClone);
413
+ }
414
+ }
415
+ }
416
+
417
+ // Update a single aggregation with the array of contexts. Use the calculated diff to
418
+ // only add/remove children as the data has changed to minimize control updates and rendering
419
+ function updateDiff(oControl, aContexts) {
420
+ var aDiff = aContexts.diff,
421
+ aChildren = oControl[oAggregationInfo._sGetter]() || [],
422
+ oDiff, oClone, oContext, i;
423
+
424
+ // If no diff exists or aggregation is empty, fall back to default update
425
+ if (!aDiff || aChildren.length === 0) {
426
+ update(oControl, aContexts);
427
+ return;
428
+ }
429
+
430
+ // Loop through the diff and apply it
431
+ for (i = 0; i < aDiff.length; i++) {
432
+ oDiff = aDiff[i];
433
+ switch (oDiff.type) {
434
+ case "insert":
435
+ oContext = aContexts[oDiff.index];
436
+ oClone = fnFactory(getIdSuffix(oControl, oDiff.index), oContext);
437
+ oClone.setBindingContext(oContext, oBindingInfo.model);
438
+ oControl[oAggregationInfo._sInsertMutator](oClone, oDiff.index);
439
+ break;
440
+ case "delete":
441
+ oClone = oControl[oAggregationInfo._sRemoveMutator](oDiff.index);
442
+ oClone.destroy("KeepDom");
443
+ break;
444
+ default:
445
+ Log.error("Unknown diff type \"" + oDiff.type + "\"");
446
+ }
447
+ }
448
+
449
+ // Loop through all children and set the binding context again. This is needed for
450
+ // indexed contexts, where inserting/deleting entries shifts the index of all following items
451
+ aChildren = oControl[oAggregationInfo._sGetter]() || [];
452
+ for (i = 0; i < aChildren.length; i++) {
453
+ aChildren[i].setBindingContext(aContexts[i], oBindingInfo.model);
454
+ }
455
+ }
456
+
457
+ // Check the current context for its group. If the group key changes, call the
458
+ // group function on the control.
459
+ function updateGroup(oContext) {
460
+ var oNewGroup = oBinding.getGroup(oContext);
461
+ if (oNewGroup.key !== sGroup) {
462
+ var oGroupHeader;
463
+ //If factory is defined use it
464
+ if (oBindingInfo.groupHeaderFactory) {
465
+ oGroupHeader = oBindingInfo.groupHeaderFactory(oNewGroup);
466
+ }
467
+ that[sGroupFunction](oNewGroup, oGroupHeader);
468
+ sGroup = oNewGroup.key;
469
+ }
470
+ }
471
+
472
+ // Update the tree recursively
473
+ function updateRecursive(oControl, oContexts) {
474
+ update(oControl, oContexts, null, function(oContext, oClone) {
475
+ updateRecursive(oClone, oBinding.getNodeContexts(oContext));
476
+ });
477
+ }
478
+
479
+ if (BaseObject.isA(oBinding, "sap.ui.model.ListBinding")) {
480
+ aContexts = oBinding.getContexts(oBindingInfo.startIndex, oBindingInfo.length);
481
+ bGrouped = oBinding.isGrouped() && that[sGroupFunction];
482
+ if (bGrouped || oBinding.bWasGrouped) {
483
+ // If grouping is enabled, destroy aggregation and use updateGroup as fnBefore to create groups
484
+ this[oAggregationInfo._sDestructor]();
485
+ update(this, aContexts, bGrouped ? updateGroup : undefined);
486
+ } else if (this.bUseExtendedChangeDetection) {
487
+ // With extended change detection just update according to the diff
488
+ updateDiff(this, aContexts);
489
+ } else {
490
+ // If factory function is used without extended change detection, destroy aggregation
491
+ if (!oBindingInfo.template) {
492
+ this[oAggregationInfo._sDestructor]();
493
+ }
494
+ update(this, aContexts);
495
+ }
496
+ oBinding.bWasGrouped = bGrouped;
497
+ } else if (BaseObject.isA(oBinding, "sap.ui.model.TreeBinding")) {
498
+ // Destroy all children in case a factory function is used
499
+ if (!oBindingInfo.template) {
500
+ this[oAggregationInfo._sDestructor]();
501
+ }
502
+ // In fnAfter call update recursively for the child nodes of the current tree node
503
+ updateRecursive(this, oBinding.getRootContexts());
504
+ }
505
+ },
506
+
507
+ updateBindingContext: function(bSkipLocal, sFixedModelName, bUpdateAll){
508
+ var oModel,
509
+ oModelNames = {},
510
+ sModelName,
511
+ oContext,
512
+ sName,
513
+ oBindingInfo,
514
+ aParts;
515
+
516
+ // Whether the binding part with the given index belongs to the current model name and is
517
+ // not a static binding
518
+ function isPartForModel(iPartIndex) {
519
+ return aParts[iPartIndex].model == sModelName && aParts[iPartIndex].value === undefined;
520
+ }
521
+
522
+ // find models that need a context update
523
+ if (bUpdateAll) {
524
+ for (sModelName in this.oModels) {
525
+ if ( this.oModels.hasOwnProperty(sModelName) ) {
526
+ oModelNames[sModelName] = sModelName;
527
+ }
528
+ }
529
+ for (sModelName in this.oPropagatedProperties.oModels) {
530
+ if ( this.oPropagatedProperties.oModels.hasOwnProperty(sModelName) ) {
531
+ oModelNames[sModelName] = sModelName;
532
+ }
533
+ }
534
+ } else {
535
+ oModelNames[sFixedModelName] = sFixedModelName;
536
+ }
537
+
538
+ for (sModelName in oModelNames ) {
539
+ if ( oModelNames.hasOwnProperty(sModelName) ) {
540
+ sModelName = sModelName === "undefined" ? undefined : sModelName;
541
+ oModel = this.getModel(sModelName);
542
+ oBindingInfo = this.mObjectBindingInfos[sModelName];
543
+
544
+ if (oModel && oBindingInfo && !bSkipLocal) {
545
+ if (!oBindingInfo.binding) {
546
+ this._bindObject(oBindingInfo);
547
+ } else {
548
+ oContext = this._getBindingContext(sModelName);
549
+ var oOldContext = oBindingInfo.binding.getContext();
550
+ if (Context.hasChanged(oOldContext, oContext)) {
551
+ oBindingInfo.binding.setContext(oContext);
552
+ }
553
+ }
554
+ continue;
555
+ }
556
+
557
+ oContext = this.getBindingContext(sModelName);
558
+
559
+ // update context in existing bindings
560
+ for ( sName in this.mBindingInfos ){
561
+ var oBindingInfo = this.mBindingInfos[sName],
562
+ oBinding = oBindingInfo.binding;
563
+
564
+ aParts = oBindingInfo.parts;
565
+
566
+ if (!oBinding) {
567
+ continue;
568
+ }
569
+ if (oBinding instanceof CompositeBinding) {
570
+ oBinding.setContext(oContext, {fnIsBindingRelevant : isPartForModel});
571
+ } else if (oBindingInfo.factory) {
572
+ // list binding: update required when the model has the same name (or updateall)
573
+ if ( oBindingInfo.model == sModelName) {
574
+ oBinding.setContext(oContext);
575
+ }
576
+
577
+ } else if (isPartForModel(0)) {
578
+ // simple property binding: update required when the model has the same name
579
+ oBinding.setContext(oContext);
580
+ }
581
+ }
582
+ }
583
+ }
584
+ },
585
+
586
+ /*
587
+ * Refresh Bindings
588
+ */
589
+ refreshAggregation: function(sName) {
590
+ var oBindingInfo = this.mBindingInfos[sName],
591
+ oBinding = oBindingInfo.binding;
592
+ oBinding.getContexts(oBindingInfo.startIndex, oBindingInfo.length);
593
+ },
594
+
595
+ /*
596
+ * Setter
597
+ */
598
+ setElementBindingContext: function(oContext, sModelName){
599
+ assert(sModelName === undefined || (typeof sModelName === "string" && !/^(undefined|null)?$/.test(sModelName)), "sModelName must be a string or omitted");
600
+ var oOldContext = this.mElementBindingContexts[sModelName];
601
+
602
+ if (Context.hasChanged(oOldContext, oContext)) {
603
+ if (oContext === undefined) {
604
+ delete this.mElementBindingContexts[sModelName];
605
+ } else {
606
+ this.mElementBindingContexts[sModelName] = oContext;
607
+ }
608
+ this.updateBindingContext(true, sModelName);
609
+ this.propagateProperties(sModelName);
610
+ this.fireModelContextChange();
611
+ }
612
+ return this;
613
+ },
614
+
615
+ /*
616
+ * Property Binding
617
+ */
618
+ _bindProperty: function(sName, oBindingInfo) {
619
+ var oModel,
620
+ oContext,
621
+ oBinding,
622
+ sMode,
623
+ sCompositeMode = BindingMode.TwoWay,
624
+ oType,
625
+ clType,
626
+ oPropertyInfo = this.getMetadata().getPropertyLikeSetting(sName), // TODO fix handling of hidden entities?
627
+ sInternalType = oPropertyInfo._iKind === /* PROPERTY */ 0 ? oPropertyInfo.type : oPropertyInfo.altTypes[0],
628
+ that = this,
629
+ aBindings = [],
630
+ fnModelChangeHandler = function(oEvent){
631
+ that.updateProperty(sName);
632
+ //clear Messages from messageManager
633
+ var oDataState = oBinding.getDataState();
634
+ if (oDataState) {
635
+ var oControlMessages = oDataState.getControlMessages();
636
+ if (oControlMessages && oControlMessages.length > 0) {
637
+ var oMessageManager = sap.ui.getCore().getMessageManager();
638
+ oDataState.setControlMessages([]); //remove the controlMessages before informing manager to avoid 'dataStateChange' event to fire
639
+ if (oControlMessages) {
640
+ oMessageManager.removeMessages(oControlMessages);
641
+ }
642
+ }
643
+ oDataState.setInvalidValue(undefined); //assume that the model always sends valid data
644
+ }
645
+ if (oBinding.getBindingMode() === BindingMode.OneTime && oBinding.isResolved()) {
646
+ // if binding is one time but not resolved yet we don't destroy it yet.
647
+ oBinding.detachChange(fnModelChangeHandler);
648
+ if (this.refreshDataState) {
649
+ oBinding.detachAggregatedDataStateChange(fnDataStateChangeHandler);
650
+ }
651
+ oBinding.detachEvents(oBindingInfo.events);
652
+ }
653
+ },
654
+ fnDataStateChangeHandler = function(){
655
+ var oDataState = oBinding.getDataState();
656
+ if (!oDataState) {
657
+ return;
658
+ }
659
+ //inform generic refreshDataState method
660
+ if (that.refreshDataState) {
661
+ that.refreshDataState(sName, oDataState);
662
+ }
663
+ };
664
+
665
+ oBindingInfo.parts.forEach(function(oPart) {
666
+ // get context and model for this part
667
+ oContext = that.getBindingContext(oPart.model);
668
+ oModel = that.getModel(oPart.model);
669
+
670
+ // Create type instance if needed
671
+ oType = oPart.type;
672
+ if (typeof oType == "string") {
673
+ clType = ObjectPath.get(oType);
674
+ if (typeof clType !== "function") {
675
+ throw new Error("Cannot find type \"" + oType + "\" used in control \"" + that.getId() + "\"!");
676
+ }
677
+ oType = new clType(oPart.formatOptions, oPart.constraints);
678
+ }
679
+
680
+ if (oPart.value !== undefined) {
681
+ oBinding = new StaticBinding(oPart.value);
682
+ } else {
683
+ oBinding = oModel.bindProperty(oPart.path, oContext, oPart.parameters || oBindingInfo.parameters);
684
+ }
685
+ oBinding.setType(oType, oPart.targetType || sInternalType);
686
+ oBinding.setFormatter(oPart.formatter);
687
+ if (oPart.suspended) {
688
+ oBinding.suspend(true);
689
+ }
690
+
691
+ sMode = oPart.mode || (oModel && oModel.getDefaultBindingMode()) || BindingMode.TwoWay;
692
+ oBinding.setBindingMode(sMode);
693
+
694
+ // Only if all parts have twoway binding enabled, the composite binding will also have twoway binding
695
+ if (sMode !== BindingMode.TwoWay) {
696
+ sCompositeMode = BindingMode.OneWay;
697
+ }
698
+
699
+ aBindings.push(oBinding);
700
+ });
701
+
702
+ // check if we have a composite binding or a formatter function created by the BindingParser which has property textFragments
703
+ if (aBindings.length > 1 || ( oBindingInfo.formatter && oBindingInfo.formatter.textFragments )) {
704
+ // Create type instance if needed
705
+ oType = oBindingInfo.type;
706
+ if (typeof oType == "string") {
707
+ clType = ObjectPath.get(oType);
708
+ oType = new clType(oBindingInfo.formatOptions, oBindingInfo.constraints);
709
+ }
710
+ oBinding = new CompositeBinding(aBindings, oBindingInfo.useRawValues, oBindingInfo.useInternalValues);
711
+ oBinding.setType(oType, oBindingInfo.targetType || sInternalType);
712
+ oBinding.setBindingMode(oBindingInfo.mode || sCompositeMode);
713
+ } else {
714
+ oBinding = aBindings[0];
715
+ }
716
+
717
+ oBinding.attachChange(fnModelChangeHandler);
718
+ if (this.refreshDataState) {
719
+ oBinding.attachAggregatedDataStateChange(fnDataStateChangeHandler);
720
+ }
721
+
722
+ // set only one formatter function if any
723
+ // because the formatter gets the context of the element, we have to set the context via proxy to ensure compatibility
724
+ // for formatter function which is now called by the property binding
725
+ // proxy formatter here because "this" is the correct cloned object
726
+ if (typeof oBindingInfo.formatter === "function") {
727
+ oBinding.setFormatter(oBindingInfo.formatter.bind(this));
728
+ }
729
+
730
+ // Set additional information on the binding info
731
+ oBindingInfo.binding = oBinding;
732
+ oBindingInfo.modelChangeHandler = fnModelChangeHandler;
733
+ oBindingInfo.dataStateChangeHandler = fnDataStateChangeHandler;
734
+ oBinding.attachEvents(oBindingInfo.events);
735
+
736
+ oBinding.initialize();
737
+
738
+ if (this._observer) {
739
+ this._observer.bindingChange(this, sName, "ready", oBindingInfo, "property");
740
+ }
741
+ },
742
+
743
+ _unbindProperty: function(oBindingInfo, sName){
744
+ var oBinding;
745
+
746
+ oBinding = oBindingInfo.binding;
747
+ if (oBinding) {
748
+ if (!this._bIsBeingDestroyed) {
749
+ this._detachPropertyBindingHandlers(sName);
750
+ }
751
+ oBinding.destroy();
752
+ /* to reset messages on a control we need to detach the datastate handler after destroy,
753
+ as binding destroy clears up validation messages */
754
+ if (this.refreshDataState && !this._bIsBeingDestroyed) {
755
+ oBinding.detachAggregatedDataStateChange(oBindingInfo.dataStateChangeHandler);
756
+ }
757
+ }
758
+ },
759
+
760
+ _detachPropertyBindingHandlers: function(sName) {
761
+ var oBindingInfo = this.mBindingInfos[sName],
762
+ oBinding;
763
+ if (oBindingInfo) {
764
+ oBinding = oBindingInfo.binding;
765
+ if (oBinding) {
766
+ oBinding.detachChange(oBindingInfo.modelChangeHandler);
767
+ oBinding.detachEvents(oBindingInfo.events);
768
+ /* to reset messages on a control we need to detach the datastate handler after destroy,
769
+ as binding destroy clears up validation messages */
770
+ if (this.refreshDataState && this._bIsBeingDestroyed) {
771
+ oBinding.detachAggregatedDataStateChange(oBindingInfo.dataStateChangeHandler);
772
+ }
773
+ }
774
+ }
775
+ },
776
+
777
+ /*
778
+ * Aggregation Binding
779
+ */
780
+ _bindAggregation: function(sName, oBindingInfo) {
781
+ var that = this,
782
+ oBinding,
783
+ oAggregationInfo = this.getMetadata().getAggregation(sName),
784
+ fnModelChangeHandler = function(oEvent){
785
+ var sOldOwnerId = ManagedObject._sOwnerId;
786
+ try {
787
+ ManagedObject._sOwnerId = that._sOwnerId;
788
+ oAggregationInfo.update(that, oEvent.getParameter("reason"), {
789
+ detailedReason: oEvent.getParameter("detailedReason")
790
+ });
791
+ } finally {
792
+ ManagedObject._sOwnerId = sOldOwnerId;
793
+ }
794
+ },
795
+ fnModelRefreshHandler = function(oEvent){
796
+ oAggregationInfo.refresh(that, oEvent.getParameter("reason"));
797
+ },
798
+ fnDataStateChangeHandler = function(oEvent) {
799
+ var oDataState = oBinding.getDataState();
800
+ if (!oDataState) {
801
+ return;
802
+ }
803
+ //inform generic refreshDataState method
804
+ if (that.refreshDataState) {
805
+ that.refreshDataState(sName, oDataState);
806
+ }
807
+ };
808
+
809
+ var oModel = this.getModel(oBindingInfo.model);
810
+ if (this.isTreeBinding(sName)) {
811
+ oBinding = oModel.bindTree(oBindingInfo.path, this.getBindingContext(oBindingInfo.model), oBindingInfo.filters, oBindingInfo.parameters, oBindingInfo.sorter);
812
+ } else {
813
+ oBinding = oModel.bindList(oBindingInfo.path, this.getBindingContext(oBindingInfo.model), oBindingInfo.sorter, oBindingInfo.filters, oBindingInfo.parameters);
814
+ if (this.bUseExtendedChangeDetection) {
815
+ assert(!this.oExtendedChangeDetectionConfig || !this.oExtendedChangeDetectionConfig.symbol, "symbol function must not be set by controls");
816
+ oBinding.enableExtendedChangeDetection(!oBindingInfo.template, oBindingInfo.key, this.oExtendedChangeDetectionConfig);
817
+ }
818
+ }
819
+
820
+ if (oBindingInfo.suspended) {
821
+ oBinding.suspend(true);
822
+ }
823
+
824
+ oBindingInfo.binding = oBinding;
825
+ oBindingInfo.modelChangeHandler = fnModelChangeHandler;
826
+ oBindingInfo.modelRefreshHandler = fnModelRefreshHandler;
827
+ oBindingInfo.dataStateChangeHandler = fnDataStateChangeHandler;
828
+
829
+ oBinding.attachChange(fnModelChangeHandler);
830
+
831
+ oBinding.attachRefresh(fnModelRefreshHandler);
832
+
833
+ oBinding.attachEvents(oBindingInfo.events);
834
+
835
+ if (this.refreshDataState) {
836
+ oBinding.attachAggregatedDataStateChange(fnDataStateChangeHandler);
837
+ }
838
+
839
+ oBinding.initialize();
840
+
841
+ if (this._observer) {
842
+ this._observer.bindingChange(this, sName, "ready", oBindingInfo, "aggregation");
843
+ }
844
+ },
845
+
846
+ _unbindAggregation: function(oBindingInfo, sName){
847
+ if (oBindingInfo.binding) {
848
+ if (!this._bIsBeingDestroyed) {
849
+ this._detachAggregationBindingHandlers(sName);
850
+ }
851
+ oBindingInfo.binding.destroy();
852
+ }
853
+ },
854
+
855
+ _detachAggregationBindingHandlers: function(sName) {
856
+ var oBindingInfo = this.mBindingInfos[sName];
857
+ if (oBindingInfo) {
858
+ if (oBindingInfo.binding) {
859
+ oBindingInfo.binding.detachChange(oBindingInfo.modelChangeHandler);
860
+ oBindingInfo.binding.detachRefresh(oBindingInfo.modelRefreshHandler);
861
+ oBindingInfo.binding.detachEvents(oBindingInfo.events);
862
+ if (this.refreshDataState) {
863
+ oBindingInfo.binding.detachAggregatedDataStateChange(oBindingInfo.dataStateChangeHandler);
864
+ }
865
+ }
866
+ }
867
+ }
868
+ };
869
+
870
+ return ManagedObjectBindingSupport;
871
+ });