2658 ! ! |
2656 ! ! |
2659 |
2657 |
2660 !AbstractFileBrowser methodsFor:'aspects handling'! |
2658 !AbstractFileBrowser methodsFor:'aspects handling'! |
2661 |
2659 |
2662 aspectFor:something ifAbsent:aBlock |
2660 aspectFor:something ifAbsent:aBlock |
2663 "returns the model for an aspect |
2661 "returns the model for an aspect; these are stored in a common dictionary" |
2664 " |
2662 |
2665 ^ self aspectFor:something ifAbsent:aBlock notPresentDo:nil |
2663 ^ self aspectFor:something ifAbsent:aBlock notPresentDo:nil |
2666 ! |
2664 ! |
2667 |
2665 |
2668 aspectFor:aKey ifAbsent:aBlock notPresentDo:notPresentBlock |
2666 aspectFor:aKey ifAbsent:aBlock notPresentDo:notPresentBlock |
2669 "return the model for an aspect" |
2667 "returns the model for an aspect; these are stored in a common dictionary" |
2670 |
2668 |
2671 |holder saveAspectItem aspect| |
2669 |holder saveAspectItem aspect| |
2672 |
2670 |
2673 holder := aspects at:aKey ifAbsent:[ |
2671 holder := aspects at:aKey ifAbsent:[ |
2674 masterApplication notNil ifTrue:[ |
2672 masterApplication notNil ifTrue:[ |
3237 ! ! |
3236 ! ! |
3238 |
3237 |
3239 !AbstractFileBrowser methodsFor:'drag & drop'! |
3238 !AbstractFileBrowser methodsFor:'drag & drop'! |
3240 |
3239 |
3241 canDropFiles:dropedObjects for:filename |
3240 canDropFiles:dropedObjects for:filename |
3242 | filenameDirString filenameDir| |
3241 |filenameDirString filenameDir| |
3243 |
3242 |
3244 dropedObjects isEmpty ifTrue:[^ false]. |
3243 dropedObjects isEmpty ifTrue:[^ false]. |
|
3244 |
3245 filenameDir := self getDirWithoutFileName:filename. |
3245 filenameDir := self getDirWithoutFileName:filename. |
3246 filenameDir isWritable ifFalse:[^ false]. |
3246 filenameDir isWritable ifFalse:[^ false]. |
|
3247 |
3247 filenameDirString := filenameDir asString. |
3248 filenameDirString := filenameDir asString. |
3248 |
3249 |
3249 dropedObjects do:[:aDropObject | |
3250 dropedObjects do:[:aDropObject | |
3250 |dropFileName dropFileNameString| |
3251 (self canDropObject:aDropObject into:filenameDir) ifFalse:[^ false]. |
3251 dropFileName := aDropObject theObject. |
3252 "/ |dropFileName dropFileNameString physicalPathName| |
3252 dropFileNameString := dropFileName asString. |
3253 "/ |
3253 dropFileName isDirectory ifTrue:[ |
3254 "/ dropFileName := aDropObject theObject. |
3254 (self fileName:filenameDirString startsWith:dropFileNameString) ifTrue:[ |
3255 "/ dropFileNameString := dropFileName asString. |
3255 self notify:'Cannot drop a directory into one of its parent directories'. |
3256 "/ dropFileName isDirectory ifTrue:[ |
3256 ^ false |
3257 "/ (self fileName:filenameDirString startsWith:dropFileNameString) ifTrue:[ |
3257 ] |
3258 "/ self notify:'Cannot drop a directory into one of its parent directories'. |
3258 ] ifFalse:[ |
3259 "/ ^ false |
3259 | physicalPathName | |
3260 "/ ] |
3260 physicalPathName := dropFileName physicalPathName. |
3261 "/ ] ifFalse:[ |
3261 (filenameDirString = dropFileName directory asString |
3262 "/ physicalPathName := dropFileName physicalPathName. |
3262 or:[ aDropObject isFileInArchive not and:[physicalPathName notNil |
3263 "/ (filenameDirString = dropFileName directory asString |
3263 and:[ filenameDirString = physicalPathName asFilename directory asString]]]) ifTrue:[ |
3264 "/ or:[ aDropObject isFileInArchive not and:[physicalPathName notNil |
3264 self notify:'Cannot drop a file into same directory'. |
3265 "/ and:[ filenameDirString = physicalPathName asFilename directory asString]]]) ifTrue:[ |
3265 ^ false |
3266 "/ self notify:'Cannot drop a file into same directory'. |
3266 ] |
3267 "/ ^ false |
|
3268 "/ ] |
|
3269 "/ ] |
|
3270 ]. |
|
3271 self notify:nil. |
|
3272 ^ true |
|
3273 ! |
|
3274 |
|
3275 canDropObject:aDropObject into:aDirectory |
|
3276 |filenameDirString dropFileName dropFileNameString physicalPathName| |
|
3277 |
|
3278 dropFileName := aDropObject theObject. |
|
3279 dropFileNameString := dropFileName asString. |
|
3280 dropFileName isDirectory ifTrue:[ |
|
3281 filenameDirString := aDirectory asString. |
|
3282 (self fileName:filenameDirString startsWith:dropFileNameString) ifTrue:[ |
|
3283 self notify:'Cannot drop a directory into one of its parent directories'. |
|
3284 ^ false |
3267 ] |
3285 ] |
3268 ]. |
3286 ] ifFalse:[ |
3269 ^ true |
3287 physicalPathName := dropFileName physicalPathName. |
|
3288 (aDirectory = dropFileName directory |
|
3289 or:[ aDropObject isFileInArchive not |
|
3290 and:[physicalPathName notNil |
|
3291 and:[ aDirectory = physicalPathName asFilename directory]]]) ifTrue:[ |
|
3292 self notify:'Cannot drop a file into same directory'. |
|
3293 ^ false |
|
3294 ] |
|
3295 ]. |
|
3296 ^ true. |
3270 ! |
3297 ! |
3271 |
3298 |
3272 doStartDrag:aDropSource in:aView |
3299 doStartDrag:aDropSource in:aView |
3273 "set the cursors before starting the drag & drop operation |
3300 "set the cursors before starting the drag & drop operation |
3274 " |
3301 " |
6097 |
6120 |
6098 ^ self fileListIsEmpty not. |
6121 ^ self fileListIsEmpty not. |
6099 ! |
6122 ! |
6100 |
6123 |
6101 fileName:aFilename1 startsWith:aFilename2 |
6124 fileName:aFilename1 startsWith:aFilename2 |
6102 |
6125 " check if aFilename2 is a prefix of aFilename1" |
6103 " check if aFilename2 starts with the same directories like aFilename1 " |
|
6104 |
6126 |
6105 | file1 file2 | |
6127 | file1 file2 | |
6106 |
6128 |
6107 aFilename2 isNil ifTrue:[ ^ false]. |
6129 (aFilename2 isNil or:[aFilename1 isNil]) ifTrue:[ ^ false]. |
6108 aFilename1 isNil ifTrue:[ ^ false]. |
|
6109 file1 := aFilename1 asFilename. |
6130 file1 := aFilename1 asFilename. |
6110 file2 := aFilename2 asFilename. |
6131 file2 := aFilename2 asFilename. |
|
6132 |
6111 file2 isRootDirectory ifTrue:[ ^ true]. |
6133 file2 isRootDirectory ifTrue:[ ^ true]. |
|
6134 |
6112 ((file1 isDirectory) |
6135 ((file1 isDirectory) |
6113 and:[(file2 isDirectory) |
6136 and:[(file2 isDirectory) |
6114 and:[file1 directory = file2 directory]]) ifTrue:[ |
6137 and:[file1 directory = file2 directory]]) ifTrue:[ |
6115 ^ file1 baseName = file2 baseName |
6138 ^ file1 baseName = file2 baseName |
6116 ]. |
6139 ]. |