Add half of a coder

This commit is contained in:
2022-04-17 21:39:50 +02:00
parent 64a8353006
commit 8f48fc25c3
4 changed files with 77 additions and 55 deletions

View File

@@ -7,6 +7,11 @@ Class {
#category : #'Carp-IDE' #category : #'Carp-IDE'
} }
{ #category : #accessing }
CarpExpression >> asElement [
^ (GtCarpCoderModel new sourceCode: (GtCoderExplicitStringSource new source: self toCarp)) asElement
]
{ #category : #accessing } { #category : #accessing }
CarpExpression >> documentation [ CarpExpression >> documentation [
^ documentation ifNil: [''] ^ documentation ifNil: ['']

View File

@@ -52,16 +52,16 @@ CarpModule >> carpCoderCommentsFor: aView [
action: [ :aToggle :aTab | action: [ :aToggle :aTab |
self documentation: self documentation:
aTab viewContentElement children first text asString ]; aTab viewContentElement children first text asString ];
actionUpdateButtonTooltip: 'Update documentation' actionButtonIcon: BrGlamorousVectorIcons cancel
tooltip: 'Discard documentation'
action: [ :aToggle :aTab |
aTab viewContentElement children first text: self documentation ]
] ]
{ #category : #accessing } { #category : #accessing }
CarpModule >> carpCoderStreamingMethodsFor: aView context: aPhlowContext [ CarpModule >> carpCoderStreamingMethodsFor: aView context: aPhlowContext [
<gtModuleView> <gtModuleView>
| aMethodsCoder aMethodsCoderViewModel aNewMethodCoderHolder | | aMethodsCoder aMethodsCoderViewModel aNewMethodCoderHolder |
aMethodsCoder := GtStreamingCodersModel new.
aMethodsCoderViewModel := GtStreamingCodersViewModel new streamingCodersModel: aMethodsCoder.
aNewMethodCoderHolder := ValueHolder new. aNewMethodCoderHolder := ValueHolder new.
@@ -109,7 +109,12 @@ CarpModule >> carpCoderStreamingMethodsFor: aView context: aPhlowContext [
padding: (BlInsets all: 5); padding: (BlInsets all: 5);
addAptitude: BrGlamorousFocusableShadowAptitude new ]; addAptitude: BrGlamorousFocusableShadowAptitude new ];
name: #'button--add-new-expression']; name: #'button--add-new-expression'];
stencil: [ CarpStreamingMethodsCoderElement new streamingCodersViewModel: aMethodsCoderViewModel ] stencil: [ CarpStreamingMethodsCoderElement forModule: self ]
]
{ #category : #accessing }
CarpModule >> expressions [
^ expressions
] ]
{ #category : #initialization } { #category : #initialization }

View File

@@ -46,49 +46,47 @@ CarpModuleCoderElement >> buildDefinitionElement [
{ #category : #accessing } { #category : #accessing }
CarpModuleCoderElement >> buildModuleLabel [ CarpModuleCoderElement >> buildModuleLabel [
| classCoder aModuleNameEditor aContainer aPreviewButton removeClassButton | | classCoder aModuleNameEditor aContainer aPreviewButton removeClassButton |
aContainer := BrHorizontalPane new aContainer := BrHorizontalPane new
hMatchParent; hMatchParent;
alignCenterLeft; alignCenterLeft;
vFitContent. vFitContent.
aModuleNameEditor := BrEditableLabel new aModuleNameEditor := BrEditableLabel new
aptitude: (BrGlamorousEditableLabelAptitude new aptitude:
defaultBackground: Color transparent; (BrGlamorousEditableLabelAptitude new
glamorousCodeFont; defaultBackground: Color transparent;
bold; glamorousCodeFont;
fontSize: 18); bold;
inputFilter: BrTextEditorClassNameInputFilter new; fontSize: 18);
text: self module name; text: self module name;
margin: (BlInsets all: 0); margin: (BlInsets all: 0);
id: GtBehaviorCoderBehaviorNameId; id: GtBehaviorCoderBehaviorNameId;
whenKey: BlKeyCombination primaryG whenKey: BlKeyCombination primaryG
labelDo: [ :aShortcutEvent | self phlow spawnObject: self module ]; labelDo: [ :aShortcutEvent |
whenKey: BlKeyCombination primaryR self phlow spawnObject: self module ];
labelDo: [ :aShortcutEvent | aShortcutEvent currentTarget switchToEditor ]; whenKey: BlKeyCombination primaryR
whenKey: BlKeyCombination primaryC labelDo: [ :aShortcutEvent |
labelDo: [ :aShortcutEvent | Clipboard clipboardText: self module name asString ]. aShortcutEvent currentTarget switchToEditor ];
whenKey: BlKeyCombination primaryC
aPreviewButton := BrButton new labelDo: [ :aShortcutEvent |
id: CarpCoderBehaviorNameApplyPreviewId; Clipboard clipboardText:
margin: (BlInsets left: 5); self module name asString ];
addAptitude: BrGlamorousButtonWithIconAptitude; when: BrEditorAcceptWish
icon: BrGlamorousVectorIcons accept; do: [ :aWish |
action: [self module name: aModuleNameEditor text]. self module name: aWish text asString ].
aModuleNameEditor editor
when: BrTextEditorModifiedEvent
do: [ :anEvent |
anEvent text asString trimBoth asSymbol = self module name
ifTrue: [ aContainer removeChild: aPreviewButton ]
ifFalse: [
"show preview button when name is modified"
(aContainer hasChild: aPreviewButton)
ifFalse: [ aContainer addChild: aPreviewButton after: aModuleNameEditor ] ] ].
aContainer addChild: aModuleNameEditor. aContainer addChild: aModuleNameEditor.
aContainer addChild: (BrButton new
aptitude: BrGlamorousButtonWithIconAptitude;
icon: BrGlamorousVectorIcons play;
beSmallSize;
label: 'Generate source';
action: [ :aButton |
aButton phlow spawnObject: self module toCarp ]).
^ aContainer ^ aContainer
] ]

View File

@@ -4,28 +4,42 @@ Class {
#traits : 'TBrLayoutResizable + TGtWithStreamingCodersViewModel', #traits : 'TBrLayoutResizable + TGtWithStreamingCodersViewModel',
#classTraits : 'TBrLayoutResizable classTrait + TGtWithStreamingCodersViewModel classTrait', #classTraits : 'TBrLayoutResizable classTrait + TGtWithStreamingCodersViewModel classTrait',
#instVars : [ #instVars : [
'listItemsProvider', 'list',
'list' 'module'
], ],
#category : #'Carp-Coder' #category : #'Carp-Coder'
} }
{ #category : #accessing }
CarpStreamingMethodsCoderElement class >> forModule: aModule [
^ self new module: aModule
]
{ #category : #accessing } { #category : #accessing }
CarpStreamingMethodsCoderElement >> initialize [ CarpStreamingMethodsCoderElement >> initialize [
super initialize. super initialize.
self matchParent. self matchParent.
listItemsProvider := BrListStreamItemsProvider new stream: AsyncEmptyStream new.
list := BrSimpleList new list := BrSimpleList new
itemType: [ :anItemTypeFactory :anItemObject | anItemObject elementClass ]; itemType: [ :anItemTypeFactory :anItemObject |
itemStencil: [ :anElementClass | anElementClass new id: GtSourceCoderId ]; anItemObject ];
itemDataBinder: [ :aCoderElement :aCoderViewModel | itemStencil: [ :anItem |
BlFrameTelemetry anItem asElement id: GtSourceCoderId ];
time: [ 'Set {1} as a view model of {2}' format: { aCoderViewModel class name . aCoderElement class name } ] itemsProvider:
during: [ aCoderElement textualCoderViewModel: aCoderViewModel ] ]; (BrListStreamItemsProvider new stream: AsyncEmptyStream new).
itemsProvider: listItemsProvider.
self addChild: list self addChild: list
] ]
{ #category : #accessing }
CarpStreamingMethodsCoderElement >> initializeForModule [
list itemsProvider: module expressions asBrItemsProvider
]
{ #category : #accessing }
CarpStreamingMethodsCoderElement >> module: aModule [
module := aModule.
self initializeForModule
]