From e51bb3c64b4a56a0f7d196a18e3147daa486ccd6 Mon Sep 17 00:00:00 2001 From: Pierre Laborde Date: Fri, 17 Nov 2023 12:44:27 +0100 Subject: [PATCH 01/12] Place flags for #117. Working on edition plugin. --- .../PyramidPluginEditOnRunningTest.class.st | 12 ++++++++++ src/Pyramid/BlElement.extension.st | 2 ++ src/Pyramid/BlSpace.extension.st | 2 ++ .../PyramidPluginEditOnRunning.class.st | 24 +++++++++++++++++-- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st b/src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st index 0b57bcb8..fc1d3958 100644 --- a/src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st +++ b/src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st @@ -24,6 +24,18 @@ PyramidPluginEditOnRunningTest >> tearDown [ super tearDown. ] +{ #category : #tests } +PyramidPluginEditOnRunningTest >> testCanEditBlSpace [ + + | space | + PyramidPluginEditOnRunning editOnRunning: true. + + "Create a BlSpace and check if it is configured correctly" + space := BlSpace new. + + self assert: space. +] + { #category : #tests } PyramidPluginEditOnRunningTest >> testEditOnRunning [ diff --git a/src/Pyramid/BlElement.extension.st b/src/Pyramid/BlElement.extension.st index 7b83e087..6abe50fc 100644 --- a/src/Pyramid/BlElement.extension.st +++ b/src/Pyramid/BlElement.extension.st @@ -5,6 +5,8 @@ BlElement >> editWithPyramid [ | editor oldParent | editor := PyramidPluginManager uniqueInstance makeEditor. + + self flag:'labordep: the code below is too complicated, we need to have a more simple API to edit a BlElement, for example editElement:'. oldParent := self parent. self hasParent ifTrue: [ oldParent removeChild: self ]. diff --git a/src/Pyramid/BlSpace.extension.st b/src/Pyramid/BlSpace.extension.st index 7987a743..bae04baf 100644 --- a/src/Pyramid/BlSpace.extension.st +++ b/src/Pyramid/BlSpace.extension.st @@ -12,6 +12,8 @@ BlSpace >> editWithPyramid [ editor := PyramidPluginManager uniqueInstance makeEditor. editor window open. + self flag:'labordep: the code below is too complicated, we need to have a more simple API to edit a BlSpace, for example editSpace:'. + "Remove all blElement of the application root to be replaced by the image" elements := self root children asArray copy. self root removeChildren. diff --git a/src/Pyramid/PyramidPluginEditOnRunning.class.st b/src/Pyramid/PyramidPluginEditOnRunning.class.st index 1876e000..a29f2d24 100644 --- a/src/Pyramid/PyramidPluginEditOnRunning.class.st +++ b/src/Pyramid/PyramidPluginEditOnRunning.class.st @@ -34,17 +34,37 @@ PyramidPluginEditOnRunning class >> install [ { #category : #'universe management' } PyramidPluginEditOnRunning class >> installBlUniverseListeners [ - BlParallelUniverse all do:[ :universe | + Beacon instance + when: BlParallelUniverseHostSpaceCreatedSignal + send: #receiveBlParallelUniverseHostSpaceCreatedSignal: + to: self. + + "BlParallelUniverse all do:[ :universe | universe when: BlParallelUniverseHostSpaceCreatedSignal do:[ :e | self receiveBlParallelUniverseHostSpaceCreatedSignal: e ]. - ]. + ]." ] { #category : #'universe management' } PyramidPluginEditOnRunning class >> receiveBlParallelUniverseHostSpaceCreatedSignal: anEvent [ self editOnRunning ifFalse: [ ^ self ]. + + "add a sequence to install shortcut" +] + +{ #category : #initialization } +PyramidPluginEditOnRunning class >> uninstall [ + "Undo some stuff here when the plugin used class oriented behavior" + + self uninstallBlUniverseListeners. +] + +{ #category : #'universe management' } +PyramidPluginEditOnRunning class >> uninstallBlUniverseListeners [ + + Beacon instance unsubscribe: self ] { #category : #adding } From 84ce56d31eca7190306de27bc72f2198b1cdeab4 Mon Sep 17 00:00:00 2001 From: Pierre Laborde Date: Fri, 17 Nov 2023 14:21:57 +0100 Subject: [PATCH 02/12] Working on edition plugin with shortcuts. Refactor editor building and opening. Tests. --- .../PyramidContextMenuPlugin.class.st | 4 +- src/Pyramid-Bloc/PyramidSavePlugin.class.st | 2 +- src/Pyramid-IDE/PyramidWorld.class.st | 2 +- src/Pyramid-Tests/PyramidEditorTest.class.st | 2 +- .../PyramidPluginEditOnRunningTest.class.st | 64 +++++++++++++- src/Pyramid/BlElement.extension.st | 3 +- src/Pyramid/BlSpace.extension.st | 2 +- src/Pyramid/PyramidEditor.class.st | 13 +++ src/Pyramid/PyramidEditorBuilder.class.st | 10 --- .../PyramidPluginEditOnRunning.class.st | 85 +++++++++++++++---- src/Pyramid/PyramidPluginManager.class.st | 8 ++ 11 files changed, 160 insertions(+), 35 deletions(-) diff --git a/src/Pyramid-Bloc/PyramidContextMenuPlugin.class.st b/src/Pyramid-Bloc/PyramidContextMenuPlugin.class.st index e259496a..4d8955d3 100644 --- a/src/Pyramid-Bloc/PyramidContextMenuPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidContextMenuPlugin.class.st @@ -12,8 +12,10 @@ Class { { #category : #'class initialization' } PyramidContextMenuPlugin class >> initialize [ - self flag:'labordep: Why remove before add ?'. + "Remove the plugin in case of already install (reset)" PyramidPluginManager uniqueInstance removePlugin: self. + + "Add the plugin" PyramidPluginManager uniqueInstance addPlugin: self ] diff --git a/src/Pyramid-Bloc/PyramidSavePlugin.class.st b/src/Pyramid-Bloc/PyramidSavePlugin.class.st index 7c7ee66f..7c1307a1 100644 --- a/src/Pyramid-Bloc/PyramidSavePlugin.class.st +++ b/src/Pyramid-Bloc/PyramidSavePlugin.class.st @@ -19,7 +19,7 @@ Class { PyramidSavePlugin class >> openOn: aCollectionOfBlElement saveModel: aSaveModel [ | editor savePlugin | - editor := PyramidEditorBuilder makeEditor. + editor := PyramidEditor buildEditor. savePlugin := editor plugins select: [ :each | each class = self ]. savePlugin size = 1 ifFalse: [ Error signal: diff --git a/src/Pyramid-IDE/PyramidWorld.class.st b/src/Pyramid-IDE/PyramidWorld.class.st index ca8cc1b3..194da388 100644 --- a/src/Pyramid-IDE/PyramidWorld.class.st +++ b/src/Pyramid-IDE/PyramidWorld.class.st @@ -161,7 +161,7 @@ PyramidWorld class >> startBrowseSources [ { #category : #actions } PyramidWorld class >> startNewDesign [ - PyramidPluginManager uniqueInstance makeEditor window open + PyramidEditor open ] { #category : #actions } diff --git a/src/Pyramid-Tests/PyramidEditorTest.class.st b/src/Pyramid-Tests/PyramidEditorTest.class.st index 30d6ced1..4403ae5a 100644 --- a/src/Pyramid-Tests/PyramidEditorTest.class.st +++ b/src/Pyramid-Tests/PyramidEditorTest.class.st @@ -34,7 +34,7 @@ PyramidEditorTest >> openFromBlSpace [ PyramidEditorTest >> openNewEditor [ | editor spec | - editor := PyramidPluginManager uniqueInstance makeEditor. + editor := PyramidEditor buildEditor. spec := editor window open. (Duration milliSeconds: 10) wait. self currentWorld doOneCycle. diff --git a/src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st b/src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st index fc1d3958..c79e5636 100644 --- a/src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st +++ b/src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st @@ -10,11 +10,24 @@ Class { #category : #'Pyramid-Tests-cases-plugin-edit-on-running' } +{ #category : #utils } +PyramidPluginEditOnRunningTest >> closeSpace: aSpace [ + + aSpace when: BlSpaceShownEvent doOnce: [ :event | + BlSpace pulseUntilEmptyTaskQueue: aSpace timeout: 200 milliSeconds. + aSpace close ]. +] + { #category : #tests } PyramidPluginEditOnRunningTest >> setUp [ super setUp. + + "Preserve user settings" setting := PyramidPluginEditOnRunning editOnRunning. + + PyramidPluginEditOnRunning uninstall. + PyramidPluginEditOnRunning install. ] { #category : #tests } @@ -25,15 +38,20 @@ PyramidPluginEditOnRunningTest >> tearDown [ ] { #category : #tests } -PyramidPluginEditOnRunningTest >> testCanEditBlSpace [ - +PyramidPluginEditOnRunningTest >> testBlSpaceShortcutAddAndRemove [ | space | + PyramidPluginEditOnRunning editOnRunning: true. - "Create a BlSpace and check if it is configured correctly" 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 assert: space. + self closeSpace: space. ] { #category : #tests } @@ -45,3 +63,41 @@ PyramidPluginEditOnRunningTest >> testEditOnRunning [ PyramidPluginEditOnRunning editOnRunning: false. self deny: PyramidPluginEditOnRunning editOnRunning. ] + +{ #category : #tests } +PyramidPluginEditOnRunningTest >> testKeyCombination [ + + self assert: (PyramidPluginEditOnRunning keyCombination isKindOf: BlKeyCombination) + +] + +{ #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 [ + + self assert: (PyramidPluginEditOnRunning shortcut isKindOf: BlShortcutWithAction). + +] + +{ #category : #tests } +PyramidPluginEditOnRunningTest >> testSpaceIds [ + + self assert: PyramidPluginEditOnRunning spaceIds isEmpty. + +] diff --git a/src/Pyramid/BlElement.extension.st b/src/Pyramid/BlElement.extension.st index 6abe50fc..9db70f8c 100644 --- a/src/Pyramid/BlElement.extension.st +++ b/src/Pyramid/BlElement.extension.st @@ -4,7 +4,7 @@ Extension { #name : #BlElement } BlElement >> editWithPyramid [ | editor oldParent | - editor := PyramidPluginManager uniqueInstance makeEditor. + editor := PyramidEditor buildEditor. self flag:'labordep: the code below is too complicated, we need to have a more simple API to edit a BlElement, for example editElement:'. oldParent := self parent. @@ -21,6 +21,7 @@ BlElement >> editWithPyramid [ BlElement >> openInNewSpaceWithPyramidShortcut [ | space isEdit | + self deprecated:'use the edition capacity in pyramid properties'. space := self openInNewSpace. isEdit := false. space when: BlKeyDownEvent do: [ :evt | diff --git a/src/Pyramid/BlSpace.extension.st b/src/Pyramid/BlSpace.extension.st index bae04baf..ee0cd949 100644 --- a/src/Pyramid/BlSpace.extension.st +++ b/src/Pyramid/BlSpace.extension.st @@ -9,7 +9,7 @@ BlSpace >> editWithPyramid [ spacePlaceholder addChildren: PyramidLogo logoOpenInPyramid materializeAsBlElement. "Open editor" - editor := PyramidPluginManager uniqueInstance makeEditor. + editor := PyramidEditor buildEditor. editor window open. self flag:'labordep: the code below is too complicated, we need to have a more simple API to edit a BlSpace, for example editSpace:'. diff --git a/src/Pyramid/PyramidEditor.class.st b/src/Pyramid/PyramidEditor.class.st index 56a2c0f4..0c7cc60b 100644 --- a/src/Pyramid/PyramidEditor.class.st +++ b/src/Pyramid/PyramidEditor.class.st @@ -10,6 +10,19 @@ Class { #category : #'Pyramid-core' } +{ #category : #private } +PyramidEditor class >> buildEditor [ + + ^ PyramidPluginManager uniqueInstance buildEditor +] + +{ #category : #'instance creation' } +PyramidEditor class >> open [ +