Link.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. MWF.xApplication.ScriptEditor.statement = MWF.xApplication.ScriptEditor.statement || {};
  2. MWF.xApplication.ScriptEditor.statement.Link = new Class({
  3. initialize: function(statement, type, node){
  4. this.statement = statement;
  5. this.type = type;
  6. this.node = node;
  7. this.area = this.statement.area;
  8. this.block = this.statement.block;
  9. this.editor = this.statement.editor;
  10. this.rePosition();
  11. this.linkStatement = null;
  12. this.toLink = null;
  13. if (this.type==="up"){
  14. this.linkType = "up";
  15. this.around = false;
  16. }
  17. if (this.type==="middle"){
  18. this.linkType = "down";
  19. this.around = true;
  20. }
  21. if (this.type==="down"){
  22. this.linkType = "down";
  23. this.around = false;
  24. }
  25. this.load();
  26. },
  27. load :function(){
  28. },
  29. rePosition: function(){
  30. this.position = this.node.getPosition(this.statement.areaNode);
  31. return this;
  32. },
  33. linkDown: function(link){
  34. var oldLink = this.toLink;
  35. if (link.toLink){
  36. link.toLink.toLink = null;
  37. link.toLink = null;
  38. }
  39. this.toLink = link;
  40. link.toLink = this;
  41. if (oldLink && oldLink!==link){
  42. if (link.statement.centerLink && !link.statement.centerLink.toLink){
  43. link.statement.centerLink.toLink = oldLink;
  44. var group = this.area.getStatementGroup(oldLink.statement);
  45. link.statement.centerLink.endStatement = group[group.length-1];
  46. oldLink.toLink = link.statement.centerLink;
  47. }else{
  48. var linkGroup = this.area.getStatementGroup(link.statement);
  49. var statement = linkGroup[linkGroup.length-1];
  50. oldLink.toLink = statement.bottomLink;
  51. statement.bottomLink.toLink = oldLink;
  52. }
  53. }
  54. },
  55. linkUp: function(link){
  56. this.toLink = link;
  57. link.toLink = link;
  58. },
  59. linkMiddle: function(link){
  60. var oldLink = this.toLink;
  61. if (link.toLink){
  62. link.toLink.toLink = null;
  63. link.toLink = null;
  64. }
  65. this.toLink = link;
  66. link.toLink = this;
  67. if (oldLink && oldLink!==link){
  68. if (link.statement.centerLink && !link.statement.centerLink.toLink){
  69. link.statement.centerLink.toLink = oldLink;
  70. var group = this.area.getStatementGroup(oldLink.statement);
  71. link.statement.centerLink.endStatement = group[group.length-1];
  72. oldLink.toLink = link.statement.centerLink;
  73. }else{
  74. var linkGroup = this.area.getStatementGroup(link.statement);
  75. var statement = linkGroup[linkGroup.length-1];
  76. oldLink.toLink = statement.bottomLink;
  77. statement.bottomLink.toLink = oldLink;
  78. }
  79. }else{
  80. this.endStatement = link.statement;
  81. }
  82. },
  83. linkUpAround: function(link){
  84. this.toLink = link;
  85. link.toLink = link;
  86. var group = this.area.getStatementGroup(this.statement);
  87. link.endStatement = group[group.length-1];
  88. },
  89. // link: function(link){
  90. // if (this.type==="up"){
  91. // this.toLink = link;
  92. // link.toLink = this;
  93. // }
  94. // if (this.type==="down"){
  95. // var oldLink = this.toLink;
  96. // this.toLink = link;
  97. // link.toLink = this;
  98. //
  99. // if (link.statement.centerLink){
  100. // oldLink.toLink = link.statement.centerLink;
  101. // link.statement.bottomLink.toLink = oldLink;
  102. //
  103. // }else{
  104. // oldLink.toLink = link.statement.bottomLink;
  105. // link.statement.bottomLink.toLink = oldLink;
  106. // }
  107. // }
  108. // if (this.type==="middle"){
  109. // var oldLink = this.toLink;
  110. // this.toLink = link;
  111. // link.toLink = this;
  112. //
  113. // if (link)
  114. //
  115. // var group = this.area.getStatementGroup(oldLink.statement);
  116. //
  117. // }
  118. //
  119. //
  120. //
  121. // if (!this.toLink){
  122. // this.toLink = link;
  123. // }else {
  124. // var oldToLink = this.toLink;
  125. // this.toLink = link;
  126. // if (this.linkType==="up" && link.linkType==="down"){
  127. //
  128. // }
  129. //
  130. // if (this.linkType==="down" && link.linkType==="up"){
  131. //
  132. // }
  133. // }
  134. // },
  135. getSerialLinkGroup: function(link){
  136. link.statement.bottomLink
  137. }
  138. });