author | Claus Gittinger <cg@exept.de> |
Thu, 18 Jan 2018 19:07:03 +0100 | |
changeset 17944 | 58da3a446bc2 |
parent 17866 | 6a5f75df356b |
child 18142 | d367ddfbb627 |
permissions | -rw-r--r-- |
17866 | 1 |
"{ Encoding: utf8 }" |
2 |
||
5139 | 3 |
" |
4 |
COPYRIGHT (c) 2003 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
4712 | 14 |
"{ Package: 'stx:libtool' }" |
15 |
||
16912 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
4712 | 18 |
AbstractFileBrowser subclass:#AbstractDirectoryBrowser |
19 |
instanceVariableNames:'inDropMode canDropItem browser updateToExternFileHolderLock' |
|
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'Interface-Tools-File' |
|
23 |
! |
|
24 |
||
25 |
!AbstractDirectoryBrowser class methodsFor:'documentation'! |
|
26 |
||
5139 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 2003 by eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
4712 | 41 |
documentation |
42 |
" |
|
43 |
Abstract class containing the common code from DirectoryTreeBrowser and |
|
44 |
DirectoryContentsBrowser applications. |
|
5967 | 45 |
|
46 |
[Author:] |
|
47 |
Christian Penk |
|
4712 | 48 |
" |
49 |
! ! |
|
50 |
||
17289 | 51 |
!AbstractDirectoryBrowser class methodsFor:'queries'! |
52 |
||
53 |
isAbstract |
|
54 |
^ self == AbstractDirectoryBrowser |
|
55 |
! ! |
|
56 |
||
4712 | 57 |
!AbstractDirectoryBrowser methodsFor:'accessing'! |
58 |
||
59 |
updateToExternFileHolderLock |
|
60 |
updateToExternFileHolderLock isNil ifTrue:[ |
|
61 |
updateToExternFileHolderLock := self class newLock. |
|
62 |
]. |
|
63 |
^ updateToExternFileHolderLock |
|
64 |
! ! |
|
65 |
||
66 |
!AbstractDirectoryBrowser methodsFor:'drag & drop'! |
|
67 |
||
7402 | 68 |
canDrop:aDropContext |
4712 | 69 |
^ inDropMode and:[canDropItem] |
7402 | 70 |
|
71 |
"Modified: / 13-10-2006 / 11:35:09 / cg" |
|
4712 | 72 |
! |
73 |
||
4745 | 74 |
doDrop:aContext |
75 |
|col destinationPath receiver didDrop| |
|
76 |
||
4754
e8ff80bb18ea
oops - dropLeave has a side effect.
Claus Gittinger <cg@exept.de>
parents:
4745
diff
changeset
|
77 |
destinationPath := self dropDestinationPath. |
e8ff80bb18ea
oops - dropLeave has a side effect.
Claus Gittinger <cg@exept.de>
parents:
4745
diff
changeset
|
78 |
|
4745 | 79 |
self dropLeave:aContext. |
80 |
||
7586 | 81 |
destinationPath isNil ifTrue:[^ self]. |
4745 | 82 |
|
83 |
aContext dropSource argument == #archivApplication ifTrue:[ |
|
84 |
receiver := aContext dropSource receiver. |
|
85 |
receiver extractSelectedFilesTo:destinationPath askForExtractOptions:true. |
|
86 |
^ self |
|
87 |
]. |
|
88 |
||
9362 | 89 |
self withWaitCursorDo:[ |
17866 | 90 |
col := aContext dropObjects collect:#theObject. |
9362 | 91 |
didDrop := self copyOrMoveFiles:col to:destinationPath. |
92 |
didDrop ifFalse:[ |
|
93 |
aContext clearHasDroppedFlagToSuppressFeedBack |
|
94 |
]. |
|
95 |
] |
|
4745 | 96 |
! |
97 |
||
5335 | 98 |
dropDestinationPath |
99 |
self subclassResponsibility |
|
100 |
! |
|
101 |
||
4712 | 102 |
dropEnter:aContext |
6377 | 103 |
|dropObjects| |
4712 | 104 |
|
105 |
self dropTargetItemChangedTo:nil in:aContext. |
|
106 |
inDropMode := false. |
|
107 |
||
108 |
"/ self directory isNil ifTrue:[^ self]. |
|
6377 | 109 |
dropObjects := aContext dropObjects. |
4712 | 110 |
|
17754 | 111 |
dropObjects do:[:eachDropObject| |
15042
f002aba0f9c9
class: AbstractDirectoryBrowser
Claus Gittinger <cg@exept.de>
parents:
12873
diff
changeset
|
112 |
|checkObject| |
4712 | 113 |
|
17754 | 114 |
eachDropObject isFileObject ifFalse:[^ self]. |
4712 | 115 |
|
17754 | 116 |
checkObject := eachDropObject theObject. |
6250
5b0673ccff1c
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
5967
diff
changeset
|
117 |
checkObject isFilename ifFalse:[^ self]. |
5b0673ccff1c
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
5967
diff
changeset
|
118 |
(aContext dropSource argument == #archivApplication) ifFalse:[ |
4712 | 119 |
checkObject isSpecialFile ifTrue:[^ self]. |
120 |
checkObject isReadable ifFalse:[^ self]. |
|
121 |
]. |
|
122 |
]. |
|
123 |
inDropMode := true. |
|
17754 | 124 |
|
125 |
"Modified (format): / 15-11-2017 / 11:10:16 / cg" |
|
4712 | 126 |
! |
127 |
||
128 |
dropLeave:aDropContext |
|
9328 | 129 |
"called, when leaving the widget" |
130 |
||
4712 | 131 |
inDropMode ifFalse:[ ^ self ]. |
132 |
||
133 |
self dropTargetItemChangedTo:nil in:aDropContext. |
|
134 |
self removeExpandItemTimedBlock. |
|
135 |
inDropMode := false. |
|
136 |
! |
|
137 |
||
5330 | 138 |
dropTargetItemChangedTo:anItem in:aContext |
139 |
||
140 |
self subclassResponsibility |
|
141 |
! |
|
142 |
||
4712 | 143 |
getDropObjects:anArgument |
144 |
||
145 |
^ self selectedFiles collect:[:file| DropObject newFile:file]. |
|
146 |
! |
|
147 |
||
148 |
getLineNumberFor:aDropContext |
|
149 |
| yVisible| |
|
150 |
||
151 |
yVisible := (aDropContext targetPoint y). |
|
152 |
^ browser yVisibleToRowNr:yVisible. |
|
153 |
! |
|
154 |
||
4802 | 155 |
pushUserEvent:selector withArgument:argument |
156 |
self window sensor |
|
157 |
pushUserEvent:selector |
|
158 |
for:self |
|
159 |
withArgument:argument |
|
5796 | 160 |
! |
161 |
||
162 |
removeExpandItemTimedBlock |
|
163 |
"left blank" |
|
4712 | 164 |
! ! |
165 |
||
166 |
!AbstractDirectoryBrowser methodsFor:'file actions'! |
|
167 |
||
168 |
doCopy |
|
6286 | 169 |
"copy the selected files/directories to the clipBoard" |
4712 | 170 |
|
171 |
self copyFilesToClipBoard:(self selectedFiles). |
|
172 |
! |
|
173 |
||
174 |
doCut |
|
6286 | 175 |
"cut the selected files/directories to the clipBoard" |
4712 | 176 |
|
177 |
self cutFilesToClipBoard:(self selectedFiles). |
|
178 |
! |
|
179 |
||
180 |
doDelete |
|
6286 | 181 |
"delete the selected files/directories" |
5967 | 182 |
|
4742
972a9d30ec47
enumerate copies of the selection in delete & rename
Claus Gittinger <cg@exept.de>
parents:
4712
diff
changeset
|
183 |
self deleteFiles:(self selectedFiles copy). |
6286 | 184 |
! |
185 |
||
186 |
doErase |
|
187 |
"erase the selected files" |
|
188 |
||
189 |
self eraseFiles:(self selectedFiles copy). |
|
4712 | 190 |
! ! |
191 |
||
192 |
!AbstractDirectoryBrowser methodsFor:'selection'! |
|
193 |
||
194 |
selectedFiles |
|
195 |
||
17866 | 196 |
^ self selectedItems collect:#fileName. |
16946 | 197 |
! |
198 |
||
199 |
selectedItems |
|
200 |
self subclassResponsibility |
|
4712 | 201 |
! ! |
202 |
||
203 |
!AbstractDirectoryBrowser methodsFor:'startup & release'! |
|
204 |
||
205 |
initialize |
|
206 |
||
207 |
inDropMode := false. |
|
208 |
^ super initialize. |
|
209 |
! |
|
210 |
||
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
211 |
postOpenAsSubcanvasWith:aBuilder |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
212 |
"this is sent after the applications window is opened inside another application. |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
213 |
Can be redefined in subclasses for actions after showing the canvas view." |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
214 |
|
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
215 |
"/ cg: used to be unconditionally true hew; |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
216 |
"/ but then, when a FileDialog (which is not an AbstractFileBrowser) is opened, |
16912 | 217 |
"/ the commonPostBuild will not properly update its enable channels; |
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
218 |
"/ especially the enableDirectoryUp is false. |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
219 |
"/ This whole FileBrowser is so complicated that it became almost unusable. |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
220 |
"/ (too much inheritance and knowledge - DirTree and DirContents should each only do |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
221 |
"/ what it should and not depend on shared functionality from their superclass) |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
222 |
self postOpenFromMaster:(self masterApplication class includesBehavior:AbstractFileBrowser). |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
223 |
! |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
224 |
|
5444 | 225 |
postOpenFromMaster:fromMaster |
5442 | 226 |
self subclassResponsibility |
4712 | 227 |
! |
228 |
||
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
229 |
postOpenWith:aBuilder |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
230 |
"this is sent after the applications main window is opened. |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
231 |
Can be redefined in subclasses for actions after opening the view." |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
232 |
|
17578 | 233 |
super postOpenWith:aBuilder. |
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
234 |
self postOpenFromMaster:false. |
17578 | 235 |
|
236 |
"Modified: / 16-07-2017 / 12:19:48 / cg" |
|
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
237 |
! |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
238 |
|
4712 | 239 |
preBuildWith:aBuilder |
240 |
||
241 |
self masterApplication isNil ifTrue:[ |
|
242 |
self masterApplication:nil. |
|
243 |
]. |
|
244 |
^ super preBuildWith:aBuilder. |
|
245 |
! ! |
|
246 |
||
247 |
!AbstractDirectoryBrowser class methodsFor:'documentation'! |
|
248 |
||
249 |
version |
|
16912 | 250 |
^ '$Header$' |
9328 | 251 |
! |
252 |
||
253 |
version_CVS |
|
16912 | 254 |
^ '$Header$' |
4712 | 255 |
! ! |
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
256 |