author | Claus Gittinger <cg@exept.de> |
Mon, 15 Jul 2019 18:47:18 +0200 | |
changeset 18902 | c2dea21fb224 |
parent 18114 | 501752bc1873 |
permissions | -rw-r--r-- |
18114 | 1 |
"{ Encoding: utf8 }" |
2 |
||
13826 | 3 |
" |
4 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
10924 | 14 |
"{ Package: 'stx:libtool' }" |
15 |
||
16 |
"{ NameSpace: Tools }" |
|
17 |
||
18 |
BrowserList subclass:#BrowserListWithFilter |
|
19 |
instanceVariableNames:'listView filterView filterPatternHolder showFilterHolder' |
|
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'Interface-Browsers-New' |
|
23 |
! |
|
24 |
||
25 |
!BrowserListWithFilter class methodsFor:'documentation'! |
|
26 |
||
13826 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
10924 | 41 |
documentation |
42 |
" |
|
43 |
Abstract superclass for a browser list with user filter. |
|
44 |
Currently used only ChangeList and ChangeSetDiffList, but |
|
18009 | 45 |
user filter may be useful for class/category lists as well. |
10924 | 46 |
|
47 |
[author:] |
|
48 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
|
49 |
||
50 |
[instance variables:] |
|
51 |
||
52 |
[class variables:] |
|
53 |
||
54 |
[see also:] |
|
55 |
||
56 |
" |
|
57 |
! ! |
|
58 |
||
13826 | 59 |
!BrowserListWithFilter class methodsFor:'plugIn spec'! |
60 |
||
61 |
aspectSelectors |
|
62 |
||
63 |
^#( |
|
14036
ba97bd20b671
Refactoring of NavigatorModel's environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13826
diff
changeset
|
64 |
environmentHolder |
13826 | 65 |
showFilterHolder |
66 |
) |
|
67 |
||
68 |
"Created: / 11-02-2012 / 22:44:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14036
ba97bd20b671
Refactoring of NavigatorModel's environment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13826
diff
changeset
|
69 |
"Modified: / 24-02-2014 / 10:37:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13826 | 70 |
! ! |
71 |
||
15157
f71d0df9dd41
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
14036
diff
changeset
|
72 |
!BrowserListWithFilter class methodsFor:'queries'! |
f71d0df9dd41
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
14036
diff
changeset
|
73 |
|
f71d0df9dd41
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
14036
diff
changeset
|
74 |
isAbstract |
f71d0df9dd41
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
14036
diff
changeset
|
75 |
^ self == Tools::BrowserListWithFilter |
f71d0df9dd41
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
14036
diff
changeset
|
76 |
! ! |
f71d0df9dd41
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
14036
diff
changeset
|
77 |
|
10924 | 78 |
!BrowserListWithFilter methodsFor:'accessing'! |
79 |
||
80 |
filterPattern |
|
81 |
||
82 |
| p | |
|
83 |
p := filterPatternHolder value. |
|
10941 | 84 |
^p isEmptyOrNil ifTrue:[ |
10924 | 85 |
nil |
86 |
] ifFalse:[ |
|
87 |
StringPattern fromString: p |
|
88 |
] |
|
89 |
||
90 |
"Created: / 29-11-2011 / 15:23:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
91 |
! |
|
92 |
||
93 |
showFilter |
|
94 |
||
95 |
^self showFilterHolder value |
|
96 |
||
97 |
"Created: / 29-11-2011 / 15:27:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
98 |
! ! |
|
99 |
||
100 |
!BrowserListWithFilter methodsFor:'aspects'! |
|
101 |
||
102 |
filterPatternHolder |
|
103 |
"return/create the 'filterPatternHolder' value holder (automatically generated)" |
|
104 |
||
105 |
filterPatternHolder isNil ifTrue:[ |
|
106 |
filterPatternHolder := ValueHolder new. |
|
107 |
filterPatternHolder addDependent:self. |
|
108 |
]. |
|
109 |
^ filterPatternHolder |
|
110 |
! |
|
111 |
||
112 |
menuHolderWithShowFilter |
|
113 |
||
114 |
^[ |
|
115 |
| menu | |
|
10936 | 116 |
menu := self menuHolder value copy. |
10924 | 117 |
menu isArray ifTrue:[menu := Menu decodeFromLiteralArray: menu]. |
118 |
menu addSeparator. |
|
119 |
menu addItem: |
|
120 |
((MenuItem label:(self resources at: 'Show filter')) |
|
121 |
indication: self showFilterHolder; |
|
122 |
yourself). |
|
123 |
menu |
|
124 |
] |
|
125 |
||
126 |
"Created: / 29-11-2011 / 15:40:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
127 |
! |
|
128 |
||
129 |
showFilterHolder |
|
130 |
"return/create the 'showFilterHolder' value holder (automatically generated)" |
|
131 |
||
132 |
showFilterHolder isNil ifTrue:[ |
|
133 |
showFilterHolder := ValueHolder with: false. |
|
134 |
showFilterHolder addDependent:self. |
|
135 |
]. |
|
136 |
^ showFilterHolder |
|
137 |
||
138 |
"Modified: / 29-11-2011 / 15:43:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
139 |
! |
|
140 |
||
141 |
showFilterHolder:something |
|
142 |
"set the 'showFilterHolder' value holder (automatically generated)" |
|
143 |
||
144 |
|oldValue newValue| |
|
145 |
||
146 |
showFilterHolder notNil ifTrue:[ |
|
147 |
oldValue := showFilterHolder value. |
|
148 |
showFilterHolder removeDependent:self. |
|
149 |
]. |
|
150 |
showFilterHolder := something. |
|
151 |
showFilterHolder notNil ifTrue:[ |
|
152 |
showFilterHolder addDependent:self. |
|
153 |
]. |
|
154 |
newValue := showFilterHolder value. |
|
155 |
oldValue ~~ newValue ifTrue:[ |
|
156 |
self update:#value with:newValue from:showFilterHolder. |
|
157 |
]. |
|
158 |
! ! |
|
159 |
||
160 |
!BrowserListWithFilter methodsFor:'change & update'! |
|
161 |
||
162 |
update:something with:aParameter from:changedObject |
|
163 |
"Invoked when an object that I depend upon sends a change notification." |
|
164 |
||
165 |
changedObject == showFilterHolder ifTrue:[ |
|
166 |
self showFilter: showFilterHolder value. |
|
167 |
^self. |
|
168 |
]. |
|
169 |
changedObject == filterPatternHolder ifTrue:[ |
|
170 |
self enqueueDelayedUpdateList. |
|
171 |
^self |
|
172 |
]. |
|
173 |
super update:something with:aParameter from:changedObject |
|
174 |
||
175 |
"Modified: / 29-11-2011 / 15:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11562 | 176 |
"Modified (format): / 06-06-2012 / 00:01:37 / cg" |
10924 | 177 |
! ! |
178 |
||
13826 | 179 |
!BrowserListWithFilter methodsFor:'event handling-delegation'! |
180 |
||
181 |
handlesKeyPress:key inView:aView |
|
182 |
^ aView == filterView and:[key == #CursorDown] |
|
183 |
||
184 |
"Created: / 06-02-2012 / 23:02:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
185 |
! |
|
186 |
||
187 |
keyPress:key x:x y:y view:aView |
|
188 |
||
189 |
(aView == filterView and:[key == #CursorDown]) ifTrue:[ |
|
190 |
listView scrolledView notNil ifTrue:[ |
|
191 |
listView scrolledView |
|
192 |
takeFocus; |
|
193 |
keyPress: key x:x y:y. |
|
194 |
]. |
|
195 |
]. |
|
196 |
||
197 |
"Created: / 06-02-2012 / 23:06:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
198 |
"Modified: / 17-01-2013 / 21:28:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
199 |
! ! |
|
200 |
||
10924 | 201 |
!BrowserListWithFilter methodsFor:'hooks'! |
202 |
||
203 |
commonPostBuild |
|
12398
eef1be6c07b7
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
11562
diff
changeset
|
204 |
super commonPostBuild. |
10924 | 205 |
listView isNil ifTrue:[listView := builder componentAt:#List]. |
206 |
listView isNil ifTrue:[self breakPoint: #jv]. |
|
207 |
filterView isNil ifTrue:[self breakPoint: #jv]. |
|
208 |
||
18114 | 209 |
"I want to see the events of the filter" |
13826 | 210 |
filterView delegate: self. |
211 |
self showFilter: showFilterHolder value. |
|
212 |
||
10924 | 213 |
"Created: / 29-11-2011 / 14:47:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
214 |
! |
|
215 |
||
216 |
postBuildFilterView: aView |
|
217 |
||
218 |
filterView := aView |
|
219 |
||
220 |
"Created: / 29-11-2011 / 14:47:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
221 |
! |
|
222 |
||
223 |
postBuildListView: aView |
|
224 |
||
225 |
listView := aView |
|
226 |
||
227 |
"Created: / 29-11-2011 / 14:47:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
228 |
! ! |
|
229 |
||
230 |
!BrowserListWithFilter methodsFor:'private'! |
|
231 |
||
232 |
filterList: list |
|
233 |
| pattern filteredList | |
|
234 |
||
235 |
self showFilter ifFalse:[ ^ list ]. |
|
12659
f89af2fdbc11
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
12398
diff
changeset
|
236 |
|
10924 | 237 |
pattern := self filterPattern. |
238 |
pattern isNil ifTrue:[ ^ list ]. |
|
239 |
filteredList := list value select:[:each|pattern matchObject: each relax: 1]. |
|
240 |
filteredList isEmpty ifTrue:[ |
|
12659
f89af2fdbc11
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
12398
diff
changeset
|
241 |
filteredList := list value select:[:each|pattern matchObject: each relax: 2]. |
f89af2fdbc11
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
12398
diff
changeset
|
242 |
filteredList isEmpty ifTrue:[ |
f89af2fdbc11
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
12398
diff
changeset
|
243 |
filteredList := list value select:[:each|pattern matchObject: each relax: 3]. |
f89af2fdbc11
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
12398
diff
changeset
|
244 |
] |
f89af2fdbc11
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
12398
diff
changeset
|
245 |
]. |
10924 | 246 |
^filteredList |
247 |
||
248 |
"Created: / 29-11-2011 / 15:31:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
249 |
! |
|
250 |
||
251 |
showFilter: aBoolean |
|
252 |
| offset | |
|
253 |
||
13826 | 254 |
listView isNil ifTrue:[ ^ self ]. |
255 |
||
10924 | 256 |
aBoolean ifTrue:[ |
257 |
offset := filterView height. |
|
258 |
] ifFalse:[ |
|
259 |
offset := 0 |
|
260 |
]. |
|
261 |
listView layout: (listView layout copy topOffset: offset) . |
|
262 |
filterView isVisible: aBoolean |
|
263 |
||
264 |
"Created: / 29-11-2011 / 14:55:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
265 |
! ! |
|
266 |
||
267 |
!BrowserListWithFilter class methodsFor:'documentation'! |
|
268 |
||
269 |
version |
|
18009 | 270 |
^ '$Header$' |
10924 | 271 |
! |
272 |
||
273 |
version_CVS |
|
18009 | 274 |
^ '$Header$' |
10924 | 275 |
! ! |
12398
eef1be6c07b7
class: Tools::BrowserListWithFilter
Claus Gittinger <cg@exept.de>
parents:
11562
diff
changeset
|
276 |