[GRASS-SVN] r61434 - sandbox/krejcmat/src

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 28 13:56:58 PDT 2014


Author: krejcmat
Date: 2014-07-28 13:56:57 -0700 (Mon, 28 Jul 2014)
New Revision: 61434

Modified:
   sandbox/krejcmat/src/editor3.py
   sandbox/krejcmat/src/g.gui.metadata.py
   sandbox/krejcmat/src/mdgrass.py
Log:
g.gui.metadata- allows new session

Modified: sandbox/krejcmat/src/editor3.py
===================================================================
--- sandbox/krejcmat/src/editor3.py	2014-07-28 18:59:37 UTC (rev 61433)
+++ sandbox/krejcmat/src/editor3.py	2014-07-28 20:56:57 UTC (rev 61434)
@@ -283,6 +283,8 @@
 
     def __init__(self,parent,item,multiplicity=None,rmMulti=False,isFirstNum=-1):
         wx.BoxSizer.__init__(self, wx.VERTICAL)
+        self.isValid=False
+        
         self.mdDescription = item
 
         if multiplicity is None:
@@ -300,8 +302,8 @@
             self.valueCtrl = wx.TextCtrl(parent, id=ID_ANY, size=(0, 55),
                                          # validator=MyValidator('ALPHA_ONLY'),
                                          style=wx.VSCROLL |
-                                         wx.TE_MULTILINE | wx.TE_NO_VSCROLL | wx.TE_BESTWRAP |
-                                         wx.TAB_TRAVERSAL | wx.RAISED_BORDER | wx.HSCROLL)
+                                         wx.TE_MULTILINE  | wx.TE_WORDWRAP |
+                                         wx.TAB_TRAVERSAL | wx.RAISED_BORDER )
         else:
 
             self.valueCtrl = wx.TextCtrl(parent, id=wx.ID_ANY,
@@ -319,7 +321,10 @@
         if rmMulti:
             self.rmItemButt = wx.Button(parent, -1, size=(30, 30), label='-')
             self.rmItemButt.Bind(EVT_BUTTON, self.removeItem)
-
+        
+        
+        #self.valueCtrl.Bind(wx.EVT_ACTIVATE, )
+        
         self.createInfo()
         self.tip = wx.ToolTip(self.infoTip)
         self._addItemLay(item.multiline, rmMulti)
@@ -341,11 +346,12 @@
             string += 'DATA TYPE: \n' + self.mdDescription.type + '\n\n'
         string += '- -'*30 + '\n'    
         if self.mdDescription.statements is not None:     
-            string += 'statements: \n' + self.mdDescription.statements + '\n'
+            string += 'Jinja template info: \n' + self.mdDescription.statements + '\n'
+        else:
+            string += 'OWSLib info:\n' + self.mdDescription.tag 
         if self.mdDescription.statements1 is not None:     
             string +=  self.mdDescription.statements1 + '\n'   
                  
-        string += '\ntag: \n' + self.mdDescription.tag 
         self.infoTip = string
 
     def removeItem(self, evt):
@@ -381,14 +387,16 @@
         ##print "value ",value
         
         if value is None:
-            self.valueCtrl.SetBackgroundColour((245,204,230))
+            self.valueCtrl.SetBackgroundColour((245,204,230))#red
+            
             self.valueCtrl.SetValue('')
         elif value=='$NULL':
-            self.valueCtrl.SetBackgroundColour((255,255,82))
+            self.valueCtrl.SetBackgroundColour((255,255,82))#yellow
             self.valueCtrl.SetValue('')
         else:
             value=value.replace('"','')
             value=value.replace("'",'')
+            self.isValid=True
             self.valueCtrl.SetValue(value)
 
     def getValue(self):

Modified: sandbox/krejcmat/src/g.gui.metadata.py
===================================================================
--- sandbox/krejcmat/src/g.gui.metadata.py	2014-07-28 18:59:37 UTC (rev 61433)
+++ sandbox/krejcmat/src/g.gui.metadata.py	2014-07-28 20:56:57 UTC (rev 61434)
@@ -43,6 +43,7 @@
 from  lmgr import datacatalog 
 from core.gcmd import RunCommand, GError, GMessage
 import mdgrass
+from wx import SplitterWindow
 
 #===============================================================================
 # gsetup.init(gisbase,
@@ -51,129 +52,8 @@
 # from grass.pygrass.gis import Mapset
 #===============================================================================
 
-########################################################################
-class MapTree(datacatalog.LocationMapTree):
-    
-        def __init__(self, parent):
-            """Test Tree constructor."""
-            super(MapTree, self).__init__(parent)
-            self.InitTreeItems()
-            self.map=None
-            self.mapType=None
-            
-        def InitTreeItems(self):
-            """Add locations, mapsets and layers to the tree."""
-            gisenv = grass.gisenv()
-            location = gisenv['LOCATION_NAME']
-            self.mapset = gisenv['MAPSET']
-            self._initTreeItems(locations=[location],
-                                mapsets=[self.mapset])
-            self.ExpandAll()
-            self.Bind(wx.EVT_TREE_SEL_CHANGED,self.onChanged)
-            
-        def onChanged(self,evt=None):
-            if self.GetChildrenCount(evt.Item)==0:
-                self.map = self.GetItemText(evt.Item)+ '@'+self.mapset
-                self.mapType=self.GetItemParent(evt.Item)
-                self.mapType=self.GetItemText(self.mapType)               
-                if self.mapType =='vect':
-                    self.mapType='vector'
-                elif self.mapType == 'rast':
-                    self.mapType='cell'
-            else:
-                GMessage('Please select map.')
 
-        def _popupMenuLayer(self):
-            """Create popup menu for layers"""
-            pass
 
-        def _popupMenuMapset(self):
-            """Create popup menu for mapsets"""
-            pass
-
-
-class Html(wx.Panel):
-
-    def __init__(self, parent):
-        pass
-
-
-class RandomPanel(wx.Panel):
-
-    def __init__(self, parent, color):
-        wx.Panel.__init__(self, parent)
-        self.SetBackgroundColour(color)
-
-
-class TreeEditor(wx.TreeCtrl):
-
-    def __init__(self, parent, xmlPath):
-        wx.TreeCtrl.__init__(
-            self,
-            parent=parent,
-            id=wx.ID_ANY,
-            style=wx.TR_HAS_BUTTONS)
-        
-        self.parent = parent
-        self.fpath = xmlPath
-        self.xml = et.parse(self.fpath)
-
-        # wx.TreeCtrl(parent=self.parent,
-        root = self.fillmeup()
-        self.Expand(root)
-
-        # self.Bind(wx.EVT_CLOSE, self.OnClose)
-        # self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEdit)
-        self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnRClickAllChildren)
-
-    def fillmeup(self):
-        xml = self.xml.getroot()
-        tree = self
-        root = tree.AddRoot(xml.tag)
-
-        def add(parent, elem):
-            # count=0 # do not make empty field after  <appointment> or <item>
-            # etc
-            for e in elem:
-                if str(e).find("<!--") != -1:  # skip comments
-                    continue
-                tag = et.QName(e)
-                item = tree.AppendItem(parent, tag.localname, data=None)
-                if e.text:
-                    text = e.text.strip()
-                else:
-                    text = e.text
-                if text:
-                    val = tree.AppendItem(item, text)
-                    tree.SetPyData(val, e)
-                    # count+=1
-
-                add(item, e)
-        add(root, xml)
-        return root
-
-    #=========================================================================
-    # def OnEdit(self, evt):
-    #     elm = self.GetPyData(evt.Item)
-    #
-    #     #print evt.Label
-    #     if elm is not None:
-    #         elm.text = evt.Label
-    #         self.xml.write(self.fpath, encoding="UTF-8", xml_declaration=True)
-    # self.validate()
-    #=========================================================================
-
-    #=========================================================================
-    # def OnClose(self, evt):
-    #     self.Destroy()
-    #=========================================================================
-
-    def OnRClickAllChildren(self, evt):
-        if not self.IsExpanded(evt.Item):
-            self.ExpandAllChildren(evt.Item)
-        else:
-            self.CollapseAllChildren(evt.Item)
-
 class Toolbar(wx.Panel):
 
     def __init__(self, parent):
@@ -182,7 +62,17 @@
         self.xmlPath=None
         self.toolbar = wx.ToolBar(self, 1, wx.DefaultPosition, (-1, -1),)
 
+#-------------------------------------------------------------------- NEW SESION
         self.toolbar.AddSeparator()
+        
+        bitmapNew = wx.Image(
+            os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'create.png'),
+            wx.BITMAP_TYPE_PNG).ConvertToBitmap()
+        self.bttNew = BitmapBtnTxt(
+            self.toolbar, -1, bitmapNew, "new", size=(80, -1))
+        self.toolbar.AddControl(control=self.bttNew)
+        self.bttNew.Disable()
+        self.toolbar.AddSeparator()
 #----------------------------------------------------------------- OPEN TEMPLATE
         bitmapLoad = wx.Image(
             os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'open.png'),
@@ -219,14 +109,18 @@
         self.bttLoad.Bind(wx.EVT_BUTTON, self.OnOpenTemplate)
         self.bttsave.Bind(wx.EVT_BUTTON, self.onSaveXML)
         self.bttLoadXml.Bind(wx.EVT_BUTTON, self.onLoadXml)
+        self.bttNew.Bind(wx.EVT_BUTTON,self.onNewSesion)
+    #===========================================================================
+    # def forteseting(self,evt=None):
+    #     self.xmlPath = '/home/matt/Dropbox/gsoc/gsoc2014-krejci/src/metadata/series.xml'
+    #     self.jinjaFile  ='/home/matt/Dropbox/gsoc/gsoc2014-krejci/src/templates/grassInspireTemplateFinal.xml'
+    #       
+    #     self.onChangeXml() 
+    #     self.onChangeTemplate()
+    #===========================================================================
+    def onNewSesion(self,evt):
+        self.GetParent().init()
         
-    def forteseting(self,evt=None):
-        self.xmlPath = '/home/matt/Dropbox/gsoc/gsoc2014-krejci/src/metadata/series.xml'
-        self.jinjaFile  ='/home/matt/Dropbox/gsoc/gsoc2014-krejci/src/templates/grassInspireTemplateFinal.xml'
-          
-        self.onChangeXml() 
-        self.onChangeTemplate()
-        
     def onLoadXml(self,evt=None):
         dlg = wx.FileDialog(
                             self,
@@ -244,6 +138,7 @@
             dlg.Destroy()
                 
     def onSaveXML(self, evt=None):
+        
         dlg = wx.FileDialog(
             self,
             "Choose a file",
@@ -251,6 +146,7 @@
             "",
             "*.xml",
             wx.SAVE)
+        
         if dlg.ShowModal() == wx.ID_OK:
             if self.jinjaFile is None:
                 self.jinjaFile=self.GetParent().jinjaPath
@@ -262,11 +158,13 @@
         
     def onChangeXml(self,evt=None):
         self.GetParent().xmlPath = self.xmlPath
-        self.GetParent().refreshConfig()
+        if self.jinjaFile:
+            self.GetParent().init()
     
     def onChangeTemplate(self, evt=None):
         self.GetParent().jinjaPath = self.jinjaFile
-        self.GetParent().refreshConfig()
+        if self.xmlPath:
+            self.GetParent().init()
 
     def OnOpenTemplate(self, evt):
 
@@ -292,17 +190,11 @@
                 "",
                 "*.xml",
                 wx.OPEN)
+            
             if dlg.ShowModal() == wx.ID_OK:
-
                 self.jinjaFile = dlg.GetPath()
-                xml = self.GetParent().xmlPath
-                x, y = self.GetParent().GetSize()
-                MainFrame(self.jinjaFile, xml, (x, y))
-
-                self.GetParent().Close(True)
-                self.GetParent().DestroyChildren()
-
-                self.onChangeTemplate(None)
+                self.GetParent().init()
+                self.onChangeTemplate()
                 dlg.Destroy()
 
     def _layout(self):
@@ -339,10 +231,10 @@
 
         self.notebook_panel1 = wx.Panel(self, wx.ID_ANY)
 
-        if path is None:
-            self.tmpPanel = tempPanel(self.notebook_panel1)
-        else:
-            self.tree = TreeEditor(self.notebook_panel1, path)
+        #if path is None:
+        #    self.tmpPanel = tempPanel(self.notebook_panel1)
+        #else:
+        self.tree = TreeEditor(self.notebook_panel1, path)
 
         # second panel
         self.notebook_panel2 = wx.Panel(self, wx.ID_ANY, style=0)
@@ -383,20 +275,12 @@
         panelSizer2 = wx.BoxSizer(wx.VERTICAL)
         self.notebook_panel2.SetSizer(panelSizer2)
 
-#=========================================================================
-# class tempPanel(wx.Panel):
-#     def __init__(self, parent):
-#         wx.Panel.__init__(self, parent)
-#         self.mainSizer = wx.BoxSizer(wx.VERTICAL)
-#         self.SetSizer(self.mainSizer)
-#         infoText=wx.StaticText(self, id=wx.ID_ANY, label='Select ISO template with using toolbar(upper) and map in catalog browser(left)')
-#         self.mainSizer.Add(infoText, proportion=1, flag=wx.EXPAND)
-#=========================================================================
-class MdEditTypePanel(wx.Panel):
+
+class MdEditConfigPanel(wx.Panel):
     
     def __init__(self, parent):
         wx.Panel.__init__(self, parent,id=wx.ID_ANY)
-        
+        self.SetMinSize((240,-1))
         self.mapGrassEdit=True
 
         self.rbGrass = wx.RadioButton(self, id=wx.ID_ANY, label='Metadata map editor', style=wx.RB_GROUP)
@@ -428,18 +312,22 @@
         else:
             self.comboBoxProfile.Show()
             self.buttEdit.Show()
-        self.GetParent().GetParent().GetParent().editingType(self.mapGrassEdit)
+        self.GetParent().GetParent().editingStatus(self.mapGrassEdit)
 
        #print parent
     
     def onClickEdit(self,evt=None):
+        
         self.templeteChoice=self.comboBoxProfile.GetValue()
-        self.GetParent().GetParent().GetParent().editMapMetadata(self.templeteChoice)
-        self.buttEdit.Disable()
-        self.rbGrass.Disable()
-        self.rbExternal.Disable()
-        self.comboBoxProfile.Disable()
+        self.GetParent().GetParent().editMapMetadata(self.templeteChoice)
+        
+        #self.buttEdit.Disable()
+        #self.rbGrass.Disable()
+        #self.rbExternal.Disable()
+        #self.comboBoxProfile.Disable()
 
+        
+        
     def _layout(self):
         self.mainsizer = wx.BoxSizer(wx.VERTICAL)
         self.SetSizer(self.mainsizer)
@@ -458,23 +346,16 @@
         # self.template
         self.jinjaPath = jinjaPath
         self.xmlPath = xmlPath
+        self.first=True
+        self.firstAfterChoice=False
+        self.second=False
+        self.secondAfterChoice=False
+        
+        self.init()
 
-        self.init()
-        #=======================================================================
-        # if templeteChoice is not None:
-        #    #print '***'*50
-        #    #print 'haskjak'
-        #     self.jinjaPath=None
-        #     self.editMapMetadata(templeteChoice)
-        #=======================================================================
             
     def refreshConfig(self):
-       #print '***'*50
-       #print self.jinjaPath
-       #print self.xmlPath
-        
-        #self.xmlPath=os.path.basename(self.xmlPath)
-       #print '***'*50
+
         if self.jinjaPath and self.xmlPath:
             self.editor = mainEditor(self.splitter,self.jinjaPath,self.xmlPath)
             
@@ -483,51 +364,58 @@
             self.toolbar.bttsave.Enable()
             self.Show()
             
-    
+    def resizeFrame(self,x1=1,y1=0):
+            x,y=self.GetSize()
+            self.SetSize((x+x1,y+y1))      
+              
     def editMapMetadata(self,templeteChoice):
-        
-        if self.jinjaPath is None:
-            self.mapTreePanelLeft.Hide()
-            map=self.mapTreePanelLeft.map
-            maptype=self.mapTreePanelLeft.mapType
+        map=self.mapTreePanelLeft.map
+        maptype=self.mapTreePanelLeft.mapType      
+
+        if map is not None:
             
-            if map is not None:
-                mdCreator=mdgrass.GrassMD(map,maptype)
+            self.toolbar.bttNew.Enable()
+            self.toolbar.bttsave.Enable()
+            self.Hsizer.Remove(self.leftPanel)
+            self.leftPanel.SetSize((1,1))
+            #self.Hsizer.Fit()
+            self.splitter.Refresh()
+            self.resizeFrame()
+            self.splitter.SetSashGravity(0.7)
+            
+            mdCreator=mdgrass.GrassMD(map,maptype)                
+            if templeteChoice=='INSPIRE':
+                mdCreator.createGrassInspireISO()
+                self.jinjaPath=mdCreator.templatePathAbs
+                self.xmlPath = mdCreator.saveXML()
+                self.init()
                 
-                if templeteChoice=='INSPIRE':
+            elif templeteChoice=='GRASS BASIC':
+                mdCreator.createGrassBasicISO()
+                self.jinjaPath=mdCreator.templatePathAbs
+                self.xmlPath = mdCreator.saveXML()
+                self.init()
+                    
+            elif templeteChoice=='Load Custom':   
+                dlg = wx.FileDialog(
+                            self,
+                            "Choose a file",
+                            os.getcwd(),
+                            "",
+                            "*.xml",
+                            wx.OPEN)
+                    
+                if dlg.ShowModal() == wx.ID_OK:
                     mdCreator.createGrassInspireISO()
-                    self.jinjaPath=mdCreator.templatePathAbs
+                    self.jinjaPath = dlg.GetPath()
                     self.xmlPath = mdCreator.saveXML()
-                    self.refreshConfig()
-                    
-                elif templeteChoice=='GRASS BASIC':
-                    mdCreator.createGrassBasicISO()
-                    self.jinjaPath=mdCreator.templatePathAbs
-                    self.xmlPath = mdCreator.saveXML()
-                    self.refreshConfig()
-                    
-                elif templeteChoice=='Load Custom':   
-                    dlg = wx.FileDialog(
-                                self,
-                                "Choose a file",
-                                os.getcwd(),
-                                "",
-                                "*.xml",
-                                wx.OPEN)
-                    if dlg.ShowModal() == wx.ID_OK:
-                        mdCreator.createGrassInspireISO()
-                        self.jinjaPath = dlg.GetPath()
-                        self.xmlPath = mdCreator.saveXML()
-                        self.refreshConfig()
+                    self.init()
         else:            
-                x, y = self.GetSize()
-                MainFrame(self.jinjaPath, None, (x, y))
-
-                self.Close(True)
-                self.DestroyChildren()
-                                  
-    def editingType(self,editStatus):
+            pass
         
+                                   
+    def editingStatus(self,editStatus):
+        
         if editStatus:
             self.mapTreePanelLeft.Show()
             self.toolbar.bttLoad.Disable()
@@ -540,46 +428,225 @@
     
     def init(self):
 
-        self.toolbar = Toolbar(self)
-        self.splitter = MultiSplitterWindow(
-            self,
-            style=wx.SP_3D | wx.SP_LIVE_UPDATE)
+            if self.first:
+                self.first=False
+                self.firstAfterChoice=True
+                print "first-----"
+                self.toolbar = Toolbar(self)
+                
+                self.leftPanel=wx.Panel(self,id=wx.ID_ANY)
+                self.typePanelLeft=MdEditConfigPanel(self.leftPanel)
+                self.mapTreePanelLeft=MapTree(self.leftPanel)
+                self.splitter =SplitterWindow(
+                                                  self,
+                                                  style=wx.SP_3D | wx.SP_LIVE_UPDATE)                              
+                self.Show()
+                self._layout()
+
+            elif self.firstAfterChoice:
+                if self.jinjaPath and self.xmlPath:
+                    print "firstAfterChoice-----"
+                    self.firstAfterChoice=False
+                    self.second=True
+                    self.editor = mainEditor(
+                                            self.splitter,
+                                            self.jinjaPath,
+                                            self.xmlPath)
+                    self.ntbRight=NotebookRight(self.splitter,self.xmlPath)
+                    self.splitter.SplitVertically(self.editor, self.ntbRight,sashPosition=0.6)
+                    #self.toolbar.bttsave.Enable()
+                    #self._layout()
+                    self.resizeFrame(1, 0)
+                    self.Show()
+            
+            elif self.second:#if next initializing of editor
+                
+                print "second-----"
+                self.second=False
+                self.secondAfterChoice=True
+                self.splitter.Hide()
+                self.toolbar.bttNew.Disable()
+                self.toolbar.bttsave.Disable()
+                
+                self.Hsizer.Insert(0, self.leftPanel, proportion=0.5, flag=wx.EXPAND)
+                self.resizeFrame()
+                
+            elif self.secondAfterChoice:
+                if self.jinjaPath and self.xmlPath:
+                    print 'secondAfterChoice'
+                    self.secondAfterChoice=False
+                    self.second=True
+                    self.splitter.Show()
+                    self.toolbar.bttNew.Enable() 
+                    self.toolbar.bttsave.Enable()
+                    ntbRightBCK=self.ntbRight     
+                    self.ntbRight=NotebookRight(self.splitter,self.xmlPath) 
+                    self.splitter.ReplaceWindow(ntbRightBCK,self.ntbRight)                 
+                    
+                    editorTMP=self.editor
+                    self.editor = mainEditor(
+                        self.splitter,#
+                        self.jinjaPath,
+                        self.xmlPath)
+                    
+                    self.splitter.ReplaceWindow(editorTMP,self.editor)
+                    ntbRightBCK.Destroy()
+                    editorTMP.Destroy()
+                    self.resizeFrame()
+                    self.Show()
+                    self.splitter.SetSashGravity(0.6)                
+                
+    def _layout(self):
         
-        self.leftPanel=wx.Panel(self.splitter,id=wx.ID_ANY)
-        self.typePanelLeft=MdEditTypePanel(self.leftPanel)
-        self.mapTreePanelLeft=MapTree(self.leftPanel)
+        #if state=='first':
+            self.mainSizer = wx.BoxSizer(wx.VERTICAL)
+            self.SetSizer(self.mainSizer)
+                
+            self.mainSizer.Add(self.toolbar)
+            self.mainSizer.Add(
+                wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL, size=(10000, 5)))
+            self.mainSizer.Add(
+                wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL, size=(0, 5)))        
+    
+            self.leftPanelSizer=wx.BoxSizer(wx.VERTICAL)
+            self.leftPanel.SetSizer(self.leftPanelSizer)
+            self.leftPanelSizer.Add(self.typePanelLeft, proportion=0.2, flag=wx.EXPAND)
+            self.leftPanelSizer.Add(self.mapTreePanelLeft, proportion=1, flag=wx.EXPAND)
         
-        self.splitter.AppendWindow(self.leftPanel)
-
-        if self.jinjaPath and self.xmlPath:
-            self.editor = mainEditor(
-                self.splitter,
-                self.jinjaPath,
-                self.xmlPath)
+            self.Hsizer=wx.BoxSizer(wx.HORIZONTAL)
+            self.mainSizer.Add(self.Hsizer,proportion=1,flag=wx.EXPAND)        
+        
+            self.Hsizer.Add(self.leftPanel, proportion=0.5, flag=wx.EXPAND)
+            x,y=self.GetSize()
+            self.SetSize((x+1,y))
+        #else:
+            #print '2 lay----'
+            self.Hsizer.Add(self.splitter, proportion=1, flag=wx.EXPAND)
+            self.splitter.SetSashGravity(0.6)
+            self.splitter.SizeWindows()
+            self.resizeFrame(300, 0)
+########################################################################
+class MapTree(datacatalog.LocationMapTree):
+    
+        def __init__(self, parent):
+            """Test Tree constructor."""
+            super(MapTree, self).__init__(parent)
+            self.InitTreeItems()
+            self.map=None
+            self.mapType=None
             
-            self.splitter.AppendWindow(self.editor)
-            self.splitter.AppendWindow(NotebookRight(self.splitter,self.xmlPath))
+        def InitTreeItems(self):
+            """Add locations, mapsets and layers to the tree."""
+            gisenv = grass.gisenv()
+            location = gisenv['LOCATION_NAME']
+            self.mapset = gisenv['MAPSET']
+            self._initTreeItems(locations=[location],
+                                mapsets=[self.mapset])
+            self.ExpandAll()
+            self.Bind(wx.EVT_TREE_SEL_CHANGED,self.onChanged)
+            
+        def onChanged(self,evt=None):
+            if self.GetChildrenCount(evt.Item)==0:
+                self.map = self.GetItemText(evt.Item)+ '@'+self.mapset
+                self.mapType=self.GetItemParent(evt.Item)
+                self.mapType=self.GetItemText(self.mapType)               
+                if self.mapType =='vect':
+                    self.mapType='vector'
+                elif self.mapType == 'rast':
+                    self.mapType='cell'
+            else:
+                GMessage('Please select map.')
 
-        self._layout()
-        self.Show()
+        def _popupMenuLayer(self):
+            """Create popup menu for layers"""
+            pass
 
-    def _layout(self):
-        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
-        self.SetSizer(self.mainSizer)
+        def _popupMenuMapset(self):
+            """Create popup menu for mapsets"""
+            pass
 
-        self.leftPanelSizer=wx.BoxSizer(wx.VERTICAL)
-        self.leftPanel.SetSizer(self.leftPanelSizer)
-        self.leftPanelSizer.Add(self.typePanelLeft, proportion=0.2, flag=wx.EXPAND)
-        self.leftPanelSizer.Add(self.mapTreePanelLeft, proportion=1, flag=wx.EXPAND)
+
+class Html(wx.Panel):
+
+    def __init__(self, parent):
+        pass
+
+
+class RandomPanel(wx.Panel):
+
+    def __init__(self, parent, color):
+        wx.Panel.__init__(self, parent)
+        self.SetBackgroundColour(color)
+
+class TreeEditor(wx.TreeCtrl):
+
+    def __init__(self, parent, xmlPath):
+        wx.TreeCtrl.__init__(
+            self,
+            parent=parent,
+            id=wx.ID_ANY,
+            style=wx.TR_HAS_BUTTONS)
         
-        self.mainSizer.Add(self.toolbar)
-        self.mainSizer.Add(
-            wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL, size=(10000, 5)))
-        self.mainSizer.Add(
-            wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL, size=(0, 5)))
-        self.mainSizer.Add(self.splitter, proportion=1, flag=wx.EXPAND)
+        self.parent = parent
+        self.fpath = xmlPath
+        self.xml = et.parse(self.fpath)
 
+        # wx.TreeCtrl(parent=self.parent,
+        root = self.fillmeup()
+        self.Expand(root)
 
+        # self.Bind(wx.EVT_CLOSE, self.OnClose)
+        # self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEdit)
+        self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnRClickAllChildren)
+
+    def fillmeup(self):
+        xml = self.xml.getroot()
+        tree = self
+        root = tree.AddRoot(xml.tag)
+
+        def add(parent, elem):
+            # count=0 # do not make empty field after  <appointment> or <item>
+            # etc
+            for e in elem:
+                if str(e).find("<!--") != -1:  # skip comments
+                    continue
+                tag = et.QName(e)
+                item = tree.AppendItem(parent, tag.localname, data=None)
+                if e.text:
+                    text = e.text.strip()
+                else:
+                    text = e.text
+                if text:
+                    val = tree.AppendItem(item, text)
+                    tree.SetPyData(val, e)
+                    # count+=1
+
+                add(item, e)
+        add(root, xml)
+        return root
+
+    #=========================================================================
+    # def OnEdit(self, evt):
+    #     elm = self.GetPyData(evt.Item)
+    #
+    #     #print evt.Label
+    #     if elm is not None:
+    #         elm.text = evt.Label
+    #         self.xml.write(self.fpath, encoding="UTF-8", xml_declaration=True)
+    # self.validate()
+    #=========================================================================
+
+    #=========================================================================
+    # def OnClose(self, evt):
+    #     self.Destroy()
+    #=========================================================================
+
+    def OnRClickAllChildren(self, evt):
+        if not self.IsExpanded(evt.Item):
+            self.ExpandAllChildren(evt.Item)
+        else:
+            self.CollapseAllChildren(evt.Item)
+            
 class InspireValidator(wx.Panel):
 
     def __init__(self, parent):
@@ -854,7 +921,7 @@
                 result["status"] = "failed"
                 result["num_of_errors"] = str(errors)
             #print result
-            str1  = 'INSPIRE VALIDATOR'
+            str1  = 'INSPIRE VALIDATOR\n'
             str1 += 'Status of validation: ' + result["status"] + '\n'
             str1 += 'Numbers of errors: ' + result["num_of_errors"] + '\n'
 

Modified: sandbox/krejcmat/src/mdgrass.py
===================================================================
--- sandbox/krejcmat/src/mdgrass.py	2014-07-28 18:59:37 UTC (rev 61433)
+++ sandbox/krejcmat/src/mdgrass.py	2014-07-28 20:56:57 UTC (rev 61434)
@@ -249,6 +249,7 @@
             val.role = 'owner'
             self.md.identification.contact.append(val)
         self.templatePathAbs=os.path.join(self.dirpath,self.template)
+        
     def createGrassInspireISO(self,template=None):
         '''Create valid INSPIRE profile and fill it as much as possible by GRASS metadata. Missing values is $NULL
         -create basic md profile and add INSPIRE mandatory attributes



More information about the grass-commit mailing list