Commits

Santiago Payà Miralta committed 73aaa5f

More on drop schema.

Comments (0)

Files changed (3)

control/genet_creator.py

     st = "SELECT id " \
         "FROM gn____edge_types " \
         "WHERE level = " + level + ";"
-    ids = db.query(st).getresult()[0]
-    for i in ids:
-        dropEdgeType(i)        
+    ids = db.query(st).getresult()
+    if len(ids):
+        for i in ids[0]:
+            dropEdgeType(i)        
 
     # Nodes.
     st = "SELECT id " \
         "FROM gn____node_types " \
         "WHERE level = " + level + ";"
-    ids = db.query(st).getresult()[0]
-    for i in ids:
-        dropNodeType(i)        
+    ids = db.query(st).getresult()
+    if len(ids):
+        for i in ids[0]:
+            dropNodeType(i)        
 
     # Delete entry into the levels table.
     st = "DELETE FROM gn____levels " \
     """
     st = "SELECT tablename " \
         "FROM gn____edge_types " \
-        "WHERE id = " + id + ";"
+        "WHERE id = " + str(id) + ";"
     tablename = db.query(st).getresult()[0][0]
 
     # Drop the table.
 
     # Delete entry into the types table.
     st = "DELETE FROM gn____edge_types " \
-        "WHERE id = " + level + ";"
+        "WHERE id = " + str(id) + ";"
     ret = ret, db.query(st)
 
     return ret
     """
     st = "SELECT tablename " \
         "FROM gn____node_types " \
-        "WHERE id = " + id + ";"
+        "WHERE id = " + str(id) + ";"
     tablename = db.query(st).getresult()[0][0]
 
     # Drop the table.
 
     # Delete entry into the types table.
     st = "DELETE FROM gn____node_types " \
-        "WHERE id = " + level + ";"
+        "WHERE id = " + str(id) + ";"
     ret = ret, db.query(st)
 
     return ret
                   <placeholder/>
                 </child>
                 <child>
-                  <widget class="GtkComboBoxEntry" id="comboboxentry_browser_nB">
+                  <widget class="GtkButton" id="button_connect_nodes">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Connect</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_connect_nodes_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label_browser_level">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Level</property>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkComboBoxEntry" id="comboboxentry_browser_level">
                     <property name="visible">True</property>
                     <child internal-child="entry">
-                      <widget class="GtkEntry" id="comboboxentry-entry4">
+                      <widget class="GtkEntry" id="comboboxentry-entry6">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                       </widget>
                     </child>
                   </widget>
                   <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
                   </packing>
                 </child>
                 <child>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkComboBoxEntry" id="comboboxentry_browser_level">
+                  <widget class="GtkComboBoxEntry" id="comboboxentry_browser_nB">
                     <property name="visible">True</property>
                     <child internal-child="entry">
-                      <widget class="GtkEntry" id="comboboxentry-entry6">
+                      <widget class="GtkEntry" id="comboboxentry-entry4">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                       </widget>
                     </child>
                   </widget>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkLabel" id="label_browser_level">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">Level</property>
-                  </widget>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_connect_nodes">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Connect</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_connect_nodes_clicked"/>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
                   </packing>
                   <placeholder/>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="label_creator_node">
+                  <widget class="GtkButton" id="button_create_node">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">Node</property>
-                  </widget>
-                </child>
-                <child>
-                  <widget class="GtkComboBox" id="combobox_creator_node_level">
-                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Create</property>
+                    <property name="response_id">0</property>
                   </widget>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
                   </packing>
                 </child>
                 <child>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkButton" id="button_create_node">
+                  <widget class="GtkComboBox" id="combobox_creator_node_level">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Create</property>
-                    <property name="response_id">0</property>
                   </widget>
                   <packing>
-                    <property name="left_attach">3</property>
-                    <property name="right_attach">4</property>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
                   </packing>
                 </child>
+                <child>
+                  <widget class="GtkLabel" id="label_creator_node">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Node</property>
+                  </widget>
+                </child>
               </widget>
               <packing>
                 <property name="position">1</property>
             <child>
               <widget class="GtkTable" id="table_creator">
                 <property name="visible">True</property>
-                <property name="n_rows">5</property>
+                <property name="n_rows">6</property>
                 <property name="n_columns">5</property>
                 <child>
+                  <widget class="GtkLabel" id="label_admin_modify_level">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">In this level</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_levels">
+                    <property name="visible">True</property>
+                    <property name="items" translatable="yes"></property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
                   <placeholder/>
                 </child>
                 <child>
                   <placeholder/>
                 </child>
                 <child>
-                  <widget class="GtkButton" id="button_drop_level">
+                  <widget class="GtkLabel" id="label_creator_node_type">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Node type</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkHSeparator" id="hseparator1">
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="right_attach">5</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="y_padding">5</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_drop_edge_type">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
                     <property name="label" translatable="yes">Delete</property>
                     <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_drop_level_clicked"/>
+                    <signal name="clicked" handler="on_button_drop_edge_type_clicked"/>
                   </widget>
                   <packing>
                     <property name="left_attach">4</property>
                     <property name="right_attach">5</property>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="label_creator_level">
+                  <widget class="GtkButton" id="button_drop_node_type">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">Level</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Delete</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_drop_node_type_clicked"/>
                   </widget>
+                  <packing>
+                    <property name="left_attach">4</property>
+                    <property name="right_attach">5</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
                 </child>
                 <child>
-                  <widget class="GtkEntry" id="entry_creator_level">
+                  <widget class="GtkButton" id="button_create_node_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Create</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_create_node_type_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="entry_creator_edge_type">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                   </widget>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_create_edge_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Create</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_create_edge_type_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label_creator_edge_type">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Edge type</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_admin_reset">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Reset</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_admin_reset_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">4</property>
+                    <property name="right_attach">5</property>
+                    <property name="top_attach">5</property>
+                    <property name="bottom_attach">6</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="entry_creator_node_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_admin_refresh">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Refresh</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_admin_refresh_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">5</property>
+                    <property name="bottom_attach">6</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_node_types">
+                    <property name="visible">True</property>
+                    <property name="items" translatable="yes"></property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_edge_types">
+                    <property name="visible">True</property>
+                    <property name="items" translatable="yes"></property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
                   </packing>
                 </child>
                 <child>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkComboBox" id="combobox_creator_levels">
-                    <property name="visible">True</property>
-                    <property name="items" translatable="yes"></property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">3</property>
-                    <property name="right_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkComboBox" id="combobox_creator_edge_types">
-                    <property name="visible">True</property>
-                    <property name="items" translatable="yes"></property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">3</property>
-                    <property name="right_attach">4</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkComboBox" id="combobox_creator_node_types">
-                    <property name="visible">True</property>
-                    <property name="items" translatable="yes"></property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">3</property>
-                    <property name="right_attach">4</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_admin_refresh">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Refresh</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_admin_refresh_clicked"/>
-                  </widget>
-                  <packing>
-                    <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkComboBox" id="combobox_creator_levels_types">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="has_focus">True</property>
-                    <property name="is_focus">True</property>
-                    <property name="items" translatable="yes"></property>
-                  </widget>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkEntry" id="entry_creator_node_type">
+                  <widget class="GtkEntry" id="entry_creator_level">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                   </widget>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkButton" id="button_admin_reset">
+                  <widget class="GtkLabel" id="label_creator_level">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Reset</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_admin_reset_clicked"/>
+                    <property name="label" translatable="yes">Level</property>
                   </widget>
-                  <packing>
-                    <property name="left_attach">4</property>
-                    <property name="right_attach">5</property>
-                    <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
-                  </packing>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="label_creator_edge_type">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">Edge type</property>
-                  </widget>
-                  <packing>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_create_edge_type">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Create</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_create_edge_type_clicked"/>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkEntry" id="entry_creator_edge_type">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_create_node_type">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Create</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_create_node_type_clicked"/>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkLabel" id="label_creator_node_type">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">Node type</property>
-                  </widget>
-                  <packing>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_drop_node_type">
+                  <widget class="GtkButton" id="button_drop_level">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
                     <property name="label" translatable="yes">Delete</property>
                     <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_drop_level_clicked"/>
                   </widget>
                   <packing>
                     <property name="left_attach">4</property>
                     <property name="bottom_attach">3</property>
                   </packing>
                 </child>
-                <child>
-                  <widget class="GtkButton" id="button_drop_edge_type">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Delete</property>
-                    <property name="response_id">0</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">4</property>
-                    <property name="right_attach">5</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
               </widget>
               <packing>
                 <property name="position">2</property>
             self.button_create_level_clicked,
             "on_button_drop_level_clicked" : 
             self.button_drop_level_clicked,
+            "on_button_drop_edge_type_clicked" : 
+            self.button_drop_edge_type_clicked,
+            "on_button_drop_node_type_clicked" : 
+            self.button_drop_node_type_clicked,
             "on_button_create_node_type_clicked" :
             self.button_create_node_type_clicked,
             "on_button_create_edge_type_clicked" :
 
     ############################################################################
     # Admin tab.
+    # TODO Must be all in a tree control.
     #
     def button_create_level_clicked(self,widget):
+        # Get description
         description = self.wTree.get_widget("entry_creator_level").get_text()
+
+        # Create level
         genet_creator.createLevel(description)
 
         # TODO Refresh the combo when touched.    
-        self.refreshCombo("combobox_creator_levels", 'levels')
-        self.refreshCombo("combobox_creator_levels_types", 'levels')
+        self.button_admin_refresh_clicked(None)
 
     def button_drop_level_clicked(self,widget):
+        # Get level
         combo = self.wTree.get_widget("combobox_creator_levels")
         combo_model = combo.get_model()
         combo_index = combo.get_active()
         level = combo_model[combo_index][1]
+
+        # Drop level
         genet_creator.dropLevel(level)
 
         # TODO Refresh the combo when touched.    
-        self.refreshCombo("combobox_creator_levels", 'levels')
-        self.refreshCombo("combobox_creator_levels_types", 'levels')
+        self.button_admin_refresh_clicked(None)
 
     def button_create_node_type_clicked(self, widget):
         # Get level
         genet_creator.createNodeType(level, description)
 
         # TODO Refresh the combo when touched.    
-        self.refreshCombo("combobox_creator_node_types", 'node_types')
+        self.button_admin_refresh_clicked(None)
+
+    def button_drop_node_type_clicked(self, widget):
+        # Get type
+        combo = self.wTree.get_widget("combobox_creator_node_types")
+        combo_model = combo.get_model()
+        combo_index = combo.get_active()
+        type = combo_model[combo_index][1]
+        
+        # Drop type
+        genet_creator.dropNodeType(type)
+
+        # TODO Refresh the combo when touched.    
+        self.button_admin_refresh_clicked(None)
        
     def button_create_edge_type_clicked(self, widget):
         # Get level
         genet_creator.createEdgeType(level, description)
 
         # TODO Refresh the combo when touched.    
-        self.refreshCombo("combobox_creator_edge_types", 'edge_types')
+        self.button_admin_refresh_clicked(None)
+
+    def button_drop_edge_type_clicked(self, widget):
+        # Get type
+        combo = self.wTree.get_widget("combobox_creator_edge_types")
+        combo_model = combo.get_model()
+        combo_index = combo.get_active()
+        type = combo_model[combo_index][1]
+        
+        # Drop type
+        genet_creator.dropEdgeType(type)
+
+        # TODO Refresh the combo when touched.    
+        self.button_admin_refresh_clicked(None)
 
     def button_admin_refresh_clicked(self, widget):
         # TODO Refresh the combo when touched.    
         self.refreshCombo("combobox_creator_levels", 'levels')
-        self.refreshCombo("combobox_creator_levels_types", 'levels')
         self.refreshCombo("combobox_creator_node_types", 'node_types')
         self.refreshCombo("combobox_creator_edge_types", 'edge_types')
 
     def button_admin_reset_clicked(self, widget):
         genet_global.restartDatabase()
         
+        # TODO Refresh the combo when touched.    
+        self.button_admin_refresh_clicked(None)
+
     ############################################################################
     # Auxiliary functions.
     #