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