main_window.xml 43 KB

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