1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339 |
- <class name="MainWindow">
- <relationships>
- <inheritance class="tk.Toplevel" priority="1"/>
- <inheritance class="SCCDWidget" priority="0"/>
- <association name="parent" class="A"/>
- <association name="generic_toolbars" class="Toolbar"/>
- <association name="model_toolbars" class="Toolbar"/>
- <association name="subwindow" class="Window"/>
- <association name="canvas" class="Canvas"/>
- <association name="error_log" class="Errorlog"/>
- <association name="progress_bar" class="ProgressBar"/>
- </relationships>
- <constructor>
- <super class="tk.Toplevel"/>
- <super class="SCCDWidget"/>
- <parameter name="open_model"/>
- <parameter name="limited_mode"/>
- <body>
- self.toolbar_frame = tk.Frame(self)
- self.progressbar_frame = tk.Frame(self)
- self.modelling_frame = tk.Frame(self)
- self.canvas_frame = tk.Frame(self.modelling_frame)
- self.error_log_frame = tk.Frame(self.modelling_frame)
- self.toolbar_frame.pack(fill=tk.X)
- self.modelling_frame.pack(fill=tk.BOTH, expand=tk.TRUE)
- self.canvas_frame.pack(fill=tk.BOTH, expand=tk.TRUE, side=tk.LEFT)
- self.error_log_frame.pack(fill=tk.Y, expand=tk.FALSE, side=tk.RIGHT, anchor=tk.E)
- self.progressbar_frame.pack(fill=tk.X)
- self.model_loaded = False
- self.preload_model = open_model
- self.limited_mode = limited_mode
- global current_mapper
- current_mapper = None
- global current_rendered_model
- current_rendered_model = None
- global current_metamodel
- current_metamodel = None
- global current_model
- current_model = None
- </body>
- </constructor>
- <destructor>
- <body>
- self.destroy()
- </body>
- </destructor>
- <scxml initial="init">
- <parallel id="init">
- <state id="init" initial="init">
- <state id="init" initial="determine_initial">
- <state id="determine_initial">
- <transition cond="self.limited_mode" target="../progressbar"/>
- <transition cond="not self.limited_mode" target="../generic_toolbar"/>
- </state>
- <state id="generic_toolbar">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'generic_toolbars'"/>
- <parameter expr="'GenericToolbar'"/>
- <parameter expr="self.toolbar_frame"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../pack_generic">
- <parameter name="association_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="association_name"/>
- </raise>
- </transition>
- </state>
-
- <state id="pack_generic">
- <transition event="tk_widget" target="../progressbar">
- <parameter name="tk_elem"/>
- <script>
- tk_elem.pack(anchor=tk.NW)
- </script>
- </transition>
- </state>
- <state id="progressbar">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'progress_bar'"/>
- <parameter expr="'ProgressBar'"/>
- <parameter expr="{'parent': self.progressbar_frame}"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../pack_progressbar">
- <parameter name="association_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="association_name"/>
- </raise>
- </transition>
- </state>
- <state id="pack_progressbar">
- <transition event="tk_widget" target="../error_log">
- <parameter name="tk_elem"/>
- <script>
- tk_elem.pack(side=tk.BOTTOM, fill=tk.X, expand=tk.TRUE)
- print("Pack progress")
- </script>
- </transition>
- </state>
- <state id="error_log">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'error_log'"/>
- <parameter expr="'Errorlog'"/>
- <parameter expr="{'parent': self.error_log_frame}"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../../running">
- <parameter name="association_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="association_name"/>
- </raise>
- <script>
- print("Packed errorlog")
- </script>
- </transition>
- </state>
- </state>
- <state id="running" initial="idle">
- <state id="idle">
- <onentry>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="0"/>
- <parameter expr="'Ready for action!'"/>
- </raise>
- </onentry>
- <transition event="create_new_model" target="../create_new_model"/>
- <transition event="open_model" target="../open_model"/>
- <transition event="rerender_model" target="../rerender_model"/>
- <transition event="minimal_rerender_model" target="../rerender_model/request_render"/>
- <transition event="new_rendered" cond="current_mapper is not None" target="../new_rendered"/>
- <transition event="verify" target="../verify_model"/>
- <transition event="conf_bottom" target="../conf_bottom"/>
- <transition event="custom_MM" target="../custom_MM"/>
- <transition event="upload_MVC" target="../upload_MVC"/>
- <transition event="add_object_diagrams" target="../add_object_diagrams"/>
- <transition event="activity" target="../execute_activity"/>
- <transition event="create_activity" target="../create_activity"/>
- <transition event="enact_process" target="../enact_process"/>
- <transition event="modify_defined_attrs" target="../modify_defined_attrs">
- <parameter name="as_element"/>
- <parameter name="cs_element"/>
- <script>
- self.as_element = as_element
- self.cs_element = cs_element
- </script>
- </transition>
- <transition event="change_metamodel" target="../change_metamodel">
- <parameter name="new_metamodel"/>
- <script>
- global current_metamodel
- current_metamodel = new_metamodel
- </script>
- </transition>
- <transition event="change_mapper" target="../change_mapper">
- <parameter name="new_mapper"/>
- <script>
- global current_mapper
- if new_mapper == "(none)":
- current_mapper = None
- else:
- current_mapper = new_mapper
- </script>
- </transition>
- <transition event="change_rendered" target="../change_rendered">
- <parameter name="new_rendered"/>
- <script>
- global current_rendered_model
- current_rendered_model = new_rendered
- </script>
- </transition>
- <transition event="select_for_creation" target=".">
- <parameter name="element_name"/>
- <raise event="select_for_creation" scope="narrow" target="'canvas'">
- <parameter expr="element_name"/>
- </raise>
- </transition>
- <transition cond="self.preload_model is not None" target="../open_model/search_metamodels">
- <script>
- global current_model
- current_model = self.preload_model
- self.preload_model = None
- self.locations = {}
- </script>
- </transition>
- </state>
- <state id="modify_defined_attrs" initial="create_window">
- <state id="create_window">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'subwindow'"/>
- <parameter expr="'AttributeEditor'"/>
- <parameter expr="self.as_element"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../wait_for_finished">
- <parameter name="assoc_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="assoc_name"/>
- </raise>
- <script>
- self.current_window = assoc_name
- </script>
- </transition>
- </state>
- <state id="wait_for_finished">
- <transition event="close_window" cond="current_rendered_model is not None" target="../mark_dirty">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.current_window"/>
- </raise>
- </transition>
- <transition event="close_window" cond="current_rendered_model is None" target="../../rerender_model/request_render">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.current_window"/>
- </raise>
- </transition>
- </state>
- <state id="mark_dirty">
- <onentry>
- <raise event="mv_request" scope="broad">
- <parameter expr="'attr_assign'"/>
- <parameter expr="[current_rendered_model, self.cs_element, 'dirty', True]"/>
- </raise>
- </onentry>
- <transition event="mv_response" target="../../rerender_model/request_render"/>
- </state>
- </state>
- <state id="execute_activity" initial="open_window">
- <state id="open_window">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'subwindow'"/>
- <parameter expr="'ActivityExecutor'"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../waiting">
- <parameter name="assoc_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="assoc_name"/>
- </raise>
- <script>
- self.activity_executor = assoc_name
- </script>
- </transition>
- </state>
- <state id="waiting">
- <transition event="window_close" target="../../idle">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.activity_executor"/>
- </raise>
- </transition>
- </state>
- </state>
- <state id="create_activity" initial="open_window">
- <state id="open_window">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'subwindow'"/>
- <parameter expr="'ActivityCreator'"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../waiting">
- <parameter name="assoc_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="assoc_name"/>
- </raise>
- <script>
- self.activity_creator = assoc_name
- </script>
- </transition>
- </state>
- <state id="waiting">
- <transition event="close_window" target="../../idle">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.activity_creator"/>
- </raise>
- </transition>
- </state>
- </state>
- <state id="enact_process" initial="open_window">
- <state id="open_window">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'subwindow'"/>
- <parameter expr="'ProcessEnactor'"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../waiting">
- <parameter name="assoc_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="assoc_name"/>
- </raise>
- <script>
- self.process_enactor = assoc_name
- </script>
- </transition>
- </state>
- <state id="waiting">
- <transition event="window_close" target="../../idle">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.process_enactor"/>
- </raise>
- </transition>
- </state>
- </state>
- <state id="add_object_diagrams" initial="init">
- <state id="init">
- <onentry>
- <script>
- self.subprocess = subprocess.Popen([sys.executable, "add_render_OD.py", current_metamodel])
- </script>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="10"/>
- <parameter expr="'Adding transformation...'"/>
- </raise>
- </onentry>
- <transition cond="self.subprocess.poll() is not None" target="../../open_model/search_CS_mappers">
- <script>
- global current_mapper
- current_mapper = 'models/render_OD/' + current_metamodel
- </script>
- </transition>
- </state>
- </state>
- <state id="upload_MVC" initial="load_code">
- <state id="load_code">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'subwindow'"/>
- <parameter expr="'FileBrowser'"/>
- <parameter expr="'Select model code.'"/>
- </raise>
- <script>
- self.filename = None
- </script>
- </onentry>
-
- <transition event="instance_created" target="../waiting">
- <parameter name="result"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="result"/>
- </raise>
- </transition>
- </state>
- <state id="waiting">
- <transition event="browse_result" target=".">
- <parameter name="result"/>
- <script>
- self.filename = result
- </script>
- </transition>
- <transition event="close_window" target="../got_filename">
- <raise event="delete_instance" scope="cd">
- <parameter expr="'subwindow'"/>
- </raise>
- </transition>
- </state>
- <state id="got_filename">
- <transition cond="self.filename is not None" target="../overwriting_model">
- <raise event="mv_request" scope="broad">
- <parameter expr="'model_overwrite'"/>
- <parameter expr="[current_model, open(self.filename, 'r').read()]"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="10"/>
- <parameter expr="'Uploading model...'"/>
- </raise>
- </transition>
- <transition cond="self.filename is None" target="../../idle"/>
- </state>
- <state id="overwriting_model">
- <transition event="mv_response" target="../../rerender_model">
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="50"/>
- <parameter expr="'Rerendering model...'"/>
- </raise>
- </transition>
- </state>
- </state>
- <state id="change_metamodel">
- <onentry>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="20"/>
- <parameter expr="'Storing model context...'"/>
- </raise>
- <raise event="mv_request" scope="broad">
- <parameter expr="'alter_context'"/>
- <parameter expr="[current_model, current_metamodel]"/>
- </raise>
- </onentry>
- <transition target="../open_model/search_CS_mappers"/>
- </state>
- <state id="conf_bottom" initial="check_if_exists">
- <state id="check_if_exists">
- <transition cond="'formalisms/Bottom' in self.allowed_metamodels" target="../../idle"/>
- <transition cond="'formalisms/Bottom' not in self.allowed_metamodels" target="../add_bottom"/>
- </state>
- <state id="add_bottom">
- <onentry>
- <raise event="mv_request" scope="broad">
- <parameter expr="'conformance_add'"/>
- <parameter expr="[current_model, 'formalisms/Bottom']"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="10"/>
- <parameter expr="'Storing model context...'"/>
- </raise>
- <script>
- global current_metamodel
- current_metamodel = 'formalisms/Bottom'
- </script>
- </onentry>
- <transition event="mv_response" target="../../open_model/search_metamodels"/>
- </state>
- </state>
- <state id="custom_MM" initial="query">
- <state id="query">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'subwindow'"/>
- <parameter expr="'Browser'"/>
- <parameter expr="'Select metamodel to use.'"/>
- <parameter expr="['formalisms/SimpleClassDiagrams']"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="0"/>
- <parameter expr="'Browsing for metamodel...'"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../wait_for_metamodel">
- <parameter name="association_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="association_name"/>
- </raise>
- <script>
- self.subwindow = association_name
- </script>
- </transition>
- </state>
- <state id="wait_for_metamodel" initial="wait_for_result">
- <onentry>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="10"/>
- <parameter expr="'Browsing for model... OK'"/>
- </raise>
- </onentry>
- <state id="wait_for_result">
- <transition event="browse_result" cond="result not in self.allowed_metamodels" target="../got_result">
- <parameter name="result"/>
- <script>
- global current_metamodel
- current_metamodel = result
- </script>
- <raise event="mv_request" scope="broad">
- <parameter expr="'alter_context'"/>
- <parameter expr="[current_model, current_metamodel]"/>
- </raise>
- </transition>
- <transition event="close_window" target="../../../idle">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.subwindow"/>
- </raise>
- </transition>
- </state>
- <state id="got_result">
- <transition event="close_window" target="../mv_processing">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.subwindow"/>
- </raise>
- <raise event="mv_request" scope="broad">
- <parameter expr="'conformance_add'"/>
- <parameter expr="[current_model, current_metamodel]"/>
- </raise>
- </transition>
- </state>
- <state id="mv_processing">
- <transition event="mv_response" target="../../../open_model/search_metamodels"/>
- </state>
- </state>
- </state>
- <state id="change_mapper">
- <transition target="../open_model/search_CS_mappers"/>
- </state>
- <state id="change_rendered">
- <transition target="../rerender_model"/>
- </state>
- <state id="verify_model" initial="request">
- <state id="request">
- <onentry>
- <raise event="mv_request" scope="broad">
- <parameter expr="'verify'"/>
- <parameter expr="[current_model, current_metamodel]"/>
- </raise>
- </onentry>
- <transition event="mv_progress" target=".">
- <parameter name="result"/>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="result * 100"/>
- <parameter expr="'Verifying...'"/>
- </raise>
- </transition>
- <transition event="mv_response" target="../show_result">
- <parameter name="result"/>
- <raise event="create_instance" scope="cd">
- <parameter expr="'subwindow'"/>
- <parameter expr="'Popup'"/>
- <parameter expr="result"/>
- </raise>
- </transition>
- </state>
- <state id="show_result">
- <transition event="instance_created" target="../wait_for_close">
- <parameter name="assoc_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="assoc_name"/>
- </raise>
- </transition>
- </state>
- <state id="wait_for_close">
- <transition event="close_window" target="../../idle">
- <raise event="delete_instance" scope="cd">
- <parameter expr="'subwindow'"/>
- </raise>
- </transition>
- </state>
- </state>
- <state id="open_model" initial="query_model">
- <state id="query_model">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'subwindow'"/>
- <parameter expr="'Browser'"/>
- <parameter expr="'Select model to open'"/>
- <parameter expr="[]"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="0"/>
- <parameter expr="'Browsing for model...'"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../wait_for_model">
- <parameter name="association_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="association_name"/>
- </raise>
- <script>
- self.subwindow = association_name
- </script>
- </transition>
- </state>
- <state id="wait_for_model">
- <transition event="close_window" target="../../idle">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.subwindow"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="10"/>
- <parameter expr="'Browsing for model... OK'"/>
- </raise>
- </transition>
- <transition event="browse_result" target="../got_model">
- <parameter name="result"/>
- <script>
- global current_model
- current_model = result
- self.locations = {}
- </script>
- </transition>
- </state>
- <state id="got_model">
- <transition event="close_window" target="../search_metamodels">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.subwindow"/>
- </raise>
- </transition>
- </state>
- <state id="search_metamodels">
- <onentry>
- <raise event="mv_request" scope="broad">
- <parameter expr="'model_types'"/>
- <parameter expr="[current_model]"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="10"/>
- <parameter expr="'Querying existing metamodels...'"/>
- </raise>
- </onentry>
- <transition event="mv_response" target="../search_CS_mappers">
- <parameter name="result"/>
- <script>
- global current_metamodel
- if len(result) > 0:
- current_metamodel = next(iter(result))[0]
- else:
- current_metamodel = 'formalisms/Bottom'
- self.allowed_metamodels = set([i[0] for i in result])
- </script>
- <raise event="mv_request" scope="broad">
- <parameter expr="'alter_context'"/>
- <parameter expr="[current_model, current_metamodel]"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="20"/>
- <parameter expr="'Querying existing metamodels... OK'"/>
- </raise>
- </transition>
- </state>
- <state id="search_CS_mappers">
- <onentry>
- <raise event="mv_request" scope="broad">
- <parameter expr="'transformation_between'"/>
- <parameter expr="[{'abstract': current_metamodel, 'rendered': 'formalisms/MM_render/graphical'}, {'rendered': 'formalisms/MM_render/graphical'}]"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="25"/>
- <parameter expr="'Querying available Concrete Syntax mappers...'"/>
- </raise>
- </onentry>
- <transition event="mv_response" target="../check_CS_mapper">
- <parameter name="result"/>
- <script>
- result.add("(none)")
- self.allowed_mappers = list(result)
- global current_mapper
- if current_mapper is None:
- current_mapper = None
- elif current_mapper not in result:
- current_mapper = next(iter(result))
- if current_mapper == "(none)":
- current_mapper = None
- </script>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="30"/>
- <parameter expr="'Querying available Concrete Syntax mappers... OK'"/>
- </raise>
- </transition>
- <transition event="mv_exception" target="../check_CS_mapper">
- <script>
- self.allowed_mappers = ["(none)"]
- global current_mapper
- current_mapper = None
- </script>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="30"/>
- <parameter expr="'Querying available Concrete Syntax mappers... OK'"/>
- </raise>
- </transition>
- </state>
- <state id="check_CS_mapper">
- <transition cond="current_mapper is None" target="../../rerender_model">
- <script>
- global current_rendered_model
- current_rendered_model = None
- self.allowed_rendered = []
- </script>
- <raise event="clear_canvas" scope="narrow" target="'canvas'"/>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="35"/>
- <parameter expr="'Rendering model with internal renderer...'"/>
- </raise>
- </transition>
- <transition cond="current_mapper is not None" target="../search_CS_rendered"/>
- </state>
- <state id="search_CS_rendered">
- <onentry>
- <raise event="mv_request" scope="broad">
- <parameter expr="'model_rendered'"/>
- <parameter expr="[current_model, current_mapper]"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="35"/>
- <parameter expr="'Rendering model with custom renderer...'"/>
- </raise>
- </onentry>
- <transition event="mv_response" target="../store_metamodel">
- <parameter name="result"/>
- <script>
- self.allowed_rendered = list(result)
- #self.allowed_rendered.append("(none)")
- global current_rendered_model
- if (len(result) > 0):
- if current_rendered_model not in result:
- current_rendered_model = next(iter(result))
- else:
- current_rendered_model = "rendered/%s" % str(uuid.uuid4())
- self.allowed_rendered.append(current_rendered_model)
- if current_rendered_model == "(none)":
- current_rendered_model = None
- </script>
- </transition>
- </state>
- <state id="store_metamodel">
- <onentry>
- <raise event="mv_request" scope="broad">
- <parameter expr="'alter_context'"/>
- <parameter expr="[current_model, current_metamodel]"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="45"/>
- <parameter expr="'Storing model context...'"/>
- </raise>
- </onentry>
- <transition target="../../rerender_model"/>
- </state>
- </state>
- <state id="new_rendered">
- <onentry>
- <script>
- global current_rendered_model
- current_rendered_model = "rendered/%s" % str(uuid.uuid4())
- self.allowed_rendered.append(current_rendered_model)
- </script>
- </onentry>
- <transition target="../rerender_model"/>
- </state>
- <state id="create_new_model" initial="query_metamodel">
- <state id="query_metamodel">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'subwindow'"/>
- <parameter expr="'Browser'"/>
- <parameter expr="'Select metamodel to instantiate'"/>
- <parameter expr="['formalisms/SimpleClassDiagrams']"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="5"/>
- <parameter expr="'Browsing for metamodel...'"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../wait_for_metamodel">
- <parameter name="association_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="association_name"/>
- </raise>
- <script>
- self.subwindow = association_name
- </script>
- </transition>
- </state>
- <state id="wait_for_metamodel">
- <transition event="close_window" target="../../idle">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.subwindow"/>
- </raise>
- </transition>
- <transition event="browse_result" target="../got_mm">
- <parameter name="result"/>
- <script>
- global current_metamodel
- current_metamodel = result
- </script>
- </transition>
- </state>
- <state id="got_mm">
- <transition event="close_window" target="../prompt_model_name">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.subwindow"/>
- </raise>
- </transition>
- </state>
- <state id="prompt_model_name">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'subwindow'"/>
- <parameter expr="'PromptWindow'"/>
- <parameter expr="{'Model name': ''}"/>
- <parameter expr="{}"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="15"/>
- <parameter expr="'Prompt model name...'"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../waiting_for_model_name">
- <parameter name="association_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="association_name"/>
- </raise>
- <script>
- global current_model
- self.subwindow = association_name
- current_model = ""
- self.locations = {}
- </script>
- </transition>
- </state>
- <state id="waiting_for_model_name">
- <transition event="prompt_results" target=".">
- <parameter name="results"/>
- <script>
- global current_model
- current_model = results["Model name"]
- self.locations = {}
- </script>
- </transition>
- <transition event="close_window" cond="current_model != ''" target="../creating_model">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.subwindow"/>
- </raise>
- <raise event="mv_request" scope="broad">
- <parameter expr="'alter_context'"/>
- <parameter expr="[current_model, current_metamodel]"/>
- </raise>
- </transition>
- <transition event="close_window" cond="current_model == ''" target="../../idle">
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.subwindow"/>
- </raise>
- </transition>
- </state>
- <state id="creating_model">
- <onentry>
- <raise event="mv_request" scope="broad">
- <parameter expr="'model_add'"/>
- <parameter expr="[current_model, current_metamodel, '']"/>
- </raise>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="25"/>
- <parameter expr="'Creating empty model...'"/>
- </raise>
- </onentry>
- <transition event="mv_response" target="../../open_model/search_metamodels">
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="50"/>
- <parameter expr="'Creating empty model... OK'"/>
- </raise>
- </transition>
- </state>
- </state>
- <state id="rerender_model" initial="initial_render">
- <onentry>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="50"/>
- <parameter expr="'Rendering model...'"/>
- </raise>
- </onentry>
- <state id="initial_render">
- <transition cond="self.model_loaded" target="../recreate_toolbars"/>
- <transition cond="not self.model_loaded" target="../canvas">
- <script>
- self.model_loaded = True
- </script>
- </transition>
- </state>
- <state id="recreate_toolbars" initial="waiting">
- <onentry>
- <raise event="close" scope="narrow" target="'model_toolbars'"/>
- <script>
- self.nr_toolbars = 3
- </script>
- </onentry>
- <state id="waiting">
- <transition event="close_window" target=".">
- <script>
- self.nr_toolbars -= 1
- </script>
- </transition>
- <transition cond="self.nr_toolbars == 0" target="../close_all"/>
- </state>
- <state id="close_all">
- <transition target="../../model_toolbars">
- <raise event="delete_instance" scope="cd">
- <parameter expr="'model_toolbars'"/>
- </raise>
- </transition>
- </state>
- </state>
- <state id="canvas">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'canvas'"/>
- <parameter expr="'Canvas'"/>
- <parameter expr="self.canvas_frame"/>
- </raise>
- </onentry>
-
- <transition event="instance_created" target="../pack_canvas">
- <parameter name="association_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="association_name"/>
- </raise>
- </transition>
- </state>
- <state id="pack_canvas">
- <transition event="tk_widget" target="../model_toolbars">
- <parameter name="tk_elem"/>
- <script>
- tk_elem.pack(fill=tk.BOTH, expand=tk.TRUE)
- </script>
- </transition>
- </state>
- <state id="model_toolbars" initial="mm_toolbar">
- <state id="mm_toolbar">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'model_toolbars'"/>
- <parameter expr="'MetamodellingToolbar'"/>
- <parameter expr="self.toolbar_frame"/>
- <parameter expr="current_metamodel"/>
- <parameter expr="self.allowed_metamodels"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../pack_mm_toolbar">
- <parameter name="association_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="association_name"/>
- </raise>
- </transition>
- </state>
- <state id="pack_mm_toolbar">
- <transition event="tk_widget" target="../cs_toolbar">
- <parameter name="tk_elem"/>
- <script>
- tk_elem.pack(anchor=tk.W)
- </script>
- </transition>
- </state>
- <state id="cs_toolbar">
- <onentry>
- <raise event="create_instance" scope="cd">
- <parameter expr="'model_toolbars'"/>
- <parameter expr="'ConcreteSyntaxToolbar'"/>
- <parameter expr="self.toolbar_frame"/>
- <parameter expr="self.allowed_mappers"/>
- <parameter expr="self.allowed_rendered"/>
- </raise>
- </onentry>
- <transition event="instance_created" target="../pack_cs_toolbar">
- <parameter name="association_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="association_name"/>
- </raise>
- </transition>
- </state>
- <state id="pack_cs_toolbar">
- <transition event="tk_widget" target="../fetch_types">
- <parameter name="tk_elem"/>
- <script>
- tk_elem.pack(anchor=tk.W)
- </script>
- </transition>
- </state>
- <state id="fetch_types">
- <onentry>
- <raise event="mv_request" scope="broad">
- <parameter expr="'types'"/>
- <parameter expr="[current_model]"/>
- </raise>
- </onentry>
- <transition event="mv_response" target="../dsl_toolbar">
- <parameter name="result"/>
- <raise event="create_instance" scope="cd">
- <parameter expr="'model_toolbars'"/>
- <parameter expr="'DSLToolbar'"/>
- <parameter expr="self.toolbar_frame"/>
- <parameter expr="result"/>
- </raise>
- </transition>
- </state>
- <state id="dsl_toolbar">
- <transition event="instance_created" target="../pack_dsl_toolbar">
- <parameter name="association_name"/>
- <raise event="start_instance" scope="cd">
- <parameter expr="association_name"/>
- </raise>
- </transition>
- </state>
- <state id="pack_dsl_toolbar">
- <transition event="tk_widget" target="../../request_render">
- <parameter name="tk_elem"/>
- <script>
- tk_elem.pack(anchor=tk.W)
- </script>
- </transition>
- </state>
- </state>
- <state id="request_render">
- <onentry>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="50"/>
- <parameter expr="'Perceptualizing model...'"/>
- </raise>
- <raise event="mv_request" scope="broad">
- <parameter expr="'model_render' if current_rendered_model else 'element_list_nice'"/>
- <parameter expr="[current_model, current_mapper, current_rendered_model] if current_rendered_model else [current_model]"/>
- </raise>
- </onentry>
- <transition event="mv_response" cond="current_rendered_model" target="../render_model">
- <parameter name="result"/>
- <script>
- self.rendered = result
- </script>
- </transition>
- <transition event="mv_response" cond="not current_rendered_model" target="../render_model">
- <parameter name="result"/>
- <script>
- self.rendered = []
- group_counter = 0
- groups = {}
- edges = []
- defined_attributes = {}
- names = {}
- if current_metamodel == "formalisms/SimpleClassDiagrams":
- for elem in result:
- if elem["__type"] == "AttributeLink":
- defined_attributes.setdefault(elem["__source"], []).append((elem["name"], elem["__target"], True if elem["optional"] == True else False))
- if "name" in elem:
- names[elem["__id"]] = elem["name"]
- for elem in list(result):
- is_edge = False
- attrs = {}
- for key, value in elem.items():
- if key == "__id":
- element_id = value
- elif key == "__source":
- element_source = value
- is_edge = True
- elif key == "__target":
- element_target = value
- is_edge = True
- elif key == "__type":
- element_type = value
- else:
- attrs[key] = value
- max_text = 0
- if is_edge:
- edge_edge = len([x for x in result if (x["__id"] == element_source or x["__id"] == element_target) and "__source" in x]) > 0
- else:
- edge_edge = False
- if is_edge:
- if not (elem["__type"] == "AttributeLink" and current_metamodel == "formalisms/SimpleClassDiagrams"):
- cs_elem_id = str(uuid.uuid4())
- edges.append({"id": cs_elem_id, "type": "ConnectingLine", "offsetSourceX": 0 if edge_edge else 100, "offsetSourceY": 0 if edge_edge else 30, "offsetTargetX": 100, "offsetTargetY": 30, "lineWidth": 3, "lineColour": "black", "arrow": True, "__asid": element_id, "layer": 0, "__source": element_source, "__target": element_target})
- groups[element_id] = cs_elem_id
- else:
- # Add the group
- x, y = self.locations.get(element_id, (30 + (group_counter * 250) % 1000, 30 + ((group_counter / 4) * 250)))
- self.rendered.append({"id": str(group_counter), "type": "Group", "x": x, "y": y, "__asid": element_id})
- self.locations[element_id] = (x, y)
- group_id = str(group_counter)
- groups[element_id] = group_id
- group_counter += 1
- # Add the text elements
- # First the header
- cs_elem_id = str(uuid.uuid4())
- self.rendered.append({"id": cs_elem_id, "type": "Text", "x": 10, "y": 10, "text": "%s : %s" % (element_id, element_type), "lineWidth": 1, "lineColour": "black", "layer": 2})
- self.rendered.append({"id": str(uuid.uuid4()), "type": "contains", "__source": group_id, "__target": cs_elem_id})
- max_text = max(len("%s : %s" % (element_id, element_type)), max_text)
- # Then the attributes
- text_counter = 1
- for name, attr_type, optional in defined_attributes.get(elem["__id"], []):
- cs_elem_id = str(uuid.uuid4())
- text = "%s : %s" % (name, names.get(attr_type, "(%s)" % attr_type))
- if optional:
- text = text.replace(" : ", " ?: ")
- self.rendered.append({"id": cs_elem_id, "type": "Text", "x": 10, "y": 25 + text_counter * 11, "text": text, "lineWidth": 3, "lineColour": "black", "layer": 2})
- max_text = max(len(text), max_text)
- self.rendered.append({"id": str(uuid.uuid4()), "type": "contains", "__source": group_id, "__target": cs_elem_id})
- text_counter += 1
- if text_counter > 1:
- text_counter += 1
- for key, value in attrs.items():
- cs_elem_id = str(uuid.uuid4())
- if isinstance(value, dict):
- if value["AL"] == "":
- text = "(%s)" % key
- else:
- text = "%s = ^%s" % (key, value['AL'])
- else:
- text = ("%s = %s" % (key, value)) if value is not None else ("(%s)" % key)
- self.rendered.append({"id": cs_elem_id, "type": "Text", "x": 10, "y": 25 + text_counter * 11, "text": text, "lineWidth": 3, "lineColour": "black", "layer": 2})
- max_text = max(len(text), max_text)
- self.rendered.append({"id": str(uuid.uuid4()), "type": "contains", "__source": group_id, "__target": cs_elem_id})
- text_counter += 1
- # Add the rectangle
- cs_elem_id = str(uuid.uuid4())
- self.rendered.append({"id": cs_elem_id, "type": "Rectangle", "x": 0, "y": 0, "width": max_text * 8, "height": 35 + text_counter * 11, "lineWidth": 1, "lineColour": "black", "fillColour": "white", "layer": 1})
- self.rendered.append({"id": str(uuid.uuid4()), "type": "contains", "__source": group_id, "__target": cs_elem_id})
- # Add the line
- cs_elem_id = str(uuid.uuid4())
- self.rendered.append({"id": cs_elem_id, "type": "Line", "x": 0, "y": 20, "targetX": max_text * 8, "targetY": 20, "lineWidth": 1, "lineColour": "black", "layer": 0, "arrow": False})
- self.rendered.append({"id": str(uuid.uuid4()), "type": "contains", "__source": group_id, "__target": cs_elem_id})
- for edge in edges:
- edge["__source"] = groups[edge["__source"]]
- edge["__target"] = groups[edge["__target"]]
- self.rendered.append(edge)
- </script>
- </transition>
- <transition event="mv_exception" target="../../../close"/>
- </state>
- <state id="render_model" initial="allocate_groups">
- <onentry>
- <raise event="update_status" scope="narrow" target="'progress_bar'">
- <parameter expr="80"/>
- <parameter expr="'Perceptualizing model... OK'"/>
- </raise>
- <raise event="clear_canvas" scope="narrow" target="'canvas'"/>
- <script>
- self.groups = [i for i in self.rendered if i["type"] == "Group"]
- self.contains = [i for i in self.rendered if i["type"] == "contains"]
- self.rendered = [i for i in self.rendered if i["type"] not in ["Group", "contains"]]
- self.rendered.reverse()
- </script>
- <raise event="mv_request" scope="broad">
- <parameter expr="'alter_context'"/>
- <parameter expr="[current_rendered_model, 'formalisms/MM_render/graphical']"/>
- </raise>
- </onentry>
- <state id="allocate_groups">
- <transition cond="len(self.groups) > 0" target="../allocating_group">
- <raise event="define_group" scope="narrow" target="'canvas'">
- <parameter expr="self.groups.pop()"/>
- </raise>
- </transition>
- <transition cond="len(self.groups) == 0" target="../allocate_contains"/>
- </state>
- <state id="allocating_group">
- <transition event="group_ready" target="../allocate_groups"/>
- </state>
- <state id="allocate_contains">
- <transition cond="len(self.contains) > 0" target=".">
- <raise event="define_contains" scope="narrow" target="'canvas'">
- <parameter expr="self.contains.pop()"/>
- </raise>
- </transition>
- <transition cond="len(self.contains) == 0" target="../render_elements"/>
- </state>
- <state id="render_elements">
- <transition cond="len(self.rendered) > 0" target=".">
- <raise event="draw_canvas" scope="narrow" target="'canvas'">
- <parameter expr="self.rendered.pop()"/>
- </raise>
- </transition>
- <transition cond="len(self.rendered) == 0" target="../../../idle"/>
- </state>
- </state>
- </state>
- <transition event="window-close" cond="ID == id(self)" target="../close">
- <parameter name="ID"/>
- </transition>
- </state>
- <state id="close">
- <onentry>
- <raise event="close_window" scope="narrow" target="'parent'"/>
- </onentry>
- </state>
- </state>
- <state id="key_status">
- <onentry>
- <script>
- global control_pressed
- control_pressed = False
- </script>
- </onentry>
- <state id="listening">
- <transition event="control" target=".">
- <script>
- global control_pressed
- control_pressed = True
- </script>
- </transition>
- <transition event="control-release" target=".">
- <script>
- global control_pressed
- control_pressed = False
- </script>
- </transition>
- </state>
- </state>
- <state id="mover">
- <state id="move">
- <transition event="move" target=".">
- <parameter name="asid"/>
- <parameter name="location"/>
- <script>
- self.locations[asid] = location
- </script>
- </transition>
- </state>
- </state>
- </parallel>
- </scxml>
- </class>
|