objdictgen/objdictedit.py
changeset 512 e84806c0ada4
parent 491 2ad3dedf6c6a
child 527 7d5c74cc8f91
equal deleted inserted replaced
511:34300a28ad27 512:e84806c0ada4
   296         
   296         
   297         if self.ModeSolo:
   297         if self.ModeSolo:
   298             self.Manager = NodeManager()
   298             self.Manager = NodeManager()
   299             for filepath in filesOpen:
   299             for filepath in filesOpen:
   300                 result = self.Manager.OpenFileInCurrent(filepath)
   300                 result = self.Manager.OpenFileInCurrent(filepath)
   301                 if type(result) == IntType:
   301                 if isinstance(result, (IntType, LongType)):
   302                     new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
   302                     new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
   303                     new_editingpanel.SetIndex(result)
   303                     new_editingpanel.SetIndex(result)
   304                     self.FileOpened.AddPage(new_editingpanel, "")
   304                     self.FileOpened.AddPage(new_editingpanel, "")
   305         else:
   305         else:
   306             self.Manager = manager
   306             self.Manager = manager
   387             result = window.GetSelection()
   387             result = window.GetSelection()
   388             if result:
   388             if result:
   389                 find_index = True
   389                 find_index = True
   390                 index, subIndex = result
   390                 index, subIndex = result
   391                 result = OpenPDFDocIndex(index, ScriptDirectory)
   391                 result = OpenPDFDocIndex(index, ScriptDirectory)
   392                 if type(result) == StringType:
   392                 if isinstance(result, (StringType, UnicodeType)):
   393                     message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
   393                     message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
   394                     message.ShowModal()
   394                     message.ShowModal()
   395                     message.Destroy()
   395                     message.Destroy()
   396         if not find_index:
   396         if not find_index:
   397             result = OpenPDFDocIndex(None, ScriptDirectory)
   397             result = OpenPDFDocIndex(None, ScriptDirectory)
   398             if type(result) == StringType:
   398             if isinstance(result, (StringType, UnicodeType)):
   399                 message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
   399                 message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
   400                 message.ShowModal()
   400                 message.ShowModal()
   401                 message.Destroy()
   401                 message.Destroy()
   402         event.Skip()
   402         event.Skip()
   403         
   403         
   596             name, id, nodetype, description = dialog.GetValues()
   596             name, id, nodetype, description = dialog.GetValues()
   597             profile, filepath = dialog.GetProfile()
   597             profile, filepath = dialog.GetProfile()
   598             NMT = dialog.GetNMTManagement()
   598             NMT = dialog.GetNMTManagement()
   599             options = dialog.GetOptions()
   599             options = dialog.GetOptions()
   600             result = self.Manager.CreateNewNode(name, id, nodetype, description, profile, filepath, NMT, options)
   600             result = self.Manager.CreateNewNode(name, id, nodetype, description, profile, filepath, NMT, options)
   601             if type(result) == IntType:
   601             if isinstance(result, (IntType, LongType)):
   602                 new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
   602                 new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
   603                 new_editingpanel.SetIndex(result)
   603                 new_editingpanel.SetIndex(result)
   604                 self.FileOpened.AddPage(new_editingpanel, "")
   604                 self.FileOpened.AddPage(new_editingpanel, "")
   605                 self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
   605                 self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
   606                 self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, False)
   606                 self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, False)
   625         dialog = wx.FileDialog(self, "Choose a file", directory, "",  "OD files (*.od)|*.od|All files|*.*", wx.OPEN|wx.CHANGE_DIR)
   625         dialog = wx.FileDialog(self, "Choose a file", directory, "",  "OD files (*.od)|*.od|All files|*.*", wx.OPEN|wx.CHANGE_DIR)
   626         if dialog.ShowModal() == wx.ID_OK:
   626         if dialog.ShowModal() == wx.ID_OK:
   627             filepath = dialog.GetPath()
   627             filepath = dialog.GetPath()
   628             if os.path.isfile(filepath):
   628             if os.path.isfile(filepath):
   629                 result = self.Manager.OpenFileInCurrent(filepath)
   629                 result = self.Manager.OpenFileInCurrent(filepath)
   630                 if type(result) == IntType:
   630                 if isinstance(result, (IntType, LongType)):
   631                     new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
   631                     new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
   632                     new_editingpanel.SetIndex(result)
   632                     new_editingpanel.SetIndex(result)
   633                     self.FileOpened.AddPage(new_editingpanel, "")
   633                     self.FileOpened.AddPage(new_editingpanel, "")
   634                     self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
   634                     self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
   635                     if self.Manager.CurrentDS302Defined(): 
   635                     if self.Manager.CurrentDS302Defined(): 
   661         
   661         
   662     def Save(self):
   662     def Save(self):
   663         result = self.Manager.SaveCurrentInFile()
   663         result = self.Manager.SaveCurrentInFile()
   664         if not result:
   664         if not result:
   665             self.SaveAs()
   665             self.SaveAs()
   666         elif type(result) != StringType:
   666         elif not isinstance(result, (StringType, UnicodeType)):
   667             self.RefreshBufferState()
   667             self.RefreshBufferState()
   668         else:
   668         else:
   669             message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
   669             message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
   670             message.ShowModal()
   670             message.ShowModal()
   671             message.Destroy()
   671             message.Destroy()
   679         dialog = wx.FileDialog(self, "Choose a file", directory, filename,  "OD files (*.od)|*.od|All files|*.*", wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
   679         dialog = wx.FileDialog(self, "Choose a file", directory, filename,  "OD files (*.od)|*.od|All files|*.*", wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
   680         if dialog.ShowModal() == wx.ID_OK:
   680         if dialog.ShowModal() == wx.ID_OK:
   681             filepath = dialog.GetPath()
   681             filepath = dialog.GetPath()
   682             if os.path.isdir(os.path.dirname(filepath)):
   682             if os.path.isdir(os.path.dirname(filepath)):
   683                 result = self.Manager.SaveCurrentInFile(filepath)
   683                 result = self.Manager.SaveCurrentInFile(filepath)
   684                 if type(result) != StringType:
   684                 if not isinstance(result, (StringType, UnicodeType)):
   685                     self.RefreshBufferState()
   685                     self.RefreshBufferState()
   686                 else:
   686                 else:
   687                     message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
   687                     message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
   688                     message.ShowModal()
   688                     message.ShowModal()
   689                     message.Destroy()
   689                     message.Destroy()
   724         dialog = wx.FileDialog(self, "Choose a file", os.getcwd(), "",  "EDS files (*.eds)|*.eds|All files|*.*", wx.OPEN|wx.CHANGE_DIR)
   724         dialog = wx.FileDialog(self, "Choose a file", os.getcwd(), "",  "EDS files (*.eds)|*.eds|All files|*.*", wx.OPEN|wx.CHANGE_DIR)
   725         if dialog.ShowModal() == wx.ID_OK:
   725         if dialog.ShowModal() == wx.ID_OK:
   726             filepath = dialog.GetPath()
   726             filepath = dialog.GetPath()
   727             if os.path.isfile(filepath):
   727             if os.path.isfile(filepath):
   728                 result = self.Manager.ImportCurrentFromEDSFile(filepath)
   728                 result = self.Manager.ImportCurrentFromEDSFile(filepath)
   729                 if type(result) == IntType:
   729                 if isinstance(result, (IntType, LongType)):
   730                     new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
   730                     new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
   731                     new_editingpanel.SetIndex(result)
   731                     new_editingpanel.SetIndex(result)
   732                     self.FileOpened.AddPage(new_editingpanel, "")
   732                     self.FileOpened.AddPage(new_editingpanel, "")
   733                     self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
   733                     self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
   734                     self.RefreshBufferState()
   734                     self.RefreshBufferState()
   879             dialog = MapVariableDialog(self)
   879             dialog = MapVariableDialog(self)
   880             dialog.SetIndex(index)
   880             dialog.SetIndex(index)
   881             if dialog.ShowModal() == wx.ID_OK:
   881             if dialog.ShowModal() == wx.ID_OK:
   882                 index, name, struct, number = dialog.GetValues()
   882                 index, name, struct, number = dialog.GetValues()
   883                 result = self.Manager.AddMapVariableToCurrent(index, name, struct, number)
   883                 result = self.Manager.AddMapVariableToCurrent(index, name, struct, number)
   884                 if type(result) != StringType:
   884                 if not isinstance(result, (StringType, UnicodeType)):
   885                     self.RefreshBufferState()
   885                     self.RefreshBufferState()
   886                     self.RefreshCurrentIndexList()
   886                     self.RefreshCurrentIndexList()
   887                 else:
   887                 else:
   888                     message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
   888                     message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
   889                     message.ShowModal()
   889                     message.ShowModal()