Skip to content

Commit

Permalink
Extracts inactive watches to their own class
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Oct 12, 2023
1 parent f79853e commit d791ba8
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ SBExampleValueDisplay >> exampleFinished: anExample [
display exampleFinished: anExample.

statusLabel
contents: (hadValue ifTrue: [''] ifFalse: ['- Not reached -']);
contents: (hadValue
ifTrue: ['']
ifFalse: ['- Not reached -']);
visible: hadValue not
]

Expand Down
31 changes: 4 additions & 27 deletions packages/Sandblocks-Babylonian/SBExampleWatch.class.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"
Observes (watches) an expression locally for added SBExamples. Whenever an example has finished running, it updates its belonging view. Only active watches update their views. Further, with a given modifyExpression, it transforms the watched expression values. Also known as a Probe in the context of Babylonian Smalltalk.
Observes (watches) an expression locally for added SBExamples. Whenever an example has finished running, it updates its belonging view. Further, with a given modifyExpression, it transforms the watched expression values. Also known as a Probe in the context of Babylonian Smalltalk.
"
Class {
#name : #SBExampleWatch,
Expand All @@ -8,7 +8,6 @@ Class {
'identifier',
'watchedExpression',
'modifyExpression',
'isActive',
'exampleToDisplay',
'exampleToValues'
],
Expand Down Expand Up @@ -112,31 +111,10 @@ SBExampleWatch >> applyModifyExpressionOnValues [
anExampleDisplayPair value updateDisplay]
]

{ #category : #callbacks }
SBExampleWatch >> artefactSaved: aBlock [

"As we are inactive, we have to manually apply our modifyExpression if it changes.
Otherwise, we would reset by examples starting"
(self isActive not and: [aBlock = self containingArtefact]) ifTrue: [self applyModifyExpressionOnValues]
]

{ #category : #copying }
SBExampleWatch >> asInactiveCopy [

| copy |
copy := self veryDeepCopy beInactive.

"Resolve bindings"
copy expression: (SBTextBubble new contents: copy expression sourceString).
copy setWatchedExpressionUneditable.

^ copy
]

{ #category : #accessing }
SBExampleWatch >> beInactive [

isActive := false
^ SBInactiveExampleWatch newFromWatch: self
]

{ #category : #'colors and color policies' }
Expand Down Expand Up @@ -253,7 +231,6 @@ SBExampleWatch >> initialize [
exampleToValues := Dictionary new.
watchedExpression := SBStMessageSend new.
modifyExpression := SBStBlockBody identityNamed: 'result'.
isActive := true.

self
cellGap: 4;
Expand All @@ -275,7 +252,7 @@ SBExampleWatch >> intoWorld: aWorld [
{ #category : #accessing }
SBExampleWatch >> isActive [

^ isActive
^ true
]

{ #category : #'*Sandblocks-Babylonian' }
Expand Down Expand Up @@ -314,7 +291,7 @@ SBExampleWatch >> layoutCommands [
{ #category : #'*Sandblocks-Babylonian' }
SBExampleWatch >> listensToExamples [

^ self isActive
^ true
]

{ #category : #accessing }
Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBExampleWatch.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ SBExampleWatch >> isGlobalWatch [
{ #category : #'*Sandblocks-Babylonian' }
SBExampleWatch >> listensToExamples [

^ self isActive
^ true
]
50 changes: 50 additions & 0 deletions packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"
Does not update its results anymore. Applying modification expressions is still possible.
"
Class {
#name : #SBInactiveExampleWatch,
#superclass : #SBExampleWatch,
#category : #'Sandblocks-Babylonian'
}

{ #category : #'initialize-release' }
SBInactiveExampleWatch class >> newFromWatch: anActiveWatch [

^ (anActiveWatch veryDeepCopy)
primitiveChangeClassTo: self basicNew;
expression: (SBTextBubble new contents: anActiveWatch expression sourceString);
yourself
]

{ #category : #callbacks }
SBInactiveExampleWatch >> artefactSaved: aBlock [

"As we are inactive, we have to manually apply our modifyExpression if it changes.
Otherwise, we would reset by examples starting"
(aBlock = self containingArtefact) ifTrue: [self applyModifyExpressionOnValues]
]

{ #category : #'event handling' }
SBInactiveExampleWatch >> doubleClick: evt [

"Nothing"
]

{ #category : #'as yet unclassified' }
SBInactiveExampleWatch >> expression: aBlock [

super expression: aBlock.
watchedExpression selectable: false
]

{ #category : #accessing }
SBInactiveExampleWatch >> isActive [

^ false
]

{ #category : #'*Sandblocks-Babylonian' }
SBInactiveExampleWatch >> listensToExamples [

^ false
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #SBInactiveExampleWatch }

{ #category : #'*Sandblocks-Babylonian' }
SBInactiveExampleWatch >> listensToExamples [

^ false
]

0 comments on commit d791ba8

Please sign in to comment.