Skip to content

Commit

Permalink
Add a single popover panel on the top of the screen + lazy load the g…
Browse files Browse the repository at this point in the history
…rouped and single properties.
  • Loading branch information
Nyan11 committed Jul 31, 2024
1 parent 94d2092 commit 16c4d24
Show file tree
Hide file tree
Showing 6 changed files with 442 additions and 11 deletions.
24 changes: 18 additions & 6 deletions src/Pyramid/PyramidPopingPresenterBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ I create a presenter with a main input to change property of all element at once
Class {
#name : #PyramidPopingPresenterBuilder,
#superclass : #PyramidPropertyPresenterBuilder,
#category : 'Pyramid-property'
#instVars : [
'popupFactory'
],
#category : #'Pyramid-property'
}

{ #category : #'as yet unclassified' }
Expand Down Expand Up @@ -43,14 +46,11 @@ PyramidPopingPresenterBuilder >> buildLayoutAll: presenterAll grouped: presenter

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 popupFactory value: presenterPopup value: buttonPopup) popup ].
^ self layoutForAll: presenterAll buttonPopup: buttonPopup
]

Expand Down Expand Up @@ -178,3 +178,15 @@ PyramidPopingPresenterBuilder >> makeNewInput [
strings: self property pyramidInputPresenterStrings;
yourself
]

{ #category : #'as yet unclassified' }
PyramidPopingPresenterBuilder >> popupFactory [

^ popupFactory
]

{ #category : #'as yet unclassified' }
PyramidPopingPresenterBuilder >> popupFactory: anObject [

popupFactory := anObject
]
9 changes: 8 additions & 1 deletion src/Pyramid/PyramidPropertiesManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Class {
'presenterStrategy',
'history'
],
#category : 'Pyramid-property'
#category : #'Pyramid-property'
}

{ #category : #removing }
Expand All @@ -20,6 +20,7 @@ PyramidPropertiesManager >> addAllProperties: aCollection [
PyramidPropertiesManager >> addProperty: aPyramidProperty [

aPyramidProperty commandExecutor: self commandExecutor.
aPyramidProperty presenterBuilder: self makePresenterBuilder.
self properties add: aPyramidProperty
]

Expand Down Expand Up @@ -61,6 +62,12 @@ PyramidPropertiesManager >> initialize [
presenterStrategy := PyramidHideEmptyPropertyStrategy new
]

{ #category : #'as yet unclassified' }
PyramidPropertiesManager >> makePresenterBuilder [

^ self shouldBeImplemented
]

{ #category : #accessing }
PyramidPropertiesManager >> presenterStrategy [

Expand Down
16 changes: 15 additions & 1 deletion src/Pyramid/PyramidPropertiesManagerForSelection.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Class {
'shouldComputeProperties',
'projectModel'
],
#category : 'Pyramid-property'
#category : #'Pyramid-property'
}

{ #category : #'as yet unclassified' }
Expand All @@ -33,6 +33,20 @@ PyramidPropertiesManagerForSelection >> initialize [
commandExecutor afterDo: [ self projectModel informElementsChanged ]
]

{ #category : #'as yet unclassified' }
PyramidPropertiesManagerForSelection >> makePresenterBuilder [

| popupPanel |
popupPanel := PyramidSinglePropertyPopupPresenter new
originPresenter: self presenter;
popoverDirection: SpPopoverPosition left;
yourself.

^ PyramidSinglePopingPresenterBuilder new
popupPanel: popupPanel;
yourself
]

{ #category : #accessing }
PyramidPropertiesManagerForSelection >> presenter [

Expand Down
12 changes: 9 additions & 3 deletions src/Pyramid/PyramidPropertyPopupPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Class {
'groupedPresenters',
'name'
],
#category : 'Pyramid-property'
#category : #'Pyramid-property'
}

{ #category : #accessing }
Expand Down Expand Up @@ -101,12 +101,12 @@ 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
]

Expand All @@ -132,6 +132,12 @@ PyramidPropertyPopupPresenter >> name: aString grouped: groupedCollection indivi
self buttonGroup state ifTrue: [ self showGroupPresenter ] ifFalse: [ self showIndividualPresenter ].
]

{ #category : #'as yet unclassified' }
PyramidPropertyPopupPresenter >> popupExtent [

^ 250 @ 500
]

{ #category : #'as yet unclassified' }
PyramidPropertyPopupPresenter >> showGroupPresenter [

Expand Down
193 changes: 193 additions & 0 deletions src/Pyramid/PyramidSinglePopingPresenterBuilder.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
Class {
#name : #PyramidSinglePopingPresenterBuilder,
#superclass : #PyramidPropertyPresenterBuilder,
#instVars : [
'popupPanel'
],
#category : #'Pyramid-property'
}

{ #category : #'as yet unclassified' }
PyramidSinglePopingPresenterBuilder >> build [

| presenterAll layout |
presenterAll := self buildPresenterAll.

self cluster size > 1
ifTrue: [
layout := self buildLayoutAllGroupedAndIndividual: presenterAll ]
ifFalse: [ layout := self buildLayoutOnlyForAll: presenterAll ].

^ SpPresenter new
layout: layout;
yourself
]

{ #category : #'as yet unclassified' }
PyramidSinglePopingPresenterBuilder >> buildLayoutAllGroupedAndIndividual: presenterAll [

| buttonPopup |
buttonPopup := SpButtonPresenter new
icon: (Smalltalk ui icons iconNamed: #edit);
help: 'Show groups and individuals values';
yourself.

buttonPopup action: [
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' }
PyramidSinglePopingPresenterBuilder >> buildLayoutOnlyForAll: presenterAll [

| buttonPopup |
buttonPopup := SpButtonPresenter new
icon: (Smalltalk ui icons iconNamed: #edit);
enabled: false;
yourself.

^ self layoutForAll: presenterAll buttonPopup: buttonPopup
]

{ #category : #'as yet unclassified' }
PyramidSinglePopingPresenterBuilder >> buildPresenterAll [

| input |
input := self makeNewInput.

self cluster isEmpty ifTrue: [
input emptyValue.
^ input ].

self cluster isTargetsSameArguments
ifTrue: [ input value: self cluster groups first ]
ifFalse: [ input mixedValues ].

input whenValueChangedDo: [ :value |
self property commandExecutor
use: self property command
on: self cluster allTargets
with: value ].
^ input
]

{ #category : #'as yet unclassified' }
PyramidSinglePopingPresenterBuilder >> buildPresenterWithButtonsFor: anAssociation withLabel: aString [

| input buttonApplyToAll layout |
input := self makeNewInput.
input value: anAssociation key.
input whenValueChangedDo: [ :value |
self property commandExecutor
use: self property command
on: anAssociation value
with: value ].

buttonApplyToAll := SpButtonPresenter new
icon: (Smalltalk ui icons iconNamed: #smallExpert);
help: 'Apply this value to all selected elements.';
action: [
self property commandExecutor
use: self property command
on: self cluster allTargets
with: input value ].
layout := self
layoutForLabel: aString
input: input
button: buttonApplyToAll.
^ SpPresenter new
layout: layout;
yourself
]

{ #category : #'as yet unclassified' }
PyramidSinglePopingPresenterBuilder >> buildPresentersGrouped [

| size label |
self cluster isEmpty ifTrue: [ ^ { } ].
^ self cluster groupedAssociations associations collect: [ :each |
size := each value size.
label := size = 1
ifTrue: [ '1 element' ]
ifFalse: [ size printString , ' elements' ].
self buildPresenterWithButtonsFor: each withLabel: label ]
]

{ #category : #'as yet unclassified' }
PyramidSinglePopingPresenterBuilder >> buildPresentersIndividual [

| label |
self cluster isEmpty ifTrue: [ ^ { } ].
^ self cluster individualAssociations collect: [ :each |
label := each value first hash printString.
self buildPresenterWithButtonsFor: each withLabel: label ]
]

{ #category : #'as yet unclassified' }
PyramidSinglePopingPresenterBuilder >> layoutForAll: presenterAll buttonPopup: buttonPopup [

^ SpBoxLayout newVertical
spacing: 4;
add: (SpBoxLayout newHorizontal
spacing: 4;
vAlignCenter;
add: buttonPopup width: 24;
add: (SpLabelPresenter new
label: self property name;
displayBold: [ :t | true ];
yourself);
yourself)
height: 24;
add: presenterAll expand: false;
yourself
]

{ #category : #'as yet unclassified' }
PyramidSinglePopingPresenterBuilder >> layoutForLabel: aString input: anInput button: aButton [

^ SpBoxLayout newHorizontal
spacing: 4;
vAlignCenter;
add: aString width: 80;
add: anInput;
add: aButton width: 24;
yourself
]

{ #category : #'as yet unclassified' }
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
]
Loading

0 comments on commit 16c4d24

Please sign in to comment.