Skip to content

Commit

Permalink
Multiselection works for variant actions
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Nov 24, 2023
1 parent 1eedda3 commit 1f0b74d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 10 deletions.
4 changes: 4 additions & 0 deletions packages/Sandblocks-Babylonian/SBExploriantsView.class.st
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"
Caution:
The Views need a parent who in in the editor to visualize themselves
"
Class {
#name : #SBExploriantsView,
#superclass : #SBNamedBlock,
Expand Down
72 changes: 62 additions & 10 deletions packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
<action>
Expand Down Expand Up @@ -401,6 +417,44 @@ SBStGrammarHandler >> wrapAsArgument [
startInput: msg receiver at: 0 replacingContents: false
]
{ #category : #actions }
SBStGrammarHandler >> wrapEachInOptionalVariant [
<multiSelectAction>
<actionValidIf: #isSandblock>
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 [
<multiSelectAction>
<actionValidIf: #isSandblock>
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 [
Expand Down Expand Up @@ -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]
]
Expand Down Expand Up @@ -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]
]
Expand Down

0 comments on commit 1f0b74d

Please sign in to comment.