author | laurent |
Tue, 17 Jul 2012 21:25:28 +0200 | |
changeset 788 | 3cec473bef94 |
parent 771 | 85d33a130a5c |
child 814 | 5743cbdff669 |
permissions | -rw-r--r-- |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
1 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
2 |
import wx |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
3 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
4 |
from subindextable import EditingPanel |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
5 |
from networkedit import NetworkEditorTemplate |
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
738
diff
changeset
|
6 |
from ConfTreeNodeEditor import ConfTreeNodeEditor |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
7 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
8 |
[ID_NETWORKEDITOR, |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
9 |
] = [wx.NewId() for _init_ctrls in range(1)] |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
10 |
|
717 | 11 |
[ID_NETWORKEDITORCONFNODEMENUADDSLAVE, ID_NETWORKEDITORCONFNODEMENUREMOVESLAVE, |
12 |
ID_NETWORKEDITORCONFNODEMENUMASTER, |
|
13 |
] = [wx.NewId() for _init_coll_ConfNodeMenu_Items in range(3)] |
|
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
14 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
15 |
[ID_NETWORKEDITORMASTERMENUNODEINFOS, ID_NETWORKEDITORMASTERMENUDS301PROFILE, |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
16 |
ID_NETWORKEDITORMASTERMENUDS302PROFILE, ID_NETWORKEDITORMASTERMENUDSOTHERPROFILE, |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
17 |
ID_NETWORKEDITORMASTERMENUADD, |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
18 |
] = [wx.NewId() for _init_coll_MasterMenu_Items in range(5)] |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
19 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
20 |
[ID_NETWORKEDITORADDMENUSDOSERVER, ID_NETWORKEDITORADDMENUSDOCLIENT, |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
21 |
ID_NETWORKEDITORADDMENUPDOTRANSMIT, ID_NETWORKEDITORADDMENUPDORECEIVE, |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
22 |
ID_NETWORKEDITORADDMENUMAPVARIABLE, ID_NETWORKEDITORADDMENUUSERTYPE, |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
23 |
] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)] |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
24 |
|
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
738
diff
changeset
|
25 |
class NetworkEditor(ConfTreeNodeEditor, NetworkEditorTemplate): |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
26 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
27 |
ID = ID_NETWORKEDITOR |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
28 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
29 |
def _init_coll_MainSizer_Items(self, parent): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
30 |
parent.AddWindow(self.NetworkNodes, 0, border=5, flag=wx.GROW|wx.ALL) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
31 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
32 |
def _init_coll_MainSizer_Growables(self, parent): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
33 |
parent.AddGrowableCol(0) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
34 |
parent.AddGrowableRow(0) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
35 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
36 |
def _init_sizers(self): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
37 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=1, vgap=0) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
38 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
39 |
self._init_coll_MainSizer_Items(self.MainSizer) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
40 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
41 |
|
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
738
diff
changeset
|
42 |
self.ConfNodeEditor.SetSizer(self.MainSizer) |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
43 |
|
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
738
diff
changeset
|
44 |
def _init_ConfNodeEditor(self, prnt): |
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
738
diff
changeset
|
45 |
self.ConfNodeEditor = wx.Panel(id=-1, parent=prnt, pos=wx.Point(0, 0), |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
46 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
47 |
|
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
738
diff
changeset
|
48 |
NetworkEditorTemplate._init_ctrls(self, self.ConfNodeEditor) |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
49 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
50 |
self._init_sizers() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
51 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
52 |
def __init__(self, parent, controler, window): |
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
738
diff
changeset
|
53 |
ConfTreeNodeEditor.__init__(self, parent, controler, window) |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
54 |
NetworkEditorTemplate.__init__(self, controler, window, False) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
55 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
56 |
self.RefreshNetworkNodes() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
57 |
self.RefreshBufferState() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
58 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
59 |
def __del__(self): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
60 |
self.Controler.OnCloseEditor(self) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
61 |
|
717 | 62 |
def GetConfNodeMenuItems(self): |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
63 |
add_menu = [(wx.ITEM_NORMAL, (_('SDO Server'), ID_NETWORKEDITORADDMENUSDOSERVER, '', self.OnAddSDOServerMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
64 |
(wx.ITEM_NORMAL, (_('SDO Client'), ID_NETWORKEDITORADDMENUSDOCLIENT, '', self.OnAddSDOClientMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
65 |
(wx.ITEM_NORMAL, (_('PDO Transmit'), ID_NETWORKEDITORADDMENUPDOTRANSMIT, '', self.OnAddPDOTransmitMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
66 |
(wx.ITEM_NORMAL, (_('PDO Receive'), ID_NETWORKEDITORADDMENUPDORECEIVE, '', self.OnAddPDOReceiveMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
67 |
(wx.ITEM_NORMAL, (_('Map Variable'), ID_NETWORKEDITORADDMENUMAPVARIABLE, '', self.OnAddMapVariableMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
68 |
(wx.ITEM_NORMAL, (_('User Type'), ID_NETWORKEDITORADDMENUUSERTYPE, '', self.OnAddUserTypeMenu))] |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
69 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
70 |
profile = self.Manager.GetCurrentProfileName() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
71 |
if profile not in ("None", "DS-301"): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
72 |
other_profile_text = _("%s Profile") % profile |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
73 |
add_menu.append((wx.ITEM_SEPARATOR, None)) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
74 |
for text, indexes in self.Manager.GetCurrentSpecificMenu(): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
75 |
add_menu.append((wx.ITEM_NORMAL, (text, wx.NewId(), '', self.GetProfileCallBack(text)))) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
76 |
else: |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
77 |
other_profile_text = _('Other Profile') |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
78 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
79 |
master_menu = [(wx.ITEM_NORMAL, (_('Node infos'), ID_NETWORKEDITORMASTERMENUNODEINFOS, '', self.OnNodeInfosMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
80 |
(wx.ITEM_NORMAL, (_('DS-301 Profile'), ID_NETWORKEDITORMASTERMENUDS301PROFILE, '', self.OnCommunicationMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
81 |
(wx.ITEM_NORMAL, (_('DS-302 Profile'), ID_NETWORKEDITORMASTERMENUDS302PROFILE, '', self.OnOtherCommunicationMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
82 |
(wx.ITEM_NORMAL, (other_profile_text, ID_NETWORKEDITORMASTERMENUDSOTHERPROFILE, '', self.OnEditProfileMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
83 |
(wx.ITEM_SEPARATOR, None), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
84 |
(add_menu, (_('Add'), ID_NETWORKEDITORMASTERMENUADD))] |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
85 |
|
717 | 86 |
return [(wx.ITEM_NORMAL, (_('Add slave'), ID_NETWORKEDITORCONFNODEMENUADDSLAVE, '', self.OnAddSlaveMenu)), |
87 |
(wx.ITEM_NORMAL, (_('Remove slave'), ID_NETWORKEDITORCONFNODEMENUREMOVESLAVE, '', self.OnRemoveSlaveMenu)), |
|
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
88 |
(wx.ITEM_SEPARATOR, None), |
717 | 89 |
(master_menu, (_('Master'), ID_NETWORKEDITORCONFNODEMENUMASTER))] |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
90 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
91 |
def RefreshMainMenu(self): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
92 |
pass |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
93 |
|
717 | 94 |
def RefreshConfNodeMenu(self, confnode_menu): |
95 |
confnode_menu.Enable(ID_NETWORKEDITORCONFNODEMENUMASTER, self.NetworkNodes.GetSelection() == 0) |
|
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
96 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
97 |
def RefreshView(self): |
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
738
diff
changeset
|
98 |
ConfTreeNodeEditor.RefreshView(self) |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
99 |
self.RefreshCurrentIndexList() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
100 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
101 |
def RefreshBufferState(self): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
102 |
NetworkEditorTemplate.RefreshBufferState(self) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
103 |
self.ParentWindow.RefreshTitle() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
104 |
self.ParentWindow.RefreshFileMenu() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
105 |
self.ParentWindow.RefreshEditMenu() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
106 |
self.ParentWindow.RefreshPageTitles() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
107 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
108 |
def OnNodeSelectedChanged(self, event): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
109 |
NetworkEditorTemplate.OnNodeSelectedChanged(self, event) |
771 | 110 |
wx.CallAfter(self.ParentWindow.RefreshEditMenu) |