From 0af79ae0f4b5ddfbd8171b9841d17e778af583af Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Fri, 27 Oct 2023 16:01:39 +0200 Subject: [PATCH] resolves sbeditor current --- packages/Sandblocks-Babylonian/SBExploriants.class.st | 9 ++++++++- .../Sandblocks-Babylonian/SBExploriantsView.class.st | 6 +++++- packages/Sandblocks-Babylonian/SBResultsView.class.st | 6 ++---- packages/Sandblocks-Babylonian/SBVariantsView.class.st | 2 -- packages/Sandblocks-Core/SBEditor.class.st | 4 +++- packages/Sandblocks-Core/SBTabView.class.st | 2 +- packages/Sandblocks-Utils/SBPermutation.class.st | 2 +- 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index 2a43ff42..3dae2d61 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -58,5 +58,12 @@ SBExploriants >> saveTryFixing: aFixBoolean quick: aQuickBoolean [ { #category : #actions } SBExploriants >> visualize [ - self namedBlocks: SBExploriantsView getTabs activeIndex: 1 + "The Views need a parent to visualize themselves. We also want to avoid double-calculations" + | tabs | + tabs := SBExploriantsView getTabs. + tabs do: [:aTab | self addMorph: aTab block. aTab visualize.]. + self removeAllMorphs. + + self namedBlocks: tabs activeIndex: 1. + ] diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index ccfa77f5..103d9f5b 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, @@ -69,7 +73,7 @@ SBExploriantsView >> findExistingOrConvertToBlocks: aCollectionOfCompiledMethods ^ aCollectionOfCompiledMethods collect: [:aCompiledMethod | - SBEditor current blockFor: aCompiledMethod withInterfaces: #(#isMethod) + self block sandblockEditor blockFor: aCompiledMethod withInterfaces: #(#isMethod) ifOpen: [:existingMethodBlock | existingMethodBlock] ifClosed: [aCompiledMethod asSandblock]] ] diff --git a/packages/Sandblocks-Babylonian/SBResultsView.class.st b/packages/Sandblocks-Babylonian/SBResultsView.class.st index d290853b..ff4ec18f 100644 --- a/packages/Sandblocks-Babylonian/SBResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResultsView.class.st @@ -16,7 +16,7 @@ SBResultsView >> allActiveExamples [ ^ (self allCompiledMethodsContainingExamples collect: [:aCompiledMethod | "Only examples which are open in the editor can actually be active." - SBEditor current blockFor: aCompiledMethod withInterfaces: #(#isMethod) + self block sandblockEditor blockFor: aCompiledMethod withInterfaces: #(#isMethod) ifOpen: [:existingMethodBlock | existingMethodBlock containedExamples select: #active] ifClosed: [#()]]) flatten ] @@ -95,9 +95,7 @@ SBResultsView >> initialize [ super initialize. - self name: 'Possible Results'. - - self visualize + self name: 'Possible Results' ] { #category : #building } diff --git a/packages/Sandblocks-Babylonian/SBVariantsView.class.st b/packages/Sandblocks-Babylonian/SBVariantsView.class.st index bf963701..034e9d63 100644 --- a/packages/Sandblocks-Babylonian/SBVariantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBVariantsView.class.st @@ -25,8 +25,6 @@ SBVariantsView >> initialize [ super initialize. self name: 'Variant Manager'. - - self visualize ] { #category : #actions } diff --git a/packages/Sandblocks-Core/SBEditor.class.st b/packages/Sandblocks-Core/SBEditor.class.st index 5782a72f..c74bd492 100644 --- a/packages/Sandblocks-Core/SBEditor.class.st +++ b/packages/Sandblocks-Core/SBEditor.class.st @@ -1155,7 +1155,9 @@ SBEditor >> openAll: aCollection [ SBEditor >> openExploriants [ - self open: SBExploriants uniqueInstance visualize + "Not calling visualize directly as we first want the editor to be an owner of SBExploriants" + self open: SBExploriants uniqueInstance. + SBExploriants uniqueInstance visualize ] { #category : #'actions creating' } diff --git a/packages/Sandblocks-Core/SBTabView.class.st b/packages/Sandblocks-Core/SBTabView.class.st index 354e0103..155695ff 100644 --- a/packages/Sandblocks-Core/SBTabView.class.st +++ b/packages/Sandblocks-Core/SBTabView.class.st @@ -378,7 +378,7 @@ SBTabView >> removeCurrentTab [ { #category : #tabs } SBTabView >> setActive: aNamedBlock [ - SBEditor current do: + self sandblockEditor do: (self switchCommandFor: (self namedBlocks indexOf: aNamedBlock ifAbsent: 1)) ] diff --git a/packages/Sandblocks-Utils/SBPermutation.class.st b/packages/Sandblocks-Utils/SBPermutation.class.st index a6920486..12bbc6c1 100644 --- a/packages/Sandblocks-Utils/SBPermutation.class.st +++ b/packages/Sandblocks-Utils/SBPermutation.class.st @@ -36,7 +36,7 @@ SBPermutation >> apply [ self referencedVariants do: [:aVariant | aVariant switchToAlternative: (self at: aVariant id)]. (Set newFrom: (referencedVariants collect: #containingArtefact thenSelect: #isMethod)) - do: [:aMethodBlock | SBEditor current save: aMethodBlock tryFixing: true quick: true]. + do: [:aMethodBlock | aMethodBlock sandblockEditor save: aMethodBlock tryFixing: true quick: true]. ] { #category : #converting }