author | Claus Gittinger <cg@exept.de> |
Wed, 08 Oct 2003 17:34:27 +0200 | |
changeset 5252 | 453aee873a3d |
parent 5231 | d74730347ed8 |
child 5279 | 165a7b841a86 |
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 |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
19 |
ignoreCaseInNotContents findFileView searchResultTable resultList |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
20 |
enableStop enableSearch stopSignal accessLock searchTask expanded |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
21 |
searchRecursively selectionHolder hasListEntries |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
22 |
targetApplication useLocate' |
3892 | 23 |
classVariableNames:'' |
24 |
poolDictionaries:'' |
|
25 |
category:'Interface-Tools-File' |
|
26 |
! |
|
27 |
||
5140 | 28 |
!FindFileApplication class methodsFor:'documentation'! |
29 |
||
30 |
copyright |
|
31 |
" |
|
32 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
33 |
All Rights Reserved |
|
34 |
||
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! ! |
|
3892 | 43 |
|
44 |
!FindFileApplication class methodsFor:'instance creation'! |
|
45 |
||
46 |
open |
|
47 |
||
48 |
^ self openOnFileName:(Filename currentDirectory asAbsoluteFilename) |
|
49 |
! |
|
50 |
||
51 |
openOnFileName:aFileName |
|
52 |
||
53 |
| instance builder| |
|
54 |
||
55 |
builder := super open. |
|
56 |
instance := builder application. |
|
3983 | 57 |
instance item:(DirectoryContentsBrowser itemClass fileName:aFileName). |
3892 | 58 |
^ builder |
59 |
! |
|
60 |
||
61 |
openOnFileName:aFileName for:aTargetApplication |
|
62 |
||
63 |
| instance builder| |
|
64 |
||
65 |
builder := super open. |
|
66 |
instance := builder application. |
|
3983 | 67 |
instance item:(DirectoryContentsBrowser itemClass fileName:aFileName). |
4101 | 68 |
instance targetApplication:aTargetApplication. |
3892 | 69 |
^ builder |
70 |
! ! |
|
71 |
||
72 |
!FindFileApplication class methodsFor:'defaults'! |
|
73 |
||
74 |
tabStringFor:aApplicationType |
|
75 |
||
76 |
^ 'Find file in:' |
|
77 |
! ! |
|
78 |
||
79 |
!FindFileApplication class methodsFor:'interface specs'! |
|
80 |
||
81 |
windowSpec |
|
82 |
"This resource specification was automatically generated |
|
83 |
by the UIPainter of ST/X." |
|
84 |
||
85 |
"Do not manually edit this!! If it is corrupted, |
|
86 |
the UIPainter may not be able to read the specification." |
|
87 |
||
88 |
" |
|
89 |
UIPainter new openOnClass:FindFileApplication andSelector:#windowSpec |
|
90 |
FindFileApplication new openInterface:#windowSpec |
|
91 |
FindFileApplication open |
|
92 |
" |
|
93 |
||
94 |
<resource: #canvas> |
|
95 |
||
96 |
^ |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
97 |
#(FullSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
98 |
name: windowSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
99 |
window: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
100 |
(WindowSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
101 |
label: 'File Search' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
102 |
name: 'File Search' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
103 |
min: (Point 377 131) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
104 |
max: (Point 1280 1024) |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
105 |
bounds: (Rectangle 10 46 675 378) |
3892 | 106 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
107 |
component: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
108 |
(SpecCollection |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
109 |
collection: ( |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
110 |
(MenuPanelSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
111 |
name: 'ToolBar1' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
112 |
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
|
113 |
level: 0 |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
114 |
menu: searchMenu |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
115 |
textDefault: true |
3892 | 116 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
117 |
(ViewSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
118 |
name: 'Box1' |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
119 |
layout: (LayoutFrame 0 0.0 32 0 0 1.0 132 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
120 |
component: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
121 |
(SpecCollection |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
122 |
collection: ( |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
123 |
(LabelSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
124 |
label: 'Directory:' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
125 |
name: 'DirectoryLabel' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
126 |
layout: (LayoutFrame 4 0 7 0 136 0 24 0) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
127 |
translateLabel: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
128 |
adjust: left |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
129 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
130 |
(FilenameInputFieldSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
131 |
name: 'DirectoryEntryField' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
132 |
layout: (LayoutFrame 140 0 4 0 -246 1 24 0) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
133 |
model: searchDirectoryHolder |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
134 |
immediateAccept: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
135 |
acceptOnPointerLeave: false |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
136 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
137 |
(CheckBoxSpec |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
138 |
label: 'Use ''locate'' Cmd' |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
139 |
name: 'UseLocateCheckBox' |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
140 |
layout: (LayoutFrame -236 1 5 0 -105 1 28 0) |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
141 |
visibilityChannel: canUseLocate |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
142 |
tabable: true |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
143 |
model: useLocate |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
144 |
translateLabel: true |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
145 |
) |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
146 |
(CheckBoxSpec |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
147 |
label: 'Recursively' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
148 |
name: 'RecursiveSearchCheckBox' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
149 |
layout: (LayoutFrame -97 1 5 0 0 1 28 0) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
150 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
151 |
model: searchRecursively |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
152 |
translateLabel: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
153 |
) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
154 |
(LabelSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
155 |
label: 'Search files named:' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
156 |
name: 'FileNameLabel' |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
157 |
layout: (LayoutFrame 4 0 30 0 136 0 47 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
158 |
translateLabel: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
159 |
adjust: left |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
160 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
161 |
(InputFieldSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
162 |
name: 'FileNameEntryField' |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
163 |
layout: (LayoutFrame 140 0 28 0 -246 1 48 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
164 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
165 |
model: namePatternHolder |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
166 |
immediateAccept: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
167 |
acceptOnLeave: false |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
168 |
acceptOnPointerLeave: false |
3892 | 169 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
170 |
(CheckBoxSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
171 |
label: 'Directories' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
172 |
name: 'SearchDirectoriesCheckBox' |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
173 |
layout: (LayoutFrame -236 1 29 0 -105 1 49 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: searchDirectories |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
176 |
translateLabel: true |
3892 | 177 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
178 |
(CheckBoxSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
179 |
label: 'Ignore case' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
180 |
name: 'IgnoreCaseInNameCheckBox' |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
181 |
layout: (LayoutFrame -97 1 29 0 0 1 49 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
182 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
183 |
model: ignoreCaseInName |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
184 |
translateLabel: true |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
185 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
186 |
(LabelSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
187 |
label: 'Containing the string:' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
188 |
name: 'ContentsLabel' |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
189 |
layout: (LayoutFrame 4 0 55 0 136 0 72 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
190 |
translateLabel: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
191 |
adjust: left |
3892 | 192 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
193 |
(InputFieldSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
194 |
name: 'ContentsEntryField' |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
195 |
layout: (LayoutFrame 140 0 52 0 -115 1 72 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
196 |
enableChannel: notSearchForSameContents |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
197 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
198 |
model: contentsPatternHolder |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
199 |
immediateAccept: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
200 |
acceptOnPointerLeave: false |
3892 | 201 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
202 |
(CheckBoxSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
203 |
label: 'Ignore case' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
204 |
name: 'IgnoreCaseInContentsCheckBox' |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
205 |
layout: (LayoutFrame -97 1 52 0 0 1 75 0) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
206 |
enableChannel: notSearchForSameContents |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
207 |
tabable: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
208 |
model: ignoreCaseInContents |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
209 |
translateLabel: true |
3892 | 210 |
) |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
211 |
(LabelSpec |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
212 |
label: 'Not Containing:' |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
213 |
name: 'NotContentsLabel' |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
214 |
layout: (LayoutFrame 4 0 79 0 136 0 96 0) |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
215 |
translateLabel: true |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
216 |
adjust: left |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
217 |
) |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
218 |
(InputFieldSpec |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
219 |
name: 'NotContentsEntryField' |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
220 |
layout: (LayoutFrame 140 0 76 0 -115 1 96 0) |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
221 |
enableChannel: notSearchForSameContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
222 |
tabable: true |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
223 |
model: notContentsPatternHolder |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
224 |
immediateAccept: true |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
225 |
acceptOnPointerLeave: false |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
226 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
227 |
(CheckBoxSpec |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
228 |
label: 'Ignore case' |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
229 |
name: 'IgnoreCaseInNotContentsCheckBox' |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
230 |
layout: (LayoutFrame -97 1 76 0 0 1 99 0) |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
231 |
enableChannel: notSearchForSameContents |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
232 |
tabable: true |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
233 |
model: ignoreCaseInNotContents |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
234 |
translateLabel: true |
3892 | 235 |
) |
236 |
) |
|
237 |
||
238 |
) |
|
239 |
) |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
240 |
(SequenceViewSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
241 |
name: 'List1' |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
242 |
layout: (LayoutFrame 0 0.0 132 0 0 1.0 0 1) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
243 |
model: selectionHolder |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
244 |
menu: menu |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
245 |
hasHorizontalScrollBar: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
246 |
hasVerticalScrollBar: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
247 |
isMultiSelect: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
248 |
doubleClickSelector: fileDoubleClick: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
249 |
useIndex: true |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
250 |
sequenceList: resultList |
3892 | 251 |
) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
252 |
(ProgressIndicatorSpec |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
253 |
name: 'ProgressIndicator1' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
254 |
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
|
255 |
visibilityChannel: enableStop |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
256 |
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
|
257 |
showPercentage: false |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
258 |
isActivityIndicator: true |
4168 | 259 |
) |
3892 | 260 |
) |
261 |
||
262 |
) |
|
263 |
) |
|
264 |
! ! |
|
265 |
||
266 |
!FindFileApplication class methodsFor:'menu specs'! |
|
267 |
||
268 |
menu |
|
269 |
"This resource specification was automatically generated |
|
270 |
by the MenuEditor of ST/X." |
|
271 |
||
272 |
"Do not manually edit this!! If it is corrupted, |
|
273 |
the MenuEditor may not be able to read the specification." |
|
274 |
||
275 |
" |
|
276 |
MenuEditor new openOnClass:FindFileApplication andSelector:#menu |
|
277 |
(Menu new fromLiteralArrayEncoding:(FindFileApplication menu)) startUp |
|
278 |
" |
|
279 |
||
280 |
<resource: #menu> |
|
281 |
||
282 |
^ |
|
283 |
#(#Menu |
|
284 |
#( |
|
285 |
#(#MenuItem |
|
286 |
#label: 'Select in Browser' |
|
287 |
#translateLabel: true |
|
288 |
#isVisible: #isEmbeddedApplication |
|
289 |
#value: #selectInBrowser |
|
290 |
#enabled: #hasOneFileSelected |
|
291 |
) |
|
292 |
#(#MenuItem |
|
293 |
#label: 'Copy Selected Files' |
|
294 |
#translateLabel: true |
|
295 |
#value: #copySelectedFiles |
|
296 |
#enabled: #hasSelectionInResultList |
|
297 |
) |
|
298 |
#(#MenuItem |
|
299 |
#label: 'Open in New File Browser' |
|
300 |
#translateLabel: true |
|
301 |
#value: #openInNewBrowser |
|
302 |
#enabled: #hasOneFileSelected |
|
303 |
) |
|
304 |
#(#MenuItem |
|
305 |
#label: 'Remove selected Files' |
|
306 |
#translateLabel: true |
|
307 |
#value: #removeFromList |
|
308 |
#enabled: #hasSelection |
|
309 |
) |
|
310 |
#(#MenuItem |
|
311 |
#label: 'Remove all Files' |
|
312 |
#translateLabel: true |
|
313 |
#value: #removeAllFromList |
|
314 |
#enabled: #hasListEntries |
|
315 |
) |
|
316 |
) |
|
317 |
nil |
|
318 |
nil |
|
319 |
) |
|
320 |
! |
|
321 |
||
322 |
searchMenu |
|
323 |
"This resource specification was automatically generated |
|
324 |
by the MenuEditor of ST/X." |
|
325 |
||
326 |
"Do not manually edit this!! If it is corrupted, |
|
327 |
the MenuEditor may not be able to read the specification." |
|
328 |
||
329 |
" |
|
330 |
MenuEditor new openOnClass:FindFileApplication andSelector:#searchMenu |
|
331 |
(Menu new fromLiteralArrayEncoding:(FindFileApplication searchMenu)) startUp |
|
332 |
" |
|
333 |
||
334 |
<resource: #menu> |
|
335 |
||
336 |
^ |
|
337 |
#(#Menu |
|
338 |
#( |
|
339 |
#(#MenuItem |
|
340 |
#label: 'Search' |
|
341 |
#translateLabel: true |
|
342 |
#isButton: true |
|
343 |
#value: #doSearch |
|
344 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #search20x20Icon) |
|
345 |
) |
|
346 |
#(#MenuItem |
|
347 |
#label: 'Stop' |
|
348 |
#translateLabel: true |
|
349 |
#isButton: true |
|
350 |
#value: #stop |
|
351 |
#enabled: #enableStop |
|
352 |
#labelImage: #(#ResourceRetriever #ToolbarIconLibrary #stop22x22Icon) |
|
353 |
) |
|
354 |
#(#MenuItem |
|
355 |
#label: 'Clean Up' |
|
356 |
#translateLabel: true |
|
357 |
#isButton: true |
|
358 |
#value: #removeAllFromList |
|
359 |
#enabled: #hasListEntries |
|
360 |
#labelImage: #(#ResourceRetriever #Icon #deleteIcon) |
|
361 |
) |
|
362 |
#(#MenuItem |
|
363 |
#label: 'Close' |
|
364 |
#translateLabel: true |
|
365 |
#isButton: true |
|
366 |
#startGroup: #right |
|
367 |
#value: #doClose |
|
368 |
#labelImage: #(#ResourceRetriever #AbstractFileBrowser #closeIcon) |
|
369 |
) |
|
370 |
) |
|
371 |
nil |
|
372 |
nil |
|
373 |
) |
|
374 |
! ! |
|
375 |
||
376 |
!FindFileApplication class methodsFor:'tableColumns specs'! |
|
377 |
||
378 |
searchResultTable |
|
379 |
"This resource specification was automatically generated |
|
380 |
by the DataSetBuilder of ST/X." |
|
381 |
||
382 |
"Do not manually edit this!! If it is corrupted, |
|
383 |
the DataSetBuilder may not be able to read the specification." |
|
384 |
||
385 |
" |
|
386 |
DataSetBuilder new openOnClass:FindFileApplication andSelector:#searchResultTable |
|
387 |
" |
|
388 |
||
389 |
<resource: #tableColumns> |
|
390 |
||
391 |
^#( |
|
392 |
#(#DataSetColumnSpec |
|
393 |
#label: 'Filename' |
|
394 |
#id: 'FileName' |
|
395 |
#labelButtonType: #Button |
|
396 |
#model: #fileName |
|
397 |
#showRowSeparator: false |
|
398 |
#showColSeparator: false |
|
399 |
) |
|
400 |
) |
|
401 |
||
402 |
! ! |
|
403 |
||
404 |
!FindFileApplication methodsFor:'accessing'! |
|
405 |
||
406 |
accessLock |
|
407 |
"return the value of the instance variable 'accessLock' (automatically generated)" |
|
408 |
||
409 |
accessLock isNil ifTrue:[ |
|
410 |
accessLock := Semaphore forMutualExclusion name:'accessLock'. |
|
411 |
]. |
|
412 |
^ accessLock |
|
413 |
! |
|
414 |
||
415 |
stopSignal |
|
416 |
||
417 |
stopSignal isNil ifTrue:[ |
|
418 |
stopSignal := Signal new. |
|
419 |
]. |
|
420 |
^ stopSignal |
|
4101 | 421 |
! |
422 |
||
423 |
targetApplication:something |
|
424 |
"set the value of the instance variable 'targetApplication' (automatically generated)" |
|
425 |
||
426 |
targetApplication := something. |
|
3892 | 427 |
! ! |
428 |
||
429 |
!FindFileApplication methodsFor:'actions'! |
|
430 |
||
431 |
changeInformationTo:aString |
|
432 |
||
433 |
self changeInformationTo:aString toTab:false |
|
434 |
! |
|
435 |
||
436 |
changeInformationTo:aString toTab:aBoolean |
|
437 |
masterApplication isNil ifTrue:[ |
|
438 |
findFileView label:aString |
|
439 |
] ifFalse:[ |
|
440 |
aBoolean ifTrue:[ |
|
441 |
masterApplication tabStringChangeTo:aString for:self |
|
442 |
] |
|
443 |
]. |
|
444 |
! |
|
445 |
||
446 |
copySelectedFiles |
|
447 |
|sel list stream| |
|
448 |
||
449 |
sel := self selectionHolder value. |
|
450 |
list := self resultList. |
|
451 |
(sel notNil and:[sel notEmpty]) ifTrue:[ |
|
452 |
stream := WriteStream on:''. |
|
453 |
sel do:[: key | |
|
454 |
stream nextPutAll:(list at:key). |
|
455 |
stream cr. |
|
456 |
]. |
|
457 |
self window setTextSelection:stream contents. |
|
458 |
stream close. |
|
459 |
]. |
|
460 |
! |
|
461 |
||
462 |
doSearch |
|
463 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
464 |
| namePattern namePatterns contentsPattern notContentsPattern dir| |
3892 | 465 |
|
466 |
"/ self changeExtentToSeeSearchResult. |
|
467 |
||
468 |
dir := self searchDirectoryHolder value. |
|
469 |
dir isNil ifTrue:[ |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
470 |
Dialog warn:'Missing directory name'. |
3892 | 471 |
^ self. |
472 |
]. |
|
473 |
dir asFilename exists not ifTrue:[ |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
474 |
Dialog warn:('No such directory: %1' bindWith:dir asString allBold). |
3892 | 475 |
^ self. |
476 |
]. |
|
477 |
||
478 |
searchTask notNil ifTrue:[ |
|
479 |
(Dialog |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
480 |
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
|
481 |
yesLabel:(resources at:'Stop other Task and Proceed') |
3892 | 482 |
noLabel:(resources at:'Cancel')) |
483 |
ifFalse:[^ self]. |
|
484 |
self stop. |
|
485 |
]. |
|
486 |
||
487 |
namePattern := self namePatternHolder value. |
|
488 |
namePattern size == 0 ifTrue:[ |
|
489 |
namePatterns := nil |
|
490 |
] ifFalse:[ |
|
491 |
ignoreCaseInName value ifTrue:[ |
|
492 |
namePattern := namePattern asLowercase |
|
493 |
]. |
|
494 |
namePatterns := namePattern asCollectionOfSubstringsSeparatedBy:$; |
|
495 |
]. |
|
496 |
contentsPattern := self contentsPatternHolder value. |
|
497 |
contentsPattern size == 0 ifTrue:[ |
|
498 |
contentsPattern := nil |
|
499 |
] ifFalse:[ |
|
500 |
self ignoreCaseInContents value ifTrue:[ |
|
501 |
contentsPattern := contentsPattern asLowercase |
|
502 |
] |
|
503 |
]. |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
504 |
notContentsPattern := self notContentsPatternHolder value. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
505 |
notContentsPattern size == 0 ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
506 |
notContentsPattern := nil |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
507 |
] ifFalse:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
508 |
self ignoreCaseInNotContents value ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
509 |
notContentsPattern := notContentsPattern asLowercase |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
510 |
] |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
511 |
]. |
3892 | 512 |
searchTask := Process for:[ |
5224
93c284d6fe4b
locale t var declaration outside of thread doesnt work for compiled
penk
parents:
5176
diff
changeset
|
513 |
|message t| |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
514 |
|
4168 | 515 |
[ |
3892 | 516 |
(self stopSignal) catch:[ |
4168 | 517 |
self enableStop value:true. |
3892 | 518 |
self resultList removeAll. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
519 |
self changeInformationTo:'Find File ' , '- searching ' toTab:true. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
520 |
self notify:'searching...'. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
521 |
t := Time millisecondsToRun:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
522 |
self |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
523 |
doFindFileNamed:namePatterns |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
524 |
directories:(self searchDirectories value) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
525 |
ignoreCase:(self ignoreCaseInName value) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
526 |
containingString:contentsPattern |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
527 |
ignoreCaseInContents:(self ignoreCaseInContents value) |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
528 |
notContainingString:notContentsPattern |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
529 |
ignoreCaseInNotContents:(self ignoreCaseInNotContents value) |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
530 |
sameContentsAsFile:nil |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
531 |
sameContentsAs:nil |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
532 |
in:(self searchDirectoryHolder value). |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
533 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
534 |
t > 100 ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
535 |
t := ((t / 1000) asFixedPoint:2) printString , ' s' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
536 |
] ifFalse:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
537 |
t := t printString , ' ms' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
538 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
539 |
message := 'Found %1 file%2 in %3' bindWith:(resultList size) with:(resultList size == 1 ifTrue:'' ifFalse:'s') with:t. |
3892 | 540 |
self enableStop value:false. |
541 |
self enableSearch value:true. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
542 |
self changeInformationTo:'Find File ' , '- done.' toTab:true. |
3892 | 543 |
]. |
544 |
] valueNowOrOnUnwindDo:[ |
|
545 |
searchTask := nil. |
|
546 |
self enableStop value:false. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
547 |
self notify:message. |
3892 | 548 |
] |
549 |
] priority:(Processor systemBackgroundPriority). |
|
550 |
||
551 |
searchTask name:('FindFile[', self searchDirectoryHolder value asFilename baseName, ']'). |
|
552 |
searchTask resume. |
|
553 |
! |
|
554 |
||
555 |
openInNewBrowser |
|
556 |
|sel| |
|
557 |
||
558 |
sel := self selectionHolder value. |
|
559 |
(sel notNil and:[sel notEmpty]) ifTrue:[ |
|
560 |
FileBrowserV2 openOn:(self resultList at:sel first) asFilename |
|
561 |
]. |
|
562 |
! |
|
563 |
||
564 |
removeAllFromList |
|
565 |
||
566 |
self resultList removeAll. |
|
567 |
! |
|
568 |
||
569 |
removeFromList |
|
570 |
|sel list| |
|
571 |
||
572 |
sel := self selectionHolder value. |
|
573 |
list := self resultList. |
|
574 |
(sel notNil and:[sel notEmpty]) ifTrue:[ |
|
575 |
sel reverseDo:[: key | |
|
576 |
list removeAtIndex:key |
|
577 |
] |
|
578 |
]. |
|
579 |
! |
|
580 |
||
581 |
selectInBrowser |
|
582 |
|sel entry application| |
|
583 |
||
584 |
sel := self selectionHolder value. |
|
585 |
(sel notNil and:[sel notEmpty]) ifTrue:[ |
|
586 |
entry := self resultList at:sel first. |
|
5252 | 587 |
entry asFilename exists ifFalse:[ ^ self]. |
4101 | 588 |
application := targetApplication ? self masterApplication. |
4182 | 589 |
application notNil ifTrue:[ |
4101 | 590 |
application gotoFile:(entry asFilename). |
591 |
]. |
|
3892 | 592 |
]. |
593 |
! |
|
594 |
||
595 |
stop |
|
596 |
||
597 |
searchTask notNil ifTrue:[ |
|
598 |
self accessLock critical:[ |
|
599 |
searchTask interruptWith:[stopSignal raiseRequest]. |
|
600 |
] |
|
601 |
]. |
|
602 |
self enableStop value:false. |
|
603 |
self enableSearch value:true. |
|
604 |
self changeInformationTo:'Find File ' , '- search stopped' toTab:true. |
|
605 |
! |
|
606 |
||
607 |
stopSearchTask |
|
608 |
|task| |
|
609 |
||
610 |
(task := searchTask) notNil ifTrue:[ |
|
611 |
searchTask := nil. |
|
612 |
||
613 |
Object errorSignal handle:[:ex| |
|
614 |
Dialog warn:ex description. |
|
615 |
]do:[ |
|
616 |
task isDead ifFalse:[ |
|
3937
80d958725879
terminateWithAllSUbprocesses -> xxxInGroup
Claus Gittinger <cg@exept.de>
parents:
3892
diff
changeset
|
617 |
task terminateWithAllSubprocessesInGroup. |
3892 | 618 |
task waitUntilTerminated. |
619 |
] |
|
620 |
] |
|
621 |
]. |
|
622 |
! ! |
|
623 |
||
624 |
!FindFileApplication methodsFor:'aspects'! |
|
625 |
||
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
626 |
canUseLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
627 |
"locate command is much faster, but: |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
628 |
- only if searching recursively, |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
629 |
- no case ignore |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
630 |
- no contents matching |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
631 |
" |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
632 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
633 |
^ OperatingSystem isUNIXlike and:[ OperatingSystem canExecuteCommand:'locate' ] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
634 |
! |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
635 |
|
3892 | 636 |
contentsPatternHolder |
637 |
||
638 |
contentsPatternHolder isNil ifTrue:[ |
|
639 |
contentsPatternHolder := nil asValue. |
|
640 |
]. |
|
641 |
^ contentsPatternHolder. |
|
642 |
! |
|
643 |
||
644 |
enableSearch |
|
645 |
||
646 |
enableSearch isNil ifTrue:[ |
|
647 |
enableSearch := true asValue. |
|
648 |
]. |
|
649 |
^ enableSearch. |
|
650 |
! |
|
651 |
||
652 |
enableStop |
|
653 |
||
654 |
enableStop isNil ifTrue:[ |
|
655 |
enableStop := true asValue. |
|
656 |
]. |
|
657 |
^ enableStop. |
|
658 |
! |
|
659 |
||
660 |
hasListEntries |
|
661 |
||
662 |
hasListEntries isNil ifTrue:[ |
|
663 |
hasListEntries := false asValue. |
|
664 |
]. |
|
665 |
^ hasListEntries. |
|
666 |
! |
|
667 |
||
668 |
ignoreCaseInContents |
|
669 |
ignoreCaseInContents isNil ifTrue:[ |
|
670 |
ignoreCaseInContents := false asValue. |
|
671 |
]. |
|
672 |
^ ignoreCaseInContents. |
|
673 |
! |
|
674 |
||
675 |
ignoreCaseInName |
|
676 |
||
677 |
ignoreCaseInName isNil ifTrue:[ |
|
678 |
ignoreCaseInName := false asValue. |
|
679 |
]. |
|
680 |
^ ignoreCaseInName. |
|
681 |
! |
|
682 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
683 |
ignoreCaseInNotContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
684 |
ignoreCaseInNotContents isNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
685 |
ignoreCaseInNotContents := false asValue. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
686 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
687 |
^ ignoreCaseInNotContents. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
688 |
! |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
689 |
|
3892 | 690 |
namePatternHolder |
691 |
||
692 |
namePatternHolder isNil ifTrue:[ |
|
693 |
namePatternHolder := '*' asValue. |
|
694 |
]. |
|
695 |
^ namePatternHolder. |
|
696 |
! |
|
697 |
||
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
698 |
notContentsPatternHolder |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
699 |
|
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
700 |
notContentsPatternHolder isNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
701 |
notContentsPatternHolder := nil asValue. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
702 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
703 |
^ notContentsPatternHolder. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
704 |
! |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
705 |
|
3892 | 706 |
notSearchForSameContents |
707 |
||
708 |
notSearchForSameContents isNil ifTrue:[ |
|
709 |
notSearchForSameContents := true asValue. |
|
710 |
]. |
|
711 |
^ notSearchForSameContents. |
|
712 |
! |
|
713 |
||
714 |
resultList |
|
715 |
||
716 |
resultList isNil ifTrue:[ |
|
717 |
resultList := List new. |
|
718 |
resultList addDependent:self. |
|
719 |
]. |
|
720 |
^ resultList. |
|
721 |
! |
|
722 |
||
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
723 |
searchDirectories |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
724 |
searchDirectories isNil ifTrue:[ |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
725 |
searchDirectories := false asValue. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
726 |
]. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
727 |
^ searchDirectories. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
728 |
! |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
729 |
|
3892 | 730 |
searchDirectoryHolder |
731 |
||
732 |
searchDirectoryHolder isNil ifTrue:[ |
|
733 |
searchDirectoryHolder := ValueHolder new. |
|
734 |
]. |
|
735 |
^ searchDirectoryHolder. |
|
736 |
! |
|
737 |
||
738 |
searchRecursively |
|
739 |
||
740 |
searchRecursively isNil ifTrue:[ |
|
741 |
searchRecursively := true asValue. |
|
742 |
]. |
|
743 |
^ searchRecursively. |
|
744 |
! |
|
745 |
||
746 |
searchResultTable |
|
747 |
||
748 |
searchResultTable isNil ifTrue:[ |
|
749 |
searchResultTable := self class searchResultTable asValue. |
|
750 |
]. |
|
751 |
^ searchResultTable. |
|
752 |
! |
|
753 |
||
754 |
selectionHolder |
|
755 |
||
756 |
selectionHolder isNil ifTrue:[ |
|
4101 | 757 |
selectionHolder := ValueHolder new. |
758 |
selectionHolder addDependent:self. |
|
3892 | 759 |
]. |
760 |
^ selectionHolder |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
761 |
! |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
762 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
763 |
useLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
764 |
useLocate isNil ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
765 |
useLocate := false asValue. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
766 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
767 |
^ useLocate. |
3892 | 768 |
! ! |
769 |
||
770 |
!FindFileApplication methodsFor:'change & update'! |
|
771 |
||
772 |
update:something with:aParameter from:changedObject |
|
773 |
changedObject == self resultList ifTrue:[ |
|
4798 | 774 |
self hasListEntries value:(changedObject notEmpty). |
3892 | 775 |
^ self |
776 |
]. |
|
4101 | 777 |
changedObject == self selectionHolder ifTrue:[ |
778 |
self selectInBrowser. |
|
779 |
^ self |
|
780 |
]. |
|
3892 | 781 |
super update:something with:aParameter from:changedObject |
782 |
! ! |
|
783 |
||
784 |
!FindFileApplication methodsFor:'event handling'! |
|
785 |
||
4101 | 786 |
fileDoubleClick:entries |
4145
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
787 |
|file app openedAppl contentsPattern| |
4101 | 788 |
|
789 |
file := self resultList at:entries first. |
|
4182 | 790 |
file asFilename exists not ifTrue:[^ self]. |
4101 | 791 |
app := targetApplication ? self masterApplication. |
792 |
app notNil ifTrue:[ |
|
4145
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
793 |
openedAppl := app openApplForFile:file. |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
794 |
openedAppl isTextEditor ifTrue:[ |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
795 |
contentsPattern := self contentsPatternHolder value. |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
796 |
(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
|
797 |
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
|
798 |
] |
08d6561f7639
on doubleclick after search the file is opened and searchPatternStrin is selected
penk
parents:
4101
diff
changeset
|
799 |
]. |
4101 | 800 |
] ifFalse:[ |
801 |
self openInNewBrowser. |
|
802 |
] |
|
803 |
! |
|
804 |
||
3892 | 805 |
processEvent:anEvent |
806 |
"filter keyboard events. |
|
807 |
Return true, if I have eaten the event" |
|
808 |
||
809 |
|focusView key rawKey| |
|
810 |
||
811 |
anEvent isKeyPressEvent ifTrue:[ |
|
812 |
focusView := anEvent targetView. |
|
813 |
key := anEvent key. |
|
814 |
rawKey := anEvent rawKey. |
|
815 |
||
816 |
(focusView isSameOrComponentOf:self window) ifTrue:[ |
|
817 |
(key == #Return) ifTrue:[ |
|
818 |
(focusView name ~= 'selectionInListView') ifTrue:[ |
|
819 |
self doSearch. |
|
820 |
] ifFalse:[ |
|
821 |
self hasOneFileSelected ifTrue:[ |
|
4101 | 822 |
self fileDoubleClick:(self selectionHolder value) |
823 |
"/ self isEmbeddedApplication ifTrue:[ |
|
824 |
"/ self selectInBrowser. |
|
825 |
"/ ] ifFalse:[ |
|
826 |
"/ self openInNewBrowser. |
|
827 |
"/ ] |
|
3892 | 828 |
] |
829 |
]. |
|
830 |
^ true |
|
831 |
]. |
|
832 |
] |
|
833 |
]. |
|
834 |
^ false |
|
835 |
! ! |
|
836 |
||
837 |
!FindFileApplication methodsFor:'private'! |
|
838 |
||
839 |
changeExtentToSeeSearchResult |
|
840 |
||
841 |
| extent window| |
|
842 |
||
843 |
expanded isNil ifTrue:[ |
|
844 |
window := self builder window. |
|
845 |
window ifNotNil:[ |
|
846 |
window := window topView. |
|
847 |
extent := window extent. |
|
848 |
window extent:((extent x) @ (extent y + 300)). |
|
849 |
expanded := true. |
|
850 |
window containerChangedSize. |
|
851 |
]. |
|
852 |
]. |
|
853 |
! ! |
|
854 |
||
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
855 |
!FindFileApplication methodsFor:'private - searching'! |
3892 | 856 |
|
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
857 |
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
|
858 |
containingString:contentsStringArg ignoreCaseInContents:ignCaseInContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
859 |
notContainingString:notContentsStringArg ignoreCaseInNotContents:ignCaseInNotContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
860 |
sameContentsAsFile:filenameToCompareContentsOrNil sameContentsAs:bytesToCompareContentsOrNil in:aDirectory |
3892 | 861 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
862 |
|dir subDirs nameMatches lines contentsToCompare list directoryContents inStream |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
863 |
doesFileMatch contentsString notContentsString check checkNot| |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
864 |
|
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
865 |
contentsString := contentsStringArg. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
866 |
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
|
867 |
notContentsString := notContentsStringArg. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
868 |
ignCaseInNotContents ifTrue:[ notContentsString := notContentsString asLowercase ]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
869 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
870 |
dir := aDirectory asFilename. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
871 |
self changeInformationTo:'Find File ' , '- searching .' , ((dir name) copyFrom:(self searchDirectoryHolder value asString size + 1)) toTab:false. |
3892 | 872 |
|
873 |
list := self resultList. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
874 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
875 |
doesFileMatch := |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
876 |
[:f | |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
877 |
|contentsMatches| |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
878 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
879 |
filenameToCompareContentsOrNil notNil ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
880 |
"/ contents compare ... |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
881 |
contentsMatches := false. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
882 |
f pathName ~= filenameToCompareContentsOrNil pathName ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
883 |
f fileSize == filenameToCompareContentsOrNil fileSize ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
884 |
contentsToCompare isNil ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
885 |
filenameToCompareContentsOrNil fileSize < (512*1024) ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
886 |
contentsToCompare := filenameToCompareContentsOrNil binaryContentsOfEntireFile |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
887 |
] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
888 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
889 |
contentsToCompare isNil ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
890 |
"/ too large - compare block-wise ... |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
891 |
contentsMatches := (filenameToCompareContentsOrNil sameContentsAs:f). |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
892 |
] ifFalse:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
893 |
contentsMatches := contentsToCompare = (f binaryContentsOfEntireFile). |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
894 |
] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
895 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
896 |
] ifFalse:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
897 |
f isSymbolicLink ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
898 |
list add: (f name , ' is a symbolic link to ' , f pathName). |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
899 |
] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
900 |
] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
901 |
] ifFalse:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
902 |
"/ string search ... |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
903 |
contentsMatches := true. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
904 |
(contentsString notNil or:[notContentsString notNil]) ifTrue:[ |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
905 |
(f exists and:[f isReadable]) ifFalse:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
906 |
list add: (('*** ' , f pathName , ' skipped - unreadable or bad symbolic link ***') asText colorizeAllWith:(Color red darkened)). |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
907 |
] ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
908 |
f fileSize > (4024*1024) ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
909 |
list add: (('*** ' , f pathName , ' skipped - too large ***') asText colorizeAllWith:(Color red darkened)). |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
910 |
] ifFalse:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
911 |
Stream lineTooLongErrorSignal handle:[:ex | |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
912 |
|cont| |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
913 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
914 |
"/ this typically happens, when a binary file is read linewise ... |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
915 |
cont := f readStream binary contentsOfEntireFile asString. |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
916 |
check notNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
917 |
checkNot isNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
918 |
contentsMatches := check value:cont |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
919 |
] ifFalse:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
920 |
contentsMatches := (check value:cont) and:[(checkNot value:cont) not]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
921 |
] |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
922 |
] ifFalse:[ |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
923 |
contentsMatches := (checkNot value:cont) not. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
924 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
925 |
] do:[ |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
926 |
contentsString notNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
927 |
ignCaseInContents ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
928 |
check := [:l | l asLowercase includesString:contentsString] |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
929 |
] ifFalse:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
930 |
check := [:l | l includesString:contentsString] |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
931 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
932 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
933 |
notContentsString notNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
934 |
ignCaseInNotContents ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
935 |
checkNot := [:l | l asLowercase includesString:notContentsString] |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
936 |
] ifFalse:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
937 |
checkNot := [:l | l includesString:notContentsString] |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
938 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
939 |
]. |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
940 |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
941 |
lines := f contents ? #(). |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
942 |
check notNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
943 |
checkNot isNil ifTrue:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
944 |
contentsMatches := (lines contains:check). |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
945 |
] ifFalse:[ |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
946 |
contentsMatches := (lines contains:check) and:[(lines contains:checkNot) not] |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
947 |
] |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
948 |
] ifFalse:[ |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
949 |
contentsMatches := (lines contains:checkNot) not. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
950 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
951 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
952 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
953 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
954 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
955 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
956 |
contentsMatches |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
957 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
958 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
959 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
960 |
(self canUseLocate |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
961 |
and:[self useLocate value |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
962 |
and:[searchDirectories not]]) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
963 |
ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
964 |
[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
965 |
|cmd line f| |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
966 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
967 |
cmd := 'locate '. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
968 |
ignCaseInName ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
969 |
cmd := cmd , '--ignore-case' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
970 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
971 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
972 |
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
|
973 |
asStringCollection asStringWith:Character space). |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
974 |
inStream := PipeStream readingFrom:cmd inDirectory:dir. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
975 |
[inStream atEnd] whileFalse:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
976 |
line := inStream nextLine. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
977 |
|
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
978 |
f := line asFilename. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
979 |
(doesFileMatch value:f) ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
980 |
list add:line. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
981 |
] |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
982 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
983 |
] ensure:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
984 |
inStream notNil ifTrue:[inStream close]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
985 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
986 |
^ self. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
987 |
]. |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
988 |
|
3892 | 989 |
bytesToCompareContentsOrNil notNil ifTrue:[ |
990 |
contentsToCompare := bytesToCompareContentsOrNil |
|
991 |
]. |
|
992 |
||
993 |
subDirs := OrderedCollection new. |
|
994 |
||
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
995 |
[ |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
996 |
directoryContents := dir directoryContents. |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
997 |
] on:FileStream openErrorSignal do:[:ex| |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
998 |
list add:((ex parameter pathName , ' -> ' , ex description) asText colorizeAllWith:Color red darkened). |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
999 |
"/ self warn:('Cannot access %1\(%2)' |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1000 |
"/ bindWith:ex parameter printString |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1001 |
"/ with:ex description) withCRs. |
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1002 |
^ self |
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1003 |
]. |
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1004 |
|
4638
79734f7bdfc4
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4518
diff
changeset
|
1005 |
directoryContents sort do:[:fn | |
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1006 |
|f isDirectory| |
3892 | 1007 |
|
1008 |
f := dir construct:fn. |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1009 |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1010 |
isDirectory := f isDirectory. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1011 |
isDirectory ifTrue:[ |
3892 | 1012 |
f isSymbolicLink ifFalse:[ |
1013 |
subDirs add:f |
|
1014 |
] |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1015 |
]. |
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1016 |
(searchDirectories or:[isDirectory not]) ifTrue:[ |
3892 | 1017 |
(nameMatches := namePatterns isNil) ifFalse:[ |
1018 |
ignCaseInName ifTrue:[ |
|
1019 |
nameMatches := namePatterns contains:[:aPattern | aPattern match:(fn asLowercase)] |
|
1020 |
] ifFalse:[ |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1021 |
nameMatches := namePatterns contains:[:aPattern | aPattern match:fn] |
3892 | 1022 |
] |
1023 |
]. |
|
1024 |
nameMatches ifTrue:[ |
|
5176
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1025 |
(isDirectory or:[ doesFileMatch value:f ]) |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1026 |
ifTrue:[ |
b76af7e92feb
option to use locate for faster search
Claus Gittinger <cg@exept.de>
parents:
5140
diff
changeset
|
1027 |
list add:(f asString). |
3892 | 1028 |
] |
1029 |
] |
|
1030 |
] |
|
1031 |
]. |
|
1032 |
||
1033 |
self searchRecursively value ifTrue:[ |
|
1034 |
subDirs do:[:dir | |
|
1035 |
self |
|
1036 |
doFindFileNamed:namePatterns |
|
4518
85b13890d7b1
allow to search for directories
Claus Gittinger <cg@exept.de>
parents:
4336
diff
changeset
|
1037 |
directories:searchDirectories |
3892 | 1038 |
ignoreCase:ignCaseInName |
5231
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1039 |
containingString:contentsString ignoreCaseInContents:ignCaseInContents |
d74730347ed8
added option to search for file NOT containing a string
Claus Gittinger <cg@exept.de>
parents:
5224
diff
changeset
|
1040 |
notContainingString:notContentsString ignoreCaseInNotContents:ignCaseInNotContents |
3892 | 1041 |
sameContentsAsFile:filenameToCompareContentsOrNil |
1042 |
sameContentsAs:contentsToCompare |
|
1043 |
in:dir |
|
1044 |
]. |
|
1045 |
] |
|
1046 |
! ! |
|
1047 |
||
1048 |
!FindFileApplication methodsFor:'queries'! |
|
1049 |
||
1050 |
getTabStringEnd |
|
1051 |
||
1052 |
" get the tab string from the application list on the class side " |
|
1053 |
||
1054 |
^ self fileName directory asString |
|
1055 |
! |
|
1056 |
||
1057 |
hasOneFileSelected |
|
1058 |
| sel | |
|
1059 |
sel := self selectionHolder value. |
|
1060 |
^ (sel notNil and:[sel notEmpty and:[sel size = 1]]) |
|
1061 |
! |
|
1062 |
||
1063 |
hasSelectionInResultList |
|
1064 |
| sel | |
|
1065 |
sel := self selectionHolder value. |
|
1066 |
^ (sel notNil and:[sel notEmpty]) |
|
1067 |
! ! |
|
1068 |
||
1069 |
!FindFileApplication methodsFor:'startup & release'! |
|
1070 |
||
5010 | 1071 |
item:anItem |
3892 | 1072 |
|
4797 | 1073 |
|file newPattern| |
3892 | 1074 |
|
5010 | 1075 |
super item:anItem. |
4797 | 1076 |
|
3892 | 1077 |
file := self fileName. |
1078 |
self searchDirectoryHolder value:(self getDirWithoutFileName:file). |
|
4797 | 1079 |
|
3892 | 1080 |
file isDirectory ifTrue:[ |
4797 | 1081 |
newPattern := '*'. |
3892 | 1082 |
] ifFalse:[ |
5010 | 1083 |
newPattern := '*.', anItem suffix. |
3892 | 1084 |
]. |
4797 | 1085 |
self namePatternHolder value:newPattern. |
3892 | 1086 |
self enableStop value:false. |
1087 |
self enableSearch value:true. |
|
1088 |
^ true. |
|
1089 |
! |
|
1090 |
||
1091 |
postOpenWith:aBuilder |
|
1092 |
||
1093 |
self masterApplication isNil ifTrue:[ |
|
1094 |
self masterApplication:nil. |
|
1095 |
]. |
|
1096 |
findFileView := aBuilder window. |
|
1097 |
self windowGroup addPreEventHook:self. |
|
1098 |
^ super postOpenWith:aBuilder. |
|
1099 |
! |
|
1100 |
||
1101 |
release |
|
1102 |
||
1103 |
self stopSearchTask. |
|
1104 |
^ super release |
|
1105 |
! ! |
|
1106 |
||
1107 |
!FindFileApplication class methodsFor:'documentation'! |
|
1108 |
||
1109 |
version |
|
5252 | 1110 |
^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.18 2003-10-08 15:34:27 cg Exp $' |
3892 | 1111 |
! ! |