Skip to content

Commit

Permalink
Fix cycling edition, refactoring open/close editor, plugin access fro…
Browse files Browse the repository at this point in the history
…m plugin class
  • Loading branch information
LabordePierre committed Nov 17, 2023
1 parent 84ce56d commit 22d9d6c
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/Pyramid-Bloc/PyramidSavePlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ PyramidSavePlugin class >> openOn: aCollectionOfBlElement saveModel: aSaveModel
savePlugin := savePlugin asArray first.
editor projectModel roots addAll: aCollectionOfBlElement.
savePlugin openOn: aSaveModel.
editor window open
editor open
]

{ #category : #adding }
Expand Down
1 change: 1 addition & 0 deletions src/Pyramid-Bloc/PyramidSpaceBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ PyramidSpaceBuilder >> addOverlayNamed: aString [
PyramidSpaceBuilder >> build [

self space: BlSpace new.
self space userData at: #isPyramidEditor put: true.

self overlays ifEmpty: [ ^ self space ].

Expand Down
8 changes: 5 additions & 3 deletions src/Pyramid-Tests/PyramidEditorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ PyramidEditorTest >> openFromBlSpace [
self assert: (editor projectModel roots includes: element).
self deny: (space root children includes: element).

editor window close.
editor close.
(Duration milliSeconds: 10) wait.

self assert: editor window isClosed.
Expand All @@ -35,13 +35,15 @@ PyramidEditorTest >> openNewEditor [

| editor spec |
editor := PyramidEditor buildEditor.
spec := editor window open.
editor open.

spec := editor window spec.
(Duration milliSeconds: 10) wait.
self currentWorld doOneCycle.
self assert: editor window isOpen.
self assert: spec window isInWorld.

editor window close.
editor close.
(Duration milliSeconds: 10) wait.
self currentWorld doOneCycle.
self assert: editor window isClosed.
Expand Down
32 changes: 15 additions & 17 deletions src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ PyramidPluginEditOnRunningTest >> testBlSpaceShortcutAddAndRemove [
self closeSpace: space.
]

{ #category : #tests }
PyramidPluginEditOnRunningTest >> testCannotEditTheEditor [
| space editor |

PyramidPluginEditOnRunning editOnRunning: true.

editor := PyramidEditor buildEditor.
"get the space of the editor"
space := (editor getPlugin: 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)).
]

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

Expand All @@ -71,23 +86,6 @@ PyramidPluginEditOnRunningTest >> testKeyCombination [

]

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

PyramidPluginEditOnRunning editOnRunning: true.

space := PyramidEditor 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.
]

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

Expand Down
28 changes: 25 additions & 3 deletions src/Pyramid/PyramidEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,21 @@ PyramidEditor class >> buildEditor [
PyramidEditor class >> open [
<script>

self buildEditor window open
self buildEditor open
]

{ #category : #'open/close' }
PyramidEditor >> close [

self window ifNil: [ ^ self ].
self window isClosed ifTrue:[ ^ self ].
self window close
]

{ #category : #plugins }
PyramidEditor >> getPlugin: aPluginClass [

^ self plugins detect:[ :p | p class = aPluginClass ] ifNone:[ ]
]

{ #category : #initialization }
Expand All @@ -33,13 +47,21 @@ PyramidEditor >> initialize [
plugins := { }
]

{ #category : #accessing }
{ #category : #'open/close' }
PyramidEditor >> open [

self window ifNil: [ ^ self ].
self window isOpen ifTrue:[ ^ self ].
self window open
]

{ #category : #plugins }
PyramidEditor >> plugins [

^ plugins
]

{ #category : #accessing }
{ #category : #plugins }
PyramidEditor >> plugins: aCollection [

plugins := aCollection
Expand Down
3 changes: 3 additions & 0 deletions src/Pyramid/PyramidPluginEditOnRunning.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ PyramidPluginEditOnRunning class >> addShortcutInSpace: aSpace [
aSpace ifNil: [ ^ self ].
(self spaceIds includes: aSpace id) ifTrue:[ ^ self ].

"Not edit the editor space to prevent cycling"
aSpace userData at: #isPyramidEditor ifPresent:[ ^ self ].

self spaceIds add: aSpace id.
aSpace root addShortcut: shortcut
]
Expand Down
6 changes: 6 additions & 0 deletions src/Pyramid/PyramidWindow.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ PyramidWindow >> services [
^ services
]

{ #category : #accessing }
PyramidWindow >> spec [

^ spec
]

{ #category : #'api - showing' }
PyramidWindow >> title [

Expand Down

0 comments on commit 22d9d6c

Please sign in to comment.