objdictgen/nodeeditortemplate.py
author Edouard Tisserant
Thu, 24 Jan 2019 13:49:40 +0100
changeset 807 46027bb24429
parent 778 9edaa9d21cf9
permissions -rw-r--r--
Rewrite of timer_xeno.c to use POSIX API instead of Alchemy.
745
0bd84a528133 Fix bug when adding an entry to a node
Laurent Bessard
parents: 715
diff changeset
     1
from types import *
0bd84a528133 Fix bug when adding an entry to a node
Laurent Bessard
parents: 715
diff changeset
     2
715
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
     3
import wx
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
     4
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
     5
from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
     6
from commondialogs import *
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
     7
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
     8
class NodeEditorTemplate:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
     9
    
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    10
    EDITMENU_ID = None
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    11
    
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    12
    def __init__(self, manager, frame, mode_solo):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    13
        self.Manager = manager
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    14
        self.Frame = frame
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    15
        self.ModeSolo = mode_solo
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    16
        
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    17
        self.BusId = None
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    18
        self.Closing = False
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    19
    
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    20
    def SetBusId(self, bus_id):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    21
        self.BusId = bus_id
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    22
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    23
    def GetBusId(self):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    24
        return self.BusId
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    25
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    26
    def IsClosing(self):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    27
        return self.Closing
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    28
    
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    29
    def OnAddSDOServerMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    30
        self.Manager.AddSDOServerToCurrent()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    31
        self.RefreshBufferState()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    32
        self.RefreshCurrentIndexList()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    33
        
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    34
    def OnAddSDOClientMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    35
        self.Manager.AddSDOClientToCurrent()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    36
        self.RefreshBufferState()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    37
        self.RefreshCurrentIndexList()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    38
        
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    39
    def OnAddPDOTransmitMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    40
        self.Manager.AddPDOTransmitToCurrent()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    41
        self.RefreshBufferState()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    42
        self.RefreshCurrentIndexList()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    43
        
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    44
    def OnAddPDOReceiveMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    45
        self.Manager.AddPDOReceiveToCurrent()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    46
        self.RefreshBufferState()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    47
        self.RefreshCurrentIndexList()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    48
        
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    49
    def OnAddMapVariableMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    50
        self.AddMapVariable()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    51
        
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    52
    def OnAddUserTypeMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    53
        self.AddUserType()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    54
    
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    55
    def OnRefreshMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    56
        self.RefreshCurrentIndexList()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    57
        
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    58
    def RefreshCurrentIndexList(self):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    59
        pass
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    60
    
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    61
    def RefreshStatusBar(self):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    62
        pass
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    63
    
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    64
    def SetStatusBarText(self, selection, manager):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    65
        if selection:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    66
            index, subIndex = selection
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    67
            if manager.IsCurrentEntry(index):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    68
                self.Frame.HelpBar.SetStatusText(_("Index: 0x%04X")%index, 0)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    69
                self.Frame.HelpBar.SetStatusText(_("Subindex: 0x%02X")%subIndex, 1)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    70
                entryinfos = manager.GetEntryInfos(index)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    71
                name = entryinfos["name"]
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    72
                category = _("Optional")
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    73
                if entryinfos["need"]:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    74
                    category = _("Mandatory")
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    75
                struct = "VAR"
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    76
                number = ""
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    77
                if entryinfos["struct"] & OD_IdenticalIndexes:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    78
                    number = _(" possibly defined %d times")%entryinfos["nbmax"]
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    79
                if entryinfos["struct"] & OD_IdenticalSubindexes:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    80
                    struct = "REC"
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    81
                elif entryinfos["struct"] & OD_MultipleSubindexes:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    82
                    struct = "ARRAY"
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    83
                text = _("%s: %s entry of struct %s%s.")%(name,category,struct,number)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    84
                self.Frame.HelpBar.SetStatusText(text, 2)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    85
            else:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    86
                for i in xrange(3):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    87
                    self.Frame.HelpBar.SetStatusText("", i)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    88
        else:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    89
            for i in xrange(3):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    90
                self.Frame.HelpBar.SetStatusText("", i)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    91
    
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    92
    def RefreshProfileMenu(self):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    93
        if self.EDITMENU_ID is not None:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    94
            profile = self.Manager.GetCurrentProfileName()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    95
            edititem = self.Frame.EditMenu.FindItemById(self.EDITMENU_ID)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    96
            if edititem:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    97
                length = self.Frame.AddMenu.GetMenuItemCount()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    98
                for i in xrange(length-6):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
    99
                    additem = self.Frame.AddMenu.FindItemByPosition(6)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   100
                    self.Frame.AddMenu.Delete(additem.GetId())
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   101
                if profile not in ("None", "DS-301"):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   102
                    edititem.SetText(_("%s Profile")%profile)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   103
                    edititem.Enable(True)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   104
                    self.Frame.AddMenu.AppendSeparator()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   105
                    for text, indexes in self.Manager.GetCurrentSpecificMenu():
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   106
                        new_id = wx.NewId()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   107
                        self.Frame.AddMenu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=text)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   108
                        self.Frame.Bind(wx.EVT_MENU, self.GetProfileCallBack(text), id=new_id)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   109
                else:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   110
                    edititem.SetText(_("Other Profile"))
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   111
                    edititem.Enable(False)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   112
        
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   113
#-------------------------------------------------------------------------------
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   114
#                            Buffer Functions
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   115
#-------------------------------------------------------------------------------
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   116
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   117
    def RefreshBufferState(self):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   118
        pass
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   119
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   120
    def OnUndoMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   121
        self.Manager.LoadCurrentPrevious()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   122
        self.RefreshCurrentIndexList()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   123
        self.RefreshBufferState()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   124
        
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   125
    def OnRedoMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   126
        self.Manager.LoadCurrentNext()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   127
        self.RefreshCurrentIndexList()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   128
        self.RefreshBufferState()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   129
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   130
#-------------------------------------------------------------------------------
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   131
#                          Editing Profiles functions
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   132
#-------------------------------------------------------------------------------
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   133
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   134
    def OnCommunicationMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   135
        dictionary,current = self.Manager.GetCurrentCommunicationLists()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   136
        self.EditProfile(_("Edit DS-301 Profile"), dictionary, current)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   137
    
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   138
    def OnOtherCommunicationMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   139
        dictionary,current = self.Manager.GetCurrentDS302Lists()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   140
        self.EditProfile(_("Edit DS-302 Profile"), dictionary, current)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   141
    
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   142
    def OnEditProfileMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   143
        title = _("Edit %s Profile") % self.Manager.GetCurrentProfileName()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   144
        dictionary,current = self.Manager.GetCurrentProfileLists()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   145
        self.EditProfile(title, dictionary, current)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   146
    
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   147
    def EditProfile(self, title, dictionary, current):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   148
        dialog = CommunicationDialog(self.Frame)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   149
        dialog.SetTitle(title)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   150
        dialog.SetIndexDictionary(dictionary)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   151
        dialog.SetCurrentList(current)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   152
        dialog.RefreshLists()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   153
        if dialog.ShowModal() == wx.ID_OK:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   154
            new_profile = dialog.GetCurrentList()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   155
            addinglist = []
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   156
            removinglist = []
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   157
            for index in new_profile:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   158
                if index not in current:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   159
                    addinglist.append(index)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   160
            for index in current:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   161
                if index not in new_profile:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   162
                    removinglist.append(index)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   163
            self.Manager.ManageEntriesOfCurrent(addinglist, removinglist)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   164
            self.Manager.BufferCurrentNode()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   165
            self.RefreshBufferState()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   166
            
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   167
        dialog.Destroy()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   168
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   169
    def GetProfileCallBack(self, text):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   170
        def ProfileCallBack(event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   171
            self.Manager.AddSpecificEntryToCurrent(text)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   172
            self.RefreshBufferState()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   173
            self.RefreshCurrentIndexList()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   174
        return ProfileCallBack
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   175
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   176
#-------------------------------------------------------------------------------
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   177
#                         Edit Node informations function
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   178
#-------------------------------------------------------------------------------
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   179
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   180
    def OnNodeInfosMenu(self, event):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   181
        dialog = NodeInfosDialog(self.Frame)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   182
        name, id, type, description = self.Manager.GetCurrentNodeInfos()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   183
        defaultstringsize = self.Manager.GetCurrentNodeDefaultStringSize()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   184
        dialog.SetValues(name, id, type, description, defaultstringsize)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   185
        if dialog.ShowModal() == wx.ID_OK:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   186
            name, id, type, description, defaultstringsize = dialog.GetValues()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   187
            self.Manager.SetCurrentNodeInfos(name, id, type, description)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   188
            self.Manager.SetCurrentNodeDefaultStringSize(defaultstringsize)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   189
            self.RefreshBufferState()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   190
            self.RefreshCurrentIndexList()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   191
            self.RefreshProfileMenu()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   192
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   193
#-------------------------------------------------------------------------------
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   194
#                           Add User Types and Variables
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   195
#-------------------------------------------------------------------------------
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   196
        
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   197
    def AddMapVariable(self):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   198
        index = self.Manager.GetCurrentNextMapIndex()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   199
        if index:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   200
            dialog = MapVariableDialog(self.Frame)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   201
            dialog.SetIndex(index)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   202
            if dialog.ShowModal() == wx.ID_OK:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   203
                result = self.Manager.AddMapVariableToCurrent(*dialog.GetValues())
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   204
                if not isinstance(result, (StringType, UnicodeType)):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   205
                    self.RefreshBufferState()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   206
                    self.RefreshCurrentIndexList()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   207
                else:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   208
                    self.ShowErrorMessage(result)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   209
            dialog.Destroy()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   210
        else:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   211
            self.ShowErrorMessage(_("No map variable index left!"))
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   212
        
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   213
    def AddUserType(self):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   214
        dialog = UserTypeDialog(self)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   215
        dialog.SetTypeList(self.Manager.GetCustomisableTypes())
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   216
        if dialog.ShowModal() == wx.ID_OK:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   217
            result = self.Manager.AddUserTypeToCurrent(*dialog.GetValues())
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   218
            if not isinstance(result, (StringType, UnicodeType)):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   219
                self.RefreshBufferState()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   220
                self.RefreshCurrentIndexList()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   221
            else:
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   222
                self.ShowErrorMessage(result)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   223
        dialog.Destroy()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   224
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   225
    def ShowErrorMessage(self, message):
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   226
        message = wx.MessageDialog(self.Frame, message, _("Error"), wx.OK|wx.ICON_ERROR)
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   227
        message.ShowModal()
5795fb789230 Adding support for integration of panels in Beremiz
smarteh-dev
parents:
diff changeset
   228
        message.Destroy()