From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:49:19 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>RandomWatcher</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none generator <imports></imports> <category>Examples-Help</category> <attributes> <package>RandomWatcher-Example</package> </attributes> </class> <comment> Examples.RandomWatcher
A GUI designed to monitor the state of an independent process, a domain model that updates itself. Instance Variables: currentValue <Object> the current display value generator <RunawayRandoms> the random number generator being monitored
</comment> <class> <name>RunawayRandoms</name> <environment>Examples</environment> <super>Core.Object</super> <private>false</private> none generator current running delay <imports></imports> <category>AdaptorExplorations</category> <attributes> <package>RandomWatcher-Example</package> </attributes> </class> <comment> Examples.RunawayRandoms
RunawayRandoms simply starts a random number generator and generates the next one each second. This is used with RandomWatcher to illustrated updating a GUI from a domain model that updates itself. Intended to simulate a display monitor on any independent process. Instance Variables: current <Object> current random value delay <Delay> the length between generating new randoms generator <Stream> the random number generator running <Boolean> state: running or not
</comment> <methods> Examples.RandomWatcher <category>aspects</category>
currentValue | adaptor | adaptor := AspectAdaptor subject: generator. adaptor forAspect: #current. "update using change mechanism" adaptor subjectSendsUpdates: true. "update using trigger-event mechanism" "generator when: #currentChanged do: [ :arg | adaptor update: #current with: arg from: generator ]." ^adaptor
</methods> <methods> Examples.RandomWatcher <category>actions</category>
start generator start
stop generator stop
</methods> <methods> Examples.RandomWatcher <category>private</category>
update: arg arg inspect. " self currentValue valueUsingTarget: generator"
</methods> <methods> Examples.RandomWatcher <category>initialize-release</category>
initialize | collection | collection := RunawayRandoms allInstances. generator := collection isEmpty ifTrue: [ RunawayRandoms new start ] ifFalse: [ collection first ]
</methods> <methods> Examples.RunawayRandoms <category>accessing</category>
current ^current
</methods> <methods> Examples.RunawayRandoms <category>initialize-release</category>
initialize generator := Random new. running := false. delay := Delay forSeconds: 1
</methods> <methods> Examples.RunawayRandoms <category>updating</category>
next "Get next random and notify of update" current := generator next. "change/update version" self changed: #current. "event version" "self triggerEvent: #currentChanged with: current."
</methods> <methods> Examples.RunawayRandoms <category>private - running</category>
start running := true. [ [ running = true ] whileTrue: [ delay wait. self next ] ] fork
stop running := false
</methods> <methods> Examples.RunawayRandoms class <category>instance creation</category>
new ^super new initialize
</methods> <methods> Examples.RandomWatcher class <category>interface specs</category>
windowSpec "Tools.UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: 'Random Watcher' #bounds: #(#{Graphics.Rectangle} 512 384 712 584 ) ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.LabelSpec} #layout: #(#{Core.Point} 20 10 ) #name: #Label1 #label: 'Current Random Value' ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.Rectangle} 16 127 97 150 ) #name: #ActionButton1 #model: #start #label: 'Start' #defaultable: true ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.Rectangle} 106 127 187 150 ) #name: #ActionButton2 #model: #stop #label: 'Stop' #defaultable: true ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 19 39 180 64 ) #name: #InputField1 #model: #currentValue #alignment: #right #isReadOnly: true #type: #number ) ) ) )
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>Object</name> <environment>Core</environment> <super></super> <private>false</private> none <imports></imports> <category>Kernel-Objects</category> <attributes> <package>Kernel-Objects</package> </attributes> </class> <class> <name>ApplicationModel</name> <environment>UI</environment> <super>UI.Model</super> <private>false</private> none builder uiSession eventHandlers savedWindowInformation <imports></imports> <category>UIBuilder-Framework</category> <attributes> <package>UIBuilder-Framework</package> </attributes> </class>