From 1f0b74df2cc2c1cff0999505e072ffa7393b6f56 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Fri, 24 Nov 2023 14:25:18 +0100 Subject: [PATCH 1/2] Multiselection works for variant actions --- .../SBExploriantsView.class.st | 4 ++ .../SBStGrammarHandler.class.st | 72 ++++++++++++++++--- 2 files changed, 66 insertions(+), 10 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index 6b87edc1..3d27f0c1 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -1,3 +1,7 @@ +" +Caution: +The Views need a parent who in in the editor to visualize themselves +" Class { #name : #SBExploriantsView, #superclass : #SBNamedBlock, diff --git a/packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st b/packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st index 33cad29b..155f4aba 100644 --- a/packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st +++ b/packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st @@ -83,6 +83,22 @@ SBStGrammarHandler >> debugExpression [ receiver: (context ifNil: [artefact ifNotNil: #evaluationReceiver] ifNotNil: #receiver)) debugWithTitle: 'Debug it' ] +{ #category : #'action helpers' } +SBStGrammarHandler >> defaultAlternativesForBlocks: aCollectionOfBlocks [ + + ^ { + SBNamedBlock block: (SBStBlockBody new statements: aCollectionOfBlocks) named: 'original'. + SBNamedBlock block: (SBStBlockBody new statements: aCollectionOfBlocks veryDeepCopy) named: 'alternative'. } +] + +{ #category : #'action helpers' } +SBStGrammarHandler >> defaultOptionalAlternativesForBlocks: aCollectionOfBlocks [ + + ^ { + SBNamedBlock block: (SBStBlockBody new statements: aCollectionOfBlocks) named:'with'. + SBNamedBlock block: (SBStBlockBody empty) named:'without'.} +] + { #category : #actions } SBStGrammarHandler >> doExpression [ @@ -401,6 +417,44 @@ SBStGrammarHandler >> wrapAsArgument [ startInput: msg receiver at: 0 replacingContents: false ] +{ #category : #actions } +SBStGrammarHandler >> wrapEachInOptionalVariant [ + + + + self assert: self block isSelected. + self block sandblockEditor doMultiSelectionEach: [:selected | | variant | + variant := SBVariant new. + SBWrapCommand new + outer: variant; + inner: selected; + wrap: [:outer :inner | + variant + named: inner printString + alternatives: (self defaultOptionalAlternativesForBlocks: {inner}) + activeIndex: 2]; + yourself] +] + +{ #category : #actions } +SBStGrammarHandler >> wrapEachInVariant [ + + + + self assert: self block isSelected. + self block sandblockEditor doMultiSelectionEach: [:selected | | variant | + variant := SBVariant new. + SBWrapCommand new + outer: variant; + inner: selected; + wrap: [:outer :inner | + variant + named: inner printString + alternatives: (self defaultAlternativesForBlocks: {inner}) + activeIndex: 2]; + yourself] +] + { #category : #'action helpers' } SBStGrammarHandler >> wrapInArrayType: aSymbol [ @@ -527,12 +581,11 @@ SBStGrammarHandler >> wrapInOptionalVariant [ selectAfter: #block; outer: variant; targets: selected; - wrap: [:outer :inner | + wrap: [:outer :inner | variant named: inner printString - alternatives:{ - SBNamedBlock block: (SBStBlockBody new statements: inner) named:'with'. - SBNamedBlock block: (SBStBlockBody empty) named:'without'} activeIndex: 2]; + alternatives: (self defaultOptionalAlternativesForBlocks: inner) + activeIndex: 2]; yourself] ] @@ -582,12 +635,11 @@ SBStGrammarHandler >> wrapInVariant [ selectAfter: #block; outer: variant; targets: selected; - wrap: [:outer :inner | variant - named: inner printString - alternatives: { - SBNamedBlock block: (SBStBlockBody new statements: inner) named: 'original'. - SBNamedBlock block: (SBStBlockBody new statements: inner veryDeepCopy) named: 'alternative'. } - activeIndex: 2]; + wrap: [:outer :inner | + variant + named: inner printString + alternatives: (self defaultAlternativesForBlocks: inner) + activeIndex: 2]; yourself] ] From 08565a5466155fd8412697d52d27ca5dd22a84b1 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Fri, 24 Nov 2023 14:25:58 +0100 Subject: [PATCH 2/2] remove class desc --- packages/Sandblocks-Babylonian/SBExploriantsView.class.st | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index 3d27f0c1..6b87edc1 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -1,7 +1,3 @@ -" -Caution: -The Views need a parent who in in the editor to visualize themselves -" Class { #name : #SBExploriantsView, #superclass : #SBNamedBlock,