Просмотр исходного кода

Added first version of actual creation of AS in Mv, with the choice prompt window

Yentl Van Tendeloo 8 лет назад
Родитель
Сommit
7f03e10043
5 измененных файлов с 386 добавлено и 42 удалено
  1. 81 18
      classes/canvas/canvas.xml
  2. 0 2
      classes/canvas/canvas_element.xml
  3. 179 0
      classes/window/choice_prompt_window.xml
  4. 125 22
      frontend.py
  5. 1 0
      frontend.xml

+ 81 - 18
classes/canvas/canvas.xml

@@ -5,6 +5,7 @@
         <inheritance class="tk.Canvas" priority='1'/>
         <association name="elements" class="CanvasElement"/>
         <association name="connecting_lines" class="ConnectingLines"/>
+        <association name="prompt" class="ChoicePrompt"/>
     </relationships>
     <constructor>
         <parameter name="parent" />
@@ -31,7 +32,6 @@
             self.connecting_lines = {}
             self.lines = set()
             self.layers = []
-            print("RESET CANVAS")
             self.to_move = {}
 
             self.elems = []
@@ -42,7 +42,6 @@
     </constructor>
     <destructor>
         <body>
-            print("CANVAS DESTROYED")
             self.destroy()
         </body>
     </destructor>
@@ -67,6 +66,9 @@
                             <parameter expr="'connecting_lines'"/>
                         </raise>
                         <script>
+                            for f in self.elems:
+                                self.delete(f[1])
+                            self.elems = []
                             self.group_location = {}
                             self.layers = []
                         </script>
@@ -169,18 +171,6 @@
                     </onexit>
 
                     <state id="drawing">
-                        <onentry>
-                            <script>
-                                print("Drawing")
-                            </script>
-                        </onentry>
-
-                        <onexit>
-                            <script>
-                                print("NOT drawing")
-                            </script>
-                        </onexit>
-
                         <transition event="motion" target=".">
                             <script>
                                 x, y, _, _ = self.coords(self.tmp_line)
@@ -202,9 +192,6 @@
 
                         <transition event="right-click" cond="ID == id(self)" target="../../ready">
                             <parameter name="ID"/>
-                            <script>
-                                print("Release on canvas " + str(ID))
-                            </script>
                         </transition>
 
                         <transition event="create_line" target="../create_in_mv">
@@ -217,7 +204,81 @@
                         </transition>
                     </state>
 
-                    <state id="create_in_mv"/>
+                    <state id="create_in_mv" initial="query_type">
+                        <state id="query_type">
+                            <onentry>
+                                <raise event="mv_request" scope="broad">
+                                    <parameter expr="'connections_between'"/>
+                                    <parameter expr="[current_model, self.creating_line[1], self.creating_line[3]]"/>
+                                </raise>
+                            </onentry>
+
+                            <transition event="mv_response" target="../check_types">
+                                <parameter name="result"/>
+                                <script>
+                                    self.allowed_types = result
+                                </script>
+                            </transition>
+                        </state>
+
+                        <state id="check_types">
+                            <onentry>
+                                <script>
+                                    print("Got allowed types: " + str(self.allowed_types))
+                                </script>
+                            </onentry>
+                            <transition cond="len(self.allowed_types) == 0" target="../../../ready"/>
+                            <transition cond="len(self.allowed_types) == 1" target="../create">
+                                <script>
+                                    self.assoc_type = self.allowed_types.pop()
+                                </script>
+                            </transition>
+                            <transition cond="len(self.allowed_types) > 1" target="../request_user"/>
+                        </state>
+
+                        <state id="request_user">
+                            <onentry>
+                                <raise event="create_instance" scope="cd">
+                                    <parameter expr="'prompt'"/>
+                                    <parameter expr="'ChoicePrompt'"/>
+                                    <parameter expr="self.allowed_types"/>
+                                </raise>
+                            </onentry>
+
+                            <transition event="instance_created" target="../wait_for_response">
+                                <parameter name="assoc_name"/>
+                                <raise event="start_instance" scope="cd">
+                                    <parameter expr="assoc_name"/>
+                                </raise>
+                                <script>
+                                    self.assoc_type = None
+                                </script>
+                            </transition>
+                        </state>
+
+                        <state id="wait_for_response">
+                            <transition event="choice_result" target=".">
+                                <parameter name="result"/>
+                                <script>
+                                    self.assoc_type = result
+                                </script>
+                            </transition>
+
+                            <transition event="window_close" cond="self.assoc_type is not None" target="../create"/>
+                            <transition event="window_close" cond="self.assoc_type is None" target="../../../ready"/>
+                        </state>
+
+                        <state id="create">
+                            <onentry>
+                                <raise event="mv_request" scope="broad">
+                                    <parameter expr="'instantiate'"/>
+                                    <parameter expr="[current_model, self.assoc_type, '', (self.creating_line[1], self.creating_line[3])]"/>
+                                </raise>
+                            </onentry>
+
+                            <transition event="mv_response" target="../../../ready"/>
+                        </state>
+                    </state>
                 </state>
 
                 <state id="creating_group">
@@ -280,6 +341,8 @@
                             <parameter expr="'connecting_lines'"/>
                         </raise>
                         <script>
+                            for f in self.elems:
+                                self.delete(f[1])
                             self.group_location = {}
                             self.layers = []
                         </script>

+ 0 - 2
classes/canvas/canvas_element.xml

@@ -79,8 +79,6 @@
                     <script>
                         self.coordinates = self.containing_canvas.to_move.pop(self.as_element)
                         self.move_group(self.coordinates)
-                        
-                        self.containing_canvas.delete(self.containing_canvas.elems.pop(0)[1])
                     </script>
                 </transition>
             </state>

+ 179 - 0
classes/window/choice_prompt_window.xml

@@ -0,0 +1,179 @@
+<class name="Browser">
+    <relationships>
+        <inheritance class="tk.Toplevel" priority="1"/>
+        <inheritance class="SCCDWidget" priority="0"/>
+        <association name="buttons" class="Button"/>
+        <association name="labels" class="Label"/>
+        <association name="parent" class="A"/>
+    </relationships>
+
+    <constructor>
+        <parameter name="prompt"/>
+        <parameter name="options" default="None"/>
+        <super class="tk.Toplevel"/>
+        <super class="SCCDWidget"/>
+        <body>
+            tk.Label(self, text=prompt).pack()
+
+            self.button_frame = tk.Frame(self)
+            self.button_frame.pack(fill=tk.X)
+
+            self.browser_frame = tk.Frame(self)
+            self.browser_frame.pack(fill=tk.BOTH)
+
+            self.selected_label = None
+            self.labels = {}
+            self.options = options
+        </body>
+    </constructor>
+
+    <destructor>
+        <body>
+            self.destroy()
+        </body>
+    </destructor>
+
+    <scxml initial="init">
+        <state id="init">
+            <onentry>
+                <raise event="create_instance" scope="cd">
+                    <parameter expr="'buttons'"/>
+                    <parameter expr="'Button'"/>
+                    <parameter expr="{'parent': self.button_frame, 'visual': TextVisual('OK'), 'tooltip_text': 'Commit decision', 'event_parameters': 'OK'}"/>
+                </raise>
+            </onentry>
+
+            <transition event="instance_created" target="../wait_for_packing_OK">
+                <parameter name="association_name"/>
+                <raise event="start_instance" scope="cd">
+                    <parameter expr="association_name"/>
+                </raise>
+
+                <script>
+                    self.button_ok = association_name
+                </script>
+            </transition>
+        </state>
+
+        <state id="wait_for_packing_OK">
+            <transition event="tk_widget" target="../create_labels">
+                <parameter name="tk_elem"/>
+                <script>
+                    tk_elem.pack(anchor=tk.W, fill=tk.BOTH, expand=tk.TRUE)
+                </script>
+            </transition>
+        </state>
+
+        <state id="create_labels" initial="query">
+            <state id="query">
+                <transition target="check_continue">
+                    <script>
+                        self.labels_to_add = sorted(self.options)
+                        self.all_results = sorted(self.options)
+                    </script>
+                </transition>
+            </state>
+
+            <state id="add_labels" initial="add_label">
+                <state id="add_label">
+                    <onentry>
+                        <raise event="create_instance" scope="cd">
+                            <parameter expr="'labels'"/>
+                            <parameter expr="'Label'"/>
+                            <parameter expr="{'parent': self.browser_frame, 'text': self.labels_to_add[0]}"/>
+                        </raise>
+                    </onentry>
+
+                    <transition event="instance_created" target="../pack_label">
+                        <parameter name="association_name"/>
+                        <raise event="start_instance" scope="cd">
+                            <parameter expr="association_name"/>
+                        </raise>
+                        <script>
+                            self.labels[self.labels_to_add.pop(0)] = association_name
+                        </script>
+                    </transition>
+                </state>
+                <state id="pack_label">
+                    <transition event="tk_widget" target="../check_continue">
+                        <parameter name="tk_elem"/>
+                        <script>
+                            tk_elem.pack()
+                        </script>
+                    </transition>
+                </state>
+
+                <state id="check_continue">
+                    <transition cond="len(self.labels_to_add) == 0" target="../../waiting"/>
+                    <transition cond="len(self.labels_to_add) > 0" target="../add_label"/>
+                </state>
+            </state>
+        </state>
+
+        <state id="waiting">
+            <state id="selecting_label">
+                <transition event="label_pressed" cond="self.selected_label is None" target=".">
+                    <parameter name="text"/>
+                    <raise event="highlight" target="self.labels[text]" scope="narrow"/>
+                    <script>
+                        self.selected_label = text
+                    </script>
+                </transition>
+
+                <transition event="label_pressed" cond="self.selected_label is not None and self.selected_label != text" target=".">
+                    <parameter name="text"/>
+                    <raise event="unhighlight" target="self.labels[self.selected_label]" scope="narrow"/>
+                    <raise event="highlight" target="self.labels[text]" scope="narrow"/>
+                    <script>
+                        self.selected_label = text
+                    </script>
+                </transition>
+
+                <transition event="label_pressed" cond="self.selected_label is not None and self.selected_label == text" target="../delete_labels">
+                    <parameter name="text"/>
+                </transition>
+
+                <transition event="button_pressed" cond="event_name == 'OK' and self.selected_label is not None" target="../delete_labels"/>
+            </state>
+        </state>
+
+        <state id="delete_labels">
+            <transition cond="len(self.labels) > 0" target=".">
+                <raise event="delete_instance" scope="cd">
+                    <parameter expr="self.labels.popitem()[1]"/>
+                </raise>
+            </transition>
+
+            <transition cond="len(self.labels) == 0" target="../send_results"/>
+        </state>
+
+        <state id="send_results">
+            <transition target="../closing">
+                <raise event="choice_result" target="'parent'" scope="narrow">
+                    <parameter expr="self.selected_label"/>
+                </raise>
+            </transition>
+        </state>
+
+        <state id="closing">
+            <onentry>
+                <raise event="delete_instance" scope="cd">
+                    <parameter expr="self.to_close.pop(0)"/>
+                </raise>
+            </onentry>
+
+            <transition event="instance_deleted" cond="len(self.to_close) > 0" target="."/>
+            <transition event="instance_deleted" cond="len(self.to_close) == 0" target="../close"/>
+        </state>
+            
+        <state id="close">
+            <onentry>
+                <raise event="close_window" scope="narrow" target="'parent'"/>
+            </onentry>
+        </state>
+
+        <transition event="window-close" cond="ID == id(self)" target="../closing">
+            <parameter name="ID"/>
+        </transition>
+    </scxml>
+</class>

+ 125 - 22
frontend.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Mon Oct  9 16:07:22 2017
+Date:   Mon Oct  9 16:33:03 2017
 
 Model author: Yentl Van Tendeloo
 Model name:   Modelverse Visual Editor - Tkinter Version 
@@ -7144,7 +7144,6 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
         self.connecting_lines = {}
         self.lines = set()
         self.layers = []
-        print("RESET CANVAS")
         self.to_move = {}
         
         self.elems = []
@@ -7153,7 +7152,6 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
         self.loading = [tk.PhotoImage(file="icons/loading.gif", format="gif -index %i" % i) for i in range(8)]
     
     def user_defined_destructor(self):
-        print("CANVAS DESTROYED")
         self.destroy()
         # call super class destructors
         if hasattr(tk.Canvas, "__del__"):
@@ -7187,30 +7185,47 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
         
         # state /ready/process_events/creating_line/drawing
         self.states["/ready/process_events/creating_line/drawing"] = State(6, "/ready/process_events/creating_line/drawing", self)
-        self.states["/ready/process_events/creating_line/drawing"].setEnter(self._ready_process_events_creating_line_drawing_enter)
-        self.states["/ready/process_events/creating_line/drawing"].setExit(self._ready_process_events_creating_line_drawing_exit)
         
         # state /ready/process_events/creating_line/create_in_mv
         self.states["/ready/process_events/creating_line/create_in_mv"] = State(7, "/ready/process_events/creating_line/create_in_mv", self)
         
+        # state /ready/process_events/creating_line/create_in_mv/query_type
+        self.states["/ready/process_events/creating_line/create_in_mv/query_type"] = State(8, "/ready/process_events/creating_line/create_in_mv/query_type", self)
+        self.states["/ready/process_events/creating_line/create_in_mv/query_type"].setEnter(self._ready_process_events_creating_line_create_in_mv_query_type_enter)
+        
+        # state /ready/process_events/creating_line/create_in_mv/check_types
+        self.states["/ready/process_events/creating_line/create_in_mv/check_types"] = State(9, "/ready/process_events/creating_line/create_in_mv/check_types", self)
+        self.states["/ready/process_events/creating_line/create_in_mv/check_types"].setEnter(self._ready_process_events_creating_line_create_in_mv_check_types_enter)
+        
+        # state /ready/process_events/creating_line/create_in_mv/request_user
+        self.states["/ready/process_events/creating_line/create_in_mv/request_user"] = State(10, "/ready/process_events/creating_line/create_in_mv/request_user", self)
+        self.states["/ready/process_events/creating_line/create_in_mv/request_user"].setEnter(self._ready_process_events_creating_line_create_in_mv_request_user_enter)
+        
+        # state /ready/process_events/creating_line/create_in_mv/wait_for_response
+        self.states["/ready/process_events/creating_line/create_in_mv/wait_for_response"] = State(11, "/ready/process_events/creating_line/create_in_mv/wait_for_response", self)
+        
+        # state /ready/process_events/creating_line/create_in_mv/create
+        self.states["/ready/process_events/creating_line/create_in_mv/create"] = State(12, "/ready/process_events/creating_line/create_in_mv/create", self)
+        self.states["/ready/process_events/creating_line/create_in_mv/create"].setEnter(self._ready_process_events_creating_line_create_in_mv_create_enter)
+        
         # state /ready/process_events/creating_group
-        self.states["/ready/process_events/creating_group"] = State(8, "/ready/process_events/creating_group", self)
+        self.states["/ready/process_events/creating_group"] = State(13, "/ready/process_events/creating_group", self)
         
         # state /ready/process_events/wait_canvas_element_ready
-        self.states["/ready/process_events/wait_canvas_element_ready"] = State(9, "/ready/process_events/wait_canvas_element_ready", self)
+        self.states["/ready/process_events/wait_canvas_element_ready"] = State(14, "/ready/process_events/wait_canvas_element_ready", self)
         
         # state /ready/process_events/creating_element
-        self.states["/ready/process_events/creating_element"] = State(10, "/ready/process_events/creating_element", self)
+        self.states["/ready/process_events/creating_element"] = State(15, "/ready/process_events/creating_element", self)
         self.states["/ready/process_events/creating_element"].setEnter(self._ready_process_events_creating_element_enter)
         
         # state /ready/process_events/waiting_for_clear
-        self.states["/ready/process_events/waiting_for_clear"] = State(11, "/ready/process_events/waiting_for_clear", self)
+        self.states["/ready/process_events/waiting_for_clear"] = State(16, "/ready/process_events/waiting_for_clear", self)
         
         # state /ready/update_loading
-        self.states["/ready/update_loading"] = State(12, "/ready/update_loading", self)
+        self.states["/ready/update_loading"] = State(17, "/ready/update_loading", self)
         
         # state /ready/update_loading/updating
-        self.states["/ready/update_loading/updating"] = State(13, "/ready/update_loading/updating", self)
+        self.states["/ready/update_loading/updating"] = State(18, "/ready/update_loading/updating", self)
         self.states["/ready/update_loading/updating"].setEnter(self._ready_update_loading_updating_enter)
         self.states["/ready/update_loading/updating"].setExit(self._ready_update_loading_updating_exit)
         
@@ -7227,11 +7242,17 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
         self.states["/ready/process_events"].addChild(self.states["/ready/process_events/waiting_for_clear"])
         self.states["/ready/process_events/creating_line"].addChild(self.states["/ready/process_events/creating_line/drawing"])
         self.states["/ready/process_events/creating_line"].addChild(self.states["/ready/process_events/creating_line/create_in_mv"])
+        self.states["/ready/process_events/creating_line/create_in_mv"].addChild(self.states["/ready/process_events/creating_line/create_in_mv/query_type"])
+        self.states["/ready/process_events/creating_line/create_in_mv"].addChild(self.states["/ready/process_events/creating_line/create_in_mv/check_types"])
+        self.states["/ready/process_events/creating_line/create_in_mv"].addChild(self.states["/ready/process_events/creating_line/create_in_mv/request_user"])
+        self.states["/ready/process_events/creating_line/create_in_mv"].addChild(self.states["/ready/process_events/creating_line/create_in_mv/wait_for_response"])
+        self.states["/ready/process_events/creating_line/create_in_mv"].addChild(self.states["/ready/process_events/creating_line/create_in_mv/create"])
         self.states["/ready/update_loading"].addChild(self.states["/ready/update_loading/updating"])
         self.states[""].fixTree()
         self.states[""].default_state = self.states["/main"]
         self.states["/ready/process_events"].default_state = self.states["/ready/process_events/ready"]
         self.states["/ready/process_events/creating_line"].default_state = self.states["/ready/process_events/creating_line/drawing"]
+        self.states["/ready/process_events/creating_line/create_in_mv"].default_state = self.states["/ready/process_events/creating_line/create_in_mv/query_type"]
         self.states["/ready/update_loading"].default_state = self.states["/ready/update_loading/updating"]
         
         # transition /main
@@ -7291,7 +7312,6 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
         _ready_process_events_creating_line_drawing_0.setTrigger(Event("motion", None))
         self.states["/ready/process_events/creating_line/drawing"].addTransition(_ready_process_events_creating_line_drawing_0)
         _ready_process_events_creating_line_drawing_1 = Transition(self, self.states["/ready/process_events/creating_line/drawing"], [self.states["/ready/process_events/ready"]])
-        _ready_process_events_creating_line_drawing_1.setAction(self._ready_process_events_creating_line_drawing_1_exec)
         _ready_process_events_creating_line_drawing_1.setTrigger(Event("right-click", None))
         _ready_process_events_creating_line_drawing_1.setGuard(self._ready_process_events_creating_line_drawing_1_guard)
         self.states["/ready/process_events/creating_line/drawing"].addTransition(_ready_process_events_creating_line_drawing_1)
@@ -7300,6 +7320,52 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
         _ready_process_events_creating_line_drawing_2.setTrigger(Event("create_line", None))
         self.states["/ready/process_events/creating_line/drawing"].addTransition(_ready_process_events_creating_line_drawing_2)
         
+        # transition /ready/process_events/creating_line/create_in_mv/query_type
+        _ready_process_events_creating_line_create_in_mv_query_type_0 = Transition(self, self.states["/ready/process_events/creating_line/create_in_mv/query_type"], [self.states["/ready/process_events/creating_line/create_in_mv/check_types"]])
+        _ready_process_events_creating_line_create_in_mv_query_type_0.setAction(self._ready_process_events_creating_line_create_in_mv_query_type_0_exec)
+        _ready_process_events_creating_line_create_in_mv_query_type_0.setTrigger(Event("mv_response", None))
+        self.states["/ready/process_events/creating_line/create_in_mv/query_type"].addTransition(_ready_process_events_creating_line_create_in_mv_query_type_0)
+        
+        # transition /ready/process_events/creating_line/create_in_mv/check_types
+        _ready_process_events_creating_line_create_in_mv_check_types_0 = Transition(self, self.states["/ready/process_events/creating_line/create_in_mv/check_types"], [self.states["/ready/process_events/ready"]])
+        _ready_process_events_creating_line_create_in_mv_check_types_0.setTrigger(None)
+        _ready_process_events_creating_line_create_in_mv_check_types_0.setGuard(self._ready_process_events_creating_line_create_in_mv_check_types_0_guard)
+        self.states["/ready/process_events/creating_line/create_in_mv/check_types"].addTransition(_ready_process_events_creating_line_create_in_mv_check_types_0)
+        _ready_process_events_creating_line_create_in_mv_check_types_1 = Transition(self, self.states["/ready/process_events/creating_line/create_in_mv/check_types"], [self.states["/ready/process_events/creating_line/create_in_mv/create"]])
+        _ready_process_events_creating_line_create_in_mv_check_types_1.setAction(self._ready_process_events_creating_line_create_in_mv_check_types_1_exec)
+        _ready_process_events_creating_line_create_in_mv_check_types_1.setTrigger(None)
+        _ready_process_events_creating_line_create_in_mv_check_types_1.setGuard(self._ready_process_events_creating_line_create_in_mv_check_types_1_guard)
+        self.states["/ready/process_events/creating_line/create_in_mv/check_types"].addTransition(_ready_process_events_creating_line_create_in_mv_check_types_1)
+        _ready_process_events_creating_line_create_in_mv_check_types_2 = Transition(self, self.states["/ready/process_events/creating_line/create_in_mv/check_types"], [self.states["/ready/process_events/creating_line/create_in_mv/request_user"]])
+        _ready_process_events_creating_line_create_in_mv_check_types_2.setTrigger(None)
+        _ready_process_events_creating_line_create_in_mv_check_types_2.setGuard(self._ready_process_events_creating_line_create_in_mv_check_types_2_guard)
+        self.states["/ready/process_events/creating_line/create_in_mv/check_types"].addTransition(_ready_process_events_creating_line_create_in_mv_check_types_2)
+        
+        # transition /ready/process_events/creating_line/create_in_mv/request_user
+        _ready_process_events_creating_line_create_in_mv_request_user_0 = Transition(self, self.states["/ready/process_events/creating_line/create_in_mv/request_user"], [self.states["/ready/process_events/creating_line/create_in_mv/wait_for_response"]])
+        _ready_process_events_creating_line_create_in_mv_request_user_0.setAction(self._ready_process_events_creating_line_create_in_mv_request_user_0_exec)
+        _ready_process_events_creating_line_create_in_mv_request_user_0.setTrigger(Event("instance_created", None))
+        self.states["/ready/process_events/creating_line/create_in_mv/request_user"].addTransition(_ready_process_events_creating_line_create_in_mv_request_user_0)
+        
+        # transition /ready/process_events/creating_line/create_in_mv/wait_for_response
+        _ready_process_events_creating_line_create_in_mv_wait_for_response_0 = Transition(self, self.states["/ready/process_events/creating_line/create_in_mv/wait_for_response"], [self.states["/ready/process_events/creating_line/create_in_mv/wait_for_response"]])
+        _ready_process_events_creating_line_create_in_mv_wait_for_response_0.setAction(self._ready_process_events_creating_line_create_in_mv_wait_for_response_0_exec)
+        _ready_process_events_creating_line_create_in_mv_wait_for_response_0.setTrigger(Event("choice_result", None))
+        self.states["/ready/process_events/creating_line/create_in_mv/wait_for_response"].addTransition(_ready_process_events_creating_line_create_in_mv_wait_for_response_0)
+        _ready_process_events_creating_line_create_in_mv_wait_for_response_1 = Transition(self, self.states["/ready/process_events/creating_line/create_in_mv/wait_for_response"], [self.states["/ready/process_events/creating_line/create_in_mv/create"]])
+        _ready_process_events_creating_line_create_in_mv_wait_for_response_1.setTrigger(Event("window_close", None))
+        _ready_process_events_creating_line_create_in_mv_wait_for_response_1.setGuard(self._ready_process_events_creating_line_create_in_mv_wait_for_response_1_guard)
+        self.states["/ready/process_events/creating_line/create_in_mv/wait_for_response"].addTransition(_ready_process_events_creating_line_create_in_mv_wait_for_response_1)
+        _ready_process_events_creating_line_create_in_mv_wait_for_response_2 = Transition(self, self.states["/ready/process_events/creating_line/create_in_mv/wait_for_response"], [self.states["/ready/process_events/ready"]])
+        _ready_process_events_creating_line_create_in_mv_wait_for_response_2.setTrigger(Event("window_close", None))
+        _ready_process_events_creating_line_create_in_mv_wait_for_response_2.setGuard(self._ready_process_events_creating_line_create_in_mv_wait_for_response_2_guard)
+        self.states["/ready/process_events/creating_line/create_in_mv/wait_for_response"].addTransition(_ready_process_events_creating_line_create_in_mv_wait_for_response_2)
+        
+        # transition /ready/process_events/creating_line/create_in_mv/create
+        _ready_process_events_creating_line_create_in_mv_create_0 = Transition(self, self.states["/ready/process_events/creating_line/create_in_mv/create"], [self.states["/ready/process_events/ready"]])
+        _ready_process_events_creating_line_create_in_mv_create_0.setTrigger(Event("mv_response", None))
+        self.states["/ready/process_events/creating_line/create_in_mv/create"].addTransition(_ready_process_events_creating_line_create_in_mv_create_0)
+        
         # transition /ready/process_events/creating_group
         _ready_process_events_creating_group_0 = Transition(self, self.states["/ready/process_events/creating_group"], [self.states["/ready/process_events/wait_canvas_element_ready"]])
         _ready_process_events_creating_group_0.setAction(self._ready_process_events_creating_group_0_exec)
@@ -7340,11 +7406,17 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
     def _ready_process_events_creating_line_exit(self):
         self.delete(self.tmp_line)
     
-    def _ready_process_events_creating_line_drawing_enter(self):
-        print("Drawing")
+    def _ready_process_events_creating_line_create_in_mv_query_type_enter(self):
+        self.big_step.outputEventOM(Event("broad_cast", None, [self, Event("mv_request", None, ['connections_between', [current_model, self.creating_line[1], self.creating_line[3]]])]))
+    
+    def _ready_process_events_creating_line_create_in_mv_check_types_enter(self):
+        print("Got allowed types: " + str(self.allowed_types))
     
-    def _ready_process_events_creating_line_drawing_exit(self):
-        print("NOT drawing")
+    def _ready_process_events_creating_line_create_in_mv_request_user_enter(self):
+        self.big_step.outputEventOM(Event("create_instance", None, [self, 'prompt', 'ChoicePrompt', self.allowed_types]))
+    
+    def _ready_process_events_creating_line_create_in_mv_create_enter(self):
+        self.big_step.outputEventOM(Event("broad_cast", None, [self, Event("mv_request", None, ['instantiate', [current_model, self.assoc_type, '', (self.creating_line[1], self.creating_line[3])]])]))
     
     def _ready_process_events_creating_element_enter(self):
         self.big_step.outputEventOM(Event("broad_cast", None, [self, Event("mv_request", None, ['instantiate', [current_model, self.currently_selected, None, '']])]))
@@ -7362,6 +7434,9 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
     def _ready_process_events_ready_0_exec(self, parameters):
         self.big_step.outputEventOM(Event("delete_instance", None, [self, 'elements']))
         self.big_step.outputEventOM(Event("delete_instance", None, [self, 'connecting_lines']))
+        for f in self.elems:
+            self.delete(f[1])
+        self.elems = []
         self.group_location = {}
         self.layers = []
     
@@ -7435,10 +7510,6 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
         
         self.coords(self.tmp_line, x, y, self.last_x, self.last_y)
     
-    def _ready_process_events_creating_line_drawing_1_exec(self, parameters):
-        ID = parameters[0]
-        print("Release on canvas " + str(ID))
-    
     def _ready_process_events_creating_line_drawing_1_guard(self, parameters):
         ID = parameters[0]
         return ID == id(self)
@@ -7449,6 +7520,37 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
         origin_cs, origin_as, _ = self.creating_line
         self.creating_line = (origin_cs, origin_as, cs_element, as_element)
     
+    def _ready_process_events_creating_line_create_in_mv_query_type_0_exec(self, parameters):
+        result = parameters[0]
+        self.allowed_types = result
+    
+    def _ready_process_events_creating_line_create_in_mv_check_types_0_guard(self, parameters):
+        return len(self.allowed_types) == 0
+    
+    def _ready_process_events_creating_line_create_in_mv_check_types_1_exec(self, parameters):
+        self.assoc_type = self.allowed_types.pop()
+    
+    def _ready_process_events_creating_line_create_in_mv_check_types_1_guard(self, parameters):
+        return len(self.allowed_types) == 1
+    
+    def _ready_process_events_creating_line_create_in_mv_check_types_2_guard(self, parameters):
+        return len(self.allowed_types) > 1
+    
+    def _ready_process_events_creating_line_create_in_mv_request_user_0_exec(self, parameters):
+        assoc_name = parameters[0]
+        self.big_step.outputEventOM(Event("start_instance", None, [self, assoc_name]))
+        self.assoc_type = None
+    
+    def _ready_process_events_creating_line_create_in_mv_wait_for_response_0_exec(self, parameters):
+        result = parameters[0]
+        self.assoc_type = result
+    
+    def _ready_process_events_creating_line_create_in_mv_wait_for_response_1_guard(self, parameters):
+        return self.assoc_type is not None
+    
+    def _ready_process_events_creating_line_create_in_mv_wait_for_response_2_guard(self, parameters):
+        return self.assoc_type is None
+    
     def _ready_process_events_creating_group_0_exec(self, parameters):
         assoc_name = parameters[0]
         self.big_step.outputEventOM(Event("start_instance", None, [self, assoc_name]))
@@ -7471,6 +7573,8 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
     def _ready_process_events_waiting_for_clear_0_exec(self, parameters):
         self.big_step.outputEventOM(Event("delete_instance", None, [self, 'elements']))
         self.big_step.outputEventOM(Event("delete_instance", None, [self, 'connecting_lines']))
+        for f in self.elems:
+            self.delete(f[1])
         self.group_location = {}
         self.layers = []
     
@@ -8052,8 +8156,6 @@ class CanvasElement(RuntimeClassBase, SCCDWidget):
     def _init_init_1_exec(self, parameters):
         self.coordinates = self.containing_canvas.to_move.pop(self.as_element)
         self.move_group(self.coordinates)
-        
-        self.containing_canvas.delete(self.containing_canvas.elems.pop(0)[1])
     
     def _init_init_1_guard(self, parameters):
         return self.as_element in self.containing_canvas.to_move
@@ -8257,6 +8359,7 @@ class ObjectManager(ObjectManagerBase):
             instance.associations["parent"] = Association("A", 1, 1)
             instance.associations["elements"] = Association("CanvasElement", 0, -1)
             instance.associations["connecting_lines"] = Association("ConnectingLines", 0, -1)
+            instance.associations["prompt"] = Association("ChoicePrompt", 0, -1)
         elif class_name == "ConnectingLine":
             instance = ConnectingLine(self.controller, construct_params[0], construct_params[1])
             instance.associations = {}

+ 1 - 0
frontend.xml

@@ -28,6 +28,7 @@
     <class src="classes/window/browser.xml"/>
     <class src="classes/window/splash_window.xml"/>
     <class src="classes/window/popup.xml"/>
+    <class src="classes/window/choice_prompt_window.xml"/>
     <class src="classes/toolbar/toolbar.xml"/>
     <class src="classes/toolbar/generic_toolbar.xml"/>
     <class src="classes/toolbar/dsl_toolbar.xml"/>