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