Skip to content

Commit

Permalink
Exploriants as tab view
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Sep 18, 2023
1 parent f74b2b5 commit 6107a8b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 24 deletions.
12 changes: 0 additions & 12 deletions packages/Sandblocks-Babylonian/SBExampleWatch.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,8 @@ SBExampleWatch >> asInactiveCopy [
^ (self veryDeepCopy) beInactive.
]

{ #category : #accessing }
SBExampleWatch >> beActive [
<action>

self flag: #todo. "action for debugging, remove later. bc when applying modification and
then turning inactive, the already modified values are seen as the ground truth.
is aber allgemein ein problemchen....eig sollten die watchviews die wahren values haben und nur
die modifizierten anzeigen."
isActive := true
]

{ #category : #accessing }
SBExampleWatch >> beInactive [
<action>

isActive := false
]
Expand Down
6 changes: 2 additions & 4 deletions packages/Sandblocks-Core/SBExploriants.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #SBExploriants,
#superclass : #SBBlock,
#superclass : #SBTabView,
#instVars : [
'watchMethodBlocks',
'variants',
Expand Down Expand Up @@ -63,7 +63,5 @@ SBExploriants >> saveTryFixing: aFixBoolean quick: aQuickBoolean [
{ #category : #actions }
SBExploriants >> visualize [

self submorphs copy do: #delete.

self addMorphBack: SBExploriantsView asTabView.
self namedBlocks: SBExploriantsView getTabs activeIndex: 1
]
8 changes: 7 additions & 1 deletion packages/Sandblocks-Core/SBExploriantsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Class {
{ #category : #'instance creation' }
SBExploriantsView class >> asTabView [

^ SBTabView
^ SBExploriants
namedBlocks: (self subclasses collect: #new)
activeIndex: 1
]
Expand All @@ -19,6 +19,12 @@ SBExploriantsView class >> block: aSBBlock named: aString [
self shouldNotImplement
]

{ #category : #'instance creation' }
SBExploriantsView class >> getTabs [

^ self subclasses collect: #new
]

{ #category : #accessing }
SBExploriantsView >> allCompiledMethodsContainingClass: aClass [

Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Core/SBTabView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ SBTabView >> removeCurrentTab [
{ #category : #tabs }
SBTabView >> setActive: aNamedBlock [

self sandblockEditor do:
SBEditor current do:
(self switchCommandFor: (self namedBlocks indexOf: aNamedBlock ifAbsent: 1))
]

Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Smalltalk/SBPermutation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ SBPermutation >> asString [
"collecting instead of calling (a active name), ', ', (b active name) in fold
as one variant only will not return a string but a variant"
^ (self referencedVariants collect: [:aVariant |
(aVariant blockAt: (self at: aVariant id)) name])
aVariant name, ': ', (aVariant blockAt: (self at: aVariant id)) name])
fold: [:a :b | a, ', ', b ]


Expand Down
30 changes: 25 additions & 5 deletions packages/Sandblocks-Smalltalk/SBVariant.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ SBVariant >> blockAt: anIndex [
^ self widget blockAt: anIndex
]

{ #category : #accessing }
SBVariant >> codeFor: aNamedBlock [

^ (aNamedBlock block submorphs size > 1)
ifTrue: [aNamedBlock block lastSubmorph]
ifFalse: [nil]
]

{ #category : #accessing }
SBVariant >> color [

Expand Down Expand Up @@ -242,22 +250,32 @@ SBVariant >> namedBlocks [
{ #category : #actions }
SBVariant >> replaceSelfWithBlock: aNamedBlock [

| command |
"As deleting the last tab also deletes the tab view, we gotta recreate it"
self widget: (SBTabView namedBlocks: {aNamedBlock} activeIndex: 1).
self addMorphBack: widget.

self sandblockEditor do: (SBUnwrapConsecutiveCommand new
command := (self codeFor: widget active)
ifNil: [SBDeleteCommand new target: self]
ifNotNil: [SBUnwrapConsecutiveCommand new
target: self;
unwrapped: {widget activeBlock lastSubmorph})
unwrapped: {(self codeFor: widget active)}].

self sandblockEditor do: command
]

{ #category : #actions }
SBVariant >> replaceSelfWithChosen [

<action>
self sandblockEditor do: (SBUnwrapConsecutiveCommand new
| command |
command := (self codeFor: widget active)
ifNil: [SBDeleteCommand new target: self]
ifNotNil: [SBUnwrapConsecutiveCommand new
target: self;
unwrapped: {self activeBlock lastSubmorph})
unwrapped: {(self codeFor: widget active)}].

self sandblockEditor do: command
]

{ #category : #initialization }
Expand Down Expand Up @@ -306,7 +324,9 @@ SBVariant >> writeSourceOn: aStream [
do: [:aNamedBlock |
aNamedBlock name storeOn: aStream.
aStream nextPutAll: ' -> ['.
aNamedBlock block lastSubmorph writeSourceOn: aStream.
(self codeFor: aNamedBlock)
ifNotNil: [(self codeFor: aNamedBlock) writeSourceOn: aStream]
ifNil: [aStream nextPutAll: ' '].
aStream nextPut: $].
]
separatedBy: [aStream nextPut: $.].
Expand Down

0 comments on commit 6107a8b

Please sign in to comment.