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