diff --git a/src/Pyramid-Bloc/PyramidBackgroundBlocPlugin.class.st b/src/Pyramid-Bloc/PyramidBackgroundBlocPlugin.class.st index 2e00e2be..efa43549 100644 --- a/src/Pyramid-Bloc/PyramidBackgroundBlocPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidBackgroundBlocPlugin.class.st @@ -676,7 +676,7 @@ PyramidBackgroundBlocPlugin >> addPanelsOn: aPyramidSimpleWindow [ aPyramidSimpleWindow at: #tabRight addItem: [ :builder | builder - makeTab: self propertiesManager presenter + makeTab: self propertiesManager mainPresenter label: 'Visuals' icon: (Smalltalk ui icons iconNamed: #box) order: 2 ] @@ -686,7 +686,8 @@ PyramidBackgroundBlocPlugin >> addPanelsOn: aPyramidSimpleWindow [ PyramidBackgroundBlocPlugin >> connectOn: aPyramidEditor [ propertiesManager projectModel: aPyramidEditor projectModel. - propertiesManager commandExecutor: aPyramidEditor propertiesManager commandExecutor + propertiesManager commandExecutor: + aPyramidEditor commandExecutor ] { #category : #initialization } diff --git a/src/Pyramid-Bloc/PyramidBackgroundTypeCommand.class.st b/src/Pyramid-Bloc/PyramidBackgroundTypeCommand.class.st index 5f263cb8..9031fa54 100644 --- a/src/Pyramid-Bloc/PyramidBackgroundTypeCommand.class.st +++ b/src/Pyramid-Bloc/PyramidBackgroundTypeCommand.class.st @@ -20,5 +20,5 @@ PyramidBackgroundTypeCommand >> getValueFor: aBlElement [ PyramidBackgroundTypeCommand >> setValueFor: aBlElement with: anArgument [ "Must be a blockClosure to ensure no background are created." - aBlElement background: anArgument value + aBlElement background: anArgument value value ] diff --git a/src/Pyramid-Bloc/PyramidBlocLayoutPlugin.class.st b/src/Pyramid-Bloc/PyramidBlocLayoutPlugin.class.st index a97ed8c2..0def65d9 100644 --- a/src/Pyramid-Bloc/PyramidBlocLayoutPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidBlocLayoutPlugin.class.st @@ -285,7 +285,7 @@ PyramidBlocLayoutPlugin >> addPanelsOn: aPyramidSimpleWindow [ aPyramidSimpleWindow at: #tabRight addItem: [ :builder | builder - makeTab: self propertiesManager presenter + makeTab: self propertiesManager mainPresenter label: 'Layout' icon: (Smalltalk ui icons iconNamed: #box) order: 3 ] @@ -296,7 +296,7 @@ PyramidBlocLayoutPlugin >> connectOn: aPyramidEditor [ propertiesManager projectModel: aPyramidEditor projectModel. propertiesManager commandExecutor: - aPyramidEditor propertiesManager commandExecutor + aPyramidEditor commandExecutor ] { #category : #initialization } diff --git a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st index acef6910..8d606241 100644 --- a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st @@ -5,7 +5,8 @@ Class { #classTraits : 'TPyramidPlugin classTrait', #instVars : [ 'editor', - 'groupCommand' + 'groupCommand', + 'propertiesManager' ], #category : #'Pyramid-Bloc-plugin-bloc' } @@ -100,6 +101,14 @@ PyramidBlocPlugin class >> zIndex [ { #category : #adding } PyramidBlocPlugin >> addPanelsOn: aPyramidSimpleWindow [ + + aPyramidSimpleWindow at: #tabRight addItem: [ :builder | + builder + makeTab: self propertiesManager mainPresenter + label: 'Properties' + icon: (Smalltalk ui icons iconNamed: #box) + order: 1 ]. + aPyramidSimpleWindow at: #selectionMenu addItem: [ :builder | self menuGroupOn: builder ]. @@ -111,16 +120,14 @@ PyramidBlocPlugin >> addPanelsOn: aPyramidSimpleWindow [ { #category : #connecting } PyramidBlocPlugin >> connectOn: aPyramidEditor [ - "Configure the sort function." - aPyramidEditor projectModel firstLevelElements sortFunction: PyramidElevationSortFunction new. - self editor: aPyramidEditor. - aPyramidEditor propertiesManager addProperty: self class elementId. - aPyramidEditor propertiesManager addProperty: self class visibility. - aPyramidEditor propertiesManager addProperty: self class zIndex. - aPyramidEditor propertiesManager addProperty: self class clipChildren. - aPyramidEditor propertiesManager addProperty: self class geometry. - aPyramidEditor propertiesManager addProperty: self class cornerRadii + + "Configure the sort function." + aPyramidEditor projectModel firstLevelElements sortFunction: + PyramidElevationSortFunction new. + + propertiesManager projectModel: aPyramidEditor projectModel. + propertiesManager commandExecutor: aPyramidEditor commandExecutor ] { #category : #accessing } @@ -139,7 +146,7 @@ PyramidBlocPlugin >> editor: anObject [ PyramidBlocPlugin >> groupCollection: aCollection [ self editor ifNil: [ ^ self ]. - self editor propertiesManager commandExecutor + self editor commandExecutor use: self groupCommand on: { aCollection } with: self editor projectModel firstLevelElements @@ -184,7 +191,18 @@ PyramidBlocPlugin >> groupMenuBlockSingle [ { #category : #initialization } PyramidBlocPlugin >> initialize [ - groupCommand := PyramidGroupCommand new + super initialize. + + groupCommand := PyramidGroupCommand new. + + propertiesManager := PyramidPropertiesManagerForSelection new. + + propertiesManager addProperty: self class elementId. + propertiesManager addProperty: self class visibility. + propertiesManager addProperty: self class zIndex. + propertiesManager addProperty: self class clipChildren. + propertiesManager addProperty: self class geometry. + propertiesManager addProperty: self class cornerRadii ] { #category : #'as yet unclassified' } @@ -236,11 +254,17 @@ PyramidBlocPlugin >> menuGroupOn: aBuilder [ aBuilder addGroupMultiSelection: self groupMenuBlockMulti order: 20 ] +{ #category : #accessing } +PyramidBlocPlugin >> propertiesManager [ + + ^ propertiesManager +] + { #category : #'as yet unclassified' } PyramidBlocPlugin >> send: aCommand on: aCollection [ self editor ifNil: [ ^ self ]. - self editor propertiesManager commandExecutor + self editor commandExecutor use: aCommand on: aCollection with: nil diff --git a/src/Pyramid-Bloc/PyramidBlocTextPlugin.class.st b/src/Pyramid-Bloc/PyramidBlocTextPlugin.class.st index 385fc993..28cb89ca 100644 --- a/src/Pyramid-Bloc/PyramidBlocTextPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidBlocTextPlugin.class.st @@ -64,8 +64,11 @@ 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 + | propertiesManager | + propertiesManager := (aPyramidEditor findPlugin: PyramidBlocPlugin)propertiesManager. + propertiesManager addProperty: self class changeText. + propertiesManager addProperty: self class fontSize. + propertiesManager addProperty: self class fontWeight. + propertiesManager addProperty: + self class textForeground ] diff --git a/src/Pyramid-Bloc/PyramidLibraryController.class.st b/src/Pyramid-Bloc/PyramidLibraryController.class.st index cefa8eb3..c82099b4 100644 --- a/src/Pyramid-Bloc/PyramidLibraryController.class.st +++ b/src/Pyramid-Bloc/PyramidLibraryController.class.st @@ -105,7 +105,7 @@ PyramidLibraryController >> openForRoot [ self addElementsBlock: [ :arrayOfElement | self renameElements: arrayOfElement. - self editor propertiesManager commandExecutor + self editor commandExecutor use: PyramidAddAllToCollectionCommand new on: { self editor projectModel firstLevelElements } with: arrayOfElement ]. diff --git a/src/Pyramid-Bloc/PyramidLibraryDefault.class.st b/src/Pyramid-Bloc/PyramidLibraryDefault.class.st index 80f1efb4..21f089a6 100644 --- a/src/Pyramid-Bloc/PyramidLibraryDefault.class.st +++ b/src/Pyramid-Bloc/PyramidLibraryDefault.class.st @@ -51,7 +51,7 @@ PyramidLibraryDefault >> pragmaCategory: aSymbol withIcon: anIcon [ method selector) materializeAsBlElement ]; yourself ]. PyramidLibraryCategory new - name: package name; + name: (package ifNil: [ '(nil)' ] ifNotNil: [ :p | p name ]); icon: anIcon; elements: (elements sorted: [ :a :b | a name < b name ]); yourself ]) sorted: [ :a :b | a name < b name ] diff --git a/src/Pyramid-Bloc/PyramidNavigationPlugin.class.st b/src/Pyramid-Bloc/PyramidNavigationPlugin.class.st index 38a6285b..bf15c4fc 100644 --- a/src/Pyramid-Bloc/PyramidNavigationPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidNavigationPlugin.class.st @@ -102,7 +102,7 @@ PyramidNavigationPlugin >> navigation [ { #category : #removing } PyramidNavigationPlugin >> removeSelectedElements [ - self editor propertiesManager commandExecutor + self editor commandExecutor use: PyramidRemoveSelectedElementsCommand new on: self editor projectModel selection with: self editor projectModel firstLevelElements. diff --git a/src/Pyramid-Bloc/PyramidNavigationTreePresenter.class.st b/src/Pyramid-Bloc/PyramidNavigationTreePresenter.class.st index 31ae702c..5bab04d8 100644 --- a/src/Pyramid-Bloc/PyramidNavigationTreePresenter.class.st +++ b/src/Pyramid-Bloc/PyramidNavigationTreePresenter.class.st @@ -154,10 +154,14 @@ PyramidNavigationTreePresenter >> treeTable [ { #category : #'as yet unclassified' } PyramidNavigationTreePresenter >> updateRoots [ - | roots parent shouldOrder | + | currentTreeRoots roots parent shouldOrder | self shouldUpdateSelection: false. roots := self editor projectModel firstLevelElements asArray. + currentTreeRoots := self treeTable roots. + + (roots size = currentTreeRoots size and: [ roots includesAll: currentTreeRoots ] )ifTrue: [ self shouldUpdateSelection: true. ^ self ]. + parent := nil. "If roots all have the same parent then it should be ordered by the parent children order." @@ -179,8 +183,15 @@ PyramidNavigationTreePresenter >> updateSelection [ self shouldUpdateSelection ifFalse: [ ^ self ]. self shouldUpdateSelection: false. [ - self treeTable unselectAll. - self editor projectModel selection ifNotEmpty: [ :e | - self treeTable selectItems: e ] ] ensure: [ + | currentTreeSelection requestedSelection | + currentTreeSelection := self treeTable selectedItems. + requestedSelection := self editor projectModel selection asArray. + requestedSelection + ifEmpty: [ self treeTable unselectAll ] + ifNotEmpty: [ + (currentTreeSelection size = requestedSelection size and: [ + currentTreeSelection includesAll: requestedSelection ]) ifTrue: [ self treeTable refresh ] ifFalse: [ + self treeTable unselectAll. + self treeTable selectItems: requestedSelection ] ] ] ensure: [ self shouldUpdateSelection: true ] ] diff --git a/src/Pyramid-Bloc/PyramidSelectionWidgetExtension.class.st b/src/Pyramid-Bloc/PyramidSelectionWidgetExtension.class.st index b2c83350..5464a016 100644 --- a/src/Pyramid-Bloc/PyramidSelectionWidgetExtension.class.st +++ b/src/Pyramid-Bloc/PyramidSelectionWidgetExtension.class.st @@ -83,7 +83,8 @@ PyramidSelectionWidgetExtension >> dragOrigin: anObject [ { #category : #accessing } PyramidSelectionWidgetExtension >> editor: aPyramidEditor [ - self commandExecutor: aPyramidEditor propertiesManager commandExecutor + self commandExecutor: + aPyramidEditor commandExecutor ] { #category : #events } diff --git a/src/Pyramid-Tests/PyramidEditorBuilderTest.class.st b/src/Pyramid-Tests/PyramidEditorBuilderTest.class.st index 76a3d469..a8e20dba 100644 --- a/src/Pyramid-Tests/PyramidEditorBuilderTest.class.st +++ b/src/Pyramid-Tests/PyramidEditorBuilderTest.class.st @@ -41,3 +41,119 @@ PyramidEditorBuilderTest >> testBuild2 [ self assert: plugin1 isInstalled. self deny: plugin2 isInstalled ] + +{ #category : #tests } +PyramidEditorBuilderTest >> testCommandExecutor [ + + | builder target1 target2 editor | + target1 := PyramidMainCommandExecutor new. + target2 := PyramidMainCommandExecutor new. + + "Default value is not nil" + builder := PyramidEditorBuilder new. + self assert: builder commandExecutor isNotNil. + + "editor is correctly set" + builder := PyramidEditorBuilder new. + builder commandExecutor: target1. + self assert: builder commandExecutor equals: target1. + editor := builder build. + self assert: editor commandExecutor equals: target1. + + "cannot set twice" + builder := PyramidEditorBuilder new. + builder commandExecutor: target1. + self assert: builder commandExecutor equals: target1. + [ + builder commandExecutor: target2. + self fail ] + on: PyramidBuilderAlreadyConfiguredError + do: [ self assert: true ] +] + +{ #category : #tests } +PyramidEditorBuilderTest >> testEditor [ + + | builder target1 target2 editor | + target1 := PyramidEditor new. + target2 := PyramidEditor new. + + "Default value is not nil" + builder := PyramidEditorBuilder new. + self assert: builder editor isNotNil. + + "editor is correctly set" + builder := PyramidEditorBuilder new. + builder editor: target1. + self assert: builder editor equals: target1. + editor := builder build. + self assert: editor equals: target1. + + "cannot set twice" + builder := PyramidEditorBuilder new. + builder editor: target1. + self assert: builder editor equals: target1. + [ + builder editor: target2. + self fail ] + on: PyramidBuilderAlreadyConfiguredError + do: [ self assert: true ] +] + +{ #category : #tests } +PyramidEditorBuilderTest >> testProjectModel [ + + | builder target1 target2 editor | + target1 := PyramidProjectModel new. + target2 := PyramidProjectModel new. + + "Default value is not nil" + builder := PyramidEditorBuilder new. + self assert: builder projectModel isNotNil. + + "editor is correctly set" + builder := PyramidEditorBuilder new. + builder projectModel: target1. + self assert: builder projectModel equals: target1. + editor := builder build. + self assert: editor projectModel equals: target1. + + "cannot set twice" + builder := PyramidEditorBuilder new. + builder projectModel: target1. + self assert: builder projectModel equals: target1. + [ + builder projectModel: target2. + self fail ] + on: PyramidBuilderAlreadyConfiguredError + do: [ self assert: true ] +] + +{ #category : #tests } +PyramidEditorBuilderTest >> testWindow [ + + | builder target1 target2 editor | + target1 := PyramidSimpleWindow new. + target2 := PyramidSimpleWindow new. + + "Default value is not nil" + builder := PyramidEditorBuilder new. + self assert: builder window isNotNil. + + "editor is correctly set" + builder := PyramidEditorBuilder new. + builder window: target1. + self assert: builder window equals: target1. + editor := builder build. + self assert: editor window equals: target1. + + "cannot set twice" + builder := PyramidEditorBuilder new. + builder window: target1. + self assert: builder window equals: target1. + [ + builder window: target2. + self fail ] + on: PyramidBuilderAlreadyConfiguredError + do: [ self assert: true ] +] diff --git a/src/Pyramid-Tests/PyramidFakePlugin1.class.st b/src/Pyramid-Tests/PyramidFakePlugin1.class.st new file mode 100644 index 00000000..c4cb4eb5 --- /dev/null +++ b/src/Pyramid-Tests/PyramidFakePlugin1.class.st @@ -0,0 +1,5 @@ +Class { + #name : #PyramidFakePlugin1, + #superclass : #PyramidFakePlugin, + #category : #'Pyramid-Tests-cases-core' +} diff --git a/src/Pyramid-Tests/PyramidFakePlugin2.class.st b/src/Pyramid-Tests/PyramidFakePlugin2.class.st new file mode 100644 index 00000000..f2431ef4 --- /dev/null +++ b/src/Pyramid-Tests/PyramidFakePlugin2.class.st @@ -0,0 +1,5 @@ +Class { + #name : #PyramidFakePlugin2, + #superclass : #PyramidFakePlugin, + #category : #'Pyramid-Tests-cases-core' +} diff --git a/src/Pyramid-Tests/PyramidFakePlugin3.class.st b/src/Pyramid-Tests/PyramidFakePlugin3.class.st new file mode 100644 index 00000000..c1e97451 --- /dev/null +++ b/src/Pyramid-Tests/PyramidFakePlugin3.class.st @@ -0,0 +1,5 @@ +Class { + #name : #PyramidFakePlugin3, + #superclass : #PyramidFakePlugin, + #category : #'Pyramid-Tests-cases-core' +} diff --git a/src/Pyramid-Tests/PyramidFakePresenterBuilder.class.st b/src/Pyramid-Tests/PyramidFakePresenterBuilder.class.st new file mode 100644 index 00000000..3110fba0 --- /dev/null +++ b/src/Pyramid-Tests/PyramidFakePresenterBuilder.class.st @@ -0,0 +1,20 @@ +Class { + #name : #PyramidFakePresenterBuilder, + #superclass : #Object, + #category : #'Pyramid-Tests-cases-property' +} + +{ #category : #building } +PyramidFakePresenterBuilder >> build [ + +] + +{ #category : #'accessing - structure variables' } +PyramidFakePresenterBuilder >> cluster: aPyramidCluster [ + +] + +{ #category : #accessing } +PyramidFakePresenterBuilder >> property: aPyramidProperty [ + +] diff --git a/src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st b/src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st index 5308dc28..b9c209b8 100644 --- a/src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st +++ b/src/Pyramid-Tests/PyramidPluginEditOnRunningTest.class.st @@ -59,17 +59,18 @@ PyramidPluginEditOnRunningTest >> testBlSpaceShortcutAddAndRemove [ { #category : #tests } PyramidPluginEditOnRunningTest >> testCannotEditTheEditor [ - | space editor | + | 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" + 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)). + self deny: + (space root shortcuts includes: PyramidPluginEditOnRunning shortcut) ] { #category : #tests } diff --git a/src/Pyramid-Tests/PyramidPropertiesManagerForTest.class.st b/src/Pyramid-Tests/PyramidPropertiesManagerForTest.class.st new file mode 100644 index 00000000..22d3786f --- /dev/null +++ b/src/Pyramid-Tests/PyramidPropertiesManagerForTest.class.st @@ -0,0 +1,19 @@ +Class { + #name : #PyramidPropertiesManagerForTest, + #superclass : #PyramidPropertiesManager, + #instVars : [ + 'presenterBuilder' + ], + #category : #'Pyramid-Tests-cases-property' +} + +{ #category : #'as yet unclassified' } +PyramidPropertiesManagerForTest >> presenterBuilder [ + + ^ presenterBuilder +] + +{ #category : #accessing } +PyramidPropertiesManagerForTest >> presenterBuilder: anObject [ + presenterBuilder:=anObject +] diff --git a/src/Pyramid-Tests/PyramidPropertiesManagerTest.class.st b/src/Pyramid-Tests/PyramidPropertiesManagerTest.class.st index 8a704bc4..baaae46c 100644 --- a/src/Pyramid-Tests/PyramidPropertiesManagerTest.class.st +++ b/src/Pyramid-Tests/PyramidPropertiesManagerTest.class.st @@ -1,14 +1,65 @@ Class { #name : #PyramidPropertiesManagerTest, #superclass : #TestCase, + #instVars : [ + 'commandExecutor', + 'presenterBuilder', + 'manager', + 'presenterStrategy', + 'prop1', + 'prop2', + 'prop3' + ], #category : #'Pyramid-Tests-cases-property' } -{ #category : #tests } -PyramidPropertiesManagerTest >> testAddAllProperties [ +{ #category : #accessing } +PyramidPropertiesManagerTest >> commandExecutor [ + + ^ commandExecutor +] + +{ #category : #accessing } +PyramidPropertiesManagerTest >> manager [ + + ^ manager +] + +{ #category : #accessing } +PyramidPropertiesManagerTest >> presenterBuilder [ + + ^ presenterBuilder +] + +{ #category : #accessing } +PyramidPropertiesManagerTest >> presenterStrategy [ + + ^ presenterStrategy +] + +{ #category : #accessing } +PyramidPropertiesManagerTest >> prop1 [ - | manager prop1 prop2 prop3 | - manager := PyramidPropertiesManager new commandExecutor: Object new; yourself. + ^ prop1 +] + +{ #category : #accessing } +PyramidPropertiesManagerTest >> prop2 [ + + ^ prop2 +] + +{ #category : #accessing } +PyramidPropertiesManagerTest >> prop3 [ + + ^ prop3 +] + +{ #category : #running } +PyramidPropertiesManagerTest >> setUp [ + + super setUp. + prop1 := PyramidProperty new name: 'Porp1'; command: PyramidSimpleMockCommand new; @@ -24,38 +75,44 @@ PyramidPropertiesManagerTest >> testAddAllProperties [ command: PyramidSimpleMockCommand new; pyramidInputPresenterClass: PyramidNumberInputPresenter; yourself. + + presenterStrategy := PyramidFakePropertyForTestStrategy new. + commandExecutor := PyramidMainCommandExecutor new. + presenterBuilder := PyramidFakePresenterBuilder new. + manager := PyramidPropertiesManagerForTest new + commandExecutor: commandExecutor; + presenterBuilder: presenterBuilder; + presenterStrategy: presenterStrategy; + yourself +] - manager addAllProperties: { prop1. prop2 . prop3 }. - self assert: (manager properties includes: prop1). - self assert: (manager properties includes: prop2). - self assert: (manager properties includes: prop3). - self assert: manager commandExecutor equals: prop1 commandExecutor. - self assert: manager commandExecutor equals: prop2 commandExecutor. - self assert: manager commandExecutor equals: prop3 commandExecutor. +{ #category : #tests } +PyramidPropertiesManagerTest >> testAddAllProperties [ + + self manager addAllProperties: { + prop1. + prop2. + prop3 }. + self assert: (self manager properties includes: prop1). + self assert: (self manager properties includes: prop2). + self assert: (self manager properties includes: prop3). + self + assert: self manager commandExecutor + equals: prop1 commandExecutor. + self + assert: self manager commandExecutor + equals: prop2 commandExecutor. + self + assert: self manager commandExecutor + equals: prop3 commandExecutor. + self assert: self presenterBuilder equals: prop1 presenterBuilder. + self assert: self presenterBuilder equals: prop2 presenterBuilder. + self assert: self presenterBuilder equals: prop3 presenterBuilder ] { #category : #tests } PyramidPropertiesManagerTest >> testAddProperty [ - | manager prop1 prop2 prop3 | - manager := PyramidPropertiesManager new commandExecutor: Object new; - yourself. - prop1 := PyramidProperty new - name: 'Porp1'; - command: PyramidSimpleMockCommand new; - pyramidInputPresenterClass: PyramidNumberInputPresenter; - yourself. - prop2 := PyramidProperty new - name: 'Porp2'; - command: PyramidSimpleMockCommand new; - pyramidInputPresenterClass: PyramidNumberInputPresenter; - yourself. - prop3 := PyramidProperty new - name: 'Porp3'; - command: PyramidSimpleMockCommand new; - pyramidInputPresenterClass: PyramidNumberInputPresenter; - yourself. - manager addProperty: prop1. manager addProperty: prop2. manager addProperty: prop3. @@ -64,69 +121,57 @@ PyramidPropertiesManagerTest >> testAddProperty [ self assert: (manager properties includes: prop3). self assert: manager commandExecutor equals: prop1 commandExecutor. self assert: manager commandExecutor equals: prop2 commandExecutor. - self assert: manager commandExecutor equals: prop3 commandExecutor + self assert: manager commandExecutor equals: prop3 commandExecutor. + self assert: self presenterBuilder equals: prop1 presenterBuilder. + self assert: self presenterBuilder equals: prop2 presenterBuilder. + self assert: self presenterBuilder equals: prop3 presenterBuilder ] { #category : #tests } PyramidPropertiesManagerTest >> testBuildPresenterFromCollection [ - | manager fakeStrategy prop1 prop2 prop3 targets | - targets := { -PyramidMockObjectForTest new count: 1; yourself. -PyramidMockObjectForTest new count: 2; yourself. -PyramidMockObjectForTest new count: 3; yourself. -PyramidMockObjectForTest new count: 4; yourself }. - fakeStrategy := PyramidFakePropertyForTestStrategy new. - manager := PyramidPropertiesManager new - presenterStrategy: fakeStrategy; - yourself. - - prop1 := PyramidProperty new name: 'Porp1'; command: PyramidSimpleMockCommand new ; pyramidInputPresenterClass: PyramidNumberInputPresenter ; yourself. - prop2 := PyramidProperty new name: 'Porp2'; command: PyramidSimpleMockCommand new ; pyramidInputPresenterClass: PyramidNumberInputPresenter ; yourself. - prop3 := PyramidProperty new name: 'Porp3'; command: PyramidSimpleMockCommand new ; pyramidInputPresenterClass: PyramidNumberInputPresenter ; yourself. - + | targets | + targets := { + (PyramidMockObjectForTest new + count: 1; + yourself). + (PyramidMockObjectForTest new + count: 2; + yourself). + (PyramidMockObjectForTest new + count: 3; + yourself). + (PyramidMockObjectForTest new + count: 4; + yourself) }. + manager addProperty: prop1. manager addProperty: prop2. manager addProperty: prop3. - + manager buildPresenterFromCollection: targets. - - self assert: fakeStrategy properties size equals: 3. - self assert: (fakeStrategy properties includes: prop1). - self assert: (fakeStrategy properties includes: prop2). - self assert: (fakeStrategy properties includes: prop3). + + self assert: self presenterStrategy properties size equals: 3. + self assert: (self presenterStrategy properties includes: prop1). + self assert: (self presenterStrategy properties includes: prop2). + self assert: (self presenterStrategy properties includes: prop3) ] { #category : #tests } PyramidPropertiesManagerTest >> testCommandExecutor [ - | manager prop1 prop2 prop3 fake1 fake2 | - fake1 := Object new. - manager := PyramidPropertiesManager new. - prop1 := PyramidProperty new - name: 'Porp1'; - command: PyramidSimpleMockCommand new; - pyramidInputPresenterClass: PyramidNumberInputPresenter; - yourself. - prop2 := PyramidProperty new - name: 'Porp2'; - command: PyramidSimpleMockCommand new; - pyramidInputPresenterClass: PyramidNumberInputPresenter; - yourself. + | fake1 fake2 | + fake1 := PyramidMainCommandExecutor new. + manager addProperty: prop1. manager addProperty: prop2. manager commandExecutor: fake1. self assert: prop1 commandExecutor equals: fake1. self assert: prop2 commandExecutor equals: fake1. - prop3 := PyramidProperty new - name: 'Porp3'; - command: PyramidSimpleMockCommand new; - pyramidInputPresenterClass: PyramidNumberInputPresenter; - yourself. manager addProperty: prop3. self assert: prop3 commandExecutor equals: fake1. - fake2 := Object new. + fake2 := PyramidMainCommandExecutor new. manager commandExecutor: fake2. self assert: prop1 commandExecutor equals: fake2. self assert: prop2 commandExecutor equals: fake2. @@ -136,25 +181,6 @@ PyramidPropertiesManagerTest >> testCommandExecutor [ { #category : #tests } PyramidPropertiesManagerTest >> testRemoveAllProperties [ - | manager prop1 prop2 prop3 | - manager := PyramidPropertiesManager new - commandExecutor: Object new; - yourself. - prop1 := PyramidProperty new - name: 'Porp1'; - command: PyramidSimpleMockCommand new; - pyramidInputPresenterClass: PyramidNumberInputPresenter; - yourself. - prop2 := PyramidProperty new - name: 'Porp2'; - command: PyramidSimpleMockCommand new; - pyramidInputPresenterClass: PyramidNumberInputPresenter; - yourself. - prop3 := PyramidProperty new - name: 'Porp3'; - command: PyramidSimpleMockCommand new; - pyramidInputPresenterClass: PyramidNumberInputPresenter; - yourself. manager addAllProperties: { prop1. @@ -169,32 +195,13 @@ PyramidPropertiesManagerTest >> testRemoveAllProperties [ manager removeAllProperties. self deny: (manager properties includes: prop1). self deny: (manager properties includes: prop2). - self deny: (manager properties includes: prop3). - + self deny: (manager properties includes: prop3) ] { #category : #tests } PyramidPropertiesManagerTest >> testRemoveProperty [ - | manager prop1 prop2 prop3 hasFailed | - manager := PyramidPropertiesManager new - commandExecutor: Object new; - yourself. - prop1 := PyramidProperty new - name: 'Porp1'; - command: PyramidSimpleMockCommand new; - pyramidInputPresenterClass: PyramidNumberInputPresenter; - yourself. - prop2 := PyramidProperty new - name: 'Porp2'; - command: PyramidSimpleMockCommand new; - pyramidInputPresenterClass: PyramidNumberInputPresenter; - yourself. - prop3 := PyramidProperty new - name: 'Porp3'; - command: PyramidSimpleMockCommand new; - pyramidInputPresenterClass: PyramidNumberInputPresenter; - yourself. + | hasFailed | manager addAllProperties: { prop1. diff --git a/src/Pyramid-Tests/PyramidSavingServiceTest.class.st b/src/Pyramid-Tests/PyramidSavingServiceTest.class.st index 807183b2..10fe4ce6 100644 --- a/src/Pyramid-Tests/PyramidSavingServiceTest.class.st +++ b/src/Pyramid-Tests/PyramidSavingServiceTest.class.st @@ -60,7 +60,7 @@ PyramidSavingServiceTest >> testCanSave [ | model | "Skip it if VM 11 because of bugs when deleting classes." - SystemVersion current major = 11 ifTrue: [ ^ self skip. ]. + SystemVersion current major = 11 ifTrue: [ ^ self skip ]. self deny: self savingService canSave. model := PyramidSaveModel new. diff --git a/src/Pyramid-Tests/TPyramidFindPluginTest.class.st b/src/Pyramid-Tests/TPyramidFindPluginTest.class.st new file mode 100644 index 00000000..baebf6d7 --- /dev/null +++ b/src/Pyramid-Tests/TPyramidFindPluginTest.class.st @@ -0,0 +1,85 @@ +Class { + #name : #TPyramidFindPluginTest, + #superclass : #TestCase, + #traits : 'TPyramidFindPlugin', + #classTraits : 'TPyramidFindPlugin classTrait', + #instVars : [ + 'object1', + 'object2', + 'object3' + ], + #category : #'Pyramid-Tests-cases-core' +} + +{ #category : #accessing } +TPyramidFindPluginTest >> object1 [ + + ^ object1 +] + +{ #category : #accessing } +TPyramidFindPluginTest >> object2 [ + + ^ object2 +] + +{ #category : #accessing } +TPyramidFindPluginTest >> object3 [ + + ^ object3 +] + +{ #category : #accessing } +TPyramidFindPluginTest >> plugins [ + "Return a collection of TPyramidPlugin instances." + + ^ { + self object1. + self object2. + self object3. + self object3 } +] + +{ #category : #accessing } +TPyramidFindPluginTest >> setUp [ + + super setUp. + + object1 := PyramidFakePlugin1 new. + object2 := PyramidFakePlugin2 new. + object3 := PyramidFakePlugin3 new +] + +{ #category : #tests } +TPyramidFindPluginTest >> testFindPlugin [ + + self + assert: (self findPlugin: PyramidFakePlugin1) + equals: self object1. + self + assert: (self findPlugin: #PyramidFakePlugin2) + equals: self object2. + [ + self findPlugin: #PyramidFakePlugin3. + self fail ] + on: PyramidMultiplePluginsFoundError + do: [ :err | + self assert: err plugins size equals: 2. + self assert: err plugins first equals: self object3. + self assert: err plugins last equals: self object3 ]. + [ + self findPlugin: PyramidFakePlugin3. + self fail ] + on: PyramidMultiplePluginsFoundError + do: [ :err | + self assert: err plugins size equals: 2. + self assert: err plugins first equals: self object3. + self assert: err plugins last equals: self object3 ]. + [ + self findPlugin: #PyramidFakePlugin4. + self fail ] + on: PyramidNoPluginFoundError + do: [ :err | + self assert: err query equals: #PyramidFakePlugin4. + ] +] diff --git a/src/Pyramid-Toplo/PyramidThemePresenter.class.st b/src/Pyramid-Toplo/PyramidThemePresenter.class.st index d77c8367..70d6bc07 100644 --- a/src/Pyramid-Toplo/PyramidThemePresenter.class.st +++ b/src/Pyramid-Toplo/PyramidThemePresenter.class.st @@ -6,7 +6,7 @@ Class { 'themeSpaceSelector', 'themeElementSelector' ], - #category : 'Pyramid-Toplo-plugin-theme-management' + #category : #'Pyramid-Toplo-plugin-theme-management' } { #category : #layout } @@ -25,7 +25,8 @@ PyramidThemePresenter >> editor: aPyramidEditor [ self themeSpaceSelector projectModel: aPyramidEditor projectModel. self themeElementSelector projectModel: aPyramidEditor projectModel. - self themeElementSelector commandExecutor: aPyramidEditor propertiesManager commandExecutor + self themeElementSelector commandExecutor: + aPyramidEditor commandExecutor ] { #category : #layout } diff --git a/src/Pyramid-Toplo/PyramidToploThemePlugin.class.st b/src/Pyramid-Toplo/PyramidToploThemePlugin.class.st index fa3f0d8a..32564fbe 100644 --- a/src/Pyramid-Toplo/PyramidToploThemePlugin.class.st +++ b/src/Pyramid-Toplo/PyramidToploThemePlugin.class.st @@ -154,7 +154,7 @@ PyramidToploThemePlugin >> initialize [ presenterStrategy: PyramidThemePropertyStrategy new; yourself. - themePresenter styleSheetEditor stampPresenter: themePropertyManager presenter + themePresenter styleSheetEditor stampPresenter: themePropertyManager mainPresenter ] { #category : #accessing } diff --git a/src/Pyramid/PyramidBuilderAlreadyConfiguredError.class.st b/src/Pyramid/PyramidBuilderAlreadyConfiguredError.class.st new file mode 100644 index 00000000..c1296472 --- /dev/null +++ b/src/Pyramid/PyramidBuilderAlreadyConfiguredError.class.st @@ -0,0 +1,5 @@ +Class { + #name : #PyramidBuilderAlreadyConfiguredError, + #superclass : #PyramidError, + #category : #'Pyramid-core' +} diff --git a/src/Pyramid/PyramidEditor.class.st b/src/Pyramid/PyramidEditor.class.st index f77eaa30..3a36da61 100644 --- a/src/Pyramid/PyramidEditor.class.st +++ b/src/Pyramid/PyramidEditor.class.st @@ -7,10 +7,10 @@ Class { 'plugins', 'projectModel', 'window', - 'propertiesManager', + 'commandExecutor', 'announcer' ], - #category : 'Pyramid-core' + #category : #'Pyramid-core' } { #category : #private } @@ -40,10 +40,16 @@ PyramidEditor >> close [ self window close ] -{ #category : #plugins } -PyramidEditor >> getPlugin: aPluginClass [ +{ #category : #accessing } +PyramidEditor >> commandExecutor [ - ^ self plugins detect:[ :p | p class = aPluginClass ] ifNone:[ ] + ^ commandExecutor +] + +{ #category : #accessing } +PyramidEditor >> commandExecutor: anObject [ + + commandExecutor := anObject ] { #category : #initialization } @@ -51,12 +57,14 @@ PyramidEditor >> initialize [ announcer := Announcer new. plugins := { }. - projectModel := PyramidProjectModel new editor: self; yourself. - propertiesManager := PyramidPropertiesManagerForSelection new - projectModel: projectModel; - yourself. - - + projectModel := PyramidProjectModel new + editor: self; + yourself. + commandExecutor := PyramidCallbackCommandExecutor new + afterDo: [ + self projectModel informElementsChanged ]; + wrappee: PyramidMainCommandExecutor new; + yourself ] { #category : #'open/close' } @@ -86,9 +94,10 @@ PyramidEditor >> projectModel [ ] { #category : #accessing } -PyramidEditor >> propertiesManager [ +PyramidEditor >> projectModel: anObject [ - ^ propertiesManager + projectModel := anObject. + projectModel editor: self. ] { #category : #accessing } @@ -107,10 +116,5 @@ PyramidEditor >> window [ PyramidEditor >> window: anObject [ window := anObject. - window at: #tabRight addItem: [ :builder | - builder - makeTab: self propertiesManager presenter - label: 'Properties' - icon: (Smalltalk ui icons iconNamed: #box) - order: 1 ] + ] diff --git a/src/Pyramid/PyramidEditorBuilder.class.st b/src/Pyramid/PyramidEditorBuilder.class.st index 0177e0e1..05ca869e 100644 --- a/src/Pyramid/PyramidEditorBuilder.class.st +++ b/src/Pyramid/PyramidEditorBuilder.class.st @@ -6,9 +6,11 @@ Class { #instVars : [ 'plugins', 'editor', - 'window' + 'window', + 'projectModel', + 'commandExecutor' ], - #category : 'Pyramid-core' + #category : #'Pyramid-core' } { #category : #building } @@ -21,22 +23,76 @@ PyramidEditorBuilder >> build [ self editor window: self window. self editor plugins: self plugins. + self editor projectModel: self projectModel. + self editor commandExecutor: self commandExecutor. self plugins do: [ :each | each addPanelsOn: self window ]. self plugins do: [ :each | each connectOn: self editor ]. ^ editor ] +{ #category : #accessing } +PyramidEditorBuilder >> commandExecutor [ + + commandExecutor ifNil: [ commandExecutor := self defaultCommandExecutor ]. + ^ commandExecutor +] + +{ #category : #accessing } +PyramidEditorBuilder >> commandExecutor: anObject [ + + commandExecutor ifNotNil: [ + PyramidBuilderAlreadyConfiguredError signal: + 'The commandExecutor is already set by another plugin.' ]. + commandExecutor := anObject +] + +{ #category : #default } +PyramidEditorBuilder >> defaultCommandExecutor [ + + ^ PyramidCallbackCommandExecutor new + afterDo: [ self projectModel informElementsChanged ]; + wrappee: PyramidMainCommandExecutor new; yourself +] + +{ #category : #default } +PyramidEditorBuilder >> defaultEditor [ + + ^ PyramidEditor new +] + +{ #category : #default } +PyramidEditorBuilder >> defaultProjectModel [ + + ^ PyramidProjectModel new +] + +{ #category : #default } +PyramidEditorBuilder >> defaultWindow [ + + ^ PyramidSimpleWindow new +] + { #category : #accessing } PyramidEditorBuilder >> editor [ -editor ifNil: [ editor := PyramidEditor new ]. - ^ editor + editor ifNil: [ editor := self defaultEditor ]. + ^ editor +] + +{ #category : #accessing } +PyramidEditorBuilder >> editor: anObject [ + + editor ifNotNil: [ + PyramidBuilderAlreadyConfiguredError signal: + 'The editor is already set by another plugin.' ]. + editor := anObject ] { #category : #accessing } PyramidEditorBuilder >> plugins [ + plugins ifNil: [ plugins := { } ]. ^ plugins ] @@ -46,19 +102,33 @@ PyramidEditorBuilder >> plugins: anObject [ plugins := anObject ] -{ #category : #building } -PyramidEditorBuilder >> window [ +{ #category : #accessing } +PyramidEditorBuilder >> projectModel [ -window ifNil: [ window := PyramidSimpleWindow new ]. -^ window + projectModel ifNil: [ projectModel := self defaultProjectModel ]. + ^ projectModel +] - +{ #category : #accessing } +PyramidEditorBuilder >> projectModel: aPyramidWindow [ + + projectModel ifNotNil: [ + PyramidBuilderAlreadyConfiguredError signal: + 'The projectModel is already set by another plugin !' ]. + projectModel := aPyramidWindow ] -{ #category : #building } +{ #category : #accessing } +PyramidEditorBuilder >> window [ + + window ifNil: [ window := self defaultWindow ]. + ^ window +] + +{ #category : #accessing } PyramidEditorBuilder >> window: aPyramidWindow [ window ifNotNil: [ - Error signal: 'The window is already set by another plugin !' ]. + PyramidBuilderAlreadyConfiguredError signal: 'The window is already set by another plugin !' ]. window := aPyramidWindow ] diff --git a/src/Pyramid/PyramidHistoryPlugin.class.st b/src/Pyramid/PyramidHistoryPlugin.class.st index 54e8d3c3..990ac2e9 100644 --- a/src/Pyramid/PyramidHistoryPlugin.class.st +++ b/src/Pyramid/PyramidHistoryPlugin.class.st @@ -9,7 +9,7 @@ Class { 'history', 'projectModel' ], - #category : 'Pyramid-history' + #category : #'Pyramid-history' } { #category : #adding } @@ -25,12 +25,26 @@ PyramidHistoryPlugin >> addPanelsOn: aPyramidSimpleWindow [ builder makeButtonWithIcon: self redoButton order: 20 ] ] +{ #category : #actions } +PyramidHistoryPlugin >> configureBuilder: aPyramidEditorBuilder [ + + | historyExecutor executor mainExecutor | + historyExecutor := PyramidHistoryCommandExecutor new + history: self history; + yourself. + + executor := aPyramidEditorBuilder commandExecutor. + mainExecutor := executor wrappee. + + executor wrappee: historyExecutor. + historyExecutor wrappee: mainExecutor +] + { #category : #connecting } PyramidHistoryPlugin >> connectOn: aPyramidEditor [ - self history: aPyramidEditor propertiesManager history. self projectModel: aPyramidEditor projectModel. - self pyramidElementsChanged: nil. + self pyramidElementsChanged: nil ] { #category : #accessing } @@ -48,12 +62,13 @@ PyramidHistoryPlugin >> history: anObject [ { #category : #'as yet unclassified' } PyramidHistoryPlugin >> initialize [ + history := PyramidHistory new. undoButton := SpButtonPresenter new icon: (Smalltalk ui icons iconNamed: #smallUndo); action: [ self history undo. self projectModel informElementsChanged ]; - enabled: false; + enabled: false; help: 'Undo'; yourself. redoButton := SpButtonPresenter new @@ -61,7 +76,7 @@ PyramidHistoryPlugin >> initialize [ action: [ self history redo. self projectModel informElementsChanged ]; - enabled: false; + enabled: false; help: 'Redo'; yourself ] diff --git a/src/Pyramid/PyramidProjectModel.class.st b/src/Pyramid/PyramidProjectModel.class.st index 0fc5a122..1d53fa03 100644 --- a/src/Pyramid/PyramidProjectModel.class.st +++ b/src/Pyramid/PyramidProjectModel.class.st @@ -6,7 +6,7 @@ Class { 'firstLevelElements', 'selection' ], - #category : 'Pyramid-models' + #category : #'Pyramid-models' } { #category : #'as yet unclassified' } @@ -42,10 +42,10 @@ PyramidProjectModel >> firstLevelElements [ { #category : #'as yet unclassified' } PyramidProjectModel >> informElementsChanged [ - self announce: (PyramidElementsChangedEvent new - firstLevelElements: self firstLevelElements; - selection: self selection; - yourself) + self announce: (PyramidElementsChangedEvent new + firstLevelElements: self firstLevelElements; + selection: self selection; + yourself) ] { #category : #'as yet unclassified' } diff --git a/src/Pyramid/PyramidPropertiesManager.class.st b/src/Pyramid/PyramidPropertiesManager.class.st index bc4c20bc..05c437b0 100644 --- a/src/Pyramid/PyramidPropertiesManager.class.st +++ b/src/Pyramid/PyramidPropertiesManager.class.st @@ -7,7 +7,7 @@ Class { 'presenterStrategy', 'history' ], - #category : 'Pyramid-property' + #category : #'Pyramid-property' } { #category : #removing } @@ -20,6 +20,7 @@ PyramidPropertiesManager >> addAllProperties: aCollection [ PyramidPropertiesManager >> addProperty: aPyramidProperty [ aPyramidProperty commandExecutor: self commandExecutor. + aPyramidProperty presenterBuilder: self presenterBuilder. self properties add: aPyramidProperty ] @@ -61,6 +62,12 @@ PyramidPropertiesManager >> initialize [ presenterStrategy := PyramidHideEmptyPropertyStrategy new ] +{ #category : #'as yet unclassified' } +PyramidPropertiesManager >> presenterBuilder [ + + ^ self shouldBeImplemented +] + { #category : #accessing } PyramidPropertiesManager >> presenterStrategy [ diff --git a/src/Pyramid/PyramidPropertiesManagerForSelection.class.st b/src/Pyramid/PyramidPropertiesManagerForSelection.class.st index 60a4f063..b1bc7746 100644 --- a/src/Pyramid/PyramidPropertiesManagerForSelection.class.st +++ b/src/Pyramid/PyramidPropertiesManagerForSelection.class.st @@ -2,17 +2,18 @@ Class { #name : #PyramidPropertiesManagerForSelection, #superclass : #PyramidPropertiesManager, #instVars : [ - 'presenter', + 'mainPresenter', 'shouldComputeProperties', - 'projectModel' + 'projectModel', + 'popupPresenter' ], - #category : 'Pyramid-property' + #category : #'Pyramid-property' } { #category : #'as yet unclassified' } PyramidPropertiesManagerForSelection >> computeProperties: aCollection [ - self presenter layout child: + self mainPresenter layout child: (self buildPresenterFromCollection: aCollection). self shouldComputeProperties: false ] @@ -22,21 +23,37 @@ PyramidPropertiesManagerForSelection >> initialize [ super initialize. shouldComputeProperties := false. - presenter := SpPresenter new - layout: SpScrollableLayout new; - whenVisibleChangedDo: [ :isVisible | - isVisible ifTrue: [ self computeProperties: self projectModel selection ] ]; - yourself. - commandExecutor := PyramidCallbackCommandExecutor new - wrappee: commandExecutor; - yourself. - commandExecutor afterDo: [ self projectModel informElementsChanged ] + mainPresenter := SpPresenter new + layout: SpScrollableLayout new; + whenVisibleChangedDo: [ :isVisible | + isVisible ifTrue: [ + self computeProperties: + self projectModel selection ] ]; + yourself. + popupPresenter := PyramidSinglePropertyPopupPresenter new + originPresenter: mainPresenter; + popoverDirection: SpPopoverPosition left; + yourself. ] { #category : #accessing } -PyramidPropertiesManagerForSelection >> presenter [ +PyramidPropertiesManagerForSelection >> mainPresenter [ - ^ presenter + ^ mainPresenter +] + +{ #category : #accessing } +PyramidPropertiesManagerForSelection >> popupPresenter [ + + ^ popupPresenter +] + +{ #category : #'as yet unclassified' } +PyramidPropertiesManagerForSelection >> presenterBuilder [ + + ^ PyramidSinglePopingPresenterBuilder new + popupPanel: self popupPresenter; + yourself ] { #category : #accessing } @@ -63,7 +80,7 @@ PyramidPropertiesManagerForSelection >> projectModel: aPyramidProjectModel [ PyramidPropertiesManagerForSelection >> selectionOrElementsChanged: anEvent [ self shouldComputeProperties: true. - self presenter isVisible ifFalse: [ ^ self ]. + self mainPresenter isVisible ifFalse: [ ^ self ]. self computeProperties: anEvent selection ] diff --git a/src/Pyramid/PyramidProperty.class.st b/src/Pyramid/PyramidProperty.class.st index 22eeaad6..907bba7c 100644 --- a/src/Pyramid/PyramidProperty.class.st +++ b/src/Pyramid/PyramidProperty.class.st @@ -9,7 +9,7 @@ Class { 'name', 'pyramidInputPresenterStrings' ], - #category : 'Pyramid-property' + #category : #'Pyramid-property' } { #category : #'as yet unclassified' } @@ -48,7 +48,6 @@ PyramidProperty >> commandExecutor: anObject [ { #category : #initialization } PyramidProperty >> initialize [ - presenterBuilder := PyramidPopingPresenterBuilder new. name := 'Default property name' ] diff --git a/src/Pyramid/PyramidPopingPresenterBuilder.class.st b/src/Pyramid/PyramidSinglePopingPresenterBuilder.class.st similarity index 65% rename from src/Pyramid/PyramidPopingPresenterBuilder.class.st rename to src/Pyramid/PyramidSinglePopingPresenterBuilder.class.st index ac7cf9b0..17c8000e 100644 --- a/src/Pyramid/PyramidPopingPresenterBuilder.class.st +++ b/src/Pyramid/PyramidSinglePopingPresenterBuilder.class.st @@ -1,61 +1,52 @@ -" -I transform a `PyramidCluster` and a `NeoPyramidProperty` into a `SpPresenter`. - -I create a presenter with a main input to change property of all element at once and a button to show a popup with properties in group and in individual. - -" Class { - #name : #PyramidPopingPresenterBuilder, + #name : #PyramidSinglePopingPresenterBuilder, #superclass : #PyramidPropertyPresenterBuilder, - #category : 'Pyramid-property' + #instVars : [ + 'popupPanel' + ], + #category : #'Pyramid-property' } { #category : #'as yet unclassified' } -PyramidPopingPresenterBuilder >> build [ +PyramidSinglePopingPresenterBuilder >> build [ - | presenterAll presentersGrouped presentersIndividual layout | + | presenterAll layout | presenterAll := self buildPresenterAll. self cluster size > 1 ifTrue: [ - presentersGrouped := self buildPresentersGrouped. - presentersIndividual := self buildPresentersIndividual. - layout := self - buildLayoutAll: presenterAll - grouped: presentersGrouped - individual: presentersIndividual ] + layout := self buildLayoutAllGroupedAndIndividual: presenterAll ] ifFalse: [ layout := self buildLayoutOnlyForAll: presenterAll ]. ^ SpPresenter new layout: layout; - yourself. + yourself ] { #category : #'as yet unclassified' } -PyramidPopingPresenterBuilder >> buildLayoutAll: presenterAll grouped: presentersGrouped individual: presentersIndividual [ - - | presenterPopup buttonPopup | - presenterPopup := PyramidPropertyPopupPresenter new - name: self property name - grouped: presentersGrouped - individual: presentersIndividual; - yourself. +PyramidSinglePopingPresenterBuilder >> buildLayoutAllGroupedAndIndividual: presenterAll [ + | buttonPopup | buttonPopup := SpButtonPresenter new icon: (Smalltalk ui icons iconNamed: #edit); - help: 'Show groups and individuals values'; + help: 'Show groups and individuals values'; yourself. buttonPopup action: [ - (PyramidPopoverFactory - makeWithPresenter: presenterPopup - relativeTo: buttonPopup - position: SpPopoverPosition left) popup ]. + self popupPanel lastPropertyShown: self property. + self popupPanel + name: self property name + grouped: self buildPresentersGrouped + individual: self buildPresentersIndividual. + self popupPanel popup ]. + + self updatePopupPanel. + ^ self layoutForAll: presenterAll buttonPopup: buttonPopup ] { #category : #'as yet unclassified' } -PyramidPopingPresenterBuilder >> buildLayoutOnlyForAll: presenterAll [ +PyramidSinglePopingPresenterBuilder >> buildLayoutOnlyForAll: presenterAll [ | buttonPopup | buttonPopup := SpButtonPresenter new @@ -67,7 +58,7 @@ PyramidPopingPresenterBuilder >> buildLayoutOnlyForAll: presenterAll [ ] { #category : #'as yet unclassified' } -PyramidPopingPresenterBuilder >> buildPresenterAll [ +PyramidSinglePopingPresenterBuilder >> buildPresenterAll [ | input | input := self makeNewInput. @@ -89,7 +80,7 @@ PyramidPopingPresenterBuilder >> buildPresenterAll [ ] { #category : #'as yet unclassified' } -PyramidPopingPresenterBuilder >> buildPresenterWithButtonsFor: anAssociation withLabel: aString [ +PyramidSinglePopingPresenterBuilder >> buildPresenterWithButtonsFor: anAssociation withLabel: aString [ | input buttonApplyToAll layout | input := self makeNewInput. @@ -118,7 +109,7 @@ PyramidPopingPresenterBuilder >> buildPresenterWithButtonsFor: anAssociation wit ] { #category : #'as yet unclassified' } -PyramidPopingPresenterBuilder >> buildPresentersGrouped [ +PyramidSinglePopingPresenterBuilder >> buildPresentersGrouped [ | size label | self cluster isEmpty ifTrue: [ ^ { } ]. @@ -131,7 +122,7 @@ PyramidPopingPresenterBuilder >> buildPresentersGrouped [ ] { #category : #'as yet unclassified' } -PyramidPopingPresenterBuilder >> buildPresentersIndividual [ +PyramidSinglePopingPresenterBuilder >> buildPresentersIndividual [ | label | self cluster isEmpty ifTrue: [ ^ { } ]. @@ -141,7 +132,7 @@ PyramidPopingPresenterBuilder >> buildPresentersIndividual [ ] { #category : #'as yet unclassified' } -PyramidPopingPresenterBuilder >> layoutForAll: presenterAll buttonPopup: buttonPopup [ +PyramidSinglePopingPresenterBuilder >> layoutForAll: presenterAll buttonPopup: buttonPopup [ ^ SpBoxLayout newVertical spacing: 4; @@ -160,7 +151,7 @@ PyramidPopingPresenterBuilder >> layoutForAll: presenterAll buttonPopup: buttonP ] { #category : #'as yet unclassified' } -PyramidPopingPresenterBuilder >> layoutForLabel: aString input: anInput button: aButton [ +PyramidSinglePopingPresenterBuilder >> layoutForLabel: aString input: anInput button: aButton [ ^ SpBoxLayout newHorizontal spacing: 4; @@ -172,9 +163,31 @@ PyramidPopingPresenterBuilder >> layoutForLabel: aString input: anInput button: ] { #category : #'as yet unclassified' } -PyramidPopingPresenterBuilder >> makeNewInput [ +PyramidSinglePopingPresenterBuilder >> makeNewInput [ ^ self property pyramidInputPresenterClass new strings: self property pyramidInputPresenterStrings; yourself ] + +{ #category : #'as yet unclassified' } +PyramidSinglePopingPresenterBuilder >> popupPanel [ + + ^ popupPanel +] + +{ #category : #'as yet unclassified' } +PyramidSinglePopingPresenterBuilder >> popupPanel: anObject [ + + popupPanel := anObject +] + +{ #category : #'as yet unclassified' } +PyramidSinglePopingPresenterBuilder >> updatePopupPanel [ + + self popupPanel lastPropertyShown = self property ifFalse: [ ^ self ]. + self popupPanel + name: self property name + grouped: self buildPresentersGrouped + individual: self buildPresentersIndividual +] diff --git a/src/Pyramid/PyramidPropertyPopupPresenter.class.st b/src/Pyramid/PyramidSinglePropertyPopupPresenter.class.st similarity index 54% rename from src/Pyramid/PyramidPropertyPopupPresenter.class.st rename to src/Pyramid/PyramidSinglePropertyPopupPresenter.class.st index afb43214..c36b1b59 100644 --- a/src/Pyramid/PyramidPropertyPopupPresenter.class.st +++ b/src/Pyramid/PyramidSinglePropertyPopupPresenter.class.st @@ -1,60 +1,63 @@ Class { - #name : #PyramidPropertyPopupPresenter, + #name : #PyramidSinglePropertyPopupPresenter, #superclass : #SpPresenter, #instVars : [ 'buttonIndividual', 'buttonGroup', 'individualPresenters', 'groupedPresenters', - 'name' + 'name', + 'originPresenter', + 'popoverDirection', + 'lastPropertyShown' ], - #category : 'Pyramid-property' + #category : #'Pyramid-property' } { #category : #accessing } -PyramidPropertyPopupPresenter >> buttonGroup [ +PyramidSinglePropertyPopupPresenter >> buttonGroup [ ^ buttonGroup ] { #category : #accessing } -PyramidPropertyPopupPresenter >> buttonIndividual [ +PyramidSinglePropertyPopupPresenter >> buttonIndividual [ ^ buttonIndividual ] { #category : #layout } -PyramidPropertyPopupPresenter >> defaultLayout [ +PyramidSinglePropertyPopupPresenter >> defaultLayout [ ^ SpBoxLayout newVertical ] { #category : #accessing } -PyramidPropertyPopupPresenter >> groupedPresenters [ +PyramidSinglePropertyPopupPresenter >> groupedPresenters [ ^ groupedPresenters ] { #category : #accessing } -PyramidPropertyPopupPresenter >> groupedPresenters: anObject [ +PyramidSinglePropertyPopupPresenter >> groupedPresenters: anObject [ groupedPresenters := anObject ] { #category : #accessing } -PyramidPropertyPopupPresenter >> individualPresenters [ +PyramidSinglePropertyPopupPresenter >> individualPresenters [ ^ individualPresenters ] { #category : #accessing } -PyramidPropertyPopupPresenter >> individualPresenters: anObject [ +PyramidSinglePropertyPopupPresenter >> individualPresenters: anObject [ individualPresenters := anObject ] { #category : #'initialization - deprecated' } -PyramidPropertyPopupPresenter >> initializePresenters [ +PyramidSinglePropertyPopupPresenter >> initializePresenters [ individualPresenters := { }. groupedPresenters := { }. @@ -73,8 +76,20 @@ PyramidPropertyPopupPresenter >> initializePresenters [ buttonGroup whenActivatedDo: [ self showGroupPresenter ] ] +{ #category : #accessing } +PyramidSinglePropertyPopupPresenter >> lastPropertyShown [ + + ^ lastPropertyShown +] + +{ #category : #accessing } +PyramidSinglePropertyPopupPresenter >> lastPropertyShown: anObject [ + + lastPropertyShown := anObject +] + { #category : #'as yet unclassified' } -PyramidPropertyPopupPresenter >> layoutWith: aCollection [ +PyramidSinglePropertyPopupPresenter >> layoutWith: aCollection [ | inputsLayout scroll | inputsLayout := SpBoxLayout newVertical @@ -101,29 +116,29 @@ PyramidPropertyPopupPresenter >> layoutWith: aCollection [ label: self name; displayBold: [ :t | true ]; yourself) - width: 150; + width: self popupExtent x; add: self buttonGroup width: 75; add: self buttonIndividual width: 75; yourself) expand: false; - add: scroll height: 300; + add: scroll height: self popupExtent y; yourself ] { #category : #accessing } -PyramidPropertyPopupPresenter >> name [ +PyramidSinglePropertyPopupPresenter >> name [ ^ name ] { #category : #accessing } -PyramidPropertyPopupPresenter >> name: anObject [ +PyramidSinglePropertyPopupPresenter >> name: anObject [ name := anObject ] { #category : #'as yet unclassified' } -PyramidPropertyPopupPresenter >> name: aString grouped: groupedCollection individual: individualCollection [ +PyramidSinglePropertyPopupPresenter >> name: aString grouped: groupedCollection individual: individualCollection [ self name: aString. self individualPresenters: individualCollection. @@ -132,14 +147,53 @@ PyramidPropertyPopupPresenter >> name: aString grouped: groupedCollection indivi self buttonGroup state ifTrue: [ self showGroupPresenter ] ifFalse: [ self showIndividualPresenter ]. ] +{ #category : #accessing } +PyramidSinglePropertyPopupPresenter >> originPresenter [ + + ^ originPresenter +] + +{ #category : #accessing } +PyramidSinglePropertyPopupPresenter >> originPresenter: anObject [ + + originPresenter := anObject +] + +{ #category : #accessing } +PyramidSinglePropertyPopupPresenter >> popoverDirection [ + + ^ popoverDirection +] + +{ #category : #accessing } +PyramidSinglePropertyPopupPresenter >> popoverDirection: anObject [ + + popoverDirection := anObject +] + +{ #category : #api } +PyramidSinglePropertyPopupPresenter >> popup [ + + (PyramidPopoverFactory + makeWithPresenter: self + relativeTo: self originPresenter + position: self popoverDirection) popup +] + +{ #category : #'as yet unclassified' } +PyramidSinglePropertyPopupPresenter >> popupExtent [ + + ^ 250 @ 500 +] + { #category : #'as yet unclassified' } -PyramidPropertyPopupPresenter >> showGroupPresenter [ +PyramidSinglePropertyPopupPresenter >> showGroupPresenter [ self layout: (self layoutWith: self groupedPresenters). ] { #category : #'as yet unclassified' } -PyramidPropertyPopupPresenter >> showIndividualPresenter [ +PyramidSinglePropertyPopupPresenter >> showIndividualPresenter [ self layout: (self layoutWith: self individualPresenters) ]