diff --git a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st index d0a1ddab..b09aa73b 100644 --- a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st @@ -407,9 +407,14 @@ SBExampleWatch >> printOn: aStream [ SBExampleWatch >> replaceWithWatchedExpression [ - self sandblockEditor do: (SBReplaceCommand new + | command | + command := (SBReplaceCommand new replacer: self expression; - target: self) + target: self). + + self sandblockEditor + ifNil: [command do] + ifNotNil:[:theEditor | theEditor do: command] ] { #category : #actions } diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index 3add0d53..d3060ca4 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -29,6 +29,21 @@ SBExploriantsView class >> newMultiverse: aSBMultiverse [ yourself ] +{ #category : #building } +SBExploriantsView >> buildButtonRow [ + + self block addMorphFront: (SBRow new + changeTableLayout; + cellGap: 8 * self scalingFactor; + addAllMorphsBack: self buttons) +] + +{ #category : #accessing } +SBExploriantsView >> buttons [ + + ^ {self updateButton. self resolveButton} +] + { #category : #actions } SBExploriantsView >> clean [ @@ -90,8 +105,30 @@ SBExploriantsView >> multiverse: aSBMultiverse [ multiverse when: #initialized send: #visualize to: self. ] +{ #category : #building } +SBExploriantsView >> resolveButton [ + + ^ SBButton new + icon: SBIcon iconTrash + label: 'Resolve All From Code' + do: [self multiverse resolve]; + cornerStyle: #squared +] + +{ #category : #building } +SBExploriantsView >> updateButton [ + + ^ SBButton new + icon: SBIcon iconRotateLeft + label: 'Re-Generate Multiverse' + do: [self multiverse initialize]; + cornerStyle: #squared +] + { #category : #actions } SBExploriantsView >> visualize [ - self subclassResponsibility + self clean. + + self buildButtonRow ] diff --git a/packages/Sandblocks-Babylonian/SBLiveView.class.st b/packages/Sandblocks-Babylonian/SBLiveView.class.st index 2d6c31bf..5787fe74 100644 --- a/packages/Sandblocks-Babylonian/SBLiveView.class.st +++ b/packages/Sandblocks-Babylonian/SBLiveView.class.st @@ -30,15 +30,6 @@ SBLiveView >> buildBrodcaster [ ] -{ #category : #building } -SBLiveView >> buildButtonRow [ - - self block addMorphBack: (SBRow new - changeTableLayout; - cellGap: 8 * self scalingFactor; - addAllMorphsBack: {self updateButton. self rebuildButton}) -] - { #category : #building } SBLiveView >> buildPreviewFor: aPermutation [ @@ -57,12 +48,13 @@ SBLiveView >> buildPreviewFor: aPermutation [ { #category : #building } SBLiveView >> buildSetUpRow [ - self block addMorph: (SBRow new + self block addMorphBack: (SBRow new changeTableLayout; hResizing: #spaceFill; wrapCentering: #center; listCentering: #center; cellPositioning: #center; + name: #setup; cellGap: 8 * self scalingFactor; addMorphBack: (SBIcon iconSpinner balloonText: 'Toggle stepping'; @@ -71,10 +63,16 @@ SBLiveView >> buildSetUpRow [ addMorphBack: ([Morph new] asSandblock width: 200)) ] +{ #category : #building } +SBLiveView >> buttons [ + + ^ {self updateButton. self rebuildButton. self resolveButton} +] + { #category : #actions } SBLiveView >> clean [ - self block submorphs allButFirst copy do: #delete. + (self block submorphs reject: [:aSubmorph| aSubmorph externalName = 'setup']) copy do: #delete. gridContainer := self newGridContainer. ] @@ -104,6 +102,8 @@ SBLiveView >> initialize [ self name: 'Live View'. self buildSetUpRow. + + ] { #category : #accessing } @@ -202,7 +202,7 @@ SBLiveView >> reportError: anError [ { #category : #accessing } SBLiveView >> setUpMorph [ - ^ self block firstSubmorph "setup row" lastSubmorph + ^ (self block submorphNamed: 'setup') lastSubmorph ] { #category : #building } diff --git a/packages/Sandblocks-Babylonian/SBMultiverse.class.st b/packages/Sandblocks-Babylonian/SBMultiverse.class.st index d9ff4887..67c761cb 100644 --- a/packages/Sandblocks-Babylonian/SBMultiverse.class.st +++ b/packages/Sandblocks-Babylonian/SBMultiverse.class.st @@ -115,10 +115,7 @@ SBMultiverse >> findExistingOrConvertToBlocks: aCollectionOfCompiledMethods [ ] { #category : #'initialize-release' } -SBMultiverse >> initialize [ - - | permutations | - super initialize. +SBMultiverse >> gatherElements [ "We are looking for already opened methods so that we can assign the variant there as the original in SBVariantProxy. That way, we immediately @@ -131,6 +128,17 @@ SBMultiverse >> initialize [ variants := (allMethodBlocksContainingVariants collect: #containedVariants) flatten. activeExamples := self allActiveExamples. + +] + +{ #category : #'initialize-release' } +SBMultiverse >> initialize [ + + | permutations | + super initialize. + + self gatherElements. + permutations := SBPermutation allPermutationsOf: variants. universes := OrderedCollection new. [permutations do: [:aPermutation | @@ -150,6 +158,21 @@ SBMultiverse >> resetWatchesToOriginalPermutationRunning: activeExamples [ activeExamples do: #runSynchronouslyIgnoreReturn ] +{ #category : #actions } +SBMultiverse >> resolve [ + + self allActiveExamples do: #stopRunning. + + (self findExistingOrConvertToBlocks: self allCompiledMethodsContainingVariants) do: [:aVariantMethod | + aVariantMethod containedVariants do: #replaceSelfWithChosen. + self saveMethod: aVariantMethod]. + + (self findExistingOrConvertToBlocks: self allCompiledMethodsContainingExampleWatches) do: [:aWatchMethod | + aWatchMethod containedExampleWatches do: #replaceWithWatchedExpression. + self saveMethod: aWatchMethod]. + +] + { #category : #accessing } SBMultiverse >> sandblockEditor [ @@ -162,6 +185,14 @@ SBMultiverse >> sandblockEditor: aSandblockEditor [ sandblockEditor := aSandblockEditor ] +{ #category : #'action-helper' } +SBMultiverse >> saveMethod: aMethod [ + + aMethod save. + aMethod sandblockEditor ifNotNil: [:theEditor | theEditor markSaved: aMethod] + +] + { #category : #accessing } SBMultiverse >> universes [ diff --git a/packages/Sandblocks-Babylonian/SBResultsView.class.st b/packages/Sandblocks-Babylonian/SBResultsView.class.st index b43d72b4..0e34a49a 100644 --- a/packages/Sandblocks-Babylonian/SBResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResultsView.class.st @@ -28,21 +28,9 @@ SBResultsView >> resetWatchesToOriginalPermutationRunning: activeExamples [ activeExamples do: #runSynchronouslyIgnoreReturn ] -{ #category : #building } -SBResultsView >> updateButton [ - - ^ SBButton new - icon: SBIcon iconRotateLeft - label: 'Re-Generate Multiverse' - do: [self multiverse initialize]; - cornerStyle: #squared -] - { #category : #actions } SBResultsView >> visualize [ - self clean. - - self block addMorphFront: self updateButton. + super visualize. self buildAllPossibleResults ] diff --git a/packages/Sandblocks-Babylonian/SBVariantsView.class.st b/packages/Sandblocks-Babylonian/SBVariantsView.class.st index 2cd6c0ed..42ff6767 100644 --- a/packages/Sandblocks-Babylonian/SBVariantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBVariantsView.class.st @@ -30,8 +30,7 @@ SBVariantsView >> initialize [ { #category : #actions } SBVariantsView >> visualize [ - self clean. - + super visualize. self multiverse allMethodBlocksContainingVariants ifNotEmptyDo: [:theMethods | theMethods do: [:aSBStMethod | self buildMethodSectionFor: aSBStMethod]] ifEmpty: [self buildNoVariantsText] diff --git a/packages/Sandblocks-Smalltalk/SBVariant.class.st b/packages/Sandblocks-Smalltalk/SBVariant.class.st index 386c972e..11ce7317 100644 --- a/packages/Sandblocks-Smalltalk/SBVariant.class.st +++ b/packages/Sandblocks-Smalltalk/SBVariant.class.st @@ -289,7 +289,9 @@ SBVariant >> replaceSelfWithBlock: aNamedBlock [ target: self; unwrapped: statements]. - self sandblockEditor do: command + self sandblockEditor + ifNil: [command do] + ifNotNil:[:theEditor | theEditor do: command] ] { #category : #actions } @@ -303,7 +305,9 @@ SBVariant >> replaceSelfWithChosen [ target: self; unwrapped: statements]. - self sandblockEditor do: command + self sandblockEditor + ifNil: [command do] + ifNotNil:[:theEditor | theEditor do: command] ] { #category : #initialization }