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