author | laurent |
Fri, 18 Nov 2011 17:39:12 +0100 | |
changeset 590 | b2442bb10c0b |
parent 586 | 9aa96a36cf33 |
child 591 | 4d6719c51f05 |
permissions | -rw-r--r-- |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
1 |
#!/usr/bin/env python |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
3 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
4 |
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
5 |
#based on the plcopen standard. |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
6 |
# |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
7 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
8 |
# |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
9 |
#See COPYING file for copyrights details. |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
10 |
# |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
11 |
#This library is free software; you can redistribute it and/or |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
12 |
#modify it under the terms of the GNU General Public |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
13 |
#License as published by the Free Software Foundation; either |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
15 |
# |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
16 |
#This library is distributed in the hope that it will be useful, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
19 |
#General Public License for more details. |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
20 |
# |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
21 |
#You should have received a copy of the GNU General Public |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
22 |
#License along with this library; if not, write to the Free Software |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
24 |
|
436
f3bb091f803f
Fix BrowseVariableDialog to be used in PLCOpenEditor without Beremiz plugins
laurent
parents:
431
diff
changeset
|
25 |
import os |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
26 |
import wx, wx.grid |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
27 |
|
580 | 28 |
from types import TupleType, StringType, UnicodeType |
419
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
29 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
30 |
from plcopen.structures import LOCATIONDATATYPES, TestIdentifier, IEC_KEYWORDS |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
31 |
from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD |
507
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
32 |
from dialogs import ArrayTypeDialog |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
33 |
from CustomGrid import CustomGrid |
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
34 |
from LocationCellEditor import LocationCellEditor |
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
35 |
|
431
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
36 |
# Compatibility function for wx versions < 2.6 |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
37 |
def AppendMenu(parent, help, id, kind, text): |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
38 |
if wx.VERSION >= (2, 6, 0): |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
39 |
parent.Append(help=help, id=id, kind=kind, text=text) |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
40 |
else: |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
41 |
parent.Append(helpString=help, id=id, kind=kind, item=text) |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
42 |
|
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
43 |
[TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE, |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
44 |
INSTANCESTREE, LIBRARYTREE, SCALING |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
45 |
] = range(9) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
46 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
47 |
#------------------------------------------------------------------------------- |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
48 |
# Variables Editor Panel |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
49 |
#------------------------------------------------------------------------------- |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
50 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
51 |
def GetVariableTableColnames(location): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
52 |
_ = lambda x : x |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
53 |
if location: |
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
54 |
return ["#", _("Name"), _("Class"), _("Type"), _("Location"), _("Initial Value"), _("Option"), _("Documentation")] |
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
55 |
return ["#", _("Name"), _("Class"), _("Type"), _("Initial Value"), _("Option"), _("Documentation")] |
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
56 |
|
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
57 |
def GetOptions(constant=True, retain=True, non_retain=True): |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
58 |
_ = lambda x : x |
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
59 |
options = [""] |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
60 |
if constant: |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
61 |
options.append(_("Constant")) |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
62 |
if retain: |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
63 |
options.append(_("Retain")) |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
64 |
if non_retain: |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
65 |
options.append(_("Non-Retain")) |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
66 |
return options |
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
67 |
OPTIONS_DICT = dict([(_(option), option) for option in GetOptions()]) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
68 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
69 |
def GetFilterChoiceTransfer(): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
70 |
_ = lambda x : x |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
71 |
return {_("All"): _("All"), _("Interface"): _("Interface"), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
72 |
_(" Input"): _("Input"), _(" Output"): _("Output"), _(" InOut"): _("InOut"), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
73 |
_(" External"): _("External"), _("Variables"): _("Variables"), _(" Local"): _("Local"), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
74 |
_(" Temp"): _("Temp"), _("Global"): _("Global")}#, _("Access") : _("Access")} |
509
6f72513bc074
Bug on variable panel row size in grid preventing readability of value inside cell editors fixed
laurent
parents:
507
diff
changeset
|
75 |
VARIABLE_CHOICES_DICT = dict([(_(_class), _class) for _class in GetFilterChoiceTransfer().iterkeys()]) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
76 |
VARIABLE_CLASSES_DICT = dict([(_(_class), _class) for _class in GetFilterChoiceTransfer().itervalues()]) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
77 |
|
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
78 |
CheckOptionForClass = {"Local": lambda x: x, |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
79 |
"Temp": lambda x: "", |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
80 |
"Input": lambda x: {"Retain": "Retain", "Non-Retain": "Non-Retain"}.get(x, ""), |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
81 |
"InOut": lambda x: "", |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
82 |
"Output": lambda x: {"Retain": "Retain", "Non-Retain": "Non-Retain"}.get(x, ""), |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
83 |
"Global": lambda x: {"Constant": "Constant", "Retain": "Retain"}.get(x, ""), |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
84 |
"External": lambda x: {"Constant": "Constant"}.get(x, "") |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
85 |
} |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
86 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
87 |
class VariableTable(wx.grid.PyGridTableBase): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
88 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
89 |
""" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
90 |
A custom wx.grid.Grid Table using user supplied data |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
91 |
""" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
92 |
def __init__(self, parent, data, colnames): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
93 |
# The base class must be initialized *first* |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
94 |
wx.grid.PyGridTableBase.__init__(self) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
95 |
self.data = data |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
96 |
self.old_value = None |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
97 |
self.colnames = colnames |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
98 |
self.Highlights = {} |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
99 |
self.Parent = parent |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
100 |
# XXX |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
101 |
# we need to store the row length and collength to |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
102 |
# see if the table has changed size |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
103 |
self._rows = self.GetNumberRows() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
104 |
self._cols = self.GetNumberCols() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
105 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
106 |
def GetNumberCols(self): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
107 |
return len(self.colnames) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
108 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
109 |
def GetNumberRows(self): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
110 |
return len(self.data) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
111 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
112 |
def GetColLabelValue(self, col, translate=True): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
113 |
if col < len(self.colnames): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
114 |
if translate: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
115 |
return _(self.colnames[col]) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
116 |
return self.colnames[col] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
117 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
118 |
def GetRowLabelValues(self, row, translate=True): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
119 |
return row |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
120 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
121 |
def GetValue(self, row, col): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
122 |
if row < self.GetNumberRows(): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
123 |
if col == 0: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
124 |
return self.data[row]["Number"] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
125 |
colname = self.GetColLabelValue(col, False) |
507
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
126 |
value = self.data[row].get(colname, "") |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
127 |
if colname == "Type" and isinstance(value, TupleType): |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
128 |
if value[0] == "array": |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
129 |
return "ARRAY [%s] OF %s" % (",".join(map(lambda x : "..".join(x), value[2])), value[1]) |
580 | 130 |
if not isinstance(value, (StringType, UnicodeType)): |
131 |
value = str(value) |
|
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
132 |
if colname in ["Class", "Option"]: |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
133 |
return _(value) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
134 |
return value |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
135 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
136 |
def SetValue(self, row, col, value): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
137 |
if col < len(self.colnames): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
138 |
colname = self.GetColLabelValue(col, False) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
139 |
if colname == "Name": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
140 |
self.old_value = self.data[row][colname] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
141 |
elif colname == "Class": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
142 |
value = VARIABLE_CLASSES_DICT[value] |
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
143 |
self.SetValueByName(row, "Option", CheckOptionForClass[value](self.GetValueByName(row, "Option"))) |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
144 |
if value == "External": |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
145 |
self.SetValueByName(row, "Initial Value", "") |
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
146 |
elif colname == "Option": |
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
147 |
value = OPTIONS_DICT[value] |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
148 |
self.data[row][colname] = value |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
149 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
150 |
def GetValueByName(self, row, colname): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
151 |
if row < self.GetNumberRows(): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
152 |
return self.data[row].get(colname) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
153 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
154 |
def SetValueByName(self, row, colname, value): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
155 |
if row < self.GetNumberRows(): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
156 |
self.data[row][colname] = value |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
157 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
158 |
def GetOldValue(self): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
159 |
return self.old_value |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
160 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
161 |
def ResetView(self, grid): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
162 |
""" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
163 |
(wx.grid.Grid) -> Reset the grid view. Call this to |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
164 |
update the grid if rows and columns have been added or deleted |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
165 |
""" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
166 |
grid.BeginBatch() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
167 |
for current, new, delmsg, addmsg in [ |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
168 |
(self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
169 |
(self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
170 |
]: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
171 |
if new < current: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
172 |
msg = wx.grid.GridTableMessage(self,delmsg,new,current-new) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
173 |
grid.ProcessTableMessage(msg) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
174 |
elif new > current: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
175 |
msg = wx.grid.GridTableMessage(self,addmsg,new-current) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
176 |
grid.ProcessTableMessage(msg) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
177 |
self.UpdateValues(grid) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
178 |
grid.EndBatch() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
179 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
180 |
self._rows = self.GetNumberRows() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
181 |
self._cols = self.GetNumberCols() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
182 |
# update the column rendering scheme |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
183 |
self._updateColAttrs(grid) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
184 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
185 |
# update the scrollbars and the displayed part of the grid |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
186 |
grid.AdjustScrollbars() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
187 |
grid.ForceRefresh() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
188 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
189 |
def UpdateValues(self, grid): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
190 |
"""Update all displayed values""" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
191 |
# This sends an event to the grid table to update all of the values |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
192 |
msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
193 |
grid.ProcessTableMessage(msg) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
194 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
195 |
def _updateColAttrs(self, grid): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
196 |
""" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
197 |
wx.grid.Grid -> update the column attributes to add the |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
198 |
appropriate renderer given the column name. |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
199 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
200 |
Otherwise default to the default renderer. |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
201 |
""" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
202 |
for row in range(self.GetNumberRows()): |
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
203 |
var_class = self.GetValueByName(row, "Class") |
552
a387f258814a
Disabling location definition for enumerated and structure variables
laurent
parents:
544
diff
changeset
|
204 |
var_type = self.GetValueByName(row, "Type") |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
205 |
row_highlights = self.Highlights.get(row, {}) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
206 |
for col in range(self.GetNumberCols()): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
207 |
editor = None |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
208 |
renderer = None |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
209 |
colname = self.GetColLabelValue(col, False) |
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
210 |
if colname == "Option": |
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
211 |
options = GetOptions(constant = var_class in ["Local", "External", "Global"], |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
212 |
retain = self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output", "Global"], |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
213 |
non_retain = self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output"]) |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
214 |
if len(options) > 1: |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
215 |
editor = wx.grid.GridCellChoiceEditor() |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
216 |
editor.SetParameters(",".join(map(_, options))) |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
217 |
else: |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
218 |
grid.SetReadOnly(row, col, True) |
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
219 |
elif col != 0 and self.GetValueByName(row, "Edit"): |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
220 |
grid.SetReadOnly(row, col, False) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
221 |
if colname == "Name": |
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
222 |
if self.Parent.PouIsUsed and var_class in ["Input", "Output", "InOut"]: |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
223 |
grid.SetReadOnly(row, col, True) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
224 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
225 |
editor = wx.grid.GridCellTextEditor() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
226 |
renderer = wx.grid.GridCellStringRenderer() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
227 |
elif colname == "Initial Value": |
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
228 |
if var_class != "External": |
552
a387f258814a
Disabling location definition for enumerated and structure variables
laurent
parents:
544
diff
changeset
|
229 |
if self.Parent.Controler.IsEnumeratedType(var_type): |
a387f258814a
Disabling location definition for enumerated and structure variables
laurent
parents:
544
diff
changeset
|
230 |
editor = wx.grid.GridCellChoiceEditor() |
a387f258814a
Disabling location definition for enumerated and structure variables
laurent
parents:
544
diff
changeset
|
231 |
editor.SetParameters(",".join(self.Parent.Controler.GetEnumeratedDataValues(var_type))) |
a387f258814a
Disabling location definition for enumerated and structure variables
laurent
parents:
544
diff
changeset
|
232 |
else: |
a387f258814a
Disabling location definition for enumerated and structure variables
laurent
parents:
544
diff
changeset
|
233 |
editor = wx.grid.GridCellTextEditor() |
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
234 |
renderer = wx.grid.GridCellStringRenderer() |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
235 |
else: |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
236 |
grid.SetReadOnly(row, col, True) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
237 |
elif colname == "Location": |
552
a387f258814a
Disabling location definition for enumerated and structure variables
laurent
parents:
544
diff
changeset
|
238 |
if var_class in ["Local", "Global"] and self.Parent.Controler.IsLocatableType(var_type): |
436
f3bb091f803f
Fix BrowseVariableDialog to be used in PLCOpenEditor without Beremiz plugins
laurent
parents:
431
diff
changeset
|
239 |
editor = LocationCellEditor(self, self.Parent.Controler) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
240 |
renderer = wx.grid.GridCellStringRenderer() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
241 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
242 |
grid.SetReadOnly(row, col, True) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
243 |
elif colname == "Class": |
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
244 |
if len(self.Parent.ClassList) == 1 or self.Parent.PouIsUsed and var_class in ["Input", "Output", "InOut"]: |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
245 |
grid.SetReadOnly(row, col, True) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
246 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
247 |
editor = wx.grid.GridCellChoiceEditor() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
248 |
excluded = [] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
249 |
if self.Parent.PouIsUsed: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
250 |
excluded.extend(["Input","Output","InOut"]) |
552
a387f258814a
Disabling location definition for enumerated and structure variables
laurent
parents:
544
diff
changeset
|
251 |
if self.Parent.IsFunctionBlockType(var_type): |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
252 |
excluded.extend(["Local","Temp"]) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
253 |
editor.SetParameters(",".join([_(choice) for choice in self.Parent.ClassList if choice not in excluded])) |
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
254 |
elif colname != "Documentation": |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
255 |
grid.SetReadOnly(row, col, True) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
256 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
257 |
grid.SetCellEditor(row, col, editor) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
258 |
grid.SetCellRenderer(row, col, renderer) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
259 |
|
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
260 |
highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1] |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
261 |
grid.SetCellBackgroundColour(row, col, highlight_colours[0]) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
262 |
grid.SetCellTextColour(row, col, highlight_colours[1]) |
509
6f72513bc074
Bug on variable panel row size in grid preventing readability of value inside cell editors fixed
laurent
parents:
507
diff
changeset
|
263 |
if wx.Platform == '__WXMSW__': |
6f72513bc074
Bug on variable panel row size in grid preventing readability of value inside cell editors fixed
laurent
parents:
507
diff
changeset
|
264 |
grid.SetRowMinimalHeight(row, 20) |
6f72513bc074
Bug on variable panel row size in grid preventing readability of value inside cell editors fixed
laurent
parents:
507
diff
changeset
|
265 |
else: |
6f72513bc074
Bug on variable panel row size in grid preventing readability of value inside cell editors fixed
laurent
parents:
507
diff
changeset
|
266 |
grid.SetRowMinimalHeight(row, 28) |
6f72513bc074
Bug on variable panel row size in grid preventing readability of value inside cell editors fixed
laurent
parents:
507
diff
changeset
|
267 |
grid.AutoSizeRow(row, False) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
268 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
269 |
def SetData(self, data): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
270 |
self.data = data |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
271 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
272 |
def GetData(self): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
273 |
return self.data |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
274 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
275 |
def GetCurrentIndex(self): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
276 |
return self.CurrentIndex |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
277 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
278 |
def SetCurrentIndex(self, index): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
279 |
self.CurrentIndex = index |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
280 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
281 |
def AppendRow(self, row_content): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
282 |
self.data.append(row_content) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
283 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
284 |
def RemoveRow(self, row_index): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
285 |
self.data.pop(row_index) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
286 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
287 |
def GetRow(self, row_index): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
288 |
return self.data[row_index] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
289 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
290 |
def Empty(self): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
291 |
self.data = [] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
292 |
self.editors = [] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
293 |
|
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
294 |
def AddHighlight(self, infos, highlight_type): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
295 |
row_highlights = self.Highlights.setdefault(infos[0], {}) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
296 |
col_highlights = row_highlights.setdefault(infos[1], []) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
297 |
col_highlights.append(highlight_type) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
298 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
299 |
def ClearHighlights(self, highlight_type=None): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
300 |
if highlight_type is None: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
301 |
self.Highlights = {} |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
302 |
else: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
303 |
for row, row_highlights in self.Highlights.iteritems(): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
304 |
row_items = row_highlights.items() |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
305 |
for col, col_highlights in row_items: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
306 |
if highlight_type in col_highlights: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
307 |
col_highlights.remove(highlight_type) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
308 |
if len(col_highlights) == 0: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
309 |
row_highlights.pop(col) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
310 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
311 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
312 |
class VariableDropTarget(wx.TextDropTarget): |
419
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
313 |
''' |
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
314 |
This allows dragging a variable location from somewhere to the Location |
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
315 |
column of a variable row. |
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
316 |
|
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
317 |
The drag source should be a TextDataObject containing a Python tuple like: |
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
318 |
('%ID0.0.0', 'location', 'REAL') |
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
319 |
|
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
320 |
c_ext/CFileEditor.py has an example of this (you can drag a C extension |
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
321 |
variable to the Location column of the variable panel). |
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
322 |
''' |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
323 |
def __init__(self, parent): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
324 |
wx.TextDropTarget.__init__(self) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
325 |
self.ParentWindow = parent |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
326 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
327 |
def OnDropText(self, x, y, data): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
328 |
x, y = self.ParentWindow.VariablesGrid.CalcUnscrolledPosition(x, y) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
329 |
col = self.ParentWindow.VariablesGrid.XToCol(x) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
330 |
row = self.ParentWindow.VariablesGrid.YToRow(y - self.ParentWindow.VariablesGrid.GetColLabelSize()) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
331 |
if col != wx.NOT_FOUND and row != wx.NOT_FOUND: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
332 |
if self.ParentWindow.Table.GetColLabelValue(col, False) != "Location": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
333 |
return |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
334 |
message = None |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
335 |
if not self.ParentWindow.Table.GetValueByName(row, "Edit"): |
427 | 336 |
message = _("Can't give a location to a function block instance") |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
337 |
elif self.ParentWindow.Table.GetValueByName(row, "Class") not in ["Local", "Global"]: |
427 | 338 |
message = _("Can only give a location to local or global variables") |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
339 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
340 |
try: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
341 |
values = eval(data) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
342 |
except: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
343 |
message = _("Invalid value \"%s\" for location")%data |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
344 |
values = None |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
345 |
if not isinstance(values, TupleType): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
346 |
message = _("Invalid value \"%s\" for location")%data |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
347 |
values = None |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
348 |
if values is not None and values[1] == "location": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
349 |
location = values[0] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
350 |
variable_type = self.ParentWindow.Table.GetValueByName(row, "Type") |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
351 |
base_type = self.ParentWindow.Controler.GetBaseType(variable_type) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
352 |
message = None |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
353 |
if location.startswith("%"): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
354 |
if base_type != values[2]: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
355 |
message = _("Incompatible data types between \"%s\" and \"%s\"")%(values[2], variable_type) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
356 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
357 |
self.ParentWindow.Table.SetValue(row, col, location) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
358 |
self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
359 |
self.ParentWindow.SaveValues() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
360 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
361 |
if location[0].isdigit() and base_type != "BOOL": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
362 |
message = _("Incompatible size of data between \"%s\" and \"BOOL\"")%location |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
363 |
elif location[0] not in LOCATIONDATATYPES: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
364 |
message = _("Unrecognized data size \"%s\"")%location[0] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
365 |
elif base_type not in LOCATIONDATATYPES[location[0]]: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
366 |
message = _("Incompatible size of data between \"%s\" and \"%s\"")%(location, variable_type) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
367 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
368 |
dialog = wx.SingleChoiceDialog(self.ParentWindow, _("Select a variable class:"), _("Variable class"), ["Input", "Output", "Memory"], wx.OK|wx.CANCEL) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
369 |
if dialog.ShowModal() == wx.ID_OK: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
370 |
selected = dialog.GetSelection() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
371 |
if selected == 0: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
372 |
location = "%I" + location |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
373 |
elif selected == 1: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
374 |
location = "%Q" + location |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
375 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
376 |
location = "%M" + location |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
377 |
self.ParentWindow.Table.SetValue(row, col, location) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
378 |
self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
379 |
self.ParentWindow.SaveValues() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
380 |
dialog.Destroy() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
381 |
if message is not None: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
382 |
wx.CallAfter(self.ShowMessage, message) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
383 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
384 |
def ShowMessage(self, message): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
385 |
message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
386 |
message.ShowModal() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
387 |
message.Destroy() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
388 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
389 |
[ID_VARIABLEEDITORPANEL, ID_VARIABLEEDITORPANELVARIABLESGRID, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
390 |
ID_VARIABLEEDITORCONTROLPANEL, ID_VARIABLEEDITORPANELRETURNTYPE, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
391 |
ID_VARIABLEEDITORPANELCLASSFILTER, ID_VARIABLEEDITORPANELADDBUTTON, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
392 |
ID_VARIABLEEDITORPANELDELETEBUTTON, ID_VARIABLEEDITORPANELUPBUTTON, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
393 |
ID_VARIABLEEDITORPANELDOWNBUTTON, ID_VARIABLEEDITORPANELSTATICTEXT1, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
394 |
ID_VARIABLEEDITORPANELSTATICTEXT2, ID_VARIABLEEDITORPANELSTATICTEXT3, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
395 |
] = [wx.NewId() for _init_ctrls in range(12)] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
396 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
397 |
class VariablePanel(wx.Panel): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
398 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
399 |
if wx.VERSION < (2, 6, 0): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
400 |
def Bind(self, event, function, id = None): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
401 |
if id is not None: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
402 |
event(self, id, function) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
403 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
404 |
event(self, function) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
405 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
406 |
def _init_coll_MainSizer_Items(self, parent): |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
407 |
parent.AddWindow(self.ControlPanel, 0, border=5, flag=wx.GROW|wx.ALL) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
408 |
parent.AddWindow(self.VariablesGrid, 0, border=0, flag=wx.GROW) |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
409 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
410 |
def _init_coll_MainSizer_Growables(self, parent): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
411 |
parent.AddGrowableCol(0) |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
412 |
parent.AddGrowableRow(1) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
413 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
414 |
def _init_coll_ControlPanelSizer_Items(self, parent): |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
415 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) |
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
416 |
parent.AddWindow(self.ReturnType, 0, border=0, flag=0) |
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
417 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) |
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
418 |
parent.AddWindow(self.ClassFilter, 0, border=0, flag=0) |
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
419 |
parent.AddWindow(self.AddButton, 0, border=0, flag=0) |
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
420 |
parent.AddWindow(self.DeleteButton, 0, border=0, flag=0) |
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
421 |
parent.AddWindow(self.UpButton, 0, border=0, flag=0) |
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
422 |
parent.AddWindow(self.DownButton, 0, border=0, flag=0) |
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
423 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
424 |
def _init_coll_ControlPanelSizer_Growables(self, parent): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
425 |
parent.AddGrowableCol(3) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
426 |
parent.AddGrowableRow(0) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
427 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
428 |
def _init_sizers(self): |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
429 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=0) |
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
430 |
self.ControlPanelSizer = wx.FlexGridSizer(cols=8, hgap=5, rows=1, vgap=5) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
431 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
432 |
self._init_coll_MainSizer_Items(self.MainSizer) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
433 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
434 |
self._init_coll_ControlPanelSizer_Items(self.ControlPanelSizer) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
435 |
self._init_coll_ControlPanelSizer_Growables(self.ControlPanelSizer) |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
436 |
|
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
437 |
self.ControlPanel.SetSizer(self.ControlPanelSizer) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
438 |
self.SetSizer(self.MainSizer) |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
439 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
440 |
def _init_ctrls(self, prnt): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
441 |
wx.Panel.__init__(self, id=ID_VARIABLEEDITORPANEL, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
442 |
name='VariableEditorPanel', parent=prnt, pos=wx.Point(0, 0), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
443 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
444 |
|
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
445 |
self.VariablesGrid = CustomGrid(id=ID_VARIABLEEDITORPANELVARIABLESGRID, |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
446 |
name='VariablesGrid', parent=self, pos=wx.Point(0, 0), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
447 |
size=wx.Size(0, 0), style=wx.VSCROLL) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
448 |
self.VariablesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
449 |
'Sans')) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
450 |
self.VariablesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
451 |
False, 'Sans')) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
452 |
self.VariablesGrid.SetSelectionBackground(wx.WHITE) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
453 |
self.VariablesGrid.SetSelectionForeground(wx.BLACK) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
454 |
if wx.VERSION >= (2, 6, 0): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
455 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnVariablesGridCellChange) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
456 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnVariablesGridCellLeftClick) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
457 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnVariablesGridEditorShown) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
458 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
459 |
wx.grid.EVT_GRID_CELL_CHANGE(self.VariablesGrid, self.OnVariablesGridCellChange) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
460 |
wx.grid.EVT_GRID_CELL_LEFT_CLICK(self.VariablesGrid, self.OnVariablesGridCellLeftClick) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
461 |
wx.grid.EVT_GRID_EDITOR_SHOWN(self.VariablesGrid, self.OnVariablesGridEditorShown) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
462 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
463 |
self.ControlPanel = wx.ScrolledWindow(id=ID_VARIABLEEDITORCONTROLPANEL, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
464 |
name='ControlPanel', parent=self, pos=wx.Point(0, 0), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
465 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
466 |
self.ControlPanel.SetScrollRate(10, 0) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
467 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
468 |
self.staticText1 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT1, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
469 |
label=_('Return Type:'), name='staticText1', parent=self.ControlPanel, |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
470 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
471 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
472 |
self.ReturnType = wx.ComboBox(id=ID_VARIABLEEDITORPANELRETURNTYPE, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
473 |
name='ReturnType', parent=self.ControlPanel, pos=wx.Point(0, 0), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
474 |
size=wx.Size(145, 28), style=wx.CB_READONLY) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
475 |
self.Bind(wx.EVT_COMBOBOX, self.OnReturnTypeChanged, id=ID_VARIABLEEDITORPANELRETURNTYPE) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
476 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
477 |
self.staticText2 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT2, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
478 |
label=_('Class Filter:'), name='staticText2', parent=self.ControlPanel, |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
479 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
480 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
481 |
self.ClassFilter = wx.ComboBox(id=ID_VARIABLEEDITORPANELCLASSFILTER, |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
482 |
name='ClassFilter', parent=self.ControlPanel, pos=wx.Point(0, 0), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
483 |
size=wx.Size(145, 28), style=wx.CB_READONLY) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
484 |
self.Bind(wx.EVT_COMBOBOX, self.OnClassFilter, id=ID_VARIABLEEDITORPANELCLASSFILTER) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
485 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
486 |
self.AddButton = wx.Button(id=ID_VARIABLEEDITORPANELADDBUTTON, label=_('Add'), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
487 |
name='AddButton', parent=self.ControlPanel, pos=wx.Point(0, 0), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
488 |
size=wx.DefaultSize, style=0) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
489 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
490 |
self.DeleteButton = wx.Button(id=ID_VARIABLEEDITORPANELDELETEBUTTON, label=_('Delete'), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
491 |
name='DeleteButton', parent=self.ControlPanel, pos=wx.Point(0, 0), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
492 |
size=wx.DefaultSize, style=0) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
493 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
494 |
self.UpButton = wx.Button(id=ID_VARIABLEEDITORPANELUPBUTTON, label='^', |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
495 |
name='UpButton', parent=self.ControlPanel, pos=wx.Point(0, 0), |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
496 |
size=wx.Size(28, 28), style=0) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
497 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
498 |
self.DownButton = wx.Button(id=ID_VARIABLEEDITORPANELDOWNBUTTON, label='v', |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
499 |
name='DownButton', parent=self.ControlPanel, pos=wx.Point(0, 0), |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
500 |
size=wx.Size(28, 28), style=0) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
501 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
502 |
self._init_sizers() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
503 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
504 |
def __init__(self, parent, window, controler, element_type): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
505 |
self._init_ctrls(parent) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
506 |
self.ParentWindow = window |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
507 |
self.Controler = controler |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
508 |
self.ElementType = element_type |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
509 |
|
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
510 |
self.RefreshHighlightsTimer = wx.Timer(self, -1) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
511 |
self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, self.RefreshHighlightsTimer) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
512 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
513 |
self.Filter = "All" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
514 |
self.FilterChoices = [] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
515 |
self.FilterChoiceTransfer = GetFilterChoiceTransfer() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
516 |
|
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
517 |
self.DefaultValue = { "Name" : "", "Class" : "", "Type" : "INT", "Location" : "", |
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
518 |
"Initial Value" : "", "Option" : "", |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
519 |
"Documentation" : "", "Edit" : True |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
520 |
} |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
521 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
522 |
if element_type in ["config", "resource"]: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
523 |
self.DefaultTypes = {"All" : "Global"} |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
524 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
525 |
self.DefaultTypes = {"All" : "Local", "Interface" : "Input", "Variables" : "Local"} |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
526 |
|
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
527 |
if element_type in ["config", "resource"] \ |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
528 |
or element_type in ["program", "transition", "action"]: |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
529 |
# this is an element that can have located variables |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
530 |
self.Table = VariableTable(self, [], GetVariableTableColnames(True)) |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
531 |
|
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
532 |
if element_type in ["config", "resource"]: |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
533 |
self.FilterChoices = ["All", "Global"]#,"Access"] |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
534 |
else: |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
535 |
self.FilterChoices = ["All", |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
536 |
"Interface", " Input", " Output", " InOut", " External", |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
537 |
"Variables", " Local", " Temp"]#,"Access"] |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
538 |
|
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
539 |
# these condense the ColAlignements list |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
540 |
l = wx.ALIGN_LEFT |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
541 |
c = wx.ALIGN_CENTER |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
542 |
|
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
543 |
# Num Name Class Type Loc Init Option Doc |
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
544 |
self.ColSizes = [40, 80, 70, 80, 80, 80, 100, 80] |
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
545 |
self.ColAlignements = [c, l, l, l, l, l, l, l] |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
546 |
|
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
547 |
else: |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
548 |
# this is an element that cannot have located variables |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
549 |
self.Table = VariableTable(self, [], GetVariableTableColnames(False)) |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
550 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
551 |
if element_type == "function": |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
552 |
self.FilterChoices = ["All", |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
553 |
"Interface", " Input", " Output", " InOut", |
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
554 |
"Variables", " Local"] |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
555 |
else: |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
556 |
self.FilterChoices = ["All", |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
557 |
"Interface", " Input", " Output", " InOut", " External", |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
558 |
"Variables", " Local", " Temp"] |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
559 |
|
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
560 |
# these condense the ColAlignements list |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
561 |
l = wx.ALIGN_LEFT |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
562 |
c = wx.ALIGN_CENTER |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
563 |
|
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
564 |
# Num Name Class Type Init Option Doc |
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
565 |
self.ColSizes = [40, 80, 70, 80, 80, 100, 160] |
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
566 |
self.ColAlignements = [c, l, l, l, l, l, l] |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
567 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
568 |
for choice in self.FilterChoices: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
569 |
self.ClassFilter.Append(_(choice)) |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
570 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
571 |
reverse_transfer = {} |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
572 |
for filter, choice in self.FilterChoiceTransfer.items(): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
573 |
reverse_transfer[choice] = filter |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
574 |
self.ClassFilter.SetStringSelection(_(reverse_transfer[self.Filter])) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
575 |
self.RefreshTypeList() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
576 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
577 |
self.VariablesGrid.SetTable(self.Table) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
578 |
self.VariablesGrid.SetButtons({"Add": self.AddButton, |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
579 |
"Delete": self.DeleteButton, |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
580 |
"Up": self.UpButton, |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
581 |
"Down": self.DownButton}) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
582 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
583 |
def _AddVariable(new_row): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
584 |
if not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"]: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
585 |
row_content = self.DefaultValue.copy() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
586 |
if self.Filter in self.DefaultTypes: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
587 |
row_content["Class"] = self.DefaultTypes[self.Filter] |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
588 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
589 |
row_content["Class"] = self.Filter |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
590 |
if self.Filter == "All" and len(self.Values) > 0: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
591 |
self.Values.insert(new_row, row_content) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
592 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
593 |
self.Values.append(row_content) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
594 |
new_row = self.Table.GetNumberRows() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
595 |
self.SaveValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
596 |
self.RefreshValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
597 |
return new_row |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
598 |
return self.VariablesGrid.GetGridCursorRow() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
599 |
setattr(self.VariablesGrid, "_AddRow", _AddVariable) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
600 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
601 |
def _DeleteVariable(row): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
602 |
if (self.Table.GetValueByName(row, "Edit") and |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
603 |
(not self.PouIsUsed or self.Table.GetValueByName(row, "Class") not in ["Input", "Output", "InOut"])): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
604 |
self.Values.remove(self.Table.GetRow(row)) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
605 |
self.SaveValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
606 |
self.RefreshValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
607 |
setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
608 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
609 |
def _MoveVariable(row, move): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
610 |
if (self.Filter == "All" and |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
611 |
(not self.PouIsUsed or self.Table.GetValueByName(row, "Class") not in ["Input", "Output", "InOut"])): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
612 |
new_row = max(0, min(row + move, len(self.Values) - 1)) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
613 |
if new_row != row: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
614 |
self.Values.insert(new_row, self.Values.pop(row)) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
615 |
self.SaveValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
616 |
self.RefreshValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
617 |
return new_row |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
618 |
return row |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
619 |
setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
620 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
621 |
def _RefreshButtons(): |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
622 |
table_length = len(self.Table.data) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
623 |
row_class = None |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
624 |
row_edit = True |
496 | 625 |
row = 0 |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
626 |
if table_length > 0: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
627 |
row = self.VariablesGrid.GetGridCursorRow() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
628 |
row_edit = self.Table.GetValueByName(row, "Edit") |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
629 |
if self.PouIsUsed: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
630 |
row_class = self.Table.GetValueByName(row, "Class") |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
631 |
self.AddButton.Enable(not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"]) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
632 |
self.DeleteButton.Enable(table_length > 0 and row_edit and row_class not in ["Input", "Output", "InOut"]) |
496 | 633 |
self.UpButton.Enable(table_length > 0 and row > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"]) |
634 |
self.DownButton.Enable(table_length > 0 and row < table_length - 1 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"]) |
|
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
635 |
setattr(self.VariablesGrid, "RefreshButtons", _RefreshButtons) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
636 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
637 |
self.VariablesGrid.SetRowLabelSize(0) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
638 |
for col in range(self.Table.GetNumberCols()): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
639 |
attr = wx.grid.GridCellAttr() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
640 |
attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
641 |
self.VariablesGrid.SetColAttr(col, attr) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
642 |
self.VariablesGrid.SetColMinimalWidth(col, self.ColSizes[col]) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
643 |
self.VariablesGrid.AutoSizeColumn(col, False) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
644 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
645 |
def __del__(self): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
646 |
self.RefreshHighlightsTimer.Stop() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
647 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
648 |
def SetTagName(self, tagname): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
649 |
self.TagName = tagname |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
650 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
651 |
def IsFunctionBlockType(self, name): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
652 |
bodytype = self.Controler.GetEditedElementBodyType(self.TagName) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
653 |
pouname, poutype = self.Controler.GetEditedElementType(self.TagName) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
654 |
if poutype != "function" and bodytype in ["ST", "IL"]: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
655 |
return False |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
656 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
657 |
return name in self.Controler.GetFunctionBlockTypes(self.TagName) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
658 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
659 |
def RefreshView(self): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
660 |
self.PouNames = self.Controler.GetProjectPouNames() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
661 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
662 |
words = self.TagName.split("::") |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
663 |
if self.ElementType == "config": |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
664 |
self.PouIsUsed = False |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
665 |
returnType = None |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
666 |
self.Values = self.Controler.GetConfigurationGlobalVars(words[1]) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
667 |
elif self.ElementType == "resource": |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
668 |
self.PouIsUsed = False |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
669 |
returnType = None |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
670 |
self.Values = self.Controler.GetConfigurationResourceGlobalVars(words[1], words[2]) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
671 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
672 |
if self.ElementType == "function": |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
673 |
self.ReturnType.Clear() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
674 |
for base_type in self.Controler.GetDataTypes(self.TagName, True): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
675 |
self.ReturnType.Append(base_type) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
676 |
returnType = self.Controler.GetEditedElementInterfaceReturnType(self.TagName) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
677 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
678 |
returnType = None |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
679 |
self.PouIsUsed = self.Controler.PouIsUsed(words[1]) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
680 |
self.Values = self.Controler.GetEditedElementInterfaceVars(self.TagName) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
681 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
682 |
if returnType is not None: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
683 |
self.ReturnType.SetStringSelection(returnType) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
684 |
self.ReturnType.Enable(True) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
685 |
self.staticText1.Show() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
686 |
self.ReturnType.Show() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
687 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
688 |
self.ReturnType.Enable(False) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
689 |
self.staticText1.Hide() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
690 |
self.ReturnType.Hide() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
691 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
692 |
self.RefreshValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
693 |
self.VariablesGrid.RefreshButtons() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
694 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
695 |
def OnReturnTypeChanged(self, event): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
696 |
words = self.TagName.split("::") |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
697 |
self.Controler.SetPouInterfaceReturnType(words[1], self.ReturnType.GetStringSelection()) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
698 |
self.Controler.BufferProject() |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
699 |
self.ParentWindow.RefreshView(variablepanel = False) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
700 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, INSTANCESTREE, LIBRARYTREE) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
701 |
event.Skip() |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
702 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
703 |
def OnClassFilter(self, event): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
704 |
self.Filter = self.FilterChoiceTransfer[VARIABLE_CHOICES_DICT[self.ClassFilter.GetStringSelection()]] |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
705 |
self.RefreshTypeList() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
706 |
self.RefreshValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
707 |
self.VariablesGrid.RefreshButtons() |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
708 |
event.Skip() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
709 |
|
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
710 |
def RefreshTypeList(self): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
711 |
if self.Filter == "All": |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
712 |
self.ClassList = [self.FilterChoiceTransfer[choice] for choice in self.FilterChoices if self.FilterChoiceTransfer[choice] not in ["All","Interface","Variables"]] |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
713 |
elif self.Filter == "Interface": |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
714 |
self.ClassList = ["Input","Output","InOut","External"] |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
715 |
elif self.Filter == "Variables": |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
716 |
self.ClassList = ["Local","Temp"] |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
717 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
718 |
self.ClassList = [self.Filter] |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
719 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
720 |
def OnVariablesGridCellChange(self, event): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
721 |
row, col = event.GetRow(), event.GetCol() |
431
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
722 |
colname = self.Table.GetColLabelValue(col, False) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
723 |
value = self.Table.GetValue(row, col) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
724 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
725 |
if colname == "Name" and value != "": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
726 |
if not TestIdentifier(value): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
727 |
message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%value, _("Error"), wx.OK|wx.ICON_ERROR) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
728 |
message.ShowModal() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
729 |
message.Destroy() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
730 |
event.Veto() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
731 |
elif value.upper() in IEC_KEYWORDS: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
732 |
message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%value, _("Error"), wx.OK|wx.ICON_ERROR) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
733 |
message.ShowModal() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
734 |
message.Destroy() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
735 |
event.Veto() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
736 |
elif value.upper() in self.PouNames: |
446 | 737 |
message = wx.MessageDialog(self, _("A POU named \"%s\" already exists!")%value, _("Error"), wx.OK|wx.ICON_ERROR) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
738 |
message.ShowModal() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
739 |
message.Destroy() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
740 |
event.Veto() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
741 |
elif value.upper() in [var["Name"].upper() for var in self.Values if var != self.Table.data[row]]: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
742 |
message = wx.MessageDialog(self, _("A variable with \"%s\" as name already exists in this pou!")%value, _("Error"), wx.OK|wx.ICON_ERROR) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
743 |
message.ShowModal() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
744 |
message.Destroy() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
745 |
event.Veto() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
746 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
747 |
self.SaveValues(False) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
748 |
old_value = self.Table.GetOldValue() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
749 |
if old_value != "": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
750 |
self.Controler.UpdateEditedElementUsedVariable(self.TagName, old_value, value) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
751 |
self.Controler.BufferProject() |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
752 |
self.ParentWindow.RefreshView(variablepanel = False) |
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
753 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, INSTANCESTREE, LIBRARYTREE) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
754 |
event.Skip() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
755 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
756 |
self.SaveValues() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
757 |
if colname == "Class": |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
758 |
self.ParentWindow.RefreshView(variablepanel = False) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
759 |
event.Skip() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
760 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
761 |
def OnVariablesGridEditorShown(self, event): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
762 |
row, col = event.GetRow(), event.GetCol() |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
763 |
|
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
764 |
label_value = self.Table.GetColLabelValue(col) |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
765 |
if label_value == "Type": |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
766 |
type_menu = wx.Menu(title='') # the root menu |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
767 |
|
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
768 |
# build a submenu containing standard IEC types |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
769 |
base_menu = wx.Menu(title='') |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
770 |
for base_type in self.Controler.GetBaseTypes(): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
771 |
new_id = wx.NewId() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
772 |
AppendMenu(base_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
773 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
774 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
775 |
type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
776 |
|
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
777 |
# build a submenu containing user-defined types |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
778 |
datatype_menu = wx.Menu(title='') |
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
779 |
|
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
780 |
# TODO : remove complextypes argument when matiec can manage complex types in pou interface |
491
d22a4a95fd5e
Remove limitation on complex types in POU interface
laurent
parents:
484
diff
changeset
|
781 |
datatypes = self.Controler.GetDataTypes(basetypes = False) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
782 |
for datatype in datatypes: |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
783 |
new_id = wx.NewId() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
784 |
AppendMenu(datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
785 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
786 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
787 |
type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
788 |
|
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
789 |
# build a submenu containing function block types |
431
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
790 |
bodytype = self.Controler.GetEditedElementBodyType(self.TagName) |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
791 |
pouname, poutype = self.Controler.GetEditedElementType(self.TagName) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
792 |
classtype = self.Table.GetValueByName(row, "Class") |
507
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
793 |
|
556
69214983dd03
Enabling support for direct array variable declaration
laurent
parents:
552
diff
changeset
|
794 |
new_id = wx.NewId() |
69214983dd03
Enabling support for direct array variable declaration
laurent
parents:
552
diff
changeset
|
795 |
AppendMenu(type_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Array")) |
69214983dd03
Enabling support for direct array variable declaration
laurent
parents:
552
diff
changeset
|
796 |
self.Bind(wx.EVT_MENU, self.VariableArrayTypeFunction, id=new_id) |
507
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
797 |
|
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
798 |
if classtype in ["Input", "Output", "InOut", "External", "Global"] or \ |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
799 |
poutype != "function" and bodytype in ["ST", "IL"]: |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
800 |
functionblock_menu = wx.Menu(title='') |
431
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
801 |
fbtypes = self.Controler.GetFunctionBlockTypes(self.TagName) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
802 |
for functionblock_type in fbtypes: |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
803 |
new_id = wx.NewId() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
804 |
AppendMenu(functionblock_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=functionblock_type) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
805 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), id=new_id) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
806 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
807 |
type_menu.AppendMenu(wx.NewId(), _("Function Block Types"), functionblock_menu) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
808 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
809 |
rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col)) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
810 |
corner_x = rect.x + rect.width |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
811 |
corner_y = rect.y + self.VariablesGrid.GetColLabelSize() |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
812 |
|
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
813 |
# pop up this new menu |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
814 |
self.VariablesGrid.PopupMenuXY(type_menu, corner_x, corner_y) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
815 |
event.Veto() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
816 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
817 |
event.Skip() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
818 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
819 |
def GetVariableTypeFunction(self, base_type): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
820 |
def VariableTypeFunction(event): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
821 |
row = self.VariablesGrid.GetGridCursorRow() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
822 |
self.Table.SetValueByName(row, "Type", base_type) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
823 |
self.Table.ResetView(self.VariablesGrid) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
824 |
self.SaveValues(False) |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
825 |
self.ParentWindow.RefreshView(variablepanel = False) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
826 |
self.Controler.BufferProject() |
494
c91644c2bfa7
Bug on FileMenu not refreshed when modifications fixed
laurent
parents:
491
diff
changeset
|
827 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, INSTANCESTREE, LIBRARYTREE) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
828 |
return VariableTypeFunction |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
829 |
|
507
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
830 |
def VariableArrayTypeFunction(self, event): |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
831 |
row = self.VariablesGrid.GetGridCursorRow() |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
832 |
dialog = ArrayTypeDialog(self, |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
833 |
self.Controler.GetDataTypes(self.TagName), |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
834 |
self.Table.GetValueByName(row, "Type")) |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
835 |
if dialog.ShowModal() == 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:
496
diff
changeset
|
836 |
self.Table.SetValueByName(row, "Type", dialog.GetValue()) |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
837 |
self.Table.ResetView(self.VariablesGrid) |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
838 |
self.SaveValues(False) |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
839 |
self.ParentWindow.RefreshView(variablepanel = False) |
507
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
840 |
self.Controler.BufferProject() |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
841 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, INSTANCESTREE, LIBRARYTREE) |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
842 |
dialog.Destroy() |
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
496
diff
changeset
|
843 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
844 |
def OnVariablesGridCellLeftClick(self, event): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
845 |
row = event.GetRow() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
846 |
if event.GetCol() == 0 and self.Table.GetValueByName(row, "Edit"): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
847 |
row = event.GetRow() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
848 |
var_name = self.Table.GetValueByName(row, "Name") |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
849 |
var_class = self.Table.GetValueByName(row, "Class") |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
850 |
var_type = self.Table.GetValueByName(row, "Type") |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
851 |
data = wx.TextDataObject(str((var_name, var_class, var_type, self.TagName))) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
852 |
dragSource = wx.DropSource(self.VariablesGrid) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
853 |
dragSource.SetData(data) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
854 |
dragSource.DoDragDrop() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
855 |
event.Skip() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
856 |
|
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
857 |
def RefreshValues(self): |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
858 |
data = [] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
859 |
for num, variable in enumerate(self.Values): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
860 |
if variable["Class"] in self.ClassList: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
861 |
variable["Number"] = num + 1 |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
862 |
data.append(variable) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
863 |
self.Table.SetData(data) |
561
5c8fa95eb834
Fixing bug in Variable Panel when pressing Add,Delete,Up or Down button while a cell editor in variable grid is active
laurent
parents:
556
diff
changeset
|
864 |
self.Table.ResetView(self.VariablesGrid) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
865 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
866 |
def SaveValues(self, buffer = True): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
867 |
words = self.TagName.split("::") |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
868 |
if self.ElementType == "config": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
869 |
self.Controler.SetConfigurationGlobalVars(words[1], self.Values) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
870 |
elif self.ElementType == "resource": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
871 |
self.Controler.SetConfigurationResourceGlobalVars(words[1], words[2], self.Values) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
872 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
873 |
if self.ReturnType.IsEnabled(): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
874 |
self.Controler.SetPouInterfaceReturnType(words[1], self.ReturnType.GetStringSelection()) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
875 |
self.Controler.SetPouInterfaceVars(words[1], self.Values) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
876 |
if buffer: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
877 |
self.Controler.BufferProject() |
494
c91644c2bfa7
Bug on FileMenu not refreshed when modifications fixed
laurent
parents:
491
diff
changeset
|
878 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, INSTANCESTREE, LIBRARYTREE) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
879 |
|
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
880 |
#------------------------------------------------------------------------------- |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
881 |
# Highlights showing functions |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
882 |
#------------------------------------------------------------------------------- |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
883 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
884 |
def OnRefreshHighlightsTimer(self, event): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
885 |
self.Table.ResetView(self.VariablesGrid) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
886 |
event.Skip() |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
887 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
888 |
def AddVariableHighlight(self, infos, highlight_type): |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
889 |
if isinstance(infos[0], TupleType): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
890 |
for i in xrange(*infos[0]): |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
891 |
self.Table.AddHighlight((i,) + infos[1:], highlight_type) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
892 |
else: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
893 |
self.Table.AddHighlight(infos, highlight_type) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
894 |
self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
895 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
896 |
def ClearHighlights(self, highlight_type=None): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
897 |
self.Table.ClearHighlights(highlight_type) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
898 |
self.Table.ResetView(self.VariablesGrid) |