Skip to content

Commit

Permalink
jump to last save button, variant proxy deletion deletes variant even…
Browse files Browse the repository at this point in the history
… if method closed
  • Loading branch information
JoeAtHPI committed Mar 8, 2024
1 parent 520c8ed commit 360e8d6
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBExample.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ SBExample >> lastError: anError [
"ToolSet debugException: anError"
^ reportedError := self sandblockEditor
reportError: anError
process: ((Process forContext: anError signalerContext copyStack priority: Processor activeProcess priority)
process: ((Process forContext: anError signal copyStack priority: Processor activeProcess priority)
shouldResumeFromDebugger: false;
yourself)
source: self].
Expand Down
10 changes: 6 additions & 4 deletions packages/Sandblocks-Babylonian/SBExampleCluster.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ SBExampleCluster >> newTopRowFrom: aCollectionOfPermutationLabels [
wrappedLabel := (self wrapInCell: aLabel owner
flexVertically: true
flexHorizontally: false) borderWidth: 0.
button := SBButton newApplyPermutationFor: aLabel permutation.
button addFlexShell clipSubmorphs: false.
button rotationDegrees: 90.
button owner width > wrappedLabel width ifTrue: [button makeTiny].
"Rotating morphs somehow clips their right border, so dirty hack so container gets clipped 1px"
button := self newContainerMorph
cellInset: 1;
addMorphBack: (SBButton newApplyPermutationFor: aLabel permutation);
rotationDegrees: 90.
button owner width > wrappedLabel width ifTrue: [button firstSubmorph makeTiny].

self newContainerMorph
cellPositioning: #bottomToTop;
Expand Down
17 changes: 17 additions & 0 deletions packages/Sandblocks-Babylonian/SBExploriants.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ SBExploriants >> binding: aString for: block class: aClass ifPresent: aBlock [
^ nil
]

{ #category : #ui }
SBExploriants >> buildTabs [

self addMorphBack: (SBRow new
addAllMorphsBack: (self namedBlocks collect: [:block | self asTabButton: block]);
name: #tabs;
changeTableLayout;
listDirection: #leftToRight;
hResizing: #shrinkWrap)
]

{ #category : #ui }
SBExploriants >> buildView [

Expand Down Expand Up @@ -140,6 +151,12 @@ SBExploriants >> selector [
^ nil
]

{ #category : #accessing }
SBExploriants >> tabs [

^ (self submorphNamed: #tabs) submorphs
]

{ #category : #actions }
SBExploriants >> tryToUpdateInBackgroundAfterChangeIn: aMethodBlock [

Expand Down
26 changes: 24 additions & 2 deletions packages/Sandblocks-Babylonian/SBLiveView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Class {
'broadcaster',
'errorDecorator',
'errorIcon',
'reportedError'
'reportedError',
'lastSave'
],
#category : #'Sandblocks-Babylonian'
}
Expand Down Expand Up @@ -64,7 +65,7 @@ SBLiveView >> buildSetUpRow [
{ #category : #building }
SBLiveView >> buttons [

^ super buttons, {self rebuildButton}
^ super buttons, {self rebuildButton. self reloadLastSaveButton}
]

{ #category : #actions }
Expand Down Expand Up @@ -98,6 +99,16 @@ SBLiveView >> initialize [

]

{ #category : #building }
SBLiveView >> jumpToLastSave [

lastSave ifNil: [^ self].
broadcaster containers do: [:otherContainer |
self privateRegisterListener: lastSave veryDeepCopy
for: (SBExploriants objectToPermutation at: (otherContainer valueOfProperty: #sbListener))
in: otherContainer ]
]

{ #category : #accessing }
SBLiveView >> listeners [

Expand Down Expand Up @@ -172,6 +183,16 @@ SBLiveView >> rebuildRegisteredListenerFor: aPermutation in: aContainer [

]

{ #category : #building }
SBLiveView >> reloadLastSaveButton [

^ SBButton new
icon: SBIcon iconRotateRight
label: 'Reset To Last Synch'
do: [self jumpToLastSave ];
cornerStyle: #squared
]

{ #category : #actions }
SBLiveView >> reportError: anError [

Expand Down Expand Up @@ -223,6 +244,7 @@ SBLiveView >> synchronizePreviewsWith: aContainer [

| replacingListener |
replacingListener := (aContainer valueOfProperty: #sbListener).
lastSave := replacingListener veryDeepCopy.
(broadcaster containers reject: [:someContainer | aContainer == someContainer])
do: [:otherContainer |
self privateRegisterListener: replacingListener veryDeepCopy
Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Morphs/SBButton.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SBButton class >> newApplyPermutationFor: aPermutation [

^ self new
icon: (SBIcon iconArrowDown
size: 12.0 sbScaled;
size: 10.0 sbScaled;
color: (Color r: 0.0 g: 1 b: 0.0))
label: 'Apply'
do: [aPermutation apply];
Expand Down
10 changes: 5 additions & 5 deletions packages/Sandblocks-Smalltalk/SBVariant.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ SBVariant class >> named: aString associations: aCollectionOfAssociations active
aBoolean ifFalse: [^ defaultBehavior value].

"Always prioritize the permutation which is marked as active"
SBActiveVariantPermutation value ifNotNil: [^ (aCollectionOfAssociations at: (SBActiveVariantPermutation value at: uuid)) value value].
SBActiveVariantPermutation value ifNotNil: [^ (aCollectionOfAssociations at: (SBActiveVariantPermutation value at: uuid) ifAbsent: [^ defaultBehavior value]) value value].

"The requesting object does not require dynamic update behavior in which it needs to know a certain alternative"
SBExploriants objectToPermutation at: (requestor := thisContext sender receiver) ifAbsent: [^ defaultBehavior value].
Expand All @@ -95,7 +95,7 @@ SBVariant class >> named: aString associations: aCollectionOfAssociations active
"An outdated permutation in which an alternative with a higher index than current has been deleted"
aCollectionOfAssociations at: (requiredPermutation at: uuid) ifAbsent: [^ defaultBehavior value].

^ (aCollectionOfAssociations at: (requiredPermutation at: uuid)) value value
^ (aCollectionOfAssociations at: (requiredPermutation at: uuid) ifAbsent: [^defaultBehavior value]) value value
]

{ #category : #'instance creation' }
Expand Down Expand Up @@ -146,7 +146,7 @@ SBVariant >> activeIndex [
^ self widget activeIndex
]

{ #category : #actions }
{ #category : #accessing }
SBVariant >> activeMutateCommandWithNewValue: aBoolean [

^ SBMutatePropertyCommand new
Expand Down Expand Up @@ -375,7 +375,7 @@ SBVariant >> namedBlocks [
^ self widget namedBlocks
]

{ #category : #actions }
{ #category : #callbacks }
SBVariant >> nestedActiveCommands: allCommands [

allCommands add: (self activeMutateCommandWithNewValue: true).
Expand All @@ -384,7 +384,7 @@ SBVariant >> nestedActiveCommands: allCommands [
aVariant nestedActiveCommands: allCommands]]
]

{ #category : #actions }
{ #category : #callbacks }
SBVariant >> nestedInactiveCommands: allCommands [

allCommands add: (self activeMutateCommandWithNewValue: false).
Expand Down
13 changes: 10 additions & 3 deletions packages/Sandblocks-Smalltalk/SBVariantProxy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ SBVariantProxy class >> for: aVariant [
{ #category : #callbacks }
SBVariantProxy >> artefactChanged: anArtefact [

anArtefact = self ifTrue: [ self updateOriginalWithOwnValues ].

anArtefact = self ifTrue: [self updateOriginalWithOwnValues ].

(anArtefact = self containedMethod)
ifTrue: [ self updateSelfAfterMethodUpdate: anArtefact ]
Expand Down Expand Up @@ -101,10 +102,16 @@ SBVariantProxy >> updateOriginalWithOwnValues [
variantThatNeedsChanging ifNil: [^self delete].

original replaceBy: (original := self firstSubmorph copyBlock).
original isVariant ifFalse: [^ self delete].
original isVariant
ifFalse: [
self containedMethod save.
^ self delete].

variantThatNeedsChanging replaceValuesFrom: original copyBlock.
self sandblockEditor markChanged: self containedMethod
self containedMethod isInEditor
ifTrue: [self sandblockEditor markChanged: self containedMethod]
ifFalse: [self containedMethod save].

]

{ #category : #callbacks }
Expand Down

0 comments on commit 360e8d6

Please sign in to comment.