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