--- a/AbstractFileBrowser.st Mon Oct 14 17:30:45 2002 +0200
+++ b/AbstractFileBrowser.st Mon Oct 14 18:02:37 2002 +0200
@@ -202,7 +202,7 @@
#viewType
#enableFileHistory
#openMultipleApplicationsForType
- #sortBlockHolder
+ #sortBlockProperty
#filenameEntryFieldVisibleHolder
#toolBarVisibleHolder
)
@@ -1183,21 +1183,21 @@
#label: 'By Filename'
#translateLabel: true
#hideMenuOnActivated: false
- #choice: #sortBlockHolder
+ #choice: #sortBlockProperty
#choiceValue: #baseName
)
#(#MenuItem
#label: 'By Type'
#translateLabel: true
#hideMenuOnActivated: false
- #choice: #sortBlockHolder
+ #choice: #sortBlockProperty
#choiceValue: #suffix
)
#(#MenuItem
#label: 'By Permissions'
#translateLabel: true
#hideMenuOnActivated: false
- #choice: #sortBlockHolder
+ #choice: #sortBlockProperty
#choiceValue: #permissions
)
#(#MenuItem
@@ -1205,7 +1205,7 @@
#translateLabel: true
#hideMenuOnActivated: false
#isVisible: #viewOwner
- #choice: #sortBlockHolder
+ #choice: #sortBlockProperty
#choiceValue: #owner
)
#(#MenuItem
@@ -1213,30 +1213,23 @@
#translateLabel: true
#hideMenuOnActivated: false
#isVisible: #viewOwner
- #choice: #sortBlockHolder
+ #choice: #sortBlockProperty
#choiceValue: #group
)
#(#MenuItem
#label: 'By Size'
#translateLabel: true
#hideMenuOnActivated: false
- #choice: #sortBlockHolder
- #choiceValue: #size
+ #choice: #sortBlockProperty
+ #choiceValue: #fileSize
)
#(#MenuItem
#label: 'By Date && Time'
#translateLabel: true
#hideMenuOnActivated: false
- #choice: #sortBlockHolder
+ #choice: #sortBlockProperty
#choiceValue: #modificationTime
)
-"/ #(#MenuItem
-"/ #label: 'By Description'
-"/ #translateLabel: true
-"/ #hideMenuOnActivated: false
-"/ #choice: #sortBlockHolder
-"/ #choiceValue: #fileType
-"/ )
#(#MenuItem
#label: '-'
)
@@ -1642,15 +1635,6 @@
^ self aspectFor:#currentFileNameHolder ifAbsent:[(OrderedCollection with:(Filename currentDirectory asAbsoluteFilename)) asValue]
!
-currentSortOrder
-
- " returns a Ordered Collection of all directories currently selected
- if only a file is selected currentDirectories holds the directory of the file
- "
-
- ^ self aspectFor:#currentSortOrder ifAbsent:[ Dictionary new ].
-!
-
enableDirectoryUp
^ self aspectFor:#enableDirectoryUp ifAbsent:[false asValue]
@@ -1684,15 +1668,6 @@
notifyChannel
^ self aspectFor:#notifyChannel ifAbsent:['' asValue]
-!
-
-sortCaseless
-
- ^ self aspectFor:#sortCaseless ifAbsent:[
- | holder |
- holder := (Filename isCaseSensitive not) asValue.
- holder
- ]
! !
!AbstractFileBrowser methodsFor:'aspects handling'!
@@ -1822,11 +1797,6 @@
^ self aspectFor:#showHiddenFiles ifAbsent:[ true asValue ].
!
-sortBlockHolder
-
- ^ self aspectFor:#sortBlockHolder ifAbsent:[ #baseName asValue ].
-!
-
toolBarVisibleHolder
^ self aspectFor:#toolBarVisibleHolder ifAbsent:[true asValue]
@@ -1996,6 +1966,15 @@
].
^ self
].
+ changedObject == self sortCaseless ifTrue:[
+ self sortFileListsBy:#baseName withReverse:false.
+ ^ self
+ ].
+ changedObject == self sortBlockProperty ifTrue:[
+ self sortFileListsBy:(self sortBlockProperty value) withReverse:false.
+ ^ self.
+ ].
+
super update:something with:aParameter from:changedObject
! !
@@ -4237,52 +4216,130 @@
| files |
files := self currentFileNameHolder value.
^ (files detect:[: file | file isDirectory not] ifNone:[nil]).
-!
-
-selectedFiles
-
- | files |
- files := self currentFileNameHolder value.
- ^ (files select:[: file | file isDirectory not]).
! !
!AbstractFileBrowser methodsFor:'sorting'!
-sortList:instanceName
-
- self sortList:instanceName withReverse:true
-!
-
-sortList:instanceName withReverse:aBoolean
-
- | aSymbol sortCaselessLocal locCurrentSortOrder|
+currentSortOrder
+
+ " returns a Ordered Collection of all directories currently selected
+ if only a file is selected currentDirectories holds the directory of the file
+ "
+
+ ^ self aspectFor:#currentSortOrder ifAbsent:[ Dictionary new ].
+!
+
+makeDirectorySortBlockFor:aSortBlock
+
+ self viewDirectoriesInDirectoryContentsBrowser value ifTrue:[
+ ^ [:a :b|
+ |aIsDir bIsDir res|
+
+ aIsDir := a isDirectory.
+ bIsDir := b isDirectory.
+ (aIsDir ~~ bIsDir) ifTrue:[
+ res := aIsDir
+ ] ifFalse:[
+ res := aSortBlock value:a value:b.
+ ].
+ res
+ ].
+ ].
+ ^ aSortBlock
+!
+
+sortBlockHolder
+ |nameSortBlock|
+
+ ^ self aspectFor:#sortBlockHolder ifAbsent:[
+ self sortCaseless ifTrue:[
+ nameSortBlock := [ :a :b | a asString asLowercase < b asString asLowercase.].
+ ] ifFalse:[
+ nameSortBlock := [ :a :b | a asString < b asString.].
+ ].
+ (self makeDirectorySortBlockFor:nameSortBlock) asValue.
+ ].
+!
+
+sortBlockProperty
+
+ ^ self aspectFor:#sortBlockProperty ifAbsent:[ #baseName asValue ].
+!
+
+sortCaseless
+
+ ^ self aspectFor:#sortCaseless ifAbsent:[
+ | holder |
+ holder := (Filename isCaseSensitive not) asValue.
+ holder
+ ]
+!
+
+sortFileListsBy:instanceName
+
+ self sortFileListsBy:instanceName withReverse:true
+!
+
+sortFileListsBy:instanceName withReverse:aBoolean
+
+ | aSymbol sortCaselessLocal currentSortOrder cmpOp instanceSortBlock|
aSymbol := instanceName asSymbol.
- locCurrentSortOrder := self currentSortOrder.
- locCurrentSortOrder isEmpty ifTrue:[
- locCurrentSortOrder at:#column put:aSymbol.
- locCurrentSortOrder at:#reverse put:false.
- locCurrentSortOrder at:#sortCaseless put:sortCaselessLocal.
+ currentSortOrder := self currentSortOrder.
+ currentSortOrder isEmpty ifTrue:[
+ currentSortOrder at:#column put:aSymbol.
+ currentSortOrder at:#reverse put:false.
+ currentSortOrder at:#sortCaseless put:sortCaselessLocal.
] ifFalse:[
- (locCurrentSortOrder at:#sortCaseless) ~= sortCaselessLocal ifTrue:[
+ (currentSortOrder at:#sortCaseless) ~= sortCaselessLocal ifTrue:[
"/ sort caseless changed
- locCurrentSortOrder at:#sortCaseless put:sortCaselessLocal.
+ currentSortOrder at:#sortCaseless put:sortCaselessLocal.
] ifFalse:[
- (locCurrentSortOrder at:#column) = aSymbol ifTrue:[
+ (currentSortOrder at:#column) = aSymbol ifTrue:[
"/ same column like before - change sort order ifReverse is true
aBoolean ifTrue:[
| isReverse |
- isReverse := locCurrentSortOrder at:#reverse.
- locCurrentSortOrder at:#reverse put:(isReverse not).
+ isReverse := currentSortOrder at:#reverse.
+ currentSortOrder at:#reverse put:(isReverse not).
].
] ifFalse:[
"/ another column - remark column
- locCurrentSortOrder at:#column put:aSymbol.
+ currentSortOrder at:#column put:aSymbol.
]
]
].
- self application:#DirectoryContentsBrowser do:#sortListChangedWith:and: withArg:locCurrentSortOrder withArg:instanceName.
-"/ self application:#DirectoryTreeBrowser do:#sortListChangedWith:and: withArg:true withArg:instanceName.
+ sortCaselessLocal := self sortCaseless value.
+ (currentSortOrder at:#reverse) ifTrue:[
+ cmpOp := #'>'
+ ] ifFalse:[
+ cmpOp := #'<'
+ ].
+ instanceSortBlock := [:a :b |
+ |entry1 entry2|
+
+ entry1 := (a perform:aSymbol).
+ entry2 := (b perform:aSymbol).
+ ((entry1 isNil) or:[entry2 isNil]) ifTrue:[
+ ((entry1 isNil) and:[entry2 isNil]) ifTrue:[true] ifFalse:[
+ ((entry1 notNil) and:[entry2 isNil]) ifTrue:[
+ (currentSortOrder at:#reverse)
+ ].
+ (currentSortOrder at:#reverse) not
+ ]
+ ] ifFalse:[
+ (aSymbol = #baseName) ifTrue:[
+ sortCaselessLocal ifTrue:[
+ entry1 := entry1 asString asLowercase.
+ entry2 := entry2 asString asLowercase.
+ ] ifFalse:[
+ entry1 := entry1 asString.
+ entry2 := entry2 asString.
+ ].
+ ].
+ entry1 perform:cmpOp with:entry2
+ ]
+ ].
+ self sortBlockHolder value:(self makeDirectorySortBlockFor:instanceSortBlock).
! !
!AbstractFileBrowser methodsFor:'startup & release'!
@@ -4643,5 +4700,5 @@
!AbstractFileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.18 2002-10-14 09:14:55 penk Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.19 2002-10-14 16:02:37 penk Exp $'
! !