Skip to content

Commit

Permalink
Merge pull request magritte-metamodel#279 from seandenigris/feature_r…
Browse files Browse the repository at this point in the history
…elation-spotter

[Feature]: Bloc ToOne Relations Spotter Support
  • Loading branch information
seandenigris committed May 29, 2022
2 parents d09e3a4 + 0cec232 commit f94580c
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 2 deletions.
19 changes: 17 additions & 2 deletions source/Magritte-GToolkit/MAElementBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,23 @@ MAElementBuilder >> visitToManyScalarRelationDescription: anObject [
]

{ #category : #'visiting-description' }
MAElementBuilder >> visitToOneRelationDescription: anObject [
self visitRelationDescription: anObject
MAElementBuilder >> visitToOneRelationDescription: aDescription [
| inputElement valueLabel searchButton |

aDescription gtSearchSource ifNil: [ ^ self visitRelationDescription: aDescription ].

inputElement := MATokenCollectorElement new
relationDescription: aDescription;
tokenClickAction: [ :evt |
(self object readUsing: aDescription)
ifNotNil: [ :obj | evt target phlow spawnObject: obj ] ];
spotterAction: [ :evt :colElem |
aDescription write: evt element to: self memento.
colElem valueLabel text: (self textUsing: aDescription) ].

inputElement valueLabel text: (self textUsing: aDescription).

self addInputField: inputElement using: aDescription
]

{ #category : #'visiting-description' }
Expand Down
95 changes: 95 additions & 0 deletions source/Magritte-GToolkit/MATokenCollectorElement.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
Class {
#name : #MATokenCollectorElement,
#superclass : #BrHorizontalPane,
#instVars : [
'relationDescription',
'spotterAction',
'tokenClickAction',
'valueLabel'
],
#category : #'Magritte-GToolkit-Widgets'
}

{ #category : #initialization }
MATokenCollectorElement >> initialize [

| searchButton |
super initialize.

self
hMatchParent;
padding: (BlInsets top: 4 bottom: 4);
alignCenterLeft;
cellSpacing: 5;
vFitContent.

valueLabel := BrLabel new
aptitude: BrGlamorousLabelAptitude;
beSmallSize;
addEventHandlerOn: BlClickEvent
do: [ :evt | self tokenClickAction cull: evt ];
yourself.

searchButton := GtSpotterDropdownButtonStencil new
valuable: [ self relationDescription gtSearchSource value ];
icon: BrGlamorousVectorIcons search;
spotterModelDo: [ :sm |
sm announcer
when: GtSpotterActOn
do: [ :evt |
self spotterAction cull: evt cull: self.
evt actedUpon: true ] ];
create.

self
addChild: valueLabel;
addChild: searchButton.
]

{ #category : #accessing }
MATokenCollectorElement >> relationDescription [

^ relationDescription
]

{ #category : #accessing }
MATokenCollectorElement >> relationDescription: anObject [

relationDescription := anObject
]

{ #category : #accessing }
MATokenCollectorElement >> spotterAction [

^ spotterAction
]

{ #category : #accessing }
MATokenCollectorElement >> spotterAction: anObject [

spotterAction := anObject
]

{ #category : #accessing }
MATokenCollectorElement >> tokenClickAction [

^ tokenClickAction
]

{ #category : #accessing }
MATokenCollectorElement >> tokenClickAction: anObject [

tokenClickAction := anObject
]

{ #category : #accessing }
MATokenCollectorElement >> valueLabel [

^ valueLabel
]

{ #category : #accessing }
MATokenCollectorElement >> valueLabel: anObject [

valueLabel := anObject
]
10 changes: 10 additions & 0 deletions source/Magritte-Model/MAReferenceDescription.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ MAReferenceDescription >> descriptionReference [
yourself
]

{ #category : #accessing }
MAReferenceDescription >> gtSearchSource [
^ self propertyAt: #gtSearchSource ifAbsent: [ nil ]
]

{ #category : #accessing }
MAReferenceDescription >> gtSearchSource: valuable [
self propertyAt: #gtSearchSource put: valuable
]

{ #category : #accessing }
MAReferenceDescription >> initializer [
^ self propertyAt: #initializer ifAbsent: [ #yourself ]
Expand Down

0 comments on commit f94580c

Please sign in to comment.