moose-technology(a)googlecode.com wrote:
Updates:
Labels: Component-Roassal
Comment #3 on issue 894 by alexandr...(a)gmail.com: Roassal revised
ROSelection and example
http://code.google.com/p/moose-technology/issues/detail?id=894
Ben, there is some 'as yet unclassified' category. Can you provide
some proper category.
I have not been confident in my familiarity with choosing
categories -
so I ignored it :(
Though I suppose giving it a go and being corrected is the best way to
learn.
ROSelection methods have been classified in attached fileout. Please
advise if any of them seem out of order.
Tests are also very welcome
I'd love to be a better citizen and provide some tests to avoid looking
like a hack, but right now I am at the pointy end of writing my
dissertation. At least after that I do want to revisit all my
contributions and tidy them up with tests and documentation. I will get
there.
'From Pharo1.4 of 18 April 2012 [Latest update: #14457] on 12 December 2012 at 8:54:56
pm'!
ROInteraction subclass: #ROSelection
instanceVariableNames: 'filter inclusionAction exclusionAction selectedElements'
classVariableNames: ''
poolDictionaries: ''
category: 'Roassal-Interaction'!
!ROSelection methodsFor: 'comparing' stamp: 'BenComan 10/15/2012 22:23'!
contains: aROElement
selectedElements do: [ :element | (element = aROElement) ifTrue: [ ^true] ].
^false.! !
!ROSelection methodsFor: 'events-registering' stamp: 'BenComan 10/15/2012
22:05'!
for: aBlock
filter := aBlock.
! !
!ROSelection methodsFor: 'events-registering' stamp: 'BenComan 10/15/2012
22:09'!
onExclusion: aBlock
exclusionAction := aBlock.
! !
!ROSelection methodsFor: 'events-registering' stamp: 'BenComan 10/15/2012
22:09'!
onInclusion: aBlock
inclusionAction := aBlock.
! !
!ROSelection methodsFor: 'initialize-release' stamp: 'BenComan 10/15/2012
22:12'!
initialize
super initialize.
filter := [ :source :target | false ].
selectedElements := OrderedCollection new.
! !
!ROSelection methodsFor: 'printing' stamp: 'BenComan 12/9/2012 11:38'!
printOn: aStream
super printOn: aStream.
aStream nextPutAll: '[' .
selectedElements do:
[ :el |
aStream nextPutAll: el model asString.
aStream nextPutAll: ' '.
].
aStream nextPutAll: ']' .
! !
!ROSelection methodsFor: 'events-triggering' stamp: 'BenComan 12/9/2012
13:19'!
add: targetElement
targetElement ifNotNil:
[
selectedElements add: targetElement .
inclusionAction ifNotNil: [ inclusionAction value: targetElement ].
].
! !
!ROSelection methodsFor: 'events-triggering' stamp: 'BenComan 10/15/2012
22:08'!
clear
exclusionAction ifNotNil: [ selectedElements do: [ :element | exclusionAction value:
element ] ].
selectedElements := OrderedCollection new.
! !
!ROSelection methodsFor: 'events-triggering' stamp: 'BenComan 12/9/2012
12:05'!
source: sourceElement target: targetElement
(filter value: sourceElement value: targetElement) ifTrue:
[
self add: targetElement.
]! !