author | Claus Gittinger <cg@exept.de> |
Tue, 18 May 2004 14:00:46 +0200 | |
changeset 5859 | c85f10082d25 |
parent 5857 | 255fc389bf5d |
child 5860 | 294f0dcfbe4b |
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 |
24 |
matchedFilesList shownList' |
|
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 |
5859 | 311 |
sequenceList: shownList |
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 |
|
555 |
self shownList valueHolder 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 |
||
5859 | 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:[ |
|
588 |
delete := FileOperation getDeleteClass deleteFiles:colOfFiles confirm:confirm. |
|
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. |
|
607 |
files := sel collect:[:idx | resultList at:idx]. |
|
608 |
self deleteFiles:files confirm:true. |
|
5856 | 609 |
result == true ifTrue:[ |
610 |
self removeSelectedFilesFromResultList. |
|
611 |
]. |
|
5766 | 612 |
! |
613 |
||
3892 | 614 |
doSearch |
615 |
||
5723 | 616 |
| namePattern namePatterns contentsPattern notContentsPattern dir fileToCompareAgainst| |
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 |
||
5776 | 683 |
searchTask := |
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:[ |
720 |
searchTask := nil. |
|
3892 | 721 |
self enableStop value:false. |
5776 | 722 |
self notify:message. |
723 |
] |
|
724 |
] newProcess. |
|
3892 | 725 |
|
5776 | 726 |
searchTask priorityRange:(Processor systemBackgroundPriority to:Processor userSchedulingPriority). |
3892 | 727 |
searchTask name:('FindFile[', self searchDirectoryHolder value asFilename baseName, ']'). |
728 |
searchTask resume. |
|
729 |
! |
|
730 |
||
731 |
openInNewBrowser |
|
732 |
|sel| |
|
733 |
||
734 |
sel := self selectionHolder value. |
|
735 |
(sel notNil and:[sel notEmpty]) ifTrue:[ |
|
5859 | 736 |
FileBrowserV2 openOn:(self shownList at:sel first) asFilename |
3892 | 737 |
]. |
738 |
! |
|
739 |
||
5766 | 740 |
removeSelectedFilesFromResultList |
3892 | 741 |
|sel list| |
742 |
||
743 |
sel := self selectionHolder value. |
|
5859 | 744 |
list := self shownList valueHolder. |
3892 | 745 |
(sel notNil and:[sel notEmpty]) ifTrue:[ |
746 |
sel reverseDo:[: key | |
|
747 |
list removeAtIndex:key |
|
748 |
] |
|
749 |
]. |
|
750 |
! |
|
751 |
||
752 |
selectInBrowser |
|
753 |
|sel entry application| |
|
754 |
||
755 |
sel := self selectionHolder value. |
|
756 |
(sel notNil and:[sel notEmpty]) ifTrue:[ |
|
5859 | 757 |
entry := self shownList at:sel first. |
5252 | 758 |
entry asFilename exists ifFalse:[ ^ self]. |
4101 | 759 |
application := targetApplication ? self masterApplication. |
4182 | 760 |
application notNil ifTrue:[ |
4101 | 761 |
application gotoFile:(entry asFilename). |
762 |
]. |
|
3892 | 763 |
]. |
764 |
! |
|
765 |
||
5859 | 766 |
showMatchedFiles:aBoolean |
767 |
aBoolean ifTrue:[ |
|
768 |
self shownList valueHolder:(self matchedFilesList) |
|
769 |
] ifFalse:[ |
|
770 |
self shownList valueHolder:(self resultList) |
|
771 |
]. |
|
772 |
! |
|
773 |
||
3892 | 774 |
stop |
775 |
||
776 |
searchTask notNil ifTrue:[ |
|
777 |
self accessLock critical:[ |
|
778 |
searchTask interruptWith:[stopSignal raiseRequest]. |
|
779 |
] |
|
780 |
]. |
|
781 |
self enableStop value:false. |
|
782 |
self enableSearch value:true. |
|
783 |
self changeInformationTo:'Find File ' , '- search stopped' toTab:true. |
|
784 |
! |
|
785 |
||
786 |
stopSearchTask |
|
787 |
|task| |
|
788 |
||
789 |
(task := searchTask) notNil ifTrue:[ |
|
790 |
searchTask := nil. |
|
791 |
||
792 |
Object errorSignal handle:[:ex| |
|
793 |
Dialog warn:ex description. |
|
794 |
]do:[ |
|
795 |
task isDead ifFalse:[ |
|
3937
80d958725879
terminateWithAllSUbprocesses -> xxxInGroup
Claus Gittinger <cg@exept.de>
parents:
3892
diff
changeset
|
796 |
task terminateWithAllSubprocessesInGroup. |
3892 | 797 |
task waitUntilTerminated. |
798 |
] |
|
799 |
] |
|
800 |
]. |
|
801 |
! ! |
|
802 |
||
803 |
!FindFileApplication methodsFor:'aspects'! |
|
804 |
||
5856 | 805 |
autoSelectInBrowser |
806 |
^ false. |
|
807 |
! |
|
808 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
809 |
canUseGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
810 |
"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
|
811 |
- not under MSDOS |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
812 |
" |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
813 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
814 |
^ 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
|
815 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
816 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
817 |
canUseLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
818 |
"locate command is much faster, but: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
819 |
- only if searching recursively, |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
820 |
- no case ignore |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
821 |
- no contents matching |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
822 |
" |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
823 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
824 |
^ OperatingSystem isUNIXlike and:[ OperatingSystem canExecuteCommand:'locate' ] |
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 |
|
3892 | 827 |
contentsPatternHolder |
828 |
||
829 |
contentsPatternHolder isNil ifTrue:[ |
|
830 |
contentsPatternHolder := nil asValue. |
|
831 |
]. |
|
832 |
^ contentsPatternHolder. |
|
833 |
! |
|
834 |
||
835 |
enableSearch |
|
836 |
||
837 |
enableSearch isNil ifTrue:[ |
|
838 |
enableSearch := true asValue. |
|
839 |
]. |
|
840 |
^ enableSearch. |
|
841 |
! |
|
842 |
||
843 |
enableStop |
|
844 |
||
845 |
enableStop isNil ifTrue:[ |
|
846 |
enableStop := true asValue. |
|
847 |
]. |
|
848 |
^ enableStop. |
|
849 |
! |
|
850 |
||
851 |
hasListEntries |
|
852 |
||
853 |
hasListEntries isNil ifTrue:[ |
|
854 |
hasListEntries := false asValue. |
|
855 |
]. |
|
856 |
^ hasListEntries. |
|
857 |
! |
|
858 |
||
859 |
ignoreCaseInContents |
|
860 |
ignoreCaseInContents isNil ifTrue:[ |
|
861 |
ignoreCaseInContents := false asValue. |
|
862 |
]. |
|
863 |
^ ignoreCaseInContents. |
|
864 |
! |
|
865 |
||
866 |
ignoreCaseInName |
|
867 |
||
868 |
ignoreCaseInName isNil ifTrue:[ |
|
869 |
ignoreCaseInName := false asValue. |
|
870 |
]. |
|
871 |
^ ignoreCaseInName. |
|
872 |
! |
|
873 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
874 |
ignoreCaseInNotContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
875 |
ignoreCaseInNotContents isNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
876 |
ignoreCaseInNotContents := false asValue. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
877 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
878 |
^ ignoreCaseInNotContents. |
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 |
|
5859 | 881 |
matchedFilesList |
882 |
||
883 |
matchedFilesList isNil ifTrue:[ |
|
884 |
matchedFilesList := List new. |
|
885 |
matchedFilesList addDependent:self. |
|
886 |
]. |
|
887 |
^ matchedFilesList. |
|
888 |
! |
|
889 |
||
3892 | 890 |
namePatternHolder |
891 |
||
892 |
namePatternHolder isNil ifTrue:[ |
|
893 |
namePatternHolder := '*' asValue. |
|
894 |
]. |
|
895 |
^ namePatternHolder. |
|
896 |
! |
|
897 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
898 |
notContentsPatternHolder |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
899 |
|
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
900 |
notContentsPatternHolder isNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
901 |
notContentsPatternHolder := nil asValue. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
902 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
903 |
^ notContentsPatternHolder. |
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 |
|
3892 | 906 |
notSearchForSameContents |
5743 | 907 |
^ BlockValue forLogicalNot:self searchForSameContents |
3892 | 908 |
! |
909 |
||
5859 | 910 |
notShowingMatchedFiles |
911 |
^ shownList valueHolder == self resultList |
|
912 |
! |
|
913 |
||
5723 | 914 |
rememberInCache |
915 |
rememberInCache isNil ifTrue:[ |
|
5859 | 916 |
rememberInCache := (LastRememberInCache ? false) asValue. |
5723 | 917 |
]. |
918 |
^ rememberInCache. |
|
919 |
! |
|
920 |
||
3892 | 921 |
resultList |
922 |
resultList isNil ifTrue:[ |
|
923 |
resultList := List new. |
|
924 |
resultList addDependent:self. |
|
925 |
]. |
|
926 |
^ resultList. |
|
927 |
! |
|
928 |
||
5723 | 929 |
sameContentsAsHolder |
930 |
|sel| |
|
931 |
||
932 |
sameContentsAsHolder isNil ifTrue:[ |
|
933 |
sameContentsAsHolder := ValueHolder new. |
|
934 |
masterApplication notNil ifTrue:[ |
|
935 |
sel := masterApplication currentSelectedFiles. |
|
936 |
sel size > 0 ifTrue:[ |
|
937 |
sameContentsAsHolder value:(sel first asFilename pathName). |
|
938 |
]. |
|
939 |
]. |
|
940 |
]. |
|
941 |
^ sameContentsAsHolder. |
|
942 |
! |
|
943 |
||
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
944 |
searchDirectories |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
945 |
searchDirectories isNil ifTrue:[ |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
946 |
searchDirectories := false asValue. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
947 |
]. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
948 |
^ searchDirectories. |
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 |
|
3892 | 951 |
searchDirectoryHolder |
952 |
||
953 |
searchDirectoryHolder isNil ifTrue:[ |
|
954 |
searchDirectoryHolder := ValueHolder new. |
|
955 |
]. |
|
956 |
^ searchDirectoryHolder. |
|
957 |
! |
|
958 |
||
5743 | 959 |
searchForSameContents |
960 |
searchForSameContents isNil ifTrue:[ |
|
961 |
searchForSameContents := false asValue. |
|
962 |
]. |
|
963 |
^ searchForSameContents. |
|
964 |
! |
|
965 |
||
5726 | 966 |
searchOnlyInCache |
967 |
searchOnlyInCache isNil ifTrue:[ |
|
968 |
searchOnlyInCache := false asValue. |
|
969 |
]. |
|
970 |
^ searchOnlyInCache. |
|
971 |
! |
|
972 |
||
3892 | 973 |
searchRecursively |
974 |
||
975 |
searchRecursively isNil ifTrue:[ |
|
976 |
searchRecursively := true asValue. |
|
977 |
]. |
|
978 |
^ searchRecursively. |
|
979 |
! |
|
980 |
||
981 |
searchResultTable |
|
982 |
||
983 |
searchResultTable isNil ifTrue:[ |
|
984 |
searchResultTable := self class searchResultTable asValue. |
|
985 |
]. |
|
986 |
^ searchResultTable. |
|
987 |
! |
|
988 |
||
989 |
selectionHolder |
|
990 |
||
991 |
selectionHolder isNil ifTrue:[ |
|
4101 | 992 |
selectionHolder := ValueHolder new. |
993 |
selectionHolder addDependent:self. |
|
3892 | 994 |
]. |
995 |
^ selectionHolder |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
996 |
! |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
997 |
|
5859 | 998 |
showingMatchedFiles |
999 |
^ shownList valueHolder == self matchedFilesList |
|
1000 |
! |
|
1001 |
||
1002 |
shownList |
|
1003 |
shownList isNil ifTrue:[ |
|
1004 |
shownList := IndirectValue for:(self resultList). |
|
1005 |
shownList addDependent:self. |
|
1006 |
]. |
|
1007 |
^ shownList. |
|
1008 |
! |
|
1009 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1010 |
useGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1011 |
useGrep isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1012 |
useGrep := false asValue. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1013 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1014 |
^ useGrep. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1015 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1016 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1017 |
useLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1018 |
useLocate isNil ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1019 |
useLocate := false asValue. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1020 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1021 |
^ useLocate. |
3892 | 1022 |
! ! |
1023 |
||
1024 |
!FindFileApplication methodsFor:'change & update'! |
|
1025 |
||
1026 |
update:something with:aParameter from:changedObject |
|
5859 | 1027 |
changedObject == self shownList ifTrue:[ |
1028 |
self hasListEntries value:(changedObject valueHolder notEmpty). |
|
3892 | 1029 |
^ self |
1030 |
]. |
|
4101 | 1031 |
changedObject == self selectionHolder ifTrue:[ |
5856 | 1032 |
self autoSelectInBrowser ifTrue:[ |
1033 |
self selectInBrowser. |
|
1034 |
]. |
|
4101 | 1035 |
^ self |
1036 |
]. |
|
3892 | 1037 |
super update:something with:aParameter from:changedObject |
1038 |
! ! |
|
1039 |
||
1040 |
!FindFileApplication methodsFor:'event handling'! |
|
1041 |
||
4101 | 1042 |
fileDoubleClick:entries |
5677
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1043 |
|file fn app openedAppl contentsPattern| |
4101 | 1044 |
|
5859 | 1045 |
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
|
1046 |
fn := file asFilename. |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1047 |
fn exists ifFalse:[ |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1048 |
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
|
1049 |
^ self |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1050 |
]. |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1051 |
|
4101 | 1052 |
app := targetApplication ? self masterApplication. |
5279 | 1053 |
file asFilename isDirectory ifTrue:[ |
1054 |
app gotoFile:(file asFilename). |
|
1055 |
^ self. |
|
1056 |
]. |
|
4101 | 1057 |
app notNil ifTrue:[ |
4145
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1058 |
openedAppl := app openApplForFile:file. |
5279 | 1059 |
(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
|
1060 |
contentsPattern := self contentsPatternHolder value. |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1061 |
(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
|
1062 |
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
|
1063 |
] |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1064 |
]. |
4101 | 1065 |
] ifFalse:[ |
1066 |
self openInNewBrowser. |
|
1067 |
] |
|
1068 |
! |
|
1069 |
||
3892 | 1070 |
processEvent:anEvent |
1071 |
"filter keyboard events. |
|
1072 |
Return true, if I have eaten the event" |
|
1073 |
||
1074 |
|focusView key rawKey| |
|
1075 |
||
1076 |
anEvent isKeyPressEvent ifTrue:[ |
|
1077 |
focusView := anEvent targetView. |
|
1078 |
key := anEvent key. |
|
1079 |
rawKey := anEvent rawKey. |
|
1080 |
||
1081 |
(focusView isSameOrComponentOf:self window) ifTrue:[ |
|
1082 |
(key == #Return) ifTrue:[ |
|
1083 |
(focusView name ~= 'selectionInListView') ifTrue:[ |
|
1084 |
self doSearch. |
|
1085 |
] ifFalse:[ |
|
1086 |
self hasOneFileSelected ifTrue:[ |
|
4101 | 1087 |
self fileDoubleClick:(self selectionHolder value) |
1088 |
"/ self isEmbeddedApplication ifTrue:[ |
|
1089 |
"/ self selectInBrowser. |
|
1090 |
"/ ] ifFalse:[ |
|
1091 |
"/ self openInNewBrowser. |
|
1092 |
"/ ] |
|
3892 | 1093 |
] |
1094 |
]. |
|
1095 |
^ true |
|
1096 |
]. |
|
1097 |
] |
|
1098 |
]. |
|
1099 |
^ false |
|
1100 |
! ! |
|
1101 |
||
1102 |
!FindFileApplication methodsFor:'private'! |
|
1103 |
||
1104 |
changeExtentToSeeSearchResult |
|
1105 |
||
1106 |
| extent window| |
|
1107 |
||
1108 |
expanded isNil ifTrue:[ |
|
1109 |
window := self builder window. |
|
1110 |
window ifNotNil:[ |
|
1111 |
window := window topView. |
|
1112 |
extent := window extent. |
|
1113 |
window extent:((extent x) @ (extent y + 300)). |
|
1114 |
expanded := true. |
|
1115 |
window containerChangedSize. |
|
1116 |
]. |
|
1117 |
]. |
|
1118 |
! ! |
|
1119 |
||
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1120 |
!FindFileApplication methodsFor:'private - searching'! |
3892 | 1121 |
|
5856 | 1122 |
cachedFileSizeOf:aFilenameString |
1123 |
|cache cacheLine fileSize| |
|
1124 |
||
1125 |
cache := self contentsInfoCache. |
|
1126 |
cache isNil ifTrue:[ |
|
5859 | 1127 |
fileSize := aFilenameString asFilename fileSize |
5856 | 1128 |
] ifFalse:[ |
5859 | 1129 |
ContentsInfoCacheAccessLock critical:[ |
1130 |
cacheLine := cache at:aFilenameString ifAbsent:nil. |
|
1131 |
cacheLine isNil ifTrue:[ |
|
1132 |
cache at:aFilenameString put:(cacheLine := Array new:2). |
|
1133 |
] ifFalse:[ |
|
1134 |
fileSize := (cacheLine at:1). |
|
1135 |
]. |
|
5856 | 1136 |
|
5859 | 1137 |
fileSize isNil ifTrue:[ |
1138 |
fileSize := aFilenameString asFilename fileSize. |
|
1139 |
cacheLine at:1 put:fileSize. |
|
1140 |
]. |
|
1141 |
]. |
|
5856 | 1142 |
]. |
1143 |
^ fileSize |
|
1144 |
! |
|
1145 |
||
1146 |
cachedHashValueOfFile:aFilenameString |
|
1147 |
|cache cacheLine hashValue| |
|
1148 |
||
1149 |
cache := self contentsInfoCache. |
|
1150 |
cache isNil ifTrue:[ |
|
5859 | 1151 |
hashValue := MD5Stream hashValueOfFile:aFilenameString asFilename |
5856 | 1152 |
] ifFalse:[ |
5859 | 1153 |
ContentsInfoCacheAccessLock critical:[ |
1154 |
cacheLine := cache at:aFilenameString ifAbsent:nil. |
|
1155 |
cacheLine isNil ifTrue:[ |
|
1156 |
cache at:aFilenameString put:(Array new:2). |
|
1157 |
] ifFalse:[ |
|
1158 |
hashValue := (cacheLine at:2). |
|
1159 |
]. |
|
5856 | 1160 |
|
5859 | 1161 |
hashValue isNil ifTrue:[ |
1162 |
hashValue := MD5Stream hashValueOfFile:aFilenameString asFilename. |
|
1163 |
cacheLine at:2 put:hashValue. |
|
1164 |
]. |
|
1165 |
]. |
|
5856 | 1166 |
]. |
1167 |
^ hashValue |
|
1168 |
! |
|
1169 |
||
1170 |
contentsInfoCache |
|
1171 |
ContentsInfoCache isNil ifTrue:[ |
|
1172 |
ContentsInfoCache := Dictionary new. |
|
1173 |
ContentsInfoCacheAccessLock := Semaphore forMutualExclusion. |
|
1174 |
]. |
|
1175 |
^ ContentsInfoCache |
|
1176 |
! |
|
1177 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1178 |
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
|
1179 |
containingString:contentsStringArg ignoreCaseInContents:ignCaseInContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1180 |
notContainingString:notContentsStringArg ignoreCaseInNotContents:ignCaseInNotContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1181 |
sameContentsAsFile:filenameToCompareContentsOrNil sameContentsAs:bytesToCompareContentsOrNil in:aDirectory |
3892 | 1182 |
|
5859 | 1183 |
|dir nameMatches lines contentsToCompare resultList matchedFilesList inStream |
5601 | 1184 |
doesFileMatch contentsString notContentsString check checkNot |
5859 | 1185 |
grepCommand nameMatch fileSizesToSearchFor filesToSearchFor fileMD5sToSearchFor |
1186 |
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
|
1187 |
|
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1188 |
contentsString := contentsStringArg. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1189 |
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
|
1190 |
notContentsString := notContentsStringArg. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1191 |
ignCaseInNotContents ifTrue:[ notContentsString := notContentsString asLowercase ]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1192 |
|
5723 | 1193 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
5768 | 1194 |
fileSizesToSearchFor := OrderedCollection new. |
1195 |
filesToSearchFor := OrderedCollection new. |
|
1196 |
fileMD5sToSearchFor := OrderedCollection new. |
|
1197 |
||
1198 |
filenameToCompareContentsOrNil includesMatchCharacters ifTrue:[ |
|
1199 |
dir := filenameToCompareContentsOrNil asFilename. |
|
1200 |
[dir pathName includesMatchCharacters] whileTrue:[ |
|
1201 |
dir := dir directory |
|
1202 |
]. |
|
1203 |
dir recursiveDirectoryContentsDo:[:relName | |
|
1204 |
|path fn| |
|
1205 |
||
1206 |
fn := dir construct:relName. |
|
5770 | 1207 |
(filenameToCompareContentsOrNil match:fn name) ifTrue:[ |
5847 | 1208 |
fn isDirectory ifFalse:[ |
5856 | 1209 |
fileSizesToSearchFor add:(self cachedFileSizeOf:fn). |
5847 | 1210 |
filesToSearchFor add:(fn name). |
5856 | 1211 |
fileMD5sToSearchFor add:(self cachedHashValueOfFile:fn). |
5847 | 1212 |
] |
5768 | 1213 |
] |
1214 |
]. |
|
1215 |
] ifFalse:[ |
|
1216 |
fn := filenameToCompareContentsOrNil asFilename. |
|
5856 | 1217 |
fileSizesToSearchFor add:(self cachedFileSizeOf:fn). |
5768 | 1218 |
filesToSearchFor add:(fn pathName). |
5856 | 1219 |
fileMD5sToSearchFor add:(self cachedHashValueOfFile:fn). |
5768 | 1220 |
]. |
1221 |
||
5859 | 1222 |
remember := LastRememberInCache := self rememberInCache value. |
5723 | 1223 |
remember ifTrue:[ |
5856 | 1224 |
cache := self contentsInfoCache. |
5723 | 1225 |
]. |
1226 |
]. |
|
5859 | 1227 |
setOfFilesToSearchFor := filesToSearchFor asSet. |
5791 | 1228 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1229 |
dir := aDirectory asFilename. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1230 |
self changeInformationTo:'Find File ' , '- searching .' , ((dir name) copyFrom:(self searchDirectoryHolder value asString size + 1)) toTab:false. |
3892 | 1231 |
|
5859 | 1232 |
resultList := self resultList. |
1233 |
matchedFilesList := self matchedFilesList. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1234 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1235 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1236 |
doesFileMatch := |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1237 |
[:f | |
5859 | 1238 |
|contentsMatches mustValidateExistance |
1239 |
fileMD5 fileName fileSize cacheLine idxInList matchedFile| |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1240 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1241 |
"/ contents compare ... |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1242 |
contentsMatches := false. |
5771 | 1243 |
fileName := f name. |
5859 | 1244 |
(setOfFilesToSearchFor includes:fileName) ifFalse:[ |
5850 | 1245 |
mustValidateExistance := false. |
5856 | 1246 |
|
5727 | 1247 |
cache notNil ifTrue:[ |
5859 | 1248 |
ContentsInfoCacheAccessLock critical:[ |
1249 |
cacheLine := cache at:fileName ifAbsent:nil. |
|
1250 |
cacheLine notNil ifTrue:[ |
|
1251 |
fileSize := cacheLine at:1. |
|
1252 |
fileMD5 := cacheLine at:2. |
|
1253 |
mustValidateExistance := true. |
|
1254 |
]. |
|
5727 | 1255 |
]. |
5723 | 1256 |
]. |
5850 | 1257 |
|
5723 | 1258 |
fileSize isNil ifTrue:[ |
1259 |
fileSize := f fileSize. |
|
1260 |
]. |
|
1261 |
remember ifTrue:[ |
|
5859 | 1262 |
ContentsInfoCacheAccessLock critical:[ |
1263 |
cacheLine := cache at:fileName ifAbsentPut:[Array new:2]. |
|
1264 |
cacheLine at:1 put:fileSize. |
|
1265 |
] |
|
5723 | 1266 |
]. |
5768 | 1267 |
(idxInList := fileSizesToSearchFor indexOf:fileSize) ~~ 0 ifTrue:[ |
5723 | 1268 |
fileMD5 isNil ifTrue:[ |
5850 | 1269 |
OpenError handle:[:ex | |
1270 |
ObjectMemory garbageCollect. |
|
1271 |
fileMD5 := MD5Stream hashValueOfFile:f. |
|
1272 |
] do:[ |
|
1273 |
fileMD5 := MD5Stream hashValueOfFile:f. |
|
1274 |
]. |
|
5723 | 1275 |
remember ifTrue:[ |
1276 |
cacheLine at:2 put:fileMD5 |
|
1277 |
]. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1278 |
]. |
5768 | 1279 |
contentsMatches := (fileMD5 = (fileMD5sToSearchFor at:idxInList)). |
5850 | 1280 |
contentsMatches ifTrue:[ |
1281 |
mustValidateExistance ifTrue:[ |
|
1282 |
fileName asFilename exists ifFalse:[ |
|
5859 | 1283 |
ContentsInfoCacheAccessLock critical:[ |
1284 |
cache removeKey:fileName. |
|
1285 |
]. |
|
5850 | 1286 |
contentsMatches := false. |
1287 |
]. |
|
5859 | 1288 |
]. |
1289 |
contentsMatches ifTrue:[ |
|
1290 |
matchedFile := filesToSearchFor at:idxInList. |
|
1291 |
matchedFilesList add:matchedFile. |
|
1292 |
]. |
|
5850 | 1293 |
]. |
5723 | 1294 |
"/ contentsToCompare isNil ifTrue:[ |
1295 |
"/ filenameToCompareContentsOrNil fileSize < (512*1024) ifTrue:[ |
|
1296 |
"/ contentsToCompare := filenameToCompareContentsOrNil binaryContentsOfEntireFile |
|
1297 |
"/ ] |
|
1298 |
"/ ]. |
|
1299 |
"/ contentsToCompare isNil ifTrue:[ |
|
1300 |
"/ "/ too large - compare block-wise ... |
|
1301 |
"/ contentsMatches := (filenameToCompareContentsOrNil sameContentsAs:f). |
|
1302 |
"/ ] ifFalse:[ |
|
1303 |
"/ contentsMatches := contentsToCompare = (f binaryContentsOfEntireFile). |
|
1304 |
"/ ] |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1305 |
]. |
5773 | 1306 |
] ifTrue:[ |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1307 |
f isSymbolicLink ifTrue:[ |
5859 | 1308 |
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
|
1309 |
] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1310 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1311 |
contentsMatches |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1312 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1313 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1314 |
(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
|
1315 |
doesFileMatch := [:f | true]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1316 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1317 |
(self canUseGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1318 |
and:[self useGrep value]) ifTrue:[ |
5601 | 1319 |
(ignCaseInContents not and:[ignCaseInNotContents not]) ifTrue:[ |
1320 |
contentsString notNil ifTrue:[ |
|
1321 |
notContentsString notNil ifTrue:[ |
|
1322 |
grepCommand := '(grep "',contentsString,'" %1) && (grep -v "',notContentsString,'" %1)'. |
|
1323 |
] ifFalse:[ |
|
1324 |
grepCommand := 'grep "' , contentsString , '" %1'. |
|
1325 |
]. |
|
1326 |
] ifFalse:[ |
|
1327 |
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
|
1328 |
]. |
5601 | 1329 |
doesFileMatch := [:f | |cmd ret| |
1330 |
cmd := grepCommand bindWith:f pathName. |
|
1331 |
ret := OperatingSystem executeCommand:cmd. |
|
1332 |
ret |
|
1333 |
]. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1334 |
] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1335 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1336 |
|
5601 | 1337 |
doesFileMatch isNil ifTrue:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1338 |
contentsString notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1339 |
ignCaseInContents ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1340 |
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
|
1341 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1342 |
check := [:l | l includesString:contentsString] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1343 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1344 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1345 |
notContentsString notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1346 |
ignCaseInNotContents ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1347 |
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
|
1348 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1349 |
checkNot := [:l | l includesString:notContentsString] |
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 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1352 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1353 |
doesFileMatch := |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1354 |
[:f | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1355 |
|contentsMatches| |
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 |
"/ string search ... |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1358 |
contentsMatches := true. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1359 |
(f exists and:[f isReadable]) ifFalse:[ |
5859 | 1360 |
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
|
1361 |
] ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1362 |
f fileSize > (4024*1024) ifTrue:[ |
5859 | 1363 |
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
|
1364 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1365 |
Stream lineTooLongErrorSignal handle:[:ex | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1366 |
|cont| |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1367 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1368 |
"/ 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
|
1369 |
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
|
1370 |
check notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1371 |
checkNot isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1372 |
contentsMatches := check value:cont |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1373 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1374 |
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
|
1375 |
] |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1376 |
] ifFalse:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1377 |
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
|
1378 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1379 |
] do:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1380 |
lines := f contents ? #(). |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1381 |
check notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1382 |
checkNot isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1383 |
contentsMatches := (lines contains:check). |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1384 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1385 |
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
|
1386 |
] |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1387 |
] ifFalse:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1388 |
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
|
1389 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1390 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1391 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1392 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1393 |
contentsMatches |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1394 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1395 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1396 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1397 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1398 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1399 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1400 |
(self canUseLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1401 |
and:[self useLocate value |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1402 |
and:[searchDirectories not]]) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1403 |
ifTrue:[ |
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 |
|cmd line f| |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1406 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1407 |
cmd := 'locate '. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1408 |
ignCaseInName ifTrue:[ |
5408 | 1409 |
cmd := cmd , '--ignore-case ' |
5176
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 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1412 |
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
|
1413 |
asStringCollection asStringWith:Character space). |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1414 |
inStream := PipeStream readingFrom:cmd inDirectory:dir. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1415 |
[inStream atEnd] whileFalse:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1416 |
line := inStream nextLine. |
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 |
f := line asFilename. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1419 |
(doesFileMatch value:f) ifTrue:[ |
5859 | 1420 |
resultList add:line. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1421 |
] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1422 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1423 |
] ensure:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1424 |
inStream notNil ifTrue:[inStream close]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1425 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1426 |
^ self. |
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 |
|
3892 | 1429 |
bytesToCompareContentsOrNil notNil ifTrue:[ |
1430 |
contentsToCompare := bytesToCompareContentsOrNil |
|
1431 |
]. |
|
1432 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1433 |
namePatterns isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1434 |
nameMatch := [:fn | true] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1435 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1436 |
ignCaseInName ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1437 |
nameMatch := [:fn | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1438 |
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
|
1439 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1440 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1441 |
nameMatch := [:fn | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1442 |
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
|
1443 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1444 |
]. |
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 |
|
5726 | 1447 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
5727 | 1448 |
self searchOnlyInCache value ifTrue:[ |
5726 | 1449 |
cache notEmptyOrNil ifTrue:[ |
1450 |
cache keysAndValuesDo:[:fn :info | |
|
5768 | 1451 |
|filesSize filesMD5 idxInList| |
5727 | 1452 |
|
5726 | 1453 |
filesSize := info at:1. |
1454 |
filesSize isNil ifTrue:[ |
|
1455 |
filesSize := fn asFilename fileSize. |
|
1456 |
info at:1 put:filesSize. |
|
1457 |
]. |
|
5768 | 1458 |
(idxInList := fileSizesToSearchFor indexOf:filesSize) ~~ 0 ifTrue:[ |
5859 | 1459 |
(setOfFilesToSearchFor includes:fn) not ifTrue:[ |
5729 | 1460 |
fn asFilename exists ifFalse:[ |
1461 |
info at:1 put:nil. |
|
1462 |
info at:2 put:nil. |
|
1463 |
] ifTrue:[ |
|
1464 |
filesMD5 := info at:2. |
|
1465 |
filesMD5 isNil ifTrue:[ |
|
1466 |
filesMD5 := MD5Stream hashValueOfFile:fn asFilename. |
|
1467 |
info at:2 put:filesMD5. |
|
1468 |
]. |
|
5768 | 1469 |
filesMD5 = (fileMD5sToSearchFor at:idxInList) ifTrue:[ |
5859 | 1470 |
resultList add:fn. |
5728 | 1471 |
] |
5727 | 1472 |
] |
5726 | 1473 |
] |
1474 |
] |
|
1475 |
]. |
|
1476 |
]. |
|
1477 |
^ self. |
|
1478 |
]. |
|
1479 |
]. |
|
1480 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1481 |
self |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1482 |
doFindFileNamed:namePatterns |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1483 |
directories:searchDirectories |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1484 |
nameMatch:nameMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1485 |
contentsMatch:doesFileMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1486 |
in:dir. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1487 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1488 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1489 |
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
|
1490 |
|dir subDirs list directoryContents| |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1491 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1492 |
dir := aDirectory asFilename. |
5844 | 1493 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1494 |
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
|
1495 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1496 |
list := self resultList. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1497 |
|
3892 | 1498 |
subDirs := OrderedCollection new. |
1499 |
||
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1500 |
[ |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1501 |
directoryContents := dir directoryContents. |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1502 |
] on:FileStream openErrorSignal do:[:ex| |
5811
c397040c27b4
openErrorSignal arg: always a string
Claus Gittinger <cg@exept.de>
parents:
5791
diff
changeset
|
1503 |
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
|
1504 |
"/ 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
|
1505 |
"/ bindWith:ex parameter printString |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1506 |
"/ with:ex description) withCRs. |
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1507 |
^ self |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1508 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1509 |
|
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1510 |
directoryContents sort do:[:fn | |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1511 |
|f isDirectory| |
3892 | 1512 |
|
1513 |
f := dir construct:fn. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1514 |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1515 |
isDirectory := f isDirectory. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1516 |
isDirectory ifTrue:[ |
3892 | 1517 |
f isSymbolicLink ifFalse:[ |
1518 |
subDirs add:f |
|
1519 |
] |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1520 |
]. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1521 |
(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
|
1522 |
(nameMatch value:fn) ifTrue:[ |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1523 |
(isDirectory or:[ doesFileMatch value:f ]) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1524 |
ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1525 |
list add:(f asString). |
3892 | 1526 |
] |
1527 |
] |
|
1528 |
] |
|
1529 |
]. |
|
1530 |
||
1531 |
self searchRecursively value ifTrue:[ |
|
1532 |
subDirs do:[:dir | |
|
1533 |
self |
|
1534 |
doFindFileNamed:namePatterns |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1535 |
directories:searchDirectories |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1536 |
nameMatch:nameMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1537 |
contentsMatch:doesFileMatch |
3892 | 1538 |
in:dir |
1539 |
]. |
|
1540 |
] |
|
1541 |
! ! |
|
1542 |
||
1543 |
!FindFileApplication methodsFor:'queries'! |
|
1544 |
||
1545 |
getTabStringEnd |
|
1546 |
||
1547 |
" get the tab string from the application list on the class side " |
|
1548 |
||
1549 |
^ self fileName directory asString |
|
1550 |
! |
|
1551 |
||
1552 |
hasOneFileSelected |
|
1553 |
| sel | |
|
1554 |
sel := self selectionHolder value. |
|
1555 |
^ (sel notNil and:[sel notEmpty and:[sel size = 1]]) |
|
1556 |
! |
|
1557 |
||
1558 |
hasSelectionInResultList |
|
1559 |
| sel | |
|
1560 |
sel := self selectionHolder value. |
|
1561 |
^ (sel notNil and:[sel notEmpty]) |
|
1562 |
! ! |
|
1563 |
||
1564 |
!FindFileApplication methodsFor:'startup & release'! |
|
1565 |
||
5010 | 1566 |
item:anItem |
3892 | 1567 |
|
4797 | 1568 |
|file newPattern| |
3892 | 1569 |
|
5010 | 1570 |
super item:anItem. |
4797 | 1571 |
|
3892 | 1572 |
file := self fileName. |
1573 |
self searchDirectoryHolder value:(self getDirWithoutFileName:file). |
|
4797 | 1574 |
|
3892 | 1575 |
file isDirectory ifTrue:[ |
4797 | 1576 |
newPattern := '*'. |
3892 | 1577 |
] ifFalse:[ |
5010 | 1578 |
newPattern := '*.', anItem suffix. |
3892 | 1579 |
]. |
4797 | 1580 |
self namePatternHolder value:newPattern. |
3892 | 1581 |
self enableStop value:false. |
1582 |
self enableSearch value:true. |
|
1583 |
^ true. |
|
1584 |
! |
|
1585 |
||
1586 |
postOpenWith:aBuilder |
|
1587 |
||
1588 |
self masterApplication isNil ifTrue:[ |
|
1589 |
self masterApplication:nil. |
|
1590 |
]. |
|
1591 |
findFileView := aBuilder window. |
|
1592 |
self windowGroup addPreEventHook:self. |
|
1593 |
^ super postOpenWith:aBuilder. |
|
1594 |
! |
|
1595 |
||
1596 |
release |
|
1597 |
self stopSearchTask. |
|
5856 | 1598 |
ContentsInfoCache := ContentsInfoCacheAccessLock := nil. |
3892 | 1599 |
^ super release |
1600 |
! ! |
|
1601 |
||
1602 |
!FindFileApplication class methodsFor:'documentation'! |
|
1603 |
||
1604 |
version |
|
5859 | 1605 |
^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.53 2004-05-18 12:00:46 cg Exp $' |
3892 | 1606 |
! ! |