etherlab/ConfigEditor.py
author Laurent Bessard
Wed, 27 Feb 2013 22:40:45 +0100
changeset 2097 58d07e039896
parent 2095 6733a7c5c897
child 2098 392791b5cc04
permissions -rw-r--r--
Added panel for managing ESI files from project and from database including module PDO alignment setting
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
     1
import os
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
     2
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     3
import wx
2026
65ecbfe9a6f9 Adding support for drag'n dropping located variables from topology panel to configurations and resources variable panel for declaring global located variables
laurent
parents: 2023
diff changeset
     4
import wx.grid
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
     5
import wx.gizmos
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
     6
import wx.lib.buttons
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
     7
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
     8
from controls import CustomGrid, CustomTable, FolderTree
2071
37d603e91a43 Fix import after integration of plcopeneditor into Beremiz
Laurent Bessard
parents: 2067
diff changeset
     9
from editors.ConfTreeNodeEditor import ConfTreeNodeEditor, SCROLLBAR_UNIT
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    10
from util.BitmapLibrary import GetBitmap
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    11
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    12
[ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    13
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    14
def AppendMenu(parent, help, id, kind, text):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    15
    if wx.VERSION >= (2, 6, 0):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    16
        parent.Append(help=help, id=id, kind=kind, text=text)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    17
    else:
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    18
        parent.Append(helpString=help, id=id, kind=kind, item=text)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    19
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    20
def GetVariablesTableColnames():
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    21
    _ = lambda x : x
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    22
    return ["#", _("Name"), _("Index"), _("SubIndex"), _("Type"), _("Access")]
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    23
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    24
ACCESS_TYPES = {
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    25
    'ro': 'R',
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    26
    'wo': 'W',
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    27
    'rw': 'R/W'}
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    28
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    29
def GetAccessValue(access, pdo_mapping):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    30
    value = ACCESS_TYPES.get(access)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    31
    if pdo_mapping != "":
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    32
        value += "/P"
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    33
    return value
2034
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    34
2053
5998beb54a6c refactoring
laurent
parents: 2048
diff changeset
    35
class NodeEditor(ConfTreeNodeEditor):
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    36
    
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    37
    CONFNODEEDITOR_TABS = [
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    38
        (_("Ethercat node"), "_create_EthercatNodeEditor")]
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    39
    
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    40
    def _create_EthercatNodeEditor(self, prnt):
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    41
        self.EthercatNodeEditor = wx.Panel(prnt, style=wx.TAB_TRAVERSAL)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    42
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    43
        main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    44
        main_sizer.AddGrowableCol(0)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    45
        main_sizer.AddGrowableRow(1)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    46
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    47
        variables_label = wx.StaticText(self.EthercatNodeEditor,
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    48
              label=_('Variable entries:'))
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    49
        main_sizer.AddWindow(variables_label, border=10, flag=wx.TOP|wx.LEFT|wx.RIGHT)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    50
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    51
        self.VariablesGrid = wx.gizmos.TreeListCtrl(self.EthercatNodeEditor,
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    52
              style=wx.TR_DEFAULT_STYLE |
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    53
                    wx.TR_ROW_LINES |
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    54
                    wx.TR_COLUMN_LINES |
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    55
                    wx.TR_HIDE_ROOT |
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    56
                    wx.TR_FULL_ROW_HIGHLIGHT)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    57
        self.VariablesGrid.GetMainWindow().Bind(wx.EVT_LEFT_DOWN, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    58
            self.OnVariablesGridLeftClick)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    59
        main_sizer.AddWindow(self.VariablesGrid, border=10, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    60
            flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    61
                
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    62
        self.EthercatNodeEditor.SetSizer(main_sizer)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    63
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    64
        return self.EthercatNodeEditor
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    65
    
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    66
    def __init__(self, parent, controler, window):
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
    67
        ConfTreeNodeEditor.__init__(self, parent, controler, window)
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    68
    
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    69
        for colname, colsize, colalign in zip(GetVariablesTableColnames(),
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    70
                                              [40, 150, 100, 100, 150, 100],
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    71
                                              [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, 
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    72
                                               wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_LEFT]):
2072
b7477ba593ba Fix bug variable entries table column headers not translated
Laurent Bessard
parents: 2071
diff changeset
    73
            self.VariablesGrid.AddColumn(_(colname), colsize, colalign)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    74
        self.VariablesGrid.SetMainColumn(1)
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    75
    
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    76
    def GetBufferState(self):
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    77
        return False, False
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    78
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    79
    def RefreshView(self):
2060
c7a2c9362d63 Fixing bug on ConfNodeEditors refresh
Laurent Bessard
parents: 2058
diff changeset
    80
        ConfTreeNodeEditor.RefreshView(self)
2067
04cc0295e2c4 Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents: 2060
diff changeset
    81
    
04cc0295e2c4 Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents: 2060
diff changeset
    82
        self.RefreshSlaveInfos()
04cc0295e2c4 Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents: 2060
diff changeset
    83
        
04cc0295e2c4 Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents: 2060
diff changeset
    84
    def RefreshSlaveInfos(self):
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    85
        slave_infos = self.Controler.GetSlaveInfos()
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    86
        if slave_infos is not None:
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    87
            self.RefreshVariablesGrid(slave_infos["entries"])
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    88
        else:
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    89
            self.RefreshVariablesGrid([])
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    90
    
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    91
    def RefreshVariablesGrid(self, entries):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    92
        root = self.VariablesGrid.GetRootItem()
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    93
        if not root.IsOk():
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    94
            root = self.VariablesGrid.AddRoot("Slave entries")
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    95
        self.GenerateVariablesGridBranch(root, entries, GetVariablesTableColnames())
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    96
        self.VariablesGrid.Expand(root)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    97
        
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    98
    def GenerateVariablesGridBranch(self, root, entries, colnames, idx=0):
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
    99
        item, root_cookie = self.VariablesGrid.GetFirstChild(root)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   100
        
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   101
        no_more_items = not item.IsOk()
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   102
        for entry in entries:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   103
            idx += 1
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   104
            if no_more_items:
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   105
                item = self.VariablesGrid.AppendItem(root, "")
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   106
            for col, colname in enumerate(colnames):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   107
                if col == 0:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   108
                    self.VariablesGrid.SetItemText(item, str(idx), 0)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   109
                else:
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   110
                    value = entry.get(colname, "")
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   111
                    if colname == "Access":
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   112
                        value = GetAccessValue(value, entry.get("PDOMapping", ""))
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   113
                    self.VariablesGrid.SetItemText(item, value, col)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   114
            if entry["PDOMapping"] == "":
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   115
                self.VariablesGrid.SetItemBackgroundColour(item, wx.LIGHT_GREY)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   116
            self.VariablesGrid.SetItemPyData(item, entry)
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   117
            idx = self.GenerateVariablesGridBranch(item, entry["children"], colnames, idx)
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   118
            if not no_more_items:
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   119
                item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie)
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   120
                no_more_items = not item.IsOk()
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   121
        
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   122
        if not no_more_items:
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   123
            to_delete = []
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   124
            while item.IsOk():
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   125
                to_delete.append(item)
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   126
                item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie)
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   127
            for item in to_delete:
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   128
                self.VariablesGrid.Delete(item)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   129
        
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   130
        return idx
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   131
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   132
    def OnVariablesGridLeftClick(self, event):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   133
        item, flags, col = self.VariablesGrid.HitTest(event.GetPosition())
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   134
        if item.IsOk():
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   135
            entry = self.VariablesGrid.GetItemPyData(item)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   136
            data_type = entry.get("Type", "")
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   137
            pdo_mapping = entry.get("PDOMapping", "")
2029
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   138
            
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   139
            if (col == -1 and pdo_mapping != "" and
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   140
                self.Controler.GetSizeOfType(data_type) is not None):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   141
                
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   142
                entry_index = self.Controler.ExtractHexDecValue(entry.get("Index", "0"))
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   143
                entry_subindex = self.Controler.ExtractHexDecValue(entry.get("SubIndex", "0"))
2048
5726f2bbdace reflected changes in beremiz extension mechanism
Edouard Tisserant
parents: 2043
diff changeset
   144
                var_name = "%s_%4.4x_%2.2x" % (self.Controler.CTNName(), entry_index, entry_subindex)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   145
                if pdo_mapping == "R":
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   146
                    dir = "%I"
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   147
                else:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   148
                    dir = "%Q"
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   149
                location = "%s%s" % (dir, self.Controler.GetSizeOfType(data_type)) + \
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   150
                           ".".join(map(lambda x:str(x), self.Controler.GetCurrentLocation() + (self.Controler.GetSlavePos(), entry_index, entry_subindex)))
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   151
                
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   152
                data = wx.TextDataObject(str((location, "location", data_type, var_name, "")))
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   153
                dragSource = wx.DropSource(self.VariablesGrid)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   154
                dragSource.SetData(data)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   155
                dragSource.DoDragDrop()
2089
3f5c41f3d47f Fix bug when Drag'n Dropping located variables on Windows
Laurent Bessard
parents: 2072
diff changeset
   156
                return
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   157
            
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   158
        event.Skip()
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   159
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   160
CIA402NodeEditor = NodeEditor
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   161
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   162
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   163
def GetModulesTableColnames():
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   164
    _ = lambda x : x
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   165
    return [_("Name"), _("PDO alignment (bits)")]
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   166
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   167
class LibraryEditorPanel(wx.ScrolledWindow):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   168
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   169
    def __init__(self, parent, module_library, buttons):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   170
        wx.ScrolledWindow.__init__(self, parent,
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   171
            style=wx.TAB_TRAVERSAL|wx.HSCROLL|wx.VSCROLL)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   172
        self.Bind(wx.EVT_SIZE, self.OnResize)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   173
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   174
        self.ModuleLibrary = module_library
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   175
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   176
        main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=4, vgap=5)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   177
        main_sizer.AddGrowableCol(0)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   178
        main_sizer.AddGrowableRow(1)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   179
        main_sizer.AddGrowableRow(3)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   180
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   181
        ESI_files_label = wx.StaticText(self, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   182
            label=_("ESI Files:"))
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   183
        main_sizer.AddWindow(ESI_files_label, border=10, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   184
            flag=wx.TOP|wx.LEFT|wx.RIGHT)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   185
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   186
        folder_tree_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=1, vgap=0)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   187
        folder_tree_sizer.AddGrowableCol(0)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   188
        folder_tree_sizer.AddGrowableRow(0)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   189
        main_sizer.AddSizer(folder_tree_sizer, border=10, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   190
            flag=wx.GROW|wx.LEFT|wx.RIGHT)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   191
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   192
        self.ESIFiles = FolderTree(self, self.GetPath(), editable=False)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   193
        self.ESIFiles.SetFilter(".xml")
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   194
        self.ESIFiles.SetMinSize(wx.Size(600, 300))
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   195
        folder_tree_sizer.AddWindow(self.ESIFiles, flag=wx.GROW)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   196
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   197
        buttons_sizer = wx.BoxSizer(wx.VERTICAL)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   198
        folder_tree_sizer.AddSizer(buttons_sizer, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   199
            flag=wx.ALIGN_CENTER_VERTICAL)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   200
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   201
        for idx, (name, bitmap, help, callback) in enumerate(buttons):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   202
            button = wx.lib.buttons.GenBitmapButton(self, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   203
                  bitmap=GetBitmap(bitmap), 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   204
                  size=wx.Size(28, 28), style=wx.NO_BORDER)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   205
            button.SetToolTipString(help)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   206
            setattr(self, name, button)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   207
            if idx > 0:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   208
                flag = wx.TOP
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   209
            else:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   210
                flag = 0
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   211
            if callback is None:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   212
                callback = getattr(self, "On" + name, None)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   213
            if callback is not None:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   214
                self.Bind(wx.EVT_BUTTON, callback, button)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   215
            buttons_sizer.AddWindow(button, border=10, flag=flag)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   216
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   217
        modules_label = wx.StaticText(self, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   218
            label=_("Modules library:"))
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   219
        main_sizer.AddSizer(modules_label, border=10, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   220
            flag=wx.LEFT|wx.RIGHT)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   221
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   222
        self.ModulesGrid = wx.gizmos.TreeListCtrl(self,
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   223
              style=wx.TR_DEFAULT_STYLE |
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   224
                    wx.TR_ROW_LINES |
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   225
                    wx.TR_COLUMN_LINES |
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   226
                    wx.TR_HIDE_ROOT |
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   227
                    wx.TR_FULL_ROW_HIGHLIGHT)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   228
        self.ModulesGrid.SetMinSize(wx.Size(600, 300))
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   229
        self.ModulesGrid.GetMainWindow().Bind(wx.EVT_LEFT_DCLICK,
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   230
            self.OnModulesGridLeftDClick)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   231
        main_sizer.AddWindow(self.ModulesGrid, border=10, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   232
            flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   233
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   234
        self.SetSizer(main_sizer)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   235
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   236
        for colname, colsize, colalign in zip(GetModulesTableColnames(),
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   237
                                              [400, 150],
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   238
                                              [wx.ALIGN_LEFT, wx.ALIGN_RIGHT]):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   239
            self.ModulesGrid.AddColumn(_(colname), colsize, colalign)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   240
        self.ModulesGrid.SetMainColumn(0)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   241
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   242
    def GetPath(self):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   243
        return self.ModuleLibrary.GetPath()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   244
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   245
    def GetSelectedFilePath(self):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   246
        return self.ESIFiles.GetPath()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   247
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   248
    def RefreshView(self):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   249
        self.ESIFiles.RefreshTree()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   250
        self.RefreshModulesGrid()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   251
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   252
    def RefreshModulesGrid(self):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   253
        root = self.ModulesGrid.GetRootItem()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   254
        if not root.IsOk():
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   255
            root = self.ModulesGrid.AddRoot("Modules")
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   256
        self.GenerateModulesGridBranch(root, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   257
            self.ModuleLibrary.GetModulesLibrary(), 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   258
            GetVariablesTableColnames())
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   259
        self.ModulesGrid.Expand(root)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   260
            
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   261
    def GenerateModulesGridBranch(self, root, modules, colnames):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   262
        item, root_cookie = self.ModulesGrid.GetFirstChild(root)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   263
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   264
        no_more_items = not item.IsOk()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   265
        for module in modules:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   266
            if no_more_items:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   267
                item = self.ModulesGrid.AppendItem(root, "")
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   268
            self.ModulesGrid.SetItemText(item, module["name"], 0)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   269
            if module["infos"] is not None:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   270
                self.ModulesGrid.SetItemText(item, str(module["infos"]["alignment"]), 1)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   271
            else:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   272
                self.ModulesGrid.SetItemBackgroundColour(item, wx.LIGHT_GREY)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   273
            self.ModulesGrid.SetItemPyData(item, module["infos"])
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   274
            self.GenerateModulesGridBranch(item, module["children"], colnames)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   275
            if not no_more_items:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   276
                item, root_cookie = self.ModulesGrid.GetNextChild(root, root_cookie)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   277
                no_more_items = not item.IsOk()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   278
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   279
        if not no_more_items:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   280
            to_delete = []
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   281
            while item.IsOk():
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   282
                to_delete.append(item)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   283
                item, root_cookie = self.ModulesGrid.GetNextChild(root, root_cookie)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   284
            for item in to_delete:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   285
                self.ModulesGrid.Delete(item)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   286
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   287
    def OnImportButton(self, event):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   288
        dialog = wx.FileDialog(self,
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   289
             _("Choose an XML file"), 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   290
             os.getcwd(), "",  
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   291
             _("XML files (*.xml)|*.xml|All files|*.*"), wx.OPEN)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   292
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   293
        if dialog.ShowModal() == wx.ID_OK:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   294
            filepath = dialog.GetPath()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   295
            if self.ModuleLibrary.ImportModuleLibrary(filepath):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   296
                wx.CallAfter(self.RefreshView)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   297
            else:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   298
                message = wx.MessageDialog(self, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   299
                    _("No such XML file: %s\n") % filepath, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   300
                    _("Error"), wx.OK|wx.ICON_ERROR)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   301
                message.ShowModal()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   302
                message.Destroy()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   303
        dialog.Destroy()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   304
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   305
        event.Skip()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   306
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   307
    def OnDeleteButton(self, event):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   308
        filepath = self.GetSelectedFilePath()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   309
        if os.path.isfile(filepath):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   310
            folder, filename = os.path.split(filepath)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   311
            
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   312
            dialog = wx.MessageDialog(self, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   313
                  _("Do you really want to delete the file '%s'?") % filename, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   314
                  _("Delete File"), wx.YES_NO|wx.ICON_QUESTION)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   315
            remove = dialog.ShowModal() == wx.ID_YES
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   316
            dialog.Destroy()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   317
            
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   318
            if remove:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   319
                os.remove(filepath)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   320
                self.ModuleLibrary.LoadModules()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   321
                wx.CallAfter(self.RefreshView)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   322
        event.Skip()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   323
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   324
    def OnModulesGridLeftDClick(self, event):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   325
        item, flags, col = self.ModulesGrid.HitTest(event.GetPosition())
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   326
        if item.IsOk():
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   327
            entry_infos = self.ModulesGrid.GetItemPyData(item)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   328
            if entry_infos is not None and col == 1:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   329
                dialog = wx.TextEntryDialog(self, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   330
                    _("Set PDO alignment (bits):"),
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   331
                    _("%s PDO alignment") % self.ModulesGrid.GetItemText(item), 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   332
                    str(entry_infos["alignment"]))
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   333
                
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   334
                if dialog.ShowModal() == wx.ID_OK:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   335
                    try:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   336
                        self.ModuleLibrary.SetAlignment(
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   337
                            entry_infos["vendor"],
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   338
                            entry_infos["product_code"],
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   339
                            entry_infos["revision_number"],
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   340
                            int(dialog.GetValue()))
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   341
                        wx.CallAfter(self.RefreshModulesGrid)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   342
                    except ValueError:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   343
                        message = wx.MessageDialog(self, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   344
                            _("Module PDO alignment must be an integer!"), 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   345
                            _("Error"), wx.OK|wx.ICON_ERROR)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   346
                        message.ShowModal()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   347
                        message.Destroy()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   348
                    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   349
                dialog.Destroy()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   350
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   351
        event.Skip()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   352
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   353
    def OnResize(self, event):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   354
        self.GetBestSize()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   355
        xstart, ystart = self.GetViewStart()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   356
        window_size = self.GetClientSize()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   357
        maxx, maxy = self.GetMinSize()
2058
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   358
        posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT))
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   359
        posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT))
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   360
        self.Scroll(posx, posy)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   361
        self.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, 
2058
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   362
                maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, posx, posy)
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   363
        event.Skip()
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   364
2097
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   365
class DatabaseManagementDialog(wx.Dialog):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   366
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   367
    def __init__(self, parent, database):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   368
        wx.Dialog.__init__(self, parent,
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   369
              size=wx.Size(700, 500), title=_('ESI Files Database management'),
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   370
              style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   371
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   372
        main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   373
        main_sizer.AddGrowableCol(0)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   374
        main_sizer.AddGrowableRow(0)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   375
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   376
        self.DatabaseEditor = LibraryEditorPanel(self, database,
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   377
            [("ImportButton", "ImportESI", _("Import file to ESI files database"), None),
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   378
             ("DeleteButton", "remove_element", _("Remove file from database"), None)])
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   379
        main_sizer.AddWindow(self.DatabaseEditor, border=10,
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   380
            flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   381
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   382
        button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   383
        button_sizer.GetAffirmativeButton().SetLabel(_("Add file to project"))
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   384
        button_sizer.GetCancelButton().SetLabel(_("Close"))
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   385
        main_sizer.AddSizer(button_sizer, border=10, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   386
              flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   387
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   388
        self.SetSizer(main_sizer)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   389
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   390
        self.DatabaseEditor.RefreshView()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   391
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   392
    def GetValue(self):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   393
        return self.DatabaseEditor.GetSelectedFilePath()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   394
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   395
class LibraryEditor(ConfTreeNodeEditor):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   396
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   397
    CONFNODEEDITOR_TABS = [
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   398
        (_("Modules Library"), "_create_ModuleLibraryEditor")]
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   399
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   400
    def _create_ModuleLibraryEditor(self, prnt):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   401
        self.ModuleLibraryEditor = LibraryEditorPanel(prnt,
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   402
            self.Controler.GetModulesLibraryInstance(),
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   403
            [("ImportButton", "ImportESI", _("Import ESI file"), None),
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   404
             ("AddButton", "ImportDatabase", _("Add file from ESI files database"), self.OnAddButton),
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   405
             ("DeleteButton", "remove_element", _("Remove file from library"), None)])
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   406
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   407
        return self.ModuleLibraryEditor
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   408
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   409
    def __init__(self, parent, controler, window):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   410
        ConfTreeNodeEditor.__init__(self, parent, controler, window)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   411
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   412
        self.RefreshView()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   413
    
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   414
    def RefreshView(self):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   415
        ConfTreeNodeEditor.RefreshView(self)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   416
        self.ModuleLibraryEditor.RefreshView()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   417
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   418
    def OnAddButton(self, event):
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   419
        dialog = DatabaseManagementDialog(self, 
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   420
            self.Controler.GetModulesDatabaseInstance())
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   421
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   422
        if dialog.ShowModal() == wx.ID_OK:
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   423
            module_library = self.Controler.GetModulesLibraryInstance()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   424
            module_library.ImportModuleLibrary(dialog.GetValue())
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   425
            
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   426
        dialog.Destroy()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   427
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   428
        wx.CallAfter(self.ModuleLibraryEditor.RefreshView)
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   429
        
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   430
        event.Skip()
58d07e039896 Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents: 2095
diff changeset
   431