From 1e64b020765b20d008db2787ff2426850554f81a Mon Sep 17 00:00:00 2001 From: Guille Polito Date: Wed, 10 Jul 2024 17:36:48 +0200 Subject: [PATCH] Draft simplerene integration --- .../BaselineOfPyramid.class.st | 10 ++- .../PyramidBlocTextPlugin.class.st | 18 +++- .../PyramidFontSizeCommand.class.st | 3 +- .../PyramidGenericCommand.class.st | 34 +++++++ src/Pyramid/PyramidMagritteProperty.class.st | 89 +++++++++++++++++++ .../PyramidNumberInputPresenter.class.st | 27 ++++-- .../PyramidPopingPresenterBuilder.class.st | 4 +- src/Pyramid/PyramidProperty.class.st | 8 ++ 8 files changed, 175 insertions(+), 18 deletions(-) create mode 100644 src/Pyramid-Bloc/PyramidGenericCommand.class.st create mode 100644 src/Pyramid/PyramidMagritteProperty.class.st diff --git a/src/BaselineOfPyramid/BaselineOfPyramid.class.st b/src/BaselineOfPyramid/BaselineOfPyramid.class.st index c9ce28f5..eb41e3f1 100644 --- a/src/BaselineOfPyramid/BaselineOfPyramid.class.st +++ b/src/BaselineOfPyramid/BaselineOfPyramid.class.st @@ -81,11 +81,13 @@ BaselineOfPyramid >> preload: loader package: packageSpec [ { #category : 'packages' } BaselineOfPyramid >> pyramidPackages: spec [ - spec package: 'Pyramid'. - spec - package: 'Pyramid-IDE' - with: [ spec requires: #( 'Pyramid' ) ]. + spec baseline: 'SimpleRene' with: [ + spec + repository: 'github://pharo-contributions/SimpleRene:v1.0.0'; + loads: #( Core ) ]. + spec package: 'Pyramid' with: [ spec requires: #( 'SimpleRene' ) ]. + spec package: 'Pyramid-IDE' with: [ spec requires: #( 'Pyramid' ) ] ] { #category : 'dependencies' } diff --git a/src/Pyramid-Bloc/PyramidBlocTextPlugin.class.st b/src/Pyramid-Bloc/PyramidBlocTextPlugin.class.st index f80df7b3..ad1de789 100644 --- a/src/Pyramid-Bloc/PyramidBlocTextPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidBlocTextPlugin.class.st @@ -11,7 +11,9 @@ Class { { #category : 'accessing' } PyramidBlocTextPlugin class >> changeText [ + | property | + property := PyramidProperty new name: 'Text'; command: PyramidChangeTextCommand new; @@ -38,6 +40,7 @@ PyramidBlocTextPlugin class >> fontSize [ { #category : 'accessing' } PyramidBlocTextPlugin class >> fontWeight [ + | property | property := PyramidProperty new name: 'Font weight'; @@ -51,6 +54,7 @@ PyramidBlocTextPlugin class >> fontWeight [ { #category : 'accessing' } PyramidBlocTextPlugin class >> textForeground [ + | property | property := PyramidProperty new name: 'Text foreground'; @@ -66,8 +70,14 @@ PyramidBlocTextPlugin class >> textForeground [ { #category : 'connecting' } PyramidBlocTextPlugin >> connectOn: aPyramidEditor [ - aPyramidEditor propertiesManager addProperty: self class changeText. - aPyramidEditor propertiesManager addProperty: self class fontSize. - aPyramidEditor propertiesManager addProperty: self class fontWeight. - aPyramidEditor propertiesManager addProperty: self class textForeground + (self class class methods select: [ :e | + e hasPragmaNamed: #pyManualProperty ]) do: [ :m | + aPyramidEditor propertiesManager addProperty: + (self class perform: m selector) ]. + + BlTextElement new simpleReneDescription do: [ :propertyDescription | + | property | + property := PyramidMagritteProperty new magritteDescription: + propertyDescription. + aPyramidEditor propertiesManager addProperty: property ] ] diff --git a/src/Pyramid-Bloc/PyramidFontSizeCommand.class.st b/src/Pyramid-Bloc/PyramidFontSizeCommand.class.st index 58a1631f..591ea9d6 100644 --- a/src/Pyramid-Bloc/PyramidFontSizeCommand.class.st +++ b/src/Pyramid-Bloc/PyramidFontSizeCommand.class.st @@ -19,6 +19,5 @@ PyramidFontSizeCommand >> getValueFor: aBlTextElement [ { #category : 'as yet unclassified' } PyramidFontSizeCommand >> setValueFor: aBlTextElement with: aNumber [ - aBlTextElement text attribute: (BlFontSizeAttribute size: aNumber). - aBlTextElement textChanged + aBlTextElement fontSize: aNumber ] diff --git a/src/Pyramid-Bloc/PyramidGenericCommand.class.st b/src/Pyramid-Bloc/PyramidGenericCommand.class.st new file mode 100644 index 00000000..f0c4c976 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidGenericCommand.class.st @@ -0,0 +1,34 @@ +Class { + #name : 'PyramidGenericCommand', + #superclass : 'PyramidBlocTextCommand', + #instVars : [ + 'selector' + ], + #category : 'Pyramid-Bloc-plugin-bloc-text', + #package : 'Pyramid-Bloc', + #tag : 'plugin-bloc-text' +} + +{ #category : 'as yet unclassified' } +PyramidGenericCommand >> getValueFor: aBLElement [ + + ^ aBLElement perform: selector +] + +{ #category : 'accessing' } +PyramidGenericCommand >> selector [ + + ^ selector +] + +{ #category : 'accessing' } +PyramidGenericCommand >> selector: anObject [ + + selector := anObject +] + +{ #category : 'as yet unclassified' } +PyramidGenericCommand >> setValueFor: aBLElement with: aValue [ + + aBLElement perform: selector asMutator with: aValue +] diff --git a/src/Pyramid/PyramidMagritteProperty.class.st b/src/Pyramid/PyramidMagritteProperty.class.st new file mode 100644 index 00000000..89c3fa85 --- /dev/null +++ b/src/Pyramid/PyramidMagritteProperty.class.st @@ -0,0 +1,89 @@ +Class { + #name : 'PyramidMagritteProperty', + #superclass : 'Object', + #instVars : [ + 'magritteDescription', + 'commandExecutor', + 'presenterBuilder' + ], + #category : 'Pyramid-property', + #package : 'Pyramid', + #tag : 'property' +} + +{ #category : 'ad' } +PyramidMagritteProperty >> buildPresenterFromCluster: aCluster [ + + ^ self presenterBuilder + cluster: aCluster; + property: self; + build +] + +{ #category : 'accessing' } +PyramidMagritteProperty >> command [ + + ^ PyramidGenericCommand new + selector: magritteDescription accessor readSelector; + yourself +] + +{ #category : 'accessing' } +PyramidMagritteProperty >> commandExecutor [ + ^ commandExecutor +] + +{ #category : 'accessing' } +PyramidMagritteProperty >> commandExecutor: aPyramidCallbackCommandExecutor [ + + commandExecutor := aPyramidCallbackCommandExecutor +] + +{ #category : 'accessing' } +PyramidMagritteProperty >> initialize [ + + super initialize. + presenterBuilder := PyramidPopingPresenterBuilder new +] + +{ #category : 'accessing' } +PyramidMagritteProperty >> magritteDescription [ + + ^ magritteDescription +] + +{ #category : 'accessing' } +PyramidMagritteProperty >> magritteDescription: anObject [ + + magritteDescription := anObject +] + +{ #category : 'tests' } +PyramidMagritteProperty >> makeNewInput [ + + ^ magritteDescription acceptSimpleReneVisitor: self +] + +{ #category : 'accessing' } +PyramidMagritteProperty >> name [ + + ^ magritteDescription label +] + +{ #category : 'accessing' } +PyramidMagritteProperty >> presenterBuilder [ + + ^ presenterBuilder +] + +{ #category : 'visiting' } +PyramidMagritteProperty >> visitNumberDescription: aMANumberDescription [ + + | presenter | + presenter := PyramidNumberInputPresenter new. + presenter help: magritteDescription comment. + aMANumberDescription min ifNotNil: [ + presenter min: aMANumberDescription min ]. + + ^ presenter +] diff --git a/src/Pyramid/PyramidNumberInputPresenter.class.st b/src/Pyramid/PyramidNumberInputPresenter.class.st index 01c4a219..9c723cca 100644 --- a/src/Pyramid/PyramidNumberInputPresenter.class.st +++ b/src/Pyramid/PyramidNumberInputPresenter.class.st @@ -6,7 +6,8 @@ Class { #superclass : 'PyramidInputPresenter', #instVars : [ 'inputNumber', - 'submitBlock' + 'submitBlock', + 'min' ], #category : 'Pyramid-specs-custom', #package : 'Pyramid', @@ -30,7 +31,16 @@ PyramidNumberInputPresenter >> defaultLayout [ { #category : 'as yet unclassified' } PyramidNumberInputPresenter >> getNumberFrom: aString [ - ^ NumberParser parse: aString onError: [ PyramidUnknowState new ] + | number | + number := (NumberParser parse: aString onError: [ PyramidUnknowState new ]). + min ifNotNil: [ ^ number max: min ]. + ^ number +] + +{ #category : 'as yet unclassified' } +PyramidNumberInputPresenter >> help: aString [ + + self inputNumber help: aString ] { #category : 'initialization - deprecated' } @@ -42,14 +52,21 @@ PyramidNumberInputPresenter >> initializePresenters [ { #category : 'accessing' } PyramidNumberInputPresenter >> inputNumber [ -^ inputNumber + + ^ inputNumber +] + +{ #category : 'accessing' } +PyramidNumberInputPresenter >> min: anInteger [ + + min := anInteger ] { #category : 'accessing' } PyramidNumberInputPresenter >> submitBlock [ - submitBlock ifNil: [ submitBlock := [ :n | ] ]. -^ submitBlock + submitBlock ifNil: [ submitBlock := [ :n | ] ]. + ^ submitBlock ] { #category : 'accessing' } diff --git a/src/Pyramid/PyramidPopingPresenterBuilder.class.st b/src/Pyramid/PyramidPopingPresenterBuilder.class.st index 4f9c4ad2..35ca4bdd 100644 --- a/src/Pyramid/PyramidPopingPresenterBuilder.class.st +++ b/src/Pyramid/PyramidPopingPresenterBuilder.class.st @@ -176,7 +176,5 @@ PyramidPopingPresenterBuilder >> layoutForLabel: aString input: anInput button: { #category : 'as yet unclassified' } PyramidPopingPresenterBuilder >> makeNewInput [ - ^ self property pyramidInputPresenterClass new - strings: self property pyramidInputPresenterStrings; - yourself + ^ self property makeNewInput ] diff --git a/src/Pyramid/PyramidProperty.class.st b/src/Pyramid/PyramidProperty.class.st index 541f21dd..0060112c 100644 --- a/src/Pyramid/PyramidProperty.class.st +++ b/src/Pyramid/PyramidProperty.class.st @@ -54,6 +54,14 @@ PyramidProperty >> initialize [ name := 'Default property name' ] +{ #category : 'tests' } +PyramidProperty >> makeNewInput [ + + ^ self pyramidInputPresenterClass new + strings: self pyramidInputPresenterStrings; + yourself +] + { #category : 'accessing' } PyramidProperty >> name [