PLCOpenEditor.py
changeset 500 b3499ff87178
parent 498 5f90349529c9
child 503 52689bda4686
--- a/PLCOpenEditor.py	Mon May 10 21:36:11 2010 +0200
+++ b/PLCOpenEditor.py	Wed May 19 22:16:29 2010 +0200
@@ -2504,12 +2504,15 @@
     def __init__(self, parent, fileOpen = None):
         IDEFrame.__init__(self, parent)
         
+        result = None
+        
         # Open the filepath if defined
         if fileOpen is not None and os.path.isfile(fileOpen):
             # Create a new controller
             self.Controler = PLCControler()
-            self.Controler.OpenXMLFile(fileOpen)
-            self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
+            result = self.Controler.OpenXMLFile(fileOpen)
+            if result is None:
+                self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
         
         # Define PLCOpenEditor icon
         self.SetIcon(wx.Icon(os.path.join(CWD,"Images", "poe.ico"),wx.BITMAP_TYPE_ICO))
@@ -2517,6 +2520,9 @@
         self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
         
         self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
+        
+        if result is not None:
+            self.ShowErrorMessage(result)
 
     def OnCloseFrame(self, event):
         if self.Controler is None or self.CheckSaveBeforeClosing(_("Close Application")):
@@ -2595,16 +2601,23 @@
             directory = os.path.dirname(filepath)
         else:
             directory = os.getcwd()
+        
+        result = None
+        
         dialog = wx.FileDialog(self, _("Choose a file"), directory, "",  _("PLCOpen files (*.xml)|*.xml|All files|*.*"), wx.OPEN)
         if dialog.ShowModal() == wx.ID_OK:
             filepath = dialog.GetPath()
             if os.path.isfile(filepath):
                 self.ResetView()
                 self.Controler = PLCControler()
-                self.Controler.OpenXMLFile(filepath)
-                self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
+                result = self.Controler.OpenXMLFile(filepath)
+                if result is None:
+                    self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
             self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
         dialog.Destroy()
+        
+        if result is not None:
+            self.ShowErrorMessage(result)
     
     def OnCloseProjectMenu(self, event):
         if not self.CheckSaveBeforeClosing():