Guest User

Untitled

a guest
May 25th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. qx.Class.define("playground.ArrayStore",
  2. {
  3. extend : qx.core.Object,
  4.  
  5.  
  6. /**
  7. * @param delegate {Object?} The delegate containing one of the methods
  8. * specified in {@link qx.data.store.IStoreDelegate}.
  9. */
  10. construct : function(delegate)
  11. {
  12. this.base(arguments);
  13.  
  14.  
  15. // store the marshaler and the delegate
  16. this._marshaler = new qx.data.marshal.Json(delegate);
  17. this._delegate = delegate;
  18. },
  19.  
  20.  
  21. events :
  22. {
  23. /**
  24. * Data event fired after the model has been created. The data will be the
  25. * created model.
  26. */
  27. "loaded": "qx.event.type.Data"
  28. },
  29.  
  30.  
  31. properties :
  32. {
  33. /**
  34. * Property for holding the loaded model instance.
  35. */
  36. model : {
  37. nullable: true,
  38. event: "changeModel"
  39. },
  40.  
  41.  
  42. /**
  43. * The state of the request as an url. If you want to check if the request
  44. * did his job, use, the {@link #changeState} event and check for one of the
  45. * listed values.
  46. */
  47. state : {
  48. check : [
  49. "configured", "completed"
  50. ],
  51. init : "configured",
  52. event : "changeState"
  53. }
  54. },
  55.  
  56.  
  57. members :
  58. {
  59. // private members
  60. __request : null,
  61. _delegate : null,
  62.  
  63.  
  64.  
  65. setData : function(data)
  66. {
  67. // check for the data manipulation hook
  68. var del = this._delegate;
  69. if (del && qx.lang.Type.isFunction(del.manipulateData)) {
  70. data = this._delegate.manipulateData(data);
  71. }
  72.  
  73. // create the class
  74. this._marshaler.toClass(data, true);
  75. // set the initial data
  76. this.setModel(this._marshaler.toModel(data));
  77.  
  78. // fire complete event
  79. this.fireDataEvent("loaded", this.getModel());
  80. },
  81.  
  82. getData: function()
  83. {
  84. return this.getModel();
  85. }
  86. },
  87.  
  88. /*
  89. *****************************************************************************
  90. DESTRUCT
  91. *****************************************************************************
  92. */
  93.  
  94. destruct : function()
  95. {
  96. this._disposeObjects("_marshaler");
  97. this._delegate = null;
  98. }
  99. });
Add Comment
Please, Sign In to add comment