[GRASS-SVN] r48951 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 26 07:59:10 EDT 2011


Author: martinl
Date: 2011-10-26 04:59:10 -0700 (Wed, 26 Oct 2011)
New Revision: 48951

Modified:
   grass/trunk/gui/wxpython/gui_modules/dbm_dialogs.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py
   grass/trunk/gui/wxpython/gui_modules/vdigit.py
Log:
wxGUI/vdigit: don't try to add new attribute record when no attribute table is defined


Modified: grass/trunk/gui/wxpython/gui_modules/dbm_dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm_dialogs.py	2011-10-26 09:18:01 UTC (rev 48950)
+++ grass/trunk/gui/wxpython/gui_modules/dbm_dialogs.py	2011-10-26 11:59:10 UTC (rev 48951)
@@ -32,7 +32,7 @@
                  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 @@
         @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 @@
 
         # 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)
 

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py	2011-10-26 09:18:01 UTC (rev 48950)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py	2011-10-26 11:59:10 UTC (rev 48951)
@@ -159,7 +159,7 @@
                 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 @@
                 # 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 @@
                     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')

Modified: grass/trunk/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/vdigit.py	2011-10-26 09:18:01 UTC (rev 48950)
+++ grass/trunk/gui/wxpython/gui_modules/vdigit.py	2011-10-26 11:59:10 UTC (rev 48951)
@@ -606,7 +606,8 @@
     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



More information about the grass-commit mailing list