Skip to content

Commit

Permalink
Adds resolve button to quickly delete live elements
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Jan 6, 2024
1 parent 0fe9f32 commit bf1337d
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 36 deletions.
9 changes: 7 additions & 2 deletions packages/Sandblocks-Babylonian/SBExampleWatch.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,14 @@ SBExampleWatch >> printOn: aStream [
SBExampleWatch >> replaceWithWatchedExpression [
<action>

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 }
Expand Down
39 changes: 38 additions & 1 deletion packages/Sandblocks-Babylonian/SBExploriantsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 [

Expand Down Expand Up @@ -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
]
24 changes: 12 additions & 12 deletions packages/Sandblocks-Babylonian/SBLiveView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 [

Expand All @@ -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';
Expand All @@ -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.
]
Expand Down Expand Up @@ -104,6 +102,8 @@ SBLiveView >> initialize [

self name: 'Live View'.
self buildSetUpRow.


]

{ #category : #accessing }
Expand Down Expand Up @@ -202,7 +202,7 @@ SBLiveView >> reportError: anError [
{ #category : #accessing }
SBLiveView >> setUpMorph [

^ self block firstSubmorph "setup row" lastSubmorph
^ (self block submorphNamed: 'setup') lastSubmorph
]

{ #category : #building }
Expand Down
39 changes: 35 additions & 4 deletions packages/Sandblocks-Babylonian/SBMultiverse.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 |
Expand All @@ -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 [

Expand All @@ -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 [

Expand Down
14 changes: 1 addition & 13 deletions packages/Sandblocks-Babylonian/SBResultsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
3 changes: 1 addition & 2 deletions packages/Sandblocks-Babylonian/SBVariantsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 6 additions & 2 deletions packages/Sandblocks-Smalltalk/SBVariant.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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 }
Expand Down

0 comments on commit bf1337d

Please sign in to comment.