dialogs/ArrayTypeDialog.py
author laurent
Fri, 23 Sep 2011 20:07:40 +0200
changeset 564 5024d42e1050
parent 534 d506a353b3d3
child 577 9dbb79722fbc
permissions -rw-r--r--
Adding custom cell editor for interval value in task informations of ResourceEditor
507
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
     1
# -*- coding: utf-8 -*-
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
     2
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
     3
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
     4
#based on the plcopen standard. 
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
     5
#
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
     6
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
     7
#
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
     8
#See COPYING file for copyrights details.
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
     9
#
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    10
#This library is free software; you can redistribute it and/or
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    11
#modify it under the terms of the GNU General Public
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    12
#License as published by the Free Software Foundation; either
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    13
#version 2.1 of the License, or (at your option) any later version.
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    14
#
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    15
#This library is distributed in the hope that it will be useful,
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    16
#but WITHOUT ANY WARRANTY; without even the implied warranty of
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    17
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    18
#General Public License for more details.
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    19
#
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    20
#You should have received a copy of the GNU General Public
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    21
#License along with this library; if not, write to the Free Software
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    22
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    23
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    24
import re
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    25
from types import TupleType
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    26
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    27
import wx
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    28
import wx.gizmos
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    29
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    30
DIMENSION_MODEL = re.compile("([0-9]+)\.\.([0-9]+)$")
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    31
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    32
[ID_ARRAYTYPEDIALOG, ID_ARRAYTYPEDIALOGBASETYPE, 
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    33
 ID_ARRAYTYPEDIALOGDIMENSIONS, ID_ARRAYTYPEDIALOGDIALOGSTATICTEXT1, 
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    34
] = [wx.NewId() for _init_ctrls in range(4)]
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    35
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    36
class ArrayTypeDialog(wx.Dialog):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    37
    
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    38
    if wx.VERSION < (2, 6, 0):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    39
        def Bind(self, event, function, id = None):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    40
            if id is not None:
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    41
                event(self, id, function)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    42
            else:
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    43
                event(self, function)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    44
    
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    45
    def _init_coll_flexGridSizer1_Items(self, parent):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    46
        parent.AddSizer(self.TopSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    47
        parent.AddWindow(self.Dimensions, 0, border=20, flag=wx.GROW|wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    48
        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    49
        
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    50
    def _init_coll_flexGridSizer1_Growables(self, parent):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    51
        parent.AddGrowableCol(0)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    52
        parent.AddGrowableRow(1)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    53
        
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    54
    def _init_coll_TopSizer_Items(self, parent):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    55
        parent.AddWindow(self.staticText1, 1, border=0, flag=wx.GROW)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    56
        parent.AddWindow(self.BaseType, 1, border=0, flag=wx.GROW)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    57
    
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    58
    def _init_sizers(self):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    59
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    60
        self.TopSizer = wx.BoxSizer(wx.HORIZONTAL)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    61
        
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    62
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    63
        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    64
        self._init_coll_TopSizer_Items(self.TopSizer)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    65
        
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    66
        self.SetSizer(self.flexGridSizer1)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    67
    
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    68
    def _init_ctrls(self, prnt):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    69
        wx.Dialog.__init__(self, id=ID_ARRAYTYPEDIALOG,
534
d506a353b3d3 Fix dialogs positions to stay on the same screen than parent frame
laurent
parents: 507
diff changeset
    70
              name='ArrayTypeDialog', parent=prnt,
507
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    71
              size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    72
              title=_('Edit array type properties'))
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    73
        self.SetClientSize(wx.Size(500, 300))
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    74
        
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    75
        self.staticText1 = wx.StaticText(id=ID_ARRAYTYPEDIALOGDIALOGSTATICTEXT1,
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    76
              label=_('Base Type:'), name='staticText1', parent=self,
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    77
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    78
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    79
        self.BaseType = wx.ComboBox(id=ID_ARRAYTYPEDIALOGBASETYPE, 
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    80
              name='BaseType', parent=self, pos=wx.Point(0, 0),
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    81
              size=wx.Size(0, 28), style=wx.CB_READONLY)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    82
        
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    83
        self.Dimensions = wx.gizmos.EditableListBox(id=ID_ARRAYTYPEDIALOGDIMENSIONS, 
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    84
              name='ArrayDimensions', parent=self, label=_("Dimensions:"), pos=wx.Point(0, 0),
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    85
              size=wx.Size(0, 24), style=wx.gizmos.EL_ALLOW_NEW | wx.gizmos.EL_ALLOW_EDIT | wx.gizmos.EL_ALLOW_DELETE)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    86
        self.Dimensions.GetListCtrl().Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnDimensionsChanged)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    87
        new_button = self.Dimensions.GetNewButton()
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    88
        new_button.SetToolTipString(_("New item"))
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    89
        new_button.Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    90
        del_button = self.Dimensions.GetDelButton()
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    91
        del_button.SetToolTipString(_("Delete item"))
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    92
        del_button.Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    93
        up_button = self.Dimensions.GetUpButton()
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    94
        up_button.SetToolTipString(_("Move up"))
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    95
        up_button.Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    96
        down_button = self.Dimensions.GetDownButton()
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    97
        down_button.SetToolTipString(_("Move down"))
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    98
        down_button.Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
    99
        
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   100
        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   101
        if wx.VERSION >= (2, 5, 0):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   102
            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   103
        else:
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   104
            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   105
        
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   106
        self._init_sizers()
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   107
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   108
    def __init__(self, parent, datatypes, infos):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   109
        self._init_ctrls(parent)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   110
        
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   111
        for datatype in datatypes:
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   112
            self.BaseType.Append(datatype)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   113
        
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   114
        if isinstance(infos, TupleType) and infos[0] == "array":
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   115
            self.BaseType.SetStringSelection(infos[1])
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   116
            self.Dimensions.SetStrings(map(lambda x : "..".join(x), infos[2]))
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   117
        elif infos in datatypes:
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   118
            self.BaseType.SetStringSelection(infos)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   119
        
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   120
    def GetDimensions(self):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   121
        dimensions_list = []
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   122
        for dimensions in self.Dimensions.GetStrings():
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   123
            result = DIMENSION_MODEL.match(dimensions)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   124
            if result is None:
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   125
                message = wx.MessageDialog(self, _("\"%s\" value isn't a valid array dimension!")%dimensions, _("Error"), wx.OK|wx.ICON_ERROR)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   126
                message.ShowModal()
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   127
                message.Destroy()
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   128
                return None
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   129
            bounds = result.groups()
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   130
            if int(bounds[0]) >= int(bounds[1]):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   131
                message = wx.MessageDialog(self, _("\"%s\" value isn't a valid array dimension!\nRight value must be greater than left value.")%dimensions, _("Error"), wx.OK|wx.ICON_ERROR)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   132
                message.ShowModal()
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   133
                message.Destroy()
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   134
                return None
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   135
            dimensions_list.append(bounds)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   136
        return dimensions_list
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   137
    
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   138
    def OnDimensionsChanged(self, event):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   139
        wx.CallAfter(self.GetDimensions)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   140
        event.Skip()
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   141
    
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   142
    def OnOK(self, event):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   143
        if self.GetDimensions() is not None:
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   144
            self.EndModal(wx.ID_OK)
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   145
            
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   146
    def GetValue(self):
42150e041dbe Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
diff changeset
   147
        return "array", self.BaseType.GetStringSelection(), self.GetDimensions()