diff --git a/src/Pyramid-Bloc/BlRadialGradientPaint.extension.st b/src/Pyramid-Bloc/BlRadialGradientPaint.extension.st index 9e0d2fcf..03af8766 100644 --- a/src/Pyramid-Bloc/BlRadialGradientPaint.extension.st +++ b/src/Pyramid-Bloc/BlRadialGradientPaint.extension.st @@ -4,7 +4,7 @@ Extension { #name : #BlRadialGradientPaint } BlRadialGradientPaint >> = aBlPaint [ super = aBlPaint ifFalse: [ ^ false ]. - ^ self center = aBlPaint center and: [ self radius = aBlPaint radius ] + ^ self innerCenter = aBlPaint innerCenter and: [ self innerRadius = aBlPaint innerRadius and: [ self outerCenter = aBlPaint outerCenter and: [ self outerRadius = aBlPaint outerRadius ] ] ] ] { #category : #'*Pyramid-Bloc' } @@ -12,6 +12,6 @@ BlRadialGradientPaint >> selectOnGradientPaintInput: aPyramidGradientPaintInputP super selectOnGradientPaintInput: aPyramidGradientPaintInputPresenter. aPyramidGradientPaintInputPresenter radialButton click. - aPyramidGradientPaintInputPresenter centerInput value: self center. - aPyramidGradientPaintInputPresenter radiusInput value: self radius + aPyramidGradientPaintInputPresenter centerInput value: self outerCenter. + aPyramidGradientPaintInputPresenter radiusInput value: self outerRadius ] diff --git a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st index 5cc72fc8..5f1cd964 100644 --- a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st @@ -349,7 +349,7 @@ PyramidBlocPlugin >> groupCollection: aCollection [ self editor propertiesManager commandExecutor use: self groupCommand on: { aCollection } - with: self editor projectModel roots + with: self editor projectModel firstLevelElements ] { #category : #accessing } diff --git a/src/Pyramid-Bloc/PyramidLibraryPresenterForFirstLevelElement.class.st b/src/Pyramid-Bloc/PyramidLibraryPresenterForFirstLevelElement.class.st new file mode 100644 index 00000000..2e22e673 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidLibraryPresenterForFirstLevelElement.class.st @@ -0,0 +1,20 @@ +Class { + #name : #PyramidLibraryPresenterForFirstLevelElement, + #superclass : #PyramidLibraryPresenter, + #category : #'Pyramid-Bloc-plugin-tree-library' +} + +{ #category : #'as yet unclassified' } +PyramidLibraryPresenterForFirstLevelElement >> buttonAction [ + + self editor propertiesManager commandExecutor + use: PyramidAddToCollectionCommand new + on: { self editor projectModel firstLevelElements } + with: self list selectedItem blockMaker value +] + +{ #category : #private } +PyramidLibraryPresenterForFirstLevelElement >> buttonLabel [ + + ^ 'Add new on first level' +] diff --git a/src/Pyramid-Bloc/PyramidLibraryPresenterForRoot.class.st b/src/Pyramid-Bloc/PyramidLibraryPresenterForRoot.class.st deleted file mode 100644 index a15c9b17..00000000 --- a/src/Pyramid-Bloc/PyramidLibraryPresenterForRoot.class.st +++ /dev/null @@ -1,17 +0,0 @@ -Class { - #name : #PyramidLibraryPresenterForRoot, - #superclass : #PyramidLibraryPresenter, - #category : #'Pyramid-Bloc-plugin-tree-library' -} - -{ #category : #'as yet unclassified' } -PyramidLibraryPresenterForRoot >> buttonAction [ - - self editor propertiesManager commandExecutor use: PyramidAddToCollectionCommand new on: { self editor projectModel roots } with: self list selectedItem blockMaker value -] - -{ #category : #private } -PyramidLibraryPresenterForRoot >> buttonLabel [ - - ^ 'Add new root' -] diff --git a/src/Pyramid-Bloc/PyramidMainExtension.class.st b/src/Pyramid-Bloc/PyramidMainExtension.class.st index cc8bdd13..e91a2d4e 100644 --- a/src/Pyramid-Bloc/PyramidMainExtension.class.st +++ b/src/Pyramid-Bloc/PyramidMainExtension.class.st @@ -150,10 +150,11 @@ PyramidMainExtension >> projectModel: aProjectModel [ ] { #category : #'as yet unclassified' } -PyramidMainExtension >> pyramidRootsChanged [ +PyramidMainExtension >> pyramidFirstLevelElementsChanged [ self containerElement removeChildren. - (self projectModel roots asArray sorted: PyramidElevationSortFunction new) do: [ :each | + (self projectModel firstLevelElements asArray sorted: + PyramidElevationSortFunction new) do: [ :each | each parent ifNotNil: [ :p | p removeChild: each ]. self containerElement addChild: each ] ] diff --git a/src/Pyramid-Bloc/PyramidSavePlugin.class.st b/src/Pyramid-Bloc/PyramidSavePlugin.class.st index 0516fdea..3ad8b6c2 100644 --- a/src/Pyramid-Bloc/PyramidSavePlugin.class.st +++ b/src/Pyramid-Bloc/PyramidSavePlugin.class.st @@ -25,7 +25,7 @@ PyramidSavePlugin class >> openOn: aCollectionOfBlElement saveModel: aSaveModel Error signal: 'Wrong installation of SavePlugin. Should only be one instance.' ]. savePlugin := savePlugin asArray first. - editor projectModel roots addAll: aCollectionOfBlElement. + editor projectModel firstLevelElements addAll: aCollectionOfBlElement. savePlugin openOn: aSaveModel. editor open ] diff --git a/src/Pyramid-Bloc/PyramidSaveProjectConfigurationController.class.st b/src/Pyramid-Bloc/PyramidSaveProjectConfigurationController.class.st index dfe52116..edefd87a 100644 --- a/src/Pyramid-Bloc/PyramidSaveProjectConfigurationController.class.st +++ b/src/Pyramid-Bloc/PyramidSaveProjectConfigurationController.class.st @@ -60,7 +60,7 @@ PyramidSaveProjectConfigurationController >> pyramidElementsChanged [ ] { #category : #'as yet unclassified' } -PyramidSaveProjectConfigurationController >> pyramidRootsChanged [ +PyramidSaveProjectConfigurationController >> pyramidFirstLevelElementsChanged [ self saveModel isSaved: false. self updateWindowTitle diff --git a/src/Pyramid-Bloc/PyramidSavingMethodBuilder.class.st b/src/Pyramid-Bloc/PyramidSavingMethodBuilder.class.st index fd7bc8ef..e553fc74 100644 --- a/src/Pyramid-Bloc/PyramidSavingMethodBuilder.class.st +++ b/src/Pyramid-Bloc/PyramidSavingMethodBuilder.class.st @@ -96,7 +96,7 @@ PyramidSavingMethodBuilder >> serializeBlock: anObject [ PyramidSavingMethodBuilder >> serializedString: aSaveModel [ | roots | - roots := aSaveModel projectModel roots asArray sorted: + roots := aSaveModel projectModel firstLevelElements asArray sorted: PyramidElevationSortFunction new. self flag: #FIX. "The roots must be sorted before saving or else the order on the roots will not be kept" ^ self serializeBlock value: roots diff --git a/src/Pyramid-Bloc/PyramidTreePlugin.class.st b/src/Pyramid-Bloc/PyramidTreePlugin.class.st index 81fbcdd6..580e0816 100644 --- a/src/Pyramid-Bloc/PyramidTreePlugin.class.st +++ b/src/Pyramid-Bloc/PyramidTreePlugin.class.st @@ -161,7 +161,7 @@ PyramidTreePlugin >> initializeLibraryPresenters [ editor: self editor; idGenerator: idGenerator; yourself. - libraryPresenterForRoot := PyramidLibraryPresenterForRoot new + libraryPresenterForRoot := PyramidLibraryPresenterForFirstLevelElement new editor: self editor; idGenerator: idGenerator; yourself @@ -244,10 +244,10 @@ PyramidTreePlugin >> removeSelectedElements [ self editor propertiesManager commandExecutor use: PyramidRemoveSelectedElementsCommand new on: self editor projectModel selection - with: self editor projectModel roots. - + with: self editor projectModel firstLevelElements. + "Update the selection after remove" - self editor projectModel updateSelection. + self editor projectModel updateSelection ] { #category : #accessing } diff --git a/src/Pyramid-Bloc/PyramidTreePresenter.class.st b/src/Pyramid-Bloc/PyramidTreePresenter.class.st index 0dc85a12..b8a1a883 100644 --- a/src/Pyramid-Bloc/PyramidTreePresenter.class.st +++ b/src/Pyramid-Bloc/PyramidTreePresenter.class.st @@ -4,23 +4,24 @@ Class { #traits : 'TPyramidProjectModelObserver', #classTraits : 'TPyramidProjectModelObserver classTrait', #instVars : [ - 'buttonAddToRoots', 'tree', 'columns', 'libraryPresenterForRoot', 'projectModel', 'editorMenuBuilder', - 'shouldUpdateSelection' + 'shouldUpdateSelection', + 'buttonAddToFirstLevel' ], #category : #'Pyramid-Bloc-plugin-tree-library' } { #category : #'as yet unclassified' } PyramidTreePresenter >> actionAddNewElement [ -(PyramidPopoverFactory - makeWithPresenter: self libraryPresenterForRoot - relativeTo: self buttonAddToRoots - position: SpPopoverPosition right) popup + + (PyramidPopoverFactory + makeWithPresenter: self libraryPresenterForRoot + relativeTo: self buttonAddToFirstLevel + position: SpPopoverPosition right) popup ] { #category : #'as yet unclassified' } @@ -39,9 +40,9 @@ PyramidTreePresenter >> actionSelectionChanged: aCollection [ ] { #category : #accessing } -PyramidTreePresenter >> buttonAddToRoots [ +PyramidTreePresenter >> buttonAddToFirstLevel [ - ^ buttonAddToRoots + ^ buttonAddToFirstLevel ] { #category : #accessing } @@ -55,7 +56,7 @@ PyramidTreePresenter >> defaultLayout [ ^ SpBoxLayout newVertical spacing: 4; - add: self buttonAddToRoots expand: false; + add: self buttonAddToFirstLevel expand: false; add: self tree expand: true; yourself ] @@ -88,13 +89,13 @@ PyramidTreePresenter >> initializePresenters [ columns := OrderedCollection new. - buttonAddToRoots := SpButtonPresenter new + buttonAddToFirstLevel := SpButtonPresenter new label: 'Add new element'; icon: (self iconNamed: #add); action: [ self actionAddNewElement ]; help: - 'Add a new element on the roots of the design.'; - yourself + 'Add a new element on the first level of the design.'; + yourself ] { #category : #accessing } @@ -132,9 +133,9 @@ PyramidTreePresenter >> pyramidElementsChanged [ ] { #category : #'as yet unclassified' } -PyramidTreePresenter >> pyramidRootsChanged [ +PyramidTreePresenter >> pyramidFirstLevelElementsChanged [ - self updateRoots . + self updateRoots. self updateSelection ] @@ -178,8 +179,8 @@ PyramidTreePresenter >> tree [ PyramidTreePresenter >> updateRoots [ self shouldUpdateSelection: false. - [ - self tree roots: self projectModel roots asArray ] ensure: [ self shouldUpdateSelection: true ] + [ self tree roots: self projectModel firstLevelElements asArray ] ensure: [ + self shouldUpdateSelection: true ] ] { #category : #'as yet unclassified' } diff --git a/src/Pyramid-Tests/PyramidEditorTest.class.st b/src/Pyramid-Tests/PyramidEditorTest.class.st index e21904e9..038c6ee7 100644 --- a/src/Pyramid-Tests/PyramidEditorTest.class.st +++ b/src/Pyramid-Tests/PyramidEditorTest.class.st @@ -19,14 +19,14 @@ PyramidEditorTest >> openFromBlSpace [ (Duration milliSeconds: 10) wait. self assert: editor window isOpen. - self assert: (editor projectModel roots includes: element). + self assert: (editor projectModel firstLevelElements includes: element). self deny: (space root children includes: element). editor close. (Duration milliSeconds: 10) wait. self assert: editor window isClosed. - self deny: (editor projectModel roots includes: element). + self deny: (editor projectModel firstLevelElements includes: element). self assert: (space root children includes: element) ] diff --git a/src/Pyramid/BlElement.extension.st b/src/Pyramid/BlElement.extension.st index 43d311ed..da8569d8 100644 --- a/src/Pyramid/BlElement.extension.st +++ b/src/Pyramid/BlElement.extension.st @@ -3,15 +3,17 @@ Extension { #name : #BlElement } { #category : #'*Pyramid' } BlElement >> editWithPyramid [ - | editor oldParent | + | editor oldParent | 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:'. + + 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 ]. - editor projectModel roots add: self. - editor window whenClosedDo: [ oldParent ifNotNil: [ oldParent addChild: self ] ]. + editor projectModel firstLevelElements add: self. + editor window whenClosedDo: [ + oldParent ifNotNil: [ oldParent addChild: self ] ]. editor window open. ^ editor diff --git a/src/Pyramid/BlSpace.extension.st b/src/Pyramid/BlSpace.extension.st index 232dea53..3cadf6e3 100644 --- a/src/Pyramid/BlSpace.extension.st +++ b/src/Pyramid/BlSpace.extension.st @@ -6,13 +6,15 @@ BlSpace >> editWithPyramid [ | editor elements spacePlaceholder | "Prepare image to replace the application view" spacePlaceholder := (self root exportAsForm dimmed: 0.5) asElement. - spacePlaceholder addChildren: PyramidLogo logoOpenInPyramid materializeAsBlElement. - + spacePlaceholder addChildren: + PyramidLogo logoOpenInPyramid materializeAsBlElement. + "Open editor" 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:'. + self flag: + 'labordep: the code below is too complicated, we need to have a more simple API to edit a BlSpace, for example editSpace:'. self userData at: #pyramid_isOnEdition put: true. @@ -22,16 +24,16 @@ BlSpace >> editWithPyramid [ self root addChild: spacePlaceholder. "Add child into Pyramid to be edited" - editor projectModel roots addAll: elements. + editor projectModel firstLevelElements addAll: elements. editor window whenClosedDo: [ | pyramidRoots | - pyramidRoots := editor projectModel roots asArray. + pyramidRoots := editor projectModel firstLevelElements asArray. pyramidRoots do: [ :each | each hasParent ifTrue: [ each parent removeChild: each ] ]. - editor projectModel roots removeAll. + editor projectModel firstLevelElements removeAll. self root removeChildren. self root addChildren: pyramidRoots. - self userData removeKey: #pyramid_isOnEdition. ]. - + self userData removeKey: #pyramid_isOnEdition ]. + ^ editor ] diff --git a/src/Pyramid/PyramidProjectModel.class.st b/src/Pyramid/PyramidProjectModel.class.st index 3ce7ec45..f9f2e657 100644 --- a/src/Pyramid/PyramidProjectModel.class.st +++ b/src/Pyramid/PyramidProjectModel.class.st @@ -4,7 +4,7 @@ Class { #traits : 'TPyramidProjectModel', #classTraits : 'TPyramidProjectModel classTrait', #instVars : [ - 'roots', + 'firstLevelElements', 'selection' ], #category : #'Pyramid-models' @@ -14,22 +14,29 @@ Class { PyramidProjectModel >> allElements [ ^ PyramidElementsManipulationHelper flattenChildrenOfCollection: - self roots. + self firstLevelElements ] { #category : #accessing } -PyramidProjectModel >> initialize [ - - selection := PyramidCollectionWithCallbacks new. - roots := PyramidSortedCollectionWithCallbacks new sortFunction: PyramidElevationSortFunction new; yourself. +PyramidProjectModel >> firstLevelElements [ - selection subscribe: self withCallback: [ self informSelectionChanged ]. - roots subscribe: self withCallback: [ self informRootsChanged ] + ^ firstLevelElements ] { #category : #accessing } -PyramidProjectModel >> roots [ -^ roots +PyramidProjectModel >> initialize [ + + selection := PyramidCollectionWithCallbacks new. + firstLevelElements := PyramidSortedCollectionWithCallbacks new + sortFunction: PyramidElevationSortFunction new; + yourself. + + selection + subscribe: self + withCallback: [ self informSelectionChanged ]. + firstLevelElements + subscribe: self + withCallback: [ self informFirstLevelElementsChanged ] ] { #category : #selection } diff --git a/src/Pyramid/PyramidSelectionView.class.st b/src/Pyramid/PyramidSelectionView.class.st index 12b3c74b..380b9162 100644 --- a/src/Pyramid/PyramidSelectionView.class.st +++ b/src/Pyramid/PyramidSelectionView.class.st @@ -6,17 +6,17 @@ Class { #instVars : [ 'list', 'playground', - 'projectModel' + 'projectModel', + 'codeObjectInteractionModel', + 'contextLabel' ], #category : #'Pyramid-plugin-selection' } -{ #category : #'as yet unclassified' } -PyramidSelectionView >> connectPlaygroundTo: anObject [ +{ #category : #accessing } +PyramidSelectionView >> contextLabel [ - self playground interactionModel: - (SpCodeObjectInteractionModel on: anObject). - self flag: #TODO. "remplacer ici par un interraction model custom en changeant la méthode doItReceiver par la meme chose mais en envoyant avant un message commande custom." + ^ contextLabel ] { #category : #'as yet unclassified' } @@ -29,16 +29,30 @@ PyramidSelectionView >> currentSelection [ PyramidSelectionView >> defaultLayout [ ^ SpPanedLayout newVertical - add: self list; - add: self playground; + add: (SpBoxLayout newVertical + add: (SpLabelPresenter new + label: 'Selection'; + displayBold: [ :t | true ]; + yourself) expand: false; + add: self list; + yourself); + add: (SpBoxLayout newVertical + add: (SpLabelPresenter new + label: 'Playground'; + displayBold: [ :t | true ]; + yourself) expand: false; + add: self contextLabel expand: false; + add: self playground; + yourself); yourself ] { #category : #initialization } PyramidSelectionView >> initializePresenters [ - list := self newList. - playground := self newCode. + list := SpListPresenter new. + playground := PyramidSpCodePresenter new. + contextLabel := SpLabelPresenter new. ] { #category : #accessing } @@ -62,27 +76,21 @@ PyramidSelectionView >> projectModel: aPyramidActiveProject [ projectModel := aPyramidActiveProject. projectModel addObserver: self. - self updateSelection + self playground projectModel: aPyramidActiveProject. + + self pyramidSelectionChanged. ] { #category : #'as yet unclassified' } PyramidSelectionView >> pyramidSelectionChanged [ - self updateSelection + self list items: self currentSelection. + contextLabel label: self valueOfSelf. ] { #category : #'as yet unclassified' } -PyramidSelectionView >> updateSelection [ +PyramidSelectionView >> valueOfSelf [ - | currentSelection | - currentSelection := self currentSelection. - - self list items: currentSelection. - currentSelection ifEmpty: [ - self connectPlaygroundTo: nil. - ^ self ]. - currentSelection size = 1 ifTrue: [ - self connectPlaygroundTo: currentSelection first. - ^ self ]. - self connectPlaygroundTo: currentSelection + ^ 'self is <1s>' expandMacrosWith: + self playground interactionModel doItReceiverString ] diff --git a/src/Pyramid/PyramidSpCodeObjectInteractionModel.class.st b/src/Pyramid/PyramidSpCodeObjectInteractionModel.class.st new file mode 100644 index 00000000..1e6bd904 --- /dev/null +++ b/src/Pyramid/PyramidSpCodeObjectInteractionModel.class.st @@ -0,0 +1,46 @@ +Class { + #name : #PyramidSpCodeObjectInteractionModel, + #superclass : #SpCodeInteractionModel, + #instVars : [ + 'projectModel' + ], + #category : #'Pyramid-plugin-selection' +} + +{ #category : #accessing } +PyramidSpCodeObjectInteractionModel >> doItReceiver [ + + self projectModel selection ifEmpty: [ ^ self projectModel firstLevelElements ]. + self projectModel selection size = 1 ifTrue: [ + ^ self projectModel selection first ]. + ^ self projectModel selection +] + +{ #category : #accessing } +PyramidSpCodeObjectInteractionModel >> doItReceiverString [ + + self projectModel selection ifEmpty: [ + ^ 'the collection of first level elements' ]. + self projectModel selection size = 1 ifTrue: [ + ^ 'the selected element' ]. + ^ 'an array of <1p> selected elements' expandMacrosWith: + self projectModel selection size +] + +{ #category : #testing } +PyramidSpCodeObjectInteractionModel >> isScripting [ + + ^ true +] + +{ #category : #accessing } +PyramidSpCodeObjectInteractionModel >> projectModel [ + + ^ projectModel +] + +{ #category : #accessing } +PyramidSpCodeObjectInteractionModel >> projectModel: aPyramidActiveProject [ + + projectModel := aPyramidActiveProject +] diff --git a/src/Pyramid/PyramidSpCodePresenter.class.st b/src/Pyramid/PyramidSpCodePresenter.class.st new file mode 100644 index 00000000..e41ad189 --- /dev/null +++ b/src/Pyramid/PyramidSpCodePresenter.class.st @@ -0,0 +1,36 @@ +Class { + #name : #PyramidSpCodePresenter, + #superclass : #SpCodePresenter, + #category : #'Pyramid-plugin-selection' +} + +{ #category : #'command support' } +PyramidSpCodePresenter >> evaluate: aString onCompileError: compileErrorBlock onError: errorBlock [ + + | result | + result := super + evaluate: aString + onCompileError: compileErrorBlock + onError: errorBlock. + self projectModel informElementsChanged. + ^ result +] + +{ #category : #accessing } +PyramidSpCodePresenter >> initialize [ + + super initialize. + self interactionModel: PyramidSpCodeObjectInteractionModel new. +] + +{ #category : #accessing } +PyramidSpCodePresenter >> projectModel [ + + ^ self interactionModel projectModel +] + +{ #category : #accessing } +PyramidSpCodePresenter >> projectModel: aPyramidActiveProject [ + + self interactionModel projectModel: aPyramidActiveProject +] diff --git a/src/Pyramid/TPyramidProjectModel.trait.st b/src/Pyramid/TPyramidProjectModel.trait.st index 80c173ef..83695ae3 100644 --- a/src/Pyramid/TPyramidProjectModel.trait.st +++ b/src/Pyramid/TPyramidProjectModel.trait.st @@ -18,9 +18,9 @@ TPyramidProjectModel >> informElementsChanged [ ] { #category : #'as yet unclassified' } -TPyramidProjectModel >> informRootsChanged [ +TPyramidProjectModel >> informFirstLevelElementsChanged [ - self observers do: [ :each | each pyramidRootsChanged ] + self observers do: [ :each | each pyramidFirstLevelElementsChanged ] ] { #category : #'as yet unclassified' } diff --git a/src/Pyramid/TPyramidProjectModelObserver.trait.st b/src/Pyramid/TPyramidProjectModelObserver.trait.st index 21b2480a..c528ab1d 100644 --- a/src/Pyramid/TPyramidProjectModelObserver.trait.st +++ b/src/Pyramid/TPyramidProjectModelObserver.trait.st @@ -10,7 +10,9 @@ TPyramidProjectModelObserver >> pyramidElementsChanged [ ] { #category : #'as yet unclassified' } -TPyramidProjectModelObserver >> pyramidRootsChanged [ +TPyramidProjectModelObserver >> pyramidFirstLevelElementsChanged [ + + ] { #category : #'as yet unclassified' }