84 lines
2.9 KiB
Smalltalk
84 lines
2.9 KiB
Smalltalk
Extension { #name : #OrderedDictionary }
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
OrderedDictionary >> addErrata: noteString [
|
|
self errata add: noteString
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
OrderedDictionary >> asLepiterSnippet [
|
|
| response |
|
|
self at: 'className' ifAbsent: [ ^ nil ].
|
|
response := (self at: 'className') asClass new.
|
|
response fromString: (self at: 'content').
|
|
response
|
|
uid: (LeUID new uidString: (self at: 'id'));
|
|
parent: (self at: 'parent');
|
|
createTime: (LeTime new time: ((self at: 'created')asDateAndTime));
|
|
editTime: (LeTime new time: ((self at: 'modified') asDateAndTime));
|
|
editEmail: (self at: 'modifier');
|
|
createEmail: (self at: 'creator').
|
|
self at: 'origin' ifPresent: [ response metadata at: 'origin' put: (self at: 'origin') ].
|
|
self at: 'errata' ifPresent: [ response metadata at: 'errata' put: (self at: 'errata') ].
|
|
^ response
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
OrderedDictionary >> errata [
|
|
^ self at: 'errata' ifAbsentPut: [ OrderedCollection new]
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
OrderedDictionary >> redefineTimestampsBefore: dateAndTime [
|
|
self at: 'modified' put: dateAndTime asDateAndTime.
|
|
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: [ self at: assoc key put: (assoc value replaceWithUniqueNilsAndBooleans)]
|
|
]
|
|
]
|
|
|
|
{ #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: 10)) ];
|
|
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
|
|
]
|