Guest User

Untitled

a guest
May 25th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. package com.app.screen
  2. {
  3. import com.app.utils.ComponentSerializer;
  4. import com.fake.utils.DescribeUtil;
  5.  
  6. import mx.containers.Canvas;
  7. import mx.events.FlexEvent;
  8. import mx.validators.*;
  9.  
  10. [Bindable]
  11. public class ScreenComponentCtrl extends Canvas
  12. {
  13. /**
  14. * Label of the ScreenComponent to move to when the next button is clicked.
  15. */
  16. public var nextScreen:String;
  17.  
  18. /**
  19. * Label of the ScreenComponent to move to when the summary button is clicked.
  20. */
  21. public var summaryScreen:String;
  22.  
  23. /**
  24. * Indicates whether or not an action has taken place to make this visible in the summary
  25. */
  26. public var active:Boolean;
  27.  
  28. public function ScreenComponentCtrl()
  29. {
  30. super();
  31.  
  32. addEventListener(FlexEvent.CREATION_COMPLETE, init);
  33. }
  34.  
  35. /**
  36. * Event handler for CREATION_COMPLETE.
  37. * Abstract function.
  38. */
  39. public function init(event:FlexEvent):void { }
  40.  
  41. /**
  42. * Called after the current label property of the ScreenContainer
  43. * has changed. This Screen is the current screen at this point.
  44. * Abstract function.
  45. */
  46. public function onScreenEnter(isNext:Boolean = true):void { }
  47.  
  48. /**
  49. * Called after the next or summary button has been clicked and before the current
  50. * screen changes. The container uses the nextScreen or summaryScreen to change screens.
  51. * If the boolean returned is false the next action will be canceled
  52. * Abstract function.
  53. */
  54. /* public function onNextClick():Boolean { return true; } */
  55.  
  56. public function onNextClick():void {}
  57.  
  58. /**
  59. * Called after the back button has been clicked and before the current
  60. * screen changes. The container calls an undo on the currentScreenLabel property.
  61. * Abstract function.
  62. */
  63. public function onBackClick():void { }
  64.  
  65. /**
  66. * Clears all values and selections from the UIComponents. It also clears the
  67. * related values in the data store.
  68. * Abstract function.
  69. */
  70. public function onClear():void { }
  71.  
  72. /**
  73. * Applies all values from the data store to the UIComponents.
  74. */
  75. public function deserialize():void
  76. {
  77. ScreenContainerCtrl.instance.load();
  78.  
  79. var node:XMLList = dataStore.child(DescribeUtil.localName(this));
  80.  
  81. if(node)
  82. ComponentSerializer.instance.deserialize(this, ScreenContainerCtrl.instance.dataStore.child(DescribeUtil.localName(this)));
  83. }
  84.  
  85. /**
  86. * Converts all of the values from inputs into XML.
  87. */
  88. public function serialize():void
  89. {
  90. var node:XML = ComponentSerializer.instance.serialize(this);
  91. var child:XMLList = ScreenContainerCtrl.instance.dataStore.child(node.localName());
  92.  
  93. if(child.length() > 0)
  94. {
  95. ScreenContainerCtrl.instance.dataStore.replace(node.localName(), node);
  96. }
  97. else
  98. {
  99. ScreenContainerCtrl.instance.dataStore.appendChild(node);
  100. }
  101.  
  102. ScreenContainerCtrl.instance.save();
  103. }
  104.  
  105. public function validate():String { return "" }
  106.  
  107. public function get dataStore():XML {
  108. return ScreenContainerCtrl.instance.dataStore;
  109. }
  110.  
  111. public function get co2PerYear():Number { return 0 }
  112. }
  113. }
Add Comment
Please, Sign In to add comment