author | Claus Gittinger <cg@exept.de> |
Wed, 10 Nov 2004 10:06:28 +0100 | |
changeset 6123 | f0bf15dac63b |
parent 6109 | aed06872e73e |
child 6154 | 606d9cc12d52 |
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: 'Close' |
|
456 |
#translateLabel: true |
|
457 |
#isButton: true |
|
458 |
#startGroup: #right |
|
459 |
#value: #doClose |
|
6093 | 460 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #removeTabIcon) |
3892 | 461 |
) |
462 |
) |
|
463 |
nil |
|
464 |
nil |
|
465 |
) |
|
466 |
! ! |
|
467 |
||
6107 | 468 |
!FindFileApplication class methodsFor:'startup & release'! |
469 |
||
470 |
releaseContentsInfoCache |
|
471 |
ContentsInfoCache := ContentsInfoCacheAccessLock := nil. |
|
472 |
! ! |
|
473 |
||
3892 | 474 |
!FindFileApplication class methodsFor:'tableColumns specs'! |
475 |
||
476 |
searchResultTable |
|
477 |
"This resource specification was automatically generated |
|
478 |
by the DataSetBuilder of ST/X." |
|
479 |
||
480 |
"Do not manually edit this!! If it is corrupted, |
|
481 |
the DataSetBuilder may not be able to read the specification." |
|
482 |
||
483 |
" |
|
484 |
DataSetBuilder new openOnClass:FindFileApplication andSelector:#searchResultTable |
|
485 |
" |
|
486 |
||
487 |
<resource: #tableColumns> |
|
488 |
||
489 |
^#( |
|
490 |
#(#DataSetColumnSpec |
|
491 |
#label: 'Filename' |
|
492 |
#id: 'FileName' |
|
493 |
#labelButtonType: #Button |
|
494 |
#model: #fileName |
|
495 |
#showRowSeparator: false |
|
496 |
#showColSeparator: false |
|
497 |
) |
|
498 |
) |
|
499 |
||
500 |
! ! |
|
501 |
||
502 |
!FindFileApplication methodsFor:'accessing'! |
|
503 |
||
504 |
accessLock |
|
505 |
"return the value of the instance variable 'accessLock' (automatically generated)" |
|
506 |
||
507 |
accessLock isNil ifTrue:[ |
|
508 |
accessLock := Semaphore forMutualExclusion name:'accessLock'. |
|
509 |
]. |
|
510 |
^ accessLock |
|
511 |
! |
|
512 |
||
513 |
stopSignal |
|
514 |
||
515 |
stopSignal isNil ifTrue:[ |
|
516 |
stopSignal := Signal new. |
|
517 |
]. |
|
518 |
^ stopSignal |
|
4101 | 519 |
! |
520 |
||
521 |
targetApplication:something |
|
522 |
"set the value of the instance variable 'targetApplication' (automatically generated)" |
|
523 |
||
524 |
targetApplication := something. |
|
3892 | 525 |
! ! |
526 |
||
527 |
!FindFileApplication methodsFor:'actions'! |
|
528 |
||
529 |
changeInformationTo:aString |
|
530 |
||
531 |
self changeInformationTo:aString toTab:false |
|
532 |
! |
|
533 |
||
534 |
changeInformationTo:aString toTab:aBoolean |
|
535 |
masterApplication isNil ifTrue:[ |
|
536 |
findFileView label:aString |
|
537 |
] ifFalse:[ |
|
538 |
aBoolean ifTrue:[ |
|
539 |
masterApplication tabStringChangeTo:aString for:self |
|
540 |
] |
|
541 |
]. |
|
542 |
! |
|
543 |
||
5850 | 544 |
clearCache |
6107 | 545 |
contentsInfoCache := nil |
5850 | 546 |
! |
547 |
||
5766 | 548 |
clearResultList |
549 |
self resultList removeAll. |
|
5859 | 550 |
self matchedFilesList removeAll. |
551 |
! |
|
552 |
||
553 |
clearShownList |
|
5864 | 554 |
self shownList removeAll. |
5766 | 555 |
! |
556 |
||
557 |
copySelectedFileNamesToClipboard |
|
3892 | 558 |
|sel list stream| |
559 |
||
560 |
sel := self selectionHolder value. |
|
5859 | 561 |
list := self shownList. |
3892 | 562 |
(sel notNil and:[sel notEmpty]) ifTrue:[ |
563 |
stream := WriteStream on:''. |
|
564 |
sel do:[: key | |
|
565 |
stream nextPutAll:(list at:key). |
|
566 |
stream cr. |
|
567 |
]. |
|
6038
ed07ac0069b2
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
5961
diff
changeset
|
568 |
self window setClipboardText:stream contents. |
3892 | 569 |
stream close. |
570 |
]. |
|
571 |
! |
|
572 |
||
5766 | 573 |
deleteAllFiles |
574 |
|files| |
|
575 |
||
5864 | 576 |
files := self shownList copy. |
5766 | 577 |
self deleteFiles:files confirm:true. |
5859 | 578 |
self clearShownList. |
5766 | 579 |
! |
580 |
||
581 |
deleteFiles:colOfFiles confirm:confirm |
|
582 |
"delete current selected files/directories |
|
583 |
" |
|
584 |
|delete result| |
|
585 |
||
586 |
self windowGroup withWaitCursorDo:[ |
|
5961 | 587 |
delete := FileOperation deleteFiles:(colOfFiles asSet) confirm:confirm. |
5766 | 588 |
result := delete result. |
589 |
result notNil ifTrue:[ |
|
590 |
result ifFalse:[ |
|
591 |
self notify:delete errorString. |
|
592 |
] ifTrue:[ |
|
5769 | 593 |
"/ masterApplication notNil ifTrue:[ |
594 |
"/ masterApplication updateListAfterDelete:colOfFiles. |
|
595 |
"/ ] |
|
5766 | 596 |
] |
597 |
]. |
|
598 |
]. |
|
599 |
^ result. |
|
600 |
! |
|
601 |
||
602 |
deleteSelectedFiles |
|
5856 | 603 |
|sel files result| |
5766 | 604 |
|
605 |
sel := self selectionHolder value. |
|
6109 | 606 |
sel isEmptyOrNil ifTrue:[^ self]. |
607 |
||
5864 | 608 |
files := sel collect:[:idx | self shownList at:idx]. |
5766 | 609 |
self deleteFiles:files confirm:true. |
5856 | 610 |
result == true ifTrue:[ |
611 |
self removeSelectedFilesFromResultList. |
|
612 |
]. |
|
5766 | 613 |
! |
614 |
||
3892 | 615 |
doSearch |
616 |
||
5864 | 617 |
| namePattern namePatterns contentsPattern notContentsPattern dir fileToCompareAgainst thisSearchTask| |
3892 | 618 |
|
619 |
"/ self changeExtentToSeeSearchResult. |
|
620 |
||
621 |
dir := self searchDirectoryHolder value. |
|
622 |
dir isNil ifTrue:[ |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
623 |
Dialog warn:'Missing directory name'. |
3892 | 624 |
^ self. |
625 |
]. |
|
626 |
dir asFilename exists not ifTrue:[ |
|
5786
3ae2d45d823f
care for whitespace in searchpattern
Claus Gittinger <cg@exept.de>
parents:
5776
diff
changeset
|
627 |
Dialog warn:('No such directory: ''%1''' bindWith:dir asString allBold). |
3892 | 628 |
^ self. |
629 |
]. |
|
630 |
||
631 |
searchTask notNil ifTrue:[ |
|
632 |
(Dialog |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
633 |
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
|
634 |
yesLabel:(resources at:'Stop other Task and Proceed') |
3892 | 635 |
noLabel:(resources at:'Cancel')) |
636 |
ifFalse:[^ self]. |
|
637 |
self stop. |
|
638 |
]. |
|
639 |
||
640 |
namePattern := self namePatternHolder value. |
|
641 |
namePattern size == 0 ifTrue:[ |
|
642 |
namePatterns := nil |
|
643 |
] ifFalse:[ |
|
644 |
ignoreCaseInName value ifTrue:[ |
|
645 |
namePattern := namePattern asLowercase |
|
646 |
]. |
|
5786
3ae2d45d823f
care for whitespace in searchpattern
Claus Gittinger <cg@exept.de>
parents:
5776
diff
changeset
|
647 |
namePatterns := namePattern asCollectionOfSubstringsSeparatedBy:$;. |
3ae2d45d823f
care for whitespace in searchpattern
Claus Gittinger <cg@exept.de>
parents:
5776
diff
changeset
|
648 |
namePatterns := namePatterns collect:[:each | each withoutSeparators]. |
3892 | 649 |
]. |
650 |
contentsPattern := self contentsPatternHolder value. |
|
651 |
contentsPattern size == 0 ifTrue:[ |
|
652 |
contentsPattern := nil |
|
653 |
] ifFalse:[ |
|
654 |
self ignoreCaseInContents value ifTrue:[ |
|
655 |
contentsPattern := contentsPattern asLowercase |
|
656 |
] |
|
657 |
]. |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
658 |
notContentsPattern := self notContentsPatternHolder value. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
659 |
notContentsPattern size == 0 ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
660 |
notContentsPattern := nil |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
661 |
] ifFalse:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
662 |
self ignoreCaseInNotContents value ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
663 |
notContentsPattern := notContentsPattern asLowercase |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
664 |
] |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
665 |
]. |
5787 | 666 |
searchForSameContents value ifTrue:[ |
667 |
fileToCompareAgainst := (self sameContentsAsHolder value ? '') withoutSeparators. |
|
668 |
fileToCompareAgainst isEmpty ifTrue:[ |
|
669 |
fileToCompareAgainst := nil. |
|
670 |
] ifFalse:[ |
|
671 |
fileToCompareAgainst includesMatchCharacters ifFalse:[ |
|
672 |
fileToCompareAgainst asFilename exists ifFalse:[ |
|
673 |
Dialog warn:('No such file: %1' bindWith:fileToCompareAgainst asString allBold). |
|
674 |
^ self. |
|
675 |
]. |
|
676 |
fileToCompareAgainst asFilename isReadable ifFalse:[ |
|
677 |
Dialog warn:('Cannot read: %1' bindWith:fileToCompareAgainst asString allBold). |
|
678 |
^ self. |
|
679 |
] |
|
5768 | 680 |
]. |
5726 | 681 |
]. |
5723 | 682 |
]. |
683 |
||
5864 | 684 |
searchTask := thisSearchTask := |
5776 | 685 |
[ |
686 |
|message t| |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
687 |
|
5776 | 688 |
[ |
689 |
(self stopSignal) catch:[ |
|
690 |
self enableStop value:true. |
|
691 |
self resultList removeAll. |
|
5859 | 692 |
self matchedFilesList removeAll. |
5776 | 693 |
self changeInformationTo:'Find File ' , '- searching ' toTab:true. |
694 |
self notify:'searching...'. |
|
695 |
t := Time millisecondsToRun:[ |
|
5770 | 696 |
|
5776 | 697 |
self |
698 |
doFindFileNamed:namePatterns |
|
699 |
directories:(self searchDirectories value) |
|
700 |
ignoreCase:(self ignoreCaseInName value) |
|
701 |
containingString:contentsPattern |
|
702 |
ignoreCaseInContents:(self ignoreCaseInContents value) |
|
703 |
notContainingString:notContentsPattern |
|
704 |
ignoreCaseInNotContents:(self ignoreCaseInNotContents value) |
|
705 |
sameContentsAsFile:fileToCompareAgainst |
|
706 |
sameContentsAs:nil |
|
707 |
in:(self searchDirectoryHolder value). |
|
5770 | 708 |
|
5776 | 709 |
]. |
710 |
t > 100 ifTrue:[ |
|
711 |
t := ((t / 1000) asFixedPoint:2) printString , ' s' |
|
712 |
] ifFalse:[ |
|
713 |
t := t printString , ' ms' |
|
714 |
]. |
|
715 |
message := 'Found %1 file%2 in %3' bindWith:(resultList size) with:(resultList size == 1 ifTrue:'' ifFalse:'s') with:t. |
|
716 |
self enableStop value:false. |
|
717 |
self enableSearch value:true. |
|
718 |
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
|
719 |
]. |
5776 | 720 |
] valueNowOrOnUnwindDo:[ |
5864 | 721 |
thisSearchTask == searchTask ifTrue:[ |
722 |
searchTask := nil. |
|
723 |
self enableStop value:false. |
|
724 |
self notify:message. |
|
725 |
]. |
|
5776 | 726 |
] |
727 |
] newProcess. |
|
3892 | 728 |
|
5776 | 729 |
searchTask priorityRange:(Processor systemBackgroundPriority to:Processor userSchedulingPriority). |
3892 | 730 |
searchTask name:('FindFile[', self searchDirectoryHolder value asFilename baseName, ']'). |
731 |
searchTask resume. |
|
732 |
! |
|
733 |
||
734 |
openInNewBrowser |
|
735 |
|sel| |
|
736 |
||
737 |
sel := self selectionHolder value. |
|
738 |
(sel notNil and:[sel notEmpty]) ifTrue:[ |
|
5859 | 739 |
FileBrowserV2 openOn:(self shownList at:sel first) asFilename |
3892 | 740 |
]. |
741 |
! |
|
742 |
||
5766 | 743 |
removeSelectedFilesFromResultList |
3892 | 744 |
|sel list| |
745 |
||
746 |
sel := self selectionHolder value. |
|
5864 | 747 |
list := self shownList. |
3892 | 748 |
(sel notNil and:[sel notEmpty]) ifTrue:[ |
749 |
sel reverseDo:[: key | |
|
750 |
list removeAtIndex:key |
|
751 |
] |
|
752 |
]. |
|
753 |
! |
|
754 |
||
755 |
selectInBrowser |
|
756 |
|sel entry application| |
|
757 |
||
758 |
sel := self selectionHolder value. |
|
759 |
(sel notNil and:[sel notEmpty]) ifTrue:[ |
|
5859 | 760 |
entry := self shownList at:sel first. |
5252 | 761 |
entry asFilename exists ifFalse:[ ^ self]. |
4101 | 762 |
application := targetApplication ? self masterApplication. |
4182 | 763 |
application notNil ifTrue:[ |
4101 | 764 |
application gotoFile:(entry asFilename). |
765 |
]. |
|
3892 | 766 |
]. |
767 |
! |
|
768 |
||
5859 | 769 |
showMatchedFiles:aBoolean |
770 |
aBoolean ifTrue:[ |
|
5864 | 771 |
self shownListHolder valueHolder:(self matchedFilesList) |
5859 | 772 |
] ifFalse:[ |
5864 | 773 |
self shownListHolder valueHolder:(self resultList) |
5859 | 774 |
]. |
775 |
! |
|
776 |
||
3892 | 777 |
stop |
778 |
||
779 |
searchTask notNil ifTrue:[ |
|
780 |
self accessLock critical:[ |
|
781 |
searchTask interruptWith:[stopSignal raiseRequest]. |
|
782 |
] |
|
783 |
]. |
|
784 |
self enableStop value:false. |
|
785 |
self enableSearch value:true. |
|
786 |
self changeInformationTo:'Find File ' , '- search stopped' toTab:true. |
|
787 |
! |
|
788 |
||
789 |
stopSearchTask |
|
790 |
|task| |
|
791 |
||
792 |
(task := searchTask) notNil ifTrue:[ |
|
793 |
searchTask := nil. |
|
794 |
||
795 |
Object errorSignal handle:[:ex| |
|
796 |
Dialog warn:ex description. |
|
797 |
]do:[ |
|
798 |
task isDead ifFalse:[ |
|
3937
80d958725879
terminateWithAllSUbprocesses -> xxxInGroup
Claus Gittinger <cg@exept.de>
parents:
3892
diff
changeset
|
799 |
task terminateWithAllSubprocessesInGroup. |
3892 | 800 |
task waitUntilTerminated. |
801 |
] |
|
802 |
] |
|
803 |
]. |
|
804 |
! ! |
|
805 |
||
806 |
!FindFileApplication methodsFor:'aspects'! |
|
807 |
||
5856 | 808 |
autoSelectInBrowser |
809 |
^ false. |
|
810 |
! |
|
811 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
812 |
canUseGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
813 |
"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
|
814 |
- not under MSDOS |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
815 |
" |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
816 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
817 |
^ 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
|
818 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
819 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
820 |
canUseLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
821 |
"locate command is much faster, but: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
822 |
- only if searching recursively, |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
823 |
- no case ignore |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
824 |
- no contents matching |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
825 |
" |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
826 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
827 |
^ OperatingSystem isUNIXlike and:[ OperatingSystem canExecuteCommand:'locate' ] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
828 |
! |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
829 |
|
3892 | 830 |
contentsPatternHolder |
831 |
||
832 |
contentsPatternHolder isNil ifTrue:[ |
|
833 |
contentsPatternHolder := nil asValue. |
|
834 |
]. |
|
835 |
^ contentsPatternHolder. |
|
836 |
! |
|
837 |
||
838 |
enableSearch |
|
839 |
||
840 |
enableSearch isNil ifTrue:[ |
|
841 |
enableSearch := true asValue. |
|
842 |
]. |
|
843 |
^ enableSearch. |
|
844 |
! |
|
845 |
||
846 |
enableStop |
|
847 |
||
848 |
enableStop isNil ifTrue:[ |
|
849 |
enableStop := true asValue. |
|
850 |
]. |
|
851 |
^ enableStop. |
|
852 |
! |
|
853 |
||
854 |
hasListEntries |
|
855 |
||
856 |
hasListEntries isNil ifTrue:[ |
|
857 |
hasListEntries := false asValue. |
|
858 |
]. |
|
859 |
^ hasListEntries. |
|
860 |
! |
|
861 |
||
862 |
ignoreCaseInContents |
|
863 |
ignoreCaseInContents isNil ifTrue:[ |
|
864 |
ignoreCaseInContents := false asValue. |
|
865 |
]. |
|
866 |
^ ignoreCaseInContents. |
|
867 |
! |
|
868 |
||
869 |
ignoreCaseInName |
|
870 |
||
871 |
ignoreCaseInName isNil ifTrue:[ |
|
872 |
ignoreCaseInName := false asValue. |
|
873 |
]. |
|
874 |
^ ignoreCaseInName. |
|
875 |
! |
|
876 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
877 |
ignoreCaseInNotContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
878 |
ignoreCaseInNotContents isNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
879 |
ignoreCaseInNotContents := false asValue. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
880 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
881 |
^ ignoreCaseInNotContents. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
882 |
! |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
883 |
|
5859 | 884 |
matchedFilesList |
885 |
||
886 |
matchedFilesList isNil ifTrue:[ |
|
887 |
matchedFilesList := List new. |
|
888 |
matchedFilesList addDependent:self. |
|
889 |
]. |
|
890 |
^ matchedFilesList. |
|
891 |
! |
|
892 |
||
3892 | 893 |
namePatternHolder |
894 |
||
895 |
namePatternHolder isNil ifTrue:[ |
|
896 |
namePatternHolder := '*' asValue. |
|
897 |
]. |
|
898 |
^ namePatternHolder. |
|
899 |
! |
|
900 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
901 |
notContentsPatternHolder |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
902 |
|
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
903 |
notContentsPatternHolder isNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
904 |
notContentsPatternHolder := nil asValue. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
905 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
906 |
^ notContentsPatternHolder. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
907 |
! |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
908 |
|
3892 | 909 |
notSearchForSameContents |
5743 | 910 |
^ BlockValue forLogicalNot:self searchForSameContents |
3892 | 911 |
! |
912 |
||
5859 | 913 |
notShowingMatchedFiles |
5865 | 914 |
^ self shownList == self resultList |
5859 | 915 |
! |
916 |
||
5723 | 917 |
rememberInCache |
918 |
rememberInCache isNil ifTrue:[ |
|
5859 | 919 |
rememberInCache := (LastRememberInCache ? false) asValue. |
5723 | 920 |
]. |
921 |
^ rememberInCache. |
|
922 |
! |
|
923 |
||
3892 | 924 |
resultList |
925 |
resultList isNil ifTrue:[ |
|
926 |
resultList := List new. |
|
927 |
resultList addDependent:self. |
|
928 |
]. |
|
929 |
^ resultList. |
|
930 |
! |
|
931 |
||
5723 | 932 |
sameContentsAsHolder |
933 |
|sel| |
|
934 |
||
935 |
sameContentsAsHolder isNil ifTrue:[ |
|
936 |
sameContentsAsHolder := ValueHolder new. |
|
937 |
masterApplication notNil ifTrue:[ |
|
938 |
sel := masterApplication currentSelectedFiles. |
|
939 |
sel size > 0 ifTrue:[ |
|
940 |
sameContentsAsHolder value:(sel first asFilename pathName). |
|
941 |
]. |
|
942 |
]. |
|
943 |
]. |
|
944 |
^ sameContentsAsHolder. |
|
945 |
! |
|
946 |
||
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
947 |
searchDirectories |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
948 |
searchDirectories isNil ifTrue:[ |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
949 |
searchDirectories := false asValue. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
950 |
]. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
951 |
^ searchDirectories. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
952 |
! |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
953 |
|
3892 | 954 |
searchDirectoryHolder |
955 |
||
956 |
searchDirectoryHolder isNil ifTrue:[ |
|
957 |
searchDirectoryHolder := ValueHolder new. |
|
958 |
]. |
|
959 |
^ searchDirectoryHolder. |
|
960 |
! |
|
961 |
||
5743 | 962 |
searchForSameContents |
963 |
searchForSameContents isNil ifTrue:[ |
|
964 |
searchForSameContents := false asValue. |
|
965 |
]. |
|
966 |
^ searchForSameContents. |
|
967 |
! |
|
968 |
||
5726 | 969 |
searchOnlyInCache |
970 |
searchOnlyInCache isNil ifTrue:[ |
|
971 |
searchOnlyInCache := false asValue. |
|
972 |
]. |
|
973 |
^ searchOnlyInCache. |
|
974 |
! |
|
975 |
||
3892 | 976 |
searchRecursively |
977 |
||
978 |
searchRecursively isNil ifTrue:[ |
|
979 |
searchRecursively := true asValue. |
|
980 |
]. |
|
981 |
^ searchRecursively. |
|
982 |
! |
|
983 |
||
984 |
searchResultTable |
|
985 |
||
986 |
searchResultTable isNil ifTrue:[ |
|
987 |
searchResultTable := self class searchResultTable asValue. |
|
988 |
]. |
|
989 |
^ searchResultTable. |
|
990 |
! |
|
991 |
||
992 |
selectionHolder |
|
993 |
||
994 |
selectionHolder isNil ifTrue:[ |
|
4101 | 995 |
selectionHolder := ValueHolder new. |
996 |
selectionHolder addDependent:self. |
|
3892 | 997 |
]. |
998 |
^ selectionHolder |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
999 |
! |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1000 |
|
5859 | 1001 |
showingMatchedFiles |
5865 | 1002 |
^ self shownList == self matchedFilesList |
5859 | 1003 |
! |
1004 |
||
1005 |
shownList |
|
5864 | 1006 |
^ self shownListHolder valueHolder. |
1007 |
! |
|
1008 |
||
1009 |
shownListHolder |
|
1010 |
shownListHolder isNil ifTrue:[ |
|
1011 |
shownListHolder := IndirectValue for:(self resultList). |
|
1012 |
shownListHolder addDependent:self. |
|
5859 | 1013 |
]. |
5864 | 1014 |
^ shownListHolder. |
5859 | 1015 |
! |
1016 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1017 |
useGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1018 |
useGrep isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1019 |
useGrep := false asValue. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1020 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1021 |
^ useGrep. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1022 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1023 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1024 |
useLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1025 |
useLocate isNil ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1026 |
useLocate := false asValue. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1027 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1028 |
^ useLocate. |
3892 | 1029 |
! ! |
1030 |
||
1031 |
!FindFileApplication methodsFor:'change & update'! |
|
1032 |
||
1033 |
update:something with:aParameter from:changedObject |
|
5864 | 1034 |
changedObject == self shownListHolder ifTrue:[ |
5859 | 1035 |
self hasListEntries value:(changedObject valueHolder notEmpty). |
3892 | 1036 |
^ self |
1037 |
]. |
|
4101 | 1038 |
changedObject == self selectionHolder ifTrue:[ |
5856 | 1039 |
self autoSelectInBrowser ifTrue:[ |
1040 |
self selectInBrowser. |
|
1041 |
]. |
|
4101 | 1042 |
^ self |
1043 |
]. |
|
3892 | 1044 |
super update:something with:aParameter from:changedObject |
1045 |
! ! |
|
1046 |
||
1047 |
!FindFileApplication methodsFor:'event handling'! |
|
1048 |
||
4101 | 1049 |
fileDoubleClick:entries |
5677
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1050 |
|file fn app openedAppl contentsPattern| |
4101 | 1051 |
|
5859 | 1052 |
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
|
1053 |
fn := file asFilename. |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1054 |
fn exists ifFalse:[ |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1055 |
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
|
1056 |
^ self |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1057 |
]. |
4aea2e3fd1e3
warn if file is not existing (in doubleClick)
Claus Gittinger <cg@exept.de>
parents:
5603
diff
changeset
|
1058 |
|
4101 | 1059 |
app := targetApplication ? self masterApplication. |
5279 | 1060 |
file asFilename isDirectory ifTrue:[ |
1061 |
app gotoFile:(file asFilename). |
|
1062 |
^ self. |
|
1063 |
]. |
|
4101 | 1064 |
app notNil ifTrue:[ |
4145
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1065 |
openedAppl := app openApplForFile:file. |
5279 | 1066 |
(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
|
1067 |
contentsPattern := self contentsPatternHolder value. |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1068 |
(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
|
1069 |
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
|
1070 |
] |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
1071 |
]. |
4101 | 1072 |
] ifFalse:[ |
1073 |
self openInNewBrowser. |
|
1074 |
] |
|
1075 |
! |
|
1076 |
||
3892 | 1077 |
processEvent:anEvent |
1078 |
"filter keyboard events. |
|
1079 |
Return true, if I have eaten the event" |
|
1080 |
||
1081 |
|focusView key rawKey| |
|
1082 |
||
1083 |
anEvent isKeyPressEvent ifTrue:[ |
|
1084 |
focusView := anEvent targetView. |
|
1085 |
key := anEvent key. |
|
1086 |
rawKey := anEvent rawKey. |
|
1087 |
||
1088 |
(focusView isSameOrComponentOf:self window) ifTrue:[ |
|
1089 |
(key == #Return) ifTrue:[ |
|
1090 |
(focusView name ~= 'selectionInListView') ifTrue:[ |
|
1091 |
self doSearch. |
|
1092 |
] ifFalse:[ |
|
1093 |
self hasOneFileSelected ifTrue:[ |
|
4101 | 1094 |
self fileDoubleClick:(self selectionHolder value) |
1095 |
"/ self isEmbeddedApplication ifTrue:[ |
|
1096 |
"/ self selectInBrowser. |
|
1097 |
"/ ] ifFalse:[ |
|
1098 |
"/ self openInNewBrowser. |
|
1099 |
"/ ] |
|
3892 | 1100 |
] |
1101 |
]. |
|
1102 |
^ true |
|
1103 |
]. |
|
1104 |
] |
|
1105 |
]. |
|
1106 |
^ false |
|
1107 |
! ! |
|
1108 |
||
1109 |
!FindFileApplication methodsFor:'private'! |
|
1110 |
||
1111 |
changeExtentToSeeSearchResult |
|
1112 |
||
1113 |
| extent window| |
|
1114 |
||
1115 |
expanded isNil ifTrue:[ |
|
1116 |
window := self builder window. |
|
1117 |
window ifNotNil:[ |
|
1118 |
window := window topView. |
|
1119 |
extent := window extent. |
|
1120 |
window extent:((extent x) @ (extent y + 300)). |
|
1121 |
expanded := true. |
|
1122 |
window containerChangedSize. |
|
1123 |
]. |
|
1124 |
]. |
|
1125 |
! ! |
|
1126 |
||
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1127 |
!FindFileApplication methodsFor:'private - searching'! |
3892 | 1128 |
|
5856 | 1129 |
cachedFileSizeOf:aFilenameString |
1130 |
|cache cacheLine fileSize| |
|
1131 |
||
1132 |
cache := self contentsInfoCache. |
|
1133 |
cache isNil ifTrue:[ |
|
5859 | 1134 |
fileSize := aFilenameString asFilename fileSize |
5856 | 1135 |
] ifFalse:[ |
5859 | 1136 |
ContentsInfoCacheAccessLock critical:[ |
1137 |
cacheLine := cache at:aFilenameString ifAbsent:nil. |
|
1138 |
cacheLine isNil ifTrue:[ |
|
1139 |
cache at:aFilenameString put:(cacheLine := Array new:2). |
|
1140 |
] ifFalse:[ |
|
1141 |
fileSize := (cacheLine at:1). |
|
1142 |
]. |
|
5856 | 1143 |
|
5859 | 1144 |
fileSize isNil ifTrue:[ |
1145 |
fileSize := aFilenameString asFilename fileSize. |
|
1146 |
cacheLine at:1 put:fileSize. |
|
1147 |
]. |
|
1148 |
]. |
|
5856 | 1149 |
]. |
1150 |
^ fileSize |
|
1151 |
! |
|
1152 |
||
1153 |
cachedHashValueOfFile:aFilenameString |
|
1154 |
|cache cacheLine hashValue| |
|
1155 |
||
1156 |
cache := self contentsInfoCache. |
|
1157 |
cache isNil ifTrue:[ |
|
5859 | 1158 |
hashValue := MD5Stream hashValueOfFile:aFilenameString asFilename |
5856 | 1159 |
] ifFalse:[ |
5859 | 1160 |
ContentsInfoCacheAccessLock critical:[ |
1161 |
cacheLine := cache at:aFilenameString ifAbsent:nil. |
|
1162 |
cacheLine isNil ifTrue:[ |
|
1163 |
cache at:aFilenameString put:(Array new:2). |
|
1164 |
] ifFalse:[ |
|
1165 |
hashValue := (cacheLine at:2). |
|
1166 |
]. |
|
5856 | 1167 |
|
5859 | 1168 |
hashValue isNil ifTrue:[ |
1169 |
hashValue := MD5Stream hashValueOfFile:aFilenameString asFilename. |
|
1170 |
cacheLine at:2 put:hashValue. |
|
1171 |
]. |
|
1172 |
]. |
|
5856 | 1173 |
]. |
1174 |
^ hashValue |
|
1175 |
! |
|
1176 |
||
1177 |
contentsInfoCache |
|
6107 | 1178 |
contentsInfoCache isNil ifTrue:[ |
1179 |
ContentsInfoCache isNil ifTrue:[ |
|
1180 |
ContentsInfoCache := Dictionary new. |
|
1181 |
ContentsInfoCacheAccessLock := Semaphore forMutualExclusion. |
|
1182 |
]. |
|
1183 |
contentsInfoCache := ContentsInfoCache |
|
5856 | 1184 |
]. |
6107 | 1185 |
^ contentsInfoCache |
5856 | 1186 |
! |
1187 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1188 |
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
|
1189 |
containingString:contentsStringArg ignoreCaseInContents:ignCaseInContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1190 |
notContainingString:notContentsStringArg ignoreCaseInNotContents:ignCaseInNotContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1191 |
sameContentsAsFile:filenameToCompareContentsOrNil sameContentsAs:bytesToCompareContentsOrNil in:aDirectory |
3892 | 1192 |
|
5859 | 1193 |
|dir nameMatches lines contentsToCompare resultList matchedFilesList inStream |
5601 | 1194 |
doesFileMatch contentsString notContentsString check checkNot |
5859 | 1195 |
grepCommand nameMatch fileSizesToSearchFor filesToSearchFor fileMD5sToSearchFor |
1196 |
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
|
1197 |
|
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1198 |
contentsString := contentsStringArg. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1199 |
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
|
1200 |
notContentsString := notContentsStringArg. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1201 |
ignCaseInNotContents ifTrue:[ notContentsString := notContentsString asLowercase ]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1202 |
|
5723 | 1203 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
5768 | 1204 |
fileSizesToSearchFor := OrderedCollection new. |
1205 |
filesToSearchFor := OrderedCollection new. |
|
1206 |
fileMD5sToSearchFor := OrderedCollection new. |
|
1207 |
||
1208 |
filenameToCompareContentsOrNil includesMatchCharacters ifTrue:[ |
|
1209 |
dir := filenameToCompareContentsOrNil asFilename. |
|
1210 |
[dir pathName includesMatchCharacters] whileTrue:[ |
|
1211 |
dir := dir directory |
|
1212 |
]. |
|
1213 |
dir recursiveDirectoryContentsDo:[:relName | |
|
1214 |
|path fn| |
|
1215 |
||
1216 |
fn := dir construct:relName. |
|
5770 | 1217 |
(filenameToCompareContentsOrNil match:fn name) ifTrue:[ |
5847 | 1218 |
fn isDirectory ifFalse:[ |
5856 | 1219 |
fileSizesToSearchFor add:(self cachedFileSizeOf:fn). |
5847 | 1220 |
filesToSearchFor add:(fn name). |
5856 | 1221 |
fileMD5sToSearchFor add:(self cachedHashValueOfFile:fn). |
5847 | 1222 |
] |
5768 | 1223 |
] |
1224 |
]. |
|
1225 |
] ifFalse:[ |
|
1226 |
fn := filenameToCompareContentsOrNil asFilename. |
|
5856 | 1227 |
fileSizesToSearchFor add:(self cachedFileSizeOf:fn). |
5768 | 1228 |
filesToSearchFor add:(fn pathName). |
5856 | 1229 |
fileMD5sToSearchFor add:(self cachedHashValueOfFile:fn). |
5768 | 1230 |
]. |
1231 |
||
5859 | 1232 |
remember := LastRememberInCache := self rememberInCache value. |
5723 | 1233 |
remember ifTrue:[ |
5856 | 1234 |
cache := self contentsInfoCache. |
5723 | 1235 |
]. |
5866 | 1236 |
setOfFilesToSearchFor := filesToSearchFor asSet. |
1237 |
]. |
|
5791 | 1238 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1239 |
dir := aDirectory asFilename. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1240 |
self changeInformationTo:'Find File ' , '- searching .' , ((dir name) copyFrom:(self searchDirectoryHolder value asString size + 1)) toTab:false. |
3892 | 1241 |
|
5859 | 1242 |
resultList := self resultList. |
1243 |
matchedFilesList := self matchedFilesList. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1244 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1245 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1246 |
doesFileMatch := |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1247 |
[:f | |
5859 | 1248 |
|contentsMatches mustValidateExistance |
1249 |
fileMD5 fileName fileSize cacheLine idxInList matchedFile| |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1250 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1251 |
"/ contents compare ... |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1252 |
contentsMatches := false. |
5771 | 1253 |
fileName := f name. |
5859 | 1254 |
(setOfFilesToSearchFor includes:fileName) ifFalse:[ |
5850 | 1255 |
mustValidateExistance := false. |
5856 | 1256 |
|
5727 | 1257 |
cache notNil ifTrue:[ |
5859 | 1258 |
ContentsInfoCacheAccessLock critical:[ |
1259 |
cacheLine := cache at:fileName ifAbsent:nil. |
|
1260 |
cacheLine notNil ifTrue:[ |
|
1261 |
fileSize := cacheLine at:1. |
|
1262 |
fileMD5 := cacheLine at:2. |
|
1263 |
mustValidateExistance := true. |
|
1264 |
]. |
|
5727 | 1265 |
]. |
5723 | 1266 |
]. |
5850 | 1267 |
|
5723 | 1268 |
fileSize isNil ifTrue:[ |
1269 |
fileSize := f fileSize. |
|
1270 |
]. |
|
1271 |
remember ifTrue:[ |
|
5859 | 1272 |
ContentsInfoCacheAccessLock critical:[ |
1273 |
cacheLine := cache at:fileName ifAbsentPut:[Array new:2]. |
|
1274 |
cacheLine at:1 put:fileSize. |
|
1275 |
] |
|
5723 | 1276 |
]. |
5768 | 1277 |
(idxInList := fileSizesToSearchFor indexOf:fileSize) ~~ 0 ifTrue:[ |
5723 | 1278 |
fileMD5 isNil ifTrue:[ |
5850 | 1279 |
OpenError handle:[:ex | |
1280 |
ObjectMemory garbageCollect. |
|
1281 |
fileMD5 := MD5Stream hashValueOfFile:f. |
|
1282 |
] do:[ |
|
1283 |
fileMD5 := MD5Stream hashValueOfFile:f. |
|
1284 |
]. |
|
5723 | 1285 |
remember ifTrue:[ |
1286 |
cacheLine at:2 put:fileMD5 |
|
1287 |
]. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1288 |
]. |
5768 | 1289 |
contentsMatches := (fileMD5 = (fileMD5sToSearchFor at:idxInList)). |
5850 | 1290 |
contentsMatches ifTrue:[ |
1291 |
mustValidateExistance ifTrue:[ |
|
1292 |
fileName asFilename exists ifFalse:[ |
|
5859 | 1293 |
ContentsInfoCacheAccessLock critical:[ |
1294 |
cache removeKey:fileName. |
|
1295 |
]. |
|
5850 | 1296 |
contentsMatches := false. |
1297 |
]. |
|
5859 | 1298 |
]. |
1299 |
contentsMatches ifTrue:[ |
|
1300 |
matchedFile := filesToSearchFor at:idxInList. |
|
1301 |
matchedFilesList add:matchedFile. |
|
1302 |
]. |
|
5850 | 1303 |
]. |
5723 | 1304 |
"/ contentsToCompare isNil ifTrue:[ |
1305 |
"/ filenameToCompareContentsOrNil fileSize < (512*1024) ifTrue:[ |
|
1306 |
"/ contentsToCompare := filenameToCompareContentsOrNil binaryContentsOfEntireFile |
|
1307 |
"/ ] |
|
1308 |
"/ ]. |
|
1309 |
"/ contentsToCompare isNil ifTrue:[ |
|
1310 |
"/ "/ too large - compare block-wise ... |
|
1311 |
"/ contentsMatches := (filenameToCompareContentsOrNil sameContentsAs:f). |
|
1312 |
"/ ] ifFalse:[ |
|
1313 |
"/ contentsMatches := contentsToCompare = (f binaryContentsOfEntireFile). |
|
1314 |
"/ ] |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1315 |
]. |
5773 | 1316 |
] ifTrue:[ |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1317 |
f isSymbolicLink ifTrue:[ |
5859 | 1318 |
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
|
1319 |
] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1320 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1321 |
contentsMatches |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1322 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1323 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1324 |
(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
|
1325 |
doesFileMatch := [:f | true]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1326 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1327 |
(self canUseGrep |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1328 |
and:[self useGrep value]) ifTrue:[ |
5601 | 1329 |
(ignCaseInContents not and:[ignCaseInNotContents not]) ifTrue:[ |
1330 |
contentsString notNil ifTrue:[ |
|
1331 |
notContentsString notNil ifTrue:[ |
|
1332 |
grepCommand := '(grep "',contentsString,'" %1) && (grep -v "',notContentsString,'" %1)'. |
|
1333 |
] ifFalse:[ |
|
1334 |
grepCommand := 'grep "' , contentsString , '" %1'. |
|
1335 |
]. |
|
1336 |
] ifFalse:[ |
|
1337 |
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
|
1338 |
]. |
5601 | 1339 |
doesFileMatch := [:f | |cmd ret| |
1340 |
cmd := grepCommand bindWith:f pathName. |
|
1341 |
ret := OperatingSystem executeCommand:cmd. |
|
1342 |
ret |
|
1343 |
]. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1344 |
] |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1345 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1346 |
|
5601 | 1347 |
doesFileMatch isNil ifTrue:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1348 |
contentsString notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1349 |
ignCaseInContents ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1350 |
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
|
1351 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1352 |
check := [:l | l includesString:contentsString] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1353 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1354 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1355 |
notContentsString notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1356 |
ignCaseInNotContents ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1357 |
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
|
1358 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1359 |
checkNot := [:l | l includesString:notContentsString] |
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 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1362 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1363 |
doesFileMatch := |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1364 |
[:f | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1365 |
|contentsMatches| |
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 |
"/ string search ... |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1368 |
contentsMatches := true. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1369 |
(f exists and:[f isReadable]) ifFalse:[ |
5859 | 1370 |
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
|
1371 |
] ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1372 |
f fileSize > (4024*1024) ifTrue:[ |
5859 | 1373 |
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
|
1374 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1375 |
Stream lineTooLongErrorSignal handle:[:ex | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1376 |
|cont| |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1377 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1378 |
"/ 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
|
1379 |
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
|
1380 |
check notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1381 |
checkNot isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1382 |
contentsMatches := check value:cont |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1383 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1384 |
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
|
1385 |
] |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1386 |
] ifFalse:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1387 |
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
|
1388 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1389 |
] do:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1390 |
lines := f contents ? #(). |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1391 |
check notNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1392 |
checkNot isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1393 |
contentsMatches := (lines contains:check). |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1394 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1395 |
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
|
1396 |
] |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1397 |
] ifFalse:[ |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1398 |
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
|
1399 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1400 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1401 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1402 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1403 |
contentsMatches |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1404 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1405 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1406 |
]. |
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1407 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1408 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1409 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1410 |
(self canUseLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1411 |
and:[self useLocate value |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1412 |
and:[searchDirectories not]]) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1413 |
ifTrue:[ |
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 |
|cmd line f| |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1416 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1417 |
cmd := 'locate '. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1418 |
ignCaseInName ifTrue:[ |
5408 | 1419 |
cmd := cmd , '--ignore-case ' |
5176
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 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1422 |
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
|
1423 |
asStringCollection asStringWith:Character space). |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1424 |
inStream := PipeStream readingFrom:cmd inDirectory:dir. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1425 |
[inStream atEnd] whileFalse:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1426 |
line := inStream nextLine. |
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 |
f := line asFilename. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1429 |
(doesFileMatch value:f) ifTrue:[ |
5859 | 1430 |
resultList add:line. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1431 |
] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1432 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1433 |
] ensure:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1434 |
inStream notNil ifTrue:[inStream close]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1435 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1436 |
^ self. |
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 |
|
3892 | 1439 |
bytesToCompareContentsOrNil notNil ifTrue:[ |
1440 |
contentsToCompare := bytesToCompareContentsOrNil |
|
1441 |
]. |
|
1442 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1443 |
namePatterns isNil ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1444 |
nameMatch := [:fn | true] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1445 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1446 |
ignCaseInName ifTrue:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1447 |
nameMatch := [:fn | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1448 |
nameMatches := namePatterns contains:[:aPattern | aPattern match:(fn asLowercase)] |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1449 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1450 |
] ifFalse:[ |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1451 |
nameMatch := [:fn | |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1452 |
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
|
1453 |
]. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1454 |
]. |
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 |
|
5726 | 1457 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
5727 | 1458 |
self searchOnlyInCache value ifTrue:[ |
5726 | 1459 |
cache notEmptyOrNil ifTrue:[ |
1460 |
cache keysAndValuesDo:[:fn :info | |
|
5768 | 1461 |
|filesSize filesMD5 idxInList| |
5727 | 1462 |
|
5726 | 1463 |
filesSize := info at:1. |
1464 |
filesSize isNil ifTrue:[ |
|
1465 |
filesSize := fn asFilename fileSize. |
|
1466 |
info at:1 put:filesSize. |
|
1467 |
]. |
|
5768 | 1468 |
(idxInList := fileSizesToSearchFor indexOf:filesSize) ~~ 0 ifTrue:[ |
5859 | 1469 |
(setOfFilesToSearchFor includes:fn) not ifTrue:[ |
5729 | 1470 |
fn asFilename exists ifFalse:[ |
1471 |
info at:1 put:nil. |
|
1472 |
info at:2 put:nil. |
|
1473 |
] ifTrue:[ |
|
1474 |
filesMD5 := info at:2. |
|
1475 |
filesMD5 isNil ifTrue:[ |
|
1476 |
filesMD5 := MD5Stream hashValueOfFile:fn asFilename. |
|
1477 |
info at:2 put:filesMD5. |
|
1478 |
]. |
|
5768 | 1479 |
filesMD5 = (fileMD5sToSearchFor at:idxInList) ifTrue:[ |
5859 | 1480 |
resultList add:fn. |
5728 | 1481 |
] |
5727 | 1482 |
] |
5726 | 1483 |
] |
1484 |
] |
|
1485 |
]. |
|
1486 |
]. |
|
1487 |
^ self. |
|
1488 |
]. |
|
1489 |
]. |
|
1490 |
||
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1491 |
self |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1492 |
doFindFileNamed:namePatterns |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1493 |
directories:searchDirectories |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1494 |
nameMatch:nameMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1495 |
contentsMatch:doesFileMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1496 |
in:dir. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1497 |
! |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1498 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1499 |
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
|
1500 |
|dir subDirs list directoryContents| |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1501 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1502 |
dir := aDirectory asFilename. |
5844 | 1503 |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1504 |
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
|
1505 |
|
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1506 |
list := self resultList. |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1507 |
|
3892 | 1508 |
subDirs := OrderedCollection new. |
1509 |
||
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1510 |
[ |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1511 |
directoryContents := dir directoryContents. |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1512 |
] on:FileStream openErrorSignal do:[:ex| |
5811
c397040c27b4
openErrorSignal arg: always a string
Claus Gittinger <cg@exept.de>
parents:
5791
diff
changeset
|
1513 |
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
|
1514 |
"/ 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
|
1515 |
"/ bindWith:ex parameter printString |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1516 |
"/ with:ex description) withCRs. |
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1517 |
^ self |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1518 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1519 |
|
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1520 |
directoryContents sort do:[:fn | |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1521 |
|f isDirectory| |
3892 | 1522 |
|
1523 |
f := dir construct:fn. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1524 |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1525 |
isDirectory := f isDirectory. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1526 |
isDirectory ifTrue:[ |
3892 | 1527 |
f isSymbolicLink ifFalse:[ |
1528 |
subDirs add:f |
|
1529 |
] |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1530 |
]. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1531 |
(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
|
1532 |
(nameMatch value:fn) ifTrue:[ |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1533 |
(isDirectory or:[ doesFileMatch value:f ]) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1534 |
ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1535 |
list add:(f asString). |
3892 | 1536 |
] |
1537 |
] |
|
1538 |
] |
|
1539 |
]. |
|
1540 |
||
1541 |
self searchRecursively value ifTrue:[ |
|
1542 |
subDirs do:[:dir | |
|
1543 |
self |
|
1544 |
doFindFileNamed:namePatterns |
|
5600
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1545 |
directories:searchDirectories |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1546 |
nameMatch:nameMatch |
4e7bca968c09
findFile code cleanup (and speedup by factor of 2)
Claus Gittinger <cg@exept.de>
parents:
5557
diff
changeset
|
1547 |
contentsMatch:doesFileMatch |
3892 | 1548 |
in:dir |
1549 |
]. |
|
1550 |
] |
|
1551 |
! ! |
|
1552 |
||
1553 |
!FindFileApplication methodsFor:'queries'! |
|
1554 |
||
1555 |
getTabStringEnd |
|
1556 |
||
1557 |
" get the tab string from the application list on the class side " |
|
1558 |
||
1559 |
^ self fileName directory asString |
|
1560 |
! |
|
1561 |
||
1562 |
hasOneFileSelected |
|
1563 |
| sel | |
|
1564 |
sel := self selectionHolder value. |
|
1565 |
^ (sel notNil and:[sel notEmpty and:[sel size = 1]]) |
|
1566 |
! |
|
1567 |
||
1568 |
hasSelectionInResultList |
|
1569 |
| sel | |
|
1570 |
sel := self selectionHolder value. |
|
1571 |
^ (sel notNil and:[sel notEmpty]) |
|
1572 |
! ! |
|
1573 |
||
1574 |
!FindFileApplication methodsFor:'startup & release'! |
|
1575 |
||
5010 | 1576 |
item:anItem |
3892 | 1577 |
|
4797 | 1578 |
|file newPattern| |
3892 | 1579 |
|
5010 | 1580 |
super item:anItem. |
4797 | 1581 |
|
3892 | 1582 |
file := self fileName. |
1583 |
self searchDirectoryHolder value:(self getDirWithoutFileName:file). |
|
4797 | 1584 |
|
3892 | 1585 |
file isDirectory ifTrue:[ |
4797 | 1586 |
newPattern := '*'. |
3892 | 1587 |
] ifFalse:[ |
5010 | 1588 |
newPattern := '*.', anItem suffix. |
3892 | 1589 |
]. |
4797 | 1590 |
self namePatternHolder value:newPattern. |
3892 | 1591 |
self enableStop value:false. |
1592 |
self enableSearch value:true. |
|
1593 |
^ true. |
|
1594 |
! |
|
1595 |
||
1596 |
postOpenWith:aBuilder |
|
1597 |
||
1598 |
self masterApplication isNil ifTrue:[ |
|
1599 |
self masterApplication:nil. |
|
1600 |
]. |
|
1601 |
findFileView := aBuilder window. |
|
1602 |
self windowGroup addPreEventHook:self. |
|
1603 |
^ super postOpenWith:aBuilder. |
|
1604 |
! |
|
1605 |
||
1606 |
release |
|
1607 |
self stopSearchTask. |
|
6107 | 1608 |
contentsInfoCache := nil. |
3892 | 1609 |
^ super release |
1610 |
! ! |
|
1611 |
||
1612 |
!FindFileApplication class methodsFor:'documentation'! |
|
1613 |
||
1614 |
version |
|
6123 | 1615 |
^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.66 2004-11-10 09:06:28 cg Exp $' |
3892 | 1616 |
! ! |