Migrating functionality from Grafoscopio to implement ad-hoc timestamps.
This commit is contained in:
parent
429e04bef7
commit
a5a01e7ca6
@ -17,11 +17,26 @@ Class {
|
|||||||
#category : #MiniDocs
|
#category : #MiniDocs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GrafoscopioNode >> ancestors [
|
||||||
|
"I return a collection of all the nodes wich are ancestors of the receiver node"
|
||||||
|
| currentNode ancestors |
|
||||||
|
|
||||||
|
currentNode := self.
|
||||||
|
ancestors := OrderedCollection new.
|
||||||
|
[ currentNode parent notNil and: [ currentNode level > 0 ] ]
|
||||||
|
whileTrue: [
|
||||||
|
ancestors add: currentNode parent.
|
||||||
|
currentNode := currentNode parent].
|
||||||
|
ancestors := ancestors reversed.
|
||||||
|
^ ancestors
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
GrafoscopioNode >> asLePage [
|
GrafoscopioNode >> asLePage [
|
||||||
| page |
|
| page |
|
||||||
page := LePage new
|
page := LePage new
|
||||||
title: 'Grafoscopio Notebook (imported)'.
|
initializeTitle: 'Grafoscopio Notebook (imported)'.
|
||||||
self nodesInPreorder allButFirst do: [:node |
|
self nodesInPreorder allButFirst do: [:node |
|
||||||
page addSnippet: node asSnippet .
|
page addSnippet: node asSnippet .
|
||||||
].
|
].
|
||||||
@ -119,6 +134,16 @@ GrafoscopioNode >> header: anObject [
|
|||||||
header := anObject
|
header := anObject
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GrafoscopioNode >> latestEditionDate [
|
||||||
|
| latest |
|
||||||
|
|
||||||
|
latest := self nodesWithEditionDates first edited.
|
||||||
|
self nodesWithEditionDates do: [:node |
|
||||||
|
node edited >= latest ifTrue: [ latest := node edited ] ].
|
||||||
|
^ latest
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
GrafoscopioNode >> level [
|
GrafoscopioNode >> level [
|
||||||
^ level
|
^ level
|
||||||
@ -171,12 +196,31 @@ GrafoscopioNode >> parent: anObject [
|
|||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
GrafoscopioNode >> populateTimestamps [
|
GrafoscopioNode >> populateTimestamps [
|
||||||
|
| adhocCreationMarker adhocEditionMarker |
|
||||||
|
adhocCreationMarker := 'adhoc creation timestamp'.
|
||||||
|
adhocEditionMarker := 'adhoc edition timestamp'.
|
||||||
(self nodesInPreorder size = self nodesWithCreationDates size
|
(self nodesInPreorder size = self nodesWithCreationDates size
|
||||||
and: [ self nodesInPreorder size = self nodesWithEditionDates size ])
|
and: [ self nodesInPreorder size = self nodesWithEditionDates size ])
|
||||||
ifTrue: [ ^ self nodesInPreorder ].
|
ifTrue: [ ^ self nodesInPreorder ].
|
||||||
^ { self nodesWithCreationDates.
|
self nodesInPreorder allButFirst doWithIndex: [:node :i |
|
||||||
self nodesWithEditionDates}
|
node created ifNil: [
|
||||||
|
node created: self earliestCreationDate + i.
|
||||||
|
node tags add: adhocCreationMarker.
|
||||||
|
].
|
||||||
|
node edited ifNil: [
|
||||||
|
node edited: self earliestCreationDate + i + 1.
|
||||||
|
node tags add: 'adhoc edition timestamp'
|
||||||
|
].
|
||||||
|
].
|
||||||
|
self root created ifNil: [
|
||||||
|
self root created: self earliestCreationDate - 1.
|
||||||
|
self root tags add: adhocCreationMarker.
|
||||||
|
].
|
||||||
|
self root edited ifNil: [
|
||||||
|
self root edited: self latestEditionDate.
|
||||||
|
self root tags add: adhocEditionMarker.
|
||||||
|
].
|
||||||
|
^ self nodesInPreorder
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
@ -186,6 +230,12 @@ GrafoscopioNode >> printOn: aStream [
|
|||||||
nextPutAll: '( ', self header, ' )'
|
nextPutAll: '( ', self header, ' )'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
GrafoscopioNode >> root [
|
||||||
|
self level = 0 ifTrue: [ ^ self ].
|
||||||
|
^ self ancestors first.
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
GrafoscopioNode >> selected [
|
GrafoscopioNode >> selected [
|
||||||
^ selected
|
^ selected
|
||||||
|
Loading…
Reference in New Issue
Block a user