FlowMenu.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * This notice must be untouched at all times. This is the COMPRESSED version of
  3. * Draw2D WebSite: http://www.draw2d.org Copyright: 2006 Andreas Herz. All
  4. * rights reserved. Created: 5.11.2006 by Andreas Herz (Web:
  5. * http://www.freegroup.de ) LICENSE: LGPL
  6. */
  7. draw2d.FlowMenu = function(_20d3) {
  8. this.actionDelete = new draw2d.ButtonDelete(this);
  9. // this.actionFront = new draw2d.ButtonMoveFront(this);
  10. // this.actionBack = new draw2d.ButtonMoveBack(this);
  11. draw2d.ToolPalette.call(this);
  12. this.setDimension(20, 60);
  13. this.setBackgroundColor(new draw2d.Color(220, 255, 255));
  14. this.currentFigure = null;
  15. this.myworkflow = _20d3;
  16. this.added = false;
  17. this.setDeleteable(false);
  18. this.setCanDrag(false);
  19. this.setResizeable(false);
  20. this.setSelectable(false);
  21. this.setBackgroundColor(null);
  22. this.setColor(null);
  23. this.scrollarea.style.borderBottom = "0px";
  24. this.actionDelete.setPosition(0, 0);
  25. // this.actionFront.setPosition(0, 18);
  26. // this.actionBack.setPosition(0, 36);
  27. this.addChild(this.actionDelete);
  28. // this.addChild(this.actionFront);
  29. // this.addChild(this.actionBack);
  30. };
  31. draw2d.FlowMenu.prototype = new draw2d.ToolPalette;
  32. draw2d.FlowMenu.prototype.setAlpha = function(_20d4) {
  33. draw2d.Figure.prototype.setAlpha.call(this, _20d4);
  34. };
  35. draw2d.FlowMenu.prototype.hasTitleBar = function() {
  36. return false;
  37. };
  38. draw2d.FlowMenu.prototype.onSelectionChanged = function(_20d5) {
  39. if (_20d5 == this.currentFigure) {
  40. return;
  41. }
  42. if (this.added == true) {
  43. this.myworkflow.removeFigure(this);
  44. this.added = false;
  45. }
  46. if (_20d5 != null && this.added == false) {
  47. if (this.myworkflow.getEnableSmoothFigureHandling() == true) {
  48. this.setAlpha(0.01);
  49. }
  50. this.myworkflow.addFigure(this, 100, 100);
  51. this.added = true;
  52. }
  53. if (this.currentFigure != null) {
  54. this.currentFigure.detachMoveListener(this);
  55. }
  56. this.currentFigure = _20d5;
  57. if (this.currentFigure != null) {
  58. this.currentFigure.attachMoveListener(this);
  59. this.onOtherFigureMoved(this.currentFigure);
  60. }
  61. };
  62. draw2d.FlowMenu.prototype.setWorkflow = function(_20d6) {
  63. draw2d.Figure.prototype.setWorkflow.call(this, _20d6);
  64. };
  65. draw2d.FlowMenu.prototype.onOtherFigureMoved = function(_20d7) {
  66. try {
  67. var pos = _20d7.getPosition();
  68. this.setPosition(pos.x + _20d7.getWidth(), pos.y);
  69. } catch (e) {
  70. if (_20d7.startX && _20d7.endX) {
  71. var points = _20d7.getPoints();
  72. var startX = points.get(points.size - 2).x;
  73. var startY = points.get(points.size - 2).y;
  74. var endX = points.get(points.size - 1).x;
  75. var endY = points.get(points.size - 1).y;
  76. var poX = _20d7.endX;
  77. var poY = _20d7.endY;
  78. if (startX == endX) {
  79. poX = startX - 30;
  80. poY = (Math.abs(endY - startY) / 2 + Math.min(startY, endY))
  81. - 20;
  82. } else if (startY == endY) {
  83. poX = Math.abs(endX - startX) / 2 + Math.min(startX, endX) - 30;
  84. poY = startY - 20;
  85. } else {
  86. poX = Math.abs(endX - startX) / 2 + Math.min(startX, endX) - 30;
  87. poY = Math.abs(endY - startY) / 2 + Math.min(startY, endY) - 20;
  88. }
  89. this.setPosition(poX, poY);
  90. }
  91. }
  92. };