--- a/objdictgen/networkedit.py Thu Mar 07 11:40:28 2013 +0900
+++ b/objdictgen/networkedit.py Wed Mar 27 09:32:05 2013 +0900
@@ -22,7 +22,6 @@
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import wx
-import wx.grid
from types import *
import os, re, platform, sys, time, traceback, getopt
@@ -84,9 +83,7 @@
from nodelist import *
from nodemanager import *
-from nodeeditor import NodeEditorTemplate
-from subindextable import *
-from commondialogs import *
+from networkeditortemplate import NetworkEditorTemplate
from doc_index.DS301_index import *
try:
@@ -160,125 +157,6 @@
except:
Html_Window = False
-[ID_NETWORKEDITORNETWORKNODES,
-] = [wx.NewId() for _init_ctrls in range(1)]
-
-class NetworkEditorTemplate(NodeEditorTemplate):
-
- def _init_ctrls(self, prnt):
- self.NetworkNodes = wx.Notebook(id=ID_NETWORKEDITNETWORKNODES,
- name='NetworkNodes', parent=prnt, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.NB_LEFT)
- self.NetworkNodes.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
- self.OnNodeSelectedChanged, id=ID_NETWORKEDITNETWORKNODES)
-
- def __init__(self, manager, frame, mode_solo):
- self.NodeList = manager
- NodeEditorTemplate.__init__(self, self.NodeList.GetManager(), frame, mode_solo)
-
- def GetCurrentNodeId(self):
- selected = self.NetworkNodes.GetSelection()
- # At init selected = -1
- if selected > 0:
- window = self.NetworkNodes.GetPage(selected)
- return window.GetIndex()
- else:
- return 0
-
- def RefreshCurrentIndexList(self):
- selected = self.NetworkNodes.GetSelection()
- if selected == 0:
- window = self.NetworkNodes.GetPage(selected)
- window.RefreshIndexList()
- else:
- pass
-
- def RefreshNetworkNodes(self):
- if self.NetworkNodes.GetPageCount() > 0:
- self.NetworkNodes.DeleteAllPages()
- if self.NodeList:
- new_editingpanel = EditingPanel(self.NetworkNodes, self, self.Manager)
- new_editingpanel.SetIndex(self.Manager.GetCurrentNodeID())
- self.NetworkNodes.AddPage(new_editingpanel, "")
- for idx in self.NodeList.GetSlaveIDs():
- new_editingpanel = EditingPanel(self.NetworkNodes, self, self.NodeList, False)
- new_editingpanel.SetIndex(idx)
- self.NetworkNodes.AddPage(new_editingpanel, "")
-
- def OnNodeSelectedChanged(self, event):
- if not self.Closing:
- selected = event.GetSelection()
- # At init selected = -1
- if selected >= 0:
- window = self.NetworkNodes.GetPage(selected)
- self.NodeList.SetCurrentSelected(window.GetIndex())
- wx.CallAfter(self.RefreshMainMenu)
- wx.CallAfter(self.RefreshStatusBar)
- event.Skip()
-
-#-------------------------------------------------------------------------------
-# Buffer Functions
-#-------------------------------------------------------------------------------
-
- def RefreshBufferState(self):
- if self.NodeList is not None:
- nodeID = self.Manager.GetCurrentNodeID()
- if nodeID != None:
- nodename = "0x%2.2X %s"%(nodeID, self.Manager.GetCurrentNodeName())
- else:
- nodename = self.Manager.GetCurrentNodeName()
- self.NetworkNodes.SetPageText(0, nodename)
- for idx, name in enumerate(self.NodeList.GetSlaveNames()):
- self.NetworkNodes.SetPageText(idx + 1, name)
-
-#-------------------------------------------------------------------------------
-# Slave Nodes Management
-#-------------------------------------------------------------------------------
-
- def OnAddSlaveMenu(self, event):
- dialog = AddSlaveDialog(self.Frame)
- dialog.SetNodeList(self.NodeList)
- if dialog.ShowModal() == wx.ID_OK:
- values = dialog.GetValues()
- result = self.NodeList.AddSlaveNode(values["slaveName"], values["slaveNodeID"], values["edsFile"])
- if not result:
- new_editingpanel = EditingPanel(self.NetworkNodes, self, self.NodeList, False)
- new_editingpanel.SetIndex(values["slaveNodeID"])
- idx = self.NodeList.GetOrderNumber(values["slaveNodeID"])
- self.NetworkNodes.InsertPage(idx, new_editingpanel, "")
- self.NodeList.SetCurrentSelected(idx)
- self.NetworkNodes.SetSelection(idx)
- self.RefreshBufferState()
- else:
- self.ShowErrorMessage(result)
- dialog.Destroy()
-
- def OnRemoveSlaveMenu(self, event):
- slavenames = self.NodeList.GetSlaveNames()
- slaveids = self.NodeList.GetSlaveIDs()
- dialog = wx.SingleChoiceDialog(self.Frame, _("Choose a slave to remove"), _("Remove slave"), slavenames)
- if dialog.ShowModal() == wx.ID_OK:
- choice = dialog.GetSelection()
- result = self.NodeList.RemoveSlaveNode(slaveids[choice])
- if not result:
- slaveids.pop(choice)
- current = self.NetworkNodes.GetSelection()
- self.NetworkNodes.DeletePage(choice + 1)
- if self.NetworkNodes.GetPageCount() > 0:
- new_selection = min(current, self.NetworkNodes.GetPageCount() - 1)
- self.NetworkNodes.SetSelection(new_selection)
- if new_selection > 0:
- self.NodeList.SetCurrentSelected(slaveids[new_selection - 1])
- self.RefreshBufferState()
- else:
- self.ShowErrorMessage(result)
- dialog.Destroy()
-
- def OpenMasterDCFDialog(self, node_id):
- self.NetworkNodes.SetSelection(0)
- self.NetworkNodes.GetPage(0).OpenDCFDialog(node_id)
-
-
[ID_NETWORKEDIT, ID_NETWORKEDITNETWORKNODES,
ID_NETWORKEDITHELPBAR,
] = [wx.NewId() for _init_ctrls in range(3)]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/objdictgen/networkeditortemplate.py Wed Mar 27 09:32:05 2013 +0900
@@ -0,0 +1,123 @@
+import wx
+
+from nodeeditor import NodeEditorTemplate
+from subindextable import *
+from commondialogs import *
+
+[ID_NETWORKEDITNETWORKNODES,
+] = [wx.NewId() for _init_ctrls in range(1)]
+
+class NetworkEditorTemplate(NodeEditorTemplate):
+
+ def _init_ctrls(self, prnt):
+ self.NetworkNodes = wx.Notebook(id=ID_NETWORKEDITNETWORKNODES,
+ name='NetworkNodes', parent=prnt, pos=wx.Point(0, 0),
+ size=wx.Size(0, 0), style=wx.NB_LEFT)
+ self.NetworkNodes.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
+ self.OnNodeSelectedChanged, id=ID_NETWORKEDITNETWORKNODES)
+
+ def __init__(self, manager, frame, mode_solo):
+ self.NodeList = manager
+ NodeEditorTemplate.__init__(self, self.NodeList.GetManager(), frame, mode_solo)
+
+ def GetCurrentNodeId(self):
+ selected = self.NetworkNodes.GetSelection()
+ # At init selected = -1
+ if selected > 0:
+ window = self.NetworkNodes.GetPage(selected)
+ return window.GetIndex()
+ else:
+ return 0
+
+ def RefreshCurrentIndexList(self):
+ selected = self.NetworkNodes.GetSelection()
+ if selected == 0:
+ window = self.NetworkNodes.GetPage(selected)
+ window.RefreshIndexList()
+ else:
+ pass
+
+ def RefreshNetworkNodes(self):
+ if self.NetworkNodes.GetPageCount() > 0:
+ self.NetworkNodes.DeleteAllPages()
+ if self.NodeList:
+ new_editingpanel = EditingPanel(self.NetworkNodes, self, self.Manager)
+ new_editingpanel.SetIndex(self.Manager.GetCurrentNodeID())
+ self.NetworkNodes.AddPage(new_editingpanel, "")
+ for idx in self.NodeList.GetSlaveIDs():
+ new_editingpanel = EditingPanel(self.NetworkNodes, self, self.NodeList, False)
+ new_editingpanel.SetIndex(idx)
+ self.NetworkNodes.AddPage(new_editingpanel, "")
+
+ def OnNodeSelectedChanged(self, event):
+ if not self.Closing:
+ selected = event.GetSelection()
+ # At init selected = -1
+ if selected >= 0:
+ window = self.NetworkNodes.GetPage(selected)
+ self.NodeList.SetCurrentSelected(window.GetIndex())
+ wx.CallAfter(self.RefreshMainMenu)
+ wx.CallAfter(self.RefreshStatusBar)
+ event.Skip()
+
+#-------------------------------------------------------------------------------
+# Buffer Functions
+#-------------------------------------------------------------------------------
+
+ def RefreshBufferState(self):
+ if self.NodeList is not None:
+ nodeID = self.Manager.GetCurrentNodeID()
+ if nodeID != None:
+ nodename = "0x%2.2X %s"%(nodeID, self.Manager.GetCurrentNodeName())
+ else:
+ nodename = self.Manager.GetCurrentNodeName()
+ self.NetworkNodes.SetPageText(0, nodename)
+ for idx, name in enumerate(self.NodeList.GetSlaveNames()):
+ self.NetworkNodes.SetPageText(idx + 1, name)
+
+#-------------------------------------------------------------------------------
+# Slave Nodes Management
+#-------------------------------------------------------------------------------
+
+ def OnAddSlaveMenu(self, event):
+ dialog = AddSlaveDialog(self.Frame)
+ dialog.SetNodeList(self.NodeList)
+ if dialog.ShowModal() == wx.ID_OK:
+ values = dialog.GetValues()
+ result = self.NodeList.AddSlaveNode(values["slaveName"], values["slaveNodeID"], values["edsFile"])
+ if not result:
+ new_editingpanel = EditingPanel(self.NetworkNodes, self, self.NodeList, False)
+ new_editingpanel.SetIndex(values["slaveNodeID"])
+ idx = self.NodeList.GetOrderNumber(values["slaveNodeID"])
+ self.NetworkNodes.InsertPage(idx, new_editingpanel, "")
+ self.NodeList.SetCurrentSelected(idx)
+ self.NetworkNodes.SetSelection(idx)
+ self.RefreshBufferState()
+ else:
+ self.ShowErrorMessage(result)
+ dialog.Destroy()
+
+ def OnRemoveSlaveMenu(self, event):
+ slavenames = self.NodeList.GetSlaveNames()
+ slaveids = self.NodeList.GetSlaveIDs()
+ dialog = wx.SingleChoiceDialog(self.Frame, _("Choose a slave to remove"), _("Remove slave"), slavenames)
+ if dialog.ShowModal() == wx.ID_OK:
+ choice = dialog.GetSelection()
+ result = self.NodeList.RemoveSlaveNode(slaveids[choice])
+ if not result:
+ slaveids.pop(choice)
+ current = self.NetworkNodes.GetSelection()
+ self.NetworkNodes.DeletePage(choice + 1)
+ if self.NetworkNodes.GetPageCount() > 0:
+ new_selection = min(current, self.NetworkNodes.GetPageCount() - 1)
+ self.NetworkNodes.SetSelection(new_selection)
+ if new_selection > 0:
+ self.NodeList.SetCurrentSelected(slaveids[new_selection - 1])
+ self.RefreshBufferState()
+ else:
+ self.ShowErrorMessage(result)
+ dialog.Destroy()
+
+ def OpenMasterDCFDialog(self, node_id):
+ self.NetworkNodes.SetSelection(0)
+ self.NetworkNodes.GetPage(0).OpenDCFDialog(node_id)
--- a/objdictgen/nodeeditor.py Thu Mar 07 11:40:28 2013 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +0,0 @@
-from types import *
-
-import wx
-
-from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes
-from commondialogs import *
-
-class NodeEditorTemplate:
-
- EDITMENU_ID = None
-
- def __init__(self, manager, frame, mode_solo):
- self.Manager = manager
- self.Frame = frame
- self.ModeSolo = mode_solo
-
- self.BusId = None
- self.Closing = False
-
- def SetBusId(self, bus_id):
- self.BusId = bus_id
-
- def GetBusId(self):
- return self.BusId
-
- def IsClosing(self):
- return self.Closing
-
- def OnAddSDOServerMenu(self, event):
- self.Manager.AddSDOServerToCurrent()
- self.RefreshBufferState()
- self.RefreshCurrentIndexList()
-
- def OnAddSDOClientMenu(self, event):
- self.Manager.AddSDOClientToCurrent()
- self.RefreshBufferState()
- self.RefreshCurrentIndexList()
-
- def OnAddPDOTransmitMenu(self, event):
- self.Manager.AddPDOTransmitToCurrent()
- self.RefreshBufferState()
- self.RefreshCurrentIndexList()
-
- def OnAddPDOReceiveMenu(self, event):
- self.Manager.AddPDOReceiveToCurrent()
- self.RefreshBufferState()
- self.RefreshCurrentIndexList()
-
- def OnAddMapVariableMenu(self, event):
- self.AddMapVariable()
-
- def OnAddUserTypeMenu(self, event):
- self.AddUserType()
-
- def OnRefreshMenu(self, event):
- self.RefreshCurrentIndexList()
-
- def RefreshCurrentIndexList(self):
- pass
-
- def RefreshStatusBar(self):
- pass
-
- def SetStatusBarText(self, selection, manager):
- if selection:
- index, subIndex = selection
- if manager.IsCurrentEntry(index):
- self.Frame.HelpBar.SetStatusText(_("Index: 0x%04X")%index, 0)
- self.Frame.HelpBar.SetStatusText(_("Subindex: 0x%02X")%subIndex, 1)
- entryinfos = manager.GetEntryInfos(index)
- name = entryinfos["name"]
- category = _("Optional")
- if entryinfos["need"]:
- category = _("Mandatory")
- struct = "VAR"
- number = ""
- if entryinfos["struct"] & OD_IdenticalIndexes:
- number = _(" possibly defined %d times")%entryinfos["nbmax"]
- if entryinfos["struct"] & OD_IdenticalSubindexes:
- struct = "REC"
- elif entryinfos["struct"] & OD_MultipleSubindexes:
- struct = "ARRAY"
- text = _("%s: %s entry of struct %s%s.")%(name,category,struct,number)
- self.Frame.HelpBar.SetStatusText(text, 2)
- else:
- for i in xrange(3):
- self.Frame.HelpBar.SetStatusText("", i)
- else:
- for i in xrange(3):
- self.Frame.HelpBar.SetStatusText("", i)
-
- def RefreshProfileMenu(self):
- if self.EDITMENU_ID is not None:
- profile = self.Manager.GetCurrentProfileName()
- edititem = self.Frame.EditMenu.FindItemById(self.EDITMENU_ID)
- if edititem:
- length = self.Frame.AddMenu.GetMenuItemCount()
- for i in xrange(length-6):
- additem = self.Frame.AddMenu.FindItemByPosition(6)
- self.Frame.AddMenu.Delete(additem.GetId())
- if profile not in ("None", "DS-301"):
- edititem.SetText(_("%s Profile")%profile)
- edititem.Enable(True)
- self.Frame.AddMenu.AppendSeparator()
- for text, indexes in self.Manager.GetCurrentSpecificMenu():
- new_id = wx.NewId()
- self.Frame.AddMenu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=text)
- self.Frame.Bind(wx.EVT_MENU, self.GetProfileCallBack(text), id=new_id)
- else:
- edititem.SetText(_("Other Profile"))
- edititem.Enable(False)
-
-#-------------------------------------------------------------------------------
-# Buffer Functions
-#-------------------------------------------------------------------------------
-
- def RefreshBufferState(self):
- pass
-
- def OnUndoMenu(self, event):
- self.Manager.LoadCurrentPrevious()
- self.RefreshCurrentIndexList()
- self.RefreshBufferState()
-
- def OnRedoMenu(self, event):
- self.Manager.LoadCurrentNext()
- self.RefreshCurrentIndexList()
- self.RefreshBufferState()
-
-#-------------------------------------------------------------------------------
-# Editing Profiles functions
-#-------------------------------------------------------------------------------
-
- def OnCommunicationMenu(self, event):
- dictionary,current = self.Manager.GetCurrentCommunicationLists()
- self.EditProfile(_("Edit DS-301 Profile"), dictionary, current)
-
- def OnOtherCommunicationMenu(self, event):
- dictionary,current = self.Manager.GetCurrentDS302Lists()
- self.EditProfile(_("Edit DS-302 Profile"), dictionary, current)
-
- def OnEditProfileMenu(self, event):
- title = _("Edit %s Profile") % self.Manager.GetCurrentProfileName()
- dictionary,current = self.Manager.GetCurrentProfileLists()
- self.EditProfile(title, dictionary, current)
-
- def EditProfile(self, title, dictionary, current):
- dialog = CommunicationDialog(self.Frame)
- dialog.SetTitle(title)
- dialog.SetIndexDictionary(dictionary)
- dialog.SetCurrentList(current)
- dialog.RefreshLists()
- if dialog.ShowModal() == wx.ID_OK:
- new_profile = dialog.GetCurrentList()
- addinglist = []
- removinglist = []
- for index in new_profile:
- if index not in current:
- addinglist.append(index)
- for index in current:
- if index not in new_profile:
- removinglist.append(index)
- self.Manager.ManageEntriesOfCurrent(addinglist, removinglist)
- self.Manager.BufferCurrentNode()
- self.RefreshBufferState()
-
- dialog.Destroy()
-
- def GetProfileCallBack(self, text):
- def ProfileCallBack(event):
- self.Manager.AddSpecificEntryToCurrent(text)
- self.RefreshBufferState()
- self.RefreshCurrentIndexList()
- return ProfileCallBack
-
-#-------------------------------------------------------------------------------
-# Edit Node informations function
-#-------------------------------------------------------------------------------
-
- def OnNodeInfosMenu(self, event):
- dialog = NodeInfosDialog(self.Frame)
- name, id, type, description = self.Manager.GetCurrentNodeInfos()
- defaultstringsize = self.Manager.GetCurrentNodeDefaultStringSize()
- dialog.SetValues(name, id, type, description, defaultstringsize)
- if dialog.ShowModal() == wx.ID_OK:
- name, id, type, description, defaultstringsize = dialog.GetValues()
- self.Manager.SetCurrentNodeInfos(name, id, type, description)
- self.Manager.SetCurrentNodeDefaultStringSize(defaultstringsize)
- self.RefreshBufferState()
- self.RefreshCurrentIndexList()
- self.RefreshProfileMenu()
-
-#-------------------------------------------------------------------------------
-# Add User Types and Variables
-#-------------------------------------------------------------------------------
-
- def AddMapVariable(self):
- index = self.Manager.GetCurrentNextMapIndex()
- if index:
- dialog = MapVariableDialog(self.Frame)
- dialog.SetIndex(index)
- if dialog.ShowModal() == wx.ID_OK:
- result = self.Manager.AddMapVariableToCurrent(*dialog.GetValues())
- if not isinstance(result, (StringType, UnicodeType)):
- self.RefreshBufferState()
- self.RefreshCurrentIndexList()
- else:
- self.ShowErrorMessage(result)
- dialog.Destroy()
- else:
- self.ShowErrorMessage(_("No map variable index left!"))
-
- def AddUserType(self):
- dialog = UserTypeDialog(self)
- dialog.SetTypeList(self.Manager.GetCustomisableTypes())
- if dialog.ShowModal() == wx.ID_OK:
- result = self.Manager.AddUserTypeToCurrent(*dialog.GetValues())
- if not isinstance(result, (StringType, UnicodeType)):
- self.RefreshBufferState()
- self.RefreshCurrentIndexList()
- else:
- self.ShowErrorMessage(result)
- dialog.Destroy()
-
- def ShowErrorMessage(self, message):
- message = wx.MessageDialog(self.Frame, message, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/objdictgen/nodeeditortemplate.py Wed Mar 27 09:32:05 2013 +0900
@@ -0,0 +1,228 @@
+from types import *
+
+import wx
+
+from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes
+from commondialogs import *
+
+class NodeEditorTemplate:
+
+ EDITMENU_ID = None
+
+ def __init__(self, manager, frame, mode_solo):
+ self.Manager = manager
+ self.Frame = frame
+ self.ModeSolo = mode_solo
+
+ self.BusId = None
+ self.Closing = False
+
+ def SetBusId(self, bus_id):
+ self.BusId = bus_id
+
+ def GetBusId(self):
+ return self.BusId
+
+ def IsClosing(self):
+ return self.Closing
+
+ def OnAddSDOServerMenu(self, event):
+ self.Manager.AddSDOServerToCurrent()
+ self.RefreshBufferState()
+ self.RefreshCurrentIndexList()
+
+ def OnAddSDOClientMenu(self, event):
+ self.Manager.AddSDOClientToCurrent()
+ self.RefreshBufferState()
+ self.RefreshCurrentIndexList()
+
+ def OnAddPDOTransmitMenu(self, event):
+ self.Manager.AddPDOTransmitToCurrent()
+ self.RefreshBufferState()
+ self.RefreshCurrentIndexList()
+
+ def OnAddPDOReceiveMenu(self, event):
+ self.Manager.AddPDOReceiveToCurrent()
+ self.RefreshBufferState()
+ self.RefreshCurrentIndexList()
+
+ def OnAddMapVariableMenu(self, event):
+ self.AddMapVariable()
+
+ def OnAddUserTypeMenu(self, event):
+ self.AddUserType()
+
+ def OnRefreshMenu(self, event):
+ self.RefreshCurrentIndexList()
+
+ def RefreshCurrentIndexList(self):
+ pass
+
+ def RefreshStatusBar(self):
+ pass
+
+ def SetStatusBarText(self, selection, manager):
+ if selection:
+ index, subIndex = selection
+ if manager.IsCurrentEntry(index):
+ self.Frame.HelpBar.SetStatusText(_("Index: 0x%04X")%index, 0)
+ self.Frame.HelpBar.SetStatusText(_("Subindex: 0x%02X")%subIndex, 1)
+ entryinfos = manager.GetEntryInfos(index)
+ name = entryinfos["name"]
+ category = _("Optional")
+ if entryinfos["need"]:
+ category = _("Mandatory")
+ struct = "VAR"
+ number = ""
+ if entryinfos["struct"] & OD_IdenticalIndexes:
+ number = _(" possibly defined %d times")%entryinfos["nbmax"]
+ if entryinfos["struct"] & OD_IdenticalSubindexes:
+ struct = "REC"
+ elif entryinfos["struct"] & OD_MultipleSubindexes:
+ struct = "ARRAY"
+ text = _("%s: %s entry of struct %s%s.")%(name,category,struct,number)
+ self.Frame.HelpBar.SetStatusText(text, 2)
+ else:
+ for i in xrange(3):
+ self.Frame.HelpBar.SetStatusText("", i)
+ else:
+ for i in xrange(3):
+ self.Frame.HelpBar.SetStatusText("", i)
+
+ def RefreshProfileMenu(self):
+ if self.EDITMENU_ID is not None:
+ profile = self.Manager.GetCurrentProfileName()
+ edititem = self.Frame.EditMenu.FindItemById(self.EDITMENU_ID)
+ if edititem:
+ length = self.Frame.AddMenu.GetMenuItemCount()
+ for i in xrange(length-6):
+ additem = self.Frame.AddMenu.FindItemByPosition(6)
+ self.Frame.AddMenu.Delete(additem.GetId())
+ if profile not in ("None", "DS-301"):
+ edititem.SetText(_("%s Profile")%profile)
+ edititem.Enable(True)
+ self.Frame.AddMenu.AppendSeparator()
+ for text, indexes in self.Manager.GetCurrentSpecificMenu():
+ new_id = wx.NewId()
+ self.Frame.AddMenu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=text)
+ self.Frame.Bind(wx.EVT_MENU, self.GetProfileCallBack(text), id=new_id)
+ else:
+ edititem.SetText(_("Other Profile"))
+ edititem.Enable(False)
+
+#-------------------------------------------------------------------------------
+# Buffer Functions
+#-------------------------------------------------------------------------------
+
+ def RefreshBufferState(self):
+ pass
+
+ def OnUndoMenu(self, event):
+ self.Manager.LoadCurrentPrevious()
+ self.RefreshCurrentIndexList()
+ self.RefreshBufferState()
+
+ def OnRedoMenu(self, event):
+ self.Manager.LoadCurrentNext()
+ self.RefreshCurrentIndexList()
+ self.RefreshBufferState()
+
+#-------------------------------------------------------------------------------
+# Editing Profiles functions
+#-------------------------------------------------------------------------------
+
+ def OnCommunicationMenu(self, event):
+ dictionary,current = self.Manager.GetCurrentCommunicationLists()
+ self.EditProfile(_("Edit DS-301 Profile"), dictionary, current)
+
+ def OnOtherCommunicationMenu(self, event):
+ dictionary,current = self.Manager.GetCurrentDS302Lists()
+ self.EditProfile(_("Edit DS-302 Profile"), dictionary, current)
+
+ def OnEditProfileMenu(self, event):
+ title = _("Edit %s Profile") % self.Manager.GetCurrentProfileName()
+ dictionary,current = self.Manager.GetCurrentProfileLists()
+ self.EditProfile(title, dictionary, current)
+
+ def EditProfile(self, title, dictionary, current):
+ dialog = CommunicationDialog(self.Frame)
+ dialog.SetTitle(title)
+ dialog.SetIndexDictionary(dictionary)
+ dialog.SetCurrentList(current)
+ dialog.RefreshLists()
+ if dialog.ShowModal() == wx.ID_OK:
+ new_profile = dialog.GetCurrentList()
+ addinglist = []
+ removinglist = []
+ for index in new_profile:
+ if index not in current:
+ addinglist.append(index)
+ for index in current:
+ if index not in new_profile:
+ removinglist.append(index)
+ self.Manager.ManageEntriesOfCurrent(addinglist, removinglist)
+ self.Manager.BufferCurrentNode()
+ self.RefreshBufferState()
+
+ dialog.Destroy()
+
+ def GetProfileCallBack(self, text):
+ def ProfileCallBack(event):
+ self.Manager.AddSpecificEntryToCurrent(text)
+ self.RefreshBufferState()
+ self.RefreshCurrentIndexList()
+ return ProfileCallBack
+
+#-------------------------------------------------------------------------------
+# Edit Node informations function
+#-------------------------------------------------------------------------------
+
+ def OnNodeInfosMenu(self, event):
+ dialog = NodeInfosDialog(self.Frame)
+ name, id, type, description = self.Manager.GetCurrentNodeInfos()
+ defaultstringsize = self.Manager.GetCurrentNodeDefaultStringSize()
+ dialog.SetValues(name, id, type, description, defaultstringsize)
+ if dialog.ShowModal() == wx.ID_OK:
+ name, id, type, description, defaultstringsize = dialog.GetValues()
+ self.Manager.SetCurrentNodeInfos(name, id, type, description)
+ self.Manager.SetCurrentNodeDefaultStringSize(defaultstringsize)
+ self.RefreshBufferState()
+ self.RefreshCurrentIndexList()
+ self.RefreshProfileMenu()
+
+#-------------------------------------------------------------------------------
+# Add User Types and Variables
+#-------------------------------------------------------------------------------
+
+ def AddMapVariable(self):
+ index = self.Manager.GetCurrentNextMapIndex()
+ if index:
+ dialog = MapVariableDialog(self.Frame)
+ dialog.SetIndex(index)
+ if dialog.ShowModal() == wx.ID_OK:
+ result = self.Manager.AddMapVariableToCurrent(*dialog.GetValues())
+ if not isinstance(result, (StringType, UnicodeType)):
+ self.RefreshBufferState()
+ self.RefreshCurrentIndexList()
+ else:
+ self.ShowErrorMessage(result)
+ dialog.Destroy()
+ else:
+ self.ShowErrorMessage(_("No map variable index left!"))
+
+ def AddUserType(self):
+ dialog = UserTypeDialog(self)
+ dialog.SetTypeList(self.Manager.GetCustomisableTypes())
+ if dialog.ShowModal() == wx.ID_OK:
+ result = self.Manager.AddUserTypeToCurrent(*dialog.GetValues())
+ if not isinstance(result, (StringType, UnicodeType)):
+ self.RefreshBufferState()
+ self.RefreshCurrentIndexList()
+ else:
+ self.ShowErrorMessage(result)
+ dialog.Destroy()
+
+ def ShowErrorMessage(self, message):
+ message = wx.MessageDialog(self.Frame, message, _("Error"), wx.OK|wx.ICON_ERROR)
+ message.ShowModal()
+ message.Destroy()
--- a/objdictgen/objdictedit.py Thu Mar 07 11:40:28 2013 +0900
+++ b/objdictgen/objdictedit.py Wed Mar 27 09:32:05 2013 +0900
@@ -74,7 +74,7 @@
__builtin__.__dict__['_'] = wx.GetTranslation
from nodemanager import *
-from nodeeditor import NodeEditorTemplate
+from nodeeditortemplate import NodeEditorTemplate
from subindextable import *
from commondialogs import *
from doc_index.DS301_index import *