Skip to content

Commit

Permalink
Merge pull request #213 from OpenSmock/Issue_0212
Browse files Browse the repository at this point in the history
  • Loading branch information
labordep authored Oct 29, 2024
2 parents 58a8a6e + b74efa5 commit 8e9af98
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 66 deletions.
50 changes: 50 additions & 0 deletions src/Pyramid-Bloc/PyramidBreakpoint.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Class {
#name : #PyramidBreakpoint,
#superclass : #Breakpoint,
#instVars : [
'whenHitDo'
],
#category : #'Pyramid-Bloc-plugin-edit-on-running'
}

{ #category : #accessing }
PyramidBreakpoint class >> removeBreakpoint: aBreakpoint [

"Do nothing"
]

{ #category : #api }
PyramidBreakpoint >> breakInContext: aContext node: aNode [

self class notifyBreakpointHit: self inContext: aContext node: aNode.
self isEnabled ifFalse: [ ^ self ].
self onCount ifTrue: [
self increaseCount = self breakOnCount ifFalse: [ ^ self ] ].
self once ifTrue: [ self disable ].
self whenHitDo value: aContext.
]

{ #category : #initialization }
PyramidBreakpoint >> initialize [

super initialize.
whenHitDo := [ :c | ]
]

{ #category : #testing }
PyramidBreakpoint >> isInstalled [

^ self link methods isNotEmpty
]

{ #category : #accessing }
PyramidBreakpoint >> whenHitDo [

^ whenHitDo
]

{ #category : #accessing }
PyramidBreakpoint >> whenHitDo: anObject [

whenHitDo := anObject
]
70 changes: 28 additions & 42 deletions src/Pyramid-Bloc/PyramidPluginEditOnRunning.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ Class {
'spaceIds',
'shortcut',
'shortcutFork',
'keyCombination'
'keyCombination',
'breakpoint'
],
#category : #'Pyramid-Bloc-plugin-edit-on-running'
}

{ #category : #private }
PyramidPluginEditOnRunning class >> addShortcutInSpace: aSpace [

(self canEditSpace: aSpace) ifFalse:[ ^ self ].
(self spaceIds includes: aSpace id) ifTrue:[ ^ self ].

self spaceIds add: aSpace id.
aSpace root addShortcut: self shortcut
(self canEditSpace: aSpace) ifFalse: [ ^ self ].
aSpace root addShortcut: self shortcut
]

{ #category : #initialization }
PyramidPluginEditOnRunning class >> breakpoint [
^ breakpoint
]

{ #category : #testing }
Expand Down Expand Up @@ -78,19 +81,28 @@ PyramidPluginEditOnRunning class >> editOnRunning: aBoolean [

{ #category : #initialization }
PyramidPluginEditOnRunning class >> install [
"Do some stuff here when the plugin used class oriented behavior"

self installBlUniverseListeners.


self isBreakpointInstall ifTrue: [ ^ self ].
self installBreakpoint.
]

{ #category : #'universe management' }
PyramidPluginEditOnRunning class >> installBlUniverseListeners [
PyramidPluginEditOnRunning class >> installBreakpoint [

Beacon instance
when: BlParallelUniverseOpenSpaceRequestSignal
send: #receiveBlParallelUniverseHostSpaceSignal:
to: self
| node |
node := (BlParallelUniverse methodNamed: #openSpace:) ast.

breakpoint := PyramidBreakpoint new.
breakpoint node: node.
breakpoint whenHitDo: [ :context | self addShortcutInSpace: context arguments first ].
breakpoint install
]

{ #category : #initialization }
PyramidPluginEditOnRunning class >> isBreakpointInstall [

self breakpoint ifNil: [ ^ false ].
^ self breakpoint isInstalled
]

{ #category : #accessing }
Expand All @@ -100,19 +112,11 @@ PyramidPluginEditOnRunning class >> keyCombination [
keyCombination := (BlKeyCombination builder key: KeyboardKey F12) build ]
]

{ #category : #'universe management' }
PyramidPluginEditOnRunning class >> receiveBlParallelUniverseHostSpaceSignal: anEvent [

BlSpace spaceWithId: anEvent spaceId do: [ :e | self addShortcutInSpace: e ]
]

{ #category : #private }
PyramidPluginEditOnRunning class >> removeShortcutInSpace: aSpace [

aSpace ifNil: [ ^ self ].

aSpace root removeShortcut: self shortcut.
self spaceIds remove: aSpace id.
]

{ #category : #accessing }
Expand All @@ -125,27 +129,9 @@ PyramidPluginEditOnRunning class >> shortcut [
action: [ :event | self doShortcutAction: event ] ]
]

{ #category : #accessing }
PyramidPluginEditOnRunning class >> spaceIds [

^ spaceIds ifNil: [ spaceIds := Set new ]
]

{ #category : #initialization }
PyramidPluginEditOnRunning class >> uninstall [
"Undo some stuff here when the plugin used class oriented behavior"

self uninstallBlUniverseListeners.

self spaceIds do:[ :id | BlSpace spaceWithId: id do: [ :e | self removeShortcutInSpace: e ] ].
self spaceIds removeAll.
shortcutFork ifNotNil: [ shortcutFork terminate. shortcutFork := nil ].
shortcut := nil.
keyCombination := nil.
]

{ #category : #'universe management' }
PyramidPluginEditOnRunning class >> uninstallBlUniverseListeners [

Beacon instance unsubscribe: self
self breakpoint ifNotNil: [ :b | b remove ]
]
8 changes: 4 additions & 4 deletions src/Pyramid-Bloc/PyramidSpacePlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ PyramidSpacePlugin >> initialize [
builder := PyramidSpaceBuilder defaultEditorBuilder.
morphicPresenter := SpMorphPresenter new.
resetSpaceButton := SpButtonPresenter new
icon: (Smalltalk ui icons iconNamed: #smallUpdate);
icon:
(Smalltalk ui icons iconNamed: #smallUpdate);
action: [ self resetSpace ];
help: 'Refresh space in case of an issue';
yourself
Expand All @@ -61,9 +62,8 @@ PyramidSpacePlugin >> makePresenterWithBlSpace: aBlSpace [

aBlSpace host: host.
aBlSpace addEventHandler: (BlEventHandler
on: BlSpaceDestroyedEvent
do: [ :evt |
self updateMorphInCaseOfFaillure: morph ]).
on: BlSpaceClosedEvent
do: [ :evt | self updateMorphInCaseOfFaillure: morph ]).

self morphicPresenter morph: morph.
self morphicPresenter whenDisplayDo: [ aBlSpace show ]
Expand Down
32 changes: 12 additions & 20 deletions src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Class {
{ #category : #utils }
PyramidPluginEditOnRunningTest >> closeSpace: aSpace [

aSpace when: BlSpaceShownEvent doOnce: [ :event |
aSpace addEventHandlerOn: BlSpaceShownEvent doOnce: [ :event |
BlSpace pulseUntilEmptyTaskQueue: aSpace timeout: 200 milliSeconds.
aSpace close ].
aSpace close ]
]

{ #category : #tests }
Expand All @@ -42,19 +42,19 @@ PyramidPluginEditOnRunningTest >> tearDown [

{ #category : #tests }
PyramidPluginEditOnRunningTest >> testBlSpaceShortcutAddAndRemove [
| space |

| space |
PyramidPluginEditOnRunning editOnRunning: true.

space := BlSpace new.
self deny: (PyramidPluginEditOnRunning spaceIds includes: space id).
self deny: (space root shortcuts includes: (PyramidPluginEditOnRunning shortcut)).
space show.
self assert: (PyramidPluginEditOnRunning spaceIds includes: space id).
self assert: (space root shortcuts includes: (PyramidPluginEditOnRunning shortcut)).
self closeSpace: space.
self deny:
(space root shortcuts includes: PyramidPluginEditOnRunning shortcut).

space show.
self assert:
(space root shortcuts includes: PyramidPluginEditOnRunning shortcut).

self closeSpace: space
]

{ #category : #tests }
Expand All @@ -68,7 +68,6 @@ PyramidPluginEditOnRunningTest >> testCannotEditTheEditor [
space := (editor findPlugin: PyramidSpacePlugin) builder space.

"check than the shortcut is not installed"
self deny: (PyramidPluginEditOnRunning spaceIds includes: space id).
self deny:
(space root shortcuts includes: PyramidPluginEditOnRunning shortcut)
]
Expand Down Expand Up @@ -103,10 +102,3 @@ PyramidPluginEditOnRunningTest >> testShortcut [
self assert: (PyramidPluginEditOnRunning shortcut isKindOf: BlShortcutWithAction).

]

{ #category : #tests }
PyramidPluginEditOnRunningTest >> testSpaceIds [

self assert: PyramidPluginEditOnRunning spaceIds isEmpty.

]

0 comments on commit 8e9af98

Please sign in to comment.