author | Laurent Bessard |
Wed, 01 Aug 2012 12:44:06 +0200 | |
changeset 736 | eb6b13d87bfc |
parent 731 | 4e30c1c0922d |
child 738 | 1ccd08cfae0c |
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 |
623
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
26 |
import re |
580 | 27 |
from types import TupleType, StringType, UnicodeType |
419
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
28 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
29 |
import wx |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
30 |
import wx.grid |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
31 |
import wx.lib.buttons |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
32 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
33 |
from plcopen.structures import LOCATIONDATATYPES, TestIdentifier, IEC_KEYWORDS |
625
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
34 |
from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD, ERROR_HIGHLIGHT |
591
4d6719c51f05
Fixing bug that prevent to define a directly declared array type for a variable in VariablePanel
laurent
parents:
586
diff
changeset
|
35 |
from dialogs.ArrayTypeDialog import ArrayTypeDialog |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
36 |
from CustomGrid import CustomGrid |
604
5b42b4401e6b
Adding support for unifying grid table control elements
laurent
parents:
600
diff
changeset
|
37 |
from CustomTable import CustomTable |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
38 |
from LocationCellEditor import LocationCellEditor |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
39 |
from utils.BitmapLibrary import GetBitmap |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
40 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
41 |
#------------------------------------------------------------------------------- |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
42 |
# Helpers |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
43 |
#------------------------------------------------------------------------------- |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
44 |
|
431
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
45 |
def AppendMenu(parent, help, id, kind, text): |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
46 |
if wx.VERSION >= (2, 6, 0): |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
47 |
parent.Append(help=help, id=id, kind=kind, text=text) |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
48 |
else: |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
49 |
parent.Append(helpString=help, id=id, kind=kind, item=text) |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
50 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
51 |
[TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
52 |
POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
53 |
] = range(10) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
54 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
55 |
def GetVariableTableColnames(location): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
56 |
_ = lambda x : x |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
57 |
if location: |
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
58 |
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
|
59 |
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
|
60 |
|
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
61 |
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
|
62 |
_ = lambda x : x |
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
63 |
options = [""] |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
64 |
if constant: |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
65 |
options.append(_("Constant")) |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
66 |
if retain: |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
67 |
options.append(_("Retain")) |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
68 |
if non_retain: |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
69 |
options.append(_("Non-Retain")) |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
70 |
return options |
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
71 |
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
|
72 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
73 |
def GetFilterChoiceTransfer(): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
74 |
_ = lambda x : x |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
75 |
return {_("All"): _("All"), _("Interface"): _("Interface"), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
76 |
_(" Input"): _("Input"), _(" Output"): _("Output"), _(" InOut"): _("InOut"), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
77 |
_(" External"): _("External"), _("Variables"): _("Variables"), _(" Local"): _("Local"), |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
78 |
_(" 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
|
79 |
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
|
80 |
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
|
81 |
|
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
82 |
CheckOptionForClass = {"Local": lambda x: x, |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
83 |
"Temp": lambda x: "", |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
84 |
"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
|
85 |
"InOut": lambda x: "", |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
86 |
"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
|
87 |
"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
|
88 |
"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
|
89 |
} |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
90 |
|
625
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
91 |
LOCATION_MODEL = re.compile("((?:%[IQM](?:\*|(?:[XBWLD]?[0-9]+(?:\.[0-9]+)*)))?)$") |
623
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
92 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
93 |
#------------------------------------------------------------------------------- |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
94 |
# Variables Panel Table |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
95 |
#------------------------------------------------------------------------------- |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
96 |
|
604
5b42b4401e6b
Adding support for unifying grid table control elements
laurent
parents:
600
diff
changeset
|
97 |
class VariableTable(CustomTable): |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
98 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
99 |
""" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
100 |
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
|
101 |
""" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
102 |
def __init__(self, parent, data, colnames): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
103 |
# The base class must be initialized *first* |
604
5b42b4401e6b
Adding support for unifying grid table control elements
laurent
parents:
600
diff
changeset
|
104 |
CustomTable.__init__(self, parent, data, colnames) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
105 |
self.old_value = None |
604
5b42b4401e6b
Adding support for unifying grid table control elements
laurent
parents:
600
diff
changeset
|
106 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
107 |
def GetValue(self, row, col): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
108 |
if row < self.GetNumberRows(): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
109 |
if col == 0: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
110 |
return self.data[row]["Number"] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
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
|
115 |
return "ARRAY [%s] OF %s" % (",".join(map(lambda x : "..".join(x), value[2])), value[1]) |
580 | 116 |
if not isinstance(value, (StringType, UnicodeType)): |
117 |
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
|
118 |
if colname in ["Class", "Option"]: |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
119 |
return _(value) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
120 |
return value |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
121 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
122 |
def SetValue(self, row, col, value): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
123 |
if col < len(self.colnames): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
124 |
colname = self.GetColLabelValue(col, False) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
125 |
if colname == "Name": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
126 |
self.old_value = self.data[row][colname] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
127 |
elif colname == "Class": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
128 |
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
|
129 |
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
|
130 |
if value == "External": |
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
131 |
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
|
132 |
elif colname == "Option": |
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
133 |
value = OPTIONS_DICT[value] |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
134 |
self.data[row][colname] = 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 GetOldValue(self): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
137 |
return self.old_value |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
138 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
139 |
def _updateColAttrs(self, grid): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
140 |
""" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
141 |
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
|
142 |
appropriate renderer given the column name. |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
143 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
144 |
Otherwise default to the default renderer. |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
145 |
""" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
146 |
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
|
147 |
var_class = self.GetValueByName(row, "Class") |
552
a387f258814a
Disabling location definition for enumerated and structure variables
laurent
parents:
544
diff
changeset
|
148 |
var_type = self.GetValueByName(row, "Type") |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
149 |
row_highlights = self.Highlights.get(row, {}) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
150 |
for col in range(self.GetNumberCols()): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
151 |
editor = None |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
152 |
renderer = None |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
153 |
colname = self.GetColLabelValue(col, False) |
600
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
154 |
if self.Parent.Debug: |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
155 |
grid.SetReadOnly(row, col, True) |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
156 |
else: |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
157 |
if colname == "Option": |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
158 |
options = GetOptions(constant = var_class in ["Local", "External", "Global"], |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
159 |
retain = self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output", "Global"], |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
160 |
non_retain = self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output"]) |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
161 |
if len(options) > 1: |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
162 |
editor = wx.grid.GridCellChoiceEditor() |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
163 |
editor.SetParameters(",".join(map(_, options))) |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
164 |
else: |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
165 |
grid.SetReadOnly(row, col, True) |
600
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
166 |
elif col != 0 and self.GetValueByName(row, "Edit"): |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
167 |
grid.SetReadOnly(row, col, False) |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
168 |
if colname == "Name": |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
169 |
if self.Parent.PouIsUsed and var_class in ["Input", "Output", "InOut"]: |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
170 |
grid.SetReadOnly(row, col, True) |
552
a387f258814a
Disabling location definition for enumerated and structure variables
laurent
parents:
544
diff
changeset
|
171 |
else: |
a387f258814a
Disabling location definition for enumerated and structure variables
laurent
parents:
544
diff
changeset
|
172 |
editor = wx.grid.GridCellTextEditor() |
600
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
173 |
renderer = wx.grid.GridCellStringRenderer() |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
174 |
elif colname == "Initial Value": |
731
4e30c1c0922d
Disabling capability to define inout variable initial value according to IEC 61131-3 grammar
Laurent Bessard
parents:
720
diff
changeset
|
175 |
if var_class not in ["External", "InOut"]: |
600
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
176 |
if self.Parent.Controler.IsEnumeratedType(var_type): |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
177 |
editor = wx.grid.GridCellChoiceEditor() |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
178 |
editor.SetParameters(",".join(self.Parent.Controler.GetEnumeratedDataValues(var_type))) |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
179 |
else: |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
180 |
editor = wx.grid.GridCellTextEditor() |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
181 |
renderer = wx.grid.GridCellStringRenderer() |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
182 |
else: |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
183 |
grid.SetReadOnly(row, col, True) |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
184 |
elif colname == "Location": |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
185 |
if var_class in ["Local", "Global"] and self.Parent.Controler.IsLocatableType(var_type): |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
186 |
editor = LocationCellEditor(self, self.Parent.Controler) |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
187 |
renderer = wx.grid.GridCellStringRenderer() |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
188 |
else: |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
189 |
grid.SetReadOnly(row, col, True) |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
190 |
elif colname == "Class": |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
191 |
if len(self.Parent.ClassList) == 1 or self.Parent.PouIsUsed and var_class in ["Input", "Output", "InOut"]: |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
192 |
grid.SetReadOnly(row, col, True) |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
193 |
else: |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
194 |
editor = wx.grid.GridCellChoiceEditor() |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
195 |
excluded = [] |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
196 |
if self.Parent.PouIsUsed: |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
197 |
excluded.extend(["Input","Output","InOut"]) |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
198 |
if self.Parent.IsFunctionBlockType(var_type): |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
199 |
excluded.extend(["Local","Temp"]) |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
200 |
editor.SetParameters(",".join([_(choice) for choice in self.Parent.ClassList if choice not in excluded])) |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
201 |
elif colname != "Documentation": |
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
202 |
grid.SetReadOnly(row, col, True) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
203 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
204 |
grid.SetCellEditor(row, col, editor) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
205 |
grid.SetCellRenderer(row, col, renderer) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
206 |
|
625
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
207 |
if colname == "Location" and LOCATION_MODEL.match(self.GetValueByName(row, "Location")) is None: |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
208 |
highlight_colours = ERROR_HIGHLIGHT |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
209 |
else: |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
210 |
highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1] |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
211 |
grid.SetCellBackgroundColour(row, col, highlight_colours[0]) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
212 |
grid.SetCellTextColour(row, col, highlight_colours[1]) |
604
5b42b4401e6b
Adding support for unifying grid table control elements
laurent
parents:
600
diff
changeset
|
213 |
self.ResizeRow(grid, row) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
214 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
215 |
#------------------------------------------------------------------------------- |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
216 |
# Variable Panel Drop Target |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
217 |
#------------------------------------------------------------------------------- |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
218 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
219 |
class VariableDropTarget(wx.TextDropTarget): |
419
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
220 |
''' |
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
221 |
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
|
222 |
column of a variable row. |
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
223 |
|
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
224 |
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
|
225 |
('%ID0.0.0', 'location', 'REAL') |
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
226 |
|
8f97ed01a6a6
VariablePanel.py also depends on types.TupleType
b.taylor@willowglen.ca
parents:
418
diff
changeset
|
227 |
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
|
228 |
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
|
229 |
''' |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
230 |
def __init__(self, parent): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
231 |
wx.TextDropTarget.__init__(self) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
232 |
self.ParentWindow = parent |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
233 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
234 |
def OnDropText(self, x, y, data): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
235 |
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
|
236 |
col = self.ParentWindow.VariablesGrid.XToCol(x) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
237 |
row = self.ParentWindow.VariablesGrid.YToRow(y - self.ParentWindow.VariablesGrid.GetColLabelSize()) |
616
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
238 |
message = None |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
239 |
element_type = self.ParentWindow.ElementType |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
240 |
try: |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
241 |
values = eval(data) |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
242 |
except: |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
243 |
message = _("Invalid value \"%s\" for variable grid element")%data |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
244 |
values = None |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
245 |
if not isinstance(values, TupleType): |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
246 |
message = _("Invalid value \"%s\" for variable grid element")%data |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
247 |
values = None |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
248 |
if values is not None: |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
249 |
if col != wx.NOT_FOUND and row != wx.NOT_FOUND: |
716
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
250 |
colname = self.ParentWindow.Table.GetColLabelValue(col, False) |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
251 |
if colname == "Location" and values[1] == "location": |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
252 |
if not self.ParentWindow.Table.GetValueByName(row, "Edit"): |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
253 |
message = _("Can't give a location to a function block instance") |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
254 |
elif self.ParentWindow.Table.GetValueByName(row, "Class") not in ["Local", "Global"]: |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
255 |
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
|
256 |
else: |
716
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
257 |
location = values[0] |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
258 |
variable_type = self.ParentWindow.Table.GetValueByName(row, "Type") |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
259 |
base_type = self.ParentWindow.Controler.GetBaseType(variable_type) |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
260 |
if location.startswith("%"): |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
261 |
if base_type != values[2]: |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
262 |
message = _("Incompatible data types between \"%s\" and \"%s\"")%(values[2], variable_type) |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
263 |
else: |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
264 |
self.ParentWindow.Table.SetValue(row, col, location) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
265 |
self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
266 |
self.ParentWindow.SaveValues() |
716
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
267 |
else: |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
268 |
if location[0].isdigit() and base_type != "BOOL": |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
269 |
message = _("Incompatible size of data between \"%s\" and \"BOOL\"")%location |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
270 |
elif location[0] not in LOCATIONDATATYPES: |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
271 |
message = _("Unrecognized data size \"%s\"")%location[0] |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
272 |
elif base_type not in LOCATIONDATATYPES[location[0]]: |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
273 |
message = _("Incompatible size of data between \"%s\" and \"%s\"")%(location, variable_type) |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
274 |
else: |
720
2a9d4eafaddd
Fix bug no title bar on wx.SingleChoiceDialogs
Laurent Bessard
parents:
716
diff
changeset
|
275 |
dialog = wx.SingleChoiceDialog(self.ParentWindow, |
2a9d4eafaddd
Fix bug no title bar on wx.SingleChoiceDialogs
Laurent Bessard
parents:
716
diff
changeset
|
276 |
_("Select a variable class:"), _("Variable class"), |
2a9d4eafaddd
Fix bug no title bar on wx.SingleChoiceDialogs
Laurent Bessard
parents:
716
diff
changeset
|
277 |
["Input", "Output", "Memory"], |
2a9d4eafaddd
Fix bug no title bar on wx.SingleChoiceDialogs
Laurent Bessard
parents:
716
diff
changeset
|
278 |
wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL) |
716
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
279 |
if dialog.ShowModal() == wx.ID_OK: |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
280 |
selected = dialog.GetSelection() |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
281 |
if selected == 0: |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
282 |
location = "%I" + location |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
283 |
elif selected == 1: |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
284 |
location = "%Q" + location |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
285 |
else: |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
286 |
location = "%M" + location |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
287 |
self.ParentWindow.Table.SetValue(row, col, location) |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
288 |
self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
289 |
self.ParentWindow.SaveValues() |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
290 |
dialog.Destroy() |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
291 |
elif colname == "Initial Value" and values[1] == "Constant": |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
292 |
if not self.ParentWindow.Table.GetValueByName(row, "Edit"): |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
293 |
message = _("Can't set an initial value to a function block instance") |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
294 |
else: |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
295 |
self.ParentWindow.Table.SetValue(row, col, values[0]) |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
296 |
self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
2681a6da58d6
Adding support for drag'n dropping constant values
Laurent Bessard
parents:
714
diff
changeset
|
297 |
self.ParentWindow.SaveValues() |
616
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
298 |
elif (element_type not in ["config", "resource"] and values[1] == "Global" and self.ParentWindow.Filter in ["All", "Interface", "External"] or |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
299 |
element_type in ["config", "resource"] and values[1] == "location"): |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
300 |
if values[1] == "location": |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
301 |
var_name = values[3] |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
302 |
else: |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
303 |
var_name = values[0] |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
304 |
tagname = self.ParentWindow.GetTagName() |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
305 |
if var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]: |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
306 |
message = _("\"%s\" pou already exists!")%var_name |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
307 |
elif not var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetEditedElementVariables(tagname, self.ParentWindow.Debug)]: |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
308 |
var_infos = self.ParentWindow.DefaultValue.copy() |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
309 |
var_infos["Name"] = var_name |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
310 |
var_infos["Type"] = values[2] |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
311 |
if values[1] == "location": |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
312 |
var_infos["Class"] = "Global" |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
313 |
var_infos["Location"] = values[0] |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
314 |
else: |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
315 |
var_infos["Class"] = "External" |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
316 |
var_infos["Number"] = len(self.ParentWindow.Values) |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
317 |
self.ParentWindow.Values.append(var_infos) |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
318 |
self.ParentWindow.SaveValues() |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
319 |
self.ParentWindow.RefreshValues() |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
320 |
|
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
321 |
if message is not None: |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
322 |
wx.CallAfter(self.ShowMessage, message) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
323 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
324 |
def ShowMessage(self, message): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
325 |
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
|
326 |
message.ShowModal() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
327 |
message.Destroy() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
328 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
329 |
#------------------------------------------------------------------------------- |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
330 |
# Variable Panel |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
331 |
#------------------------------------------------------------------------------- |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
332 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
333 |
class VariablePanel(wx.Panel): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
334 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
335 |
def __init__(self, parent, window, controler, element_type, debug=False): |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
336 |
wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
337 |
|
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
338 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=0) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
339 |
self.MainSizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
340 |
self.MainSizer.AddGrowableRow(1) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
341 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
342 |
controls_sizer = wx.FlexGridSizer(cols=10, hgap=5, rows=1, vgap=5) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
343 |
controls_sizer.AddGrowableCol(5) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
344 |
controls_sizer.AddGrowableRow(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
345 |
self.MainSizer.AddSizer(controls_sizer, border=5, flag=wx.GROW|wx.ALL) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
346 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
347 |
self.ReturnTypeLabel = wx.StaticText(self, label=_('Return Type:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
348 |
controls_sizer.AddWindow(self.ReturnTypeLabel, flag=wx.ALIGN_CENTER_VERTICAL) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
349 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
350 |
self.ReturnType = wx.ComboBox(self, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
351 |
size=wx.Size(145, -1), style=wx.CB_READONLY) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
352 |
self.Bind(wx.EVT_COMBOBOX, self.OnReturnTypeChanged, self.ReturnType) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
353 |
controls_sizer.AddWindow(self.ReturnType) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
354 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
355 |
self.DescriptionLabel = wx.StaticText(self, label=_('Description:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
356 |
controls_sizer.AddWindow(self.DescriptionLabel, flag=wx.ALIGN_CENTER_VERTICAL) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
357 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
358 |
self.Description = wx.TextCtrl(self, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
359 |
size=wx.Size(250, -1), style=wx.TE_PROCESS_ENTER) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
360 |
self.Bind(wx.EVT_TEXT_ENTER, self.OnDescriptionChanged, self.Description) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
361 |
self.Description.Bind(wx.EVT_KILL_FOCUS, self.OnDescriptionChanged) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
362 |
controls_sizer.AddWindow(self.Description) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
363 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
364 |
class_filter_label = wx.StaticText(self, label=_('Class Filter:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
365 |
controls_sizer.AddWindow(class_filter_label, flag=wx.ALIGN_CENTER_VERTICAL) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
366 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
367 |
self.ClassFilter = wx.ComboBox(self, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
368 |
size=wx.Size(145, -1), style=wx.CB_READONLY) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
369 |
self.Bind(wx.EVT_COMBOBOX, self.OnClassFilter, self.ClassFilter) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
370 |
controls_sizer.AddWindow(self.ClassFilter) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
371 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
372 |
for name, bitmap, help in [ |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
373 |
("AddButton", "add_element", _("Add variable")), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
374 |
("DeleteButton", "remove_element", _("Remove variable")), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
375 |
("UpButton", "up", _("Move variable up")), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
376 |
("DownButton", "down", _("Move variable down"))]: |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
377 |
button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
378 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
379 |
button.SetToolTipString(help) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
380 |
setattr(self, name, button) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
381 |
controls_sizer.AddWindow(button) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
382 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
383 |
self.VariablesGrid = CustomGrid(self, style=wx.VSCROLL) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
384 |
self.VariablesGrid.SetDropTarget(VariableDropTarget(self)) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
385 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
386 |
self.OnVariablesGridCellChange) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
387 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
388 |
self.OnVariablesGridCellLeftClick) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
389 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
390 |
self.OnVariablesGridEditorShown) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
391 |
self.MainSizer.AddWindow(self.VariablesGrid, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
392 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
393 |
self.SetSizer(self.MainSizer) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
394 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
395 |
self.ParentWindow = window |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
396 |
self.Controler = controler |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
397 |
self.ElementType = element_type |
600
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
398 |
self.Debug = debug |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
399 |
|
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
400 |
self.RefreshHighlightsTimer = wx.Timer(self, -1) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
401 |
self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
402 |
self.RefreshHighlightsTimer) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
403 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
404 |
self.Filter = "All" |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
405 |
self.FilterChoices = [] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
406 |
self.FilterChoiceTransfer = GetFilterChoiceTransfer() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
407 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
408 |
self.DefaultValue = { |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
409 |
"Name" : "", |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
410 |
"Class" : "", |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
411 |
"Type" : "INT", |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
412 |
"Location" : "", |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
413 |
"Initial Value" : "", |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
414 |
"Option" : "", |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
415 |
"Documentation" : "", |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
416 |
"Edit" : True |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
684
diff
changeset
|
417 |
} |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
418 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
419 |
if element_type in ["config", "resource"]: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
420 |
self.DefaultTypes = {"All" : "Global"} |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
421 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
422 |
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
|
423 |
|
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
424 |
if element_type in ["config", "resource"] \ |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
425 |
or element_type in ["program", "transition", "action"]: |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
426 |
# 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
|
427 |
self.Table = VariableTable(self, [], GetVariableTableColnames(True)) |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
428 |
|
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
429 |
if element_type in ["config", "resource"]: |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
430 |
self.FilterChoices = ["All", "Global"]#,"Access"] |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
431 |
else: |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
432 |
self.FilterChoices = ["All", |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
433 |
"Interface", " Input", " Output", " InOut", " External", |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
434 |
"Variables", " Local", " Temp"]#,"Access"] |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
435 |
|
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
436 |
# these condense the ColAlignements list |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
437 |
l = wx.ALIGN_LEFT |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
438 |
c = wx.ALIGN_CENTER |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
439 |
|
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
440 |
# 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
|
441 |
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
|
442 |
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
|
443 |
|
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
444 |
else: |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
445 |
# 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
|
446 |
self.Table = VariableTable(self, [], GetVariableTableColnames(False)) |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
447 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
448 |
if element_type == "function": |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
449 |
self.FilterChoices = ["All", |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
450 |
"Interface", " Input", " Output", " InOut", |
484
acef952101a5
Adding support for excluding option when not available according to IEC 61131 standard
laurent
parents:
483
diff
changeset
|
451 |
"Variables", " Local"] |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
452 |
else: |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
453 |
self.FilterChoices = ["All", |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
454 |
"Interface", " Input", " Output", " InOut", " External", |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
455 |
"Variables", " Local", " Temp"] |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
456 |
|
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
457 |
# these condense the ColAlignements list |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
458 |
l = wx.ALIGN_LEFT |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
459 |
c = wx.ALIGN_CENTER |
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
460 |
|
483
779a519f78f2
Replace Retain and Constant column in VariablePanel by Option and add the option Non-Retain
laurent
parents:
449
diff
changeset
|
461 |
# 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
|
462 |
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
|
463 |
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
|
464 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
465 |
for choice in self.FilterChoices: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
466 |
self.ClassFilter.Append(_(choice)) |
424
d19c4a6460ab
add a Documentation column to the VariablePanel
b.taylor@willowglen.ca
parents:
422
diff
changeset
|
467 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
468 |
reverse_transfer = {} |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
469 |
for filter, choice in self.FilterChoiceTransfer.items(): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
470 |
reverse_transfer[choice] = filter |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
471 |
self.ClassFilter.SetStringSelection(_(reverse_transfer[self.Filter])) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
472 |
self.RefreshTypeList() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
473 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
474 |
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
|
475 |
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
|
476 |
"Delete": self.DeleteButton, |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
477 |
"Up": self.UpButton, |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
478 |
"Down": self.DownButton}) |
600
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
479 |
self.VariablesGrid.SetEditable(not self.Debug) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
480 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
481 |
def _AddVariable(new_row): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
482 |
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
|
483 |
row_content = self.DefaultValue.copy() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
484 |
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
|
485 |
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
|
486 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
487 |
row_content["Class"] = self.Filter |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
488 |
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
|
489 |
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
|
490 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
491 |
self.Values.append(row_content) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
492 |
new_row = self.Table.GetNumberRows() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
493 |
self.SaveValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
494 |
self.RefreshValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
495 |
return new_row |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
496 |
return self.VariablesGrid.GetGridCursorRow() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
497 |
setattr(self.VariablesGrid, "_AddRow", _AddVariable) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
498 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
499 |
def _DeleteVariable(row): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
500 |
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
|
501 |
(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
|
502 |
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
|
503 |
self.SaveValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
504 |
self.RefreshValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
505 |
setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
506 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
507 |
def _MoveVariable(row, move): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
508 |
if (self.Filter == "All" and |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
509 |
(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
|
510 |
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
|
511 |
if new_row != row: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
512 |
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
|
513 |
self.SaveValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
514 |
self.RefreshValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
515 |
return new_row |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
516 |
return row |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
517 |
setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
518 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
519 |
def _RefreshButtons(): |
672
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
520 |
if self: |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
521 |
table_length = len(self.Table.data) |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
522 |
row_class = None |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
523 |
row_edit = True |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
524 |
row = 0 |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
525 |
if table_length > 0: |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
526 |
row = self.VariablesGrid.GetGridCursorRow() |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
527 |
row_edit = self.Table.GetValueByName(row, "Edit") |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
528 |
if self.PouIsUsed: |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
529 |
row_class = self.Table.GetValueByName(row, "Class") |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
530 |
self.AddButton.Enable(not self.Debug and (not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"])) |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
531 |
self.DeleteButton.Enable(not self.Debug and (table_length > 0 and row_edit and row_class not in ["Input", "Output", "InOut"])) |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
532 |
self.UpButton.Enable(not self.Debug and (table_length > 0 and row > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])) |
d751b1c609b3
Fix bug when closing project and one editor is opened
laurent
parents:
666
diff
changeset
|
533 |
self.DownButton.Enable(not self.Debug and (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
|
534 |
setattr(self.VariablesGrid, "RefreshButtons", _RefreshButtons) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
535 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
536 |
self.VariablesGrid.SetRowLabelSize(0) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
537 |
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
|
538 |
attr = wx.grid.GridCellAttr() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
539 |
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
|
540 |
self.VariablesGrid.SetColAttr(col, attr) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
541 |
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
|
542 |
self.VariablesGrid.AutoSizeColumn(col, False) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
543 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
544 |
def __del__(self): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
545 |
self.RefreshHighlightsTimer.Stop() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
546 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
547 |
def SetTagName(self, tagname): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
548 |
self.TagName = tagname |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
549 |
|
616
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
550 |
def GetTagName(self): |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
551 |
return self.TagName |
8a60ffcfd70b
Adding support for drag'n dropping variable from global defined in configurations and resources to POU variable panel or body editor for declaring external variables
laurent
parents:
606
diff
changeset
|
552 |
|
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
553 |
def IsFunctionBlockType(self, name): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
554 |
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
|
555 |
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
|
556 |
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
|
557 |
return False |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
558 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
559 |
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
|
560 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
561 |
def RefreshView(self): |
600
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
562 |
self.PouNames = self.Controler.GetProjectPouNames(self.Debug) |
625
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
563 |
returnType = None |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
564 |
description = None |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
565 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
566 |
words = self.TagName.split("::") |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
567 |
if self.ElementType == "config": |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
568 |
self.PouIsUsed = False |
600
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
569 |
self.Values = self.Controler.GetConfigurationGlobalVars(words[1], self.Debug) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
570 |
elif self.ElementType == "resource": |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
571 |
self.PouIsUsed = False |
600
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
572 |
self.Values = self.Controler.GetConfigurationResourceGlobalVars(words[1], words[2], self.Debug) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
573 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
574 |
if self.ElementType == "function": |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
575 |
self.ReturnType.Clear() |
600
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
576 |
for base_type in self.Controler.GetDataTypes(self.TagName, True, debug=self.Debug): |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
577 |
self.ReturnType.Append(base_type) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
578 |
returnType = self.Controler.GetEditedElementInterfaceReturnType(self.TagName) |
625
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
579 |
description = self.Controler.GetPouDescription(words[1]) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
580 |
self.PouIsUsed = self.Controler.PouIsUsed(words[1]) |
600
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
581 |
self.Values = self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug) |
577
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 |
if returnType is not None: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
584 |
self.ReturnType.SetStringSelection(returnType) |
625
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
585 |
self.ReturnType.Enable(not self.Debug) |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
586 |
self.ReturnTypeLabel.Show() |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
587 |
self.ReturnType.Show() |
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 |
self.ReturnType.Enable(False) |
625
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
590 |
self.ReturnTypeLabel.Hide() |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
591 |
self.ReturnType.Hide() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
592 |
|
625
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
593 |
if description is not None: |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
594 |
self.Description.SetValue(description) |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
595 |
self.Description.Enable(not self.Debug) |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
596 |
self.DescriptionLabel.Show() |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
597 |
self.Description.Show() |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
598 |
else: |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
599 |
self.Description.Enable(False) |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
600 |
self.DescriptionLabel.Hide() |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
601 |
self.Description.Hide() |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
602 |
|
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
603 |
self.RefreshValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
604 |
self.VariablesGrid.RefreshButtons() |
627
99ab0b74865f
Fixing bug in displaying variable panel header on Windows
laurent
parents:
625
diff
changeset
|
605 |
self.MainSizer.Layout() |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
606 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
607 |
def OnReturnTypeChanged(self, event): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
608 |
words = self.TagName.split("::") |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
609 |
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
|
610 |
self.Controler.BufferProject() |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
611 |
self.ParentWindow.RefreshView(variablepanel = False) |
684 | 612 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
613 |
event.Skip() |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
614 |
|
625
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
615 |
def OnDescriptionChanged(self, event): |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
616 |
words = self.TagName.split("::") |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
617 |
old_description = self.Controler.GetPouDescription(words[1]) |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
618 |
new_description = self.Description.GetValue() |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
619 |
if new_description != old_description: |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
620 |
self.Controler.SetPouDescription(words[1], new_description) |
684 | 621 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
625
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
622 |
event.Skip() |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
623 |
|
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
624 |
def OnClassFilter(self, event): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
625 |
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
|
626 |
self.RefreshTypeList() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
627 |
self.RefreshValues() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
628 |
self.VariablesGrid.RefreshButtons() |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
629 |
event.Skip() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
630 |
|
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
631 |
def RefreshTypeList(self): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
632 |
if self.Filter == "All": |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
633 |
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
|
634 |
elif self.Filter == "Interface": |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
635 |
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
|
636 |
elif self.Filter == "Variables": |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
637 |
self.ClassList = ["Local","Temp"] |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
638 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
639 |
self.ClassList = [self.Filter] |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
640 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
641 |
def OnVariablesGridCellChange(self, event): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
642 |
row, col = event.GetRow(), event.GetCol() |
431
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
643 |
colname = self.Table.GetColLabelValue(col, False) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
644 |
value = self.Table.GetValue(row, col) |
623
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
645 |
message = None |
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
646 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
647 |
if colname == "Name" and value != "": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
648 |
if not TestIdentifier(value): |
623
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
649 |
message = _("\"%s\" is not a valid identifier!") % value |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
650 |
elif value.upper() in IEC_KEYWORDS: |
623
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
651 |
message = _("\"%s\" is a keyword. It can't be used!") % value |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
652 |
elif value.upper() in self.PouNames: |
623
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
653 |
message = _("A POU named \"%s\" already exists!") % value |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
654 |
elif value.upper() in [var["Name"].upper() for var in self.Values if var != self.Table.data[row]]: |
623
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
655 |
message = _("A variable with \"%s\" as name already exists in this pou!") % value |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
656 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
657 |
self.SaveValues(False) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
658 |
old_value = self.Table.GetOldValue() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
659 |
if old_value != "": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
660 |
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
|
661 |
self.Controler.BufferProject() |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
662 |
self.ParentWindow.RefreshView(variablepanel = False) |
684 | 663 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
664 |
event.Skip() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
665 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
666 |
self.SaveValues() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
667 |
if colname == "Class": |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
668 |
self.ParentWindow.RefreshView(variablepanel = False) |
625
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
669 |
elif colname == "Location": |
b7062a7018ec
Adding support for defining a description for a user POU type, and displaying this information in library tree.
laurent
parents:
623
diff
changeset
|
670 |
wx.CallAfter(self.ParentWindow.RefreshView) |
623
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
671 |
|
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
672 |
if message is not None: |
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
673 |
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) |
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
674 |
dialog.ShowModal() |
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
675 |
dialog.Destroy() |
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
676 |
event.Veto() |
e747685e4241
Adding support for checking location validity when filled by user
laurent
parents:
616
diff
changeset
|
677 |
else: |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
678 |
event.Skip() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
679 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
680 |
def OnVariablesGridEditorShown(self, event): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
681 |
row, col = event.GetRow(), event.GetCol() |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
682 |
|
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
683 |
label_value = self.Table.GetColLabelValue(col) |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
684 |
if label_value == "Type": |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
685 |
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
|
686 |
|
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
687 |
# 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
|
688 |
base_menu = wx.Menu(title='') |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
689 |
for base_type in self.Controler.GetBaseTypes(): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
690 |
new_id = wx.NewId() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
691 |
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
|
692 |
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
|
693 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
694 |
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
|
695 |
|
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
696 |
# 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
|
697 |
datatype_menu = wx.Menu(title='') |
491
d22a4a95fd5e
Remove limitation on complex types in POU interface
laurent
parents:
484
diff
changeset
|
698 |
datatypes = self.Controler.GetDataTypes(basetypes = False) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
699 |
for datatype in datatypes: |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
700 |
new_id = wx.NewId() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
701 |
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
|
702 |
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
|
703 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
704 |
type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu) |
630
9d7e38e271cb
Adding support for loading datatypes defined in plugins to allow to use them in PLC program
laurent
parents:
627
diff
changeset
|
705 |
|
681
c141dad94ff4
beremiz 'plugins' refactoring to 'confnode'
Edouard Tisserant
parents:
672
diff
changeset
|
706 |
for category in self.Controler.GetConfNodeDataTypes(): |
630
9d7e38e271cb
Adding support for loading datatypes defined in plugins to allow to use them in PLC program
laurent
parents:
627
diff
changeset
|
707 |
|
9d7e38e271cb
Adding support for loading datatypes defined in plugins to allow to use them in PLC program
laurent
parents:
627
diff
changeset
|
708 |
if len(category["list"]) > 0: |
681
c141dad94ff4
beremiz 'plugins' refactoring to 'confnode'
Edouard Tisserant
parents:
672
diff
changeset
|
709 |
# build a submenu containing confnode types |
c141dad94ff4
beremiz 'plugins' refactoring to 'confnode'
Edouard Tisserant
parents:
672
diff
changeset
|
710 |
confnode_datatype_menu = wx.Menu(title='') |
630
9d7e38e271cb
Adding support for loading datatypes defined in plugins to allow to use them in PLC program
laurent
parents:
627
diff
changeset
|
711 |
for datatype in category["list"]: |
9d7e38e271cb
Adding support for loading datatypes defined in plugins to allow to use them in PLC program
laurent
parents:
627
diff
changeset
|
712 |
new_id = wx.NewId() |
681
c141dad94ff4
beremiz 'plugins' refactoring to 'confnode'
Edouard Tisserant
parents:
672
diff
changeset
|
713 |
AppendMenu(confnode_datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) |
630
9d7e38e271cb
Adding support for loading datatypes defined in plugins to allow to use them in PLC program
laurent
parents:
627
diff
changeset
|
714 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id) |
9d7e38e271cb
Adding support for loading datatypes defined in plugins to allow to use them in PLC program
laurent
parents:
627
diff
changeset
|
715 |
|
681
c141dad94ff4
beremiz 'plugins' refactoring to 'confnode'
Edouard Tisserant
parents:
672
diff
changeset
|
716 |
type_menu.AppendMenu(wx.NewId(), category["name"], confnode_datatype_menu) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
717 |
|
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
718 |
# build a submenu containing function block types |
431
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
719 |
bodytype = self.Controler.GetEditedElementBodyType(self.TagName) |
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
720 |
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
|
721 |
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
|
722 |
|
556
69214983dd03
Enabling support for direct array variable declaration
laurent
parents:
552
diff
changeset
|
723 |
new_id = wx.NewId() |
69214983dd03
Enabling support for direct array variable declaration
laurent
parents:
552
diff
changeset
|
724 |
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
|
725 |
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
|
726 |
|
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
727 |
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
|
728 |
poutype != "function" and bodytype in ["ST", "IL"]: |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
729 |
functionblock_menu = wx.Menu(title='') |
431
c1c92d068ac5
Changes merged
'Laurent Bessard <laurent.bessard@lolitech.fr>'
parents:
427
diff
changeset
|
730 |
fbtypes = self.Controler.GetFunctionBlockTypes(self.TagName) |
422
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
731 |
for functionblock_type in fbtypes: |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
732 |
new_id = wx.NewId() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
733 |
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
|
734 |
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
|
735 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
736 |
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
|
737 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
738 |
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
|
739 |
corner_x = rect.x + rect.width |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
740 |
corner_y = rect.y + self.VariablesGrid.GetColLabelSize() |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
741 |
|
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
742 |
# pop up this new menu |
31c3dc45cfab
introduced BrowseVariableLocationsDialog and the GridCellEditor that launches it.
b.taylor@willowglen.ca
parents:
419
diff
changeset
|
743 |
self.VariablesGrid.PopupMenuXY(type_menu, corner_x, corner_y) |
666
d4bb66691248
Improving contextual menu in Viewer and fixing menu toolbar icons on Windows
laurent
parents:
630
diff
changeset
|
744 |
type_menu.Destroy() |
418
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 |
event.Skip() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
748 |
|
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
749 |
def GetVariableTypeFunction(self, base_type): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
750 |
def VariableTypeFunction(event): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
751 |
row = self.VariablesGrid.GetGridCursorRow() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
752 |
self.Table.SetValueByName(row, "Type", base_type) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
753 |
self.Table.ResetView(self.VariablesGrid) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
754 |
self.SaveValues(False) |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
755 |
self.ParentWindow.RefreshView(variablepanel = False) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
756 |
self.Controler.BufferProject() |
684 | 757 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
758 |
return VariableTypeFunction |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
759 |
|
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
|
760 |
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
|
761 |
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
|
762 |
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
|
763 |
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
|
764 |
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
|
765 |
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
|
766 |
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
|
767 |
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
|
768 |
self.SaveValues(False) |
586
9aa96a36cf33
Moving variable panel from bottom notebook panel to POU editor panel
laurent
parents:
580
diff
changeset
|
769 |
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
|
770 |
self.Controler.BufferProject() |
684 | 771 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
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
|
772 |
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
|
773 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
774 |
def OnVariablesGridCellLeftClick(self, event): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
775 |
row = event.GetRow() |
600
7db729686416
Making variable panel not editable when showing variables of debugging block
laurent
parents:
595
diff
changeset
|
776 |
if not self.Debug and (event.GetCol() == 0 and self.Table.GetValueByName(row, "Edit")): |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
777 |
row = event.GetRow() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
778 |
var_name = self.Table.GetValueByName(row, "Name") |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
779 |
var_class = self.Table.GetValueByName(row, "Class") |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
780 |
var_type = self.Table.GetValueByName(row, "Type") |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
781 |
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
|
782 |
dragSource = wx.DropSource(self.VariablesGrid) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
783 |
dragSource.SetData(data) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
784 |
dragSource.DoDragDrop() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
785 |
event.Skip() |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
786 |
|
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
566
diff
changeset
|
787 |
def RefreshValues(self): |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
788 |
data = [] |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
789 |
for num, variable in enumerate(self.Values): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
790 |
if variable["Class"] in self.ClassList: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
791 |
variable["Number"] = num + 1 |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
792 |
data.append(variable) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
793 |
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
|
794 |
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
|
795 |
|
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
796 |
def SaveValues(self, buffer = True): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
797 |
words = self.TagName.split("::") |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
798 |
if self.ElementType == "config": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
799 |
self.Controler.SetConfigurationGlobalVars(words[1], self.Values) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
800 |
elif self.ElementType == "resource": |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
801 |
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
|
802 |
else: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
803 |
if self.ReturnType.IsEnabled(): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
804 |
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
|
805 |
self.Controler.SetPouInterfaceVars(words[1], self.Values) |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
806 |
if buffer: |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
807 |
self.Controler.BufferProject() |
684 | 808 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
809 |
|
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
810 |
#------------------------------------------------------------------------------- |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
811 |
# Highlights showing functions |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
812 |
#------------------------------------------------------------------------------- |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
813 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
814 |
def OnRefreshHighlightsTimer(self, event): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
815 |
self.Table.ResetView(self.VariablesGrid) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
816 |
event.Skip() |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
817 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
818 |
def AddVariableHighlight(self, infos, highlight_type): |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
819 |
if isinstance(infos[0], TupleType): |
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
820 |
for i in xrange(*infos[0]): |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
821 |
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
|
822 |
else: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
823 |
self.Table.AddHighlight(infos, highlight_type) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
824 |
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
|
825 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
826 |
def ClearHighlights(self, highlight_type=None): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
564
diff
changeset
|
827 |
self.Table.ClearHighlights(highlight_type) |
418
a06221a0930b
split the variable editor panel into its own file
b.taylor@willowglen.ca
parents:
diff
changeset
|
828 |
self.Table.ResetView(self.VariablesGrid) |