author | fm |
Fri, 09 Oct 2009 13:53:55 +0200 | |
changeset 8911 | b23fd42e0da7 |
parent 8613 | 6c82076a9cbf |
child 9036 | 9242245f6689 |
permissions | -rw-r--r-- |
5140 | 1 |
" |
2 |
COPYRIGHT (c) 2002 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 |
" |
|
3892 | 12 |
"{ Package: 'stx:libtool' }" |
13 |
||
14 |
AbstractFileApplicationNoteBookComponent subclass:#FindFileApplication |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
15 |
instanceVariableNames:'searchDirectories searchDirectoryHolder notSearchForSameContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
16 |
namePatternHolder ignoreCaseInName contentsPatternHolder |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
17 |
ignoreCaseInContents notContentsPatternHolder |
5723 | 18 |
ignoreCaseInNotContents sameContentsAsHolder findFileView |
19 |
searchResultTable resultList enableStop enableSearch stopSignal |
|
20 |
accessLock searchTask expanded searchRecursively selectionHolder |
|
21 |
hasListEntries targetApplication useLocate useGrep |
|
5859 | 22 |
rememberInCache searchOnlyInCache searchForSameContents |
6107 | 23 |
matchedFilesList shownListHolder contentsInfoCache |
6330 | 24 |
contentsInfoCacheAccessLock autoSelectInBrowserHolder |
25 |
fileSizeOperatorHolder fileSizeHolder enableFileSizeFilter |
|
26 |
fileSizeUnitHolder' |
|
6442 | 27 |
classVariableNames:'ContentsInfoCache ContentsInfoCacheAccessLock LastRememberInCache |
8330 | 28 |
LastSearchIgnoredCaseInContents LastSearchIgnoredCaseInFilename |
29 |
SearchStringHistory' |
|
3892 | 30 |
poolDictionaries:'' |
31 |
category:'Interface-Tools-File' |
|
32 |
! |
|
33 |
||
5140 | 34 |
!FindFileApplication class methodsFor:'documentation'! |
35 |
||
36 |
copyright |
|
37 |
" |
|
38 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
39 |
All Rights Reserved |
|
40 |
||
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
" |
|
48 |
! ! |
|
3892 | 49 |
|
50 |
!FindFileApplication class methodsFor:'instance creation'! |
|
51 |
||
52 |
open |
|
5723 | 53 |
^ self openInDirectory:(Filename currentDirectory) |
3892 | 54 |
|
5723 | 55 |
" |
56 |
self open |
|
57 |
" |
|
58 |
! |
|
59 |
||
60 |
openInDirectory:aFilename |
|
61 |
^ self openOnFileName:(aFilename asFilename asAbsoluteFilename) |
|
62 |
||
63 |
" |
|
64 |
self openInDirectory:'/etc' |
|
65 |
" |
|
3892 | 66 |
! |
67 |
||
68 |
openOnFileName:aFileName |
|
5723 | 69 |
^ self openOnFileName:aFileName for:nil |
70 |
! |
|
71 |
||
72 |
openOnFileName:aFileName for:aTargetApplicationOrNil |
|
3892 | 73 |
|
74 |
| instance builder| |
|
75 |
||
76 |
builder := super open. |
|
77 |
instance := builder application. |
|
3983 | 78 |
instance item:(DirectoryContentsBrowser itemClass fileName:aFileName). |
5723 | 79 |
aTargetApplicationOrNil notNil ifTrue:[ |
80 |
instance targetApplication:aTargetApplicationOrNil. |
|
81 |
]. |
|
3892 | 82 |
^ builder |
83 |
! ! |
|
84 |
||
85 |
!FindFileApplication class methodsFor:'defaults'! |
|
86 |
||
87 |
tabStringFor:aApplicationType |
|
7688 | 88 |
"the formatString shown in a tab (language translated)" |
3892 | 89 |
|
7688 | 90 |
^ 'Find in %1' |
91 |
||
92 |
"Modified: / 01-03-2007 / 21:47:54 / cg" |
|
3892 | 93 |
! ! |
94 |
||
8330 | 95 |
!FindFileApplication class methodsFor:'history'! |
96 |
||
97 |
addToSearchStringHistory:aString |
|
98 |
self searchStringHistory |
|
99 |
remove:aString ifAbsent:[]; |
|
100 |
addFirst:aString. |
|
101 |
self searchStringHistory size > 25 ifTrue:[ |
|
102 |
self searchStringHistory removeLast |
|
103 |
]. |
|
104 |
! |
|
105 |
||
106 |
searchStringHistory |
|
107 |
SearchStringHistory isNil ifTrue:[ |
|
108 |
SearchStringHistory := OrderedCollection new |
|
109 |
]. |
|
110 |
^ SearchStringHistory |
|
111 |
! ! |
|
112 |
||
3892 | 113 |
!FindFileApplication class methodsFor:'interface specs'! |
114 |
||
115 |
windowSpec |
|
116 |
"This resource specification was automatically generated |
|
117 |
by the UIPainter of ST/X." |
|
118 |
||
119 |
"Do not manually edit this!! If it is corrupted, |
|
120 |
the UIPainter may not be able to read the specification." |
|
121 |
||
122 |
" |
|
123 |
UIPainter new openOnClass:FindFileApplication andSelector:#windowSpec |
|
124 |
FindFileApplication new openInterface:#windowSpec |
|
125 |
FindFileApplication open |
|
126 |
" |
|
127 |
||
128 |
<resource: #canvas> |
|
129 |
||
130 |
^ |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
131 |
#(FullSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
132 |
name: windowSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
133 |
window: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
134 |
(WindowSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
135 |
label: 'File Search' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
136 |
name: 'File Search' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
137 |
min: (Point 377 131) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
138 |
max: (Point 1280 1024) |
5850 | 139 |
bounds: (Rectangle 0 0 758 512) |
3892 | 140 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
141 |
component: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
142 |
(SpecCollection |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
143 |
collection: ( |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
144 |
(MenuPanelSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
145 |
name: 'ToolBar1' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
146 |
layout: (LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
147 |
level: 0 |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
148 |
menu: searchMenu |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
149 |
textDefault: true |
3892 | 150 |
) |
7574 | 151 |
(ProgressIndicatorSpec |
152 |
name: 'ProgressIndicator1' |
|
153 |
layout: (LayoutFrame 125 0 11 0 231 0 21 0) |
|
154 |
visibilityChannel: enableStop |
|
155 |
backgroundColor: (Color 0.0 66.999313344015 66.999313344015) |
|
156 |
showPercentage: false |
|
157 |
isActivityIndicator: true |
|
158 |
) |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
159 |
(ViewSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
160 |
name: 'Box1' |
6330 | 161 |
layout: (LayoutFrame 0 0.0 32 0 0 1.0 180 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
162 |
component: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
163 |
(SpecCollection |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
164 |
collection: ( |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
165 |
(LabelSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
166 |
label: 'Directory:' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
167 |
name: 'DirectoryLabel' |
5557 | 168 |
layout: (LayoutFrame 2 0 7 0 154 0 24 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
169 |
translateLabel: true |
5557 | 170 |
adjust: right |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
171 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
172 |
(FilenameInputFieldSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
173 |
name: 'DirectoryEntryField' |
5603 | 174 |
layout: (LayoutFrame 156 0 4 0 -315 1 24 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
175 |
model: searchDirectoryHolder |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
176 |
immediateAccept: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
177 |
acceptOnPointerLeave: false |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
178 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
179 |
(LabelSpec |
5603 | 180 |
label: 'Search Files Named:' |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
181 |
name: 'FileNameLabel' |
5723 | 182 |
layout: (LayoutFrame 2 0 31 0 154 0 48 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
183 |
translateLabel: true |
5557 | 184 |
adjust: right |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
185 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
186 |
(InputFieldSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
187 |
name: 'FileNameEntryField' |
5603 | 188 |
layout: (LayoutFrame 156 0 28 0 -315 1 48 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
189 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
190 |
model: namePatternHolder |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
191 |
immediateAccept: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
192 |
acceptOnLeave: false |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
193 |
acceptOnPointerLeave: false |
3892 | 194 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
195 |
(LabelSpec |
5557 | 196 |
label: 'Containing:' |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
197 |
name: 'ContentsLabel' |
5557 | 198 |
layout: (LayoutFrame 2 0 55 0 154 0 72 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
199 |
translateLabel: true |
5557 | 200 |
adjust: right |
3892 | 201 |
) |
8330 | 202 |
(ComboBoxSpec |
203 |
name: 'ComboBox1' |
|
5603 | 204 |
layout: (LayoutFrame 156 0 52 0 -315 1 72 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
205 |
enableChannel: notSearchForSameContents |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
206 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
207 |
model: contentsPatternHolder |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
208 |
immediateAccept: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
209 |
acceptOnPointerLeave: false |
8330 | 210 |
comboList: searchStringHistory |
3892 | 211 |
) |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
212 |
(LabelSpec |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
213 |
label: 'Not Containing:' |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
214 |
name: 'NotContentsLabel' |
5557 | 215 |
layout: (LayoutFrame 2 0 79 0 154 0 96 0) |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
216 |
translateLabel: true |
5557 | 217 |
adjust: right |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
218 |
) |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
219 |
(InputFieldSpec |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
220 |
name: 'NotContentsEntryField' |
5603 | 221 |
layout: (LayoutFrame 156 0 76 0 -315 1 96 0) |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
222 |
enableChannel: notSearchForSameContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
223 |
tabable: true |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
224 |
model: notContentsPatternHolder |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
225 |
immediateAccept: true |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
226 |
acceptOnPointerLeave: false |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
227 |
) |
5723 | 228 |
(LabelSpec |
229 |
label: 'Same Contents As:' |
|
230 |
name: 'SameContentsAsLabel' |
|
231 |
layout: (LayoutFrame 2 0 103 0 154 0 120 0) |
|
232 |
translateLabel: true |
|
233 |
adjust: right |
|
234 |
) |
|
235 |
(InputFieldSpec |
|
236 |
name: 'SameContentsAsEntryField' |
|
5743 | 237 |
layout: (LayoutFrame 156 0 100 0 -339 1 120 0) |
238 |
enableChannel: searchForSameContents |
|
5723 | 239 |
tabable: true |
240 |
model: sameContentsAsHolder |
|
241 |
immediateAccept: true |
|
242 |
acceptOnPointerLeave: false |
|
243 |
) |
|
5743 | 244 |
(CheckToggleSpec |
245 |
name: 'EnableSameContentsCheckToggle' |
|
246 |
layout: (LayoutOrigin -334 1 104 0) |
|
247 |
model: searchForSameContents |
|
248 |
isTriggerOnDown: true |
|
249 |
showLamp: false |
|
250 |
lampColor: (Color 100.0 100.0 0.0) |
|
251 |
) |
|
6330 | 252 |
(LabelSpec |
253 |
label: 'File Size:' |
|
6808 | 254 |
name: 'FileSizeLabel' |
6330 | 255 |
layout: (LayoutFrame 2 0 127 0 154 0 144 0) |
256 |
translateLabel: true |
|
257 |
adjust: right |
|
258 |
) |
|
259 |
(PopUpListSpec |
|
260 |
label: 'PopUp List' |
|
6808 | 261 |
name: 'FileSizeOperatorPopUpList' |
6330 | 262 |
layout: (LayoutFrame 157 0 124 0 212 0 144 0) |
263 |
tabable: true |
|
264 |
model: fileSizeOperatorHolder |
|
265 |
enableChannel: enableFileSizeFilterAndNotSearchForSameContents |
|
266 |
menu: |
|
8330 | 267 |
(Array |
268 |
' >' ' < ' |
|
269 |
' !!= ' ' = ' |
|
270 |
' ~ ' |
|
6330 | 271 |
) |
272 |
) |
|
273 |
(InputFieldSpec |
|
6808 | 274 |
name: 'FileSizeEntryField' |
6330 | 275 |
layout: (LayoutFrame 219 0 124 0 -430 1 144 0) |
276 |
enableChannel: enableFileSizeFilterAndNotSearchForSameContents |
|
277 |
tabable: true |
|
278 |
model: fileSizeHolder |
|
279 |
type: fileSize |
|
6808 | 280 |
immediateAccept: false |
281 |
acceptOnLeave: true |
|
282 |
acceptOnLostFocus: true |
|
283 |
acceptOnPointerLeave: true |
|
6330 | 284 |
) |
285 |
(CheckToggleSpec |
|
286 |
name: 'EnableSizeCheckToggle' |
|
287 |
layout: (LayoutOrigin -334 1 127 0) |
|
288 |
model: enableFileSizeFilter |
|
289 |
enableChannel: notSearchForSameContents |
|
290 |
isTriggerOnDown: true |
|
291 |
showLamp: false |
|
292 |
lampColor: (Color 100.0 100.0 0.0) |
|
293 |
) |
|
8330 | 294 |
(CheckBoxSpec |
295 |
label: 'Use ''locate'' Cmd' |
|
296 |
name: 'UseLocateCheckBox' |
|
297 |
layout: (LayoutFrame -309 1 5 0 -167 1 28 0) |
|
298 |
visibilityChannel: canUseLocate |
|
299 |
tabable: true |
|
300 |
model: useLocate |
|
301 |
translateLabel: true |
|
302 |
) |
|
303 |
(CheckBoxSpec |
|
304 |
label: 'Recursive' |
|
305 |
name: 'RecursiveSearchCheckBox' |
|
306 |
layout: (LayoutFrame -169 1 5 0 -4 1 28 0) |
|
307 |
tabable: true |
|
308 |
model: searchRecursively |
|
309 |
translateLabel: true |
|
310 |
) |
|
311 |
(CheckBoxSpec |
|
312 |
label: 'Directories' |
|
313 |
name: 'SearchDirectoriesCheckBox' |
|
314 |
layout: (LayoutFrame -309 1 29 0 -167 1 52 0) |
|
315 |
enableChannel: notSearchForSameContents |
|
316 |
tabable: true |
|
317 |
model: searchDirectories |
|
318 |
translateLabel: true |
|
319 |
) |
|
320 |
(CheckBoxSpec |
|
321 |
label: 'Ignore Case' |
|
322 |
name: 'IgnoreCaseInNameCheckBox' |
|
323 |
layout: (LayoutFrame -169 1 29 0 -4 1 52 0) |
|
324 |
tabable: true |
|
325 |
model: ignoreCaseInName |
|
326 |
translateLabel: true |
|
327 |
) |
|
328 |
(CheckBoxSpec |
|
329 |
label: 'Use ''grep'' Cmd' |
|
330 |
name: 'UseGrepCheckBox' |
|
331 |
layout: (LayoutFrame -309 1 53 0 -167 1 76 0) |
|
332 |
visibilityChannel: canUseGrep |
|
333 |
enableChannel: notSearchForSameContents |
|
334 |
tabable: true |
|
335 |
model: useGrep |
|
336 |
translateLabel: true |
|
337 |
) |
|
338 |
(CheckBoxSpec |
|
339 |
label: 'Ignore Case' |
|
340 |
name: 'IgnoreCaseInContentsCheckBox' |
|
341 |
layout: (LayoutFrame -169 1 53 0 -4 1 76 0) |
|
342 |
enableChannel: notSearchForSameContents |
|
343 |
tabable: true |
|
344 |
model: ignoreCaseInContents |
|
345 |
translateLabel: true |
|
346 |
) |
|
347 |
(CheckBoxSpec |
|
348 |
label: 'Ignore Case' |
|
349 |
name: 'IgnoreCaseInNotContentsCheckBox' |
|
350 |
layout: (LayoutFrame -169 1 77 0 -4 1 100 0) |
|
351 |
enableChannel: notSearchForSameContents |
|
352 |
tabable: true |
|
353 |
model: ignoreCaseInNotContents |
|
354 |
translateLabel: true |
|
355 |
) |
|
356 |
(CheckBoxSpec |
|
357 |
label: 'Cache Info' |
|
358 |
name: 'RememberInCacheCheckBox' |
|
359 |
layout: (LayoutFrame -309 1 101 0 -167 1 124 0) |
|
360 |
visibilityChannel: canUseGrep |
|
361 |
enableChannel: searchForSameContents |
|
362 |
tabable: true |
|
363 |
model: rememberInCache |
|
364 |
translateLabel: true |
|
365 |
) |
|
366 |
(ActionButtonSpec |
|
367 |
label: 'Clear Cache' |
|
368 |
name: 'ClearCacheButton' |
|
369 |
layout: (LayoutFrame -169 1 101 0 -44 1 123 0) |
|
370 |
translateLabel: true |
|
371 |
model: clearCache |
|
372 |
) |
|
3892 | 373 |
) |
374 |
||
375 |
) |
|
376 |
) |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
377 |
(SequenceViewSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
378 |
name: 'List1' |
6330 | 379 |
layout: (LayoutFrame 0 0.0 180 0 0 1.0 0 1) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
380 |
model: selectionHolder |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
381 |
menu: menu |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
382 |
hasHorizontalScrollBar: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
383 |
hasVerticalScrollBar: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
384 |
isMultiSelect: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
385 |
doubleClickSelector: fileDoubleClick: |
6808 | 386 |
valueChangeSelector: fileSelected: |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
387 |
useIndex: true |
5864 | 388 |
sequenceList: shownListHolder |
3892 | 389 |
) |
390 |
) |
|
391 |
||
392 |
) |
|
393 |
) |
|
6330 | 394 |
|
3892 | 395 |
! ! |
396 |
||
397 |
!FindFileApplication class methodsFor:'menu specs'! |
|
398 |
||
399 |
menu |
|
400 |
"This resource specification was automatically generated |
|
401 |
by the MenuEditor of ST/X." |
|
402 |
||
403 |
"Do not manually edit this!! If it is corrupted, |
|
404 |
the MenuEditor may not be able to read the specification." |
|
405 |
||
406 |
" |
|
407 |
MenuEditor new openOnClass:FindFileApplication andSelector:#menu |
|
408 |
(Menu new fromLiteralArrayEncoding:(FindFileApplication menu)) startUp |
|
409 |
" |
|
410 |
||
411 |
<resource: #menu> |
|
412 |
||
413 |
^ |
|
5766 | 414 |
#(Menu |
415 |
( |
|
416 |
(MenuItem |
|
417 |
enabled: hasOneFileSelected |
|
7323 | 418 |
label: 'Open in New File Browser' |
419 |
itemValue: openInNewBrowser |
|
420 |
translateLabel: true |
|
421 |
) |
|
422 |
(MenuItem |
|
423 |
enabled: hasOneFileSelected |
|
5766 | 424 |
label: 'Select in Browser' |
425 |
itemValue: selectInBrowser |
|
426 |
translateLabel: true |
|
427 |
isVisible: isEmbeddedApplication |
|
3892 | 428 |
) |
5766 | 429 |
(MenuItem |
6158 | 430 |
label: 'Autoselect in Browser' |
431 |
translateLabel: true |
|
432 |
indication: autoSelectInBrowserHolder |
|
433 |
) |
|
434 |
(MenuItem |
|
5766 | 435 |
label: '-' |
436 |
) |
|
437 |
(MenuItem |
|
8613 | 438 |
enabled: hasOneFileSelected |
439 |
label: 'FileIn' |
|
440 |
itemValue: fileInInBrowser |
|
441 |
translateLabel: true |
|
442 |
) |
|
443 |
(MenuItem |
|
444 |
label: '-' |
|
445 |
) |
|
446 |
(MenuItem |
|
5766 | 447 |
enabled: hasSelectionInResultList |
448 |
label: 'Copy Selected Filenames to Clipboard' |
|
449 |
itemValue: copySelectedFileNamesToClipboard |
|
450 |
translateLabel: true |
|
451 |
) |
|
452 |
(MenuItem |
|
453 |
label: '-' |
|
3892 | 454 |
) |
5766 | 455 |
(MenuItem |
5859 | 456 |
enabled: hasListEntries |
457 |
label: 'Delete all Files' |
|
458 |
itemValue: deleteAllFiles |
|
459 |
translateLabel: true |
|
460 |
) |
|
461 |
(MenuItem |
|
5766 | 462 |
enabled: hasSelection |
5767 | 463 |
label: 'Delete Selected Files' |
5766 | 464 |
itemValue: deleteSelectedFiles |
465 |
translateLabel: true |
|
466 |
) |
|
467 |
(MenuItem |
|
468 |
label: '-' |
|
3892 | 469 |
) |
5766 | 470 |
(MenuItem |
471 |
enabled: hasSelection |
|
5767 | 472 |
label: 'Remove Selected from Resultlist' |
5766 | 473 |
itemValue: removeSelectedFilesFromResultList |
474 |
translateLabel: true |
|
475 |
) |
|
476 |
(MenuItem |
|
477 |
enabled: hasListEntries |
|
7691 | 478 |
label: 'Clear Resultlist' |
5766 | 479 |
itemValue: clearResultList |
480 |
translateLabel: true |
|
3892 | 481 |
) |
5859 | 482 |
(MenuItem |
483 |
label: '-' |
|
484 |
) |
|
485 |
(MenuItem |
|
7691 | 486 |
label: 'Show Matched Files (After SameContents-Search)' |
5859 | 487 |
itemValue: showMatchedFiles: |
488 |
translateLabel: true |
|
489 |
isVisible: notShowingMatchedFiles |
|
490 |
argument: true |
|
491 |
) |
|
492 |
(MenuItem |
|
7691 | 493 |
label: 'Show Matching Files (After SameContents-Search)' |
5859 | 494 |
itemValue: showMatchedFiles: |
495 |
translateLabel: true |
|
496 |
isVisible: showingMatchedFiles |
|
497 |
argument: false |
|
498 |
) |
|
3892 | 499 |
) |
500 |
nil |
|
501 |
nil |
|
502 |
) |
|
7323 | 503 |
|
7691 | 504 |
"Modified: / 01-03-2007 / 22:56:59 / cg" |
3892 | 505 |
! |
506 |
||
507 |
searchMenu |
|
508 |
"This resource specification was automatically generated |
|
509 |
by the MenuEditor of ST/X." |
|
510 |
||
511 |
"Do not manually edit this!! If it is corrupted, |
|
512 |
the MenuEditor may not be able to read the specification." |
|
513 |
||
514 |
" |
|
515 |
MenuEditor new openOnClass:FindFileApplication andSelector:#searchMenu |
|
516 |
(Menu new fromLiteralArrayEncoding:(FindFileApplication searchMenu)) startUp |
|
517 |
" |
|
518 |
||
519 |
<resource: #menu> |
|
520 |
||
521 |
^ |
|
7574 | 522 |
#(Menu |
523 |
( |
|
524 |
(MenuItem |
|
525 |
label: 'Search' |
|
526 |
itemValue: doSearch |
|
527 |
translateLabel: true |
|
528 |
isButton: true |
|
529 |
labelImage: (ResourceRetriever ToolbarIconLibrary searchFileIcon) |
|
3892 | 530 |
) |
7574 | 531 |
(MenuItem |
532 |
enabled: enableStop |
|
533 |
label: 'Stop' |
|
534 |
itemValue: stop |
|
535 |
translateLabel: true |
|
536 |
isButton: true |
|
537 |
isVisible: enableStop |
|
538 |
labelImage: (ResourceRetriever XPToolbarIconLibrary stop22x22Icon) |
|
3892 | 539 |
) |
7574 | 540 |
(MenuItem |
541 |
label: 'Close' |
|
542 |
itemValue: doClose |
|
543 |
translateLabel: true |
|
544 |
isButton: true |
|
545 |
startGroup: right |
|
546 |
labelImage: (ResourceRetriever ToolbarIconLibrary removeTabIcon) |
|
3892 | 547 |
) |
548 |
) |
|
549 |
nil |
|
550 |
nil |
|
551 |
) |
|
552 |
! ! |
|
553 |
||
6107 | 554 |
!FindFileApplication class methodsFor:'startup & release'! |
555 |
||
556 |
releaseContentsInfoCache |
|
557 |
ContentsInfoCache := ContentsInfoCacheAccessLock := nil. |
|
558 |
! ! |
|
559 |
||
3892 | 560 |
!FindFileApplication class methodsFor:'tableColumns specs'! |
561 |
||
562 |
searchResultTable |
|
563 |
"This resource specification was automatically generated |
|
564 |
by the DataSetBuilder of ST/X." |
|
565 |
||
566 |
"Do not manually edit this!! If it is corrupted, |
|
567 |
the DataSetBuilder may not be able to read the specification." |
|
568 |
||
569 |
" |
|
570 |
DataSetBuilder new openOnClass:FindFileApplication andSelector:#searchResultTable |
|
571 |
" |
|
572 |
||
573 |
<resource: #tableColumns> |
|
574 |
||
575 |
^#( |
|
6583 | 576 |
(DataSetColumnSpec |
577 |
label: 'Filename' |
|
578 |
id: 'FileName' |
|
579 |
labelButtonType: Button |
|
580 |
model: fileName |
|
581 |
showRowSeparator: false |
|
582 |
showColSeparator: false |
|
3892 | 583 |
) |
584 |
) |
|
585 |
||
586 |
! ! |
|
587 |
||
588 |
!FindFileApplication methodsFor:'accessing'! |
|
589 |
||
590 |
accessLock |
|
591 |
"return the value of the instance variable 'accessLock' (automatically generated)" |
|
592 |
||
593 |
accessLock isNil ifTrue:[ |
|
594 |
accessLock := Semaphore forMutualExclusion name:'accessLock'. |
|
595 |
]. |
|
596 |
^ accessLock |
|
597 |
! |
|
598 |
||
599 |
stopSignal |
|
600 |
||
601 |
stopSignal isNil ifTrue:[ |
|
602 |
stopSignal := Signal new. |
|
603 |
]. |
|
604 |
^ stopSignal |
|
4101 | 605 |
! |
606 |
||
607 |
targetApplication:something |
|
608 |
"set the value of the instance variable 'targetApplication' (automatically generated)" |
|
609 |
||
610 |
targetApplication := something. |
|
3892 | 611 |
! ! |
612 |
||
613 |
!FindFileApplication methodsFor:'actions'! |
|
614 |
||
615 |
changeInformationTo:aString |
|
616 |
||
617 |
self changeInformationTo:aString toTab:false |
|
618 |
! |
|
619 |
||
620 |
changeInformationTo:aString toTab:aBoolean |
|
621 |
masterApplication isNil ifTrue:[ |
|
622 |
findFileView label:aString |
|
623 |
] ifFalse:[ |
|
624 |
aBoolean ifTrue:[ |
|
625 |
masterApplication tabStringChangeTo:aString for:self |
|
626 |
] |
|
627 |
]. |
|
628 |
! |
|
629 |
||
5850 | 630 |
clearCache |
6107 | 631 |
contentsInfoCache := nil |
5850 | 632 |
! |
633 |
||
5766 | 634 |
clearResultList |
635 |
self resultList removeAll. |
|
5859 | 636 |
self matchedFilesList removeAll. |
637 |
! |
|
638 |
||
639 |
clearShownList |
|
5864 | 640 |
self shownList removeAll. |
5766 | 641 |
! |
642 |
||
643 |
copySelectedFileNamesToClipboard |
|
3892 | 644 |
|sel list stream| |
645 |
||
646 |
sel := self selectionHolder value. |
|
5859 | 647 |
list := self shownList. |
6482
00207f456339
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
6442
diff
changeset
|
648 |
(sel notEmptyOrNil) ifTrue:[ |
3892 | 649 |
stream := WriteStream on:''. |
650 |
sel do:[: key | |
|
651 |
stream nextPutAll:(list at:key). |
|
652 |
stream cr. |
|
653 |
]. |
|
6038
ed07ac0069b2
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
5961
diff
changeset
|
654 |
self window setClipboardText:stream contents. |
3892 | 655 |
stream close. |
656 |
]. |
|
657 |
! |
|
658 |
||
5766 | 659 |
deleteAllFiles |
660 |
|files| |
|
661 |
||
5864 | 662 |
files := self shownList copy. |
5766 | 663 |
self deleteFiles:files confirm:true. |
5859 | 664 |
self clearShownList. |
5766 | 665 |
! |
666 |
||
667 |
deleteFiles:colOfFiles confirm:confirm |
|
668 |
"delete current selected files/directories |
|
669 |
" |
|
670 |
|delete result| |
|
671 |
||
6832
c69c570a3ec7
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6822
diff
changeset
|
672 |
"/ self windowGroup withWaitCursorDo:[ |
5961 | 673 |
delete := FileOperation deleteFiles:(colOfFiles asSet) confirm:confirm. |
5766 | 674 |
result := delete result. |
675 |
result notNil ifTrue:[ |
|
676 |
result ifFalse:[ |
|
677 |
self notify:delete errorString. |
|
678 |
] ifTrue:[ |
|
5769 | 679 |
"/ masterApplication notNil ifTrue:[ |
680 |
"/ masterApplication updateListAfterDelete:colOfFiles. |
|
681 |
"/ ] |
|
5766 | 682 |
] |
683 |
]. |
|
6832
c69c570a3ec7
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6822
diff
changeset
|
684 |
"/ ]. |
5766 | 685 |
^ result. |
6832
c69c570a3ec7
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6822
diff
changeset
|
686 |
|
c69c570a3ec7
wait-cursor -> activity indication
Claus Gittinger <cg@exept.de>
parents:
6822
diff
changeset
|
687 |
"Modified: / 25-07-2006 / 09:11:09 / cg" |
5766 | 688 |
! |
689 |
||
690 |
deleteSelectedFiles |
|
5856 | 691 |
|sel files result| |
5766 | 692 |
|
693 |
sel := self selectionHolder value. |
|
6109 | 694 |
sel isEmptyOrNil ifTrue:[^ self]. |
695 |
||
5864 | 696 |
files := sel collect:[:idx | self shownList at:idx]. |
5766 | 697 |
self deleteFiles:files confirm:true. |
5856 | 698 |
result == true ifTrue:[ |
699 |
self removeSelectedFilesFromResultList. |
|
700 |
]. |
|
5766 | 701 |
! |
702 |
||
3892 | 703 |
doSearch |
704 |
||
5864 | 705 |
| namePattern namePatterns contentsPattern notContentsPattern dir fileToCompareAgainst thisSearchTask| |
3892 | 706 |
|
707 |
"/ self changeExtentToSeeSearchResult. |
|
708 |
||
709 |
dir := self searchDirectoryHolder value. |
|
710 |
dir isNil ifTrue:[ |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
711 |
Dialog warn:'Missing directory name'. |
3892 | 712 |
^ self. |
713 |
]. |
|
6250
5b0673ccff1c
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
6183
diff
changeset
|
714 |
dir asFilename exists ifFalse:[ |
5786
3ae2d45d823f
care for whitespace in searchpattern
Claus Gittinger <cg@exept.de>
parents:
5776
diff
changeset
|
715 |
Dialog warn:('No such directory: ''%1''' bindWith:dir asString allBold). |
3892 | 716 |
^ self. |
717 |
]. |
|
6442 | 718 |
|
719 |
LastSearchIgnoredCaseInFilename := ignoreCaseInName value. |
|
720 |
LastSearchIgnoredCaseInContents := ignoreCaseInContents value. |
|
721 |
||
3892 | 722 |
searchTask notNil ifTrue:[ |
723 |
(Dialog |
|
6355 | 724 |
confirm:(resources stringWithCRs:'There is already another find-file task running !!') |
6633 | 725 |
yesLabel:(resources string:'Stop other Task and Proceed') |
726 |
noLabel:(resources string:'Cancel')) |
|
3892 | 727 |
ifFalse:[^ self]. |
728 |
self stop. |
|
729 |
]. |
|
730 |
||
731 |
namePattern := self namePatternHolder value. |
|
732 |
namePattern size == 0 ifTrue:[ |
|
733 |
namePatterns := nil |
|
734 |
] ifFalse:[ |
|
735 |
ignoreCaseInName value ifTrue:[ |
|
736 |
namePattern := namePattern asLowercase |
|
737 |
]. |
|
5786
3ae2d45d823f
care for whitespace in searchpattern
Claus Gittinger <cg@exept.de>
parents:
5776
diff
changeset
|
738 |
namePatterns := namePattern asCollectionOfSubstringsSeparatedBy:$;. |
3ae2d45d823f
care for whitespace in searchpattern
Claus Gittinger <cg@exept.de>
parents:
5776
diff
changeset
|
739 |
namePatterns := namePatterns collect:[:each | each withoutSeparators]. |
3892 | 740 |
]. |
741 |
contentsPattern := self contentsPatternHolder value. |
|
742 |
contentsPattern size == 0 ifTrue:[ |
|
743 |
contentsPattern := nil |
|
744 |
] ifFalse:[ |
|
8330 | 745 |
self class addToSearchStringHistory:contentsPattern. |
3892 | 746 |
self ignoreCaseInContents value ifTrue:[ |
747 |
contentsPattern := contentsPattern asLowercase |
|
8330 | 748 |
]. |
3892 | 749 |
]. |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
750 |
notContentsPattern := self notContentsPatternHolder value. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
751 |
notContentsPattern size == 0 ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
752 |
notContentsPattern := nil |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
753 |
] ifFalse:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
754 |
self ignoreCaseInNotContents value ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
755 |
notContentsPattern := notContentsPattern asLowercase |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
756 |
] |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
757 |
]. |
5787 | 758 |
searchForSameContents value ifTrue:[ |
759 |
fileToCompareAgainst := (self sameContentsAsHolder value ? '') withoutSeparators. |
|
760 |
fileToCompareAgainst isEmpty ifTrue:[ |
|
761 |
fileToCompareAgainst := nil. |
|
762 |
] ifFalse:[ |
|
763 |
fileToCompareAgainst includesMatchCharacters ifFalse:[ |
|
764 |
fileToCompareAgainst asFilename exists ifFalse:[ |
|
765 |
Dialog warn:('No such file: %1' bindWith:fileToCompareAgainst asString allBold). |
|
766 |
^ self. |
|
767 |
]. |
|
768 |
fileToCompareAgainst asFilename isReadable ifFalse:[ |
|
769 |
Dialog warn:('Cannot read: %1' bindWith:fileToCompareAgainst asString allBold). |
|
770 |
^ self. |
|
771 |
] |
|
5768 | 772 |
]. |
5726 | 773 |
]. |
5723 | 774 |
]. |
775 |
||
5864 | 776 |
searchTask := thisSearchTask := |
5776 | 777 |
[ |
778 |
|message t| |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
779 |
|
5776 | 780 |
[ |
781 |
(self stopSignal) catch:[ |
|
782 |
self enableStop value:true. |
|
783 |
self resultList removeAll. |
|
5859 | 784 |
self matchedFilesList removeAll. |
5776 | 785 |
self changeInformationTo:'Find File ' , '- searching ' toTab:true. |
6808 | 786 |
self notify:'Searching...'. |
5776 | 787 |
t := Time millisecondsToRun:[ |
5770 | 788 |
|
5776 | 789 |
self |
790 |
doFindFileNamed:namePatterns |
|
791 |
directories:(self searchDirectories value) |
|
792 |
ignoreCase:(self ignoreCaseInName value) |
|
793 |
containingString:contentsPattern |
|
794 |
ignoreCaseInContents:(self ignoreCaseInContents value) |
|
795 |
notContainingString:notContentsPattern |
|
796 |
ignoreCaseInNotContents:(self ignoreCaseInNotContents value) |
|
797 |
sameContentsAsFile:fileToCompareAgainst |
|
798 |
sameContentsAs:nil |
|
799 |
in:(self searchDirectoryHolder value). |
|
5770 | 800 |
|
5776 | 801 |
]. |
802 |
t > 100 ifTrue:[ |
|
803 |
t := ((t / 1000) asFixedPoint:2) printString , ' s' |
|
804 |
] ifFalse:[ |
|
805 |
t := t printString , ' ms' |
|
806 |
]. |
|
807 |
message := 'Found %1 file%2 in %3' bindWith:(resultList size) with:(resultList size == 1 ifTrue:'' ifFalse:'s') with:t. |
|
808 |
self enableStop value:false. |
|
809 |
self enableSearch value:true. |
|
810 |
self changeInformationTo:'Find File ' , '- done.' toTab:true. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
811 |
]. |
6154 | 812 |
] ensure:[ |
5864 | 813 |
thisSearchTask == searchTask ifTrue:[ |
814 |
searchTask := nil. |
|
815 |
self enableStop value:false. |
|
816 |
self notify:message. |
|
817 |
]. |
|
5776 | 818 |
] |
819 |
] newProcess. |
|
3892 | 820 |
|
5776 | 821 |
searchTask priorityRange:(Processor systemBackgroundPriority to:Processor userSchedulingPriority). |
3892 | 822 |
searchTask name:('FindFile[', self searchDirectoryHolder value asFilename baseName, ']'). |
823 |
searchTask resume. |
|
6808 | 824 |
|
825 |
"Modified: / 04-07-2006 / 11:34:21 / cg" |
|
3892 | 826 |
! |
827 |
||
7323 | 828 |
fileInInBrowser |
829 |
|sel entry application| |
|
830 |
||
831 |
sel := self selectionHolder value. |
|
832 |
(sel notEmptyOrNil) ifTrue:[ |
|
833 |
entry := self shownList at:sel first. |
|
834 |
entry asFilename exists ifFalse:[ ^ self]. |
|
835 |
application := targetApplication ? self masterApplication. |
|
836 |
application notNil ifTrue:[ |
|
837 |
application fileIn:(entry asFilename). |
|
838 |
]. |
|
839 |
]. |
|
840 |
||
841 |
"Created: / 20-09-2006 / 14:30:37 / cg" |
|
842 |
! |
|
843 |
||
3892 | 844 |
openInNewBrowser |
845 |
|sel| |
|
846 |
||
847 |
sel := self selectionHolder value. |
|
6482
00207f456339
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
6442
diff
changeset
|
848 |
(sel notEmptyOrNil) ifTrue:[ |
5859 | 849 |
FileBrowserV2 openOn:(self shownList at:sel first) asFilename |
3892 | 850 |
]. |
851 |
! |
|
852 |
||
5766 | 853 |
removeSelectedFilesFromResultList |
3892 | 854 |
|sel list| |
855 |
||
856 |
sel := self selectionHolder value. |
|
5864 | 857 |
list := self shownList. |
6482
00207f456339
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
6442
diff
changeset
|
858 |
(sel notEmptyOrNil) ifTrue:[ |
3892 | 859 |
sel reverseDo:[: key | |
860 |
list removeAtIndex:key |
|
861 |
] |
|
862 |
]. |
|
863 |
! |
|
864 |
||
865 |
selectInBrowser |
|
866 |
|sel entry application| |
|
867 |
||
868 |
sel := self selectionHolder value. |
|
6482
00207f456339
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
6442
diff
changeset
|
869 |
(sel notEmptyOrNil) ifTrue:[ |
5859 | 870 |
entry := self shownList at:sel first. |
5252 | 871 |
entry asFilename exists ifFalse:[ ^ self]. |
4101 | 872 |
application := targetApplication ? self masterApplication. |
4182 | 873 |
application notNil ifTrue:[ |
4101 | 874 |
application gotoFile:(entry asFilename). |
875 |
]. |
|
3892 | 876 |
]. |
877 |
! |
|
878 |
||
5859 | 879 |
showMatchedFiles:aBoolean |
880 |
aBoolean ifTrue:[ |
|
5864 | 881 |
self shownListHolder valueHolder:(self matchedFilesList) |
5859 | 882 |
] ifFalse:[ |
5864 | 883 |
self shownListHolder valueHolder:(self resultList) |
5859 | 884 |
]. |
885 |
! |
|
886 |
||
3892 | 887 |
stop |
888 |
||
889 |
searchTask notNil ifTrue:[ |
|
890 |
self accessLock critical:[ |
|
891 |
searchTask interruptWith:[stopSignal raiseRequest]. |
|
892 |
] |
|
893 |
]. |
|
894 |
self enableStop value:false. |
|
895 |
self enableSearch value:true. |
|
896 |
self changeInformationTo:'Find File ' , '- search stopped' toTab:true. |
|
897 |
! |
|
898 |
||
899 |
stopSearchTask |
|
900 |
|task| |
|
901 |
||
902 |
(task := searchTask) notNil ifTrue:[ |
|
903 |
searchTask := nil. |
|
904 |
||
905 |
Object errorSignal handle:[:ex| |
|
906 |
Dialog warn:ex description. |
|
907 |
]do:[ |
|
908 |
task isDead ifFalse:[ |
|
3937
80d958725879
terminateWithAllSUbprocesses -> xxxInGroup
Claus Gittinger <cg@exept.de>
parents:
3892
diff
changeset
|
909 |
task terminateWithAllSubprocessesInGroup. |
3892 | 910 |
task waitUntilTerminated. |
911 |
] |
|
912 |
] |
|
913 |
]. |
|
914 |
! ! |
|
915 |
||
916 |
!FindFileApplication methodsFor:'aspects'! |
|
917 |
||
5856 | 918 |
autoSelectInBrowser |
6330 | 919 |
^ self autoSelectInBrowserHolder value. |
6158 | 920 |
! |
921 |
||
922 |
autoSelectInBrowserHolder |
|
923 |
autoSelectInBrowserHolder isNil ifTrue:[ |
|
924 |
autoSelectInBrowserHolder := false asValue. |
|
925 |
]. |
|
926 |
^ autoSelectInBrowserHolder. |
|
5856 | 927 |
! |
928 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
929 |
canUseGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
930 |
"grep command is much faster, but: |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
931 |
- not under MSDOS |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
932 |
" |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
933 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
934 |
^ OperatingSystem isUNIXlike and:[ OperatingSystem canExecuteCommand:'egrep' ] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
935 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
936 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
937 |
canUseLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
938 |
"locate command is much faster, but: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
939 |
- only if searching recursively, |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
940 |
- no case ignore |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
941 |
- no contents matching |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
942 |
" |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
943 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
944 |
^ OperatingSystem isUNIXlike and:[ OperatingSystem canExecuteCommand:'locate' ] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
945 |
! |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
946 |
|
3892 | 947 |
contentsPatternHolder |
948 |
||
949 |
contentsPatternHolder isNil ifTrue:[ |
|
950 |
contentsPatternHolder := nil asValue. |
|
8330 | 951 |
self class searchStringHistory size > 0 ifTrue:[ |
952 |
contentsPatternHolder value:(self class searchStringHistory first). |
|
953 |
]. |
|
3892 | 954 |
]. |
955 |
^ contentsPatternHolder. |
|
956 |
! |
|
957 |
||
6330 | 958 |
enableFileSizeFilter |
959 |
enableFileSizeFilter isNil ifTrue:[ |
|
960 |
enableFileSizeFilter := false asValue. |
|
961 |
]. |
|
962 |
^ enableFileSizeFilter. |
|
963 |
! |
|
964 |
||
965 |
enableFileSizeFilterAndNotSearchForSameContents |
|
966 |
^ BlockValue forLogical:self notSearchForSameContents and:self enableFileSizeFilter |
|
967 |
! |
|
968 |
||
3892 | 969 |
enableSearch |
970 |
||
971 |
enableSearch isNil ifTrue:[ |
|
972 |
enableSearch := true asValue. |
|
973 |
]. |
|
974 |
^ enableSearch. |
|
975 |
! |
|
976 |
||
977 |
enableStop |
|
978 |
||
979 |
enableStop isNil ifTrue:[ |
|
980 |
enableStop := true asValue. |
|
981 |
]. |
|
982 |
^ enableStop. |
|
983 |
! |
|
984 |
||
6330 | 985 |
fileSizeHolder |
986 |
fileSizeHolder isNil ifTrue:[ |
|
987 |
fileSizeHolder := 0 asValue. |
|
988 |
]. |
|
989 |
^ fileSizeHolder. |
|
990 |
! |
|
991 |
||
992 |
fileSizeOperatorHolder |
|
993 |
fileSizeOperatorHolder isNil ifTrue:[ |
|
994 |
fileSizeOperatorHolder := '>' asValue. |
|
995 |
]. |
|
996 |
^ fileSizeOperatorHolder. |
|
997 |
! |
|
998 |
||
999 |
fileSizeUnitHolder |
|
1000 |
fileSizeUnitHolder isNil ifTrue:[ |
|
1001 |
fileSizeUnitHolder := 'b' asValue. |
|
1002 |
]. |
|
1003 |
^ fileSizeUnitHolder. |
|
1004 |
! |
|
1005 |
||
3892 | 1006 |
hasListEntries |
1007 |
||
1008 |
hasListEntries isNil ifTrue:[ |
|
1009 |
hasListEntries := false asValue. |
|
1010 |
]. |
|
1011 |
^ hasListEntries. |
|
1012 |
! |
|
1013 |
||
1014 |
ignoreCaseInContents |
|
1015 |
ignoreCaseInContents isNil ifTrue:[ |
|
6442 | 1016 |
ignoreCaseInContents := (LastSearchIgnoredCaseInContents |
1017 |
? TextView lastSearchIgnoredCase |
|
1018 |
? true) asValue. |
|
3892 | 1019 |
]. |
1020 |
^ ignoreCaseInContents. |
|
1021 |
! |
|
1022 |
||
1023 |
ignoreCaseInName |
|
1024 |
||
1025 |
ignoreCaseInName isNil ifTrue:[ |
|
6442 | 1026 |
ignoreCaseInName := (LastSearchIgnoredCaseInFilename |
1027 |
? OperatingSystem caseSensitiveFilenames not) asValue. |
|
3892 | 1028 |
]. |
1029 |
^ ignoreCaseInName. |
|
1030 |
! |
|
1031 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1032 |
ignoreCaseInNotContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1033 |
ignoreCaseInNotContents isNil ifTrue:[ |
6442 | 1034 |
ignoreCaseInNotContents := (LastSearchIgnoredCaseInContents |
1035 |
? TextView lastSearchIgnoredCase |
|
1036 |
? true) asValue. |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1037 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1038 |
^ ignoreCaseInNotContents. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1039 |
! |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1040 |
|
5859 | 1041 |
matchedFilesList |
1042 |
||
1043 |
matchedFilesList isNil ifTrue:[ |
|
1044 |
matchedFilesList := List new. |
|
1045 |
matchedFilesList addDependent:self. |
|
1046 |
]. |
|
1047 |
^ matchedFilesList. |
|
1048 |
! |
|
1049 |
||
3892 | 1050 |
namePatternHolder |
1051 |
||
1052 |
namePatternHolder isNil ifTrue:[ |
|
1053 |
namePatternHolder := '*' asValue. |
|
1054 |
]. |
|
1055 |
^ namePatternHolder. |
|
1056 |
! |
|
1057 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1058 |
notContentsPatternHolder |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1059 |
notContentsPatternHolder isNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1060 |
notContentsPatternHolder := nil asValue. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1061 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1062 |
^ notContentsPatternHolder. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1063 |
! |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1064 |
|
3892 | 1065 |
notSearchForSameContents |
5743 | 1066 |
^ BlockValue forLogicalNot:self searchForSameContents |
3892 | 1067 |
! |
1068 |
||
5859 | 1069 |
notShowingMatchedFiles |
5865 | 1070 |
^ self shownList == self resultList |
5859 | 1071 |
! |
1072 |
||
5723 | 1073 |
rememberInCache |
1074 |
rememberInCache isNil ifTrue:[ |
|
5859 | 1075 |
rememberInCache := (LastRememberInCache ? false) asValue. |
5723 | 1076 |
]. |
1077 |
^ rememberInCache. |
|
1078 |
! |
|
1079 |
||
3892 | 1080 |
resultList |
1081 |
resultList isNil ifTrue:[ |
|
1082 |
resultList := List new. |
|
1083 |
resultList addDependent:self. |
|
1084 |
]. |
|
1085 |
^ resultList. |
|
1086 |
! |
|
1087 |
||
5723 | 1088 |
sameContentsAsHolder |
1089 |
|sel| |
|
1090 |
||
1091 |
sameContentsAsHolder isNil ifTrue:[ |
|
1092 |
sameContentsAsHolder := ValueHolder new. |
|
1093 |
masterApplication notNil ifTrue:[ |
|
1094 |
sel := masterApplication currentSelectedFiles. |
|
1095 |
sel size > 0 ifTrue:[ |
|
1096 |
sameContentsAsHolder value:(sel first asFilename pathName). |
|
1097 |
]. |
|
1098 |
]. |
|
1099 |
]. |
|
1100 |
^ sameContentsAsHolder. |
|
1101 |
! |
|
1102 |
||
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1103 |
searchDirectories |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1104 |
searchDirectories isNil ifTrue:[ |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1105 |
searchDirectories := false asValue. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1106 |
]. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1107 |
^ searchDirectories. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1108 |
! |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1109 |
|
3892 | 1110 |
searchDirectoryHolder |
1111 |
||
1112 |
searchDirectoryHolder isNil ifTrue:[ |
|
1113 |
searchDirectoryHolder := ValueHolder new. |
|
1114 |
]. |
|
1115 |
^ searchDirectoryHolder. |
|
1116 |
! |
|
1117 |
||
5743 | 1118 |
searchForSameContents |
1119 |
searchForSameContents isNil ifTrue:[ |
|
1120 |
searchForSameContents := false asValue. |
|
1121 |
]. |
|
1122 |
^ searchForSameContents. |
|
1123 |
! |
|
1124 |
||
5726 | 1125 |
searchOnlyInCache |
1126 |
searchOnlyInCache isNil ifTrue:[ |
|
1127 |
searchOnlyInCache := false asValue. |
|
1128 |
]. |
|
1129 |
^ searchOnlyInCache. |
|
1130 |
! |
|
1131 |
||
3892 | 1132 |
searchRecursively |
1133 |
||
1134 |
searchRecursively isNil ifTrue:[ |
|
1135 |
searchRecursively := true asValue. |
|
1136 |
]. |
|
1137 |
^ searchRecursively. |
|
1138 |
! |
|
1139 |
||
1140 |
searchResultTable |
|
1141 |
||
1142 |
searchResultTable isNil ifTrue:[ |
|
1143 |
searchResultTable := self class searchResultTable asValue. |
|
1144 |
]. |
|
1145 |
^ searchResultTable. |
|
1146 |
! |
|
1147 |
||
1148 |
selectionHolder |
|
1149 |
||
1150 |
selectionHolder isNil ifTrue:[ |
|
4101 | 1151 |
selectionHolder := ValueHolder new. |
1152 |
selectionHolder addDependent:self. |
|
3892 | 1153 |
]. |
1154 |
^ selectionHolder |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1155 |
! |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1156 |
|
5859 | 1157 |
showingMatchedFiles |
5865 | 1158 |
^ self shownList == self matchedFilesList |
5859 | 1159 |
! |
1160 |
||
1161 |
shownList |
|
5864 | 1162 |
^ self shownListHolder valueHolder. |
1163 |
! |
|
1164 |
||
1165 |
shownListHolder |
|
1166 |
shownListHolder isNil ifTrue:[ |
|
1167 |
shownListHolder := IndirectValue for:(self resultList). |
|
1168 |
shownListHolder addDependent:self. |
|
5859 | 1169 |
]. |
5864 | 1170 |
^ shownListHolder. |
5859 | 1171 |
! |
1172 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1173 |
useGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1174 |
useGrep isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1175 |
useGrep := false asValue. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1176 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1177 |
^ useGrep. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1178 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1179 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1180 |
useLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1181 |
useLocate isNil ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1182 |
useLocate := false asValue. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1183 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1184 |
^ useLocate. |
3892 | 1185 |
! ! |
1186 |
||
1187 |
!FindFileApplication methodsFor:'change & update'! |
|
1188 |
||
1189 |
update:something with:aParameter from:changedObject |
|
5864 | 1190 |
changedObject == self shownListHolder ifTrue:[ |
5859 | 1191 |
self hasListEntries value:(changedObject valueHolder notEmpty). |
3892 | 1192 |
^ self |
1193 |
]. |
|
4101 | 1194 |
changedObject == self selectionHolder ifTrue:[ |
5856 | 1195 |
self autoSelectInBrowser ifTrue:[ |
1196 |
self selectInBrowser. |
|
1197 |
]. |
|
4101 | 1198 |
^ self |
1199 |
]. |
|
3892 | 1200 |
super update:something with:aParameter from:changedObject |
1201 |
! ! |
|
1202 |
||
1203 |
!FindFileApplication methodsFor:'event handling'! |
|
1204 |
||
4101 | 1205 |
fileDoubleClick:entries |
5677
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1206 |
|file fn app openedAppl contentsPattern| |
4101 | 1207 |
|
5859 | 1208 |
file := self shownList at:entries first. |
5677
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1209 |
fn := file asFilename. |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1210 |
fn exists ifFalse:[ |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1211 |
Dialog warn:('File %1 does not (no longer ?) exist.' bindWith:file allBold). |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1212 |
^ self |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1213 |
]. |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1214 |
|
4101 | 1215 |
app := targetApplication ? self masterApplication. |
5279 | 1216 |
file asFilename isDirectory ifTrue:[ |
1217 |
app gotoFile:(file asFilename). |
|
1218 |
^ self. |
|
1219 |
]. |
|
4101 | 1220 |
app notNil ifTrue:[ |
4145
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1221 |
openedAppl := app openApplForFile:file. |
5279 | 1222 |
(openedAppl notNil and:[openedAppl isTextEditor]) ifTrue:[ |
4145
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1223 |
contentsPattern := self contentsPatternHolder value. |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1224 |
(contentsPattern notNil and:[ contentsPattern notEmpty and:[contentsPattern ~= '*']]) ifTrue:[ |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1225 |
openedAppl searchForPattern:contentsPattern ignoreCase:(self ignoreCaseInContents value). |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1226 |
] |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1227 |
]. |
4101 | 1228 |
] ifFalse:[ |
1229 |
self openInNewBrowser. |
|
1230 |
] |
|
1231 |
! |
|
1232 |
||
6808 | 1233 |
fileSelected:entries |
1234 |
|file fn| |
|
1235 |
||
6822 | 1236 |
entries isEmptyOrNil ifTrue:[^ self]. |
1237 |
||
6808 | 1238 |
file := self shownList at:entries first. |
6810 | 1239 |
file isText ifTrue:[^ self]. |
1240 |
||
6808 | 1241 |
fn := file asFilename. |
1242 |
fn exists ifFalse:[ |
|
1243 |
self notify:('%1 does not (no longer ?) exist or is not accessable.' bindWith:file allBold). |
|
1244 |
^ self |
|
1245 |
]. |
|
1246 |
fn isDirectory ifTrue:[ |
|
1247 |
self notify:nil. |
|
1248 |
^ self. |
|
1249 |
]. |
|
1250 |
||
1251 |
self notify:('%1: %2.' bindWith:fn baseName allBold with:(UnitConverter fileSizeStringFor:fn fileSize)). |
|
1252 |
||
1253 |
"Created: / 04-07-2006 / 11:35:38 / cg" |
|
1254 |
! |
|
1255 |
||
3892 | 1256 |
processEvent:anEvent |
1257 |
"filter keyboard events. |
|
1258 |
Return true, if I have eaten the event" |
|
1259 |
||
1260 |
|focusView key rawKey| |
|
1261 |
||
1262 |
anEvent isKeyPressEvent ifTrue:[ |
|
1263 |
focusView := anEvent targetView. |
|
1264 |
key := anEvent key. |
|
1265 |
rawKey := anEvent rawKey. |
|
1266 |
||
1267 |
(focusView isSameOrComponentOf:self window) ifTrue:[ |
|
1268 |
(key == #Return) ifTrue:[ |
|
1269 |
(focusView name ~= 'selectionInListView') ifTrue:[ |
|
1270 |
self doSearch. |
|
1271 |
] ifFalse:[ |
|
1272 |
self hasOneFileSelected ifTrue:[ |
|
4101 | 1273 |
self fileDoubleClick:(self selectionHolder value) |
1274 |
"/ self isEmbeddedApplication ifTrue:[ |
|
1275 |
"/ self selectInBrowser. |
|
1276 |
"/ ] ifFalse:[ |
|
1277 |
"/ self openInNewBrowser. |
|
1278 |
"/ ] |
|
3892 | 1279 |
] |
1280 |
]. |
|
1281 |
^ true |
|
1282 |
]. |
|
1283 |
] |
|
1284 |
]. |
|
1285 |
^ false |
|
1286 |
! ! |
|
1287 |
||
1288 |
!FindFileApplication methodsFor:'private'! |
|
1289 |
||
1290 |
changeExtentToSeeSearchResult |
|
1291 |
||
1292 |
| extent window| |
|
1293 |
||
1294 |
expanded isNil ifTrue:[ |
|
1295 |
window := self builder window. |
|
1296 |
window ifNotNil:[ |
|
1297 |
window := window topView. |
|
1298 |
extent := window extent. |
|
1299 |
window extent:((extent x) @ (extent y + 300)). |
|
1300 |
expanded := true. |
|
1301 |
window containerChangedSize. |
|
1302 |
]. |
|
1303 |
]. |
|
1304 |
! ! |
|
1305 |
||
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1306 |
!FindFileApplication methodsFor:'private - searching'! |
3892 | 1307 |
|
5856 | 1308 |
cachedFileSizeOf:aFilenameString |
1309 |
|cache cacheLine fileSize| |
|
1310 |
||
1311 |
cache := self contentsInfoCache. |
|
1312 |
cache isNil ifTrue:[ |
|
5859 | 1313 |
fileSize := aFilenameString asFilename fileSize |
5856 | 1314 |
] ifFalse:[ |
5859 | 1315 |
ContentsInfoCacheAccessLock critical:[ |
1316 |
cacheLine := cache at:aFilenameString ifAbsent:nil. |
|
1317 |
cacheLine isNil ifTrue:[ |
|
1318 |
cache at:aFilenameString put:(cacheLine := Array new:2). |
|
1319 |
] ifFalse:[ |
|
1320 |
fileSize := (cacheLine at:1). |
|
1321 |
]. |
|
5856 | 1322 |
|
5859 | 1323 |
fileSize isNil ifTrue:[ |
1324 |
fileSize := aFilenameString asFilename fileSize. |
|
1325 |
cacheLine at:1 put:fileSize. |
|
1326 |
]. |
|
1327 |
]. |
|
5856 | 1328 |
]. |
1329 |
^ fileSize |
|
1330 |
! |
|
1331 |
||
1332 |
cachedHashValueOfFile:aFilenameString |
|
1333 |
|cache cacheLine hashValue| |
|
1334 |
||
1335 |
cache := self contentsInfoCache. |
|
1336 |
cache isNil ifTrue:[ |
|
5859 | 1337 |
hashValue := MD5Stream hashValueOfFile:aFilenameString asFilename |
5856 | 1338 |
] ifFalse:[ |
5859 | 1339 |
ContentsInfoCacheAccessLock critical:[ |
1340 |
cacheLine := cache at:aFilenameString ifAbsent:nil. |
|
1341 |
cacheLine isNil ifTrue:[ |
|
1342 |
cache at:aFilenameString put:(Array new:2). |
|
1343 |
] ifFalse:[ |
|
1344 |
hashValue := (cacheLine at:2). |
|
1345 |
]. |
|
5856 | 1346 |
|
5859 | 1347 |
hashValue isNil ifTrue:[ |
1348 |
hashValue := MD5Stream hashValueOfFile:aFilenameString asFilename. |
|
1349 |
cacheLine at:2 put:hashValue. |
|
1350 |
]. |
|
1351 |
]. |
|
5856 | 1352 |
]. |
1353 |
^ hashValue |
|
1354 |
! |
|
1355 |
||
1356 |
contentsInfoCache |
|
6107 | 1357 |
contentsInfoCache isNil ifTrue:[ |
1358 |
ContentsInfoCache isNil ifTrue:[ |
|
1359 |
ContentsInfoCache := Dictionary new. |
|
1360 |
ContentsInfoCacheAccessLock := Semaphore forMutualExclusion. |
|
1361 |
]. |
|
1362 |
contentsInfoCache := ContentsInfoCache |
|
5856 | 1363 |
]. |
6107 | 1364 |
^ contentsInfoCache |
5856 | 1365 |
! |
1366 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1367 |
doFindFileNamed:namePatterns directories:searchDirectories ignoreCase:ignCaseInName |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1368 |
containingString:contentsStringArg ignoreCaseInContents:ignCaseInContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1369 |
notContainingString:notContentsStringArg ignoreCaseInNotContents:ignCaseInNotContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1370 |
sameContentsAsFile:filenameToCompareContentsOrNil sameContentsAs:bytesToCompareContentsOrNil in:aDirectory |
3892 | 1371 |
|
5859 | 1372 |
|dir nameMatches lines contentsToCompare resultList matchedFilesList inStream |
5601 | 1373 |
doesFileMatch contentsString notContentsString check checkNot |
5859 | 1374 |
grepCommand nameMatch fileSizesToSearchFor filesToSearchFor fileMD5sToSearchFor |
1375 |
setOfFilesToSearchFor remember cache fn| |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1376 |
|
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1377 |
contentsString := contentsStringArg. |
6183
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1378 |
contentsString notNil ifTrue:[ |
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1379 |
ignCaseInContents ifTrue:[ contentsString := contentsString asLowercase ]. |
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1380 |
]. |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1381 |
notContentsString := notContentsStringArg. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1382 |
|
6183
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1383 |
notContentsString notNil ifTrue:[ |
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1384 |
ignCaseInNotContents ifTrue:[ notContentsString := notContentsString asLowercase ]. |
e6d9cfbfb358
care for empty search-arguments
Michael Beyl <mb@exept.de>
parents:
6158
diff
changeset
|
1385 |
]. |
5723 | 1386 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
5768 | 1387 |
fileSizesToSearchFor := OrderedCollection new. |
1388 |
filesToSearchFor := OrderedCollection new. |
|
1389 |
fileMD5sToSearchFor := OrderedCollection new. |
|
1390 |
||
1391 |
filenameToCompareContentsOrNil includesMatchCharacters ifTrue:[ |
|
1392 |
dir := filenameToCompareContentsOrNil asFilename. |
|
1393 |
[dir pathName includesMatchCharacters] whileTrue:[ |
|
1394 |
dir := dir directory |
|
1395 |
]. |
|
1396 |
dir recursiveDirectoryContentsDo:[:relName | |
|
1397 |
|path fn| |
|
1398 |
||
1399 |
fn := dir construct:relName. |
|
5770 | 1400 |
(filenameToCompareContentsOrNil match:fn name) ifTrue:[ |
5847 | 1401 |
fn isDirectory ifFalse:[ |
5856 | 1402 |
fileSizesToSearchFor add:(self cachedFileSizeOf:fn). |
5847 | 1403 |
filesToSearchFor add:(fn name). |
5856 | 1404 |
fileMD5sToSearchFor add:(self cachedHashValueOfFile:fn). |
5847 | 1405 |
] |
5768 | 1406 |
] |
1407 |
]. |
|
1408 |
] ifFalse:[ |
|
1409 |
fn := filenameToCompareContentsOrNil asFilename. |
|
5856 | 1410 |
fileSizesToSearchFor add:(self cachedFileSizeOf:fn). |
5768 | 1411 |
filesToSearchFor add:(fn pathName). |
5856 | 1412 |
fileMD5sToSearchFor add:(self cachedHashValueOfFile:fn). |
5768 | 1413 |
]. |
1414 |
||
5859 | 1415 |
remember := LastRememberInCache := self rememberInCache value. |
5723 | 1416 |
remember ifTrue:[ |
5856 | 1417 |
cache := self contentsInfoCache. |
5723 | 1418 |
]. |
5866 | 1419 |
setOfFilesToSearchFor := filesToSearchFor asSet. |
1420 |
]. |
|
5791 | 1421 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1422 |
dir := aDirectory asFilename. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1423 |
self changeInformationTo:'Find File ' , '- searching .' , ((dir name) copyFrom:(self searchDirectoryHolder value asString size + 1)) toTab:false. |
3892 | 1424 |
|
5859 | 1425 |
resultList := self resultList. |
1426 |
matchedFilesList := self matchedFilesList. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1427 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1428 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1429 |
doesFileMatch := |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1430 |
[:f | |
5859 | 1431 |
|contentsMatches mustValidateExistance |
1432 |
fileMD5 fileName fileSize cacheLine idxInList matchedFile| |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1433 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1434 |
"/ contents compare ... |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1435 |
contentsMatches := false. |
5771 | 1436 |
fileName := f name. |
5859 | 1437 |
(setOfFilesToSearchFor includes:fileName) ifFalse:[ |
5850 | 1438 |
mustValidateExistance := false. |
5856 | 1439 |
|
5727 | 1440 |
cache notNil ifTrue:[ |
5859 | 1441 |
ContentsInfoCacheAccessLock critical:[ |
1442 |
cacheLine := cache at:fileName ifAbsent:nil. |
|
1443 |
cacheLine notNil ifTrue:[ |
|
1444 |
fileSize := cacheLine at:1. |
|
1445 |
fileMD5 := cacheLine at:2. |
|
1446 |
mustValidateExistance := true. |
|
1447 |
]. |
|
5727 | 1448 |
]. |
5723 | 1449 |
]. |
5850 | 1450 |
|
5723 | 1451 |
fileSize isNil ifTrue:[ |
1452 |
fileSize := f fileSize. |
|
1453 |
]. |
|
1454 |
remember ifTrue:[ |
|
5859 | 1455 |
ContentsInfoCacheAccessLock critical:[ |
1456 |
cacheLine := cache at:fileName ifAbsentPut:[Array new:2]. |
|
1457 |
cacheLine at:1 put:fileSize. |
|
1458 |
] |
|
5723 | 1459 |
]. |
5768 | 1460 |
(idxInList := fileSizesToSearchFor indexOf:fileSize) ~~ 0 ifTrue:[ |
5723 | 1461 |
fileMD5 isNil ifTrue:[ |
5850 | 1462 |
OpenError handle:[:ex | |
1463 |
ObjectMemory garbageCollect. |
|
1464 |
fileMD5 := MD5Stream hashValueOfFile:f. |
|
1465 |
] do:[ |
|
1466 |
fileMD5 := MD5Stream hashValueOfFile:f. |
|
1467 |
]. |
|
5723 | 1468 |
remember ifTrue:[ |
1469 |
cacheLine at:2 put:fileMD5 |
|
1470 |
]. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1471 |
]. |
5768 | 1472 |
contentsMatches := (fileMD5 = (fileMD5sToSearchFor at:idxInList)). |
5850 | 1473 |
contentsMatches ifTrue:[ |
1474 |
mustValidateExistance ifTrue:[ |
|
1475 |
fileName asFilename exists ifFalse:[ |
|
5859 | 1476 |
ContentsInfoCacheAccessLock critical:[ |
1477 |
cache removeKey:fileName. |
|
1478 |
]. |
|
5850 | 1479 |
contentsMatches := false. |
1480 |
]. |
|
5859 | 1481 |
]. |
1482 |
contentsMatches ifTrue:[ |
|
1483 |
matchedFile := filesToSearchFor at:idxInList. |
|
1484 |
matchedFilesList add:matchedFile. |
|
1485 |
]. |
|
5850 | 1486 |
]. |
5723 | 1487 |
"/ contentsToCompare isNil ifTrue:[ |
1488 |
"/ filenameToCompareContentsOrNil fileSize < (512*1024) ifTrue:[ |
|
1489 |
"/ contentsToCompare := filenameToCompareContentsOrNil binaryContentsOfEntireFile |
|
1490 |
"/ ] |
|
1491 |
"/ ]. |
|
1492 |
"/ contentsToCompare isNil ifTrue:[ |
|
1493 |
"/ "/ too large - compare block-wise ... |
|
1494 |
"/ contentsMatches := (filenameToCompareContentsOrNil sameContentsAs:f). |
|
1495 |
"/ ] ifFalse:[ |
|
1496 |
"/ contentsMatches := contentsToCompare = (f binaryContentsOfEntireFile). |
|
1497 |
"/ ] |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1498 |
]. |
5773 | 1499 |
] ifTrue:[ |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1500 |
f isSymbolicLink ifTrue:[ |
5859 | 1501 |
resultList add: (f name , ' is a symbolic link to ' , f pathName). |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1502 |
] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1503 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1504 |
contentsMatches |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1505 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1506 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1507 |
(contentsString isNil and:[notContentsString isNil]) ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1508 |
doesFileMatch := [:f | true]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1509 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1510 |
(self canUseGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1511 |
and:[self useGrep value]) ifTrue:[ |
5601 | 1512 |
(ignCaseInContents not and:[ignCaseInNotContents not]) ifTrue:[ |
1513 |
contentsString notNil ifTrue:[ |
|
1514 |
notContentsString notNil ifTrue:[ |
|
1515 |
grepCommand := '(grep "',contentsString,'" %1) && (grep -v "',notContentsString,'" %1)'. |
|
1516 |
] ifFalse:[ |
|
1517 |
grepCommand := 'grep "' , contentsString , '" %1'. |
|
1518 |
]. |
|
1519 |
] ifFalse:[ |
|
1520 |
grepCommand := 'grep -v "' , notContentsString , '" %1'. |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1521 |
]. |
5601 | 1522 |
doesFileMatch := [:f | |cmd ret| |
1523 |
cmd := grepCommand bindWith:f pathName. |
|
1524 |
ret := OperatingSystem executeCommand:cmd. |
|
1525 |
ret |
|
1526 |
]. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1527 |
] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1528 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1529 |
|
5601 | 1530 |
doesFileMatch isNil ifTrue:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1531 |
contentsString notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1532 |
ignCaseInContents ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1533 |
check := [:l | l asLowercase includesString:contentsString] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1534 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1535 |
check := [:l | l includesString:contentsString] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1536 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1537 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1538 |
notContentsString notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1539 |
ignCaseInNotContents ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1540 |
checkNot := [:l | l asLowercase includesString:notContentsString] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1541 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1542 |
checkNot := [:l | l includesString:notContentsString] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1543 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1544 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1545 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1546 |
doesFileMatch := |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1547 |
[:f | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1548 |
|contentsMatches| |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1549 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1550 |
"/ string search ... |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1551 |
contentsMatches := true. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1552 |
(f exists and:[f isReadable]) ifFalse:[ |
5859 | 1553 |
resultList add: (('*** ' , f pathName , ' skipped - unreadable or bad symbolic link ***') asText colorizeAllWith:(Color red darkened)). |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1554 |
] ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1555 |
f fileSize > (4024*1024) ifTrue:[ |
5859 | 1556 |
resultList add: (('*** ' , f pathName , ' skipped - too large ***') asText colorizeAllWith:(Color red darkened)). |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1557 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1558 |
Stream lineTooLongErrorSignal handle:[:ex | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1559 |
|cont| |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1560 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1561 |
"/ this typically happens, when a binary file is read linewise ... |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1562 |
cont := f readStream binary contentsOfEntireFile asString. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1563 |
check notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1564 |
checkNot isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1565 |
contentsMatches := check value:cont |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1566 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1567 |
contentsMatches := (check value:cont) and:[(checkNot value:cont) not]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1568 |
] |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1569 |
] ifFalse:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1570 |
contentsMatches := (checkNot value:cont) not. |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1571 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1572 |
] do:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1573 |
lines := f contents ? #(). |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1574 |
check notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1575 |
checkNot isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1576 |
contentsMatches := (lines contains:check). |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1577 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1578 |
contentsMatches := (lines contains:check) and:[(lines contains:checkNot) not] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1579 |
] |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1580 |
] ifFalse:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1581 |
contentsMatches := (lines contains:checkNot) not. |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1582 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1583 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1584 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1585 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1586 |
contentsMatches |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1587 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1588 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1589 |
]. |
6330 | 1590 |
self enableFileSizeFilter value ifTrue:[ |
1591 |
|fileSizeToCompare sizeMatch op oldDoesFileMatch| |
|
1592 |
||
1593 |
fileSizeToCompare := self fileSizeHolder value. |
|
7691 | 1594 |
op := self fileSizeOperatorHolder value withoutSeparators. |
6330 | 1595 |
op = '~' ifTrue:[ |
6808 | 1596 |
sizeMatch := [:f | |sz| sz := f fileSize. sz notNil and:[sz between:fileSizeToCompare*0.9 and:fileSizeToCompare*1.1]]. |
6330 | 1597 |
] ifFalse:[ |
1598 |
op := op asSymbol. |
|
6808 | 1599 |
sizeMatch := [:f | |sz| sz := f fileSize. sz notNil and:[sz perform:op with:fileSizeToCompare]]. |
6330 | 1600 |
]. |
1601 |
oldDoesFileMatch := doesFileMatch. |
|
1602 |
doesFileMatch := [:f | (sizeMatch value:f) and:[ oldDoesFileMatch value:f ]] |
|
1603 |
]. |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1604 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1605 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1606 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1607 |
(self canUseLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1608 |
and:[self useLocate value |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1609 |
and:[searchDirectories not]]) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1610 |
ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1611 |
[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1612 |
|cmd line f| |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1613 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1614 |
cmd := 'locate '. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1615 |
ignCaseInName ifTrue:[ |
5408 | 1616 |
cmd := cmd , '--ignore-case ' |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1617 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1618 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1619 |
cmd := cmd , ((namePatterns collect:[:nm | dir asFilename asAbsoluteFilename constructString:nm]) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1620 |
asStringCollection asStringWith:Character space). |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1621 |
inStream := PipeStream readingFrom:cmd inDirectory:dir. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1622 |
[inStream atEnd] whileFalse:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1623 |
line := inStream nextLine. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1624 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1625 |
f := line asFilename. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1626 |
(doesFileMatch value:f) ifTrue:[ |
5859 | 1627 |
resultList add:line. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1628 |
] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1629 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1630 |
] ensure:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1631 |
inStream notNil ifTrue:[inStream close]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1632 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1633 |
^ self. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1634 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1635 |
|
3892 | 1636 |
bytesToCompareContentsOrNil notNil ifTrue:[ |
1637 |
contentsToCompare := bytesToCompareContentsOrNil |
|
1638 |
]. |
|
1639 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1640 |
namePatterns isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1641 |
nameMatch := [:fn | true] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1642 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1643 |
ignCaseInName ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1644 |
nameMatch := [:fn | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1645 |
nameMatches := namePatterns contains:[:aPattern | aPattern match:(fn asLowercase)] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1646 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1647 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1648 |
nameMatch := [:fn | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1649 |
nameMatches := namePatterns contains:[:aPattern | aPattern match:fn] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1650 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1651 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1652 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1653 |
|
5726 | 1654 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
5727 | 1655 |
self searchOnlyInCache value ifTrue:[ |
5726 | 1656 |
cache notEmptyOrNil ifTrue:[ |
1657 |
cache keysAndValuesDo:[:fn :info | |
|
5768 | 1658 |
|filesSize filesMD5 idxInList| |
5727 | 1659 |
|
5726 | 1660 |
filesSize := info at:1. |
1661 |
filesSize isNil ifTrue:[ |
|
1662 |
filesSize := fn asFilename fileSize. |
|
1663 |
info at:1 put:filesSize. |
|
1664 |
]. |
|
5768 | 1665 |
(idxInList := fileSizesToSearchFor indexOf:filesSize) ~~ 0 ifTrue:[ |
6250
5b0673ccff1c
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
6183
diff
changeset
|
1666 |
(setOfFilesToSearchFor includes:fn) ifFalse:[ |
5729 | 1667 |
fn asFilename exists ifFalse:[ |
1668 |
info at:1 put:nil. |
|
1669 |
info at:2 put:nil. |
|
1670 |
] ifTrue:[ |
|
1671 |
filesMD5 := info at:2. |
|
1672 |
filesMD5 isNil ifTrue:[ |
|
1673 |
filesMD5 := MD5Stream hashValueOfFile:fn asFilename. |
|
1674 |
info at:2 put:filesMD5. |
|
1675 |
]. |
|
5768 | 1676 |
filesMD5 = (fileMD5sToSearchFor at:idxInList) ifTrue:[ |
5859 | 1677 |
resultList add:fn. |
5728 | 1678 |
] |
5727 | 1679 |
] |
5726 | 1680 |
] |
1681 |
] |
|
1682 |
]. |
|
1683 |
]. |
|
1684 |
^ self. |
|
1685 |
]. |
|
1686 |
]. |
|
1687 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1688 |
self |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1689 |
doFindFileNamed:namePatterns |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1690 |
directories:searchDirectories |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1691 |
nameMatch:nameMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1692 |
contentsMatch:doesFileMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1693 |
in:dir. |
6808 | 1694 |
|
7691 | 1695 |
"Modified: / 01-03-2007 / 22:12:00 / cg" |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1696 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1697 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1698 |
doFindFileNamed:namePatterns directories:searchDirectories nameMatch:nameMatch contentsMatch:doesFileMatch in:aDirectory |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1699 |
|dir subDirs list directoryContents| |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1700 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1701 |
dir := aDirectory asFilename. |
5844 | 1702 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1703 |
self changeInformationTo:'Find File ' , '- searching .' , ((dir name) copyFrom:(self searchDirectoryHolder value asString size + 1)) toTab:false. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1704 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1705 |
list := self resultList. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1706 |
|
3892 | 1707 |
subDirs := OrderedCollection new. |
1708 |
||
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1709 |
[ |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1710 |
directoryContents := dir directoryContents. |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1711 |
] on:FileStream openErrorSignal do:[:ex| |
5811
c397040c27b4
openErrorSignal arg: always a string
Claus Gittinger <cg@exept.de>
parents:
5791
diff
changeset
|
1712 |
list add:((ex pathName , ' -> ' , ex description) asText colorizeAllWith:Color red darkened). |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1713 |
"/ self warn:('Cannot access %1\(%2)' |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1714 |
"/ bindWith:ex parameter printString |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1715 |
"/ with:ex description) withCRs. |
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1716 |
^ self |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1717 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1718 |
|
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1719 |
directoryContents sort do:[:fn | |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1720 |
|f isDirectory| |
3892 | 1721 |
|
1722 |
f := dir construct:fn. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1723 |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1724 |
isDirectory := f isDirectory. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1725 |
isDirectory ifTrue:[ |
3892 | 1726 |
f isSymbolicLink ifFalse:[ |
1727 |
subDirs add:f |
|
1728 |
] |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1729 |
]. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1730 |
(searchDirectories or:[isDirectory not]) ifTrue:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1731 |
(nameMatch value:fn) ifTrue:[ |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1732 |
(isDirectory or:[ doesFileMatch value:f ]) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1733 |
ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1734 |
list add:(f asString). |
3892 | 1735 |
] |
1736 |
] |
|
1737 |
] |
|
1738 |
]. |
|
1739 |
||
1740 |
self searchRecursively value ifTrue:[ |
|
1741 |
subDirs do:[:dir | |
|
1742 |
self |
|
1743 |
doFindFileNamed:namePatterns |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1744 |
directories:searchDirectories |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1745 |
nameMatch:nameMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1746 |
contentsMatch:doesFileMatch |
3892 | 1747 |
in:dir |
1748 |
]. |
|
1749 |
] |
|
1750 |
! ! |
|
1751 |
||
1752 |
!FindFileApplication methodsFor:'queries'! |
|
1753 |
||
7688 | 1754 |
getTabValueString |
1755 |
"the item shown in a tab (not language translated)" |
|
3892 | 1756 |
|
7691 | 1757 |
^ self fileName directory baseName |
7688 | 1758 |
|
1759 |
"Created: / 01-03-2007 / 21:39:54 / cg" |
|
3892 | 1760 |
! |
1761 |
||
1762 |
hasOneFileSelected |
|
1763 |
| sel | |
|
1764 |
sel := self selectionHolder value. |
|
1765 |
^ (sel notNil and:[sel notEmpty and:[sel size = 1]]) |
|
1766 |
! |
|
1767 |
||
1768 |
hasSelectionInResultList |
|
1769 |
| sel | |
|
6482
00207f456339
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
6442
diff
changeset
|
1770 |
|
3892 | 1771 |
sel := self selectionHolder value. |
6482
00207f456339
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
6442
diff
changeset
|
1772 |
^ sel notEmptyOrNil |
3892 | 1773 |
! ! |
1774 |
||
1775 |
!FindFileApplication methodsFor:'startup & release'! |
|
1776 |
||
5010 | 1777 |
item:anItem |
3892 | 1778 |
|
4797 | 1779 |
|file newPattern| |
3892 | 1780 |
|
5010 | 1781 |
super item:anItem. |
4797 | 1782 |
|
3892 | 1783 |
file := self fileName. |
1784 |
self searchDirectoryHolder value:(self getDirWithoutFileName:file). |
|
4797 | 1785 |
|
3892 | 1786 |
file isDirectory ifTrue:[ |
4797 | 1787 |
newPattern := '*'. |
3892 | 1788 |
] ifFalse:[ |
5010 | 1789 |
newPattern := '*.', anItem suffix. |
3892 | 1790 |
]. |
4797 | 1791 |
self namePatternHolder value:newPattern. |
3892 | 1792 |
self enableStop value:false. |
1793 |
self enableSearch value:true. |
|
1794 |
^ true. |
|
1795 |
! |
|
1796 |
||
1797 |
postOpenWith:aBuilder |
|
1798 |
||
1799 |
self masterApplication isNil ifTrue:[ |
|
1800 |
self masterApplication:nil. |
|
1801 |
]. |
|
1802 |
findFileView := aBuilder window. |
|
1803 |
self windowGroup addPreEventHook:self. |
|
6633 | 1804 |
super postOpenWith:aBuilder. |
3892 | 1805 |
! |
1806 |
||
1807 |
release |
|
1808 |
self stopSearchTask. |
|
6107 | 1809 |
contentsInfoCache := nil. |
3892 | 1810 |
^ super release |
1811 |
! ! |
|
1812 |
||
1813 |
!FindFileApplication class methodsFor:'documentation'! |
|
1814 |
||
1815 |
version |
|
8613 | 1816 |
^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.86 2009-05-08 09:38:09 cg Exp $' |
3892 | 1817 |
! ! |