author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sun, 09 Oct 2016 22:55:02 +0100 | |
branch | jv |
changeset 17133 | f9f20407fbf9 |
parent 15566 | 184cea584be5 |
parent 16912 | e57a97280a14 |
child 17134 | c4cce8b7a95d |
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 |
||
49 |
!AbstractDirectoryBrowser methodsFor:'accessing'! |
|
50 |
||
51 |
updateToExternFileHolderLock |
|
52 |
updateToExternFileHolderLock isNil ifTrue:[ |
|
53 |
updateToExternFileHolderLock := self class newLock. |
|
54 |
]. |
|
55 |
^ updateToExternFileHolderLock |
|
56 |
! ! |
|
57 |
||
58 |
!AbstractDirectoryBrowser methodsFor:'drag & drop'! |
|
59 |
||
7402 | 60 |
canDrop:aDropContext |
4712 | 61 |
^ inDropMode and:[canDropItem] |
7402 | 62 |
|
63 |
"Modified: / 13-10-2006 / 11:35:09 / cg" |
|
4712 | 64 |
! |
65 |
||
4745 | 66 |
doDrop:aContext |
67 |
|col destinationPath receiver didDrop| |
|
68 |
||
4754
e8ff80bb18ea
oops - dropLeave has a side effect.
Claus Gittinger <cg@exept.de>
parents:
4745
diff
changeset
|
69 |
destinationPath := self dropDestinationPath. |
e8ff80bb18ea
oops - dropLeave has a side effect.
Claus Gittinger <cg@exept.de>
parents:
4745
diff
changeset
|
70 |
|
4745 | 71 |
self dropLeave:aContext. |
72 |
||
7586 | 73 |
destinationPath isNil ifTrue:[^ self]. |
4745 | 74 |
|
75 |
aContext dropSource argument == #archivApplication ifTrue:[ |
|
76 |
receiver := aContext dropSource receiver. |
|
77 |
receiver extractSelectedFilesTo:destinationPath askForExtractOptions:true. |
|
78 |
^ self |
|
79 |
]. |
|
80 |
||
9362 | 81 |
self withWaitCursorDo:[ |
82 |
col := aContext dropObjects collect:[:obj | obj theObject]. |
|
83 |
didDrop := self copyOrMoveFiles:col to:destinationPath. |
|
84 |
didDrop ifFalse:[ |
|
85 |
aContext clearHasDroppedFlagToSuppressFeedBack |
|
86 |
]. |
|
87 |
] |
|
4745 | 88 |
! |
89 |
||
5335 | 90 |
dropDestinationPath |
91 |
self subclassResponsibility |
|
92 |
! |
|
93 |
||
4712 | 94 |
dropEnter:aContext |
6377 | 95 |
|dropObjects| |
4712 | 96 |
|
97 |
self dropTargetItemChangedTo:nil in:aContext. |
|
98 |
inDropMode := false. |
|
99 |
||
100 |
"/ self directory isNil ifTrue:[^ self]. |
|
6377 | 101 |
dropObjects := aContext dropObjects. |
4712 | 102 |
|
9328 | 103 |
dropObjects do:[:anObject| |
15042
f002aba0f9c9
class: AbstractDirectoryBrowser
Claus Gittinger <cg@exept.de>
parents:
12873
diff
changeset
|
104 |
|checkObject| |
4712 | 105 |
|
9328 | 106 |
anObject isFileObject ifFalse:[^ self]. |
4712 | 107 |
|
9328 | 108 |
checkObject := anObject theObject. |
6250
5b0673ccff1c
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
5967
diff
changeset
|
109 |
checkObject isFilename ifFalse:[^ self]. |
5b0673ccff1c
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
5967
diff
changeset
|
110 |
(aContext dropSource argument == #archivApplication) ifFalse:[ |
4712 | 111 |
checkObject isSpecialFile ifTrue:[^ self]. |
112 |
checkObject isReadable ifFalse:[^ self]. |
|
113 |
]. |
|
114 |
]. |
|
115 |
inDropMode := true. |
|
116 |
! |
|
117 |
||
118 |
dropLeave:aDropContext |
|
9328 | 119 |
"called, when leaving the widget" |
120 |
||
4712 | 121 |
inDropMode ifFalse:[ ^ self ]. |
122 |
||
123 |
self dropTargetItemChangedTo:nil in:aDropContext. |
|
124 |
self removeExpandItemTimedBlock. |
|
125 |
inDropMode := false. |
|
126 |
! |
|
127 |
||
5330 | 128 |
dropTargetItemChangedTo:anItem in:aContext |
129 |
||
130 |
self subclassResponsibility |
|
131 |
! |
|
132 |
||
4712 | 133 |
getDropObjects:anArgument |
134 |
||
135 |
^ self selectedFiles collect:[:file| DropObject newFile:file]. |
|
136 |
! |
|
137 |
||
138 |
getLineNumberFor:aDropContext |
|
139 |
| yVisible| |
|
140 |
||
141 |
yVisible := (aDropContext targetPoint y). |
|
142 |
^ browser yVisibleToRowNr:yVisible. |
|
143 |
! |
|
144 |
||
4802 | 145 |
pushUserEvent:selector withArgument:argument |
146 |
self window sensor |
|
147 |
pushUserEvent:selector |
|
148 |
for:self |
|
149 |
withArgument:argument |
|
5796 | 150 |
! |
151 |
||
152 |
removeExpandItemTimedBlock |
|
153 |
"left blank" |
|
4712 | 154 |
! ! |
155 |
||
156 |
!AbstractDirectoryBrowser methodsFor:'file actions'! |
|
157 |
||
158 |
doCopy |
|
6286 | 159 |
"copy the selected files/directories to the clipBoard" |
4712 | 160 |
|
161 |
self copyFilesToClipBoard:(self selectedFiles). |
|
162 |
! |
|
163 |
||
164 |
doCut |
|
6286 | 165 |
"cut the selected files/directories to the clipBoard" |
4712 | 166 |
|
167 |
self cutFilesToClipBoard:(self selectedFiles). |
|
168 |
! |
|
169 |
||
170 |
doDelete |
|
6286 | 171 |
"delete the selected files/directories" |
5967 | 172 |
|
4742
972a9d30ec47
enumerate copies of the selection in delete & rename
Claus Gittinger <cg@exept.de>
parents:
4712
diff
changeset
|
173 |
self deleteFiles:(self selectedFiles copy). |
6286 | 174 |
! |
175 |
||
176 |
doErase |
|
177 |
"erase the selected files" |
|
178 |
||
179 |
self eraseFiles:(self selectedFiles copy). |
|
4712 | 180 |
! ! |
181 |
||
182 |
!AbstractDirectoryBrowser methodsFor:'selection'! |
|
183 |
||
184 |
selectedFiles |
|
185 |
||
186 |
^ self selectedItems collect:[:item| item fileName]. |
|
187 |
! ! |
|
188 |
||
189 |
!AbstractDirectoryBrowser methodsFor:'startup & release'! |
|
190 |
||
191 |
initialize |
|
192 |
||
193 |
inDropMode := false. |
|
194 |
^ super initialize. |
|
195 |
! |
|
196 |
||
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
197 |
postOpenAsSubcanvasWith:aBuilder |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
198 |
"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
|
199 |
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
|
200 |
|
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
201 |
"/ cg: used to be unconditionally true hew; |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
202 |
"/ but then, when a FileDialog (which is not an AbstractFileBrowser) is opened, |
16912 | 203 |
"/ 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
|
204 |
"/ especially the enableDirectoryUp is false. |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
205 |
"/ 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
|
206 |
"/ (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
|
207 |
"/ 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
|
208 |
self postOpenFromMaster:(self masterApplication class includesBehavior:AbstractFileBrowser). |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
209 |
! |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
210 |
|
5444 | 211 |
postOpenFromMaster:fromMaster |
5442 | 212 |
self subclassResponsibility |
4712 | 213 |
! |
214 |
||
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
215 |
postOpenWith:aBuilder |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
216 |
"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
|
217 |
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
|
218 |
|
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
219 |
self postOpenFromMaster:false. |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
220 |
! |
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
221 |
|
4712 | 222 |
preBuildWith:aBuilder |
223 |
||
224 |
self masterApplication isNil ifTrue:[ |
|
225 |
self masterApplication:nil. |
|
226 |
]. |
|
227 |
^ super preBuildWith:aBuilder. |
|
228 |
! ! |
|
229 |
||
230 |
!AbstractDirectoryBrowser class methodsFor:'documentation'! |
|
231 |
||
232 |
version |
|
16912 | 233 |
^ '$Header$' |
9328 | 234 |
! |
235 |
||
236 |
version_CVS |
|
16912 | 237 |
^ '$Header$' |
4712 | 238 |
! ! |
12873
0bf1fc08cfd1
oops - startup did not enable directoryUp
Claus Gittinger <cg@exept.de>
parents:
9362
diff
changeset
|
239 |