author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Thu, 09 Mar 2017 15:35:19 +0300 | |
changeset 1657 | 3a98027ff372 |
parent 1571 | 486f94a8032c |
child 1696 | 8043f32de7b8 |
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 |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
8 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
9 |
# 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
|
10 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
11 |
# 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
|
12 |
# 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
|
13 |
# 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
|
14 |
# 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
|
15 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
16 |
# 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
|
17 |
# 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
|
18 |
# 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
|
19 |
# 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
|
20 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
855
diff
changeset
|
21 |
# 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
|
22 |
# 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
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.# |
814 | 24 |
|
25 |
import os |
|
26 |
||
27 |
import wx |
|
28 |
||
29 |
from plcopen.structures import LOCATIONDATATYPES |
|
30 |
from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
|
829 | 31 |
from util.BitmapLibrary import GetBitmap |
814 | 32 |
|
33 |
#------------------------------------------------------------------------------- |
|
34 |
# Helpers |
|
35 |
#------------------------------------------------------------------------------- |
|
36 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
37 |
def GetDirFilterChoiceOptions(): |
814 | 38 |
_ = lambda x : x |
39 |
return [(_("All"), [LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY]), |
|
40 |
(_("Input"), [LOCATION_VAR_INPUT]), |
|
41 |
(_("Output"), [LOCATION_VAR_OUTPUT]), |
|
42 |
(_("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
|
43 |
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
|
44 |
|
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
45 |
def GetTypeFilterChoiceOptions(): |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
46 |
_ = 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
|
47 |
return [_("All"), |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
48 |
_("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
|
49 |
_("Type strict")] |
814 | 50 |
|
51 |
# turn LOCATIONDATATYPES inside-out |
|
52 |
LOCATION_SIZES = {} |
|
53 |
for size, types in LOCATIONDATATYPES.iteritems(): |
|
54 |
for type in types: |
|
55 |
LOCATION_SIZES[type] = size |
|
56 |
||
57 |
#------------------------------------------------------------------------------- |
|
58 |
# Browse Locations Dialog |
|
59 |
#------------------------------------------------------------------------------- |
|
60 |
||
61 |
class BrowseLocationsDialog(wx.Dialog): |
|
62 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
63 |
def __init__(self, parent, var_type, controller): |
814 | 64 |
wx.Dialog.__init__(self, parent, |
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
65 |
size=wx.Size(600, 400), title=_('Browse Locations'), |
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) |
|
78 |
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnLocationsTreeItemActivated, |
|
79 |
self.LocationsTree) |
|
80 |
main_sizer.AddWindow(self.LocationsTree, border=20, |
|
81 |
flag=wx.LEFT|wx.RIGHT|wx.GROW) |
|
82 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
83 |
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
|
84 |
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
|
85 |
button_gridsizer.AddGrowableCol(3) |
814 | 86 |
button_gridsizer.AddGrowableRow(0) |
87 |
main_sizer.AddSizer(button_gridsizer, border=20, |
|
88 |
flag=wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.GROW) |
|
89 |
||
90 |
direction_label = wx.StaticText(self, label=_('Direction:')) |
|
91 |
button_gridsizer.AddWindow(direction_label, |
|
92 |
flag=wx.ALIGN_CENTER_VERTICAL) |
|
93 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
94 |
self.DirFilterChoice = wx.ComboBox(self, size=wx.Size(0, -1), style=wx.CB_READONLY) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
95 |
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
|
96 |
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
|
97 |
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
|
98 |
|
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
99 |
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
|
100 |
button_gridsizer.AddWindow(filter_label, |
814 | 101 |
flag=wx.ALIGN_CENTER_VERTICAL) |
102 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
103 |
self.TypeFilterChoice = wx.ComboBox(self, size=wx.Size(0, -1), style=wx.CB_READONLY) |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
104 |
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
|
105 |
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
|
106 |
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
|
107 |
|
814 | 108 |
button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
109 |
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
|
110 |
button_gridsizer.AddSizer(button_sizer, flag=wx.ALIGN_RIGHT) |
814 | 111 |
|
112 |
self.SetSizer(main_sizer) |
|
113 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
114 |
self.Controller = controller |
814 | 115 |
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
|
116 |
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
|
117 |
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
|
118 |
self.Locations = self.Controller.GetVariableLocationTree() |
814 | 119 |
|
120 |
# Define Tree item icon list |
|
121 |
self.TreeImageList = wx.ImageList(16, 16) |
|
122 |
self.TreeImageDict = {} |
|
123 |
||
124 |
# Icons for items |
|
125 |
for imgname, itemtype in [ |
|
126 |
("CONFIGURATION", LOCATION_CONFNODE), |
|
127 |
("RESOURCE", LOCATION_MODULE), |
|
128 |
("PROGRAM", LOCATION_GROUP), |
|
129 |
("VAR_INPUT", LOCATION_VAR_INPUT), |
|
130 |
("VAR_OUTPUT", LOCATION_VAR_OUTPUT), |
|
131 |
("VAR_LOCAL", LOCATION_VAR_MEMORY)]: |
|
829 | 132 |
self.TreeImageDict[itemtype]=self.TreeImageList.Add(GetBitmap(imgname)) |
814 | 133 |
|
134 |
# Assign icon list to TreeCtrls |
|
135 |
self.LocationsTree.SetImageList(self.TreeImageList) |
|
136 |
||
137 |
# 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
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
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
|
142 |
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
|
143 |
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
|
144 |
self.RefreshFilters() |
814 | 145 |
|
146 |
self.RefreshLocationsTree() |
|
147 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
148 |
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
|
149 |
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
|
150 |
self.TypeFilter = self.TypeFilterChoice.GetSelection() |
814 | 151 |
|
152 |
def RefreshLocationsTree(self): |
|
153 |
root = self.LocationsTree.GetRootItem() |
|
154 |
if not root.IsOk(): |
|
155 |
root = self.LocationsTree.AddRoot("") |
|
156 |
self.GenerateLocationsTreeBranch(root, self.Locations) |
|
157 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
158 |
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
|
159 |
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
|
160 |
return True |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
161 |
|
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
162 |
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
|
163 |
return False |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
164 |
|
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
165 |
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
|
166 |
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
|
167 |
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
|
168 |
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
|
169 |
|
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
170 |
return True |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
171 |
|
814 | 172 |
def GenerateLocationsTreeBranch(self, root, locations): |
173 |
to_delete = [] |
|
174 |
item, root_cookie = self.LocationsTree.GetFirstChild(root) |
|
175 |
for loc_infos in locations: |
|
176 |
infos = loc_infos.copy() |
|
177 |
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
|
178 |
infos["type"] in self.DirFilter and self.FilterType(infos["IEC_type"], infos["size"]): |
814 | 179 |
children = [child for child in infos.pop("children")] |
180 |
if not item.IsOk(): |
|
181 |
item = self.LocationsTree.AppendItem(root, infos["name"]) |
|
182 |
if wx.Platform != '__WXMSW__': |
|
183 |
item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie) |
|
184 |
else: |
|
185 |
self.LocationsTree.SetItemText(item, infos["name"]) |
|
186 |
self.LocationsTree.SetPyData(item, infos) |
|
187 |
self.LocationsTree.SetItemImage(item, self.TreeImageDict[infos["type"]]) |
|
188 |
self.GenerateLocationsTreeBranch(item, children) |
|
189 |
item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie) |
|
190 |
while item.IsOk(): |
|
191 |
to_delete.append(item) |
|
192 |
item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie) |
|
193 |
for item in to_delete: |
|
194 |
self.LocationsTree.Delete(item) |
|
195 |
||
196 |
def OnLocationsTreeItemActivated(self, event): |
|
197 |
infos = self.LocationsTree.GetPyData(event.GetItem()) |
|
198 |
if infos["type"] not in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]: |
|
199 |
wx.CallAfter(self.EndModal, wx.ID_OK) |
|
200 |
event.Skip() |
|
201 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
829
diff
changeset
|
202 |
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
|
203 |
self.RefreshFilters() |
814 | 204 |
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
|
205 |
|
814 | 206 |
def GetValues(self): |
207 |
selected = self.LocationsTree.GetSelection() |
|
208 |
return self.LocationsTree.GetPyData(selected) |
|
209 |
||
210 |
def OnOK(self, event): |
|
211 |
selected = self.LocationsTree.GetSelection() |
|
212 |
var_infos = None |
|
213 |
if selected.IsOk(): |
|
214 |
var_infos = self.LocationsTree.GetPyData(selected) |
|
215 |
if var_infos is None or var_infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]: |
|
216 |
dialog = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR) |
|
217 |
dialog.ShowModal() |
|
218 |
dialog.Destroy() |
|
219 |
else: |
|
220 |
self.EndModal(wx.ID_OK) |