objdictgen/subindextable.py
author etisserant
Thu, 02 Aug 2007 14:20:52 +0200
changeset 248 7fedc55c14d5
parent 243 7fcc129a06ce
child 254 f2b0acb54e65
permissions -rw-r--r--
Disabled compilation of DS401_xxx examples
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     1
#!/usr/bin/env python
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     3
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     4
#This file is part of CanFestival, a library implementing CanOpen Stack. 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     5
#
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     6
#Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     7
#
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     8
#See COPYING file for copyrights details.
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     9
#
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    10
#This library is free software; you can redistribute it and/or
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    11
#modify it under the terms of the GNU Lesser General Public
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    12
#License as published by the Free Software Foundation; either
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    13
#version 2.1 of the License, or (at your option) any later version.
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    14
#
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    15
#This library is distributed in the hope that it will be useful,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    16
#but WITHOUT ANY WARRANTY; without even the implied warranty of
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    17
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    18
#Lesser General Public License for more details.
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    19
#
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    20
#You should have received a copy of the GNU Lesser General Public
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    21
#License along with this library; if not, write to the Free Software
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    22
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    23
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    24
from wxPython.wx import *
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    25
from wxPython.grid import *
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    26
import wx
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    27
import wx.grid
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    28
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    29
from types import *
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    30
206
6787754b251b Bugs corrected on objdictedit and networkdict
greg
parents: 205
diff changeset
    31
from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    32
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    33
ColSizes = [75, 250, 150, 125, 100, 60, 250]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    34
ColAlignements = [wxALIGN_CENTER, wxALIGN_LEFT, wxALIGN_CENTER, wxALIGN_RIGHT, wxALIGN_CENTER, wxALIGN_CENTER, wxALIGN_LEFT]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    35
AccessList = "Read Only,Write Only,Read/Write"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    36
RAccessList = "Read Only,Read/Write"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    37
BoolList = "True,False"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    38
OptionList = "Yes,No"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    39
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    40
DictionaryOrganisation = [
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    41
    {"minIndex" : 0x0001, "maxIndex" : 0x0FFF, "name" : "Data Type Definitions"},
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    42
    {"minIndex" : 0x1000, "maxIndex" : 0x1029, "name" : "Communication Parameters"},
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    43
    {"minIndex" : 0x1200, "maxIndex" : 0x12FF, "name" : "SDO Parameters"},
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    44
    {"minIndex" : 0x1400, "maxIndex" : 0x15FF, "name" : "Receive PDO Parameters"},
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    45
    {"minIndex" : 0x1600, "maxIndex" : 0x17FF, "name" : "Receive PDO Mapping"},
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    46
    {"minIndex" : 0x1800, "maxIndex" : 0x19FF, "name" : "Transmit PDO Parameters"},
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    47
    {"minIndex" : 0x1A00, "maxIndex" : 0x1BFF, "name" : "Transmit PDO Mapping"},
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    48
    {"minIndex" : 0x1C00, "maxIndex" : 0x1FFF, "name" : "Other Communication Parameters"},
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    49
    {"minIndex" : 0x2000, "maxIndex" : 0x5FFF, "name" : "Manufacturer Specific"},
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    50
    {"minIndex" : 0x6000, "maxIndex" : 0x9FFF, "name" : "Standardized Device Profile"},
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    51
    {"minIndex" : 0xA000, "maxIndex" : 0xBFFF, "name" : "Standardized Interface Profile"}]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    52
242
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
    53
SizeConversion = {1 : "X", 8 : "B", 16 : "W", 24 : "D", 32 : "D", 40 : "L", 48 : "L", 56 : "L", 64 : "L"}
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
    54
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    55
class SubindexTable(wxPyGridTableBase):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    56
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    57
    """
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    58
    A custom wxGrid Table using user supplied data
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    59
    """
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    60
    def __init__(self, parent, data, editors, colnames):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    61
        # The base class must be initialized *first*
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    62
        wxPyGridTableBase.__init__(self)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    63
        self.data = data
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    64
        self.editors = editors
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    65
        self.CurrentIndex = 0
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    66
        self.colnames = colnames
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    67
        self.Parent = parent
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    68
        self.Editable = True
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    69
        # XXX
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    70
        # we need to store the row length and collength to
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    71
        # see if the table has changed size
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    72
        self._rows = self.GetNumberRows()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    73
        self._cols = self.GetNumberCols()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    74
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    75
    def Disable(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    76
        self.Editable = False
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    77
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    78
    def Enable(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    79
        self.Editable = True
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    80
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    81
    def GetNumberCols(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    82
        return len(self.colnames)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    83
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    84
    def GetNumberRows(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    85
        return len(self.data)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    86
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    87
    def GetColLabelValue(self, col):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    88
        if col < len(self.colnames):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    89
            return self.colnames[col]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    90
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    91
    def GetRowLabelValues(self, row):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    92
        return row
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    93
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    94
    def GetValue(self, row, col):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    95
        if row < self.GetNumberRows():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    96
            value = self.data[row].get(self.GetColLabelValue(col), "")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    97
            if (type(value) == UnicodeType):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    98
                return value
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    99
            else: 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   100
                return str(value)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   101
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   102
    def GetEditor(self, row, col):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   103
        if row < self.GetNumberRows():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   104
            return self.editors[row].get(self.GetColLabelValue(col), "")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   105
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   106
    def GetValueByName(self, row, colname):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   107
        return self.data[row].get(colname)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   108
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   109
    def SetValue(self, row, col, value):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   110
        if col < len(self.colnames):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   111
            self.data[row][self.GetColLabelValue(col)] = value
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   112
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   113
    def ResetView(self, grid):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   114
        """
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   115
        (wxGrid) -> Reset the grid view.   Call this to
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   116
        update the grid if rows and columns have been added or deleted
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   117
        """
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   118
        grid.BeginBatch()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   119
        for current, new, delmsg, addmsg in [
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   120
            (self._rows, self.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   121
            (self._cols, self.GetNumberCols(), wxGRIDTABLE_NOTIFY_COLS_DELETED, wxGRIDTABLE_NOTIFY_COLS_APPENDED),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   122
        ]:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   123
            if new < current:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   124
                msg = wxGridTableMessage(self,delmsg,new,current-new)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   125
                grid.ProcessTableMessage(msg)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   126
            elif new > current:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   127
                msg = wxGridTableMessage(self,addmsg,new-current)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   128
                grid.ProcessTableMessage(msg)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   129
                self.UpdateValues(grid)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   130
        grid.EndBatch()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   131
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   132
        self._rows = self.GetNumberRows()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   133
        self._cols = self.GetNumberCols()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   134
        # update the column rendering scheme
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   135
        self._updateColAttrs(grid)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   136
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   137
        # update the scrollbars and the displayed part of the grid
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   138
        grid.AdjustScrollbars()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   139
        grid.ForceRefresh()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   140
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   141
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   142
    def UpdateValues(self, grid):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   143
        """Update all displayed values"""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   144
        # This sends an event to the grid table to update all of the values
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   145
        msg = wxGridTableMessage(self, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   146
        grid.ProcessTableMessage(msg)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   147
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   148
    def _updateColAttrs(self, grid):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   149
        """
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   150
        wxGrid -> update the column attributes to add the
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   151
        appropriate renderer given the column name.
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   152
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   153
        Otherwise default to the default renderer.
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   154
        """
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   155
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   156
        for col in range(self.GetNumberCols()):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   157
            attr = wxGridCellAttr()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   158
            attr.SetAlignment(ColAlignements[col], wxALIGN_CENTRE)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   159
            grid.SetColAttr(col, attr)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   160
            grid.SetColSize(col, ColSizes[col])
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   161
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   162
        typelist = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   163
        maplist = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   164
        for row in range(self.GetNumberRows()):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   165
            editors = self.editors[row]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   166
            for col in range(self.GetNumberCols()):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   167
                editor = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   168
                renderer = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   169
                
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   170
                colname = self.GetColLabelValue(col)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   171
                editortype = editors[colname]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   172
                if editortype and self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   173
                    grid.SetReadOnly(row, col, False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   174
                    if editortype == "string":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   175
                        editor = wxGridCellTextEditor()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   176
                        renderer = wxGridCellStringRenderer()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   177
                        if colname == "value" and "length" in editors:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   178
                            editor.SetParameters(editors["length"]) 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   179
                    elif editortype == "number":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   180
                        editor = wxGridCellNumberEditor()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   181
                        renderer = wxGridCellNumberRenderer()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   182
                        if colname == "value" and "min" in editors and "max" in editors:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   183
                            editor.SetParameters("%s,%s"%(editors["min"],editors["max"]))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   184
                    elif editortype == "real":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   185
                        editor = wxGridCellFloatEditor()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   186
                        renderer = wxGridCellFloatRenderer()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   187
                        if colname == "value" and "min" in editors and "max" in editors:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   188
                            editor.SetParameters("%s,%s"%(editors["min"],editors["max"]))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   189
                    elif editortype == "bool":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   190
                        editor = wxGridCellChoiceEditor()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   191
                        editor.SetParameters(BoolList)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   192
                    elif editortype == "access":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   193
                        editor = wxGridCellChoiceEditor()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   194
                        editor.SetParameters(AccessList)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   195
                    elif editortype == "raccess":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   196
                        editor = wxGridCellChoiceEditor()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   197
                        editor.SetParameters(RAccessList)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   198
                    elif editortype == "option":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   199
                        editor = wxGridCellChoiceEditor()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   200
                        editor.SetParameters(OptionList)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   201
                    elif editortype == "type":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   202
                        editor = wxGridCellChoiceEditor()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   203
                        if typelist == None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   204
                            typelist = self.Parent.Manager.GetCurrentTypeList()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   205
                        editor.SetParameters(typelist)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   206
                    elif editortype == "map":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   207
                        editor = wxGridCellChoiceEditor()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   208
                        if maplist == None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   209
                            maplist = self.Parent.Manager.GetCurrentMapList()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   210
                        editor.SetParameters(maplist)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   211
                    elif editortype == "time":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   212
                        editor = wxGridCellTextEditor()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   213
                        renderer = wxGridCellStringRenderer()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   214
                    elif editortype == "domain":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   215
                        editor = wxGridCellTextEditor()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   216
                        renderer = wxGridCellStringRenderer()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   217
                else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   218
                    grid.SetReadOnly(row, col, True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   219
                    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   220
                grid.SetCellEditor(row, col, editor)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   221
                grid.SetCellRenderer(row, col, renderer)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   222
                
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   223
                grid.SetCellBackgroundColour(row, col, wxWHITE)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   224
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   225
    def SetData(self, data):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   226
        self.data = data
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   227
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   228
    def SetEditors(self, editors):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   229
        self.editors = editors
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   230
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   231
    def GetCurrentIndex(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   232
        return self.CurrentIndex
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   233
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   234
    def SetCurrentIndex(self, index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   235
        self.CurrentIndex = index
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   236
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   237
    def AppendRow(self, row_content):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   238
        self.data.append(row_content)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   239
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   240
    def Empty(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   241
        self.data = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   242
        self.editors = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   243
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   244
[wxID_EDITINGPANEL, wxID_EDITINGPANELADDBUTTON, wxID_EDITINGPANELINDEXCHOICE, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   245
 wxID_EDITINGPANELINDEXLIST, wxID_EDITINGPANELINDEXLISTPANEL, wxID_EDITINGPANELPARTLIST, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   246
 wxID_EDITINGPANELSECONDSPLITTER, wxID_EDITINGPANELSUBINDEXGRID,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   247
 wxID_EDITINGPANELSUBINDEXGRIDPANEL, wxID_EDITINGPANELCALLBACKCHECK,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   248
] = [wx.NewId() for _init_ctrls in range(10)]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   249
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   250
[wxID_EDITINGPANELINDEXLISTMENUITEMS0, wxID_EDITINGPANELINDEXLISTMENUITEMS1, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   251
 wxID_EDITINGPANELINDEXLISTMENUITEMS2, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   252
] = [wx.NewId() for _init_coll_IndexListMenu_Items in range(3)]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   253
242
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
   254
[wxID_EDITINGPANELMENU1ITEMS0, wxID_EDITINGPANELMENU1ITEMS1, 
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
   255
] = [wx.NewId() for _init_coll_SubindexGridMenu_Items in range(2)]
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   256
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   257
class EditingPanel(wx.SplitterWindow):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   258
    def _init_coll_AddToListSizer_Items(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   259
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   260
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   261
        parent.AddWindow(self.AddButton, 0, border=0, flag=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   262
        parent.AddWindow(self.IndexChoice, 0, border=0, flag=wxGROW)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   263
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   264
    def _init_coll_SubindexGridSizer_Items(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   265
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   266
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   267
        parent.AddWindow(self.CallbackCheck, 0, border=0, flag=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   268
        parent.AddWindow(self.SubindexGrid, 0, border=0, flag=wxGROW)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   269
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   270
    def _init_coll_IndexListSizer_Items(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   271
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   272
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   273
        parent.AddWindow(self.IndexList, 0, border=0, flag=wxGROW)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   274
        parent.AddSizer(self.AddToListSizer, 0, border=0, flag=wxGROW)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   275
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   276
    def _init_coll_AddToListSizer_Growables(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   277
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   278
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   279
        parent.AddGrowableCol(1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   280
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   281
    def _init_coll_SubindexGridSizer_Growables(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   282
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   283
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   284
        parent.AddGrowableCol(0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   285
        parent.AddGrowableRow(1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   286
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   287
    def _init_coll_IndexListSizer_Growables(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   288
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   289
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   290
        parent.AddGrowableCol(0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   291
        parent.AddGrowableRow(0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   292
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   293
    def _init_coll_SubindexGridMenu_Items(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   294
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   295
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   296
        parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS0,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   297
              kind=wx.ITEM_NORMAL, text='Add')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   298
        parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS1,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   299
              kind=wx.ITEM_NORMAL, text='Delete')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   300
        self.Bind(wx.EVT_MENU, self.OnAddSubindexMenu,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   301
              id=wxID_EDITINGPANELMENU1ITEMS0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   302
        self.Bind(wx.EVT_MENU, self.OnDeleteSubindexMenu,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   303
              id=wxID_EDITINGPANELMENU1ITEMS1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   304
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   305
    def _init_coll_IndexListMenu_Items(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   306
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   307
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   308
        parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS0,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   309
              kind=wx.ITEM_NORMAL, text='Rename')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   310
        parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS2,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   311
              kind=wx.ITEM_NORMAL, text='Modify')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   312
        parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS1,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   313
              kind=wx.ITEM_NORMAL, text='Delete')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   314
        self.Bind(wx.EVT_MENU, self.OnRenameIndexMenu,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   315
              id=wxID_EDITINGPANELINDEXLISTMENUITEMS0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   316
        self.Bind(wx.EVT_MENU, self.OnDeleteIndexMenu,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   317
              id=wxID_EDITINGPANELINDEXLISTMENUITEMS1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   318
        self.Bind(wx.EVT_MENU, self.OnModifyIndexMenu,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   319
              id=wxID_EDITINGPANELINDEXLISTMENUITEMS2)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   320
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   321
    def _init_utils(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   322
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   323
        self.IndexListMenu = wx.Menu(title='')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   324
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   325
        self.SubindexGridMenu = wx.Menu(title='')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   326
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   327
        self._init_coll_IndexListMenu_Items(self.IndexListMenu)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   328
        self._init_coll_SubindexGridMenu_Items(self.SubindexGridMenu)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   329
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   330
    def _init_sizers(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   331
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   332
        self.IndexListSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   333
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   334
        self.SubindexGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   335
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   336
        self.AddToListSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   337
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   338
        self._init_coll_IndexListSizer_Growables(self.IndexListSizer)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   339
        self._init_coll_IndexListSizer_Items(self.IndexListSizer)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   340
        self._init_coll_SubindexGridSizer_Growables(self.SubindexGridSizer)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   341
        self._init_coll_SubindexGridSizer_Items(self.SubindexGridSizer)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   342
        self._init_coll_AddToListSizer_Growables(self.AddToListSizer)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   343
        self._init_coll_AddToListSizer_Items(self.AddToListSizer)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   344
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   345
        self.SubindexGridPanel.SetSizer(self.SubindexGridSizer)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   346
        self.IndexListPanel.SetSizer(self.IndexListSizer)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   347
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   348
    def _init_ctrls(self, prnt):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   349
        wx.SplitterWindow.__init__(self, id=wxID_EDITINGPANEL,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   350
              name='MainSplitter', parent=prnt, point=wx.Point(0, 0),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   351
              size=wx.Size(-1, -1), style=wx.SP_3D)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   352
        self._init_utils()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   353
        self.SetNeedUpdating(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   354
        self.SetMinimumPaneSize(1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   355
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   356
        self.PartList = wx.ListBox(choices=[], id=wxID_EDITINGPANELPARTLIST,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   357
              name='PartList', parent=self, pos=wx.Point(0, 0),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   358
              size=wx.Size(-1, -1), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   359
        self.PartList.Bind(wx.EVT_LISTBOX, self.OnPartListBoxClick,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   360
              id=wxID_EDITINGPANELPARTLIST)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   361
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   362
        self.SecondSplitter = wx.SplitterWindow(id=wxID_EDITINGPANELSECONDSPLITTER,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   363
              name='SecondSplitter', parent=self, point=wx.Point(0,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   364
              0), size=wx.Size(-1, -1), style=wx.SP_3D)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   365
        self.SecondSplitter.SetMinimumPaneSize(1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   366
        self.SplitHorizontally(self.PartList, self.SecondSplitter,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   367
              110)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   368
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   369
        self.SubindexGridPanel = wx.Panel(id=wxID_EDITINGPANELSUBINDEXGRIDPANEL,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   370
              name='SubindexGridPanel', parent=self.SecondSplitter, pos=wx.Point(0,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   371
              0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   372
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   373
        self.IndexListPanel = wx.Panel(id=wxID_EDITINGPANELINDEXLISTPANEL,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   374
              name='IndexListPanel', parent=self.SecondSplitter, pos=wx.Point(0,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   375
              0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   376
        self.SecondSplitter.SplitVertically(self.IndexListPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   377
              self.SubindexGridPanel, 280)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   378
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   379
        self.SubindexGrid = wx.grid.Grid(id=wxID_EDITINGPANELSUBINDEXGRID,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   380
              name='SubindexGrid', parent=self.SubindexGridPanel, pos=wx.Point(0,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   381
              0), size=wx.Size(-1, -1), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   382
        self.SubindexGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   383
              'Sans'))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   384
        self.SubindexGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   385
              False, 'Sans'))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   386
        self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   387
              self.OnSubindexGridCellChange)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   388
        self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   389
              self.OnSubindexGridRightClick)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   390
        self.SubindexGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   391
              self.OnSubindexGridSelectCell)
242
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
   392
        self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSubindexGridCellLeftClick)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   393
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   394
        self.CallbackCheck = wx.CheckBox(id=wxID_EDITINGPANELCALLBACKCHECK,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   395
              label='Have Callbacks', name='CallbackCheck',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   396
              parent=self.SubindexGridPanel, pos=wx.Point(0, 0), size=wx.Size(152,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   397
              24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   398
        self.CallbackCheck.Bind(wx.EVT_CHECKBOX, self.OnCallbackCheck,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   399
              id=wxID_EDITINGPANELCALLBACKCHECK)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   400
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   401
        self.IndexList = wx.ListBox(choices=[], id=wxID_EDITINGPANELINDEXLIST,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   402
              name='IndexList', parent=self.IndexListPanel, pos=wx.Point(0, 0),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   403
              size=wx.Size(-1, -1), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   404
        self.IndexList.Bind(wx.EVT_LISTBOX, self.OnIndexListClick,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   405
              id=wxID_EDITINGPANELINDEXLIST)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   406
        self.IndexList.Bind(wx.EVT_RIGHT_UP, self.OnIndexListRightUp)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   407
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   408
        self.AddButton = wx.Button(id=wxID_EDITINGPANELADDBUTTON, label='Add',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   409
              name='AddButton', parent=self.IndexListPanel, pos=wx.Point(0, 0),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   410
              size=wx.Size(50, 30), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   411
        self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButtonClick,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   412
              id=wxID_EDITINGPANELADDBUTTON)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   413
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   414
        self.IndexChoice = wx.Choice(choices=[], id=wxID_EDITINGPANELINDEXCHOICE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   415
              name='IndexChoice', parent=self.IndexListPanel, pos=wx.Point(50,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   416
              0), size=wx.Size(-1, 30), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   417
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   418
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   419
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   420
    def __init__(self, parent, manager, editable = True):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   421
        self._init_ctrls(parent.GetNoteBook())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   422
        self.Parent = parent
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   423
        self.Manager = manager
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   424
        self.ListIndex = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   425
        self.ChoiceIndex = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   426
        self.FirstCall = False
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   427
        self.Editable = editable
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   428
        self.Index = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   429
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   430
        for values in DictionaryOrganisation:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   431
            text = "   0x%04X-0x%04X      %s"%(values["minIndex"],values["maxIndex"],values["name"])
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   432
            self.PartList.Append(text)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   433
        self.Table = SubindexTable(self, [], [], ["subindex", "name", "type", "value", "access", "save", "comment"])
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   434
        self.SubindexGrid.SetTable(self.Table)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   435
        self.SubindexGrid.SetRowLabelSize(0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   436
        self.CallbackCheck.Disable()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   437
        self.Table.ResetView(self.SubindexGrid)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   438
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   439
        if not self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   440
            self.AddButton.Disable()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   441
            self.IndexChoice.Disable()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   442
            self.CallbackCheck.Disable()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   443
            self.Table.Disable()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   444
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   445
    def GetIndex(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   446
        return self.Index
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   447
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   448
    def SetIndex(self, index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   449
        self.Index = index
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   450
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   451
    def GetSelection(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   452
        selected = self.IndexList.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   453
        if selected != wxNOT_FOUND:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   454
            index = self.ListIndex[selected]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   455
            subIndex = self.SubindexGrid.GetGridCursorRow()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   456
            return index, subIndex
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   457
        return None
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   458
242
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
   459
    def OnSubindexGridCellLeftClick(self, event):
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
   460
        wxCallAfter(self.BeginDrag)
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
   461
        event.Skip()
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
   462
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   463
    def OnAddButtonClick(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   464
        if self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   465
            self.SubindexGrid.SetGridCursor(0, 0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   466
            selected = self.IndexChoice.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   467
            if selected != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   468
                if selected == "User Type":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   469
                    self.Parent.AddUserType()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   470
                elif selected == "SDO Server":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   471
                    self.Manager.AddSDOServerToCurrent()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   472
                elif selected == "SDO Client":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   473
                    self.Manager.AddSDOClientToCurrent()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   474
                elif selected == "PDO Receive":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   475
                    self.Manager.AddPDOReceiveToCurrent()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   476
                elif selected == "PDO Transmit":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   477
                    self.Manager.AddPDOTransmitToCurrent()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   478
                elif selected == "Map Variable":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   479
                    self.Parent.AddMapVariable()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   480
                elif selected in [menu for menu, indexes in self.Manager.GetCurrentSpecificMenu()]:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   481
                    self.Manager.AddSpecificEntryToCurrent(selected)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   482
                else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   483
                    index = self.ChoiceIndex[self.IndexChoice.GetSelection()]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   484
                    self.Manager.ManageEntriesOfCurrent([index], [])
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   485
                self.Parent.RefreshBufferState()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   486
                self.RefreshIndexList()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   487
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   488
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   489
    def OnPartListBoxClick(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   490
        self.SubindexGrid.SetGridCursor(0, 0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   491
        self.RefreshIndexList()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   492
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   493
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   494
    def OnIndexListClick(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   495
        self.SubindexGrid.SetGridCursor(0, 0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   496
        self.RefreshTable()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   497
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   498
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   499
    def OnSubindexGridSelectCell(self, event):
242
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
   500
        wxCallAfter(self.BeginDrag)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   501
        wxCallAfter(self.Parent.RefreshStatusBar)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   502
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   503
242
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
   504
    def BeginDrag(self):
243
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   505
        if not self.Parent.ModeSolo:
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   506
            row = self.SubindexGrid.GetGridCursorRow()
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   507
            col = self.SubindexGrid.GetGridCursorCol()
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   508
            if not self.Editable and col == 0:
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   509
                selected = self.IndexList.GetSelection()
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   510
                if selected != wxNOT_FOUND:
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   511
                    index = self.ListIndex[selected]
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   512
                    subindex = self.SubindexGrid.GetGridCursorRow()
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   513
                    entry_infos = self.Manager.GetEntryInfos(index)
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   514
                    if not entry_infos["struct"] & OD_MultipleSubindexes or row != 0:
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   515
                        subentry_infos = self.Manager.GetSubentryInfos(index, subindex)
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   516
                        typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"])
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   517
                        if subentry_infos["pdo"] and typeinfos:
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   518
                            bus_id = self.Parent.GetBusId()
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   519
                            node_id = self.Parent.GetCurrentNodeId()
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   520
                            size = typeinfos["size"]
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   521
                            data = wxTextDataObject(str(("%s%d.%d.%d.%d"%(SizeConversion[size], bus_id, node_id, index, subindex), "location")))
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   522
                            dragSource = wxDropSource(self.SubindexGrid)
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   523
                            dragSource.SetData(data)
7fcc129a06ce Some bugs fixed
lbessard
parents: 242
diff changeset
   524
                            dragSource.DoDragDrop()
242
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
   525
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   526
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   527
#                             Refresh Functions
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   528
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   529
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   530
    def RefreshIndexList(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   531
        selected = self.IndexList.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   532
        choice = self.IndexChoice.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   533
        choiceindex = self.IndexChoice.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   534
        if selected != wxNOT_FOUND:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   535
            selectedindex = self.ListIndex[selected]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   536
        self.IndexList.Clear()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   537
        self.IndexChoice.Clear()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   538
        i = self.PartList.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   539
        if i < len(DictionaryOrganisation):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   540
            values = DictionaryOrganisation[i]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   541
            self.ListIndex = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   542
            for name, index in self.Manager.GetCurrentValidIndexes(values["minIndex"], values["maxIndex"]):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   543
                self.IndexList.Append("0x%04X   %s"%(index, name))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   544
                self.ListIndex.append(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   545
            if self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   546
                self.ChoiceIndex = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   547
                if i == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   548
                    self.IndexChoice.Append("User Type")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   549
                    self.IndexChoice.SetStringSelection("User Type")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   550
                elif i == 2:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   551
                    self.IndexChoice.Append("SDO Server")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   552
                    self.IndexChoice.Append("SDO Client")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   553
                    if choiceindex != wxNOT_FOUND and choice == self.IndexChoice.GetString(choiceindex):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   554
                         self.IndexChoice.SetStringSelection(choice)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   555
                elif i in (3, 4):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   556
                    self.IndexChoice.Append("PDO Receive")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   557
                    self.IndexChoice.SetStringSelection("PDO Receive")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   558
                elif i in (5, 6):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   559
                    self.IndexChoice.Append("PDO Transmit")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   560
                    self.IndexChoice.SetStringSelection("PDO Transmit")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   561
                elif i == 8:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   562
                    self.IndexChoice.Append("Map Variable")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   563
                    self.IndexChoice.SetStringSelection("Map Variable")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   564
                else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   565
                    for name, index in self.Manager.GetCurrentValidChoices(values["minIndex"], values["maxIndex"]):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   566
                        if index:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   567
                            self.IndexChoice.Append("0x%04X   %s"%(index, name))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   568
                        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   569
                            self.IndexChoice.Append(name)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   570
                        self.ChoiceIndex.append(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   571
                if choiceindex != wxNOT_FOUND and choice == self.IndexChoice.GetString(choiceindex):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   572
                    self.IndexChoice.SetStringSelection(choice)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   573
        if self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   574
            self.IndexChoice.Enable(self.IndexChoice.GetCount() != 0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   575
            self.AddButton.Enable(self.IndexChoice.GetCount() != 0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   576
        if selected == wxNOT_FOUND or selected >= len(self.ListIndex) or selectedindex != self.ListIndex[selected]:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   577
            self.Table.Empty()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   578
            self.CallbackCheck.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   579
            self.CallbackCheck.Disable()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   580
            self.Table.ResetView(self.SubindexGrid)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   581
            self.Parent.RefreshStatusBar()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   582
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   583
            self.IndexList.SetSelection(selected)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   584
            self.RefreshTable()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   585
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   586
    def RefreshTable(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   587
        selected = self.IndexList.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   588
        if selected != wxNOT_FOUND:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   589
            index = self.ListIndex[selected]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   590
            if index > 0x260 and self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   591
                self.CallbackCheck.Enable()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   592
                self.CallbackCheck.SetValue(self.Manager.HasCurrentEntryCallbacks(index))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   593
            result = self.Manager.GetCurrentEntryValues(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   594
            if result != None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   595
                self.Table.SetCurrentIndex(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   596
                data, editors = result
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   597
                self.Table.SetData(data)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   598
                self.Table.SetEditors(editors)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   599
                self.Table.ResetView(self.SubindexGrid)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   600
        self.Parent.RefreshStatusBar()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   601
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   602
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   603
#                        Editing Table value function
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   604
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   605
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   606
    def OnSubindexGridCellChange(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   607
        if self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   608
            index = self.Table.GetCurrentIndex()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   609
            subIndex = event.GetRow()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   610
            col = event.GetCol()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   611
            name = self.Table.GetColLabelValue(col)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   612
            value = self.Table.GetValue(subIndex, col)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   613
            editor = self.Table.GetEditor(subIndex, col)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   614
            self.Manager.SetCurrentEntry(index, subIndex, value, name, editor)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   615
            self.Parent.RefreshBufferState()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   616
            wxCallAfter(self.RefreshTable)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   617
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   618
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   619
    def OnCallbackCheck(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   620
        if self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   621
            index = self.Table.GetCurrentIndex()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   622
            self.Manager.SetCurrentEntryCallbacks(index, self.CallbackCheck.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   623
            self.Parent.RefreshBufferState()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   624
            wxCallAfter(self.RefreshTable)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   625
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   626
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   627
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   628
#                          Contextual Menu functions
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   629
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   630
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   631
    def OnIndexListRightUp(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   632
        if self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   633
            if not self.FirstCall:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   634
                self.FirstCall = True
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   635
                selected = self.IndexList.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   636
                if selected != wxNOT_FOUND:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   637
                    index = self.ListIndex[selected]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   638
                    if index < 0x260:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   639
                        self.IndexListMenu.FindItemByPosition(0).Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   640
                        self.IndexListMenu.FindItemByPosition(1).Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   641
                        self.PopupMenu(self.IndexListMenu)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   642
                    elif 0x1000 <= index <= 0x1BFF:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   643
                        self.IndexListMenu.FindItemByPosition(0).Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   644
                        self.IndexListMenu.FindItemByPosition(1).Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   645
                        self.PopupMenu(self.IndexListMenu)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   646
                    elif 0x2000 <= index <= 0x5FFF:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   647
                        self.IndexListMenu.FindItemByPosition(0).Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   648
                        self.IndexListMenu.FindItemByPosition(1).Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   649
                        self.PopupMenu(self.IndexListMenu)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   650
                    elif index >= 0x6000:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   651
                        self.IndexListMenu.FindItemByPosition(0).Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   652
                        self.IndexListMenu.FindItemByPosition(1).Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   653
                        self.PopupMenu(self.IndexListMenu)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   654
            else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   655
                self.FirstCall = False
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   656
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   657
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   658
    def OnSubindexGridRightClick(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   659
        if self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   660
            selected = self.IndexList.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   661
            if selected != wxNOT_FOUND:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   662
                index = self.ListIndex[selected]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   663
                if self.Manager.IsCurrentEntry(index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   664
                    infos = self.Manager.GetEntryInfos(index)
242
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
   665
                    if index >= 0x2000 and infos["struct"] & OD_MultipleSubindexes or infos["struct"] & OD_IdenticalSubindexes:
4864f7f01e1d Changes in networkedit for integration with beremiz
lbessard
parents: 237
diff changeset
   666
                        self.PopupMenu(self.SubindexGridMenu)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   667
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   668
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   669
    def OnRenameIndexMenu(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   670
        if self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   671
            selected = self.IndexList.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   672
            if selected != wxNOT_FOUND:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   673
                index = self.ListIndex[selected]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   674
                if self.Manager.IsCurrentEntry(index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   675
                    infos = self.Manager.GetEntryInfos(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   676
                    dialog = wxTextEntryDialog(self, "Give a new name for index 0x%04X"%index,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   677
                                 "Rename an index", infos["name"], wxOK|wxCANCEL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   678
                    if dialog.ShowModal() == wxID_OK:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   679
                        self.Manager.SetCurrentEntryName(index, dialog.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   680
                        self.Parent.RefreshBufferState()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   681
                        self.RefreshIndexList()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   682
                    dialog.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   683
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   684
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   685
    def OnModifyIndexMenu(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   686
        if self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   687
            selected = self.IndexList.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   688
            if selected != wxNOT_FOUND:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   689
                index = self.ListIndex[selected]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   690
                if self.Manager.IsCurrentEntry(index) and index < 0x260:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   691
                    values, valuetype = self.Manager.GetCustomisedTypeValues(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   692
                    dialog = UserTypeDialog(self)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   693
                    dialog.SetTypeList(self.Manager.GetCustomisableTypes(), values[1])
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   694
                    if valuetype == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   695
                        dialog.SetValues(min = values[2], max = values[3])
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   696
                    elif valuetype == 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   697
                        dialog.SetValues(length = values[2])
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   698
                    if dialog.ShowModal() == wxID_OK:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   699
                        type, min, max, length = dialog.GetValues()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   700
                        self.Manager.SetCurrentUserType(index, type, min, max, length)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   701
                        self.Parent.RefreshBufferState()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   702
                        self.RefreshIndexList()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   703
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   704
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   705
    def OnDeleteIndexMenu(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   706
        if self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   707
            selected = self.IndexList.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   708
            if selected != wxNOT_FOUND:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   709
                index = self.ListIndex[selected]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   710
                if self.Manager.IsCurrentEntry(index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   711
                    self.Manager.ManageEntriesOfCurrent([],[index])
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   712
                    self.Parent.RefreshBufferState()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   713
                    self.RefreshIndexList()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   714
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   715
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   716
    def OnAddSubindexMenu(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   717
        if self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   718
            selected = self.IndexList.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   719
            if selected != wxNOT_FOUND:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   720
                index = self.ListIndex[selected]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   721
                if self.Manager.IsCurrentEntry(index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   722
                    dialog = wxTextEntryDialog(self, "Number of subindexes to add:",
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   723
                                 "Add subindexes", "1", wxOK|wxCANCEL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   724
                    if dialog.ShowModal() == wxID_OK:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   725
                        try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   726
                            number = int(dialog.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   727
                            self.Manager.AddSubentriesToCurrent(index, number)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   728
                            self.Parent.RefreshBufferState()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   729
                            self.RefreshIndexList()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   730
                        except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   731
                            message = wxMessageDialog(self, "An integer is required!", "ERROR", wxOK|wxICON_ERROR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   732
                            message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   733
                            message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   734
                    dialog.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   735
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   736
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   737
    def OnDeleteSubindexMenu(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   738
        if self.Editable:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   739
            selected = self.IndexList.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   740
            if selected != wxNOT_FOUND:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   741
                index = self.ListIndex[selected]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   742
                if self.Manager.IsCurrentEntry(index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   743
                    dialog = wxTextEntryDialog(self, "Number of subindexes to delete:",
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   744
                                 "Delete subindexes", "1", wxOK|wxCANCEL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   745
                    if dialog.ShowModal() == wxID_OK:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   746
                        try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   747
                            number = int(dialog.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   748
                            self.Manager.RemoveSubentriesFromCurrent(index, number)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   749
                            self.Parent.RefreshBufferState()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   750
                            self.RefreshIndexList()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   751
                        except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   752
                            message = wxMessageDialog(self, "An integer is required!", "ERROR", wxOK|wxICON_ERROR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   753
                            message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   754
                            message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   755
                    dialog.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   756
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   757