فهرست منبع

wxGUI/vdigit: don't try to add new attribute record when no attribute table is defined

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48951 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 سال پیش
والد
کامیت
741521540b
3فایلهای تغییر یافته به همراه22 افزوده شده و 15 حذف شده
  1. 16 11
      gui/wxpython/gui_modules/dbm_dialogs.py
  2. 4 3
      gui/wxpython/gui_modules/mapdisp_vdigit.py
  3. 2 1
      gui/wxpython/gui_modules/vdigit.py

+ 16 - 11
gui/wxpython/gui_modules/dbm_dialogs.py

@@ -32,7 +32,7 @@ class DisplayAttributesDialog(wx.Dialog):
                  query = None, cats = None, line = None,
                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
                  pos = wx.DefaultPosition,
-                 action = "add"):
+                 action = "add", ignoreError = False):
         """!Standard dialog used to add/update/display attributes linked
         to the vector map.
         
@@ -47,6 +47,7 @@ class DisplayAttributesDialog(wx.Dialog):
         @param style
         @param pos
         @param action (add, update, display)
+        @param ignoreError True to ignore errors
         """
         self.parent = parent # mapdisplay.BufferedWindow
         self.map    = map
@@ -64,17 +65,21 @@ class DisplayAttributesDialog(wx.Dialog):
 
         # check if db connection / layer exists
         if len(layers) <= 0:
-            label = _("Database connection "
-                      "is not defined in DB file.")
-
-            gcmd.GMessage(parent = self.parent,
-                          message = _("No attribute table linked to "
-                                      "vector map <%(vector)s> found. %(msg)s\n\n"
-                                      "New attribute table can be created by "
-                                      "Attribute Table Manager.") % 
-                          {'vector' : self.map, 'msg' : label})
+            if not ignoreError:
+                dlg = wx.MessageDialog(parent = self.parent,
+                                       message = _("No attribute table found.\n\n"
+                                                   "Do you want to create a new attribute table "
+                                                   "and defined a link to vector map <%s>?") % self.map,
+                                       caption = _("Create table?"),
+                                       style = wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
+                if dlg.ShowModal() == wx.ID_YES:
+                    lmgr = self.parent.lmgr
+                    lmgr.OnShowAttributeTable(event = None, selection = 'layers')
+                
+                dlg.Destroy()
+            
             self.mapDBInfo = None
-
+        
         wx.Dialog.__init__(self, parent = self.parent, id = wx.ID_ANY,
                            title = "", style = style, pos = pos)
 

+ 4 - 3
gui/wxpython/gui_modules/mapdisp_vdigit.py

@@ -159,7 +159,7 @@ class VDigitWindow(BufferedWindow):
                 addRecordDlg = dbm_dialogs.DisplayAttributesDialog(parent = self, map = mapLayer,
                                                                    cats = cats,
                                                                    pos = posWindow,
-                                                                   action = "add")
+                                                                   action = "add", ignoreError = True)
                 
                 if self.toolbar.GetAction('type') == 'centroid':
                     for fid in fids:
@@ -350,7 +350,8 @@ class VDigitWindow(BufferedWindow):
                 # upgrade dialog
                 self.parent.dialogs['attributes'].UpdateDialog(cats = cats)
            
-            if self.parent.dialogs['attributes']:
+            if self.parent.dialogs['attributes'] and \
+                    self.parent.dialogs['attributes'].mapDBInfo:
                 if len(cats.keys()) > 0:
                     # highlight feature & re-draw map
                     if not self.parent.dialogs['attributes'].IsShown():
@@ -883,7 +884,7 @@ class VDigitWindow(BufferedWindow):
                     addRecordDlg = dbm_dialogs.DisplayAttributesDialog(parent = self, map = mapName,
                                                                        cats = cats,
                                                                        pos = posWindow,
-                                                                       action = "add")
+                                                                       action = "add", ignoreError = True)
                     
                     for fid in fids:
                         self._geomAttrb(fid, addRecordDlg, 'length')

+ 2 - 1
gui/wxpython/gui_modules/vdigit.py

@@ -606,7 +606,8 @@ class VDigitSettingsDialog(wx.Dialog):
     def OnChangeAddRecord(self, event):
         """!Checkbox 'Add new record' status changed
         """
-        self.category.SetValue(self.digit.SetCategory())
+        pass
+        # self.category.SetValue(self.digit.SetCategory())
             
     def OnChangeSnappingValue(self, event):
         """!Change snapping value - update static text