Browse Source

wxGUI: wrong indentation fixed (wxgui)
better mapset checking (gis_set)
default connection settings include 'schema/group' (dbm)
[sync'ed with devbr6, r31496]


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@31497 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 17 years ago
parent
commit
91e7cfab37
3 changed files with 33 additions and 20 deletions
  1. 3 1
      gui/wxpython/gis_set.py
  2. 29 18
      gui/wxpython/gui_modules/dbm.py
  3. 1 1
      gui/wxpython/wxgui.py

+ 3 - 1
gui/wxpython/gis_set.py

@@ -541,7 +541,9 @@ class GRASSStartup(wx.Frame):
         self.listOfMapsetsSelectable = []
         self.listOfMapsetsSelectable = []
         
         
         for mapset in glob.glob(os.path.join(self.gisdbase, location, "*")):
         for mapset in glob.glob(os.path.join(self.gisdbase, location, "*")):
-            if os.path.isdir(mapset) and os.path.basename(mapset) != 'PERMANENT':
+            if os.path.isdir(mapset) and \
+                    os.path.isfile(os.path.join(self.gisdbase, location, mapset, "WIND")) and \
+                    os.path.basename(mapset) != 'PERMANENT':
                 self.listOfMapsets.append(os.path.basename(mapset))
                 self.listOfMapsets.append(os.path.basename(mapset))
         
         
         utils.ListSortLower(self.listOfMapsets)
         utils.ListSortLower(self.listOfMapsets)

+ 29 - 18
gui/wxpython/gui_modules/dbm.py

@@ -147,6 +147,8 @@ class VirtualAttributeList(wx.ListCtrl,
         @return -1 if key column is not displayed
         @return -1 if key column is not displayed
         """
         """
 
 
+        self.log.write(_("Loading data..."))
+
         # These two should probably be passed to init more cleanly
         # These two should probably be passed to init more cleanly
         # setting the numbers of items = number of elements in the dictionary
         # setting the numbers of items = number of elements in the dictionary
         self.itemDataMap  = {}
         self.itemDataMap  = {}
@@ -2022,26 +2024,24 @@ class LayerBook(wx.Notebook):
         #
         #
         # get default values
         # get default values
         #
         #
+        self.defaultConnect = {}
         cmdConnect = gcmd.Command(['db.connect',
         cmdConnect = gcmd.Command(['db.connect',
                                    '-p',
                                    '-p',
                                    '--q'])
                                    '--q'])
         for line in cmdConnect.ReadStdOutput():
         for line in cmdConnect.ReadStdOutput():
             item, value = line.split(':')
             item, value = line.split(':')
-            item  = item.strip()
-            value = value.strip()
-            if item == 'driver':
-                self.defaultDriver = value
-            elif item == 'database':
-                self.defaultDatabase = value
-
-        if len(self.defaultDriver) == 0 or \
-               len(self.defaultDatabase) == 0:
+            self.defaultConnect[item.strip()] = value.strip()
+
+        if len(self.defaultConnect['driver']) == 0 or \
+               len(self.defaultConnect['database']) == 0:
             raise gcmd.DBMError(_('Unable to determine default DB connection settings. '
             raise gcmd.DBMError(_('Unable to determine default DB connection settings. '
                                   'Please define DB connection using db.connect module.'))
                                   'Please define DB connection using db.connect module.'))
         
         
-        self.defaultTables = self.__getTables(self.defaultDriver, self.defaultDatabase)
+        self.defaultTables = self.__getTables(self.defaultConnect['driver'],
+                                              self.defaultConnect['database'])
         try:
         try:
-            self.defaultColumns = self.__getColumns(self.defaultDriver, self.defaultDatabase,
+            self.defaultColumns = self.__getColumns(self.defaultConnect['driver'],
+                                                    self.defaultConnect['database'],
                                                     self.defaultTables[0])
                                                     self.defaultTables[0])
         except IndexError:
         except IndexError:
             self.defaultColumns = []
             self.defaultColumns = []
@@ -2091,8 +2091,8 @@ class LayerBook(wx.Notebook):
                                                choices=self.defaultColumns))}
                                                choices=self.defaultColumns))}
         
         
         # set default values for widgets
         # set default values for widgets
-        self.addLayerWidgets['driver'][1].SetStringSelection(self.defaultDriver)
-        self.addLayerWidgets['database'][1].SetValue(self.defaultDatabase)
+        self.addLayerWidgets['driver'][1].SetStringSelection(self.defaultConnect['driver'])
+        self.addLayerWidgets['database'][1].SetValue(self.defaultConnect['database'])
         self.addLayerWidgets['table'][1].SetSelection(0)
         self.addLayerWidgets['table'][1].SetSelection(0)
         self.addLayerWidgets['key'][1].SetSelection(0)
         self.addLayerWidgets['key'][1].SetSelection(0)
         # events
         # events
@@ -2343,10 +2343,18 @@ class LayerBook(wx.Notebook):
             driver   = self.mapDBInfo.layers[layer]['driver']
             driver   = self.mapDBInfo.layers[layer]['driver']
             database = self.mapDBInfo.layers[layer]['database']
             database = self.mapDBInfo.layers[layer]['database']
             table    = self.mapDBInfo.layers[layer]['table']
             table    = self.mapDBInfo.layers[layer]['table']
+
             listOfColumns = self.__getColumns(driver, database, table)
             listOfColumns = self.__getColumns(driver, database, table)
             self.modifyLayerWidgets['driver'][1].SetStringSelection(driver)
             self.modifyLayerWidgets['driver'][1].SetStringSelection(driver)
             self.modifyLayerWidgets['database'][1].SetValue(database)
             self.modifyLayerWidgets['database'][1].SetValue(database)
-            self.modifyLayerWidgets['table'][1].SetStringSelection(table)
+            if table in self.modifyLayerWidgets['table'][1].GetItems():
+                self.modifyLayerWidgets['table'][1].SetStringSelection(table)
+            else:
+                if self.defaultConnect['schema'] != '':
+                    table = self.defaultConnect['schema'] + table # try with default schema
+                else:
+                    table = 'public.' + table # try with 'public' schema
+                self.modifyLayerWidgets['table'][1].SetStringSelection(table)
             self.modifyLayerWidgets['key'][1].SetItems(listOfColumns)
             self.modifyLayerWidgets['key'][1].SetItems(listOfColumns)
             self.modifyLayerWidgets['key'][1].SetSelection(0)
             self.modifyLayerWidgets['key'][1].SetSelection(0)
 
 
@@ -2461,15 +2469,18 @@ class LayerBook(wx.Notebook):
         table    = self.addLayerWidgets['table'][1]
         table    = self.addLayerWidgets['table'][1]
         key      = self.addLayerWidgets['key'][1]
         key      = self.addLayerWidgets['key'][1]
 
 
-        driver.SetStringSelection(self.defaultDriver)
-        database.SetValue(self.defaultDatabase)
-        tables = self.__getTables(self.defaultDriver, self.defaultDatabase)
+        driver.SetStringSelection(self.defaultConnect['driver'])
+        database.SetValue(self.defaultConnect['database'])
+        tables = self.__getTables(self.defaultConnect['driver'],
+                                  self.defaultConnect['database'])
         table.SetItems(tables)
         table.SetItems(tables)
         table.SetSelection(0)
         table.SetSelection(0)
         if len(tables) == 0:
         if len(tables) == 0:
             key.SetItems([])
             key.SetItems([])
         else:
         else:
-            cols = self.__getColumns(self.defaultDriver, self.defaultDatabase, tables[0])
+            cols = self.__getColumns(self.defaultConnect['driver'],
+                                     self.defaultConnect['database'],
+                                     tables[0])
             key.SetItems(cols)
             key.SetItems(cols)
             key.SetSelection(0)
             key.SetSelection(0)
 
 

+ 1 - 1
gui/wxpython/wxgui.py

@@ -1162,7 +1162,7 @@ class GMFrame(wx.Frame):
         busy = wx.BusyInfo(message=_("Please wait, loading attribute data..."),
         busy = wx.BusyInfo(message=_("Please wait, loading attribute data..."),
                            parent=self)
                            parent=self)
         wx.Yield()
         wx.Yield()
-
+        
         self.dbmanager = dbm.AttributeManager(parent=self, id=wx.ID_ANY,
         self.dbmanager = dbm.AttributeManager(parent=self, id=wx.ID_ANY,
                                               title="%s - <%s>" % (_("GRASS GIS Attribute Table Manager"),
                                               title="%s - <%s>" % (_("GRASS GIS Attribute Table Manager"),
                                                                    mapname),
                                                                    mapname),