Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Oct 3, 2024
1 parent c3b5c40 commit 25460e5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 34 deletions.
71 changes: 43 additions & 28 deletions repository/OpenPonk-FSM/OPFsmSimulator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -294,36 +294,51 @@ OPFsmSimulator >> stopButton [
{ #category : 'events' }
OPFsmSimulator >> watchRecognizer: aRecognizer [

aRecognizer when: OPFsmRecognizerEvent do: [ :ann |
aRecognizer isInputEmpty ifFalse: [
nextButton enable.
runButton enable ].
aRecognizer isPathEmpty ifFalse: [ backButton enable ].
(ann isKindOf: OPFsmRecognizerFailure) not & ann place isState
ifTrue: [
aRecognizer
when: OPFsmRecognizerEvent
do: [ :ann |
aRecognizer isInputEmpty ifFalse: [
nextButton enable.
runButton enable ].
aRecognizer isPathEmpty ifFalse: [ backButton enable ].
(ann isKindOf: OPFsmRecognizerFailure) not & ann place isState
ifTrue: [
self letterPanel
changeBoxAt: aRecognizer inputPosition - 1
to: #success ].
ann place isTransition ifTrue: [
self letterPanel
changeBoxAt: aRecognizer inputPosition - 1
to: #success ].
ann place isTransition ifTrue: [
to: #processed ] ]
for: self.
aRecognizer
when: OPFsmRecognizerSuccess
do: [ :ann |
OPFsmFigureHighlighter
highlightNode: (diagramController roassalShapeForModel: ann place)
with: Color green ]
for: self.
aRecognizer
when: OPFsmRecognizerFailure
do: [ :ann |
OPFsmFigureHighlighter
highlightNode: (diagramController roassalShapeForModel: ann place)
with: Color red.
self letterPanel
changeBoxAt: aRecognizer inputPosition - 1
to: #processed ] ].
aRecognizer when: OPFsmRecognizerSuccess do: [ :ann |
OPFsmFigureHighlighter
highlightNode: (diagramController roassalShapeForModel: ann place)
with: Color green ].
aRecognizer when: OPFsmRecognizerFailure do: [ :ann |
OPFsmFigureHighlighter
highlightNode: (diagramController roassalShapeForModel: ann place)
with: Color red.
self letterPanel
changeBoxAt: aRecognizer inputPosition - 1
to: #failure ].
aRecognizer when: OPFsmRecognizerLeave do: [ :ann |
OPFsmFigureHighlighter unhighlight:
(diagramController roassalShapeForModel: ann place) ].
aRecognizer when: OPFsmRecognizerEnter do: [ :ann |
OPFsmFigureHighlighter
highlight: (diagramController roassalShapeForModel: ann place)
with: Color orange ]
to: #failure ]
for: self.
aRecognizer
when: OPFsmRecognizerLeave
do: [ :ann |
OPFsmFigureHighlighter unhighlight:
(diagramController roassalShapeForModel: ann place) ]
for: self.
aRecognizer
when: OPFsmRecognizerEnter
do: [ :ann |
OPFsmFigureHighlighter
highlight: (diagramController roassalShapeForModel: ann place)
with: Color orange ]
for: self
]
4 changes: 2 additions & 2 deletions repository/OpenPonk-FSM/OPFsmTerminalPanelAdapter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ OPFsmTerminalPanelAdapter >> buildWidget [
yourself.
self model
whenRecognizerStateChangedDo: [ :event |
morph changeBoxAt: event inputPosition to: event inputState ];
whenDataChangedDo: [ :event | morph data: event data ].
morph changeBoxAt: event inputPosition to: event inputState ] for: self;
whenDataChangedDo: [ :event | morph data: event data ] for: self.
^ morph
]
14 changes: 10 additions & 4 deletions repository/OpenPonk-FSM/OPFsmTerminalPanelPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ OPFsmTerminalPanelPresenter >> data: aString [
]

{ #category : 'event handling' }
OPFsmTerminalPanelPresenter >> whenDataChangedDo: aBlock [
OPFsmTerminalPanelPresenter >> whenDataChangedDo: aBlock for: aSubscriber [

self announcer when: OPFsmTerminalDataChanged do: aBlock
self announcer
when: OPFsmTerminalDataChanged
do: aBlock
for: aSubscriber
]

{ #category : 'event handling' }
OPFsmTerminalPanelPresenter >> whenRecognizerStateChangedDo: aBlock [
OPFsmTerminalPanelPresenter >> whenRecognizerStateChangedDo: aBlock for: aSubscriber [

self announcer when: OPFsmTerminalRecognizerStateChanged do: aBlock
self announcer
when: OPFsmTerminalRecognizerStateChanged
do: aBlock
for: aSubscriber
]

0 comments on commit 25460e5

Please sign in to comment.