diff --git a/src/NewTools-FileBrowser/DateAndTime.extension.st b/src/NewTools-FileBrowser/DateAndTime.extension.st deleted file mode 100644 index 66cdf9b5c..000000000 --- a/src/NewTools-FileBrowser/DateAndTime.extension.st +++ /dev/null @@ -1,10 +0,0 @@ -Extension { #name : 'DateAndTime' } - -{ #category : '*NewTools-FileBrowser' } -DateAndTime >> fileDialogFormat [ - ^ '{1} {2} {3} {4}' format: - {self dayOfMonth asString. - self monthAbbreviation. - self year asString. - (self asTime print24 first: 5)} -] diff --git a/src/NewTools-FileBrowser/StFileBrowserAbstractColumn.class.st b/src/NewTools-FileBrowser/StFileBrowserAbstractColumn.class.st index 3502ef761..636290c6d 100644 --- a/src/NewTools-FileBrowser/StFileBrowserAbstractColumn.class.st +++ b/src/NewTools-FileBrowser/StFileBrowserAbstractColumn.class.st @@ -50,6 +50,11 @@ StFileBrowserAbstractColumn class >> evaluateOn: aFileReference [ ^ self subclassResponsibility ] +{ #category : 'templateMethod' } +StFileBrowserAbstractColumn class >> formatOn: aValue [ + ^ self subclassResponsibility +] + { #category : 'testing' } StFileBrowserAbstractColumn class >> isAbstract [ diff --git a/src/NewTools-FileBrowser/StFileBrowserCreationDateColumn.class.st b/src/NewTools-FileBrowser/StFileBrowserCreationDateColumn.class.st index 662560981..1da65900c 100644 --- a/src/NewTools-FileBrowser/StFileBrowserCreationDateColumn.class.st +++ b/src/NewTools-FileBrowser/StFileBrowserCreationDateColumn.class.st @@ -3,23 +3,16 @@ I'm a column use to display the creation date of a file in a File dialog. " Class { #name : 'StFileBrowserCreationDateColumn', - #superclass : 'StFileBrowserAbstractColumn', + #superclass : 'StFileBrowserDateColumn', #category : 'NewTools-FileBrowser-Columns', #package : 'NewTools-FileBrowser', #tag : 'Columns' } -{ #category : 'adding' } -StFileBrowserCreationDateColumn class >> addConstraintTo: aTableColumn [ - - aTableColumn - width: 150; - beSortable -] - { #category : 'templateMethod' } StFileBrowserCreationDateColumn class >> evaluateOn: aFileReference [ - ^ aFileReference creationTime fileDialogFormat + + ^ aFileReference creationTime ] { #category : 'sorting' } diff --git a/src/NewTools-FileBrowser/StFileBrowserDateColumn.class.st b/src/NewTools-FileBrowser/StFileBrowserDateColumn.class.st new file mode 100644 index 000000000..5fcb68f3d --- /dev/null +++ b/src/NewTools-FileBrowser/StFileBrowserDateColumn.class.st @@ -0,0 +1,33 @@ +Class { + #name : 'StFileBrowserDateColumn', + #superclass : 'StFileBrowserAbstractColumn', + #category : 'NewTools-FileBrowser-Columns', + #package : 'NewTools-FileBrowser', + #tag : 'Columns' +} + +{ #category : 'adding' } +StFileBrowserDateColumn class >> addConstraintTo: aTableColumn [ + + aTableColumn + width: 150; + formatted: [ :v | self formatOn: v ]; + beSortable +] + +{ #category : 'templateMethod' } +StFileBrowserDateColumn class >> formatOn: aValue [ + + aValue ifNil: [ ^ 'N/A' ]. + ^ '{1} {2} {3} {4}' format: { + aValue dayOfMonth asString. + aValue monthAbbreviation. + aValue year asString. + (aValue asTime print24 first: 5) } +] + +{ #category : 'testing' } +StFileBrowserDateColumn class >> isAbstract [ + + ^ self == StFileBrowserDateColumn +] diff --git a/src/NewTools-FileBrowser/StFileBrowserLastOpenDateColumn.class.st b/src/NewTools-FileBrowser/StFileBrowserLastOpenDateColumn.class.st index 5590356b9..cdf382bf8 100644 --- a/src/NewTools-FileBrowser/StFileBrowserLastOpenDateColumn.class.st +++ b/src/NewTools-FileBrowser/StFileBrowserLastOpenDateColumn.class.st @@ -3,23 +3,16 @@ I'm a column use to display the last access date of a file in a File dialog. " Class { #name : 'StFileBrowserLastOpenDateColumn', - #superclass : 'StFileBrowserAbstractColumn', + #superclass : 'StFileBrowserDateColumn', #category : 'NewTools-FileBrowser-Columns', #package : 'NewTools-FileBrowser', #tag : 'Columns' } -{ #category : 'adding' } -StFileBrowserLastOpenDateColumn class >> addConstraintTo: aTableColumn [ - - aTableColumn - width: 150; - beSortable -] - { #category : 'templateMethod' } StFileBrowserLastOpenDateColumn class >> evaluateOn: aFileReference [ - ^ aFileReference accessTime fileDialogFormat + + ^ aFileReference accessTime ] { #category : 'sorting' } diff --git a/src/NewTools-FileBrowser/StFileBrowserModificationDateColumn.class.st b/src/NewTools-FileBrowser/StFileBrowserModificationDateColumn.class.st index 597bfad58..4da36fe24 100644 --- a/src/NewTools-FileBrowser/StFileBrowserModificationDateColumn.class.st +++ b/src/NewTools-FileBrowser/StFileBrowserModificationDateColumn.class.st @@ -3,26 +3,18 @@ I'm a column use to display the modification date of a file in a File dialog. " Class { #name : 'StFileBrowserModificationDateColumn', - #superclass : 'StFileBrowserAbstractColumn', + #superclass : 'StFileBrowserDateColumn', #category : 'NewTools-FileBrowser-Columns', #package : 'NewTools-FileBrowser', #tag : 'Columns' } -{ #category : 'adding' } -StFileBrowserModificationDateColumn class >> addConstraintTo: aTableColumn [ - - aTableColumn - width: 150; - beSortable -] - { #category : 'templateMethod' } StFileBrowserModificationDateColumn class >> evaluateOn: aFileReference [ - ^ [ aFileReference modificationTime fileDialogFormat ] + ^ [ aFileReference modificationTime ] on: Error - do: [ 'N/A' ] + do: [ nil ] ] { #category : 'sorting' } diff --git a/src/NewTools-FileBrowser/StFileBrowserSizeColumn.class.st b/src/NewTools-FileBrowser/StFileBrowserSizeColumn.class.st index aa8f2915b..1a1bcc714 100644 --- a/src/NewTools-FileBrowser/StFileBrowserSizeColumn.class.st +++ b/src/NewTools-FileBrowser/StFileBrowserSizeColumn.class.st @@ -13,6 +13,7 @@ Class { StFileBrowserSizeColumn class >> addConstraintTo: aTableColumn [ aTableColumn + formatted: [ :e | self formatOn: e ]; width: 70; beSortable ] @@ -21,11 +22,20 @@ StFileBrowserSizeColumn class >> addConstraintTo: aTableColumn [ StFileBrowserSizeColumn class >> evaluateOn: aFileReference [ ^ aFileReference isDirectory - ifTrue: [ '--' ] + ifTrue: [ 0 ] ifFalse: [ - [ aFileReference humanReadableSize ] + [ aFileReference size ] on: Error - do: [ 'N/A' ] ] + do: [ 0 ] ] +] + +{ #category : 'templateMethod' } +StFileBrowserSizeColumn class >> formatOn: aSize [ + + ^ aSize ifNil: [ 'N/A' ] ifNotNil: [ + [ aSize humanReadableSISizeString ] + on: Error + do: [ 'N/A' ] ] ] { #category : 'sorting' } diff --git a/src/NewTools-Inspector-Extensions/AbstractFileReference.extension.st b/src/NewTools-Inspector-Extensions/AbstractFileReference.extension.st index c4237bb49..3da36ffaf 100644 --- a/src/NewTools-Inspector-Extensions/AbstractFileReference.extension.st +++ b/src/NewTools-Inspector-Extensions/AbstractFileReference.extension.st @@ -2,40 +2,46 @@ Extension { #name : 'AbstractFileReference' } { #category : '*NewTools-Inspector-Extensions' } AbstractFileReference >> inspectionCompressedItems [ + | items children root | - root := (FileSystem zip: self) open workingDirectory. - children := root directories, root files. - items := self isRoot - ifTrue: [ children ] - ifFalse: [ - children asOrderedCollection - addFirst: self parent; - yourself ]. + children := root directories , root files. + items := self isRoot + ifTrue: [ children ] + ifFalse: [ + children asOrderedCollection + addFirst: self parent; + yourself ]. ^ SpTablePresenter new - items: items; - addColumn: (SpCompositeTableColumn new - title: 'Name'; - addColumn: (SpImageTableColumn evaluated: [ :each | - self iconNamed: (each isDirectory - ifTrue: [ #folder ] - ifFalse: [ #browse ]) ]); - addColumn: (SpStringTableColumn evaluated: [ :each | - self parent = each - ifTrue: [ '..' ] - ifFalse: [ each basename ] ])); - addColumn: (SpStringTableColumn - title: 'Size' - evaluated: [ :each | each humanReadableSize ]); - addColumn: (SpStringTableColumn - title: 'Creation' - evaluated: [ :each | - String streamContents: [ :stream | - each creationTime printYMDOn: stream. - stream nextPut: Character space. - each creationTime printHMSOn: stream ] ]) + items: items; + addColumn: (SpCompositeTableColumn new + title: 'Name'; + addColumn: (SpImageTableColumn evaluated: [ :each | + self iconNamed: (each isDirectory + ifTrue: [ #folder ] + ifFalse: [ #browse ]) ]); + addColumn: (SpStringTableColumn evaluated: [ :each | + self parent = each + ifTrue: [ '..' ] + ifFalse: [ each basename ] ])); + addColumn: (SpStringTableColumn new + title: 'Size'; + evaluated: [ :each | each size ]; + formatted: [ :size | size humanReadableSISizeString ]); + addColumn: (SpStringTableColumn new + title: 'Creation'; + evaluated: [ :each | each creationTime ]; + formatted: [ :time | + [ + String streamContents: [ :s | + time printYMDOn: s. + s nextPut: Character space. + time printHMSOn: s ] ] + on: Error + do: [ 'N/A' translated ] ]; + beSortable) ] { #category : '*NewTools-Inspector-Extensions' } @@ -103,46 +109,46 @@ AbstractFileReference >> inspectionGifContext: aContext [ { #category : '*NewTools-Inspector-Extensions' } AbstractFileReference >> inspectionItems [ + | items | - - items := self directories, self files. - self isRoot ifFalse: [ - items := items copyWithFirst: self parent ]. - - ^ SpTablePresenter new - beResizable; - items: items; - addColumn: (SpCompositeTableColumn new - title: 'Name'; - width: 300; - addColumn: (SpImageTableColumn evaluated: [ :each | - each isDirectory - ifTrue: [ self iconNamed: #folder ] - ifFalse: [ self iconNamed: #browse ] ]) - beNotExpandable; - addColumn: (SpStringTableColumn evaluated: [ :each | - (self isChildOf: each) - ifTrue: [ '..' ] - ifFalse: [ each basename ] ]); - yourself); - addColumn: (SpStringTableColumn new - title: 'Size'; - width: 100; - evaluated: [ :each | - [ each humanReadableSize ] - on: Error - do: [ 'N/A' translated ] ]); - addColumn: (SpStringTableColumn - title: 'Creation' - evaluated: [ :each | - [ String streamContents: [ :s | - each creationTime printYMDOn: s. - s nextPut: Character space. - each creationTime printHMSOn: s ] ] - on: Error - do: [ 'N/A' translated ] ]); - yourself + items := self directories , self files. + self isRoot ifFalse: [ items := items copyWithFirst: self parent ]. + + ^ SpTablePresenter new + beResizable; + items: items; + addColumn: (SpCompositeTableColumn new + title: 'Name'; + width: 300; + addColumn: (SpImageTableColumn evaluated: [ :each | + each isDirectory + ifTrue: [ self iconNamed: #folder ] + ifFalse: [ self iconNamed: #browse ] ]) beNotExpandable; + addColumn: (SpStringTableColumn evaluated: [ :each | + (self isChildOf: each) + ifTrue: [ '..' ] + ifFalse: [ each basename ] ]); + yourself); + addColumn: (SpStringTableColumn new + title: 'Size'; + width: 100; + evaluated: [ :each | each size ]; + formatted: [ :size | size humanReadableSISizeString ]; + beSortable); + addColumn: (SpStringTableColumn new + title: 'Creation'; + evaluated: [ :each | each creationTime ]; + formatted: [ :time | + [ + String streamContents: [ :s | + time printYMDOn: s. + s nextPut: Character space. + time printHMSOn: s ] ] + on: Error + do: [ 'N/A' translated ] ]; + beSortable); + yourself ] { #category : '*NewTools-Inspector-Extensions' } diff --git a/src/NewTools-Inspector-Extensions/Bag.extension.st b/src/NewTools-Inspector-Extensions/Bag.extension.st index 090f855be..7d9db1a97 100644 --- a/src/NewTools-Inspector-Extensions/Bag.extension.st +++ b/src/NewTools-Inspector-Extensions/Bag.extension.st @@ -10,16 +10,15 @@ Bag >> inspectionItems: aBuilder [ ^ aBuilder newTable addColumn: (SpStringTableColumn new title: 'Items'; - evaluated: [ :each | - StObjectPrinter asTruncatedTextFrom: each key ]; + evaluated: [ :each | each key ]; + formatted: [ :each | StObjectPrinter asTruncatedTextFrom: each ]; beNotExpandable; beSortable; yourself); addColumn: (SpStringTableColumn new title: 'Occurences'; - evaluated: [ :each | - StObjectPrinter asTruncatedTextFrom: - (self occurrencesOf: each key) ]; + evaluated: [ :each | self occurrencesOf: each key ]; + formatted: [ :each | StObjectPrinter asTruncatedTextFrom: each ]; beSortable; yourself); items: (contents associations sort: sortFuction); diff --git a/src/NewTools-Inspector-Extensions/Dictionary.extension.st b/src/NewTools-Inspector-Extensions/Dictionary.extension.st index f1513b75e..b833d4b8a 100644 --- a/src/NewTools-Inspector-Extensions/Dictionary.extension.st +++ b/src/NewTools-Inspector-Extensions/Dictionary.extension.st @@ -2,17 +2,21 @@ Extension { #name : 'Dictionary' } { #category : '*NewTools-Inspector-Extensions' } Dictionary >> inspectionItems: aBuilder [ - - - ^ aBuilder newTable - addColumn: (SpStringTableColumn - title: 'Key' - evaluated: [ :each | StObjectPrinter asTruncatedTextFrom: each key ]) - beSortable; - addColumn: (SpStringTableColumn - title: 'Value' - evaluated: [ :each | StObjectPrinter asTruncatedTextFrom: each value ]) - beSortable; - items: (self associations collect: [:e | StInspectorAssociationNode hostObject: e ]); - yourself + + + ^ aBuilder newTable + addColumn: (SpStringTableColumn new + title: 'Key'; + evaluated: [ :each | each key ]; + formatted: [ :key | StObjectPrinter asTruncatedTextFrom: key ]; + beSortable); + addColumn: (SpStringTableColumn new + title: 'Value'; + evaluated: [ :each | each value ]; + formatted: [ :value | + StObjectPrinter asTruncatedTextFrom: value ]; + beSortable); + items: (self associations collect: [ :e | + StInspectorAssociationNode hostObject: e ]); + yourself ] diff --git a/src/NewTools-Inspector-Extensions/OrderedDictionary.extension.st b/src/NewTools-Inspector-Extensions/OrderedDictionary.extension.st index 644ed0744..3c5659f3a 100644 --- a/src/NewTools-Inspector-Extensions/OrderedDictionary.extension.st +++ b/src/NewTools-Inspector-Extensions/OrderedDictionary.extension.st @@ -2,17 +2,21 @@ Extension { #name : 'OrderedDictionary' } { #category : '*NewTools-Inspector-Extensions' } OrderedDictionary >> inspectionItems: aBuilder [ - - - ^ aBuilder newTable - addColumn: (SpStringTableColumn - title: 'Key' - evaluated: [ :each | StObjectPrinter asTruncatedTextFrom: each key ]) - beSortable; - addColumn: (SpStringTableColumn - title: 'Value' - evaluated: [ :each | StObjectPrinter asTruncatedTextFrom: each value ]) - beSortable; - items: (self associations collect: [:e | StInspectorAssociationNode hostObject: e ]); - yourself + + + ^ aBuilder newTable + addColumn: (SpStringTableColumn new + title: 'Key'; + evaluated: [ :each | each key ]; + formatted: [ :key | StObjectPrinter asTruncatedTextFrom: key ]; + beSortable); + addColumn: (SpStringTableColumn new + title: 'Value'; + evaluated: [ :each | each value ]; + formatted: [ :value | + StObjectPrinter asTruncatedTextFrom: value ]; + beSortable); + items: (self associations collect: [ :e | + StInspectorAssociationNode hostObject: e ]); + yourself ] diff --git a/src/NewTools-Inspector-Extensions/SmallDictionary.extension.st b/src/NewTools-Inspector-Extensions/SmallDictionary.extension.st index 80f59febc..473160993 100644 --- a/src/NewTools-Inspector-Extensions/SmallDictionary.extension.st +++ b/src/NewTools-Inspector-Extensions/SmallDictionary.extension.st @@ -2,17 +2,21 @@ Extension { #name : 'SmallDictionary' } { #category : '*NewTools-Inspector-Extensions' } SmallDictionary >> inspectionItems: aBuilder [ - - - ^ aBuilder newTable - addColumn: (SpStringTableColumn - title: 'Key' - evaluated: [ :each | StObjectPrinter asTruncatedTextFrom: each key ]) - beSortable; - addColumn: (SpStringTableColumn - title: 'Value' - evaluated: [ :each | StObjectPrinter asTruncatedTextFrom: each value ]) - beSortable; - items: (self associations collect: [:e | StInspectorAssociationNode hostObject: e ]); - yourself + + + ^ aBuilder newTable + addColumn: (SpStringTableColumn new + title: 'Key'; + evaluated: [ :each | each key ]; + formatted: [ :key | StObjectPrinter asTruncatedTextFrom: key ]; + beSortable); + addColumn: (SpStringTableColumn new + title: 'Value'; + evaluated: [ :each | each value ]; + formatted: [ :value | + StObjectPrinter asTruncatedTextFrom: value ]; + beSortable); + items: (self associations collect: [ :e | + StInspectorAssociationNode hostObject: e ]); + yourself ]