Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enh]: GT Action Blocks - Pass Described Object #365

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions source/Magritte-GToolkit/MAActionDescription.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Extension { #name : #MAActionDescription }
MAActionDescription >> gtAction: aValuable [
"aValuable - optional arguments:
- aGtPhlowNoAction (same as the argument to a standard GT action method)
- this description
- NB. the receiver is *not* passed as an argument, because it should be available in the description creation method"
- the receiver. Although it is available in the description creation method, it is a best practice not to use self in descriptions because descriptions are designed to be late bindable to any compatible object
- this description"

self flag: 'RE the last argument NB, the receiver SHOULD be passed, because descriptions are designed to be independent of model and applied to any compatible'.

Expand All @@ -20,17 +20,22 @@ MAActionDescription >> gtActionOf: anObject [
^ self
propertyAt: #gtAction
ifPresent: [ :valuable |
valuable cull: GtPhlowAction noAction cull: self ]
ifAbsent: [
| button icn |
button := GtPhlowAction noAction button.
self comment ifNotEmpty: [ :tt | button tooltip: tt ].
icn := self gtIcon ifNil: [ self icon ].
icn ifNotNil: [ :i | button icon: i ].
self isLabelVisible ifTrue: [ button label: self label ].
button
action: [ self performOn: anObject ];
yourself ].
valuable cull: GtPhlowAction noAction cull: anObject cull: self ]
ifAbsent: [ self gtButtonFor: anObject ].
]

{ #category : #'*Magritte-GToolkit' }
MAActionDescription >> gtButtonFor: anObject [

| button icn |
button := GtPhlowAction noAction button.
self comment ifNotEmpty: [ :tt | button tooltip: tt ].
icn := self gtIcon ifNil: [ self icon ].
icn ifNotNil: [ :i | button icon: i ].
self isLabelVisible ifTrue: [ button label: self label ].
^ button
action: [ self performOn: anObject ];
yourself.
]

{ #category : #'*Magritte-GToolkit' }
Expand Down
Loading