From 3c2646fbfca6d67b2806e691ee4a60108ef9a0ea Mon Sep 17 00:00:00 2001 From: Volant Date: Fri, 13 Jun 2025 11:11:54 +0200 Subject: [PATCH 01/17] Refactor script repository system to support project-specific repositories - Made `StSindarinDebuggerScriptRepository` an abstract class with `repositoryName` to be implemented by subclasses - Introduced `SindarinDefaultScriptRepository` to manage Pharo's default scripts - Updated `StSindarinDebuggerScriptRepositoryPresenter`: - Added a dropdown listing all subclasses of `StSindarinDebuggerScriptRepository` to select the active repository - Added `loadScript` and `saveScript` to work with the selected repository - Updated `StSindarinDebuggerScriptingPresenter` to support changes from `StSindarinDebuggerScriptRepositoryPresenter` --- .../SindarinDefaultScriptRepository.class.st | 12 +++++++ ...tSindarinDebuggerScriptRepository.class.st | 6 ++++ ...DebuggerScriptRepositoryPresenter.class.st | 36 +++++++++++++++---- ...indarinDebuggerScriptingPresenter.class.st | 13 +++---- 4 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 src/NewTools-Sindarin-Commands/SindarinDefaultScriptRepository.class.st diff --git a/src/NewTools-Sindarin-Commands/SindarinDefaultScriptRepository.class.st b/src/NewTools-Sindarin-Commands/SindarinDefaultScriptRepository.class.st new file mode 100644 index 00000000..017c7862 --- /dev/null +++ b/src/NewTools-Sindarin-Commands/SindarinDefaultScriptRepository.class.st @@ -0,0 +1,12 @@ +Class { + #name : 'SindarinDefaultScriptRepository', + #superclass : 'StSindarinDebuggerScriptRepository', + #category : 'NewTools-Sindarin-Commands', + #package : 'NewTools-Sindarin-Commands' +} + +{ #category : 'accessing' } +SindarinDefaultScriptRepository class >> repositoryName [ + "Return the name of the repository." + ^ 'Default Repository' +] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepository.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepository.class.st index 13ee0422..991c9559 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepository.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepository.class.st @@ -21,6 +21,12 @@ StSindarinDebuggerScriptRepository class >> loadScript: aString [ ] +{ #category : 'accessing' } +StSindarinDebuggerScriptRepository class >> repositoryName [ + "Return the name of the repository." + self subclassResponsibility +] + { #category : 'accessing' } StSindarinDebuggerScriptRepository class >> saveScript: aStringKey code: aStringValue [ diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st index b82886b4..b6fc2d04 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st @@ -6,7 +6,9 @@ Class { 'filter', 'chooseElement', 'loadButton', - 'cancelButton' + 'cancelButton', + 'scriptRepository', + 'repositoryChooser' ], #category : 'NewTools-Sindarin-Tools-Presenters', #package : 'NewTools-Sindarin-Tools', @@ -16,7 +18,8 @@ Class { { #category : 'actions' } StSindarinDebuggerScriptRepositoryPresenter >> applyFilter [ |filtered| - filtered := StSindarinDebuggerScriptRepository scriptsNames select: [ :each | + + filtered := scriptRepository scriptsNames select: [ :each | each asLowercase includesSubstring: filter text asLowercase ]. scriptList items: filtered ] @@ -44,6 +47,7 @@ StSindarinDebuggerScriptRepositoryPresenter >> defaultLayout [ ^ SpBoxLayout newTopToBottom spacing: 5; + add: repositoryChooser expand: false; add: #scriptList; add: #filter expand: false; add: buttonRow expand: false; @@ -57,8 +61,7 @@ StSindarinDebuggerScriptRepositoryPresenter >> initializeDialogWindow: aWindow [ ] { #category : 'initialization' } -StSindarinDebuggerScriptRepositoryPresenter >> initializePresenters [ - +StSindarinDebuggerScriptRepositoryPresenter >> initializePresenters [ scriptList := self newList. filter := self newTextInput. @@ -71,13 +74,34 @@ StSindarinDebuggerScriptRepositoryPresenter >> initializePresenters [ cancelButton := self newButton. cancelButton label: 'Cancel'. - self applyFilter. + repositoryChooser := self newDropList. + repositoryChooser + whenSelectedItemChangedDo: [ :each | self loadRepository: each ]; + items: StSindarinDebuggerScriptRepository subclasses; + display: [ :each | each repositoryName ]. + + scriptRepository := SindarinDefaultScriptRepository. ] +{ #category : 'actions' } +StSindarinDebuggerScriptRepositoryPresenter >> loadRepository: aSindarinRepository [ + scriptRepository := aSindarinRepository. + self applyFilter. +] + +{ #category : 'actions' } +StSindarinDebuggerScriptRepositoryPresenter >> loadScript: aString [ + ^ scriptRepository loadScript: aString. +] + +{ #category : 'actions' } +StSindarinDebuggerScriptRepositoryPresenter >> saveScript: aStringName code: aStringCode [ + scriptRepository saveScript: aStringName code: aStringCode. +] + { #category : 'transmission' } StSindarinDebuggerScriptRepositoryPresenter >> setModel: aListElement [ - chooseElement := aListElement ] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st index 5a2e4884..bad2899a 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st @@ -96,6 +96,7 @@ StSindarinDebuggerScriptingPresenter >> hasUnsavedCodeChanges [ StSindarinDebuggerScriptingPresenter >> initializePresenters [ scriptNameInput := self newTextInput. resultLabel := self newLabel. + scriptRepository := StSindarinDebuggerScriptRepositoryPresenter newApplication: self application. code := self newCode. self loadLastScript. code syntaxHighlight: true. @@ -108,8 +109,6 @@ StSindarinDebuggerScriptingPresenter >> initializePresenters [ self initializeToolbar. self updateLabel. - scriptRepository := StSindarinDebuggerScriptRepositoryPresenter newApplication: self application. - ] @@ -125,8 +124,10 @@ StSindarinDebuggerScriptingPresenter >> initializeToolbar [ { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> loadLastScript [ |script| - script := (StSindarinDebuggerScriptRepository loadScript: 'Last updated') ifNil: ['sindarin stepOver']. + + script := (scriptRepository loadScript: 'Last updated') ifNil: ['sindarin stepOver']. scriptNameInput text: 'Last updated'. + code text: script . ] @@ -142,7 +143,7 @@ StSindarinDebuggerScriptingPresenter >> loadScript [ scriptName := scriptRepository chooseElement. scriptName ifNotNil: [ scriptNameInput text: scriptName . - code text: (StSindarinDebuggerScriptRepository loadScript: scriptName) . + code text: (scriptRepository loadScript: scriptName) . hasUnsavedCodeChanges := false. self updateLabel . @@ -171,13 +172,13 @@ StSindarinDebuggerScriptingPresenter >> removeScriptCommand [ { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> saveLastScript [ - StSindarinDebuggerScriptRepository saveScript: 'Last updated' code: code text. + scriptRepository saveScript: 'Last updated' code: code text. ] { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> saveScript [ - StSindarinDebuggerScriptRepository saveScript: (scriptNameInput text) code: (code text). + scriptRepository saveScript: (scriptNameInput text) code: (code text). hasUnsavedCodeChanges := false. self updateLabel From 6dfbf74b8ab1eef401270e40aaebc23a707f574a Mon Sep 17 00:00:00 2001 From: Volant Date: Fri, 13 Jun 2025 17:12:05 +0200 Subject: [PATCH 02/17] Refactor repository selection into dedicated chooser presenter - Added StSindarinDebuggerScriptRepositoryChooserPresenter as a subclass of SpDropListPresenter to handle repository selection - Refactored StSindarinDebuggerScriptRepositoryPresenter to receive the repository as an attribute (removed internal drop list) - Integrated the new chooser into StSindarinDebuggerScriptingPresenter to manage repository switching --- ...rScriptRepositoryChooserPresenter.class.st | 17 ++++ ...DebuggerScriptRepositoryPresenter.class.st | 34 ++----- ...indarinDebuggerScriptingPresenter.class.st | 96 ++++++++++++++----- 3 files changed, 98 insertions(+), 49 deletions(-) create mode 100644 src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st new file mode 100644 index 00000000..87959f99 --- /dev/null +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st @@ -0,0 +1,17 @@ +Class { + #name : 'StSindarinDebuggerScriptRepositoryChooserPresenter', + #superclass : 'SpDropListPresenter', + #category : 'NewTools-Sindarin-Tools-Presenters', + #package : 'NewTools-Sindarin-Tools', + #tag : 'Presenters' +} + +{ #category : 'api' } +StSindarinDebuggerScriptRepositoryChooserPresenter >> display [ + ^ [ :e | e repositoryName ]. +] + +{ #category : 'initialization' } +StSindarinDebuggerScriptRepositoryChooserPresenter >> findRepositories [ + self items: StSindarinDebuggerScriptRepository subclasses +] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st index b6fc2d04..b3556557 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st @@ -7,8 +7,7 @@ Class { 'chooseElement', 'loadButton', 'cancelButton', - 'scriptRepository', - 'repositoryChooser' + 'repository' ], #category : 'NewTools-Sindarin-Tools-Presenters', #package : 'NewTools-Sindarin-Tools', @@ -18,8 +17,7 @@ Class { { #category : 'actions' } StSindarinDebuggerScriptRepositoryPresenter >> applyFilter [ |filtered| - - filtered := scriptRepository scriptsNames select: [ :each | + filtered := repository scriptsNames select: [ :each | each asLowercase includesSubstring: filter text asLowercase ]. scriptList items: filtered ] @@ -47,19 +45,12 @@ StSindarinDebuggerScriptRepositoryPresenter >> defaultLayout [ ^ SpBoxLayout newTopToBottom spacing: 5; - add: repositoryChooser expand: false; add: #scriptList; add: #filter expand: false; add: buttonRow expand: false; yourself ] -{ #category : 'initialization' } -StSindarinDebuggerScriptRepositoryPresenter >> initializeDialogWindow: aWindow [ - super initializeDialogWindow: aWindow. - aWindow title: 'Load a script'. -] - { #category : 'initialization' } StSindarinDebuggerScriptRepositoryPresenter >> initializePresenters [ scriptList := self newList. @@ -74,30 +65,23 @@ StSindarinDebuggerScriptRepositoryPresenter >> initializePresenters [ cancelButton := self newButton. cancelButton label: 'Cancel'. - repositoryChooser := self newDropList. - repositoryChooser - whenSelectedItemChangedDo: [ :each | self loadRepository: each ]; - items: StSindarinDebuggerScriptRepository subclasses; - display: [ :each | each repositoryName ]. - - scriptRepository := SindarinDefaultScriptRepository. ] { #category : 'actions' } -StSindarinDebuggerScriptRepositoryPresenter >> loadRepository: aSindarinRepository [ - scriptRepository := aSindarinRepository. - self applyFilter. +StSindarinDebuggerScriptRepositoryPresenter >> loadScript: aString [ + ^ repository loadScript: aString. ] -{ #category : 'actions' } -StSindarinDebuggerScriptRepositoryPresenter >> loadScript: aString [ - ^ scriptRepository loadScript: aString. +{ #category : 'accessing' } +StSindarinDebuggerScriptRepositoryPresenter >> repository: aScriptRepository [ + repository := aScriptRepository. + self applyFilter ] { #category : 'actions' } StSindarinDebuggerScriptRepositoryPresenter >> saveScript: aStringName code: aStringCode [ - scriptRepository saveScript: aStringName code: aStringCode. + repository saveScript: aStringName code: aStringCode. ] { #category : 'transmission' } diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st index bad2899a..649c5491 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st @@ -20,7 +20,8 @@ Class { 'resultLabel', 'hasUnsavedCodeChanges', 'scriptNameInput', - 'scriptRepository' + 'scriptRepository', + 'scriptRepositoryChooser' ], #category : 'NewTools-Sindarin-Tools-Presenters', #package : 'NewTools-Sindarin-Tools', @@ -51,8 +52,9 @@ StSindarinDebuggerScriptingPresenter >> debuggerExtensionToolName [ { #category : 'layout' } StSindarinDebuggerScriptingPresenter >> defaultLayout [ + ^ SpBoxLayout newTopToBottom - add: #toolbar expand: false; + add: self toolbarLayout expand: false; add: #scriptNameInput expand: false fill: false @@ -66,6 +68,11 @@ StSindarinDebuggerScriptingPresenter >> defaultLayout [ yourself ] +{ #category : 'accessing' } +StSindarinDebuggerScriptingPresenter >> defaultScriptRepository [ + ^ SindarinDefaultScriptRepository +] + { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> executeScript [ @@ -96,7 +103,10 @@ StSindarinDebuggerScriptingPresenter >> hasUnsavedCodeChanges [ StSindarinDebuggerScriptingPresenter >> initializePresenters [ scriptNameInput := self newTextInput. resultLabel := self newLabel. - scriptRepository := StSindarinDebuggerScriptRepositoryPresenter newApplication: self application. + + self initializeScriptRepository. + self initializeScriptRepositoryChooser. + code := self newCode. self loadLastScript. code syntaxHighlight: true. @@ -113,8 +123,50 @@ StSindarinDebuggerScriptingPresenter >> initializePresenters [ ] { #category : 'initialization' } -StSindarinDebuggerScriptingPresenter >> initializeToolbar [ +StSindarinDebuggerScriptingPresenter >> initializeScriptRepository [ + |scriptName| + + scriptRepository := StSindarinDebuggerScriptRepositoryPresenter newApplication: self application. + scriptRepository repository: self defaultScriptRepository. + + scriptRepository whenLoadButtonDo: [ + scriptName := scriptRepository chooseElement. + scriptName ifNotNil: [ + scriptNameInput text: scriptName . + code text: (scriptRepository loadScript: scriptName) . + hasUnsavedCodeChanges := false. + + self updateLabel . + self updatePresenter . + ]. + + self layout: self defaultLayout. + ]. + scriptRepository whenCancelButtonDo: [ + self layout: self defaultLayout. + ] +] + +{ #category : 'initialization' } +StSindarinDebuggerScriptingPresenter >> initializeScriptRepositoryChooser [ + + scriptRepositoryChooser := StSindarinDebuggerScriptRepositoryChooserPresenter newApplication: self application. + scriptRepositoryChooser + findRepositories; + whenSelectedItemChangedDo: [ :item | + self saveLastScript. + scriptRepository repository: item . + self loadLastScript. + self updateLabel. + ]. + + +] + +{ #category : 'initialization' } +StSindarinDebuggerScriptingPresenter >> initializeToolbar [ + toolbar := self newToolbar addStyle: 'stToolbar'; beIcons; @@ -129,38 +181,23 @@ StSindarinDebuggerScriptingPresenter >> loadLastScript [ scriptNameInput text: 'Last updated'. code text: script . + + hasUnsavedCodeChanges := false. ] { #category : 'actions' } -StSindarinDebuggerScriptingPresenter >> loadScript [ - |scriptName| - +StSindarinDebuggerScriptingPresenter >> loadScript [ self layout: self loadScriptLayout. scriptRepository applyFilter. - scriptRepository whenLoadButtonDo: [ - scriptName := scriptRepository chooseElement. - scriptName ifNotNil: [ - scriptNameInput text: scriptName . - code text: (scriptRepository loadScript: scriptName) . - hasUnsavedCodeChanges := false. - - self updateLabel . - self updatePresenter . - ]. - - self layout: self defaultLayout. - ]. - - scriptRepository whenCancelButtonDo: [ - self layout: self defaultLayout. - ] + "check self initializeScriptRepository for loading script logic" ] { #category : 'layout' } StSindarinDebuggerScriptingPresenter >> loadScriptLayout [ ^ SpBoxLayout newTopToBottom + add: self toolbarLayout expand: false; add: #scriptRepository; yourself ] @@ -173,6 +210,9 @@ StSindarinDebuggerScriptingPresenter >> removeScriptCommand [ { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> saveLastScript [ scriptRepository saveScript: 'Last updated' code: code text. + + hasUnsavedCodeChanges := false. + self updateLabel ] { #category : 'actions' } @@ -211,6 +251,14 @@ StSindarinDebuggerScriptingPresenter >> toolbarActions [ ^ group ] +{ #category : 'layout' } +StSindarinDebuggerScriptingPresenter >> toolbarLayout [ + ^ SpBoxLayout newLeftToRight + add: #toolbar expand: false; + add: #scriptRepositoryChooser; + yourself. +] + { #category : 'initialization' } StSindarinDebuggerScriptingPresenter >> updateCode [ From a70ac09a1c66446491f45fd30c0692d0fecad671 Mon Sep 17 00:00:00 2001 From: Volant Date: Fri, 13 Jun 2025 17:20:11 +0200 Subject: [PATCH 03/17] Improves clarity by distinguishing between repository selection and script selection - Renamed StSindarinDebuggerScriptRepositoryChooserPresenter to repositoryChooser - Renamed StSindarinDebuggerScriptRepositoryPresenter to scriptChooser --- ...inDebuggerScriptChooserPresenter.class.st} | 24 ++++++++-------- ...indarinDebuggerScriptingPresenter.class.st | 28 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) rename src/NewTools-Sindarin-Tools/{StSindarinDebuggerScriptRepositoryPresenter.class.st => StSindarinDebuggerScriptChooserPresenter.class.st} (65%) diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st similarity index 65% rename from src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st rename to src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st index b3556557..2319bcff 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st @@ -1,5 +1,5 @@ Class { - #name : 'StSindarinDebuggerScriptRepositoryPresenter', + #name : 'StSindarinDebuggerScriptChooserPresenter', #superclass : 'SpPresenterWithModel', #instVars : [ 'scriptList', @@ -15,7 +15,7 @@ Class { } { #category : 'actions' } -StSindarinDebuggerScriptRepositoryPresenter >> applyFilter [ +StSindarinDebuggerScriptChooserPresenter >> applyFilter [ |filtered| filtered := repository scriptsNames select: [ :each | each asLowercase includesSubstring: filter text asLowercase ]. @@ -23,18 +23,18 @@ StSindarinDebuggerScriptRepositoryPresenter >> applyFilter [ ] { #category : 'accessing' } -StSindarinDebuggerScriptRepositoryPresenter >> chooseElement [ +StSindarinDebuggerScriptChooserPresenter >> chooseElement [ ^ chooseElement ] { #category : 'initialization' } -StSindarinDebuggerScriptRepositoryPresenter >> connectPresenters [ +StSindarinDebuggerScriptChooserPresenter >> connectPresenters [ scriptList transmitTo: self ] { #category : 'layout' } -StSindarinDebuggerScriptRepositoryPresenter >> defaultLayout [ +StSindarinDebuggerScriptChooserPresenter >> defaultLayout [ |buttonRow| buttonRow := SpBoxLayout newLeftToRight @@ -52,7 +52,7 @@ StSindarinDebuggerScriptRepositoryPresenter >> defaultLayout [ ] { #category : 'initialization' } -StSindarinDebuggerScriptRepositoryPresenter >> initializePresenters [ +StSindarinDebuggerScriptChooserPresenter >> initializePresenters [ scriptList := self newList. filter := self newTextInput. @@ -69,32 +69,32 @@ StSindarinDebuggerScriptRepositoryPresenter >> initializePresenters [ ] { #category : 'actions' } -StSindarinDebuggerScriptRepositoryPresenter >> loadScript: aString [ +StSindarinDebuggerScriptChooserPresenter >> loadScript: aString [ ^ repository loadScript: aString. ] { #category : 'accessing' } -StSindarinDebuggerScriptRepositoryPresenter >> repository: aScriptRepository [ +StSindarinDebuggerScriptChooserPresenter >> repository: aScriptRepository [ repository := aScriptRepository. self applyFilter ] { #category : 'actions' } -StSindarinDebuggerScriptRepositoryPresenter >> saveScript: aStringName code: aStringCode [ +StSindarinDebuggerScriptChooserPresenter >> saveScript: aStringName code: aStringCode [ repository saveScript: aStringName code: aStringCode. ] { #category : 'transmission' } -StSindarinDebuggerScriptRepositoryPresenter >> setModel: aListElement [ +StSindarinDebuggerScriptChooserPresenter >> setModel: aListElement [ chooseElement := aListElement ] { #category : 'actions' } -StSindarinDebuggerScriptRepositoryPresenter >> whenCancelButtonDo: aBlock [ +StSindarinDebuggerScriptChooserPresenter >> whenCancelButtonDo: aBlock [ cancelButton action: aBlock . ] { #category : 'actions' } -StSindarinDebuggerScriptRepositoryPresenter >> whenLoadButtonDo: aBlock [ +StSindarinDebuggerScriptChooserPresenter >> whenLoadButtonDo: aBlock [ loadButton action: aBlock . ] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st index 649c5491..a88a183a 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st @@ -20,8 +20,8 @@ Class { 'resultLabel', 'hasUnsavedCodeChanges', 'scriptNameInput', - 'scriptRepository', - 'scriptRepositoryChooser' + 'scriptRepositoryChooser', + 'scriptChooser' ], #category : 'NewTools-Sindarin-Tools-Presenters', #package : 'NewTools-Sindarin-Tools', @@ -126,14 +126,14 @@ StSindarinDebuggerScriptingPresenter >> initializePresenters [ StSindarinDebuggerScriptingPresenter >> initializeScriptRepository [ |scriptName| - scriptRepository := StSindarinDebuggerScriptRepositoryPresenter newApplication: self application. - scriptRepository repository: self defaultScriptRepository. + scriptChooser := StSindarinDebuggerScriptChooserPresenter newApplication: self application. + scriptChooser repository: self defaultScriptRepository. - scriptRepository whenLoadButtonDo: [ - scriptName := scriptRepository chooseElement. + scriptChooser whenLoadButtonDo: [ + scriptName := scriptChooser chooseElement. scriptName ifNotNil: [ scriptNameInput text: scriptName . - code text: (scriptRepository loadScript: scriptName) . + code text: (scriptChooser loadScript: scriptName) . hasUnsavedCodeChanges := false. self updateLabel . @@ -143,7 +143,7 @@ StSindarinDebuggerScriptingPresenter >> initializeScriptRepository [ self layout: self defaultLayout. ]. - scriptRepository whenCancelButtonDo: [ + scriptChooser whenCancelButtonDo: [ self layout: self defaultLayout. ] ] @@ -156,7 +156,7 @@ StSindarinDebuggerScriptingPresenter >> initializeScriptRepositoryChooser [ findRepositories; whenSelectedItemChangedDo: [ :item | self saveLastScript. - scriptRepository repository: item . + scriptChooser repository: item . self loadLastScript. self updateLabel. ]. @@ -177,7 +177,7 @@ StSindarinDebuggerScriptingPresenter >> initializeToolbar [ StSindarinDebuggerScriptingPresenter >> loadLastScript [ |script| - script := (scriptRepository loadScript: 'Last updated') ifNil: ['sindarin stepOver']. + script := (scriptChooser loadScript: 'Last updated') ifNil: ['sindarin stepOver']. scriptNameInput text: 'Last updated'. code text: script . @@ -189,7 +189,7 @@ StSindarinDebuggerScriptingPresenter >> loadLastScript [ StSindarinDebuggerScriptingPresenter >> loadScript [ self layout: self loadScriptLayout. - scriptRepository applyFilter. + scriptChooser applyFilter. "check self initializeScriptRepository for loading script logic" ] @@ -198,7 +198,7 @@ StSindarinDebuggerScriptingPresenter >> loadScript [ StSindarinDebuggerScriptingPresenter >> loadScriptLayout [ ^ SpBoxLayout newTopToBottom add: self toolbarLayout expand: false; - add: #scriptRepository; + add: #scriptChooser ; yourself ] @@ -209,7 +209,7 @@ StSindarinDebuggerScriptingPresenter >> removeScriptCommand [ { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> saveLastScript [ - scriptRepository saveScript: 'Last updated' code: code text. + scriptChooser saveScript: 'Last updated' code: code text. hasUnsavedCodeChanges := false. self updateLabel @@ -218,7 +218,7 @@ StSindarinDebuggerScriptingPresenter >> saveLastScript [ { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> saveScript [ - scriptRepository saveScript: (scriptNameInput text) code: (code text). + scriptChooser saveScript: (scriptNameInput text) code: (code text). hasUnsavedCodeChanges := false. self updateLabel From 6b90381b643cb64bc3c65dde7636c0fd908c65ee Mon Sep 17 00:00:00 2001 From: Volant Date: Fri, 13 Jun 2025 17:40:50 +0200 Subject: [PATCH 04/17] move acces to save / load script from the scriptChooser to the scriptRepositoryChooser --- .../StSindarinDebuggerScriptChooserPresenter.class.st | 10 ---------- ...inDebuggerScriptRepositoryChooserPresenter.class.st | 10 ++++++++++ .../StSindarinDebuggerScriptingPresenter.class.st | 9 ++++----- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st index 2319bcff..b2eed445 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st @@ -68,22 +68,12 @@ StSindarinDebuggerScriptChooserPresenter >> initializePresenters [ ] -{ #category : 'actions' } -StSindarinDebuggerScriptChooserPresenter >> loadScript: aString [ - ^ repository loadScript: aString. -] - { #category : 'accessing' } StSindarinDebuggerScriptChooserPresenter >> repository: aScriptRepository [ repository := aScriptRepository. self applyFilter ] -{ #category : 'actions' } -StSindarinDebuggerScriptChooserPresenter >> saveScript: aStringName code: aStringCode [ - repository saveScript: aStringName code: aStringCode. -] - { #category : 'transmission' } StSindarinDebuggerScriptChooserPresenter >> setModel: aListElement [ chooseElement := aListElement diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st index 87959f99..c79d147c 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st @@ -15,3 +15,13 @@ StSindarinDebuggerScriptRepositoryChooserPresenter >> display [ StSindarinDebuggerScriptRepositoryChooserPresenter >> findRepositories [ self items: StSindarinDebuggerScriptRepository subclasses ] + +{ #category : 'actions' } +StSindarinDebuggerScriptRepositoryChooserPresenter >> loadScript: aString [ + ^ self selectedItem loadScript: aString +] + +{ #category : 'accessing' } +StSindarinDebuggerScriptRepositoryChooserPresenter >> saveScript: aStringKey code: aStringValue [ + self selectedItem saveScript: aStringKey code: aStringValue +] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st index a88a183a..84d99f34 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st @@ -133,7 +133,7 @@ StSindarinDebuggerScriptingPresenter >> initializeScriptRepository [ scriptName := scriptChooser chooseElement. scriptName ifNotNil: [ scriptNameInput text: scriptName . - code text: (scriptChooser loadScript: scriptName) . + code text: (scriptRepositoryChooser loadScript: scriptName) . hasUnsavedCodeChanges := false. self updateLabel . @@ -155,7 +155,6 @@ StSindarinDebuggerScriptingPresenter >> initializeScriptRepositoryChooser [ scriptRepositoryChooser findRepositories; whenSelectedItemChangedDo: [ :item | - self saveLastScript. scriptChooser repository: item . self loadLastScript. self updateLabel. @@ -177,7 +176,7 @@ StSindarinDebuggerScriptingPresenter >> initializeToolbar [ StSindarinDebuggerScriptingPresenter >> loadLastScript [ |script| - script := (scriptChooser loadScript: 'Last updated') ifNil: ['sindarin stepOver']. + script := (scriptRepositoryChooser loadScript: 'Last updated') ifNil: ['sindarin stepOver']. scriptNameInput text: 'Last updated'. code text: script . @@ -209,7 +208,7 @@ StSindarinDebuggerScriptingPresenter >> removeScriptCommand [ { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> saveLastScript [ - scriptChooser saveScript: 'Last updated' code: code text. + scriptRepositoryChooser saveScript: 'Last updated' code: code text. hasUnsavedCodeChanges := false. self updateLabel @@ -218,7 +217,7 @@ StSindarinDebuggerScriptingPresenter >> saveLastScript [ { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> saveScript [ - scriptChooser saveScript: (scriptNameInput text) code: (code text). + scriptRepositoryChooser saveScript: (scriptNameInput text) code: (code text). hasUnsavedCodeChanges := false. self updateLabel From 6af376154239723fadf76885c04952c9f23b8e34 Mon Sep 17 00:00:00 2001 From: Volant Date: Sat, 14 Jun 2025 12:41:14 +0200 Subject: [PATCH 05/17] rename initializeScriptRepository to initializeScriptChooser --- .../StSindarinDebuggerScriptingPresenter.class.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st index 84d99f34..b935fa0d 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st @@ -104,7 +104,7 @@ StSindarinDebuggerScriptingPresenter >> initializePresenters [ scriptNameInput := self newTextInput. resultLabel := self newLabel. - self initializeScriptRepository. + self initializeScriptChooser. self initializeScriptRepositoryChooser. code := self newCode. @@ -123,7 +123,7 @@ StSindarinDebuggerScriptingPresenter >> initializePresenters [ ] { #category : 'initialization' } -StSindarinDebuggerScriptingPresenter >> initializeScriptRepository [ +StSindarinDebuggerScriptingPresenter >> initializeScriptChooser [ |scriptName| scriptChooser := StSindarinDebuggerScriptChooserPresenter newApplication: self application. From 2e9b4f0a620aa2ec9b282e049e078eb9147c611f Mon Sep 17 00:00:00 2001 From: Volant Date: Mon, 16 Jun 2025 15:45:24 +0200 Subject: [PATCH 06/17] Add StSindarinDebuggerCreateCommandPresenter for command creation UI - Created StSindarinDebuggerCreateCommandPresenter to let users choose a description and an icon for a new command (command creation logic not implemented yet). - Updated StSindarinDebuggerScriptingPresenter to use the new presenter when the user clicks on "create command". --- ...rinDebuggerCreateCommandPresenter.class.st | 123 ++++++++++++++++++ ...indarinDebuggerScriptingPresenter.class.st | 35 ++++- 2 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st new file mode 100644 index 00000000..92233f7f --- /dev/null +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st @@ -0,0 +1,123 @@ +Class { + #name : 'StSindarinDebuggerCreateCommandPresenter', + #superclass : 'SpPresenterWithModel', + #instVars : [ + 'descriptionInput', + 'cancelButton', + 'createButton', + 'package', + 'iconList', + 'iconNameSelected', + 'commandName', + 'code' + ], + #category : 'NewTools-Sindarin-Tools-Presenters', + #package : 'NewTools-Sindarin-Tools', + #tag : 'Presenters' +} + +{ #category : 'accessing' } +StSindarinDebuggerCreateCommandPresenter >> code: aCode [ + code := aCode +] + +{ #category : 'accessing' } +StSindarinDebuggerCreateCommandPresenter >> commandName: aName [ + commandName := aName asCamelCase +] + +{ #category : 'initialization' } +StSindarinDebuggerCreateCommandPresenter >> connectPresenters [ + iconList transmitTo: self +] + +{ #category : 'actions' } +StSindarinDebuggerCreateCommandPresenter >> createCommand [ + | className description | + className := 'Sindarin', (commandName ifNil: ['Default']), 'MyCommand'. + description := descriptionInput text. + + SindarinCommand << className + package: package . + + Transcript showCr: ('Class name ', className ). + Transcript showCr: ('Description ', description ). + Transcript showCr: ('Code ', code ). + Transcript showCr: ('Package ', package ). + + "execute" + + "defaultIconName" + "iconNameSelected" + + "defaultDescritpion" + "description" + + "defaultName" + "nameInput text asCamelCase" + +] + +{ #category : 'layout' } +StSindarinDebuggerCreateCommandPresenter >> defaultLayout [ + |buttonRow| + + buttonRow := SpBoxLayout newLeftToRight + spacing: 6; + add: createButton; + add: cancelButton; + yourself. + + ^ SpBoxLayout newTopToBottom + spacing: 5; + add: descriptionInput expand: false; + add: iconList; + add: buttonRow expand: false; + yourself. +] + +{ #category : 'initialization' } +StSindarinDebuggerCreateCommandPresenter >> initializeIconList [ + |icons| + icons := ThemeIcons loadDefault. + iconList + items: icons allIconNames ; + display: [ :elm | ThemeIcons iconNamed: elm ] +] + +{ #category : 'initialization' } +StSindarinDebuggerCreateCommandPresenter >> initializePresenters [ + + descriptionInput := self newTextInput. + descriptionInput placeholder: 'Command description'. + + iconList := self newList. + self initializeIconList. + + createButton := self newButton. + createButton label: 'Create'. + + cancelButton := self newButton. + cancelButton label: 'Cancel'. + +] + +{ #category : 'accessing' } +StSindarinDebuggerCreateCommandPresenter >> package: aPackageName [ + package := aPackageName +] + +{ #category : 'transmission' } +StSindarinDebuggerCreateCommandPresenter >> setModel: aIconName [ + iconNameSelected := aIconName. +] + +{ #category : 'enumerating' } +StSindarinDebuggerCreateCommandPresenter >> whenCancelButtonDo: aBlock [ + cancelButton action: aBlock . +] + +{ #category : 'enumerating' } +StSindarinDebuggerCreateCommandPresenter >> whenCreateButtonDo: aBlock [ + createButton action: aBlock . +] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st index b935fa0d..786a0791 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st @@ -21,7 +21,8 @@ Class { 'hasUnsavedCodeChanges', 'scriptNameInput', 'scriptRepositoryChooser', - 'scriptChooser' + 'scriptChooser', + 'commandCreater' ], #category : 'NewTools-Sindarin-Tools-Presenters', #package : 'NewTools-Sindarin-Tools', @@ -36,7 +37,16 @@ StSindarinDebuggerScriptingPresenter >> accept: aVisitor [ { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> createCommandFromScript [ - self flag: 'todo' + self flag: 'todo'. + self layout: self createCommandLayout. +] + +{ #category : 'layout' } +StSindarinDebuggerScriptingPresenter >> createCommandLayout [ + ^ SpBoxLayout newTopToBottom + add: self toolbarLayout expand: false; + add: commandCreater ; + yourself ] { #category : 'accessing' } @@ -99,6 +109,21 @@ StSindarinDebuggerScriptingPresenter >> hasUnsavedCodeChanges [ ^ hasUnsavedCodeChanges ifNil: [ hasUnsavedCodeChanges := false ] ] +{ #category : 'initialization' } +StSindarinDebuggerScriptingPresenter >> initializeCommandCreater [ + commandCreater := StSindarinDebuggerCreateCommandPresenter newApplication: self application. + commandCreater package: (self defaultScriptRepository package name). + commandCreater + whenCancelButtonDo: [ self layout: self defaultLayout ]; + whenCreateButtonDo: [ + commandCreater + commandName: scriptNameInput text; + code: code text. + commandCreater createCommand. + self layout: self defaultLayout + ]. +] + { #category : 'initialization' } StSindarinDebuggerScriptingPresenter >> initializePresenters [ scriptNameInput := self newTextInput. @@ -106,6 +131,7 @@ StSindarinDebuggerScriptingPresenter >> initializePresenters [ self initializeScriptChooser. self initializeScriptRepositoryChooser. + self initializeCommandCreater. code := self newCode. self loadLastScript. @@ -118,8 +144,6 @@ StSindarinDebuggerScriptingPresenter >> initializePresenters [ resultInspection owner: self. self initializeToolbar. self updateLabel. - - ] { #category : 'initialization' } @@ -154,7 +178,8 @@ StSindarinDebuggerScriptingPresenter >> initializeScriptRepositoryChooser [ scriptRepositoryChooser := StSindarinDebuggerScriptRepositoryChooserPresenter newApplication: self application. scriptRepositoryChooser findRepositories; - whenSelectedItemChangedDo: [ :item | + whenSelectedItemChangedDo: [ :item | + commandCreater package: (item package name). scriptChooser repository: item . self loadLastScript. self updateLabel. From a141b00c28f2ee0c946908c9fbab6b33bcd6aa0a Mon Sep 17 00:00:00 2001 From: Volant Date: Wed, 18 Jun 2025 19:29:01 +0200 Subject: [PATCH 07/17] - createCommand create the class without any methods (todo) - SindarinDefaultScriptRepository is moved to NewTools-Sindarin-Script wich required to add thi package to the baseline --- src/BaselineOfNewTools/BaselineOfNewTools.class.st | 1 + .../SindarinCommand.class.st | 10 ++++++++++ .../SindarinDefaultScriptRepository.class.st | 6 +++--- src/NewTools-Sindarin-Scripts/package.st | 1 + .../StSindarinDebuggerCreateCommandPresenter.class.st | 11 ++++------- 5 files changed, 19 insertions(+), 10 deletions(-) rename src/{NewTools-Sindarin-Commands => NewTools-Sindarin-Scripts}/SindarinDefaultScriptRepository.class.st (68%) create mode 100644 src/NewTools-Sindarin-Scripts/package.st diff --git a/src/BaselineOfNewTools/BaselineOfNewTools.class.st b/src/BaselineOfNewTools/BaselineOfNewTools.class.st index 78a7dc17..77529775 100644 --- a/src/BaselineOfNewTools/BaselineOfNewTools.class.st +++ b/src/BaselineOfNewTools/BaselineOfNewTools.class.st @@ -103,6 +103,7 @@ BaselineOfNewTools >> baseline: spec [ package: 'NewTools-Sindarin-Commands'; package: 'NewTools-Sindarin-Commands-Tests' with: [ spec requires: #( 'NewTools-Sindarin-Commands' 'Sindarin' ) ]; package: 'NewTools-Sindarin-Tools' with: [ spec requires: #( 'NewTools-Sindarin-Commands' 'Sindarin' ) ]; + package: 'NewTools-Sindarin-Scripts' with: [ spec requires: #( 'NewTools-Sindarin-Commands' 'Sindarin' ) ]; "package: 'NewTools-Sindarin-ProcessInspector' with: [ spec requires: #('NewTools-Sindarin-Commands' 'Sindarin') ];""Debugger Selector" package: 'NewTools-DebuggerSelector' with: [ spec requires: #( 'NewTools-SpTextPresenterDecorators' ) ]; diff --git a/src/NewTools-Sindarin-Commands/SindarinCommand.class.st b/src/NewTools-Sindarin-Commands/SindarinCommand.class.st index 63686ea3..0ecc1f2d 100644 --- a/src/NewTools-Sindarin-Commands/SindarinCommand.class.st +++ b/src/NewTools-Sindarin-Commands/SindarinCommand.class.st @@ -1,6 +1,9 @@ Class { #name : 'SindarinCommand', #superclass : 'CmCommand', + #instVars : [ + 'sindarin' + ], #category : 'NewTools-Sindarin-Commands', #package : 'NewTools-Sindarin-Commands' } @@ -24,6 +27,13 @@ SindarinCommand class >> isAbstract [ ^ self == SindarinCommand ] +{ #category : 'accessing' } +SindarinCommand >> context: aDebugger [ + super context: aDebugger. + sindarin := aDebugger sindarinDebugger. + +] + { #category : 'accessing' } SindarinCommand >> debuggerPresenter [ ^self context diff --git a/src/NewTools-Sindarin-Commands/SindarinDefaultScriptRepository.class.st b/src/NewTools-Sindarin-Scripts/SindarinDefaultScriptRepository.class.st similarity index 68% rename from src/NewTools-Sindarin-Commands/SindarinDefaultScriptRepository.class.st rename to src/NewTools-Sindarin-Scripts/SindarinDefaultScriptRepository.class.st index 017c7862..cbb52bd2 100644 --- a/src/NewTools-Sindarin-Commands/SindarinDefaultScriptRepository.class.st +++ b/src/NewTools-Sindarin-Scripts/SindarinDefaultScriptRepository.class.st @@ -1,12 +1,12 @@ Class { #name : 'SindarinDefaultScriptRepository', #superclass : 'StSindarinDebuggerScriptRepository', - #category : 'NewTools-Sindarin-Commands', - #package : 'NewTools-Sindarin-Commands' + #category : 'NewTools-Sindarin-Scripts', + #package : 'NewTools-Sindarin-Scripts' } { #category : 'accessing' } SindarinDefaultScriptRepository class >> repositoryName [ "Return the name of the repository." - ^ 'Default Repository' + ^ 'Scripts' ] diff --git a/src/NewTools-Sindarin-Scripts/package.st b/src/NewTools-Sindarin-Scripts/package.st new file mode 100644 index 00000000..419017d2 --- /dev/null +++ b/src/NewTools-Sindarin-Scripts/package.st @@ -0,0 +1 @@ +Package { #name : 'NewTools-Sindarin-Scripts' } diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st index 92233f7f..6c59cafa 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st @@ -34,16 +34,13 @@ StSindarinDebuggerCreateCommandPresenter >> connectPresenters [ { #category : 'actions' } StSindarinDebuggerCreateCommandPresenter >> createCommand [ | className description | - className := 'Sindarin', (commandName ifNil: ['Default']), 'MyCommand'. + className := 'Sindarin', (commandName ifNil: ['Default']), 'Command'. description := descriptionInput text. SindarinCommand << className - package: package . - - Transcript showCr: ('Class name ', className ). - Transcript showCr: ('Description ', description ). - Transcript showCr: ('Code ', code ). - Transcript showCr: ('Package ', package ). + package: package; + build; + install. "execute" From 2519c191b453b7bd1c5d99dd8e6cddfc14b45467 Mon Sep 17 00:00:00 2001 From: Volant Date: Wed, 18 Jun 2025 20:22:07 +0200 Subject: [PATCH 08/17] temporary remove sindarin := --- src/NewTools-Sindarin-Commands/SindarinCommand.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NewTools-Sindarin-Commands/SindarinCommand.class.st b/src/NewTools-Sindarin-Commands/SindarinCommand.class.st index 0ecc1f2d..5091fddd 100644 --- a/src/NewTools-Sindarin-Commands/SindarinCommand.class.st +++ b/src/NewTools-Sindarin-Commands/SindarinCommand.class.st @@ -30,7 +30,7 @@ SindarinCommand class >> isAbstract [ { #category : 'accessing' } SindarinCommand >> context: aDebugger [ super context: aDebugger. - sindarin := aDebugger sindarinDebugger. + "sindarin := aDebugger sindarinDebugger." ] From 705b92b80655b09554c7a093aa88d7a1951c9552 Mon Sep 17 00:00:00 2001 From: Volant Date: Fri, 20 Jun 2025 12:12:49 +0200 Subject: [PATCH 09/17] - SindarinCommand remove Override of context: - StSindarinDebuggerCreateCommand createCommand done --- .../SindarinCommand.class.st | 10 ------- ...rinDebuggerCreateCommandPresenter.class.st | 30 +++++++++++-------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/NewTools-Sindarin-Commands/SindarinCommand.class.st b/src/NewTools-Sindarin-Commands/SindarinCommand.class.st index 5091fddd..63686ea3 100644 --- a/src/NewTools-Sindarin-Commands/SindarinCommand.class.st +++ b/src/NewTools-Sindarin-Commands/SindarinCommand.class.st @@ -1,9 +1,6 @@ Class { #name : 'SindarinCommand', #superclass : 'CmCommand', - #instVars : [ - 'sindarin' - ], #category : 'NewTools-Sindarin-Commands', #package : 'NewTools-Sindarin-Commands' } @@ -27,13 +24,6 @@ SindarinCommand class >> isAbstract [ ^ self == SindarinCommand ] -{ #category : 'accessing' } -SindarinCommand >> context: aDebugger [ - super context: aDebugger. - "sindarin := aDebugger sindarinDebugger." - -] - { #category : 'accessing' } SindarinCommand >> debuggerPresenter [ ^self context diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st index 6c59cafa..48c98308 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st @@ -33,25 +33,31 @@ StSindarinDebuggerCreateCommandPresenter >> connectPresenters [ { #category : 'actions' } StSindarinDebuggerCreateCommandPresenter >> createCommand [ - | className description | - className := 'Sindarin', (commandName ifNil: ['Default']), 'Command'. - description := descriptionInput text. + | name className description class | + name := (commandName ifNil: ['Default']) asCamelCase. + className := 'Sindarin{1}Command' format: {name}. + description := descriptionInput text ifNil: ['']. - SindarinCommand << className + class := SindarinCommand << className package: package; build; install. + + class compile: ('execute + |sindarin| + sindarin := self context sindarinDebugger. + self context debuggerActionModel preventUpdatesDuring: [ + {1} + ]' format: {'"TODO"'}) classified: 'executing'. - "execute" - - "defaultIconName" - "iconNameSelected" + class class compile: ('defaultIconName + ^#{1}' format: {iconNameSelected}) classified: 'initialization'. - "defaultDescritpion" - "description" + class class compile: ('defaultDescription + ^ ''{1}''' format: {description}) classified: 'initialization'. - "defaultName" - "nameInput text asCamelCase" + class class compile: ('defaultName + ^ ''{1}''' format: {name}) classified: 'initialization'. ] From fda3b191452b91b0bfdfaca0581c7118cb1999ea Mon Sep 17 00:00:00 2001 From: Volant Date: Fri, 20 Jun 2025 13:52:02 +0200 Subject: [PATCH 10/17] - createCommand method calls createMenu to automatically create the debugger menu --- ...rinDebuggerCreateCommandPresenter.class.st | 31 +++++++++++++++++-- ...indarinDebuggerScriptingPresenter.class.st | 7 +++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st index 48c98308..6310670f 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st @@ -9,7 +9,8 @@ Class { 'iconList', 'iconNameSelected', 'commandName', - 'code' + 'code', + 'projectName' ], #category : 'NewTools-Sindarin-Tools-Presenters', #package : 'NewTools-Sindarin-Tools', @@ -48,7 +49,7 @@ StSindarinDebuggerCreateCommandPresenter >> createCommand [ sindarin := self context sindarinDebugger. self context debuggerActionModel preventUpdatesDuring: [ {1} - ]' format: {'"TODO"'}) classified: 'executing'. + ]' format: {code}) classified: 'executing'. class class compile: ('defaultIconName ^#{1}' format: {iconNameSelected}) classified: 'initialization'. @@ -59,6 +60,27 @@ StSindarinDebuggerCreateCommandPresenter >> createCommand [ class class compile: ('defaultName ^ ''{1}''' format: {name}) classified: 'initialization'. + self createMenu. + +] + +{ #category : 'actions' } +StSindarinDebuggerCreateCommandPresenter >> createMenu [ + StDebugger class compile: ('buildSindarin{2}ExtentionCommandsCommandsGroupWith: stDebuggerInstance forRoot: rootCommandGroup + + | commands toolbarCommandGroup | + commands := (SindarinCommand subclasses select: [ :sub | sub packageName = ''{3}'']) collect: [ :each | each forSpecContext: stDebuggerInstance ]. + + toolbarCommandGroup := CmCommandGroup forSpec + beToolbarPopoverButton; + name: ''{1}''; + icon: (stDebuggerInstance application iconNamed: #changeUpdate); + yourself. + + (self debuggerToolbarCommandGroupFor: rootCommandGroup) register: toolbarCommandGroup. + + commands do: [ :c | toolbarCommandGroup register: c ]' format: {projectName. projectName asCamelCase . package}) + classified: 'extensions' ] { #category : 'layout' } @@ -110,6 +132,11 @@ StSindarinDebuggerCreateCommandPresenter >> package: aPackageName [ package := aPackageName ] +{ #category : 'accessing' } +StSindarinDebuggerCreateCommandPresenter >> projectName: aName [ + projectName := aName. +] + { #category : 'transmission' } StSindarinDebuggerCreateCommandPresenter >> setModel: aIconName [ iconNameSelected := aIconName. diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st index 786a0791..ed34434f 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st @@ -112,8 +112,9 @@ StSindarinDebuggerScriptingPresenter >> hasUnsavedCodeChanges [ { #category : 'initialization' } StSindarinDebuggerScriptingPresenter >> initializeCommandCreater [ commandCreater := StSindarinDebuggerCreateCommandPresenter newApplication: self application. - commandCreater package: (self defaultScriptRepository package name). commandCreater + package: (self defaultScriptRepository package name); + projectName: (self defaultScriptRepository repositoryName); whenCancelButtonDo: [ self layout: self defaultLayout ]; whenCreateButtonDo: [ commandCreater @@ -179,7 +180,9 @@ StSindarinDebuggerScriptingPresenter >> initializeScriptRepositoryChooser [ scriptRepositoryChooser findRepositories; whenSelectedItemChangedDo: [ :item | - commandCreater package: (item package name). + commandCreater + package: (item package name); + projectName: (item repositoryName). scriptChooser repository: item . self loadLastScript. self updateLabel. From 902ce2440fcd3dd2013e57b625fe699f0a013061 Mon Sep 17 00:00:00 2001 From: Volant Date: Fri, 20 Jun 2025 16:00:46 +0200 Subject: [PATCH 11/17] - fix command name - fix load layout --- .../StSindarinDebuggerCreateCommandPresenter.class.st | 8 ++++---- .../StSindarinDebuggerScriptingPresenter.class.st | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st index 6310670f..6f458d89 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st @@ -35,8 +35,8 @@ StSindarinDebuggerCreateCommandPresenter >> connectPresenters [ { #category : 'actions' } StSindarinDebuggerCreateCommandPresenter >> createCommand [ | name className description class | - name := (commandName ifNil: ['Default']) asCamelCase. - className := 'Sindarin{1}Command' format: {name}. + name := commandName ifNil: ['Default']. + className := 'Sindarin{1}Command' format: {name asCamelCase}. description := descriptionInput text ifNil: ['']. class := SindarinCommand << className @@ -66,7 +66,7 @@ StSindarinDebuggerCreateCommandPresenter >> createCommand [ { #category : 'actions' } StSindarinDebuggerCreateCommandPresenter >> createMenu [ - StDebugger class compile: ('buildSindarin{2}ExtentionCommandsCommandsGroupWith: stDebuggerInstance forRoot: rootCommandGroup + StDebugger class compile: ('buildSindarin{2}ExtentionCommandsGroupWith: stDebuggerInstance forRoot: rootCommandGroup | commands toolbarCommandGroup | commands := (SindarinCommand subclasses select: [ :sub | sub packageName = ''{3}'']) collect: [ :each | each forSpecContext: stDebuggerInstance ]. @@ -79,7 +79,7 @@ StSindarinDebuggerCreateCommandPresenter >> createMenu [ (self debuggerToolbarCommandGroupFor: rootCommandGroup) register: toolbarCommandGroup. - commands do: [ :c | toolbarCommandGroup register: c ]' format: {projectName. projectName asCamelCase . package}) + commands do: [ :c | toolbarCommandGroup register: c ].' format: {projectName. projectName asCamelCase . package}) classified: 'extensions' ] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st index ed34434f..d3ec015d 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st @@ -225,7 +225,10 @@ StSindarinDebuggerScriptingPresenter >> loadScript [ StSindarinDebuggerScriptingPresenter >> loadScriptLayout [ ^ SpBoxLayout newTopToBottom add: self toolbarLayout expand: false; - add: #scriptChooser ; + add: #scriptChooser + expand: true + fill: true + padding:2; yourself ] From 82044655f298c85fe6d300831c9c0458058fcad1 Mon Sep 17 00:00:00 2001 From: FlavienVolant <156106732+FlavienVolant@users.noreply.github.com> Date: Mon, 23 Jun 2025 16:50:56 +0200 Subject: [PATCH 12/17] Update src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st Co-authored-by: CyrilFerlicot --- .../StSindarinDebuggerCreateCommandPresenter.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st index 6f458d89..73f30558 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st @@ -79,7 +79,7 @@ StSindarinDebuggerCreateCommandPresenter >> createMenu [ (self debuggerToolbarCommandGroupFor: rootCommandGroup) register: toolbarCommandGroup. - commands do: [ :c | toolbarCommandGroup register: c ].' format: {projectName. projectName asCamelCase . package}) + commands do: [ :command | toolbarCommandGroup register: command ].' format: {projectName. projectName asCamelCase . package}) classified: 'extensions' ] From eff3507fc4831b0239c7bcdff8fe9a25eecaf91e Mon Sep 17 00:00:00 2001 From: Volant Date: Thu, 3 Jul 2025 14:28:28 +0200 Subject: [PATCH 13/17] - Added `deleteCommand` and `deleteMenu` methods to `StSindarinDebuggerCreateCommandPresenter` to allow removal of user-created commands and groups. - Removed the TODO flag from `createCommandFromScript`. - Implemented `removeScriptCommand` --- ...rinDebuggerCreateCommandPresenter.class.st | 32 +++++++++++++++++-- ...indarinDebuggerScriptingPresenter.class.st | 7 ++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st index 73f30558..d85b722e 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st @@ -35,7 +35,8 @@ StSindarinDebuggerCreateCommandPresenter >> connectPresenters [ { #category : 'actions' } StSindarinDebuggerCreateCommandPresenter >> createCommand [ | name className description class | - name := commandName ifNil: ['Default']. + + name := commandName ifNil: ['NoName']. className := 'Sindarin{1}Command' format: {name asCamelCase}. description := descriptionInput text ifNil: ['']. @@ -80,7 +81,7 @@ StSindarinDebuggerCreateCommandPresenter >> createMenu [ (self debuggerToolbarCommandGroupFor: rootCommandGroup) register: toolbarCommandGroup. commands do: [ :command | toolbarCommandGroup register: command ].' format: {projectName. projectName asCamelCase . package}) - classified: 'extensions' + classified: '*',package ] { #category : 'layout' } @@ -101,6 +102,33 @@ StSindarinDebuggerCreateCommandPresenter >> defaultLayout [ yourself. ] +{ #category : 'actions' } +StSindarinDebuggerCreateCommandPresenter >> deleteCommand [ + | name className commandsLeft| + name := commandName ifNil: ['NoName']. + className := 'Sindarin{1}Command' format: {name asCamelCase}. + + (Smalltalk globals includesKey: className asSymbol) ifTrue: [ + (Smalltalk globals at: className asSymbol) removeFromSystem. + ]. + + commandsLeft := (SindarinCommand subclasses select: [ :sub | sub packageName = package ]). + commandsLeft isEmpty ifTrue: [ self deleteMenu ] + +] + +{ #category : 'actions' } +StSindarinDebuggerCreateCommandPresenter >> deleteMenu [ + | buildGroupMethodName | + buildGroupMethodName := 'buildSindarin{1}ExtentionCommandsGroupWith:forRoot:' format: { projectName asCamelCase }. + + (StDebugger class includesSelector: buildGroupMethodName asSymbol) ifTrue: [ + StDebugger class removeSelector: buildGroupMethodName asSymbol. + ] + + +] + { #category : 'initialization' } StSindarinDebuggerCreateCommandPresenter >> initializeIconList [ |icons| diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st index d3ec015d..7e2db95e 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st @@ -37,7 +37,6 @@ StSindarinDebuggerScriptingPresenter >> accept: aVisitor [ { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> createCommandFromScript [ - self flag: 'todo'. self layout: self createCommandLayout. ] @@ -233,8 +232,10 @@ StSindarinDebuggerScriptingPresenter >> loadScriptLayout [ ] { #category : 'actions' } -StSindarinDebuggerScriptingPresenter >> removeScriptCommand [ - self flag: 'todo' +StSindarinDebuggerScriptingPresenter >> removeScriptCommand [ + commandCreater + commandName: scriptNameInput text; + deleteCommand. ] { #category : 'actions' } From a3e534346ae9b19bd37b409c76b718581396f9d4 Mon Sep 17 00:00:00 2001 From: Volant Date: Thu, 3 Jul 2025 16:08:35 +0200 Subject: [PATCH 14/17] Include project name in generated command class names --- ...rinDebuggerCreateCommandPresenter.class.st | 59 +++++++++++-------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st index d85b722e..195b0096 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st @@ -34,35 +34,44 @@ StSindarinDebuggerCreateCommandPresenter >> connectPresenters [ { #category : 'actions' } StSindarinDebuggerCreateCommandPresenter >> createCommand [ - | name className description class | - - name := commandName ifNil: ['NoName']. - className := 'Sindarin{1}Command' format: {name asCamelCase}. - description := descriptionInput text ifNil: ['']. - - class := SindarinCommand << className - package: package; - build; - install. - class compile: ('execute + | name className description class | + name := commandName ifNil: [ 'NoName' ]. + className := 'Sindarin{1}{2}Command' format: { + projectName asCamelCase. + name asCamelCase }. + description := descriptionInput text ifNil: [ '' ]. + + class := (SindarinCommand << className) + package: package; + build; + install. + + class + compile: ('execute |sindarin| sindarin := self context sindarinDebugger. self context debuggerActionModel preventUpdatesDuring: [ {1} - ]' format: {code}) classified: 'executing'. - - class class compile: ('defaultIconName - ^#{1}' format: {iconNameSelected}) classified: 'initialization'. - - class class compile: ('defaultDescription - ^ ''{1}''' format: {description}) classified: 'initialization'. - - class class compile: ('defaultName - ^ ''{1}''' format: {name}) classified: 'initialization'. - - self createMenu. + ]' format: { code }) + classified: 'executing'. + + class class + compile: ('defaultIconName + ^#{1}' format: { iconNameSelected }) + classified: 'initialization'. + + class class + compile: ('defaultDescription + ^ ''{1}''' format: { description }) + classified: 'initialization'. + + class class + compile: ('defaultName + ^ ''{1}''' format: { name }) + classified: 'initialization'. + self createMenu ] { #category : 'actions' } @@ -106,7 +115,9 @@ StSindarinDebuggerCreateCommandPresenter >> defaultLayout [ StSindarinDebuggerCreateCommandPresenter >> deleteCommand [ | name className commandsLeft| name := commandName ifNil: ['NoName']. - className := 'Sindarin{1}Command' format: {name asCamelCase}. + className := 'Sindarin{1}{2}Command' format: { + projectName asCamelCase. + name asCamelCase }. (Smalltalk globals includesKey: className asSymbol) ifTrue: [ (Smalltalk globals at: className asSymbol) removeFromSystem. From a708748e106655f628d5daf11391919f6e0643c7 Mon Sep 17 00:00:00 2001 From: Volant Date: Thu, 3 Jul 2025 16:15:25 +0200 Subject: [PATCH 15/17] format methods using cmd/ctrl + shift + f --- ...rinDebuggerCreateCommandPresenter.class.st | 115 ++++++++++-------- .../StSindarinDebuggerPresenter.class.st | 59 +++++---- ...rinDebuggerScriptChooserPresenter.class.st | 52 ++++---- ...rScriptRepositoryChooserPresenter.class.st | 10 +- 4 files changed, 134 insertions(+), 102 deletions(-) diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st index 195b0096..6d6c5395 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st @@ -19,16 +19,19 @@ Class { { #category : 'accessing' } StSindarinDebuggerCreateCommandPresenter >> code: aCode [ - code := aCode + + code := aCode ] { #category : 'accessing' } StSindarinDebuggerCreateCommandPresenter >> commandName: aName [ - commandName := aName asCamelCase + + commandName := aName asCamelCase ] { #category : 'initialization' } -StSindarinDebuggerCreateCommandPresenter >> connectPresenters [ +StSindarinDebuggerCreateCommandPresenter >> connectPresenters [ + iconList transmitTo: self ] @@ -76,7 +79,10 @@ StSindarinDebuggerCreateCommandPresenter >> createCommand [ { #category : 'actions' } StSindarinDebuggerCreateCommandPresenter >> createMenu [ - StDebugger class compile: ('buildSindarin{2}ExtentionCommandsGroupWith: stDebuggerInstance forRoot: rootCommandGroup + + StDebugger class + compile: + ('buildSindarin{2}ExtentionCommandsGroupWith: stDebuggerInstance forRoot: rootCommandGroup | commands toolbarCommandGroup | commands := (SindarinCommand subclasses select: [ :sub | sub packageName = ''{3}'']) collect: [ :each | each forSpecContext: stDebuggerInstance ]. @@ -89,104 +95,113 @@ StSindarinDebuggerCreateCommandPresenter >> createMenu [ (self debuggerToolbarCommandGroupFor: rootCommandGroup) register: toolbarCommandGroup. - commands do: [ :command | toolbarCommandGroup register: command ].' format: {projectName. projectName asCamelCase . package}) - classified: '*',package + commands do: [ :command | toolbarCommandGroup register: command ].' + format: { + projectName. + projectName asCamelCase. + package }) + classified: '*' , package ] { #category : 'layout' } -StSindarinDebuggerCreateCommandPresenter >> defaultLayout [ - |buttonRow| - - buttonRow := SpBoxLayout newLeftToRight - spacing: 6; - add: createButton; - add: cancelButton; - yourself. +StSindarinDebuggerCreateCommandPresenter >> defaultLayout [ - ^ SpBoxLayout newTopToBottom - spacing: 5; - add: descriptionInput expand: false; - add: iconList; - add: buttonRow expand: false; - yourself. + | buttonRow | + buttonRow := SpBoxLayout newLeftToRight + spacing: 6; + add: createButton; + add: cancelButton; + yourself. + + ^ SpBoxLayout newTopToBottom + spacing: 5; + add: descriptionInput expand: false; + add: iconList; + add: buttonRow expand: false; + yourself ] { #category : 'actions' } StSindarinDebuggerCreateCommandPresenter >> deleteCommand [ - | name className commandsLeft| - name := commandName ifNil: ['NoName']. + + | name className commandsLeft | + name := commandName ifNil: [ 'NoName' ]. className := 'Sindarin{1}{2}Command' format: { projectName asCamelCase. name asCamelCase }. - - (Smalltalk globals includesKey: className asSymbol) ifTrue: [ - (Smalltalk globals at: className asSymbol) removeFromSystem. - ]. - - commandsLeft := (SindarinCommand subclasses select: [ :sub | sub packageName = package ]). - commandsLeft isEmpty ifTrue: [ self deleteMenu ] + (Smalltalk globals includesKey: className asSymbol) ifTrue: [ + (Smalltalk globals at: className asSymbol) removeFromSystem ]. + + commandsLeft := SindarinCommand subclasses select: [ :sub | + sub packageName = package ]. + commandsLeft isEmpty ifTrue: [ self deleteMenu ] ] { #category : 'actions' } StSindarinDebuggerCreateCommandPresenter >> deleteMenu [ + | buildGroupMethodName | - buildGroupMethodName := 'buildSindarin{1}ExtentionCommandsGroupWith:forRoot:' format: { projectName asCamelCase }. - - (StDebugger class includesSelector: buildGroupMethodName asSymbol) ifTrue: [ - StDebugger class removeSelector: buildGroupMethodName asSymbol. - ] + buildGroupMethodName := 'buildSindarin{1}ExtentionCommandsGroupWith:forRoot:' + format: { projectName asCamelCase }. - + (StDebugger class includesSelector: buildGroupMethodName asSymbol) + ifTrue: [ + StDebugger class removeSelector: buildGroupMethodName asSymbol ] ] { #category : 'initialization' } StSindarinDebuggerCreateCommandPresenter >> initializeIconList [ - |icons| + + | icons | icons := ThemeIcons loadDefault. - iconList - items: icons allIconNames ; + iconList + items: icons allIconNames; display: [ :elm | ThemeIcons iconNamed: elm ] ] { #category : 'initialization' } -StSindarinDebuggerCreateCommandPresenter >> initializePresenters [ - - descriptionInput := self newTextInput. +StSindarinDebuggerCreateCommandPresenter >> initializePresenters [ + + descriptionInput := self newTextInput. descriptionInput placeholder: 'Command description'. - + iconList := self newList. self initializeIconList. - + createButton := self newButton. createButton label: 'Create'. - + cancelButton := self newButton. - cancelButton label: 'Cancel'. - + cancelButton label: 'Cancel' ] { #category : 'accessing' } StSindarinDebuggerCreateCommandPresenter >> package: aPackageName [ + package := aPackageName ] { #category : 'accessing' } StSindarinDebuggerCreateCommandPresenter >> projectName: aName [ - projectName := aName. + + projectName := aName ] { #category : 'transmission' } StSindarinDebuggerCreateCommandPresenter >> setModel: aIconName [ - iconNameSelected := aIconName. + + iconNameSelected := aIconName ] { #category : 'enumerating' } StSindarinDebuggerCreateCommandPresenter >> whenCancelButtonDo: aBlock [ - cancelButton action: aBlock . + + cancelButton action: aBlock ] { #category : 'enumerating' } StSindarinDebuggerCreateCommandPresenter >> whenCreateButtonDo: aBlock [ - createButton action: aBlock . + + createButton action: aBlock ] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerPresenter.class.st index e7c94a91..795d99c9 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerPresenter.class.st @@ -31,38 +31,41 @@ StSindarinDebuggerPresenter class >> defaultLayout [ { #category : 'initialization' } StSindarinDebuggerPresenter >> buildToolbar [ + | group | group := CmCommandGroup forSpec. - (SindarinCommand allSubclasses reject:#isAbstract ) - do: [ :cmd | group register: (cmd forSpecContext: self) ]. - ^ self newToolbar - displayMode: self application toolbarDisplayMode; - addStyle: 'stToolbar'; - fillWith: group + (SindarinCommand allSubclasses reject: #isAbstract) do: [ :cmd | + group register: (cmd forSpecContext: self) ]. + ^ self newToolbar + displayMode: self application toolbarDisplayMode; + addStyle: 'stToolbar'; + fillWith: group ] { #category : 'initialization' } StSindarinDebuggerPresenter >> initializePresenters [ + stack := self newList. - stack - whenSelectionChangedDo: [ :selection | + stack whenSelectionChangedDo: [ :selection | selection selectedItem - ifNil: [ inspector model: nil. - currentNodeSource text: '' ] - ifNotNil: [ | node | - node := selection selectedItem sourceNodeExecuted. - inspector model: node. - inspector setAttributeTable. - currentNodeSource text: node source. - currentNodeSource beForBehavior: node methodNode methodClass. - currentNodeSource selectionInterval: (node start to: node stop). - currentNodeSource - doItReceiver: selection selectedItem home receiver; - doItContext: selection selectedItem ]]. + ifNil: [ + inspector model: nil. + currentNodeSource text: '' ] + ifNotNil: [ + | node | + node := selection selectedItem sourceNodeExecuted. + inspector model: node. + inspector setAttributeTable. + currentNodeSource text: node source. + currentNodeSource beForBehavior: node methodNode methodClass. + currentNodeSource selectionInterval: (node start to: node stop). + currentNodeSource + doItReceiver: selection selectedItem home receiver; + doItContext: selection selectedItem ] ]. inspector := StRawInspectionPresenter on: self model stack first. currentNodeSource := self newCode. - currentNodeSource - whenBuiltDo: [ :ann | ann widget font: StandardFonts codeFont ]. + currentNodeSource whenBuiltDo: [ :ann | + ann widget font: StandardFonts codeFont ]. currentNodeSource withSyntaxHighlight. currentNodeSource text: self model node source. currentNodeSource beForBehavior: self model method methodClass. @@ -72,24 +75,28 @@ StSindarinDebuggerPresenter >> initializePresenters [ ] { #category : 'stepping' } -StSindarinDebuggerPresenter >> refresh [ +StSindarinDebuggerPresenter >> refresh [ + stack items: self model stack. stack selectIndex: 1 ] { #category : 'stepping' } -StSindarinDebuggerPresenter >> stepIn [ +StSindarinDebuggerPresenter >> stepIn [ + self model step. self refresh ] { #category : 'stepping' } -StSindarinDebuggerPresenter >> stepOver [ +StSindarinDebuggerPresenter >> stepOver [ + self model stepOver. self refresh ] { #category : 'stepping' } StSindarinDebuggerPresenter >> windowTitle [ - ^'Sindarin Debugger' + + ^ 'Sindarin Debugger' ] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st index b2eed445..77b99f40 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st @@ -16,15 +16,18 @@ Class { { #category : 'actions' } StSindarinDebuggerScriptChooserPresenter >> applyFilter [ - |filtered| + + | filtered | filtered := repository scriptsNames select: [ :each | - each asLowercase includesSubstring: filter text asLowercase ]. + each asLowercase includesSubstring: + filter text asLowercase ]. scriptList items: filtered ] { #category : 'accessing' } StSindarinDebuggerScriptChooserPresenter >> chooseElement [ - ^ chooseElement + + ^ chooseElement ] { #category : 'initialization' } @@ -35,56 +38,59 @@ StSindarinDebuggerScriptChooserPresenter >> connectPresenters [ { #category : 'layout' } StSindarinDebuggerScriptChooserPresenter >> defaultLayout [ - |buttonRow| - + + | buttonRow | buttonRow := SpBoxLayout newLeftToRight - spacing: 6; - add: #loadButton; - add: #cancelButton; - yourself. + spacing: 6; + add: #loadButton; + add: #cancelButton; + yourself. ^ SpBoxLayout newTopToBottom - spacing: 5; - add: #scriptList; - add: #filter expand: false; - add: buttonRow expand: false; - yourself + spacing: 5; + add: #scriptList; + add: #filter expand: false; + add: buttonRow expand: false; + yourself ] { #category : 'initialization' } -StSindarinDebuggerScriptChooserPresenter >> initializePresenters [ +StSindarinDebuggerScriptChooserPresenter >> initializePresenters [ + scriptList := self newList. - + filter := self newTextInput. filter placeholder: 'Filter ...'. filter whenTextChangedDo: [ self applyFilter ]. - + loadButton := self newButton. loadButton label: 'Load'. - + cancelButton := self newButton. - cancelButton label: 'Cancel'. - - + cancelButton label: 'Cancel' ] { #category : 'accessing' } StSindarinDebuggerScriptChooserPresenter >> repository: aScriptRepository [ + repository := aScriptRepository. self applyFilter ] { #category : 'transmission' } StSindarinDebuggerScriptChooserPresenter >> setModel: aListElement [ + chooseElement := aListElement ] { #category : 'actions' } StSindarinDebuggerScriptChooserPresenter >> whenCancelButtonDo: aBlock [ - cancelButton action: aBlock . + + cancelButton action: aBlock ] { #category : 'actions' } StSindarinDebuggerScriptChooserPresenter >> whenLoadButtonDo: aBlock [ - loadButton action: aBlock . + + loadButton action: aBlock ] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st index c79d147c..9d296862 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st @@ -7,21 +7,25 @@ Class { } { #category : 'api' } -StSindarinDebuggerScriptRepositoryChooserPresenter >> display [ - ^ [ :e | e repositoryName ]. +StSindarinDebuggerScriptRepositoryChooserPresenter >> display [ + + ^ [ :e | e repositoryName ] ] { #category : 'initialization' } StSindarinDebuggerScriptRepositoryChooserPresenter >> findRepositories [ + self items: StSindarinDebuggerScriptRepository subclasses ] { #category : 'actions' } StSindarinDebuggerScriptRepositoryChooserPresenter >> loadScript: aString [ - ^ self selectedItem loadScript: aString + + ^ self selectedItem loadScript: aString ] { #category : 'accessing' } StSindarinDebuggerScriptRepositoryChooserPresenter >> saveScript: aStringKey code: aStringValue [ + self selectedItem saveScript: aStringKey code: aStringValue ] From 340a7091bacd09a2f17043b6efabed4e4938092a Mon Sep 17 00:00:00 2001 From: Volant Date: Thu, 3 Jul 2025 16:46:44 +0200 Subject: [PATCH 16/17] Add documentation to script repository and dynamically generated commands --- .../StSindarinDebuggerCreateCommandPresenter.class.st | 11 +++++++++++ .../StSindarinDebuggerScriptRepository.class.st | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st index 6d6c5395..993195ca 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st @@ -74,6 +74,17 @@ StSindarinDebuggerCreateCommandPresenter >> createCommand [ ^ ''{1}''' format: { name }) classified: 'initialization'. + class comment: + ('This command was generated dynamically on {1} at {2}. +Project: {3} +Name: {4} +Description: {5}' format: { + Date today yyyymmdd. + Time now print24. + projectName. + name. + description }). + self createMenu ] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepository.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepository.class.st index 991c9559..126d1b14 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepository.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepository.class.st @@ -1,3 +1,14 @@ +" +StSindarinDebuggerScriptRepository is an abstract class that defines the logic for managing script repositories in the context of Sindarin debugger extensions. + +Its main responsibilities include: +- Saving scripts by name and code. +- Retrieving the list of available script names in the repository. +- Loading the code of a script given its name. + +Subclasses are expected to implement the class side `repositoryName` method, which specifies the name (or identifier) of the script repository, typically based on the project it is associated with. + +" Class { #name : 'StSindarinDebuggerScriptRepository', #superclass : 'Object', From 83ff81a19df36866834124051ea9d9ac8da62d96 Mon Sep 17 00:00:00 2001 From: Volant Date: Tue, 8 Jul 2025 14:37:14 +0200 Subject: [PATCH 17/17] - expand toolbar layout - rename StSindarinDebuggerCreateCommandPresenter to StSindarinDebuggerCommandPresenter - rename whenCancelButtonDo to whenCancelDo - rename whenLoadButtonDo to whenLoadDo - rename createCommand and createMenu to generateCommand and generateMenu --- src/NewTools-Debugger/StDebugger.class.st | 2 +- ...SindarinDebuggerCommandPresenter.class.st} | 122 +++++++++--------- ...rinDebuggerScriptChooserPresenter.class.st | 4 +- ...indarinDebuggerScriptingPresenter.class.st | 12 +- 4 files changed, 70 insertions(+), 70 deletions(-) rename src/NewTools-Sindarin-Tools/{StSindarinDebuggerCreateCommandPresenter.class.st => StSindarinDebuggerCommandPresenter.class.st} (81%) diff --git a/src/NewTools-Debugger/StDebugger.class.st b/src/NewTools-Debugger/StDebugger.class.st index ddaf1655..a59af8c6 100644 --- a/src/NewTools-Debugger/StDebugger.class.st +++ b/src/NewTools-Debugger/StDebugger.class.st @@ -385,7 +385,7 @@ StDebugger >> buildToolbar [ hAlignStart; vAlignCenter; yourself) - expand: false; + expand: true; yourself) ] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCommandPresenter.class.st similarity index 81% rename from src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st rename to src/NewTools-Sindarin-Tools/StSindarinDebuggerCommandPresenter.class.st index 993195ca..4af8db97 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerCreateCommandPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCommandPresenter.class.st @@ -1,5 +1,5 @@ Class { - #name : 'StSindarinDebuggerCreateCommandPresenter', + #name : 'StSindarinDebuggerCommandPresenter', #superclass : 'SpPresenterWithModel', #instVars : [ 'descriptionInput', @@ -18,25 +18,72 @@ Class { } { #category : 'accessing' } -StSindarinDebuggerCreateCommandPresenter >> code: aCode [ +StSindarinDebuggerCommandPresenter >> code: aCode [ code := aCode ] { #category : 'accessing' } -StSindarinDebuggerCreateCommandPresenter >> commandName: aName [ +StSindarinDebuggerCommandPresenter >> commandName: aName [ commandName := aName asCamelCase ] { #category : 'initialization' } -StSindarinDebuggerCreateCommandPresenter >> connectPresenters [ +StSindarinDebuggerCommandPresenter >> connectPresenters [ iconList transmitTo: self ] +{ #category : 'layout' } +StSindarinDebuggerCommandPresenter >> defaultLayout [ + + | buttonRow | + buttonRow := SpBoxLayout newLeftToRight + spacing: 6; + add: createButton; + add: cancelButton; + yourself. + + ^ SpBoxLayout newTopToBottom + spacing: 5; + add: descriptionInput expand: false; + add: iconList; + add: buttonRow expand: false; + yourself +] + +{ #category : 'actions' } +StSindarinDebuggerCommandPresenter >> deleteCommand [ + + | name className commandsLeft | + name := commandName ifNil: [ 'NoName' ]. + className := 'Sindarin{1}{2}Command' format: { + projectName asCamelCase. + name asCamelCase }. + + (Smalltalk globals includesKey: className asSymbol) ifTrue: [ + (Smalltalk globals at: className asSymbol) removeFromSystem ]. + + commandsLeft := SindarinCommand subclasses select: [ :sub | + sub packageName = package ]. + commandsLeft isEmpty ifTrue: [ self deleteMenu ] +] + +{ #category : 'actions' } +StSindarinDebuggerCommandPresenter >> deleteMenu [ + + | buildGroupMethodName | + buildGroupMethodName := 'buildSindarin{1}ExtentionCommandsGroupWith:forRoot:' + format: { projectName asCamelCase }. + + (StDebugger class includesSelector: buildGroupMethodName asSymbol) + ifTrue: [ + StDebugger class removeSelector: buildGroupMethodName asSymbol ] +] + { #category : 'actions' } -StSindarinDebuggerCreateCommandPresenter >> createCommand [ +StSindarinDebuggerCommandPresenter >> generateCommand [ | name className description class | name := commandName ifNil: [ 'NoName' ]. @@ -85,11 +132,11 @@ Description: {5}' format: { name. description }). - self createMenu + self generateMenu ] { #category : 'actions' } -StSindarinDebuggerCreateCommandPresenter >> createMenu [ +StSindarinDebuggerCommandPresenter >> generateMenu [ StDebugger class compile: @@ -114,55 +161,8 @@ StSindarinDebuggerCreateCommandPresenter >> createMenu [ classified: '*' , package ] -{ #category : 'layout' } -StSindarinDebuggerCreateCommandPresenter >> defaultLayout [ - - | buttonRow | - buttonRow := SpBoxLayout newLeftToRight - spacing: 6; - add: createButton; - add: cancelButton; - yourself. - - ^ SpBoxLayout newTopToBottom - spacing: 5; - add: descriptionInput expand: false; - add: iconList; - add: buttonRow expand: false; - yourself -] - -{ #category : 'actions' } -StSindarinDebuggerCreateCommandPresenter >> deleteCommand [ - - | name className commandsLeft | - name := commandName ifNil: [ 'NoName' ]. - className := 'Sindarin{1}{2}Command' format: { - projectName asCamelCase. - name asCamelCase }. - - (Smalltalk globals includesKey: className asSymbol) ifTrue: [ - (Smalltalk globals at: className asSymbol) removeFromSystem ]. - - commandsLeft := SindarinCommand subclasses select: [ :sub | - sub packageName = package ]. - commandsLeft isEmpty ifTrue: [ self deleteMenu ] -] - -{ #category : 'actions' } -StSindarinDebuggerCreateCommandPresenter >> deleteMenu [ - - | buildGroupMethodName | - buildGroupMethodName := 'buildSindarin{1}ExtentionCommandsGroupWith:forRoot:' - format: { projectName asCamelCase }. - - (StDebugger class includesSelector: buildGroupMethodName asSymbol) - ifTrue: [ - StDebugger class removeSelector: buildGroupMethodName asSymbol ] -] - { #category : 'initialization' } -StSindarinDebuggerCreateCommandPresenter >> initializeIconList [ +StSindarinDebuggerCommandPresenter >> initializeIconList [ | icons | icons := ThemeIcons loadDefault. @@ -172,7 +172,7 @@ StSindarinDebuggerCreateCommandPresenter >> initializeIconList [ ] { #category : 'initialization' } -StSindarinDebuggerCreateCommandPresenter >> initializePresenters [ +StSindarinDebuggerCommandPresenter >> initializePresenters [ descriptionInput := self newTextInput. descriptionInput placeholder: 'Command description'. @@ -188,31 +188,31 @@ StSindarinDebuggerCreateCommandPresenter >> initializePresenters [ ] { #category : 'accessing' } -StSindarinDebuggerCreateCommandPresenter >> package: aPackageName [ +StSindarinDebuggerCommandPresenter >> package: aPackageName [ package := aPackageName ] { #category : 'accessing' } -StSindarinDebuggerCreateCommandPresenter >> projectName: aName [ +StSindarinDebuggerCommandPresenter >> projectName: aName [ projectName := aName ] { #category : 'transmission' } -StSindarinDebuggerCreateCommandPresenter >> setModel: aIconName [ +StSindarinDebuggerCommandPresenter >> setModel: aIconName [ iconNameSelected := aIconName ] { #category : 'enumerating' } -StSindarinDebuggerCreateCommandPresenter >> whenCancelButtonDo: aBlock [ +StSindarinDebuggerCommandPresenter >> whenCancelDo: aBlock [ cancelButton action: aBlock ] { #category : 'enumerating' } -StSindarinDebuggerCreateCommandPresenter >> whenCreateButtonDo: aBlock [ +StSindarinDebuggerCommandPresenter >> whenCreateDo: aBlock [ createButton action: aBlock ] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st index 77b99f40..5958325f 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st @@ -84,13 +84,13 @@ StSindarinDebuggerScriptChooserPresenter >> setModel: aListElement [ ] { #category : 'actions' } -StSindarinDebuggerScriptChooserPresenter >> whenCancelButtonDo: aBlock [ +StSindarinDebuggerScriptChooserPresenter >> whenCancelDo: aBlock [ cancelButton action: aBlock ] { #category : 'actions' } -StSindarinDebuggerScriptChooserPresenter >> whenLoadButtonDo: aBlock [ +StSindarinDebuggerScriptChooserPresenter >> whenLoadDo: aBlock [ loadButton action: aBlock ] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st index 7e2db95e..868adec8 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st @@ -110,16 +110,16 @@ StSindarinDebuggerScriptingPresenter >> hasUnsavedCodeChanges [ { #category : 'initialization' } StSindarinDebuggerScriptingPresenter >> initializeCommandCreater [ - commandCreater := StSindarinDebuggerCreateCommandPresenter newApplication: self application. + commandCreater := StSindarinDebuggerCommandPresenter newApplication: self application. commandCreater package: (self defaultScriptRepository package name); projectName: (self defaultScriptRepository repositoryName); - whenCancelButtonDo: [ self layout: self defaultLayout ]; - whenCreateButtonDo: [ + whenCancelDo: [ self layout: self defaultLayout ]; + whenCreateDo: [ commandCreater commandName: scriptNameInput text; code: code text. - commandCreater createCommand. + commandCreater generateCommand. self layout: self defaultLayout ]. ] @@ -153,7 +153,7 @@ StSindarinDebuggerScriptingPresenter >> initializeScriptChooser [ scriptChooser := StSindarinDebuggerScriptChooserPresenter newApplication: self application. scriptChooser repository: self defaultScriptRepository. - scriptChooser whenLoadButtonDo: [ + scriptChooser whenLoadDo: [ scriptName := scriptChooser chooseElement. scriptName ifNotNil: [ scriptNameInput text: scriptName . @@ -167,7 +167,7 @@ StSindarinDebuggerScriptingPresenter >> initializeScriptChooser [ self layout: self defaultLayout. ]. - scriptChooser whenCancelButtonDo: [ + scriptChooser whenCancelDo: [ self layout: self defaultLayout. ] ]