123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326 |
- <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="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.canvas_frame = tk.Frame(self)
- self.progressbar_frame = tk.Frame(self)
- self.toolbar_frame.pack(fill=tk.X)
- self.canvas_frame.pack(fill=tk.BOTH, expand=tk.TRUE)
- 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="../../running">
- <parameter name="tk_elem"/>
- <script>
- tk_elem.pack(side=tk.BOTTOM, fill=tk.X, expand=tk.TRUE)
- </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">
- <script>
- print("Closed window!")
- </script>
- <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">
- <script>
- print("Closed window!")
- </script>
- <raise event="delete_instance" scope="cd">
- <parameter expr="self.current_window"/>
- </raise>
- </transition>
- </state>
- <state id="mark_dirty">
- <onentry>
- <script>
- print("Marking as dirty")
- </script>
- <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">
- <script>
- print("Response OK")
- </script>
- </transition>
- </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 = []
- print("Got model: " + str(result))
- 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"]
- print("Got defined attributes: " + str(defined_attributes))
- print("Got names: " + str(names))
-
- 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):
- 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>
|