diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index 0a9674c7..b213a77c 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -93,6 +93,13 @@ SBExploriants >> buttonClass [ SBExploriants >> cacheType: aClass for: aBlock [ ] +{ #category : #actions } +SBExploriants >> changeIndexOf: aVariantId to: aNewIndex [ + + namedBlocks detect: #isVariantsView + ifFound: [:variantsView | variantsView changeIndexOf: aVariantId to: aNewIndex] +] + { #category : #testing } SBExploriants >> evaluationContext [ @@ -221,6 +228,12 @@ SBExploriants >> updateInBackgroundOnTimeoutRevertTo: theOldMultiverse [ ] forkAt: Processor userBackgroundPriority. ] +{ #category : #actions } +SBExploriants >> variantsView [ + + ^ namedBlocks detect: #isVariantsView +] + { #category : #actions } SBExploriants >> visualize [ diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index 39160a95..6a06faa5 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -105,6 +105,12 @@ SBExploriantsView >> isOverview [ ^false ] +{ #category : #accessing } +SBExploriantsView >> isVariantsView [ + + ^ false +] + { #category : #accessing } SBExploriantsView >> multiverse [ diff --git a/packages/Sandblocks-Babylonian/SBMultiverse.class.st b/packages/Sandblocks-Babylonian/SBMultiverse.class.st index 84efba0e..b981f182 100644 --- a/packages/Sandblocks-Babylonian/SBMultiverse.class.st +++ b/packages/Sandblocks-Babylonian/SBMultiverse.class.st @@ -149,19 +149,33 @@ SBMultiverse >> findExistingOrConvertToBlocksMaintainingWatches: aCollectionOfCo { #category : #'initialize-release' } SBMultiverse >> gatherElements [ + universes := OrderedCollection new. + activeExamples := self allActiveExamples. + + self gatherVariants. + + self gatherWatches + +] + +{ #category : #'initialize-release' } +SBMultiverse >> gatherVariants [ + "We are looking for already opened methods so that we can assign the variant there as the original in SBVariantProxy. That way, we immediately have consistency between changes." allMethodBlocksContainingVariants := self findExistingOrConvertToBlocks: self allCompiledMethodsContainingVariants. - allMethodBlocksContainingWatches := self findExistingOrConvertToBlocksMaintainingWatches: self allCompiledMethodsContainingExampleWatches. - - universes := OrderedCollection new. - activeExamples := self allActiveExamples. - variants := (allMethodBlocksContainingVariants collect: #containedVariants) flatten. variants := variants select: #isActive. +] + +{ #category : #'initialize-release' } +SBMultiverse >> gatherWatches [ + + allMethodBlocksContainingWatches := self findExistingOrConvertToBlocksMaintainingWatches: self allCompiledMethodsContainingExampleWatches. + watches := (allMethodBlocksContainingWatches collect: [:aMethodBlock | | copies | copies := aMethodBlock containedExampleWatches. "Because the watches share the id, values would be reported to original too. Stop that" diff --git a/packages/Sandblocks-Babylonian/SBVariantsView.class.st b/packages/Sandblocks-Babylonian/SBVariantsView.class.st index 3c746903..8e576855 100644 --- a/packages/Sandblocks-Babylonian/SBVariantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBVariantsView.class.st @@ -10,16 +10,25 @@ Class { { #category : #building } SBVariantsView >> buildMethodSectionFor: aSBStMethod [ + | newProxy | + newProxy := aSBStMethod containedVariants collect: #asProxy. contents addAllMorphsBack: {aSBStMethod methodDefinition. - self containerRow - addAllMorphsBack: (aSBStMethod containedVariants collect: #asProxy). + self containerRow addAllMorphsBack: newProxy. LineMorph from: 0@0 to: 50@0 color: Color black width: 2} ] { #category : #building } SBVariantsView >> buildNoVariantsText [ - contents addMorphBack: (SBOwnTextMorph new contents: 'No variants exist.') + contents addMorphBack: (SBOwnTextMorph new contents: 'No variation points exist.') +] + +{ #category : #actions } +SBVariantsView >> changeIndexOf: aVariantId to: aNewIndex [ + + self proxies + detect: [:aProxy | aProxy original id = aVariantId] + ifFound: [:theProxy | theProxy changeActiveIndexTo: aNewIndex ] ] { #category : #actions } @@ -27,7 +36,7 @@ SBVariantsView >> clean [ super clean. - contents submorphs copy do: #delete + contents submorphs copy do: #delete. ] @@ -38,7 +47,19 @@ SBVariantsView >> initialize [ contents := self containerRow listDirection: #topToBottom. - self name: 'Variants'. + self name: 'Variation Points'. +] + +{ #category : #accessing } +SBVariantsView >> isVariantsView [ + + ^ true +] + +{ #category : #actions } +SBVariantsView >> proxies [ + + ^ (contents allMorphs select: [:aMorph | aMorph isKindOf: SBVariantProxy]) ] { #category : #copying } diff --git a/packages/Sandblocks-Core/SBTabView.class.st b/packages/Sandblocks-Core/SBTabView.class.st index 01d450ea..3c76b136 100644 --- a/packages/Sandblocks-Core/SBTabView.class.st +++ b/packages/Sandblocks-Core/SBTabView.class.st @@ -174,6 +174,8 @@ SBTabView >> asTabButton: aNamedBlock [ { #category : #tabs } SBTabView >> basicSetActive: aNamedBlock [ + self sandblockEditor ifNil: [^ self activeIndex: (self namedBlocks indexOf: aNamedBlock ifAbsent: 1)]. + self sandblockEditor do: (self switchCommandFor: (self namedBlocks indexOf: aNamedBlock ifAbsent: 1)). diff --git a/packages/Sandblocks-Smalltalk/SBVariantProxy.class.st b/packages/Sandblocks-Smalltalk/SBVariantProxy.class.st index 7caf7153..51dd137c 100644 --- a/packages/Sandblocks-Smalltalk/SBVariantProxy.class.st +++ b/packages/Sandblocks-Smalltalk/SBVariantProxy.class.st @@ -16,7 +16,6 @@ SBVariantProxy class >> for: aVariant [ { #category : #callbacks } SBVariantProxy >> artefactChanged: anArtefact [ - anArtefact = self ifTrue: [self updateOriginalWithOwnValues ]. @@ -36,6 +35,15 @@ SBVariantProxy >> binding: aString for: block class: aClass ifPresent: aBlock [ ^ original binding: aString for: block class: aClass ifPresent: aBlock ] +{ #category : #accessing } +SBVariantProxy >> changeActiveIndexTo: aNewIndex [ + + self firstSubmorph switchToAlternativeWithoutSaving: aNewIndex. + self updateOriginalWithOwnValues + + +] + { #category : #accessing } SBVariantProxy >> containedMethod [ diff --git a/packages/Sandblocks-Utils/SBPermutation.class.st b/packages/Sandblocks-Utils/SBPermutation.class.st index 5e7a01e7..481021ca 100644 --- a/packages/Sandblocks-Utils/SBPermutation.class.st +++ b/packages/Sandblocks-Utils/SBPermutation.class.st @@ -52,15 +52,39 @@ SBPermutation >> activeScore [ { #category : #actions } SBPermutation >> apply [ + + self flag: #todo. "outdated references, jb" + (self referencedVariants anySatisfy: [:aVariant | aVariant sandblockEditor isNil]) + ifTrue: [ self applyWithOutdatedReferences ] + ifFalse: [ self applyOnOriginals ]. + + +] +{ #category : #private } +SBPermutation >> applyOnOriginals [ + self referencedVariants do: [:aVariant | aVariant switchToAlternativeWithoutSaving: (self at: aVariant id)]. SBExploriants uniqueInstance ignoreUpdate: true. ((self referencedVariants collect: #containingArtefact) asSet) do: [:aMethod | - self referencedVariants first sandblockEditor save: aMethod tryFixing: false quick: false]. + aMethod sandblockEditor save: aMethod tryFixing: false quick: false]. + (self referencedVariants collect: #sandblockEditor) do: #sendNewPermutationNotification + + +] + +{ #category : #private } +SBPermutation >> applyWithOutdatedReferences [ + + | newVariants | + self keys do: [:anId | SBExploriants uniqueInstance changeIndexOf: anId to: (self at: anId)]. + newVariants := SBExploriants uniqueInstance variantsView proxies collect: #original. + self referencedVariants do: [:aVariant | + newVariants detect: [:new | new id = aVariant id] + ifFound: [:theVariant | aVariant becomeForward: theVariant]]. + SBEditor current sendNewPermutationNotification + - ((Set newFrom: (referencedVariants collect: #sandblockEditor)) - reject: #isNil) - do: #sendNewPermutationNotification ] { #category : #converting }