From 76b9333878e37099608b472ac3c52d24712d4731 Mon Sep 17 00:00:00 2001 From: Vincent Blondeau Date: Fri, 13 Feb 2026 17:29:14 +0100 Subject: [PATCH] Add "copy method" as a button and a contextual menu entry --- src/Gt4CSS/GtCSSCoderModel.class.st | 47 ++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/src/Gt4CSS/GtCSSCoderModel.class.st b/src/Gt4CSS/GtCSSCoderModel.class.st index 530163b..2abc213 100644 --- a/src/Gt4CSS/GtCSSCoderModel.class.st +++ b/src/Gt4CSS/GtCSSCoderModel.class.st @@ -121,6 +121,18 @@ GtCSSCoderModel >> addEvaluateAddonsTo: anAst to: coderAddOns [ ] +{ #category : #'add-ons - header' } +GtCSSCoderModel >> addHeaderCopyMethodSelector: aSelector to: coderAddOns [ + + + (coderAddOns + addContextMenuItem: (self createLabel: 'Copy method name' + description: aSelector) + group: BrMenuItemGroupConfiguration editing + action: [:aCoderViewModel | self copyMethodNameToClipboard] + id: nil) ifNotNil: [:anAction | anAction priority: 250] +] + { #category : #'add-ons - header' } GtCSSCoderModel >> addHeaderFormatMethodSelector: aSelector to: coderAddOns [ @@ -194,6 +206,12 @@ GtCSSCoderModel >> computeAst: aString [ ^ CSSParser parseWithErrors: aString ] +{ #category : #'as yet unclassified' } +GtCSSCoderModel >> copyMethodNameToClipboard [ + self compiledMethod + ifNotNil: [:aCompiledMethod | Clipboard clipboardText: aCompiledMethod printString] +] + { #category : #accessing } GtCSSCoderModel >> currentSelector [ ^ self currentSelectorPromise wait @@ -299,32 +317,39 @@ GtCSSCoderModel >> initializeAddOns: addOns [ { #category : #initialization } GtCSSCoderModel >> initializeAddOns: addOns viewModel: aGtPharoMethodCoderViewModel [ super initializeAddOns: addOns viewModel: aGtPharoMethodCoderViewModel. - addOns addMainAction: 'Save' translated icon: BrGlamorousVectorIcons accept - action: [ :aCoderUIModel :anElement | aCoderUIModel save ] + action: [:aCoderUIModel :anElement | aCoderUIModel save] id: GtMethodCoderSaveActionId. addOns addDropDownWithPreviewAction: 'Remove' translated icon: BrGlamorousVectorIcons bin - action: [ :aButtonElement :aButtonModel :anEvent | self remove ] - stencil: [ :element | - GtPharoRemoveMethodPreviewStencil new + action: [:aButtonElement :aButtonModel :anEvent | self remove] + stencil: + [:element | + (GtPharoRemoveMethodPreviewStencil new) selectorToRemove: self selector; isEmptyMethod: self isNewMethod; anElement: element; - create ] + create] id: GtMethodCoderRemoveActionId. addOns addMainAction: 'Inspect Method' translated icon: BrGlamorousVectorIcons inspect - action: [ :aCoderUIModel :anElement | - self - notifyObjectSpawn: (aCoderUIModel behavior >> aCoderUIModel selector) methodReference - requesterObject: aCoderUIModel ] + action: + [:aCoderUIModel :anElement | + self notifyObjectSpawn: (aCoderUIModel behavior >> aCoderUIModel selector) + methodReference + requesterObject: aCoderUIModel] id: GtMethodCoderInspectActionId. - self initializeSearchTextAddOns: addOns viewModel: aGtPharoMethodCoderViewModel + addOns + addMainAction: 'Copy method name' translated + icon: BrGlamorousVectorIcons clipboard + action: [:aCoderUIModel :anElement | self copyMethodNameToClipboard] + id: GtMethodCoderCopyActionId. + self initializeSearchTextAddOns: addOns + viewModel: aGtPharoMethodCoderViewModel ] { #category : #initialization }