so far ...
Object subclass:#Transaction
instanceVariableNames:'type text actions'
classVariableNames:''
poolDictionaries:''
privateIn:UIObjectView::UndoHistory
!
!UIObjectView::UndoHistory::Transaction class methodsFor:'instance creation'!
type:aType text:aTextOrNil
^ self new type:aType text:aTextOrNil
! !
!UIObjectView::UndoHistory::Transaction methodsFor:'accessing'!
asString
"returns printable string
"
|string|
string := type asString.
text notNil ifTrue:[^ string, ' ', text ]
ifFalse:[^ string ]
!
text
"returns text or nil assigned to transition
"
^ text
!
type
"returns type assigned to transition
"
^ type
!
type:aType
"change type assigned to transition
"
type := aType
! !
!UIObjectView::UndoHistory::Transaction methodsFor:'add & undo'!
add:anUndoBlock
"add an undo action to the transition
"
actions isNil ifTrue:[
actions := anUndoBlock
] ifFalse:[
actions isCollection ifFalse:[
|temp|
temp := OrderedCollection new.
temp add:actions.
actions := temp.
].
actions add:anUndoBlock.
]
!
undo
"undo transition
"
actions notNil ifTrue:[
actions isCollection ifFalse:[
actions value
] ifTrue:[
actions reverseDo:[:anUndoBlock| anUndoBlock value ]
]
]
! !
!UIObjectView::UndoHistory::Transaction methodsFor:'initialization'!
type:aType text:aTextOrNil
"initialize transition
"
type := aType.
text := aTextOrNil.
! !
!UIObjectView::UndoHistory::Transaction methodsFor:'testing'!
isEmpty
"returns true if no undo action is registered
"
^ actions isNil
!
notEmpty
"returns true if any undo action is registered
"
^ actions notNil
! !