From 926a04cfacde1d6aeff93950479a42390e54f208 Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Tue, 28 Nov 2023 14:48:01 +0100 Subject: [PATCH 1/7] Reclassifying layout methods under "layout" protocol --- src/NewTools-Debugger/StDebugger.class.st | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NewTools-Debugger/StDebugger.class.st b/src/NewTools-Debugger/StDebugger.class.st index 90fac8660..ddaf5a6ab 100644 --- a/src/NewTools-Debugger/StDebugger.class.st +++ b/src/NewTools-Debugger/StDebugger.class.st @@ -370,7 +370,7 @@ StDebugger >> code [ ^ code ] -{ #category : 'specs' } +{ #category : 'layout' } StDebugger >> codeLayout [ ^ SpBoxLayout newTopToBottom @@ -1144,7 +1144,7 @@ StDebugger >> stack [ ] -{ #category : 'specs' } +{ #category : 'layout' } StDebugger >> stackAndCodeLayout [ ^ SpPanedLayout newTopToBottom @@ -1154,7 +1154,7 @@ StDebugger >> stackAndCodeLayout [ yourself ] -{ #category : 'specs' } +{ #category : 'layout' } StDebugger >> stackAndCodeWithExtensionsLayout [ ^ (SpPanedLayout newLeftToRight @@ -1199,7 +1199,7 @@ StDebugger >> stackIconForContext: context [ ^ self iconNamed: #overlayDirty ] -{ #category : 'specs' } +{ #category : 'layout' } StDebugger >> stackLayout [ ^ SpBoxLayout newTopToBottom add: #stackHeader From f662b3d2dd2f3346173f00ca8f19ecd7843bac1d Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:06:08 +0100 Subject: [PATCH 2/7] Trivial layout configurator for the stack and the code --- .../StDebuggerLayoutConfiguration.class.st | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st diff --git a/src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st b/src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st new file mode 100644 index 000000000..4189c6596 --- /dev/null +++ b/src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st @@ -0,0 +1,70 @@ +" +A trivial layout configurator for the `StDebugger`. +It is configureable through api methods. +To change the layout, it takes as input a dictionary with the name of the element to layout associated to the element itself. +" +Class { + #name : 'StDebuggerLayoutConfiguration', + #superclass : 'Object', + #instVars : [ + 'layout', + 'order' + ], + #category : 'NewTools-Debugger-Model', + #package : 'NewTools-Debugger', + #tag : 'Model' +} + +{ #category : 'configuration' } +StDebuggerLayoutConfiguration >> beHorizontalCodeThenStack [ + + layout := SpPanedLayout newLeftToRight + positionOfSlider: 30 percent; + yourself. + order := #( #code #stack ) +] + +{ #category : 'configuration' } +StDebuggerLayoutConfiguration >> beHorizontalStackThenCode [ + + layout := SpPanedLayout newLeftToRight + positionOfSlider: 30 percent; + yourself. + order := #( #stack #code ) +] + +{ #category : 'configuration' } +StDebuggerLayoutConfiguration >> beVerticalCodeThenStack [ + + layout := SpPanedLayout newTopToBottom + positionOfSlider: 30 percent; + yourself. + order := #( #code #stack ) +] + +{ #category : 'configuration' } +StDebuggerLayoutConfiguration >> beVerticalStackThenCode [ + + layout := SpPanedLayout newTopToBottom + positionOfSlider: 30 percent; + yourself. + order := #( #stack #code ) +] + +{ #category : 'configuration' } +StDebuggerLayoutConfiguration >> configureForLayouts: layoutsDictionary [ + + order do: [ :layoutSymbol | + layoutsDictionary at: layoutSymbol ifPresent: [ :l | layout add: l ] ]. + + ^ layout +] + +{ #category : 'initialization' } +StDebuggerLayoutConfiguration >> initialize [ + + layout := SpPanedLayout newTopToBottom + positionOfSlider: 30 percent; + yourself. + order := #( #stack #code ) +] From ae43c91896dc21e59d945a9fedefb72f0d57da4b Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:12:47 +0100 Subject: [PATCH 3/7] Integrating the layout configurator to the debugger --- src/NewTools-Debugger/StDebugger.class.st | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/NewTools-Debugger/StDebugger.class.st b/src/NewTools-Debugger/StDebugger.class.st index ddaf5a6ab..9ac1d8959 100644 --- a/src/NewTools-Debugger/StDebugger.class.st +++ b/src/NewTools-Debugger/StDebugger.class.st @@ -93,6 +93,9 @@ Class { 'EnableStackColoring', 'FastTDD' ], + #classInstVars : [ + 'layoutConfigurator' + ], #category : 'NewTools-Debugger-View', #package : 'NewTools-Debugger', #tag : 'View' @@ -201,6 +204,13 @@ StDebugger class >> initialize [ EnableStackColoring := true ] +{ #category : 'accessing' } +StDebugger class >> layoutConfigurator [ + + ^ layoutConfigurator ifNil: [ + layoutConfigurator := StDebuggerLayoutConfiguration new ] +] + { #category : 'opening' } StDebugger class >> openOn: aDebugSession withFullView: aBool [ @@ -1147,11 +1157,9 @@ StDebugger >> stack [ { #category : 'layout' } StDebugger >> stackAndCodeLayout [ - ^ SpPanedLayout newTopToBottom - positionOfSlider: 30 percent; - add: self stackLayout; - add: self codeLayout; - yourself + ^ self class layoutConfigurator configureForLayouts: { + (#stack -> self stackLayout). + (#code -> self codeLayout) } asDictionary ] { #category : 'layout' } From 331b154a0cf094ae60400d6ac50575628747a6c1 Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:22:37 +0100 Subject: [PATCH 4/7] Fixing memory leaks and api --- src/NewTools-Debugger/StDebugger.class.st | 2 +- .../StDebuggerLayoutConfiguration.class.st | 45 ++++++++++--------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/NewTools-Debugger/StDebugger.class.st b/src/NewTools-Debugger/StDebugger.class.st index 9ac1d8959..9a8043aef 100644 --- a/src/NewTools-Debugger/StDebugger.class.st +++ b/src/NewTools-Debugger/StDebugger.class.st @@ -206,7 +206,7 @@ StDebugger class >> initialize [ { #category : 'accessing' } StDebugger class >> layoutConfigurator [ - + 'here' crTrace. ^ layoutConfigurator ifNil: [ layoutConfigurator := StDebuggerLayoutConfiguration new ] ] diff --git a/src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st b/src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st index 4189c6596..f1f388527 100644 --- a/src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st +++ b/src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st @@ -7,8 +7,8 @@ Class { #name : 'StDebuggerLayoutConfiguration', #superclass : 'Object', #instVars : [ - 'layout', - 'order' + 'order', + 'selectedLayout' ], #category : 'NewTools-Debugger-Model', #package : 'NewTools-Debugger', @@ -18,42 +18,45 @@ Class { { #category : 'configuration' } StDebuggerLayoutConfiguration >> beHorizontalCodeThenStack [ - layout := SpPanedLayout newLeftToRight - positionOfSlider: 30 percent; - yourself. - order := #( #code #stack ) + order := #( #code #stack ). + ^ SpPanedLayout newLeftToRight + positionOfSlider: 30 percent; + yourself ] { #category : 'configuration' } StDebuggerLayoutConfiguration >> beHorizontalStackThenCode [ - layout := SpPanedLayout newLeftToRight - positionOfSlider: 30 percent; - yourself. - order := #( #stack #code ) + order := #( #stack #code ). + ^ SpPanedLayout newLeftToRight + positionOfSlider: 30 percent; + yourself ] { #category : 'configuration' } StDebuggerLayoutConfiguration >> beVerticalCodeThenStack [ - layout := SpPanedLayout newTopToBottom - positionOfSlider: 30 percent; - yourself. - order := #( #code #stack ) + order := #( #code #stack ). + ^ SpPanedLayout newTopToBottom + positionOfSlider: 30 percent; + yourself ] { #category : 'configuration' } StDebuggerLayoutConfiguration >> beVerticalStackThenCode [ - layout := SpPanedLayout newTopToBottom - positionOfSlider: 30 percent; - yourself. - order := #( #stack #code ) + order := #( #stack #code ). + ^ SpPanedLayout newTopToBottom + positionOfSlider: 30 percent; + yourself ] { #category : 'configuration' } StDebuggerLayoutConfiguration >> configureForLayouts: layoutsDictionary [ + | layout | + layout := self perform: selectedLayout. + order do: [ :layoutSymbol | layoutsDictionary at: layoutSymbol ifPresent: [ :l | layout add: l ] ]. @@ -63,8 +66,6 @@ StDebuggerLayoutConfiguration >> configureForLayouts: layoutsDictionary [ { #category : 'initialization' } StDebuggerLayoutConfiguration >> initialize [ - layout := SpPanedLayout newTopToBottom - positionOfSlider: 30 percent; - yourself. - order := #( #stack #code ) + order := #( #stack #code ). + selectedLayout := #beVerticalStackThenCode ] From 3bc140ec0dfb2d60dc4eab515573e99db5797379 Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:26:59 +0100 Subject: [PATCH 5/7] removing forgotten debugging log --- src/NewTools-Debugger/StDebugger.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NewTools-Debugger/StDebugger.class.st b/src/NewTools-Debugger/StDebugger.class.st index 9a8043aef..9ac1d8959 100644 --- a/src/NewTools-Debugger/StDebugger.class.st +++ b/src/NewTools-Debugger/StDebugger.class.st @@ -206,7 +206,7 @@ StDebugger class >> initialize [ { #category : 'accessing' } StDebugger class >> layoutConfigurator [ - 'here' crTrace. + ^ layoutConfigurator ifNil: [ layoutConfigurator := StDebuggerLayoutConfiguration new ] ] From 56f97d0231159a0faac03edd85c6a1e94ef20b4e Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:39:06 +0100 Subject: [PATCH 6/7] Setting for changing the layout --- src/NewTools-Debugger/StDebugger.class.st | 26 +++++++++++++++++++ .../StDebuggerLayoutConfiguration.class.st | 12 +++++++++ 2 files changed, 38 insertions(+) diff --git a/src/NewTools-Debugger/StDebugger.class.st b/src/NewTools-Debugger/StDebugger.class.st index 9ac1d8959..d9bb99def 100644 --- a/src/NewTools-Debugger/StDebugger.class.st +++ b/src/NewTools-Debugger/StDebugger.class.st @@ -125,6 +125,17 @@ StDebugger class >> closeAllDebuggers [ self allInstancesDo: [ :dbg | dbg close ] ] +{ #category : 'accessing' } +StDebugger class >> configureLayout [ + ^self layoutConfigurator selectedLayout +] + +{ #category : 'accessing' } +StDebugger class >> configureLayout: aSymbol [ + aSymbol crTrace. + self layoutConfigurator selectedLayout: aSymbol +] + { #category : 'instance creation' } StDebugger class >> debugSession: aDebugSession [ @@ -143,6 +154,21 @@ StDebugger class >> debuggerContextClass [ ^ StDebuggerContext ] +{ #category : 'accessing' } +StDebugger class >> debuggerLayoutSettingsOn: aBuilder [ + + + (aBuilder pickOne: #configureLayout) + parent: #debugging; + label: 'Debugger Layout'; + target: StDebugger; + default: #beVerticalStackThenCode; + domainValues: + #( #beHorizontalCodeThenStack #beHorizontalStackThenCode + #beVerticalCodeThenStack #beVerticalStackThenCode ); + description: '' +] + { #category : 'accessing' } StDebugger class >> defaultDebuggerRank [ diff --git a/src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st b/src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st index f1f388527..ee2ed33f7 100644 --- a/src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st +++ b/src/NewTools-Debugger/StDebuggerLayoutConfiguration.class.st @@ -69,3 +69,15 @@ StDebuggerLayoutConfiguration >> initialize [ order := #( #stack #code ). selectedLayout := #beVerticalStackThenCode ] + +{ #category : 'accessing' } +StDebuggerLayoutConfiguration >> selectedLayout [ + + ^ selectedLayout +] + +{ #category : 'accessing' } +StDebuggerLayoutConfiguration >> selectedLayout: anObject [ + + selectedLayout := anObject +] From 00726d36058e8fec2368d94172c516c12d4d5c89 Mon Sep 17 00:00:00 2001 From: Steven Costiou <26929529+StevenCostiou@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:53:50 +0100 Subject: [PATCH 7/7] Announcement to dynamically update all debuggers after a layout change from the settings --- src/NewTools-Debugger/StDebugger.class.st | 23 +++++++++++++++++-- ...DebuggerLayoutChangedAnnouncement.class.st | 10 ++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/NewTools-Debugger/StDebuggerLayoutChangedAnnouncement.class.st diff --git a/src/NewTools-Debugger/StDebugger.class.st b/src/NewTools-Debugger/StDebugger.class.st index d9bb99def..4e3321f54 100644 --- a/src/NewTools-Debugger/StDebugger.class.st +++ b/src/NewTools-Debugger/StDebugger.class.st @@ -132,8 +132,10 @@ StDebugger class >> configureLayout [ { #category : 'accessing' } StDebugger class >> configureLayout: aSymbol [ - aSymbol crTrace. - self layoutConfigurator selectedLayout: aSymbol + + self layoutConfigurator selectedLayout: aSymbol. + SystemAnnouncer uniqueInstance announce: + StDebuggerLayoutChangedAnnouncement new ] { #category : 'instance creation' } @@ -707,6 +709,7 @@ StDebugger >> initialize [ self debuggerActionModel updateContextPredicate. self forceSessionUpdate. self susbcribeToExtensionToggleAnnouncement. + self susbcribeToLayoutChangesAnnouncement. programmaticallyClosed := false. ] @@ -1325,6 +1328,15 @@ StDebugger >> susbcribeToExtensionToggleAnnouncement [ to: self ] +{ #category : 'subscription' } +StDebugger >> susbcribeToLayoutChangesAnnouncement [ + + SystemAnnouncer uniqueInstance weak + when: StDebuggerLayoutChangedAnnouncement + send: #updateLayout + to: self +] + { #category : 'accessing - presenters' } StDebugger >> toolbar [ @@ -1477,6 +1489,13 @@ StDebugger >> updateInspectorFromContext: aContext [ inspector getRawInspectorPresenterOrNil ifNotNil: [ :p | p update ] ] +{ #category : 'updating' } +StDebugger >> updateLayout [ + + self setStackAndCodeContainer. + self layout: self defaultLayout +] + { #category : 'initialization' } StDebugger >> updatePresenter [ diff --git a/src/NewTools-Debugger/StDebuggerLayoutChangedAnnouncement.class.st b/src/NewTools-Debugger/StDebuggerLayoutChangedAnnouncement.class.st new file mode 100644 index 000000000..58b88b19a --- /dev/null +++ b/src/NewTools-Debugger/StDebuggerLayoutChangedAnnouncement.class.st @@ -0,0 +1,10 @@ +" +I am announced when the debugger layout has changed, to allow open debuggers to dynamically update their layouts. +" +Class { + #name : 'StDebuggerLayoutChangedAnnouncement', + #superclass : 'Announcement', + #category : 'NewTools-Debugger-Model', + #package : 'NewTools-Debugger', + #tag : 'Model' +}