jruby_activiti 1.2.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (317) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG +6 -0
  5. data/Jarfile +5 -0
  6. data/Jarfile.lock +52 -13
  7. data/README.md +21 -9
  8. data/java/build.md +3 -0
  9. data/java/mapping.md +20 -0
  10. data/java/pom.xml +30 -0
  11. data/java/src/main/java/jrubyactiviti/Modeler.java +95 -0
  12. data/java/src/main/java/jrubyactiviti/ProcessDiagram.java +491 -0
  13. data/java/src/main/java/jrubyactiviti/ProcessInstanceHighlights.java +237 -0
  14. data/java/src/main/java/jrubyactiviti/StencilsetResource.java +16 -0
  15. data/java/src/main/resources/stencilset.json +1339 -0
  16. data/jruby_activiti.gemspec +3 -2
  17. data/lib/generators/jruby_activiti/install_generator.rb +4 -0
  18. data/lib/jar/jrubyactiviti-2.0.jar +0 -0
  19. data/lib/jruby_activiti/version.rb +1 -1
  20. data/lib/jruby_activiti/web.rb +81 -0
  21. data/lib/jruby_activiti.rb +28 -20
  22. data/test/{base_test.rb → activiti_test.rb} +1 -3
  23. data/test/instance_hights_test.rb +18 -0
  24. data/test/modeler_test.rb +35 -0
  25. data/test/process_diagram_test.rb +33 -0
  26. data/test/resources/model_init_editor_source.json +1 -0
  27. data/test/resources/model_json_xml.json +278 -0
  28. data/test/resources/model_svg_xml.xml +66 -0
  29. data/test/stencilset_test.rb +7 -0
  30. data/test/test_helper.rb +2 -0
  31. data/web/public/diagram-viewer/images/bg.png +0 -0
  32. data/web/public/diagram-viewer/images/breadcrumbs.png +0 -0
  33. data/web/public/diagram-viewer/images/checker-bg.png +0 -0
  34. data/web/public/diagram-viewer/images/deployer/blue/message_catch.png +0 -0
  35. data/web/public/diagram-viewer/images/deployer/business_rule.png +0 -0
  36. data/web/public/diagram-viewer/images/deployer/error_catch.png +0 -0
  37. data/web/public/diagram-viewer/images/deployer/error_throw.png +0 -0
  38. data/web/public/diagram-viewer/images/deployer/manual.png +0 -0
  39. data/web/public/diagram-viewer/images/deployer/message_catch.png +0 -0
  40. data/web/public/diagram-viewer/images/deployer/message_throw.png +0 -0
  41. data/web/public/diagram-viewer/images/deployer/receive.png +0 -0
  42. data/web/public/diagram-viewer/images/deployer/script.png +0 -0
  43. data/web/public/diagram-viewer/images/deployer/send.png +0 -0
  44. data/web/public/diagram-viewer/images/deployer/service.png +0 -0
  45. data/web/public/diagram-viewer/images/deployer/signal_catch.png +0 -0
  46. data/web/public/diagram-viewer/images/deployer/signal_throw.png +0 -0
  47. data/web/public/diagram-viewer/images/deployer/timer.png +0 -0
  48. data/web/public/diagram-viewer/images/deployer/user.png +0 -0
  49. data/web/public/diagram-viewer/index.html +130 -0
  50. data/web/public/diagram-viewer/js/ActivitiRest.js +74 -0
  51. data/web/public/diagram-viewer/js/ActivityImpl.js +1 -0
  52. data/web/public/diagram-viewer/js/Color.js +603 -0
  53. data/web/public/diagram-viewer/js/LineBreakMeasurer.js +270 -0
  54. data/web/public/diagram-viewer/js/Polyline.js +387 -0
  55. data/web/public/diagram-viewer/js/ProcessDiagramCanvas.js +2172 -0
  56. data/web/public/diagram-viewer/js/ProcessDiagramGenerator.js +1087 -0
  57. data/web/public/diagram-viewer/js/jquery/jquery.asyncqueue.js +125 -0
  58. data/web/public/diagram-viewer/js/jquery/jquery.js +9266 -0
  59. data/web/public/diagram-viewer/js/jquery/jquery.progressbar.js +131 -0
  60. data/web/public/diagram-viewer/js/jstools.js +23 -0
  61. data/web/public/diagram-viewer/js/raphael.2.1.1.js +10 -0
  62. data/web/public/diagram-viewer/js/raphael.js +10 -0
  63. data/web/public/diagram-viewer/js/raphael_uncompressed.js +5815 -0
  64. data/web/public/diagram-viewer/js/textlayout.js +441 -0
  65. data/web/public/diagram-viewer/style.css +1 -0
  66. data/web/public/editor-app/app-cfg.js +25 -0
  67. data/web/public/editor-app/app.js +432 -0
  68. data/web/public/editor-app/configuration/properties/assignment-display-template.html +4 -0
  69. data/web/public/editor-app/configuration/properties/assignment-popup.html +44 -0
  70. data/web/public/editor-app/configuration/properties/assignment-write-template.html +4 -0
  71. data/web/public/editor-app/configuration/properties/boolean-property-template.html +4 -0
  72. data/web/public/editor-app/configuration/properties/condition-expression-display-template.html +2 -0
  73. data/web/public/editor-app/configuration/properties/condition-expression-popup.html +29 -0
  74. data/web/public/editor-app/configuration/properties/condition-expression-write-template.html +4 -0
  75. data/web/public/editor-app/configuration/properties/default-value-display-template.html +4 -0
  76. data/web/public/editor-app/configuration/properties/event-listeners-display-template.html +3 -0
  77. data/web/public/editor-app/configuration/properties/event-listeners-popup.html +115 -0
  78. data/web/public/editor-app/configuration/properties/event-listeners-write-template.html +4 -0
  79. data/web/public/editor-app/configuration/properties/execution-listeners-display-template.html +3 -0
  80. data/web/public/editor-app/configuration/properties/execution-listeners-popup.html +101 -0
  81. data/web/public/editor-app/configuration/properties/execution-listeners-write-template.html +4 -0
  82. data/web/public/editor-app/configuration/properties/feedback-popup.html +17 -0
  83. data/web/public/editor-app/configuration/properties/fields-display-template.html +3 -0
  84. data/web/public/editor-app/configuration/properties/fields-popup.html +61 -0
  85. data/web/public/editor-app/configuration/properties/fields-write-template.html +4 -0
  86. data/web/public/editor-app/configuration/properties/form-properties-display-template.html +3 -0
  87. data/web/public/editor-app/configuration/properties/form-properties-popup.html +93 -0
  88. data/web/public/editor-app/configuration/properties/form-properties-write-template.html +4 -0
  89. data/web/public/editor-app/configuration/properties/in-parameters-display-template.html +3 -0
  90. data/web/public/editor-app/configuration/properties/in-parameters-popup.html +53 -0
  91. data/web/public/editor-app/configuration/properties/in-parameters-write-template.html +4 -0
  92. data/web/public/editor-app/configuration/properties/message-definitions-display-template.html +2 -0
  93. data/web/public/editor-app/configuration/properties/message-definitions-popup.html +50 -0
  94. data/web/public/editor-app/configuration/properties/message-definitions-write-template.html +3 -0
  95. data/web/public/editor-app/configuration/properties/message-property-write-template.html +4 -0
  96. data/web/public/editor-app/configuration/properties/multiinstance-property-write-template.html +8 -0
  97. data/web/public/editor-app/configuration/properties/out-parameters-display-template.html +3 -0
  98. data/web/public/editor-app/configuration/properties/out-parameters-popup.html +53 -0
  99. data/web/public/editor-app/configuration/properties/out-parameters-write-template.html +4 -0
  100. data/web/public/editor-app/configuration/properties/sequenceflow-order-display-template.html +3 -0
  101. data/web/public/editor-app/configuration/properties/sequenceflow-order-popup.html +47 -0
  102. data/web/public/editor-app/configuration/properties/sequenceflow-order-write-template.html +4 -0
  103. data/web/public/editor-app/configuration/properties/signal-definitions-display-template.html +3 -0
  104. data/web/public/editor-app/configuration/properties/signal-definitions-popup.html +58 -0
  105. data/web/public/editor-app/configuration/properties/signal-definitions-write-template.html +4 -0
  106. data/web/public/editor-app/configuration/properties/signal-property-write-template.html +4 -0
  107. data/web/public/editor-app/configuration/properties/string-property-write-mode-template.html +8 -0
  108. data/web/public/editor-app/configuration/properties/subprocess-reference-display-template.html +3 -0
  109. data/web/public/editor-app/configuration/properties/subprocess-reference-popup.html +43 -0
  110. data/web/public/editor-app/configuration/properties/subprocess-reference-write-template.html +4 -0
  111. data/web/public/editor-app/configuration/properties/task-listeners-display-template.html +3 -0
  112. data/web/public/editor-app/configuration/properties/task-listeners-popup.html +102 -0
  113. data/web/public/editor-app/configuration/properties/task-listeners-write-template.html +4 -0
  114. data/web/public/editor-app/configuration/properties/text-popup.html +17 -0
  115. data/web/public/editor-app/configuration/properties/text-property-write-template.html +4 -0
  116. data/web/public/editor-app/configuration/properties-assignment-controller.js +150 -0
  117. data/web/public/editor-app/configuration/properties-condition-expression-controller.js +58 -0
  118. data/web/public/editor-app/configuration/properties-custom-controllers.js +18 -0
  119. data/web/public/editor-app/configuration/properties-default-controllers.js +115 -0
  120. data/web/public/editor-app/configuration/properties-event-listeners-controller.js +266 -0
  121. data/web/public/editor-app/configuration/properties-execution-listeners-controller.js +326 -0
  122. data/web/public/editor-app/configuration/properties-fields-controller.js +192 -0
  123. data/web/public/editor-app/configuration/properties-form-properties-controller.js +192 -0
  124. data/web/public/editor-app/configuration/properties-in-parameters-controller.js +158 -0
  125. data/web/public/editor-app/configuration/properties-message-definitions-controller.js +137 -0
  126. data/web/public/editor-app/configuration/properties-message-scope-controller.js +48 -0
  127. data/web/public/editor-app/configuration/properties-multiinstance-controller.js +34 -0
  128. data/web/public/editor-app/configuration/properties-out-parameters-controller.js +158 -0
  129. data/web/public/editor-app/configuration/properties-sequenceflow-order-controller.js +130 -0
  130. data/web/public/editor-app/configuration/properties-signal-definitions-controller.js +136 -0
  131. data/web/public/editor-app/configuration/properties-signal-scope-controller.js +47 -0
  132. data/web/public/editor-app/configuration/properties-task-listeners-controller.js +325 -0
  133. data/web/public/editor-app/configuration/properties.js +99 -0
  134. data/web/public/editor-app/configuration/toolbar-custom-actions.js +18 -0
  135. data/web/public/editor-app/configuration/toolbar-default-actions.js +429 -0
  136. data/web/public/editor-app/configuration/toolbar.js +175 -0
  137. data/web/public/editor-app/configuration/url-config.js +34 -0
  138. data/web/public/editor-app/css/style-common.css +1518 -0
  139. data/web/public/editor-app/css/style-editor.css +639 -0
  140. data/web/public/editor-app/css/style.css +471 -0
  141. data/web/public/editor-app/editor/css/editor.css +202 -0
  142. data/web/public/editor-app/editor/i18n/translation_de.js +383 -0
  143. data/web/public/editor-app/editor/i18n/translation_en_us.js +423 -0
  144. data/web/public/editor-app/editor/i18n/translation_signavio_de.js +106 -0
  145. data/web/public/editor-app/editor/i18n/translation_signavio_en_us.js +108 -0
  146. data/web/public/editor-app/editor/oryx.debug.js +24510 -0
  147. data/web/public/editor-app/editor/oryx.js +30 -0
  148. data/web/public/editor-app/editor-config.js +32 -0
  149. data/web/public/editor-app/editor-controller.js +65 -0
  150. data/web/public/editor-app/editor-utils.js +135 -0
  151. data/web/public/editor-app/editor.html +136 -0
  152. data/web/public/editor-app/eventbus.js +133 -0
  153. data/web/public/editor-app/fonts/activiti-admin-webfont.eot +0 -0
  154. data/web/public/editor-app/fonts/activiti-admin-webfont.svg +43 -0
  155. data/web/public/editor-app/fonts/activiti-admin-webfont.ttf +0 -0
  156. data/web/public/editor-app/fonts/activiti-admin-webfont.woff +0 -0
  157. data/web/public/editor-app/fonts/glyphicons-halflings-regular.eot +0 -0
  158. data/web/public/editor-app/fonts/glyphicons-halflings-regular.svg +229 -0
  159. data/web/public/editor-app/fonts/glyphicons-halflings-regular.ttf +0 -0
  160. data/web/public/editor-app/fonts/glyphicons-halflings-regular.woff +0 -0
  161. data/web/public/editor-app/header-controller.js +31 -0
  162. data/web/public/editor-app/i18n/en.json +286 -0
  163. data/web/public/editor-app/images/bpmn-error.png +0 -0
  164. data/web/public/editor-app/images/bpmn-warning.png +0 -0
  165. data/web/public/editor-app/images/datadefinition.png +0 -0
  166. data/web/public/editor-app/images/delete.png +0 -0
  167. data/web/public/editor-app/images/loading.gif +0 -0
  168. data/web/public/editor-app/images/logo-2x.png +0 -0
  169. data/web/public/editor-app/images/logo.png +0 -0
  170. data/web/public/editor-app/images/nw-handle-dark.gif +0 -0
  171. data/web/public/editor-app/images/se-handle-dark.gif +0 -0
  172. data/web/public/editor-app/images/shapemenu_highlight.png +0 -0
  173. data/web/public/editor-app/images/wrench.png +0 -0
  174. data/web/public/editor-app/libs/angular-cookies_1.2.13/angular-cookies.min.js +8 -0
  175. data/web/public/editor-app/libs/angular-cookies_1.2.13/angular-cookies.min.js.map +8 -0
  176. data/web/public/editor-app/libs/angular-dragdrop.min-1.0.3.js +9 -0
  177. data/web/public/editor-app/libs/angular-dragdrop_1.0.7/angular-dragdrop.min.js +29 -0
  178. data/web/public/editor-app/libs/angular-mocks_1.2.13/angular-mocks.js +2136 -0
  179. data/web/public/editor-app/libs/angular-resource_1.2.13/angular-resource.js +596 -0
  180. data/web/public/editor-app/libs/angular-resource_1.2.13/angular-resource.min.js +13 -0
  181. data/web/public/editor-app/libs/angular-resource_1.2.13/angular-resource.min.js.map +8 -0
  182. data/web/public/editor-app/libs/angular-route_1.2.13/angular-route.js +921 -0
  183. data/web/public/editor-app/libs/angular-route_1.2.13/angular-route.min.js +14 -0
  184. data/web/public/editor-app/libs/angular-route_1.2.13/angular-route.min.js.map +8 -0
  185. data/web/public/editor-app/libs/angular-sanitize_1.2.13/angular-sanitize.js +625 -0
  186. data/web/public/editor-app/libs/angular-sanitize_1.2.13/angular-sanitize.min.js +14 -0
  187. data/web/public/editor-app/libs/angular-sanitize_1.2.13/angular-sanitize.min.js.map +8 -0
  188. data/web/public/editor-app/libs/angular-scroll_0.5.7/angular-scroll.min.js +1 -0
  189. data/web/public/editor-app/libs/angular-strap_2.0.5/angular-strap.min.js +9 -0
  190. data/web/public/editor-app/libs/angular-strap_2.0.5/angular-strap.tpl.min.js +8 -0
  191. data/web/public/editor-app/libs/angular-translate-loader-static-files/.bower.json +19 -0
  192. data/web/public/editor-app/libs/angular-translate-loader-static-files/angular-translate-loader-static-files.js +31 -0
  193. data/web/public/editor-app/libs/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js +6 -0
  194. data/web/public/editor-app/libs/angular-translate-storage-cookie/.bower.json +20 -0
  195. data/web/public/editor-app/libs/angular-translate-storage-cookie/angular-translate-storage-cookie.js +19 -0
  196. data/web/public/editor-app/libs/angular-translate-storage-cookie/angular-translate-storage-cookie.min.js +6 -0
  197. data/web/public/editor-app/libs/angular-translate_2.4.2/angular-translate.js +960 -0
  198. data/web/public/editor-app/libs/angular-translate_2.4.2/angular-translate.min.js +6 -0
  199. data/web/public/editor-app/libs/angular_1.2.13/angular-animate.min.js +27 -0
  200. data/web/public/editor-app/libs/angular_1.2.13/angular.min.js +204 -0
  201. data/web/public/editor-app/libs/bootstrap-daterangepicker_1.3.7/daterangepicker-bs3.css +267 -0
  202. data/web/public/editor-app/libs/bootstrap-daterangepicker_1.3.7/daterangepicker.js +1026 -0
  203. data/web/public/editor-app/libs/bootstrap_3.1.1/css/bootstrap-theme.css +347 -0
  204. data/web/public/editor-app/libs/bootstrap_3.1.1/css/bootstrap-theme.css.map +1 -0
  205. data/web/public/editor-app/libs/bootstrap_3.1.1/css/bootstrap-theme.min.css +7 -0
  206. data/web/public/editor-app/libs/bootstrap_3.1.1/css/bootstrap.css +5785 -0
  207. data/web/public/editor-app/libs/bootstrap_3.1.1/css/bootstrap.css.map +1 -0
  208. data/web/public/editor-app/libs/bootstrap_3.1.1/css/bootstrap.min.css +7 -0
  209. data/web/public/editor-app/libs/bootstrap_3.1.1/fonts/glyphicons-halflings-regular.eot +0 -0
  210. data/web/public/editor-app/libs/bootstrap_3.1.1/fonts/glyphicons-halflings-regular.svg +229 -0
  211. data/web/public/editor-app/libs/bootstrap_3.1.1/fonts/glyphicons-halflings-regular.ttf +0 -0
  212. data/web/public/editor-app/libs/bootstrap_3.1.1/fonts/glyphicons-halflings-regular.woff +0 -0
  213. data/web/public/editor-app/libs/bootstrap_3.1.1/js/bootstrap.js +1951 -0
  214. data/web/public/editor-app/libs/bootstrap_3.1.1/js/bootstrap.min.js +6 -0
  215. data/web/public/editor-app/libs/es5-shim-15.3.4.5/.bower.json +14 -0
  216. data/web/public/editor-app/libs/es5-shim-15.3.4.5/.gitignore +2 -0
  217. data/web/public/editor-app/libs/es5-shim-15.3.4.5/CHANGES +93 -0
  218. data/web/public/editor-app/libs/es5-shim-15.3.4.5/CONTRIBUTORS.md +25 -0
  219. data/web/public/editor-app/libs/es5-shim-15.3.4.5/LICENSE +19 -0
  220. data/web/public/editor-app/libs/es5-shim-15.3.4.5/README.md +161 -0
  221. data/web/public/editor-app/libs/es5-shim-15.3.4.5/es5-sham.js +444 -0
  222. data/web/public/editor-app/libs/es5-shim-15.3.4.5/es5-sham.map +1 -0
  223. data/web/public/editor-app/libs/es5-shim-15.3.4.5/es5-sham.min.js +4 -0
  224. data/web/public/editor-app/libs/es5-shim-15.3.4.5/es5-shim.js +1314 -0
  225. data/web/public/editor-app/libs/es5-shim-15.3.4.5/es5-shim.map +1 -0
  226. data/web/public/editor-app/libs/es5-shim-15.3.4.5/es5-shim.min.js +4 -0
  227. data/web/public/editor-app/libs/es5-shim-15.3.4.5/package.json +34 -0
  228. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/helpers/h-kill.js +64 -0
  229. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/helpers/h-matchers.js +34 -0
  230. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/helpers/h.js +3 -0
  231. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/index.html +64 -0
  232. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/index.min.html +63 -0
  233. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/lib/jasmine-html.js +190 -0
  234. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/lib/jasmine.css +166 -0
  235. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/lib/jasmine.js +2477 -0
  236. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/lib/jasmine_favicon.png +0 -0
  237. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/lib/json2.js +478 -0
  238. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/spec/s-array.js +1223 -0
  239. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/spec/s-date.js +152 -0
  240. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/spec/s-function.js +147 -0
  241. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/spec/s-number.js +14 -0
  242. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/spec/s-object.js +181 -0
  243. data/web/public/editor-app/libs/es5-shim-15.3.4.5/tests/spec/s-string.js +204 -0
  244. data/web/public/editor-app/libs/jquery-ui-1.10.3.custom.min.js +6 -0
  245. data/web/public/editor-app/libs/jquery.autogrow-textarea.js +61 -0
  246. data/web/public/editor-app/libs/jquery_1.11.0/jquery.js +9789 -0
  247. data/web/public/editor-app/libs/jquery_1.11.0/jquery.min.js +4 -0
  248. data/web/public/editor-app/libs/jquery_1.11.0/jquery.min.map +1 -0
  249. data/web/public/editor-app/libs/json3_3.2.6/LICENSE +20 -0
  250. data/web/public/editor-app/libs/json3_3.2.6/lib/json3.js +861 -0
  251. data/web/public/editor-app/libs/json3_3.2.6/lib/json3.min.js +18 -0
  252. data/web/public/editor-app/libs/momentjs_2.5.1/momentjs.min.js +6 -0
  253. data/web/public/editor-app/libs/mousetrap-1.4.5.min.js +9 -0
  254. data/web/public/editor-app/libs/ng-grid-2.0.7-min.js +2 -0
  255. data/web/public/editor-app/libs/ng-grid-2.0.7.min.css +1 -0
  256. data/web/public/editor-app/libs/path_parser.js +30 -0
  257. data/web/public/editor-app/libs/prototype-1.5.1.js +3272 -0
  258. data/web/public/editor-app/libs/ui-utils.min-0.0.4.js +7 -0
  259. data/web/public/editor-app/partials/root-stencil-item-template.html +11 -0
  260. data/web/public/editor-app/partials/stencil-item-template.html +27 -0
  261. data/web/public/editor-app/plugins.xml +58 -0
  262. data/web/public/editor-app/popups/icon-template.html +3 -0
  263. data/web/public/editor-app/popups/save-model.html +41 -0
  264. data/web/public/editor-app/popups/select-shape.html +20 -0
  265. data/web/public/editor-app/popups/unsaved-changes.html +22 -0
  266. data/web/public/editor-app/select-shape-controller.js +314 -0
  267. data/web/public/editor-app/stencil-controller.js +1421 -0
  268. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/event.subprocess.collapsed.png +0 -0
  269. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/event.subprocess.png +0 -0
  270. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/expanded.subprocess.png +0 -0
  271. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/list/type.business.rule.png +0 -0
  272. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/list/type.camel.png +0 -0
  273. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/list/type.manual.png +0 -0
  274. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/list/type.mule.png +0 -0
  275. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/list/type.receive.png +0 -0
  276. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/list/type.script.png +0 -0
  277. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/list/type.send.png +0 -0
  278. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/list/type.service.png +0 -0
  279. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/list/type.shell.png +0 -0
  280. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/list/type.user.png +0 -0
  281. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/subprocess.png +0 -0
  282. data/web/public/editor-app/stencilsets/bpmn2.0/icons/activity/task.png +0 -0
  283. data/web/public/editor-app/stencilsets/bpmn2.0/icons/artifact/text.annotation.png +0 -0
  284. data/web/public/editor-app/stencilsets/bpmn2.0/icons/catching/cancel.png +0 -0
  285. data/web/public/editor-app/stencilsets/bpmn2.0/icons/catching/compensation.png +0 -0
  286. data/web/public/editor-app/stencilsets/bpmn2.0/icons/catching/error.png +0 -0
  287. data/web/public/editor-app/stencilsets/bpmn2.0/icons/catching/message.png +0 -0
  288. data/web/public/editor-app/stencilsets/bpmn2.0/icons/catching/signal.png +0 -0
  289. data/web/public/editor-app/stencilsets/bpmn2.0/icons/catching/timer.png +0 -0
  290. data/web/public/editor-app/stencilsets/bpmn2.0/icons/connector/association.undirected.png +0 -0
  291. data/web/public/editor-app/stencilsets/bpmn2.0/icons/connector/association.unidirectional.png +0 -0
  292. data/web/public/editor-app/stencilsets/bpmn2.0/icons/connector/messageflow.png +0 -0
  293. data/web/public/editor-app/stencilsets/bpmn2.0/icons/connector/sequenceflow.png +0 -0
  294. data/web/public/editor-app/stencilsets/bpmn2.0/icons/dataobject/data.store.png +0 -0
  295. data/web/public/editor-app/stencilsets/bpmn2.0/icons/diagram.png +0 -0
  296. data/web/public/editor-app/stencilsets/bpmn2.0/icons/endevent/cancel.png +0 -0
  297. data/web/public/editor-app/stencilsets/bpmn2.0/icons/endevent/error.png +0 -0
  298. data/web/public/editor-app/stencilsets/bpmn2.0/icons/endevent/none.png +0 -0
  299. data/web/public/editor-app/stencilsets/bpmn2.0/icons/endevent/terminate.png +0 -0
  300. data/web/public/editor-app/stencilsets/bpmn2.0/icons/gateway/eventbased.png +0 -0
  301. data/web/public/editor-app/stencilsets/bpmn2.0/icons/gateway/exclusive.databased.png +0 -0
  302. data/web/public/editor-app/stencilsets/bpmn2.0/icons/gateway/inclusive.png +0 -0
  303. data/web/public/editor-app/stencilsets/bpmn2.0/icons/gateway/parallel.png +0 -0
  304. data/web/public/editor-app/stencilsets/bpmn2.0/icons/startevent/error.png +0 -0
  305. data/web/public/editor-app/stencilsets/bpmn2.0/icons/startevent/message.png +0 -0
  306. data/web/public/editor-app/stencilsets/bpmn2.0/icons/startevent/none.png +0 -0
  307. data/web/public/editor-app/stencilsets/bpmn2.0/icons/startevent/signal.png +0 -0
  308. data/web/public/editor-app/stencilsets/bpmn2.0/icons/startevent/timer.png +0 -0
  309. data/web/public/editor-app/stencilsets/bpmn2.0/icons/swimlane/lane.png +0 -0
  310. data/web/public/editor-app/stencilsets/bpmn2.0/icons/swimlane/pool.png +0 -0
  311. data/web/public/editor-app/stencilsets/bpmn2.0/icons/throwing/none.png +0 -0
  312. data/web/public/editor-app/stencilsets/bpmn2.0/icons/throwing/signal.png +0 -0
  313. data/web/public/editor-app/toolbar-controller.js +162 -0
  314. data/web/public/modeler.html +140 -0
  315. data/web/views/models/index.erb +32 -0
  316. data/web/views/models/new.erb +15 -0
  317. metadata +334 -10
@@ -0,0 +1,1421 @@
1
+ /*
2
+ * Activiti Modeler component part of the Activiti project
3
+ * Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+ 'use strict';
20
+
21
+ angular.module('activitiModeler')
22
+ .controller('StencilController', ['$rootScope', '$scope', '$http', '$modal', '$timeout', function ($rootScope, $scope, $http, $modal, $timeout) {
23
+
24
+ // Property window toggle state
25
+ $scope.propertyWindowState = {'collapsed': false};
26
+
27
+ // Add reference to global header-config
28
+ $scope.headerConfig = KISBPM.HEADER_CONFIG;
29
+
30
+ $scope.propertyWindowState.toggle = function () {
31
+ $scope.propertyWindowState.collapsed = !$scope.propertyWindowState.collapsed;
32
+ $timeout(function () {
33
+ jQuery(window).trigger('resize');
34
+ });
35
+ };
36
+
37
+ // Code that is dependent on an initialised Editor is wrapped in a promise for the editor
38
+ $scope.editorFactory.promise.then(function () {
39
+
40
+ /* Build stencil item list */
41
+
42
+ // Build simple json representation of stencil set
43
+ var stencilItemGroups = [];
44
+
45
+ // Helper method: find a group in an array
46
+ var findGroup = function (name, groupArray) {
47
+ for (var index = 0; index < groupArray.length; index++) {
48
+ if (groupArray[index].name === name) {
49
+ return groupArray[index];
50
+ }
51
+ }
52
+ return null;
53
+ };
54
+
55
+ // Helper method: add a new group to an array of groups
56
+ var addGroup = function (groupName, groupArray) {
57
+ var group = { name: groupName, items: [], paletteItems: [], groups: [], visible: true };
58
+ groupArray.push(group);
59
+ return group;
60
+ };
61
+
62
+ /*
63
+ StencilSet items
64
+ */
65
+ $http({method: 'GET', url: KISBPM.URL.getStencilSet()}).success(function (data, status, headers, config) {
66
+
67
+ var quickMenuDefinition = ['UserTask', 'EndNoneEvent', 'ExclusiveGateway',
68
+ 'CatchTimerEvent', 'ThrowNoneEvent', 'TextAnnotation',
69
+ 'SequenceFlow', 'Association'];
70
+ var ignoreForPaletteDefinition = ['SequenceFlow', 'MessageFlow', 'Association', 'DataAssociation', 'DataStore', 'SendTask'];
71
+ var quickMenuItems = [];
72
+
73
+ var morphRoles = [];
74
+ for (var i = 0; i < data.rules.morphingRules.length; i++)
75
+ {
76
+ var role = data.rules.morphingRules[i].role;
77
+ var roleItem = {'role': role, 'morphOptions': []};
78
+ morphRoles.push(roleItem);
79
+ }
80
+
81
+ // Check all received items
82
+ for (var stencilIndex = 0; stencilIndex < data.stencils.length; stencilIndex++)
83
+ {
84
+ // Check if the root group is the 'diagram' group. If so, this item should not be shown.
85
+ var currentGroupName = data.stencils[stencilIndex].groups[0];
86
+ if (currentGroupName === 'Diagram' || currentGroupName === 'Form') {
87
+ continue; // go to next item
88
+ }
89
+
90
+ var removed = false;
91
+ if (data.stencils[stencilIndex].removed) {
92
+ removed = true;
93
+ }
94
+
95
+ var currentGroup = undefined;
96
+ if (!removed) {
97
+ // Check if this group already exists. If not, we create a new one
98
+
99
+ if (currentGroupName !== null && currentGroupName !== undefined && currentGroupName.length > 0) {
100
+
101
+ currentGroup = findGroup(currentGroupName, stencilItemGroups); // Find group in root groups array
102
+ if (currentGroup === null) {
103
+ currentGroup = addGroup(currentGroupName, stencilItemGroups);
104
+ }
105
+
106
+ // Add all child groups (if any)
107
+ for (var groupIndex = 1; groupIndex < data.stencils[stencilIndex].groups.length; groupIndex++) {
108
+ var childGroupName = data.stencils[stencilIndex].groups[groupIndex];
109
+ var childGroup = findGroup(childGroupName, currentGroup.groups);
110
+ if (childGroup === null) {
111
+ childGroup = addGroup(childGroupName, currentGroup.groups);
112
+ }
113
+
114
+ // The current group variable holds the parent of the next group (if any),
115
+ // and is basically the last element in the array of groups defined in the stencil item
116
+ currentGroup = childGroup;
117
+
118
+ }
119
+
120
+ }
121
+ }
122
+
123
+ // Construct the stencil item
124
+ var stencilItem = {'id': data.stencils[stencilIndex].id,
125
+ 'name': data.stencils[stencilIndex].title,
126
+ 'description': data.stencils[stencilIndex].description,
127
+ 'icon': data.stencils[stencilIndex].icon,
128
+ 'type': data.stencils[stencilIndex].type,
129
+ 'roles': data.stencils[stencilIndex].roles,
130
+ 'removed': removed,
131
+ 'customIcon': false,
132
+ 'canConnect': false,
133
+ 'canConnectTo': false,
134
+ 'canConnectAssociation': false};
135
+
136
+ if (data.stencils[stencilIndex].customIconId && data.stencils[stencilIndex].customIconId > 0) {
137
+ stencilItem.customIcon = true;
138
+ stencilItem.icon = data.stencils[stencilIndex].customIconId;
139
+ }
140
+
141
+ if (!removed) {
142
+ if (quickMenuDefinition.indexOf(stencilItem.id) >= 0) {
143
+ quickMenuItems[quickMenuDefinition.indexOf(stencilItem.id)] = stencilItem;
144
+ }
145
+ }
146
+
147
+ if (stencilItem.id === 'TextAnnotation' || stencilItem.id === 'BoundaryCompensationEvent') {
148
+ stencilItem.canConnectAssociation = true;
149
+ }
150
+
151
+ for (var i = 0; i < data.stencils[stencilIndex].roles.length; i++) {
152
+ var stencilRole = data.stencils[stencilIndex].roles[i];
153
+ if (stencilRole === 'sequence_start') {
154
+ stencilItem.canConnect = true;
155
+ } else if (stencilRole === 'sequence_end') {
156
+ stencilItem.canConnectTo = true;
157
+ }
158
+
159
+ for (var j = 0; j < morphRoles.length; j++) {
160
+ if (stencilRole === morphRoles[j].role) {
161
+ if (!removed) {
162
+ morphRoles[j].morphOptions.push(stencilItem);
163
+ }
164
+ stencilItem.morphRole = morphRoles[j].role;
165
+ break;
166
+ }
167
+ }
168
+ }
169
+
170
+ if (currentGroup) {
171
+ // Add the stencil item to the correct group
172
+ currentGroup.items.push(stencilItem);
173
+ if (ignoreForPaletteDefinition.indexOf(stencilItem.id) < 0) {
174
+ currentGroup.paletteItems.push(stencilItem);
175
+ }
176
+
177
+ } else {
178
+ // It's a root stencil element
179
+ if (!removed) {
180
+ stencilItemGroups.push(stencilItem);
181
+ }
182
+ }
183
+ }
184
+
185
+ for (var i = 0; i < stencilItemGroups.length; i++)
186
+ {
187
+ if (stencilItemGroups[i].paletteItems && stencilItemGroups[i].paletteItems.length == 0)
188
+ {
189
+ stencilItemGroups[i].visible = false;
190
+ }
191
+ }
192
+
193
+ $scope.stencilItemGroups = stencilItemGroups;
194
+
195
+ var containmentRules = [];
196
+ for (var i = 0; i < data.rules.containmentRules.length; i++)
197
+ {
198
+ var rule = data.rules.containmentRules[i];
199
+ containmentRules.push(rule);
200
+ }
201
+ $scope.containmentRules = containmentRules;
202
+
203
+ // remove quick menu items which are not available anymore due to custom pallette
204
+ var availableQuickMenuItems = [];
205
+ for (var i = 0; i < quickMenuItems.length; i++)
206
+ {
207
+ if (quickMenuItems[i]) {
208
+ availableQuickMenuItems[availableQuickMenuItems.length] = quickMenuItems[i];
209
+ }
210
+ }
211
+
212
+ $scope.quickMenuItems = availableQuickMenuItems;
213
+ $scope.morphRoles = morphRoles;
214
+ }).
215
+
216
+ error(function (data, status, headers, config) {
217
+ console.log('Something went wrong when fetching stencil items:' + JSON.stringify(data));
218
+ });
219
+
220
+ /*
221
+ * Listen to selection change events: show properties
222
+ */
223
+ $scope.editor.registerOnEvent(ORYX.CONFIG.EVENT_SELECTION_CHANGED, function (event) {
224
+ var shapes = event.elements;
225
+ var canvasSelected = false;
226
+ if (shapes && shapes.length == 0) {
227
+ shapes = [$scope.editor.getCanvas()];
228
+ canvasSelected = true;
229
+ }
230
+ if (shapes && shapes.length > 0) {
231
+
232
+ var selectedShape = shapes.first();
233
+ var stencil = selectedShape.getStencil();
234
+
235
+ if ($rootScope.selectedElementBeforeScrolling && stencil.id().indexOf('BPMNDiagram') !== -1)
236
+ {
237
+ // ignore canvas event because of empty selection when scrolling stops
238
+ return;
239
+ }
240
+
241
+ if ($rootScope.selectedElementBeforeScrolling && $rootScope.selectedElementBeforeScrolling.getId() === selectedShape.getId())
242
+ {
243
+ $rootScope.selectedElementBeforeScrolling = null;
244
+ return;
245
+ }
246
+
247
+ // Store previous selection
248
+ $scope.previousSelectedShape = $scope.selectedShape;
249
+
250
+ // Only do something if another element is selected (Oryx fires this event multiple times)
251
+ if ($scope.selectedShape !== undefined && $scope.selectedShape.getId() === selectedShape.getId()) {
252
+ if ($rootScope.forceSelectionRefresh) {
253
+ // Switch the flag again, this run will force refresh
254
+ $rootScope.forceSelectionRefresh = false;
255
+ } else {
256
+ // Selected the same element again, no need to update anything
257
+ return;
258
+ }
259
+ }
260
+
261
+ var selectedItem = {'title': '', 'properties': []};
262
+
263
+ if (canvasSelected) {
264
+ selectedItem.auditData = {
265
+ 'author': $scope.modelData.createdByUser,
266
+ 'createDate': $scope.modelData.createDate
267
+ };
268
+ }
269
+
270
+ // Gather properties of selected item
271
+ var properties = stencil.properties();
272
+ for (var i = 0; i < properties.length; i++) {
273
+ var property = properties[i];
274
+ if (property.popular() == false) continue;
275
+ var key = property.prefix() + "-" + property.id();
276
+
277
+ if (key === 'oryx-name') {
278
+ selectedItem.title = selectedShape.properties[key];
279
+ }
280
+
281
+ // First we check if there is a config for 'key-type' and then for 'type' alone
282
+ var propertyConfig = KISBPM.PROPERTY_CONFIG[key + '-' + property.type()];
283
+ if (propertyConfig === undefined || propertyConfig === null) {
284
+ propertyConfig = KISBPM.PROPERTY_CONFIG[property.type()];
285
+ }
286
+
287
+ if (propertyConfig === undefined || propertyConfig === null) {
288
+ console.log('WARNING: no property configuration defined for ' + key + ' of type ' + property.type());
289
+ } else {
290
+
291
+ if (selectedShape.properties[key] === 'true') {
292
+ selectedShape.properties[key] = true;
293
+ }
294
+
295
+ if (KISBPM.CONFIG.showRemovedProperties == false && property.isHidden())
296
+ {
297
+ continue;
298
+ }
299
+
300
+ var currentProperty = {
301
+ 'key': key,
302
+ 'title': property.title(),
303
+ 'type': property.type(),
304
+ 'mode': 'read',
305
+ 'hidden': property.isHidden(),
306
+ 'value': selectedShape.properties[key]
307
+ };
308
+
309
+ if ((currentProperty.type === 'complex' || currentProperty.type === 'multiplecomplex') && currentProperty.value && currentProperty.value.length > 0) {
310
+ try {
311
+ currentProperty.value = JSON.parse(currentProperty.value);
312
+ } catch (err) {
313
+ // ignore
314
+ }
315
+ }
316
+
317
+ if (propertyConfig.readModeTemplateUrl !== undefined && propertyConfig.readModeTemplateUrl !== null) {
318
+ currentProperty.readModeTemplateUrl = propertyConfig.readModeTemplateUrl + '?version=' + $rootScope.staticIncludeVersion;
319
+ }
320
+ if (propertyConfig.writeModeTemplateUrl !== null && propertyConfig.writeModeTemplateUrl !== null) {
321
+ currentProperty.writeModeTemplateUrl = propertyConfig.writeModeTemplateUrl + '?version=' + $rootScope.staticIncludeVersion;
322
+ }
323
+
324
+ if (propertyConfig.templateUrl !== undefined && propertyConfig.templateUrl !== null) {
325
+ currentProperty.templateUrl = propertyConfig.templateUrl + '?version=' + $rootScope.staticIncludeVersion;
326
+ currentProperty.hasReadWriteMode = false;
327
+ }
328
+ else {
329
+ currentProperty.hasReadWriteMode = true;
330
+ }
331
+
332
+ if (currentProperty.value === undefined
333
+ || currentProperty.value === null
334
+ || currentProperty.value.length == 0) {
335
+ currentProperty.noValue = true;
336
+ }
337
+
338
+ selectedItem.properties.push(currentProperty);
339
+ }
340
+ }
341
+
342
+ // Need to wrap this in an $apply block, see http://jimhoskins.com/2012/12/17/angularjs-and-apply.html
343
+ $scope.safeApply(function () {
344
+ $scope.selectedItem = selectedItem;
345
+ $scope.selectedShape = selectedShape;
346
+ });
347
+
348
+ } else {
349
+ $scope.safeApply(function () {
350
+ $scope.selectedItem = {};
351
+ $scope.selectedShape = null;
352
+ });
353
+ }
354
+ });
355
+
356
+ $scope.editor.registerOnEvent(ORYX.CONFIG.EVENT_SELECTION_CHANGED, function (event) {
357
+
358
+ KISBPM.eventBus.dispatch(KISBPM.eventBus.EVENT_TYPE_HIDE_SHAPE_BUTTONS);
359
+ var shapes = event.elements;
360
+
361
+ if (shapes && shapes.length == 1) {
362
+
363
+ var selectedShape = shapes.first();
364
+
365
+ var a = $scope.editor.getCanvas().node.getScreenCTM();
366
+
367
+ var absoluteXY = selectedShape.absoluteXY();
368
+
369
+ absoluteXY.x *= a.a;
370
+ absoluteXY.y *= a.d;
371
+
372
+ var additionalIEZoom = 1;
373
+ if (!isNaN(screen.logicalXDPI) && !isNaN(screen.systemXDPI)) {
374
+ var ua = navigator.userAgent;
375
+ if (ua.indexOf('MSIE') >= 0) {
376
+ //IE 10 and below
377
+ var zoom = Math.round((screen.deviceXDPI / screen.logicalXDPI) * 100);
378
+ if (zoom !== 100) {
379
+ additionalIEZoom = zoom / 100
380
+ }
381
+ }
382
+ }
383
+
384
+ if (additionalIEZoom === 1) {
385
+ absoluteXY.y = absoluteXY.y - jQuery("#canvasSection").offset().top + 5;
386
+ absoluteXY.x = absoluteXY.x - jQuery("#canvasSection").offset().left;
387
+
388
+ } else {
389
+ var canvasOffsetLeft = jQuery("#canvasSection").offset().left;
390
+ var canvasScrollLeft = jQuery("#canvasSection").scrollLeft();
391
+ var canvasScrollTop = jQuery("#canvasSection").scrollTop();
392
+
393
+ var offset = a.e - (canvasOffsetLeft * additionalIEZoom);
394
+ var additionaloffset = 0;
395
+ if (offset > 10) {
396
+ additionaloffset = (offset / additionalIEZoom) - offset;
397
+ }
398
+ absoluteXY.y = absoluteXY.y - (jQuery("#canvasSection").offset().top * additionalIEZoom) + 5 + ((canvasScrollTop * additionalIEZoom) - canvasScrollTop);
399
+ absoluteXY.x = absoluteXY.x - (canvasOffsetLeft * additionalIEZoom) + additionaloffset + ((canvasScrollLeft * additionalIEZoom) - canvasScrollLeft);
400
+ }
401
+
402
+ var bounds = new ORYX.Core.Bounds(a.e + absoluteXY.x, a.f + absoluteXY.y, a.e + absoluteXY.x + a.a*selectedShape.bounds.width(), a.f + absoluteXY.y + a.d*selectedShape.bounds.height());
403
+ var shapeXY = bounds.upperLeft();
404
+
405
+ var stencilItem = $scope.getStencilItemById(selectedShape.getStencil().idWithoutNs());
406
+ var morphShapes = [];
407
+ if (stencilItem && stencilItem.morphRole)
408
+ {
409
+ for (var i = 0; i < $scope.morphRoles.length; i++)
410
+ {
411
+ if ($scope.morphRoles[i].role === stencilItem.morphRole)
412
+ {
413
+ morphShapes = $scope.morphRoles[i].morphOptions;
414
+ }
415
+ }
416
+ }
417
+
418
+ var x = shapeXY.x;
419
+ if (bounds.width() < 48) {
420
+ x -= 24;
421
+ }
422
+
423
+ if (morphShapes && morphShapes.length > 0) {
424
+ // In case the element is not wide enough, start the 2 bottom-buttons more to the left
425
+ // to prevent overflow in the right-menu
426
+ var morphButton = document.getElementById('morph-button');
427
+ morphButton.style.display = "block";
428
+ morphButton.style.left = x + 24 +'px';
429
+ morphButton.style.top = (shapeXY.y+bounds.height() + 2) + 'px';
430
+ }
431
+
432
+ var deleteButton = document.getElementById('delete-button');
433
+ deleteButton.style.display = "block";
434
+ deleteButton.style.left = x + 'px';
435
+ deleteButton.style.top = (shapeXY.y+bounds.height() + 2) + 'px';
436
+
437
+ if (stencilItem && (stencilItem.canConnect || stencilItem.canConnectAssociation)) {
438
+ var quickButtonCounter = 0;
439
+ var quickButtonX = shapeXY.x+bounds.width() + 5;
440
+ var quickButtonY = shapeXY.y;
441
+ jQuery('.Oryx_button').each(function(i, obj) {
442
+ if (obj.id !== 'morph-button' && obj.id != 'delete-button') {
443
+ quickButtonCounter++;
444
+ if (quickButtonCounter > 3) {
445
+ quickButtonX = shapeXY.x+bounds.width() + 5;
446
+ quickButtonY += 24;
447
+ quickButtonCounter = 1;
448
+
449
+ } else if (quickButtonCounter > 1) {
450
+ quickButtonX += 24;
451
+ }
452
+ obj.style.display = "block";
453
+ obj.style.left = quickButtonX + 'px';
454
+ obj.style.top = quickButtonY + 'px';
455
+ }
456
+ });
457
+ }
458
+ }
459
+ });
460
+
461
+ if (!$rootScope.stencilInitialized) {
462
+ KISBPM.eventBus.addListener(KISBPM.eventBus.EVENT_TYPE_HIDE_SHAPE_BUTTONS, function (event) {
463
+ jQuery('.Oryx_button').each(function(i, obj) {
464
+ obj.style.display = "none";
465
+ });
466
+ });
467
+
468
+ /*
469
+ * Listen to property updates and act upon them
470
+ */
471
+ KISBPM.eventBus.addListener(KISBPM.eventBus.EVENT_TYPE_PROPERTY_VALUE_CHANGED, function (event) {
472
+ if (event.property && event.property.key) {
473
+ // If the name property is been updated, we also need to change the title of the currently selected item
474
+ if (event.property.key === 'oryx-name' && $scope.selectedItem !== undefined && $scope.selectedItem !== null) {
475
+ $scope.selectedItem.title = event.newValue;
476
+ }
477
+
478
+ // Update "no value" flag
479
+ event.property.noValue = (event.property.value === undefined
480
+ || event.property.value === null
481
+ || event.property.value.length == 0);
482
+ }
483
+ });
484
+
485
+ $rootScope.stencilInitialized = true;
486
+ }
487
+
488
+ $scope.morphShape = function() {
489
+ $scope.safeApply(function () {
490
+
491
+ var shapes = $rootScope.editor.getSelection();
492
+ if (shapes && shapes.length == 1)
493
+ {
494
+ $rootScope.currentSelectedShape = shapes.first();
495
+ var stencilItem = $scope.getStencilItemById($rootScope.currentSelectedShape.getStencil().idWithoutNs());
496
+ var morphShapes = [];
497
+ for (var i = 0; i < $scope.morphRoles.length; i++)
498
+ {
499
+ if ($scope.morphRoles[i].role === stencilItem.morphRole)
500
+ {
501
+ morphShapes = $scope.morphRoles[i].morphOptions.slice();
502
+ }
503
+ }
504
+
505
+ // Method to open shape select dialog (used later on)
506
+ var showSelectShapeDialog = function()
507
+ {
508
+ $rootScope.morphShapes = morphShapes;
509
+ $modal({
510
+ backdrop: false,
511
+ keyboard: true,
512
+ template: 'editor-app/popups/select-shape.html?version=' + Date.now()
513
+ });
514
+ };
515
+
516
+ showSelectShapeDialog();
517
+ }
518
+ });
519
+ };
520
+
521
+ $scope.deleteShape = function() {
522
+ KISBPM.TOOLBAR.ACTIONS.deleteItem({'$scope': $scope});
523
+ };
524
+
525
+ $scope.quickAddItem = function(newItemId) {
526
+ $scope.safeApply(function () {
527
+
528
+ var shapes = $rootScope.editor.getSelection();
529
+ if (shapes && shapes.length == 1)
530
+ {
531
+ $rootScope.currentSelectedShape = shapes.first();
532
+
533
+ var containedStencil = undefined;
534
+ var stencilSets = $scope.editor.getStencilSets().values();
535
+ for (var i = 0; i < stencilSets.length; i++)
536
+ {
537
+ var stencilSet = stencilSets[i];
538
+ var nodes = stencilSet.nodes();
539
+ for (var j = 0; j < nodes.length; j++)
540
+ {
541
+ if (nodes[j].idWithoutNs() === newItemId)
542
+ {
543
+ containedStencil = nodes[j];
544
+ break;
545
+ }
546
+ }
547
+ }
548
+
549
+ if (!containedStencil) return;
550
+
551
+ var option = {type: $scope.currentSelectedShape.getStencil().namespace() + newItemId, namespace: $scope.currentSelectedShape.getStencil().namespace()};
552
+ option['connectedShape'] = $rootScope.currentSelectedShape;
553
+ option['parent'] = $rootScope.currentSelectedShape.parent;
554
+ option['containedStencil'] = containedStencil;
555
+
556
+ var args = { sourceShape: $rootScope.currentSelectedShape, targetStencil: containedStencil };
557
+ var targetStencil = $scope.editor.getRules().connectMorph(args);
558
+ if (!targetStencil){ return; }// Check if there can be a target shape
559
+ option['connectingType'] = targetStencil.id();
560
+
561
+ var command = new KISBPM.CreateCommand(option, undefined, undefined, $scope.editor);
562
+
563
+ $scope.editor.executeCommands([command]);
564
+ }
565
+ });
566
+ };
567
+
568
+ }); // end of $scope.editorFactory.promise block
569
+
570
+ /* Click handler for clicking a property */
571
+ $scope.propertyClicked = function (index) {
572
+ if (!$scope.selectedItem.properties[index].hidden) {
573
+ $scope.selectedItem.properties[index].mode = "write";
574
+ }
575
+ };
576
+
577
+ /* Helper method to retrieve the template url for a property */
578
+ $scope.getPropertyTemplateUrl = function (index) {
579
+ return $scope.selectedItem.properties[index].templateUrl;
580
+ };
581
+ $scope.getPropertyReadModeTemplateUrl = function (index) {
582
+ return $scope.selectedItem.properties[index].readModeTemplateUrl;
583
+ };
584
+ $scope.getPropertyWriteModeTemplateUrl = function (index) {
585
+ return $scope.selectedItem.properties[index].writeModeTemplateUrl;
586
+ };
587
+
588
+ /* Method available to all sub controllers (for property controllers) to update the internal Oryx model */
589
+ $scope.updatePropertyInModel = function (property, shapeId) {
590
+
591
+ var shape = $scope.selectedShape;
592
+ // Some updates may happen when selected shape is already changed, so when an additional
593
+ // shapeId is supplied, we need to make sure the correct shape is updated (current or previous)
594
+ if (shapeId) {
595
+ if (shape.id != shapeId && $scope.previousSelectedShape && $scope.previousSelectedShape.id == shapeId) {
596
+ shape = $scope.previousSelectedShape;
597
+ } else {
598
+ shape = null;
599
+ }
600
+ }
601
+
602
+ if (!shape) {
603
+ // When no shape is selected, or no shape is found for the alternative
604
+ // shape ID, do nothing
605
+ return;
606
+ }
607
+ var key = property.key;
608
+ var newValue = property.value;
609
+ var oldValue = shape.properties[key];
610
+
611
+ if (newValue != oldValue) {
612
+ var commandClass = ORYX.Core.Command.extend({
613
+ construct: function () {
614
+ this.key = key;
615
+ this.oldValue = oldValue;
616
+ this.newValue = newValue;
617
+ this.shape = shape;
618
+ this.facade = $scope.editor;
619
+ },
620
+ execute: function () {
621
+ this.shape.setProperty(this.key, this.newValue);
622
+ this.facade.getCanvas().update();
623
+ this.facade.updateSelection();
624
+ },
625
+ rollback: function () {
626
+ this.shape.setProperty(this.key, this.oldValue);
627
+ this.facade.getCanvas().update();
628
+ this.facade.updateSelection();
629
+ }
630
+ });
631
+ // Instantiate the class
632
+ var command = new commandClass();
633
+
634
+ // Execute the command
635
+ $scope.editor.executeCommands([command]);
636
+ $scope.editor.handleEvents({
637
+ type: ORYX.CONFIG.EVENT_PROPWINDOW_PROP_CHANGED,
638
+ elements: [shape],
639
+ key: key
640
+ });
641
+
642
+ // Switch the property back to read mode, now the update is done
643
+ property.mode = 'read';
644
+
645
+ // Fire event to all who is interested
646
+ // Fire event to all who want to know about this
647
+ var event = {
648
+ type: KISBPM.eventBus.EVENT_TYPE_PROPERTY_VALUE_CHANGED,
649
+ property: property,
650
+ oldValue: oldValue,
651
+ newValue: newValue
652
+ };
653
+ KISBPM.eventBus.dispatch(event.type, event);
654
+ } else {
655
+ // Switch the property back to read mode, no update was needed
656
+ property.mode = 'read';
657
+ }
658
+
659
+ };
660
+
661
+ /**
662
+ * Helper method that searches a group for an item with the given id.
663
+ * If not found, will return undefined.
664
+ */
665
+ $scope.findStencilItemInGroup = function (stencilItemId, group) {
666
+
667
+ var item;
668
+
669
+ // Check all items directly in this group
670
+ for (var j = 0; j < group.items.length; j++) {
671
+ item = group.items[j];
672
+ if (item.id === stencilItemId) {
673
+ return item;
674
+ }
675
+ }
676
+
677
+ // Check the child groups
678
+ if (group.groups && group.groups.length > 0) {
679
+ for (var k = 0; k < group.groups.length; k++) {
680
+ item = $scope.findStencilItemInGroup(stencilItemId, group.groups[k]);
681
+ if (item) {
682
+ return item;
683
+ }
684
+ }
685
+ }
686
+
687
+ return undefined;
688
+ };
689
+
690
+ /**
691
+ * Helper method to find a stencil item.
692
+ */
693
+ $scope.getStencilItemById = function (stencilItemId) {
694
+ for (var i = 0; i < $scope.stencilItemGroups.length; i++) {
695
+ var element = $scope.stencilItemGroups[i];
696
+
697
+ // Real group
698
+ if (element.items !== null && element.items !== undefined) {
699
+ var item = $scope.findStencilItemInGroup(stencilItemId, element);
700
+ if (item) {
701
+ return item;
702
+ }
703
+ } else { // Root stencil item
704
+ if (element.id === stencilItemId) {
705
+ return element;
706
+ }
707
+ }
708
+ }
709
+ return undefined;
710
+ };
711
+
712
+ /*
713
+ * DRAG AND DROP FUNCTIONALITY
714
+ */
715
+
716
+ $scope.dropCallback = function (event, ui) {
717
+
718
+ $scope.editor.handleEvents({
719
+ type: ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,
720
+ highlightId: "shapeRepo.attached"
721
+ });
722
+ $scope.editor.handleEvents({
723
+ type: ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,
724
+ highlightId: "shapeRepo.added"
725
+ });
726
+
727
+ $scope.editor.handleEvents({
728
+ type: ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,
729
+ highlightId: "shapeMenu"
730
+ });
731
+
732
+ KISBPM.eventBus.dispatch(KISBPM.eventBus.EVENT_TYPE_HIDE_SHAPE_BUTTONS);
733
+
734
+ if ($scope.dragCanContain) {
735
+
736
+ var item = $scope.getStencilItemById(ui.draggable[0].id);
737
+
738
+ var pos = {x: event.pageX, y: event.pageY};
739
+
740
+ var additionalIEZoom = 1;
741
+ if (!isNaN(screen.logicalXDPI) && !isNaN(screen.systemXDPI)) {
742
+ var ua = navigator.userAgent;
743
+ if (ua.indexOf('MSIE') >= 0) {
744
+ //IE 10 and below
745
+ var zoom = Math.round((screen.deviceXDPI / screen.logicalXDPI) * 100);
746
+ if (zoom !== 100) {
747
+ additionalIEZoom = zoom / 100;
748
+ }
749
+ }
750
+ }
751
+
752
+ var screenCTM = $scope.editor.getCanvas().node.getScreenCTM();
753
+
754
+ // Correcting the UpperLeft-Offset
755
+ pos.x -= (screenCTM.e / additionalIEZoom);
756
+ pos.y -= (screenCTM.f / additionalIEZoom);
757
+ // Correcting the Zoom-Factor
758
+ pos.x /= screenCTM.a;
759
+ pos.y /= screenCTM.d;
760
+
761
+ // Correcting the ScrollOffset
762
+ pos.x -= document.documentElement.scrollLeft;
763
+ pos.y -= document.documentElement.scrollTop;
764
+
765
+ var parentAbs = $scope.dragCurrentParent.absoluteXY();
766
+ pos.x -= parentAbs.x;
767
+ pos.y -= parentAbs.y;
768
+
769
+ if ($scope.quickMenu)
770
+ {
771
+ var shapes = $scope.editor.getSelection();
772
+ if (shapes && shapes.length == 1)
773
+ {
774
+ var currentSelectedShape = shapes.first();
775
+
776
+ var containedStencil = undefined;
777
+ var stencilSets = $scope.editor.getStencilSets().values();
778
+ for (var i = 0; i < stencilSets.length; i++)
779
+ {
780
+ var stencilSet = stencilSets[i];
781
+ var nodes = stencilSet.nodes();
782
+ for (var j = 0; j < nodes.length; j++)
783
+ {
784
+ if (nodes[j].idWithoutNs() === ui.draggable[0].id)
785
+ {
786
+ containedStencil = nodes[j];
787
+ break;
788
+ }
789
+ }
790
+
791
+ if (!containedStencil)
792
+ {
793
+ var edges = stencilSet.edges();
794
+ for (var j = 0; j < edges.length; j++)
795
+ {
796
+ if (edges[j].idWithoutNs() === ui.draggable[0].id)
797
+ {
798
+ containedStencil = edges[j];
799
+ break;
800
+ }
801
+ }
802
+ }
803
+ }
804
+
805
+ if (!containedStencil) return;
806
+
807
+ var option = {};
808
+ option.type = currentSelectedShape.getStencil().namespace() + ui.draggable[0].id;
809
+ option.namespace = currentSelectedShape.getStencil().namespace();
810
+ option.connectedShape = currentSelectedShape;
811
+ option.parent = $scope.dragCurrentParent;
812
+ option.containedStencil = containedStencil;
813
+
814
+ // If the ctrl key is not pressed,
815
+ // snapp the new shape to the center
816
+ // if it is near to the center of the other shape
817
+ if (!event.ctrlKey){
818
+ // Get the center of the shape
819
+ var cShape = currentSelectedShape.bounds.center();
820
+ // Snapp +-20 Pixel horizontal to the center
821
+ if (20 > Math.abs(cShape.x - pos.x)){
822
+ pos.x = cShape.x;
823
+ }
824
+ // Snapp +-20 Pixel vertical to the center
825
+ if (20 > Math.abs(cShape.y - pos.y)){
826
+ pos.y = cShape.y;
827
+ }
828
+ }
829
+
830
+ option.position = pos;
831
+
832
+ if (containedStencil.idWithoutNs() !== 'SequenceFlow' && containedStencil.idWithoutNs() !== 'Association' &&
833
+ containedStencil.idWithoutNs() !== 'MessageFlow' && containedStencil.idWithoutNs() !== 'DataAssociation')
834
+ {
835
+ var args = { sourceShape: currentSelectedShape, targetStencil: containedStencil };
836
+ var targetStencil = $scope.editor.getRules().connectMorph(args);
837
+ if (!targetStencil){ return; }// Check if there can be a target shape
838
+ option.connectingType = targetStencil.id();
839
+ }
840
+
841
+ var command = new KISBPM.CreateCommand(option, $scope.dropTargetElement, pos, $scope.editor);
842
+
843
+ $scope.editor.executeCommands([command]);
844
+ }
845
+ }
846
+ else
847
+ {
848
+
849
+ var option = {};
850
+ option['type'] = $scope.modelData.model.stencilset.namespace + item.id;
851
+ option['namespace'] = $scope.modelData.model.stencilset.namespace;
852
+ option['position'] = pos;
853
+ option['parent'] = $scope.dragCurrentParent;
854
+
855
+ var commandClass = ORYX.Core.Command.extend({
856
+ construct: function (option, currentParent, canAttach, position, facade) {
857
+ this.option = option;
858
+ this.currentParent = currentParent;
859
+ this.canAttach = canAttach;
860
+ this.position = position;
861
+ this.facade = facade;
862
+ this.selection = this.facade.getSelection();
863
+ this.shape;
864
+ this.parent;
865
+ },
866
+ execute: function () {
867
+ if (!this.shape) {
868
+ this.shape = this.facade.createShape(option);
869
+ this.parent = this.shape.parent;
870
+ } else {
871
+ this.parent.add(this.shape);
872
+ }
873
+
874
+ if (this.canAttach && this.currentParent instanceof ORYX.Core.Node && this.shape.dockers.length > 0) {
875
+
876
+ var docker = this.shape.dockers[0];
877
+
878
+ if (this.currentParent.parent instanceof ORYX.Core.Node) {
879
+ this.currentParent.parent.add(docker.parent);
880
+ }
881
+
882
+ docker.bounds.centerMoveTo(this.position);
883
+ docker.setDockedShape(this.currentParent);
884
+ //docker.update();
885
+ }
886
+
887
+ this.facade.setSelection([this.shape]);
888
+ this.facade.getCanvas().update();
889
+ this.facade.updateSelection();
890
+
891
+ },
892
+ rollback: function () {
893
+ this.facade.deleteShape(this.shape);
894
+
895
+ //this.currentParent.update();
896
+
897
+ this.facade.setSelection(this.selection.without(this.shape));
898
+ this.facade.getCanvas().update();
899
+ this.facade.updateSelection();
900
+
901
+ }
902
+ });
903
+
904
+ // Update canvas
905
+ var command = new commandClass(option, $scope.dragCurrentParent, false, pos, $scope.editor);
906
+ $scope.editor.executeCommands([command]);
907
+
908
+ // Fire event to all who want to know about this
909
+ var dropEvent = {
910
+ type: KISBPM.eventBus.EVENT_TYPE_ITEM_DROPPED,
911
+ droppedItem: item,
912
+ position: pos
913
+ };
914
+ KISBPM.eventBus.dispatch(dropEvent.type, dropEvent);
915
+ }
916
+ }
917
+
918
+ $scope.dragCurrentParent = undefined;
919
+ $scope.dragCurrentParentId = undefined;
920
+ $scope.dragCurrentParentStencil = undefined;
921
+ $scope.dragCanContain = undefined;
922
+ $scope.quickMenu = undefined;
923
+ $scope.dropTargetElement = undefined;
924
+ };
925
+
926
+
927
+ $scope.overCallback = function (event, ui) {
928
+ $scope.dragModeOver = true;
929
+ };
930
+
931
+ $scope.outCallback = function (event, ui) {
932
+ $scope.dragModeOver = false;
933
+ };
934
+
935
+ $scope.startDragCallback = function (event, ui) {
936
+ $scope.dragModeOver = false;
937
+ $scope.quickMenu = false;
938
+ };
939
+
940
+ $scope.startDragCallbackQuickMenu = function (event, ui) {
941
+ $scope.dragModeOver = false;
942
+ $scope.quickMenu = true;
943
+ };
944
+
945
+ $scope.dragCallback = function (event, ui) {
946
+
947
+ if ($scope.dragModeOver != false) {
948
+
949
+ var coord = $scope.editor.eventCoordinatesXY(event.pageX, event.pageY);
950
+
951
+ var additionalIEZoom = 1;
952
+ if (!isNaN(screen.logicalXDPI) && !isNaN(screen.systemXDPI)) {
953
+ var ua = navigator.userAgent;
954
+ if (ua.indexOf('MSIE') >= 0) {
955
+ //IE 10 and below
956
+ var zoom = Math.round((screen.deviceXDPI / screen.logicalXDPI) * 100);
957
+ if (zoom !== 100) {
958
+ additionalIEZoom = zoom / 100
959
+ }
960
+ }
961
+ }
962
+
963
+ if (additionalIEZoom !== 1) {
964
+ coord.x = coord.x / additionalIEZoom;
965
+ coord.y = coord.y / additionalIEZoom;
966
+ }
967
+
968
+ var aShapes = $scope.editor.getCanvas().getAbstractShapesAtPosition(coord);
969
+
970
+ if (aShapes.length <= 0) {
971
+ if (event.helper) {
972
+ $scope.dragCanContain = false;
973
+ return false;
974
+ }
975
+ }
976
+
977
+ if (aShapes[0] instanceof ORYX.Core.Canvas) {
978
+ $scope.editor.getCanvas().setHightlightStateBasedOnX(coord.x);
979
+ }
980
+
981
+ if (aShapes.length == 1 && aShapes[0] instanceof ORYX.Core.Canvas)
982
+ {
983
+ var parentCandidate = aShapes[0];
984
+
985
+ $scope.dragCanContain = true;
986
+ $scope.dragCurrentParent = parentCandidate;
987
+ $scope.dragCurrentParentId = parentCandidate.id;
988
+
989
+ $scope.editor.handleEvents({
990
+ type: ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,
991
+ highlightId: "shapeRepo.attached"
992
+ });
993
+ $scope.editor.handleEvents({
994
+ type: ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,
995
+ highlightId: "shapeRepo.added"
996
+ });
997
+ return false;
998
+ }
999
+ else
1000
+ {
1001
+ var item = $scope.getStencilItemById(event.target.id);
1002
+
1003
+ var parentCandidate = aShapes.reverse().find(function (candidate) {
1004
+ return (candidate instanceof ORYX.Core.Canvas
1005
+ || candidate instanceof ORYX.Core.Node
1006
+ || candidate instanceof ORYX.Core.Edge);
1007
+ });
1008
+
1009
+ if (!parentCandidate) {
1010
+ $scope.dragCanContain = false;
1011
+ return false;
1012
+ }
1013
+
1014
+ if (item.type === "node") {
1015
+
1016
+ // check if the draggable is a boundary event and the parent an Activity
1017
+ var _canContain = false;
1018
+ var parentStencilId = parentCandidate.getStencil().id();
1019
+
1020
+ if ($scope.dragCurrentParentId && $scope.dragCurrentParentId === parentCandidate.id) {
1021
+ return false;
1022
+ }
1023
+
1024
+ var parentItem = $scope.getStencilItemById(parentCandidate.getStencil().idWithoutNs());
1025
+ if (parentItem.roles.indexOf("Activity") > -1) {
1026
+ if (item.roles.indexOf("IntermediateEventOnActivityBoundary") > -1) {
1027
+ _canContain = true;
1028
+ }
1029
+ }
1030
+ else if (parentCandidate.getStencil().idWithoutNs() === 'Pool')
1031
+ {
1032
+ if (item.id === 'Lane')
1033
+ {
1034
+ _canContain = true;
1035
+ }
1036
+ }
1037
+
1038
+ if (_canContain)
1039
+ {
1040
+ $scope.editor.handleEvents({
1041
+ type: ORYX.CONFIG.EVENT_HIGHLIGHT_SHOW,
1042
+ highlightId: "shapeRepo.attached",
1043
+ elements: [parentCandidate],
1044
+ style: ORYX.CONFIG.SELECTION_HIGHLIGHT_STYLE_RECTANGLE,
1045
+ color: ORYX.CONFIG.SELECTION_VALID_COLOR
1046
+ });
1047
+
1048
+ $scope.editor.handleEvents({
1049
+ type: ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,
1050
+ highlightId: "shapeRepo.added"
1051
+ });
1052
+ }
1053
+ else
1054
+ {
1055
+ for (var i = 0; i < $scope.containmentRules.length; i++) {
1056
+ var rule = $scope.containmentRules[i];
1057
+ if (rule.role === parentItem.id) {
1058
+ for (var j = 0; j < rule.contains.length; j++) {
1059
+ if (item.roles.indexOf(rule.contains[j]) > -1) {
1060
+ _canContain = true;
1061
+ break;
1062
+ }
1063
+ }
1064
+
1065
+ if (_canContain) {
1066
+ break;
1067
+ }
1068
+ }
1069
+ }
1070
+
1071
+ // Show Highlight
1072
+ $scope.editor.handleEvents({
1073
+ type: ORYX.CONFIG.EVENT_HIGHLIGHT_SHOW,
1074
+ highlightId: 'shapeRepo.added',
1075
+ elements: [parentCandidate],
1076
+ color: _canContain ? ORYX.CONFIG.SELECTION_VALID_COLOR : ORYX.CONFIG.SELECTION_INVALID_COLOR
1077
+ });
1078
+
1079
+ $scope.editor.handleEvents({
1080
+ type: ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,
1081
+ highlightId: "shapeRepo.attached"
1082
+ });
1083
+ }
1084
+
1085
+ $scope.dragCurrentParent = parentCandidate;
1086
+ $scope.dragCurrentParentId = parentCandidate.id;
1087
+ $scope.dragCurrentParentStencil = parentStencilId;
1088
+ $scope.dragCanContain = _canContain;
1089
+
1090
+ } else {
1091
+ var canvasCandidate = $scope.editor.getCanvas();
1092
+ var canConnect = false;
1093
+
1094
+ var targetStencil = $scope.getStencilItemById(parentCandidate.getStencil().idWithoutNs());
1095
+ if (targetStencil) {
1096
+ var associationConnect = false;
1097
+ if (stencil.idWithoutNs() === 'Association' && (curCan.getStencil().idWithoutNs() === 'TextAnnotation' || curCan.getStencil().idWithoutNs() === 'BoundaryCompensationEvent')) {
1098
+ associationConnect = true;
1099
+ } else if (stencil.idWithoutNs() === 'DataAssociation' && curCan.getStencil().idWithoutNs() === 'DataStore') {
1100
+ associationConnect = true;
1101
+ }
1102
+
1103
+ if (targetStencil.canConnectTo || associationConnect) {
1104
+ canConnect = true;
1105
+ }
1106
+ }
1107
+
1108
+ //Edge
1109
+ $scope.dragCurrentParent = canvasCandidate;
1110
+ $scope.dragCurrentParentId = canvasCandidate.id;
1111
+ $scope.dragCurrentParentStencil = canvasCandidate.getStencil().id();
1112
+ $scope.dragCanContain = canConnect;
1113
+
1114
+ // Show Highlight
1115
+ $scope.editor.handleEvents({
1116
+ type: ORYX.CONFIG.EVENT_HIGHLIGHT_SHOW,
1117
+ highlightId: 'shapeRepo.added',
1118
+ elements: [canvasCandidate],
1119
+ color: ORYX.CONFIG.SELECTION_VALID_COLOR
1120
+ });
1121
+
1122
+ $scope.editor.handleEvents({
1123
+ type: ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,
1124
+ highlightId: "shapeRepo.attached"
1125
+ });
1126
+ }
1127
+ }
1128
+ }
1129
+ };
1130
+
1131
+ $scope.dragCallbackQuickMenu = function (event, ui) {
1132
+
1133
+ if ($scope.dragModeOver != false) {
1134
+ var coord = $scope.editor.eventCoordinatesXY(event.pageX, event.pageY);
1135
+
1136
+ var additionalIEZoom = 1;
1137
+ if (!isNaN(screen.logicalXDPI) && !isNaN(screen.systemXDPI)) {
1138
+ var ua = navigator.userAgent;
1139
+ if (ua.indexOf('MSIE') >= 0) {
1140
+ //IE 10 and below
1141
+ var zoom = Math.round((screen.deviceXDPI / screen.logicalXDPI) * 100);
1142
+ if (zoom !== 100) {
1143
+ additionalIEZoom = zoom / 100
1144
+ }
1145
+ }
1146
+ }
1147
+
1148
+ if (additionalIEZoom !== 1) {
1149
+ coord.x = coord.x / additionalIEZoom;
1150
+ coord.y = coord.y / additionalIEZoom;
1151
+ }
1152
+
1153
+ var aShapes = $scope.editor.getCanvas().getAbstractShapesAtPosition(coord);
1154
+
1155
+ if (aShapes.length <= 0) {
1156
+ if (event.helper) {
1157
+ $scope.dragCanContain = false;
1158
+ return false;
1159
+ }
1160
+ }
1161
+
1162
+ if (aShapes[0] instanceof ORYX.Core.Canvas) {
1163
+ $scope.editor.getCanvas().setHightlightStateBasedOnX(coord.x);
1164
+ }
1165
+
1166
+ var stencil = undefined;
1167
+ var stencilSets = $scope.editor.getStencilSets().values();
1168
+ for (var i = 0; i < stencilSets.length; i++)
1169
+ {
1170
+ var stencilSet = stencilSets[i];
1171
+ var nodes = stencilSet.nodes();
1172
+ for (var j = 0; j < nodes.length; j++)
1173
+ {
1174
+ if (nodes[j].idWithoutNs() === event.target.id)
1175
+ {
1176
+ stencil = nodes[j];
1177
+ break;
1178
+ }
1179
+ }
1180
+
1181
+ if (!stencil)
1182
+ {
1183
+ var edges = stencilSet.edges();
1184
+ for (var j = 0; j < edges.length; j++)
1185
+ {
1186
+ if (edges[j].idWithoutNs() === event.target.id)
1187
+ {
1188
+ stencil = edges[j];
1189
+ break;
1190
+ }
1191
+ }
1192
+ }
1193
+ }
1194
+
1195
+ var candidate = aShapes.last();
1196
+
1197
+ var isValid = false;
1198
+ if (stencil.type() === "node")
1199
+ {
1200
+ //check containment rules
1201
+ var canContain = $scope.editor.getRules().canContain({containingShape:candidate, containedStencil:stencil});
1202
+
1203
+ var parentCandidate = aShapes.reverse().find(function (candidate) {
1204
+ return (candidate instanceof ORYX.Core.Canvas
1205
+ || candidate instanceof ORYX.Core.Node
1206
+ || candidate instanceof ORYX.Core.Edge);
1207
+ });
1208
+
1209
+ if (!parentCandidate) {
1210
+ $scope.dragCanContain = false;
1211
+ return false;
1212
+ }
1213
+
1214
+ $scope.dragCurrentParent = parentCandidate;
1215
+ $scope.dragCurrentParentId = parentCandidate.id;
1216
+ $scope.dragCurrentParentStencil = parentCandidate.getStencil().id();
1217
+ $scope.dragCanContain = canContain;
1218
+ $scope.dropTargetElement = parentCandidate;
1219
+ isValid = canContain;
1220
+
1221
+ } else { //Edge
1222
+
1223
+ var shapes = $scope.editor.getSelection();
1224
+ if (shapes && shapes.length == 1)
1225
+ {
1226
+ var currentSelectedShape = shapes.first();
1227
+ var curCan = candidate;
1228
+ var canConnect = false;
1229
+
1230
+ var targetStencil = $scope.getStencilItemById(curCan.getStencil().idWithoutNs());
1231
+ if (targetStencil)
1232
+ {
1233
+ var associationConnect = false;
1234
+ if (stencil.idWithoutNs() === 'Association' && (curCan.getStencil().idWithoutNs() === 'TextAnnotation' || curCan.getStencil().idWithoutNs() === 'BoundaryCompensationEvent'))
1235
+ {
1236
+ associationConnect = true;
1237
+ }
1238
+ else if (stencil.idWithoutNs() === 'DataAssociation' && curCan.getStencil().idWithoutNs() === 'DataStore')
1239
+ {
1240
+ associationConnect = true;
1241
+ }
1242
+
1243
+ if (targetStencil.canConnectTo || associationConnect)
1244
+ {
1245
+ while (!canConnect && curCan && !(curCan instanceof ORYX.Core.Canvas))
1246
+ {
1247
+ candidate = curCan;
1248
+ //check connection rules
1249
+ canConnect = $scope.editor.getRules().canConnect({
1250
+ sourceShape: currentSelectedShape,
1251
+ edgeStencil: stencil,
1252
+ targetShape: curCan
1253
+ });
1254
+ curCan = curCan.parent;
1255
+ }
1256
+ }
1257
+ }
1258
+ var parentCandidate = $scope.editor.getCanvas();
1259
+
1260
+ isValid = canConnect;
1261
+ $scope.dragCurrentParent = parentCandidate;
1262
+ $scope.dragCurrentParentId = parentCandidate.id;
1263
+ $scope.dragCurrentParentStencil = parentCandidate.getStencil().id();
1264
+ $scope.dragCanContain = canConnect;
1265
+ $scope.dropTargetElement = candidate;
1266
+ }
1267
+
1268
+ }
1269
+
1270
+ $scope.editor.handleEvents({
1271
+ type: ORYX.CONFIG.EVENT_HIGHLIGHT_SHOW,
1272
+ highlightId:'shapeMenu',
1273
+ elements: [candidate],
1274
+ color: isValid ? ORYX.CONFIG.SELECTION_VALID_COLOR : ORYX.CONFIG.SELECTION_INVALID_COLOR
1275
+ });
1276
+ }
1277
+ };
1278
+
1279
+ }]);
1280
+
1281
+ var KISBPM = KISBPM || {};
1282
+ //create command for undo/redo
1283
+ KISBPM.CreateCommand = ORYX.Core.Command.extend({
1284
+ construct: function(option, currentReference, position, facade){
1285
+ this.option = option;
1286
+ this.currentReference = currentReference;
1287
+ this.position = position;
1288
+ this.facade = facade;
1289
+ this.shape;
1290
+ this.edge;
1291
+ this.targetRefPos;
1292
+ this.sourceRefPos;
1293
+ /*
1294
+ * clone options parameters
1295
+ */
1296
+ this.connectedShape = option.connectedShape;
1297
+ this.connectingType = option.connectingType;
1298
+ this.namespace = option.namespace;
1299
+ this.type = option.type;
1300
+ this.containedStencil = option.containedStencil;
1301
+ this.parent = option.parent;
1302
+ this.currentReference = currentReference;
1303
+ this.shapeOptions = option.shapeOptions;
1304
+ },
1305
+ execute: function(){
1306
+
1307
+ if (this.shape) {
1308
+ if (this.shape instanceof ORYX.Core.Node) {
1309
+ this.parent.add(this.shape);
1310
+ if (this.edge) {
1311
+ this.facade.getCanvas().add(this.edge);
1312
+ this.edge.dockers.first().setDockedShape(this.connectedShape);
1313
+ this.edge.dockers.first().setReferencePoint(this.sourceRefPos);
1314
+ this.edge.dockers.last().setDockedShape(this.shape);
1315
+ this.edge.dockers.last().setReferencePoint(this.targetRefPos);
1316
+ }
1317
+
1318
+ this.facade.setSelection([this.shape]);
1319
+
1320
+ } else if (this.shape instanceof ORYX.Core.Edge) {
1321
+ this.facade.getCanvas().add(this.shape);
1322
+ this.shape.dockers.first().setDockedShape(this.connectedShape);
1323
+ this.shape.dockers.first().setReferencePoint(this.sourceRefPos);
1324
+ }
1325
+ resume = true;
1326
+ }
1327
+ else {
1328
+ this.shape = this.facade.createShape(this.option);
1329
+ this.edge = (!(this.shape instanceof ORYX.Core.Edge)) ? this.shape.getIncomingShapes().first() : undefined;
1330
+ }
1331
+
1332
+ if (this.currentReference && this.position) {
1333
+
1334
+ if (this.shape instanceof ORYX.Core.Edge) {
1335
+
1336
+ if (!(this.currentReference instanceof ORYX.Core.Canvas)) {
1337
+ this.shape.dockers.last().setDockedShape(this.currentReference);
1338
+
1339
+ if (this.currentReference.getStencil().idWithoutNs() === 'TextAnnotation')
1340
+ {
1341
+ var midpoint = {};
1342
+ midpoint.x = 0;
1343
+ midpoint.y = this.currentReference.bounds.height() / 2;
1344
+ this.shape.dockers.last().setReferencePoint(midpoint);
1345
+ }
1346
+ else
1347
+ {
1348
+ this.shape.dockers.last().setReferencePoint(this.currentReference.bounds.midPoint());
1349
+ }
1350
+ }
1351
+ else {
1352
+ this.shape.dockers.last().bounds.centerMoveTo(this.position);
1353
+ }
1354
+ this.sourceRefPos = this.shape.dockers.first().referencePoint;
1355
+ this.targetRefPos = this.shape.dockers.last().referencePoint;
1356
+
1357
+ } else if (this.edge){
1358
+ this.sourceRefPos = this.edge.dockers.first().referencePoint;
1359
+ this.targetRefPos = this.edge.dockers.last().referencePoint;
1360
+ }
1361
+ } else {
1362
+ var containedStencil = this.containedStencil;
1363
+ var connectedShape = this.connectedShape;
1364
+ var bc = connectedShape.bounds;
1365
+ var bs = this.shape.bounds;
1366
+
1367
+ var pos = bc.center();
1368
+ if(containedStencil.defaultAlign()==="north") {
1369
+ pos.y -= (bc.height() / 2) + ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET + (bs.height()/2);
1370
+ } else if(containedStencil.defaultAlign()==="northeast") {
1371
+ pos.x += (bc.width() / 2) + ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET_CORNER + (bs.width()/2);
1372
+ pos.y -= (bc.height() / 2) + ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET_CORNER + (bs.height()/2);
1373
+ } else if(containedStencil.defaultAlign()==="southeast") {
1374
+ pos.x += (bc.width() / 2) + ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET_CORNER + (bs.width()/2);
1375
+ pos.y += (bc.height() / 2) + ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET_CORNER + (bs.height()/2);
1376
+ } else if(containedStencil.defaultAlign()==="south") {
1377
+ pos.y += (bc.height() / 2) + ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET + (bs.height()/2);
1378
+ } else if(containedStencil.defaultAlign()==="southwest") {
1379
+ pos.x -= (bc.width() / 2) + ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET_CORNER + (bs.width()/2);
1380
+ pos.y += (bc.height() / 2) + ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET_CORNER + (bs.height()/2);
1381
+ } else if(containedStencil.defaultAlign()==="west") {
1382
+ pos.x -= (bc.width() / 2) + ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET + (bs.width()/2);
1383
+ } else if(containedStencil.defaultAlign()==="northwest") {
1384
+ pos.x -= (bc.width() / 2) + ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET_CORNER + (bs.width()/2);
1385
+ pos.y -= (bc.height() / 2) + ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET_CORNER + (bs.height()/2);
1386
+ } else {
1387
+ pos.x += (bc.width() / 2) + ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET + (bs.width()/2);
1388
+ }
1389
+
1390
+ // Move shape to the new position
1391
+ this.shape.bounds.centerMoveTo(pos);
1392
+
1393
+ // Move all dockers of a node to the position
1394
+ if (this.shape instanceof ORYX.Core.Node){
1395
+ (this.shape.dockers||[]).each(function(docker){
1396
+ docker.bounds.centerMoveTo(pos);
1397
+ });
1398
+ }
1399
+
1400
+ //this.shape.update();
1401
+ this.position = pos;
1402
+
1403
+ if (this.edge){
1404
+ this.sourceRefPos = this.edge.dockers.first().referencePoint;
1405
+ this.targetRefPos = this.edge.dockers.last().referencePoint;
1406
+ }
1407
+ }
1408
+
1409
+ this.facade.getCanvas().update();
1410
+ this.facade.updateSelection();
1411
+
1412
+ },
1413
+ rollback: function(){
1414
+ this.facade.deleteShape(this.shape);
1415
+ if(this.edge) {
1416
+ this.facade.deleteShape(this.edge);
1417
+ }
1418
+ //this.currentParent.update();
1419
+ this.facade.setSelection(this.facade.getSelection().without(this.shape, this.edge));
1420
+ }
1421
+ });