Skip to content

Commit

Permalink
Merge pull request #201 from OpenSmock/Issue_0090
Browse files Browse the repository at this point in the history
  • Loading branch information
labordep authored Aug 3, 2024
2 parents 94d2092 + bb413b6 commit 05aef3f
Show file tree
Hide file tree
Showing 32 changed files with 754 additions and 266 deletions.
5 changes: 3 additions & 2 deletions src/Pyramid-Bloc/PyramidBackgroundBlocPlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand All @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion src/Pyramid-Bloc/PyramidBackgroundTypeCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
4 changes: 2 additions & 2 deletions src/Pyramid-Bloc/PyramidBlocLayoutPlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand All @@ -296,7 +296,7 @@ PyramidBlocLayoutPlugin >> connectOn: aPyramidEditor [

propertiesManager projectModel: aPyramidEditor projectModel.
propertiesManager commandExecutor:
aPyramidEditor propertiesManager commandExecutor
aPyramidEditor commandExecutor
]

{ #category : #initialization }
Expand Down
50 changes: 37 additions & 13 deletions src/Pyramid-Bloc/PyramidBlocPlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Class {
#classTraits : 'TPyramidPlugin classTrait',
#instVars : [
'editor',
'groupCommand'
'groupCommand',
'propertiesManager'
],
#category : #'Pyramid-Bloc-plugin-bloc'
}
Expand Down Expand Up @@ -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 ].
Expand All @@ -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 }
Expand All @@ -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
Expand Down Expand Up @@ -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' }
Expand Down Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions src/Pyramid-Bloc/PyramidBlocTextPlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
2 changes: 1 addition & 1 deletion src/Pyramid-Bloc/PyramidLibraryController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 ].
Expand Down
2 changes: 1 addition & 1 deletion src/Pyramid-Bloc/PyramidLibraryDefault.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down
2 changes: 1 addition & 1 deletion src/Pyramid-Bloc/PyramidNavigationPlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 15 additions & 4 deletions src/Pyramid-Bloc/PyramidNavigationTreePresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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 ]
]
3 changes: 2 additions & 1 deletion src/Pyramid-Bloc/PyramidSelectionWidgetExtension.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ PyramidSelectionWidgetExtension >> dragOrigin: anObject [
{ #category : #accessing }
PyramidSelectionWidgetExtension >> editor: aPyramidEditor [

self commandExecutor: aPyramidEditor propertiesManager commandExecutor
self commandExecutor:
aPyramidEditor commandExecutor
]

{ #category : #events }
Expand Down
116 changes: 116 additions & 0 deletions src/Pyramid-Tests/PyramidEditorBuilderTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
]
5 changes: 5 additions & 0 deletions src/Pyramid-Tests/PyramidFakePlugin1.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #PyramidFakePlugin1,
#superclass : #PyramidFakePlugin,
#category : #'Pyramid-Tests-cases-core'
}
5 changes: 5 additions & 0 deletions src/Pyramid-Tests/PyramidFakePlugin2.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #PyramidFakePlugin2,
#superclass : #PyramidFakePlugin,
#category : #'Pyramid-Tests-cases-core'
}
5 changes: 5 additions & 0 deletions src/Pyramid-Tests/PyramidFakePlugin3.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #PyramidFakePlugin3,
#superclass : #PyramidFakePlugin,
#category : #'Pyramid-Tests-cases-core'
}
20 changes: 20 additions & 0 deletions src/Pyramid-Tests/PyramidFakePresenterBuilder.class.st
Original file line number Diff line number Diff line change
@@ -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 [

]
Loading

0 comments on commit 05aef3f

Please sign in to comment.