Utilities for visualizing dictionaries.
This commit is contained in:
parent
da459b9d26
commit
28a3d22911
@ -33,3 +33,64 @@ OrderedDictionary >> redefineTimestampsBefore: dateAndTime [
|
|||||||
self at: 'modified' put: dateAndTime asDateAndTime.
|
self at: 'modified' put: dateAndTime asDateAndTime.
|
||||||
self at: 'created' put: dateAndTime asDateAndTime - 1 second.
|
self at: 'created' put: dateAndTime asDateAndTime - 1 second.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'*MiniDocs' }
|
||||||
|
OrderedDictionary >> replaceNilsWith: aCharacter [
|
||||||
|
self associationsDo: [:each |
|
||||||
|
each value ifNil: [self at: each key put: aCharacter].
|
||||||
|
each value isDictionary ifTrue: [each value replaceNilsWith: aCharacter].
|
||||||
|
each value isArray ifTrue: [ | newArray|
|
||||||
|
newArray := (each value asDataSeries replaceNilsWith: aCharacter) asArray.
|
||||||
|
self at: each key put: newArray
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #'*MiniDocs' }
|
||||||
|
OrderedDictionary >> replaceWithUniqueNilsAndBooleansStartingAt: anInteger [
|
||||||
|
| totalNils shortUID |
|
||||||
|
totalNils := self flattened asDataSeries countNils.
|
||||||
|
shortUID := [NanoID generate copyFrom: 1 to: 3].
|
||||||
|
self associations doWithIndex: [:assoc :i | | subIndex |
|
||||||
|
subIndex := anInteger asString, '-', i asString.
|
||||||
|
assoc value
|
||||||
|
ifNil: [ self at: assoc key put: 'nil-', subIndex ].
|
||||||
|
assoc value isBoolean
|
||||||
|
ifTrue: [ self at: assoc key put: assoc value asString, '-', subIndex ].
|
||||||
|
assoc value isDictionary ifTrue: [assoc replaceWithUniqueNilsAndBooleansStartingAt: i].
|
||||||
|
assoc value isArray ifTrue: [ | newArray|
|
||||||
|
newArray := (assoc value asDataSeries replaceNilsWith: 'nil-', shortUID value) asArray.
|
||||||
|
(newArray includesAny: #(true false))
|
||||||
|
ifTrue: [ | response newItem |
|
||||||
|
response := OrderedCollection new.
|
||||||
|
self do: [ :item |
|
||||||
|
item isBoolean
|
||||||
|
ifTrue: [ newItem := item asString, '-', shortUID value]
|
||||||
|
ifFalse: [ newItem := item ].
|
||||||
|
response add: newItem.
|
||||||
|
].
|
||||||
|
newArray := response asArray.
|
||||||
|
].
|
||||||
|
self at: assoc key put: newArray
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #'*MiniDocs' }
|
||||||
|
OrderedDictionary >> treeView [
|
||||||
|
| view |
|
||||||
|
view := GtMondrian new.
|
||||||
|
view nodes
|
||||||
|
stencil: [ :x |
|
||||||
|
BlElement new
|
||||||
|
border: (BlBorder paint: Color black);
|
||||||
|
geometry: BlEllipseGeometry new;
|
||||||
|
layout: (BlLinearLayout new alignCenter);
|
||||||
|
addChild: (BlTextElement text: (x asRopedText fontSize: 17)) ];
|
||||||
|
with: (self flatCollectAsSet: #yourself) , self keys.
|
||||||
|
view edges
|
||||||
|
stencil: [ :x | BlLineElement new border: (BlBorder paint: (Color blue alpha: 0.5) width: 4) ];
|
||||||
|
connect: self associations from: #key toAll: #value.
|
||||||
|
view layout tree.
|
||||||
|
^ view
|
||||||
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user