From VisualWorks® NonCommercial, 7.6 of lundi 3 mars 2008 on mercredi 6 août 2008 at 14:38:44
CormasNS.Kernel.CormasModel mouse behavior - spatial grid
performCtrlRedButton: aSite
"Ctrl Red Button (Ctrl Left Button) open a dialog box to add in a cell
an instance of one of your classes inheriting from AgentLocation (social entity) or ObjectLocation (passive entity).
This method must refine the method of your model, in the mouse behavior category
Author : Jean-Max Estay Jean-Max.Estay@uco.fr"
| locatedEntityClass classes |
classes := OrderedCollection new.
self class environment asOrderedCollection do:[:c| (#(AgentLocation AgentCommLocation GroupLocation GroupCommLocation ObjectLocation) refersToLiteral:(c superclass name))
ifTrue:[classes add: c. classes addAll: c subclasses. (c subclasses collect:[:sc| sc subclasses]) do:[:ssc| classes addAll: ssc]]].
locatedEntityClass := Dialog
choose: 'Which located entity do you want to add?'
fromList: classes
values: classes
buttons: #()
values: #(nil)
lines: 8 "max lines"
cancel: [#noChoice].
locatedEntityClass = #noChoice
ifFalse:
[| new |
new := self newEntity: locatedEntityClass.
(aSite theOccupants at: locatedEntityClass name) add: new.
new defineVisualState.
new patch: aSite.
new patch show]