main_window.xml 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. <class name="MainWindow">
  2. <relationships>
  3. <inheritance class="tk.Toplevel" priority="1"/>
  4. <inheritance class="SCCDWidget" priority="0"/>
  5. <association name="parent" class="A"/>
  6. <association name="generic_toolbars" class="Toolbar"/>
  7. <association name="model_toolbars" class="Toolbar"/>
  8. <association name="subwindow" class="Window"/>
  9. <association name="canvas" class="Canvas"/>
  10. <association name="progress_bar" class="ProgressBar"/>
  11. </relationships>
  12. <constructor>
  13. <super class="tk.Toplevel"/>
  14. <super class="SCCDWidget"/>
  15. <parameter name="open_model"/>
  16. <parameter name="limited_mode"/>
  17. <body>
  18. self.toolbar_frame = tk.Frame(self)
  19. self.canvas_frame = tk.Frame(self)
  20. self.progressbar_frame = tk.Frame(self)
  21. self.toolbar_frame.pack(fill=tk.X)
  22. self.canvas_frame.pack(fill=tk.BOTH, expand=tk.TRUE)
  23. self.progressbar_frame.pack(fill=tk.X)
  24. self.model_loaded = False
  25. self.preload_model = open_model
  26. self.limited_mode = limited_mode
  27. global current_mapper
  28. current_mapper = None
  29. global current_rendered_model
  30. current_rendered_model = None
  31. global current_metamodel
  32. current_metamodel = None
  33. global current_model
  34. current_model = None
  35. </body>
  36. </constructor>
  37. <destructor>
  38. <body>
  39. self.destroy()
  40. </body>
  41. </destructor>
  42. <scxml initial="init">
  43. <parallel id="init">
  44. <state id="init" initial="init">
  45. <state id="init" initial="determine_initial">
  46. <state id="determine_initial">
  47. <transition cond="self.limited_mode" target="../progressbar"/>
  48. <transition cond="not self.limited_mode" target="../generic_toolbar"/>
  49. </state>
  50. <state id="generic_toolbar">
  51. <onentry>
  52. <raise event="create_instance" scope="cd">
  53. <parameter expr="'generic_toolbars'"/>
  54. <parameter expr="'GenericToolbar'"/>
  55. <parameter expr="self.toolbar_frame"/>
  56. </raise>
  57. </onentry>
  58. <transition event="instance_created" target="../pack_generic">
  59. <parameter name="association_name"/>
  60. <raise event="start_instance" scope="cd">
  61. <parameter expr="association_name"/>
  62. </raise>
  63. </transition>
  64. </state>
  65. <state id="pack_generic">
  66. <transition event="tk_widget" target="../progressbar">
  67. <parameter name="tk_elem"/>
  68. <script>
  69. tk_elem.pack(anchor=tk.NW)
  70. </script>
  71. </transition>
  72. </state>
  73. <state id="progressbar">
  74. <onentry>
  75. <raise event="create_instance" scope="cd">
  76. <parameter expr="'progress_bar'"/>
  77. <parameter expr="'ProgressBar'"/>
  78. <parameter expr="{'parent': self.progressbar_frame}"/>
  79. </raise>
  80. </onentry>
  81. <transition event="instance_created" target="../pack_progressbar">
  82. <parameter name="association_name"/>
  83. <raise event="start_instance" scope="cd">
  84. <parameter expr="association_name"/>
  85. </raise>
  86. </transition>
  87. </state>
  88. <state id="pack_progressbar">
  89. <transition event="tk_widget" target="../../running">
  90. <parameter name="tk_elem"/>
  91. <script>
  92. tk_elem.pack(side=tk.BOTTOM, fill=tk.X, expand=tk.TRUE)
  93. </script>
  94. </transition>
  95. </state>
  96. </state>
  97. <state id="running" initial="idle">
  98. <state id="idle">
  99. <onentry>
  100. <raise event="update_status" scope="narrow" target="'progress_bar'">
  101. <parameter expr="0"/>
  102. <parameter expr="'Ready for action!'"/>
  103. </raise>
  104. </onentry>
  105. <transition event="create_new_model" target="../create_new_model"/>
  106. <transition event="open_model" target="../open_model"/>
  107. <transition event="rerender_model" target="../rerender_model"/>
  108. <transition event="new_rendered" cond="current_mapper is not None" target="../new_rendered"/>
  109. <transition event="verify" target="../verify_model"/>
  110. <transition event="conf_bottom" target="../conf_bottom"/>
  111. <transition event="custom_MM" target="../custom_MM"/>
  112. <transition event="upload_MVC" target="../upload_MVC"/>
  113. <transition event="add_object_diagrams" target="../add_object_diagrams"/>
  114. <transition event="activity" target="../execute_activity"/>
  115. <transition event="create_activity" target="../create_activity"/>
  116. <transition event="modify_defined_attrs" target="../modify_defined_attrs">
  117. <parameter name="as_element"/>
  118. <parameter name="cs_element"/>
  119. <script>
  120. self.as_element = as_element
  121. self.cs_element = cs_element
  122. </script>
  123. </transition>
  124. <transition event="change_metamodel" target="../change_metamodel">
  125. <parameter name="new_metamodel"/>
  126. <script>
  127. global current_metamodel
  128. current_metamodel = new_metamodel
  129. </script>
  130. </transition>
  131. <transition event="change_mapper" target="../change_mapper">
  132. <parameter name="new_mapper"/>
  133. <script>
  134. global current_mapper
  135. current_mapper = new_mapper
  136. print("Switch mapper to " + str(new_mapper))
  137. </script>
  138. </transition>
  139. <transition event="change_rendered" target="../change_rendered">
  140. <parameter name="new_rendered"/>
  141. <script>
  142. global current_rendered_model
  143. current_rendered_model = new_rendered
  144. </script>
  145. </transition>
  146. <transition event="select_for_creation" target=".">
  147. <parameter name="element_name"/>
  148. <raise event="select_for_creation" scope="narrow" target="'canvas'">
  149. <parameter expr="element_name"/>
  150. </raise>
  151. </transition>
  152. <transition cond="self.preload_model is not None" target="../open_model/search_metamodels">
  153. <script>
  154. global current_model
  155. current_model = self.preload_model
  156. self.preload_model = None
  157. </script>
  158. </transition>
  159. </state>
  160. <state id="modify_defined_attrs" initial="create_window">
  161. <state id="create_window">
  162. <onentry>
  163. <raise event="create_instance" scope="cd">
  164. <parameter expr="'subwindow'"/>
  165. <parameter expr="'AttributeEditor'"/>
  166. <parameter expr="self.as_element"/>
  167. </raise>
  168. </onentry>
  169. <transition event="instance_created" target="../wait_for_finished">
  170. <parameter name="assoc_name"/>
  171. <raise event="start_instance" scope="cd">
  172. <parameter expr="assoc_name"/>
  173. </raise>
  174. <script>
  175. self.current_window = assoc_name
  176. </script>
  177. </transition>
  178. </state>
  179. <state id="wait_for_finished">
  180. <transition event="close_window" target="../mark_dirty">
  181. <raise event="delete_instance" scope="cd">
  182. <parameter expr="self.current_window"/>
  183. </raise>
  184. </transition>
  185. </state>
  186. <state id="mark_dirty">
  187. <onentry>
  188. <raise event="mv_request" scope="broad">
  189. <parameter expr="'attr_assign'"/>
  190. <parameter expr="[current_rendered_model, self.cs_element, 'dirty', True]"/>
  191. </raise>
  192. </onentry>
  193. <transition event="mv_response" target="../../rerender_model"/>
  194. </state>
  195. </state>
  196. <state id="execute_activity" initial="open_window">
  197. <state id="open_window">
  198. <onentry>
  199. <raise event="create_instance" scope="cd">
  200. <parameter expr="'subwindow'"/>
  201. <parameter expr="'ActivityExecutor'"/>
  202. </raise>
  203. </onentry>
  204. <transition event="instance_created" target="../waiting">
  205. <parameter name="assoc_name"/>
  206. <raise event="start_instance" scope="cd">
  207. <parameter expr="assoc_name"/>
  208. </raise>
  209. <script>
  210. self.activity_executor = assoc_name
  211. </script>
  212. </transition>
  213. </state>
  214. <state id="waiting">
  215. <transition event="window_close" target="../../idle">
  216. <raise event="delete_instance" scope="cd">
  217. <parameter expr="self.activity_executor"/>
  218. </raise>
  219. </transition>
  220. </state>
  221. </state>
  222. <state id="create_activity" initial="open_window">
  223. <state id="open_window">
  224. <onentry>
  225. <raise event="create_instance" scope="cd">
  226. <parameter expr="'subwindow'"/>
  227. <parameter expr="'ActivityCreator'"/>
  228. </raise>
  229. </onentry>
  230. <transition event="instance_created" target="../waiting">
  231. <parameter name="assoc_name"/>
  232. <raise event="start_instance" scope="cd">
  233. <parameter expr="assoc_name"/>
  234. </raise>
  235. <script>
  236. self.activity_creator = assoc_name
  237. </script>
  238. </transition>
  239. </state>
  240. <state id="waiting">
  241. <transition event="window_close" target="../../idle">
  242. <raise event="delete_instance" scope="cd">
  243. <parameter expr="self.activity_creator"/>
  244. </raise>
  245. </transition>
  246. </state>
  247. </state>
  248. <state id="add_object_diagrams" initial="init">
  249. <state id="init">
  250. <onentry>
  251. <raise event="mv_request" scope="broad">
  252. <parameter expr="'transformation_add_AL'"/>
  253. <parameter expr="[{'rendered': 'formalisms/MM_render', 'abstract': current_metamodel}, {'rendered': 'formalisms/MM_render'}, 'models/render_OD/' + current_metamodel, open('models/render_OD.alc', 'r').read()]"/>
  254. </raise>
  255. <raise event="update_status" scope="narrow" target="'progress_bar'">
  256. <parameter expr="10"/>
  257. <parameter expr="'Adding transformation...'"/>
  258. </raise>
  259. </onentry>
  260. <transition event="mv_response" target="../modify_render_OD">
  261. <parameter name="context"/>
  262. <raise event="update_status" scope="narrow" target="'progress_bar'">
  263. <parameter expr="25"/>
  264. <parameter expr="'Switching contexts...'"/>
  265. </raise>
  266. <script>
  267. self.context = context
  268. </script>
  269. </transition>
  270. <transition event="mv_exception" target="../../idle"/>
  271. </state>
  272. <state id="modify_render_OD" initial="exit">
  273. <onexit>
  274. <script>
  275. self.context = None
  276. </script>
  277. </onexit>
  278. <state id="exit">
  279. <onentry>
  280. <raise event="mv_request_context" scope="broad">
  281. <parameter expr="'exit'"/>
  282. <parameter expr="[]"/>
  283. <parameter expr="self.context"/>
  284. </raise>
  285. <raise event="update_status" scope="narrow" target="'progress_bar'">
  286. <parameter expr="30"/>
  287. <parameter expr="'Modifying transformation merged metamodel...'"/>
  288. </raise>
  289. </onentry>
  290. <transition event="mv_response" target="../../../open_model/search_CS_mappers">
  291. <script>
  292. global current_mapper
  293. current_mapper = 'models/render_OD/' + current_metamodel
  294. </script>
  295. </transition>
  296. </state>
  297. </state>
  298. </state>
  299. <state id="upload_MVC" initial="load_code">
  300. <state id="load_code">
  301. <onentry>
  302. <script>
  303. from tkFileDialog import askopenfilename
  304. self.filename = askopenfilename()
  305. </script>
  306. </onentry>
  307. <transition cond="self.filename is not None" target="../overwriting_model">
  308. <raise event="mv_request" scope="broad">
  309. <parameter expr="'model_overwrite'"/>
  310. <parameter expr="[current_model, open(self.filename, 'r').read()]"/>
  311. </raise>
  312. <raise event="update_status" scope="narrow" target="'progress_bar'">
  313. <parameter expr="10"/>
  314. <parameter expr="'Uploading model...'"/>
  315. </raise>
  316. </transition>
  317. <transition cond="self.filename is None" target="../../idle"/>
  318. </state>
  319. <state id="overwriting_model">
  320. <transition event="mv_response" target="../../rerender_model">
  321. <raise event="update_status" scope="narrow" target="'progress_bar'">
  322. <parameter expr="50"/>
  323. <parameter expr="'Rerendering model...'"/>
  324. </raise>
  325. </transition>
  326. </state>
  327. </state>
  328. <state id="change_metamodel">
  329. <onentry>
  330. <script>
  331. print("MM -> " + current_metamodel)
  332. </script>
  333. <raise event="mv_request" scope="broad">
  334. <parameter expr="'alter_context'"/>
  335. <parameter expr="[current_model, current_metamodel]"/>
  336. </raise>
  337. <raise event="update_status" scope="narrow" target="'progress_bar'">
  338. <parameter expr="20"/>
  339. <parameter expr="'Storing model context...'"/>
  340. </raise>
  341. </onentry>
  342. <transition event="mv_response" target="../open_model/search_CS_mappers"/>
  343. </state>
  344. <state id="conf_bottom" initial="check_if_exists">
  345. <state id="check_if_exists">
  346. <transition cond="'formalisms/Bottom' in self.allowed_metamodels" target="../../idle"/>
  347. <transition cond="'formalisms/Bottom' not in self.allowed_metamodels" target="../add_bottom"/>
  348. </state>
  349. <state id="add_bottom">
  350. <onentry>
  351. <raise event="mv_request" scope="broad">
  352. <parameter expr="'conformance_add'"/>
  353. <parameter expr="[current_model, 'formalisms/Bottom']"/>
  354. </raise>
  355. <raise event="update_status" scope="narrow" target="'progress_bar'">
  356. <parameter expr="10"/>
  357. <parameter expr="'Storing model context...'"/>
  358. </raise>
  359. <script>
  360. global current_metamodel
  361. current_metamodel = 'formalisms/Bottom'
  362. </script>
  363. </onentry>
  364. <transition event="mv_response" target="../../open_model/search_metamodels"/>
  365. </state>
  366. </state>
  367. <state id="custom_MM" initial="query">
  368. <state id="query">
  369. <onentry>
  370. <raise event="create_instance" scope="cd">
  371. <parameter expr="'subwindow'"/>
  372. <parameter expr="'Browser'"/>
  373. <parameter expr="'Select metamodel to use.'"/>
  374. <parameter expr="['formalisms/SimpleClassDiagrams']"/>
  375. </raise>
  376. <raise event="update_status" scope="narrow" target="'progress_bar'">
  377. <parameter expr="0"/>
  378. <parameter expr="'Browsing for metamodel...'"/>
  379. </raise>
  380. </onentry>
  381. <transition event="instance_created" target="../wait_for_metamodel">
  382. <parameter name="association_name"/>
  383. <raise event="start_instance" scope="cd">
  384. <parameter expr="association_name"/>
  385. </raise>
  386. <script>
  387. self.subwindow = association_name
  388. </script>
  389. </transition>
  390. </state>
  391. <state id="wait_for_metamodel" initial="wait_for_result">
  392. <onentry>
  393. <raise event="update_status" scope="narrow" target="'progress_bar'">
  394. <parameter expr="10"/>
  395. <parameter expr="'Browsing for model... OK'"/>
  396. </raise>
  397. </onentry>
  398. <state id="wait_for_result">
  399. <transition event="browse_result" cond="result not in self.allowed_metamodels" target="../got_result">
  400. <parameter name="result"/>
  401. <script>
  402. global current_metamodel
  403. current_metamodel = result
  404. </script>
  405. </transition>
  406. <transition event="close_window" target="../../../idle">
  407. <raise event="delete_instance" scope="cd">
  408. <parameter expr="self.subwindow"/>
  409. </raise>
  410. </transition>
  411. </state>
  412. <state id="got_result">
  413. <transition event="close_window" target="../mv_processing">
  414. <raise event="delete_instance" scope="cd">
  415. <parameter expr="self.subwindow"/>
  416. </raise>
  417. <raise event="mv_request" scope="broad">
  418. <parameter expr="'conformance_add'"/>
  419. <parameter expr="[current_model, current_metamodel]"/>
  420. </raise>
  421. </transition>
  422. </state>
  423. <state id="mv_processing">
  424. <transition event="mv_response" target="../../../open_model/search_metamodels"/>
  425. </state>
  426. </state>
  427. </state>
  428. <state id="change_mapper">
  429. <transition target="../open_model/search_CS_mappers"/>
  430. </state>
  431. <state id="change_rendered">
  432. <transition target="../rerender_model"/>
  433. </state>
  434. <state id="verify_model" initial="request">
  435. <state id="request">
  436. <onentry>
  437. <raise event="mv_request" scope="broad">
  438. <parameter expr="'verify'"/>
  439. <parameter expr="[current_model, current_metamodel]"/>
  440. </raise>
  441. </onentry>
  442. <transition event="mv_progress" target=".">
  443. <parameter name="result"/>
  444. <raise event="update_status" scope="narrow" target="'progress_bar'">
  445. <parameter expr="result * 100"/>
  446. <parameter expr="'Verifying...'"/>
  447. </raise>
  448. </transition>
  449. <transition event="mv_response" target="../show_result">
  450. <parameter name="result"/>
  451. <raise event="create_instance" scope="cd">
  452. <parameter expr="'subwindow'"/>
  453. <parameter expr="'Popup'"/>
  454. <parameter expr="result"/>
  455. </raise>
  456. </transition>
  457. </state>
  458. <state id="show_result">
  459. <transition event="instance_created" target="../wait_for_close">
  460. <parameter name="assoc_name"/>
  461. <raise event="start_instance" scope="cd">
  462. <parameter expr="assoc_name"/>
  463. </raise>
  464. </transition>
  465. </state>
  466. <state id="wait_for_close">
  467. <transition event="close_window" target="../../idle">
  468. <raise event="delete_instance" scope="cd">
  469. <parameter expr="'subwindow'"/>
  470. </raise>
  471. </transition>
  472. </state>
  473. </state>
  474. <state id="open_model" initial="query_model">
  475. <state id="query_model">
  476. <onentry>
  477. <raise event="create_instance" scope="cd">
  478. <parameter expr="'subwindow'"/>
  479. <parameter expr="'Browser'"/>
  480. <parameter expr="'Select model to open'"/>
  481. <parameter expr="[]"/>
  482. </raise>
  483. <raise event="update_status" scope="narrow" target="'progress_bar'">
  484. <parameter expr="0"/>
  485. <parameter expr="'Browsing for model...'"/>
  486. </raise>
  487. </onentry>
  488. <transition event="instance_created" target="../wait_for_model">
  489. <parameter name="association_name"/>
  490. <raise event="start_instance" scope="cd">
  491. <parameter expr="association_name"/>
  492. </raise>
  493. <script>
  494. self.subwindow = association_name
  495. </script>
  496. </transition>
  497. </state>
  498. <state id="wait_for_model">
  499. <transition event="close_window" target="../../idle">
  500. <raise event="delete_instance" scope="cd">
  501. <parameter expr="self.subwindow"/>
  502. </raise>
  503. <raise event="update_status" scope="narrow" target="'progress_bar'">
  504. <parameter expr="10"/>
  505. <parameter expr="'Browsing for model... OK'"/>
  506. </raise>
  507. </transition>
  508. <transition event="browse_result" target="../got_model">
  509. <parameter name="result"/>
  510. <script>
  511. global current_model
  512. current_model = result
  513. </script>
  514. </transition>
  515. </state>
  516. <state id="got_model">
  517. <transition event="close_window" target="../search_metamodels">
  518. <raise event="delete_instance" scope="cd">
  519. <parameter expr="self.subwindow"/>
  520. </raise>
  521. </transition>
  522. </state>
  523. <state id="search_metamodels">
  524. <onentry>
  525. <raise event="mv_request" scope="broad">
  526. <parameter expr="'model_types'"/>
  527. <parameter expr="[current_model]"/>
  528. </raise>
  529. <raise event="update_status" scope="narrow" target="'progress_bar'">
  530. <parameter expr="10"/>
  531. <parameter expr="'Querying existing metamodels...'"/>
  532. </raise>
  533. </onentry>
  534. <transition event="mv_response" target="../search_CS_mappers">
  535. <parameter name="result"/>
  536. <script>
  537. global current_metamodel
  538. print("Allowed metamodels: " + str(result))
  539. if len(result) > 0:
  540. current_metamodel = next(iter(result))
  541. else:
  542. current_metamodel = 'formalisms/Bottom'
  543. self.allowed_metamodels = result
  544. </script>
  545. <raise event="update_status" scope="narrow" target="'progress_bar'">
  546. <parameter expr="20"/>
  547. <parameter expr="'Querying existing metamodels... OK'"/>
  548. </raise>
  549. </transition>
  550. </state>
  551. <state id="search_CS_mappers">
  552. <onentry>
  553. <raise event="mv_request" scope="broad">
  554. <parameter expr="'transformation_between'"/>
  555. <parameter expr="[{'abstract': current_metamodel, 'rendered': 'formalisms/MM_render'}, {'rendered': 'formalisms/MM_render'}]"/>
  556. </raise>
  557. <script>
  558. print("Finding transformation with current MM: " + current_metamodel)
  559. </script>
  560. </onentry>
  561. <transition event="mv_response" target="../check_CS_mapper">
  562. <parameter name="result"/>
  563. <script>
  564. print("MM: " + str(current_metamodel))
  565. print("Allowed mappers: " + str(result))
  566. self.allowed_mappers = list(result)
  567. global current_mapper
  568. if len(result) > 0:
  569. if current_mapper not in result:
  570. current_mapper = next(iter(result))
  571. print("CHANGING MAPPER TO " + str(current_mapper))
  572. else:
  573. current_mapper = None
  574. print("REMOVING MAPPER")
  575. </script>
  576. </transition>
  577. </state>
  578. <state id="check_CS_mapper">
  579. <transition cond="current_mapper is None" target="../../rerender_model">
  580. <script>
  581. global current_rendered_model
  582. current_rendered_model = None
  583. self.allowed_rendered = []
  584. </script>
  585. <raise event="clear_canvas" scope="narrow" target="'canvas'"/>
  586. </transition>
  587. <transition cond="current_mapper is not None" target="../search_CS_rendered"/>
  588. </state>
  589. <state id="search_CS_rendered">
  590. <onentry>
  591. <raise event="mv_request" scope="broad">
  592. <parameter expr="'model_rendered'"/>
  593. <parameter expr="[current_model, current_mapper]"/>
  594. </raise>
  595. </onentry>
  596. <transition event="mv_response" target="../store_metamodel">
  597. <parameter name="result"/>
  598. <script>
  599. print("Allowed rendered: " + str(result))
  600. print("Current mapper: " + str(current_mapper))
  601. self.allowed_rendered = list(result)
  602. global current_rendered_model
  603. if (len(result) > 0):
  604. if current_rendered_model not in result:
  605. print("Reusing an existing rendered model")
  606. current_rendered_model = next(iter(result))
  607. else:
  608. print("Creating new rendered model!")
  609. current_rendered_model = "rendered/%s" % str(uuid.uuid4())
  610. self.allowed_rendered.append(current_rendered_model)
  611. </script>
  612. </transition>
  613. </state>
  614. <state id="store_metamodel">
  615. <onentry>
  616. <raise event="mv_request" scope="broad">
  617. <parameter expr="'alter_context'"/>
  618. <parameter expr="[current_model, current_metamodel]"/>
  619. </raise>
  620. <raise event="update_status" scope="narrow" target="'progress_bar'">
  621. <parameter expr="45"/>
  622. <parameter expr="'Storing model context...'"/>
  623. </raise>
  624. </onentry>
  625. <transition event="mv_response" target="../../rerender_model"/>
  626. </state>
  627. </state>
  628. <state id="new_rendered">
  629. <onentry>
  630. <script>
  631. global current_rendered_model
  632. current_rendered_model = "rendered/%s" % str(uuid.uuid4())
  633. self.allowed_rendered.append(current_rendered_model)
  634. </script>
  635. </onentry>
  636. <transition target="../rerender_model"/>
  637. </state>
  638. <state id="create_new_model" initial="query_metamodel">
  639. <state id="query_metamodel">
  640. <onentry>
  641. <raise event="create_instance" scope="cd">
  642. <parameter expr="'subwindow'"/>
  643. <parameter expr="'Browser'"/>
  644. <parameter expr="'Select metamodel to instantiate'"/>
  645. <parameter expr="['formalisms/SimpleClassDiagrams']"/>
  646. </raise>
  647. <raise event="update_status" scope="narrow" target="'progress_bar'">
  648. <parameter expr="5"/>
  649. <parameter expr="'Browsing for metamodel...'"/>
  650. </raise>
  651. </onentry>
  652. <transition event="instance_created" target="../wait_for_metamodel">
  653. <parameter name="association_name"/>
  654. <raise event="start_instance" scope="cd">
  655. <parameter expr="association_name"/>
  656. </raise>
  657. <script>
  658. self.subwindow = association_name
  659. </script>
  660. </transition>
  661. </state>
  662. <state id="wait_for_metamodel">
  663. <transition event="close_window" target="../../idle">
  664. <raise event="delete_instance" scope="cd">
  665. <parameter expr="self.subwindow"/>
  666. </raise>
  667. </transition>
  668. <transition event="browse_result" target="../got_mm">
  669. <parameter name="result"/>
  670. <script>
  671. global current_metamodel
  672. current_metamodel = result
  673. </script>
  674. </transition>
  675. </state>
  676. <state id="got_mm">
  677. <transition event="close_window" target="../prompt_model_name">
  678. <raise event="delete_instance" scope="cd">
  679. <parameter expr="self.subwindow"/>
  680. </raise>
  681. </transition>
  682. </state>
  683. <state id="prompt_model_name">
  684. <onentry>
  685. <raise event="create_instance" scope="cd">
  686. <parameter expr="'subwindow'"/>
  687. <parameter expr="'PromptWindow'"/>
  688. <parameter expr="{'Model name': ''}"/>
  689. <parameter expr="{}"/>
  690. </raise>
  691. <raise event="update_status" scope="narrow" target="'progress_bar'">
  692. <parameter expr="15"/>
  693. <parameter expr="'Prompt model name...'"/>
  694. </raise>
  695. </onentry>
  696. <transition event="instance_created" target="../waiting_for_model_name">
  697. <parameter name="association_name"/>
  698. <raise event="start_instance" scope="cd">
  699. <parameter expr="association_name"/>
  700. </raise>
  701. <script>
  702. global current_model
  703. self.subwindow = association_name
  704. current_model = ""
  705. </script>
  706. </transition>
  707. </state>
  708. <state id="waiting_for_model_name">
  709. <transition event="prompt_results" target=".">
  710. <parameter name="results"/>
  711. <script>
  712. global current_model
  713. current_model = results["Model name"]
  714. </script>
  715. </transition>
  716. <transition event="close_window" cond="current_model != ''" target="../creating_model">
  717. <raise event="delete_instance" scope="cd">
  718. <parameter expr="self.subwindow"/>
  719. </raise>
  720. </transition>
  721. <transition event="close_window" cond="current_model == ''" target="../../idle">
  722. <raise event="delete_instance" scope="cd">
  723. <parameter expr="self.subwindow"/>
  724. </raise>
  725. </transition>
  726. </state>
  727. <state id="creating_model">
  728. <onentry>
  729. <raise event="mv_request" scope="broad">
  730. <parameter expr="'model_add'"/>
  731. <parameter expr="[current_model, current_metamodel, '']"/>
  732. </raise>
  733. <raise event="update_status" scope="narrow" target="'progress_bar'">
  734. <parameter expr="25"/>
  735. <parameter expr="'Creating empty model...'"/>
  736. </raise>
  737. </onentry>
  738. <transition event="mv_response" target="../../open_model/search_metamodels">
  739. <raise event="update_status" scope="narrow" target="'progress_bar'">
  740. <parameter expr="50"/>
  741. <parameter expr="'Creating empty model... OK'"/>
  742. </raise>
  743. </transition>
  744. </state>
  745. </state>
  746. <state id="rerender_model" initial="initial_render">
  747. <state id="initial_render">
  748. <transition cond="self.model_loaded" target="../recreate_toolbars"/>
  749. <transition cond="not self.model_loaded" target="../canvas">
  750. <script>
  751. self.model_loaded = True
  752. </script>
  753. </transition>
  754. </state>
  755. <state id="recreate_toolbars" initial="waiting">
  756. <onentry>
  757. <raise event="close" scope="narrow" target="'model_toolbars'"/>
  758. <script>
  759. self.nr_toolbars = 3
  760. </script>
  761. </onentry>
  762. <state id="waiting">
  763. <transition event="close_window" target=".">
  764. <script>
  765. self.nr_toolbars -= 1
  766. </script>
  767. </transition>
  768. <transition cond="self.nr_toolbars == 0" target="../close_all"/>
  769. </state>
  770. <state id="close_all">
  771. <transition target="../../model_toolbars">
  772. <raise event="delete_instance" scope="cd">
  773. <parameter expr="'model_toolbars'"/>
  774. </raise>
  775. </transition>
  776. </state>
  777. </state>
  778. <state id="canvas">
  779. <onentry>
  780. <raise event="create_instance" scope="cd">
  781. <parameter expr="'canvas'"/>
  782. <parameter expr="'Canvas'"/>
  783. <parameter expr="self.canvas_frame"/>
  784. </raise>
  785. </onentry>
  786. <transition event="instance_created" target="../pack_canvas">
  787. <parameter name="association_name"/>
  788. <raise event="start_instance" scope="cd">
  789. <parameter expr="association_name"/>
  790. </raise>
  791. </transition>
  792. </state>
  793. <state id="pack_canvas">
  794. <transition event="tk_widget" target="../model_toolbars">
  795. <parameter name="tk_elem"/>
  796. <script>
  797. tk_elem.pack(fill=tk.BOTH, expand=tk.TRUE)
  798. </script>
  799. </transition>
  800. </state>
  801. <state id="model_toolbars" initial="mm_toolbar">
  802. <state id="mm_toolbar">
  803. <onentry>
  804. <raise event="create_instance" scope="cd">
  805. <parameter expr="'model_toolbars'"/>
  806. <parameter expr="'MetamodellingToolbar'"/>
  807. <parameter expr="self.toolbar_frame"/>
  808. <parameter expr="current_metamodel"/>
  809. <parameter expr="self.allowed_metamodels"/>
  810. </raise>
  811. </onentry>
  812. <transition event="instance_created" target="../pack_mm_toolbar">
  813. <parameter name="association_name"/>
  814. <raise event="start_instance" scope="cd">
  815. <parameter expr="association_name"/>
  816. </raise>
  817. </transition>
  818. </state>
  819. <state id="pack_mm_toolbar">
  820. <transition event="tk_widget" target="../cs_toolbar">
  821. <parameter name="tk_elem"/>
  822. <script>
  823. tk_elem.pack(anchor=tk.W)
  824. </script>
  825. </transition>
  826. </state>
  827. <state id="cs_toolbar">
  828. <onentry>
  829. <raise event="create_instance" scope="cd">
  830. <parameter expr="'model_toolbars'"/>
  831. <parameter expr="'ConcreteSyntaxToolbar'"/>
  832. <parameter expr="self.toolbar_frame"/>
  833. <parameter expr="self.allowed_mappers"/>
  834. <parameter expr="self.allowed_rendered"/>
  835. </raise>
  836. </onentry>
  837. <transition event="instance_created" target="../pack_cs_toolbar">
  838. <parameter name="association_name"/>
  839. <raise event="start_instance" scope="cd">
  840. <parameter expr="association_name"/>
  841. </raise>
  842. </transition>
  843. </state>
  844. <state id="pack_cs_toolbar">
  845. <transition event="tk_widget" target="../fetch_types">
  846. <parameter name="tk_elem"/>
  847. <script>
  848. tk_elem.pack(anchor=tk.W)
  849. </script>
  850. </transition>
  851. </state>
  852. <state id="fetch_types">
  853. <onentry>
  854. <raise event="mv_request" scope="broad">
  855. <parameter expr="'types'"/>
  856. <parameter expr="[current_model]"/>
  857. </raise>
  858. </onentry>
  859. <transition event="mv_response" target="../dsl_toolbar">
  860. <parameter name="result"/>
  861. <raise event="create_instance" scope="cd">
  862. <parameter expr="'model_toolbars'"/>
  863. <parameter expr="'DSLToolbar'"/>
  864. <parameter expr="self.toolbar_frame"/>
  865. <parameter expr="result"/>
  866. </raise>
  867. </transition>
  868. </state>
  869. <state id="dsl_toolbar">
  870. <transition event="instance_created" target="../pack_dsl_toolbar">
  871. <parameter name="association_name"/>
  872. <raise event="start_instance" scope="cd">
  873. <parameter expr="association_name"/>
  874. </raise>
  875. </transition>
  876. </state>
  877. <state id="pack_dsl_toolbar">
  878. <transition event="tk_widget" cond="current_mapper is None" target="../../../idle">
  879. <parameter name="tk_elem"/>
  880. <script>
  881. tk_elem.pack(anchor=tk.W)
  882. </script>
  883. </transition>
  884. <transition event="tk_widget" cond="current_mapper is not None" target="../../request_render">
  885. <parameter name="tk_elem"/>
  886. <script>
  887. tk_elem.pack(anchor=tk.W)
  888. </script>
  889. </transition>
  890. </state>
  891. </state>
  892. <state id="request_render">
  893. <onentry>
  894. <raise event="mv_request" scope="broad">
  895. <parameter expr="'model_render'"/>
  896. <parameter expr="[current_model, current_mapper, current_rendered_model]"/>
  897. </raise>
  898. <raise event="update_status" scope="narrow" target="'progress_bar'">
  899. <parameter expr="50"/>
  900. <parameter expr="'Perceptualizing model...'"/>
  901. </raise>
  902. </onentry>
  903. <transition event="mv_response" target="../render_model">
  904. <parameter name="result"/>
  905. <script>
  906. self.rendered = result
  907. </script>
  908. </transition>
  909. <transition event="mv_exception" target="../../../close"/>
  910. </state>
  911. <state id="render_model" initial="allocate_groups">
  912. <onentry>
  913. <raise event="update_status" scope="narrow" target="'progress_bar'">
  914. <parameter expr="80"/>
  915. <parameter expr="'Perceptualizing model... OK'"/>
  916. </raise>
  917. <raise event="clear_canvas" scope="narrow" target="'canvas'"/>
  918. <script>
  919. self.groups = [i for i in self.rendered if i["type"] == "Group"]
  920. self.contains = [i for i in self.rendered if i["type"] == "contains"]
  921. self.rendered = [i for i in self.rendered if i["type"] not in ["Group", "contains"]]
  922. self.rendered.reverse()
  923. </script>
  924. <raise event="mv_request" scope="broad">
  925. <parameter expr="'alter_context'"/>
  926. <parameter expr="[current_rendered_model, 'formalisms/MM_render']"/>
  927. </raise>
  928. </onentry>
  929. <state id="allocate_groups">
  930. <transition cond="len(self.groups) > 0" target="../allocating_group">
  931. <raise event="define_group" scope="narrow" target="'canvas'">
  932. <parameter expr="self.groups.pop()"/>
  933. </raise>
  934. </transition>
  935. <transition cond="len(self.groups) == 0" target="../allocate_contains"/>
  936. </state>
  937. <state id="allocating_group">
  938. <transition event="group_ready" target="../allocate_groups"/>
  939. </state>
  940. <state id="allocate_contains">
  941. <transition cond="len(self.contains) > 0" target=".">
  942. <raise event="define_contains" scope="narrow" target="'canvas'">
  943. <parameter expr="self.contains.pop()"/>
  944. </raise>
  945. </transition>
  946. <transition cond="len(self.contains) == 0" target="../render_elements"/>
  947. </state>
  948. <state id="render_elements">
  949. <transition cond="len(self.rendered) > 0" target=".">
  950. <raise event="draw_canvas" scope="narrow" target="'canvas'">
  951. <parameter expr="self.rendered.pop()"/>
  952. </raise>
  953. </transition>
  954. <transition cond="len(self.rendered) == 0" target="../../../idle"/>
  955. </state>
  956. </state>
  957. </state>
  958. <transition event="window-close" cond="ID == id(self)" target="../close">
  959. <parameter name="ID"/>
  960. </transition>
  961. </state>
  962. <state id="close">
  963. <onentry>
  964. <raise event="close_window" scope="narrow" target="'parent'"/>
  965. </onentry>
  966. </state>
  967. </state>
  968. <state id="key_status">
  969. <onentry>
  970. <script>
  971. global control_pressed
  972. control_pressed = False
  973. </script>
  974. </onentry>
  975. <state id="listening">
  976. <transition event="control" target=".">
  977. <script>
  978. global control_pressed
  979. control_pressed = True
  980. </script>
  981. </transition>
  982. <transition event="control-release" target=".">
  983. <script>
  984. global control_pressed
  985. control_pressed = False
  986. </script>
  987. </transition>
  988. </state>
  989. </state>
  990. </parallel>
  991. </scxml>
  992. </class>