author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Wed, 09 Aug 2017 14:34:28 +0300 | |
changeset 1725 | f8e4650619f7 |
parent 1696 | 8043f32de7b8 |
child 1730 | 64d8f52bc8c8 |
permissions | -rw-r--r-- |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
1 |
#!/usr/bin/env python |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
3 |
|
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
6 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
8 |
# Copyright (C) 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com> |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
9 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
10 |
# See COPYING file for copyrights details. |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
11 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
12 |
# This program is free software; you can redistribute it and/or |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
13 |
# modify it under the terms of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
14 |
# as published by the Free Software Foundation; either version 2 |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
15 |
# of the License, or (at your option) any later version. |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
16 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
17 |
# This program is distributed in the hope that it will be useful, |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
18 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
20 |
# GNU General Public License for more details. |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
21 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
22 |
# You should have received a copy of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
23 |
# along with this program; if not, write to the Free Software |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
24 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.# |
814 | 25 |
|
26 |
import os |
|
27 |
||
28 |
import wx |
|
29 |
||
30 |
from plcopen.structures import LOCATIONDATATYPES |
|
31 |
from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
|
829 | 32 |
from util.BitmapLibrary import GetBitmap |
814 | 33 |
|
34 |
#------------------------------------------------------------------------------- |
|
35 |
# Helpers |
|
36 |
#------------------------------------------------------------------------------- |
|
37 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
38 |
def GetDirFilterChoiceOptions(): |
814 | 39 |
_ = lambda x : x |
40 |
return [(_("All"), [LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY]), |
|
41 |
(_("Input"), [LOCATION_VAR_INPUT]), |
|
42 |
(_("Output"), [LOCATION_VAR_OUTPUT]), |
|
43 |
(_("Memory"), [LOCATION_VAR_MEMORY])] |
|
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
44 |
DIRFILTERCHOICE_OPTIONS = dict([(_(option), filter) for option, filter in GetDirFilterChoiceOptions()]) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
45 |
|
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
46 |
def GetTypeFilterChoiceOptions(): |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
47 |
_ = lambda x : x |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
48 |
return [_("All"), |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
49 |
_("Type and derivated"), |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
50 |
_("Type strict")] |
814 | 51 |
|
52 |
# turn LOCATIONDATATYPES inside-out |
|
53 |
LOCATION_SIZES = {} |
|
54 |
for size, types in LOCATIONDATATYPES.iteritems(): |
|
55 |
for type in types: |
|
56 |
LOCATION_SIZES[type] = size |
|
57 |
||
58 |
#------------------------------------------------------------------------------- |
|
59 |
# Browse Locations Dialog |
|
60 |
#------------------------------------------------------------------------------- |
|
61 |
||
62 |
class BrowseLocationsDialog(wx.Dialog): |
|
63 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
64 |
def __init__(self, parent, var_type, controller): |
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
65 |
wx.Dialog.__init__(self, parent, title=_('Browse Locations'), |
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
66 |
style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) |
814 | 67 |
|
68 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) |
|
69 |
main_sizer.AddGrowableCol(0) |
|
70 |
main_sizer.AddGrowableRow(1) |
|
71 |
||
72 |
locations_label = wx.StaticText(self, label=_('Locations available:')) |
|
73 |
main_sizer.AddWindow(locations_label, border=20, |
|
74 |
flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW) |
|
75 |
||
76 |
self.LocationsTree = wx.TreeCtrl(self, |
|
77 |
style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_HIDE_ROOT|wx.TR_LINES_AT_ROOT) |
|
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
78 |
self.LocationsTree.SetInitialSize(wx.Size(-1, 300)) |
814 | 79 |
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnLocationsTreeItemActivated, |
80 |
self.LocationsTree) |
|
81 |
main_sizer.AddWindow(self.LocationsTree, border=20, |
|
82 |
flag=wx.LEFT|wx.RIGHT|wx.GROW) |
|
83 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
84 |
button_gridsizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
85 |
button_gridsizer.AddGrowableCol(1) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
86 |
button_gridsizer.AddGrowableCol(3) |
814 | 87 |
button_gridsizer.AddGrowableRow(0) |
88 |
main_sizer.AddSizer(button_gridsizer, border=20, |
|
89 |
flag=wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.GROW) |
|
90 |
||
91 |
direction_label = wx.StaticText(self, label=_('Direction:')) |
|
92 |
button_gridsizer.AddWindow(direction_label, |
|
93 |
flag=wx.ALIGN_CENTER_VERTICAL) |
|
94 |
||
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
95 |
self.DirFilterChoice = wx.ComboBox(self, style=wx.CB_READONLY) |
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
96 |
self.Bind(wx.EVT_COMBOBOX, self.OnFilterChoice, self.DirFilterChoice) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
97 |
button_gridsizer.AddWindow(self.DirFilterChoice, |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
98 |
flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
99 |
|
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
100 |
filter_label = wx.StaticText(self, label=_('Type:')) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
101 |
button_gridsizer.AddWindow(filter_label, |
814 | 102 |
flag=wx.ALIGN_CENTER_VERTICAL) |
103 |
||
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
104 |
self.TypeFilterChoice = wx.ComboBox(self, style=wx.CB_READONLY) |
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
105 |
self.Bind(wx.EVT_COMBOBOX, self.OnFilterChoice, self.TypeFilterChoice) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
106 |
button_gridsizer.AddWindow(self.TypeFilterChoice, |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
107 |
flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
108 |
|
814 | 109 |
button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
110 |
self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) |
|
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
111 |
button_gridsizer.AddSizer(button_sizer, flag=wx.ALIGN_RIGHT) |
814 | 112 |
|
113 |
self.SetSizer(main_sizer) |
|
114 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
115 |
self.Controller = controller |
814 | 116 |
self.VarType = var_type |
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
117 |
self.BaseVarType = self.Controller.GetBaseType(self.VarType) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
118 |
self.VarTypeSize = LOCATION_SIZES[self.BaseVarType] |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
119 |
self.Locations = self.Controller.GetVariableLocationTree() |
814 | 120 |
|
121 |
# Define Tree item icon list |
|
122 |
self.TreeImageList = wx.ImageList(16, 16) |
|
123 |
self.TreeImageDict = {} |
|
124 |
||
125 |
# Icons for items |
|
126 |
for imgname, itemtype in [ |
|
127 |
("CONFIGURATION", LOCATION_CONFNODE), |
|
128 |
("RESOURCE", LOCATION_MODULE), |
|
129 |
("PROGRAM", LOCATION_GROUP), |
|
130 |
("VAR_INPUT", LOCATION_VAR_INPUT), |
|
131 |
("VAR_OUTPUT", LOCATION_VAR_OUTPUT), |
|
132 |
("VAR_LOCAL", LOCATION_VAR_MEMORY)]: |
|
829 | 133 |
self.TreeImageDict[itemtype]=self.TreeImageList.Add(GetBitmap(imgname)) |
814 | 134 |
|
135 |
# Assign icon list to TreeCtrls |
|
136 |
self.LocationsTree.SetImageList(self.TreeImageList) |
|
137 |
||
138 |
# Set a options for the choice |
|
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
139 |
for option, filter in GetDirFilterChoiceOptions(): |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
140 |
self.DirFilterChoice.Append(_(option)) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
141 |
self.DirFilterChoice.SetStringSelection(_("All")) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
142 |
for option in GetTypeFilterChoiceOptions(): |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
143 |
self.TypeFilterChoice.Append(_(option)) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
144 |
self.TypeFilterChoice.SetStringSelection(_("All")) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
145 |
self.RefreshFilters() |
814 | 146 |
|
147 |
self.RefreshLocationsTree() |
|
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
148 |
self.Fit() |
814 | 149 |
|
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
150 |
def RefreshFilters(self): |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
151 |
self.DirFilter = DIRFILTERCHOICE_OPTIONS[self.DirFilterChoice.GetStringSelection()] |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
152 |
self.TypeFilter = self.TypeFilterChoice.GetSelection() |
814 | 153 |
|
154 |
def RefreshLocationsTree(self): |
|
155 |
root = self.LocationsTree.GetRootItem() |
|
156 |
if not root.IsOk(): |
|
157 |
root = self.LocationsTree.AddRoot("") |
|
158 |
self.GenerateLocationsTreeBranch(root, self.Locations) |
|
159 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
160 |
def FilterType(self, location_type, location_size): |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
161 |
if self.TypeFilter == 0: |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
162 |
return True |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
163 |
|
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
164 |
if location_size != self.VarTypeSize: |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
165 |
return False |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
166 |
|
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
167 |
if self.TypeFilter == 1: |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
168 |
return self.Controller.IsOfType(location_type, self.BaseVarType) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
169 |
elif self.TypeFilter == 2: |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
170 |
return location_type == self.VarType |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
171 |
|
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
172 |
return True |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
173 |
|
814 | 174 |
def GenerateLocationsTreeBranch(self, root, locations): |
175 |
to_delete = [] |
|
176 |
item, root_cookie = self.LocationsTree.GetFirstChild(root) |
|
177 |
for loc_infos in locations: |
|
178 |
infos = loc_infos.copy() |
|
179 |
if infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP] or\ |
|
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
180 |
infos["type"] in self.DirFilter and self.FilterType(infos["IEC_type"], infos["size"]): |
814 | 181 |
children = [child for child in infos.pop("children")] |
182 |
if not item.IsOk(): |
|
183 |
item = self.LocationsTree.AppendItem(root, infos["name"]) |
|
184 |
if wx.Platform != '__WXMSW__': |
|
185 |
item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie) |
|
186 |
else: |
|
187 |
self.LocationsTree.SetItemText(item, infos["name"]) |
|
188 |
self.LocationsTree.SetPyData(item, infos) |
|
189 |
self.LocationsTree.SetItemImage(item, self.TreeImageDict[infos["type"]]) |
|
190 |
self.GenerateLocationsTreeBranch(item, children) |
|
191 |
item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie) |
|
192 |
while item.IsOk(): |
|
193 |
to_delete.append(item) |
|
194 |
item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie) |
|
195 |
for item in to_delete: |
|
196 |
self.LocationsTree.Delete(item) |
|
197 |
||
198 |
def OnLocationsTreeItemActivated(self, event): |
|
199 |
infos = self.LocationsTree.GetPyData(event.GetItem()) |
|
200 |
if infos["type"] not in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]: |
|
201 |
wx.CallAfter(self.EndModal, wx.ID_OK) |
|
202 |
event.Skip() |
|
203 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
204 |
def OnFilterChoice(self, event): |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
205 |
self.RefreshFilters() |
814 | 206 |
self.RefreshLocationsTree() |
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
207 |
|
814 | 208 |
def GetValues(self): |
209 |
selected = self.LocationsTree.GetSelection() |
|
210 |
return self.LocationsTree.GetPyData(selected) |
|
211 |
||
212 |
def OnOK(self, event): |
|
213 |
selected = self.LocationsTree.GetSelection() |
|
214 |
var_infos = None |
|
215 |
if selected.IsOk(): |
|
216 |
var_infos = self.LocationsTree.GetPyData(selected) |
|
217 |
if var_infos is None or var_infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]: |
|
218 |
dialog = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR) |
|
219 |
dialog.ShowModal() |
|
220 |
dialog.Destroy() |
|
221 |
else: |
|
222 |
self.EndModal(wx.ID_OK) |