Skip to content

Commit 4fd057b

Browse files
committed
GtPhlowToolCommonViewModel [feenkcom/gtoolkit#3422]
1 parent 5e1c0dd commit 4fd057b

7 files changed

+235
-1
lines changed

src/GToolkit-Phlow/GtPhlowCompositeTool.class.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ GtPhlowCompositeTool >> asElementDo: aOneArgBlock [
4343
aptitude: BrGlamorousTabGroupSwitcherAptitude;
4444
addTabs: self toolTabs.
4545
aTabGroup addEventHandler: GtPhlowToolObjectChangeHandler new.
46+
aTabGroup phlow toolViewModel: (GtPhlowToolCompositeViewModel new tabGroup: aTabGroup).
4647

4748
^ aOneArgBlock cull: aTabGroup
4849
]

src/GToolkit-Phlow/GtPhlowElementContext.class.st

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Class {
1515
'isPopupContainer',
1616
'isException',
1717
'isTool',
18-
'isToolLabel'
18+
'isToolLabel',
19+
'toolViewModel'
1920
],
2021
#category : #'GToolkit-Phlow-Context'
2122
}
@@ -25,6 +26,15 @@ GtPhlowElementContext class >> on: anElement [
2526
^ self new element: anElement
2627
]
2728

29+
{ #category : #'api - tool view model' }
30+
GtPhlowElementContext >> accessTool: aType viewModel: aViewModelSelector object: anObjectSelector [
31+
toolViewModel := GtPhlowToolCommonViewModel new
32+
context: self;
33+
type: aType;
34+
viewModelSelector: aViewModelSelector;
35+
objectSelector: anObjectSelector
36+
]
37+
2838
{ #category : #accessing }
2939
GtPhlowElementContext >> activePhlowContexts [
3040
^ {
@@ -398,6 +408,19 @@ GtPhlowElementContext >> textViewContent [
398408
ifFound: [:editorElement | editorElement editor text ]
399409
]
400410

411+
{ #category : #'api - tool view model' }
412+
GtPhlowElementContext >> toolViewModel [
413+
"Return a tool view model"
414+
415+
<return: #TGtPhlowToolViewModel>
416+
^ toolViewModel
417+
]
418+
419+
{ #category : #'api - tool view model' }
420+
GtPhlowElementContext >> toolViewModel: anObject [
421+
toolViewModel := anObject
422+
]
423+
401424
{ #category : #'api - updating' }
402425
GtPhlowElementContext >> update [
403426
self asyncUpdate
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Class {
2+
#name : #GtPhlowToolClassType,
3+
#superclass : #Object,
4+
#traits : 'TGtPhlowToolType',
5+
#classTraits : 'TGtPhlowToolType classTrait',
6+
#instVars : [
7+
'type'
8+
],
9+
#category : #'GToolkit-Phlow-Tool - Navigation'
10+
}
11+
12+
{ #category : #'instance creation' }
13+
GtPhlowToolClassType class >> forClass: aClass [
14+
^ self new type: aClass
15+
]
16+
17+
{ #category : #printing }
18+
GtPhlowToolClassType >> gtDisplayOn: aStream [
19+
self type gtDisplayOn: aStream
20+
]
21+
22+
{ #category : #accessing }
23+
GtPhlowToolClassType >> type [
24+
^ type
25+
]
26+
27+
{ #category : #accessing }
28+
GtPhlowToolClassType >> type: anObject [
29+
type := anObject
30+
]
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
Class {
2+
#name : #GtPhlowToolCommonViewModel,
3+
#superclass : #Object,
4+
#traits : 'TGtPhlowToolViewModel',
5+
#classTraits : 'TGtPhlowToolViewModel classTrait',
6+
#instVars : [
7+
'context',
8+
'viewModelSelector',
9+
'objectSelector',
10+
'type'
11+
],
12+
#category : #'GToolkit-Phlow-Tool - Navigation'
13+
}
14+
15+
{ #category : #accessing }
16+
GtPhlowToolCommonViewModel >> context [
17+
<return: #GtPhlowElementContext>
18+
^ context
19+
]
20+
21+
{ #category : #accessing }
22+
GtPhlowToolCommonViewModel >> context: anObject [
23+
context := anObject
24+
]
25+
26+
{ #category : #'api - accessing' }
27+
GtPhlowToolCommonViewModel >> element [
28+
^ self context element
29+
]
30+
31+
{ #category : #'api - accessing' }
32+
GtPhlowToolCommonViewModel >> object [
33+
"Return a tool view model"
34+
35+
^ self element perform: self objectSelector
36+
]
37+
38+
{ #category : #accessing }
39+
GtPhlowToolCommonViewModel >> objectSelector [
40+
^ objectSelector
41+
]
42+
43+
{ #category : #accessing }
44+
GtPhlowToolCommonViewModel >> objectSelector: anObject [
45+
objectSelector := anObject
46+
]
47+
48+
{ #category : #accessing }
49+
GtPhlowToolCommonViewModel >> type [
50+
^ type
51+
]
52+
53+
{ #category : #accessing }
54+
GtPhlowToolCommonViewModel >> type: anObject [
55+
type := anObject
56+
]
57+
58+
{ #category : #'api - accessing' }
59+
GtPhlowToolCommonViewModel >> viewModel [
60+
"Return a tool view model"
61+
62+
^ self element perform: self viewModelSelector
63+
]
64+
65+
{ #category : #accessing }
66+
GtPhlowToolCommonViewModel >> viewModelSelector [
67+
^ viewModelSelector
68+
]
69+
70+
{ #category : #accessing }
71+
GtPhlowToolCommonViewModel >> viewModelSelector: anObject [
72+
viewModelSelector := anObject
73+
]
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Class {
2+
#name : #GtPhlowToolCompositeViewModel,
3+
#superclass : #Object,
4+
#traits : 'TGtPhlowToolViewModel',
5+
#classTraits : 'TGtPhlowToolViewModel classTrait',
6+
#instVars : [
7+
'tabGroup'
8+
],
9+
#category : #'GToolkit-Phlow-Tool - Navigation'
10+
}
11+
12+
{ #category : #'api - accessing' }
13+
GtPhlowToolCompositeViewModel >> element [
14+
^ tabGroup
15+
childWithId: #content
16+
ifFound: [ :anElement | anElement children at: 1 ifAbsent: [ nil ] ]
17+
ifNone: [ nil ]
18+
]
19+
20+
{ #category : #'api - accessing' }
21+
GtPhlowToolCompositeViewModel >> object [
22+
^ self element
23+
ifNotNil: [ :anElement | anElement phlow toolViewModel ifNotNil: #object ]
24+
]
25+
26+
{ #category : #accessing }
27+
GtPhlowToolCompositeViewModel >> tabGroup [
28+
<return: #BrTabGroup>
29+
^ tabGroup
30+
]
31+
32+
{ #category : #accessing }
33+
GtPhlowToolCompositeViewModel >> tabGroup: aBrTabGroup [
34+
tabGroup := aBrTabGroup
35+
]
36+
37+
{ #category : #'api - accessing' }
38+
GtPhlowToolCompositeViewModel >> type [
39+
^ self element
40+
ifNotNil: [ :anElement | anElement phlow toolViewModel ifNotNil: #type ]
41+
]
42+
43+
{ #category : #'api - accessing' }
44+
GtPhlowToolCompositeViewModel >> viewModel [
45+
^ self element
46+
ifNotNil: [ :anElement | anElement phlow toolViewModel ifNotNil: #viewModel ]
47+
]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Trait {
2+
#name : #TGtPhlowToolType,
3+
#category : #'GToolkit-Phlow-Tool - Navigation'
4+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Trait {
2+
#name : #TGtPhlowToolViewModel,
3+
#category : #'GToolkit-Phlow-Tool - Navigation'
4+
}
5+
6+
{ #category : #'api - accessing' }
7+
TGtPhlowToolViewModel >> element [
8+
^ self explicitRequirement
9+
]
10+
11+
{ #category : #'gt - extensions' }
12+
TGtPhlowToolViewModel >> gtOverview [
13+
^ {
14+
GtPhlowOverviewItem new
15+
name: 'Tool type';
16+
value: self type.
17+
GtPhlowOverviewItem new
18+
name: 'Tool element';
19+
value: self element.
20+
GtPhlowOverviewItem new
21+
name: 'Tool view model';
22+
value: self viewModel.
23+
GtPhlowOverviewItem new
24+
name: 'Tool model object';
25+
value: self object}
26+
]
27+
28+
{ #category : #'gt - extensions' }
29+
TGtPhlowToolViewModel >> gtOverviewFor: aView [
30+
<gtView>
31+
^ aView columnedList
32+
title: 'Overview';
33+
priority: 0;
34+
items: [ self gtOverview ];
35+
column: 'Name'
36+
text: #name
37+
weight: 0.3;
38+
column: 'Value' text: #description;
39+
send: #value
40+
]
41+
42+
{ #category : #'api - accessing' }
43+
TGtPhlowToolViewModel >> object [
44+
^ self explicitRequirement
45+
]
46+
47+
{ #category : #'api - accessing' }
48+
TGtPhlowToolViewModel >> type [
49+
<return: #TGtPhlowToolType>
50+
^ self explicitRequirement
51+
]
52+
53+
{ #category : #'api - accessing' }
54+
TGtPhlowToolViewModel >> viewModel [
55+
^ self explicitRequirement
56+
]

0 commit comments

Comments
 (0)