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 : #accessing }
CarpExpression >> asElement [
^ (GtCarpCoderModel new sourceCode: (GtCoderExplicitStringSource new source: self toCarp)) asElement
]
{ #category : #accessing }
CarpExpression >> documentation [
^ documentation ifNil: ['']

View File

@@ -52,7 +52,10 @@ CarpModule >> carpCoderCommentsFor: aView [
action: [ :aToggle :aTab |
self documentation:
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 }
@@ -60,9 +63,6 @@ CarpModule >> carpCoderStreamingMethodsFor: aView context: aPhlowContext [
<gtModuleView>
| aMethodsCoder aMethodsCoderViewModel aNewMethodCoderHolder |
aMethodsCoder := GtStreamingCodersModel new.
aMethodsCoderViewModel := GtStreamingCodersViewModel new streamingCodersModel: aMethodsCoder.
aNewMethodCoderHolder := ValueHolder new.
^ aView explicit
@@ -109,7 +109,12 @@ CarpModule >> carpCoderStreamingMethodsFor: aView context: aPhlowContext [
padding: (BlInsets all: 5);
addAptitude: BrGlamorousFocusableShadowAptitude new ];
name: #'button--add-new-expression'];
stencil: [ CarpStreamingMethodsCoderElement new streamingCodersViewModel: aMethodsCoderViewModel ]
stencil: [ CarpStreamingMethodsCoderElement forModule: self ]
]
{ #category : #accessing }
CarpModule >> expressions [
^ expressions
]
{ #category : #initialization }

View File

@@ -46,49 +46,47 @@ CarpModuleCoderElement >> buildDefinitionElement [
{ #category : #accessing }
CarpModuleCoderElement >> buildModuleLabel [
| classCoder aModuleNameEditor aContainer aPreviewButton removeClassButton |
| classCoder aModuleNameEditor aContainer aPreviewButton removeClassButton |
aContainer := BrHorizontalPane new
hMatchParent;
alignCenterLeft;
vFitContent.
aModuleNameEditor := BrEditableLabel new
aptitude: (BrGlamorousEditableLabelAptitude new
aptitude:
(BrGlamorousEditableLabelAptitude new
defaultBackground: Color transparent;
glamorousCodeFont;
bold;
fontSize: 18);
inputFilter: BrTextEditorClassNameInputFilter new;
text: self module name;
margin: (BlInsets all: 0);
id: GtBehaviorCoderBehaviorNameId;
whenKey: BlKeyCombination primaryG
labelDo: [ :aShortcutEvent | self phlow spawnObject: self module ];
labelDo: [ :aShortcutEvent |
self phlow spawnObject: self module ];
whenKey: BlKeyCombination primaryR
labelDo: [ :aShortcutEvent | aShortcutEvent currentTarget switchToEditor ];
labelDo: [ :aShortcutEvent |
aShortcutEvent currentTarget switchToEditor ];
whenKey: BlKeyCombination primaryC
labelDo: [ :aShortcutEvent | Clipboard clipboardText: self module name asString ].
aPreviewButton := BrButton new
id: CarpCoderBehaviorNameApplyPreviewId;
margin: (BlInsets left: 5);
addAptitude: BrGlamorousButtonWithIconAptitude;
icon: BrGlamorousVectorIcons accept;
action: [self module name: aModuleNameEditor text].
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 ] ] ].
labelDo: [ :aShortcutEvent |
Clipboard clipboardText:
self module name asString ];
when: BrEditorAcceptWish
do: [ :aWish |
self module name: aWish text asString ].
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
]

View File

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