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-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-Scripts/SindarinDefaultScriptRepository.class.st b/src/NewTools-Sindarin-Scripts/SindarinDefaultScriptRepository.class.st new file mode 100644 index 00000000..cbb52bd2 --- /dev/null +++ b/src/NewTools-Sindarin-Scripts/SindarinDefaultScriptRepository.class.st @@ -0,0 +1,12 @@ +Class { + #name : 'SindarinDefaultScriptRepository', + #superclass : 'StSindarinDebuggerScriptRepository', + #category : 'NewTools-Sindarin-Scripts', + #package : 'NewTools-Sindarin-Scripts' +} + +{ #category : 'accessing' } +SindarinDefaultScriptRepository class >> repositoryName [ + "Return the name of the 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/StSindarinDebuggerCommandPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCommandPresenter.class.st new file mode 100644 index 00000000..4af8db97 --- /dev/null +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerCommandPresenter.class.st @@ -0,0 +1,218 @@ +Class { + #name : 'StSindarinDebuggerCommandPresenter', + #superclass : 'SpPresenterWithModel', + #instVars : [ + 'descriptionInput', + 'cancelButton', + 'createButton', + 'package', + 'iconList', + 'iconNameSelected', + 'commandName', + 'code', + 'projectName' + ], + #category : 'NewTools-Sindarin-Tools-Presenters', + #package : 'NewTools-Sindarin-Tools', + #tag : 'Presenters' +} + +{ #category : 'accessing' } +StSindarinDebuggerCommandPresenter >> code: aCode [ + + code := aCode +] + +{ #category : 'accessing' } +StSindarinDebuggerCommandPresenter >> commandName: aName [ + + commandName := aName asCamelCase +] + +{ #category : 'initialization' } +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' } +StSindarinDebuggerCommandPresenter >> generateCommand [ + + | 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'. + + 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 generateMenu +] + +{ #category : 'actions' } +StSindarinDebuggerCommandPresenter >> generateMenu [ + + StDebugger class + compile: + ('buildSindarin{2}ExtentionCommandsGroupWith: 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: [ :command | toolbarCommandGroup register: command ].' + format: { + projectName. + projectName asCamelCase. + package }) + classified: '*' , package +] + +{ #category : 'initialization' } +StSindarinDebuggerCommandPresenter >> initializeIconList [ + + | icons | + icons := ThemeIcons loadDefault. + iconList + items: icons allIconNames; + display: [ :elm | ThemeIcons iconNamed: elm ] +] + +{ #category : 'initialization' } +StSindarinDebuggerCommandPresenter >> 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' } +StSindarinDebuggerCommandPresenter >> package: aPackageName [ + + package := aPackageName +] + +{ #category : 'accessing' } +StSindarinDebuggerCommandPresenter >> projectName: aName [ + + projectName := aName +] + +{ #category : 'transmission' } +StSindarinDebuggerCommandPresenter >> setModel: aIconName [ + + iconNameSelected := aIconName +] + +{ #category : 'enumerating' } +StSindarinDebuggerCommandPresenter >> whenCancelDo: aBlock [ + + cancelButton action: aBlock +] + +{ #category : 'enumerating' } +StSindarinDebuggerCommandPresenter >> whenCreateDo: 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 new file mode 100644 index 00000000..5958325f --- /dev/null +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptChooserPresenter.class.st @@ -0,0 +1,96 @@ +Class { + #name : 'StSindarinDebuggerScriptChooserPresenter', + #superclass : 'SpPresenterWithModel', + #instVars : [ + 'scriptList', + 'filter', + 'chooseElement', + 'loadButton', + 'cancelButton', + 'repository' + ], + #category : 'NewTools-Sindarin-Tools-Presenters', + #package : 'NewTools-Sindarin-Tools', + #tag : 'Presenters' +} + +{ #category : 'actions' } +StSindarinDebuggerScriptChooserPresenter >> applyFilter [ + + | filtered | + filtered := repository scriptsNames select: [ :each | + each asLowercase includesSubstring: + filter text asLowercase ]. + scriptList items: filtered +] + +{ #category : 'accessing' } +StSindarinDebuggerScriptChooserPresenter >> chooseElement [ + + ^ chooseElement +] + +{ #category : 'initialization' } +StSindarinDebuggerScriptChooserPresenter >> connectPresenters [ + + scriptList transmitTo: self +] + +{ #category : 'layout' } +StSindarinDebuggerScriptChooserPresenter >> defaultLayout [ + + | buttonRow | + buttonRow := SpBoxLayout newLeftToRight + spacing: 6; + add: #loadButton; + add: #cancelButton; + yourself. + + ^ SpBoxLayout newTopToBottom + spacing: 5; + add: #scriptList; + add: #filter expand: false; + add: buttonRow expand: false; + yourself +] + +{ #category : 'initialization' } +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' +] + +{ #category : 'accessing' } +StSindarinDebuggerScriptChooserPresenter >> repository: aScriptRepository [ + + repository := aScriptRepository. + self applyFilter +] + +{ #category : 'transmission' } +StSindarinDebuggerScriptChooserPresenter >> setModel: aListElement [ + + chooseElement := aListElement +] + +{ #category : 'actions' } +StSindarinDebuggerScriptChooserPresenter >> whenCancelDo: aBlock [ + + cancelButton action: aBlock +] + +{ #category : 'actions' } +StSindarinDebuggerScriptChooserPresenter >> whenLoadDo: aBlock [ + + loadButton action: aBlock +] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepository.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepository.class.st index 13ee0422..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', @@ -21,6 +32,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/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st new file mode 100644 index 00000000..9d296862 --- /dev/null +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryChooserPresenter.class.st @@ -0,0 +1,31 @@ +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 +] + +{ #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/StSindarinDebuggerScriptRepositoryPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st deleted file mode 100644 index b82886b4..00000000 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptRepositoryPresenter.class.st +++ /dev/null @@ -1,92 +0,0 @@ -Class { - #name : 'StSindarinDebuggerScriptRepositoryPresenter', - #superclass : 'SpPresenterWithModel', - #instVars : [ - 'scriptList', - 'filter', - 'chooseElement', - 'loadButton', - 'cancelButton' - ], - #category : 'NewTools-Sindarin-Tools-Presenters', - #package : 'NewTools-Sindarin-Tools', - #tag : 'Presenters' -} - -{ #category : 'actions' } -StSindarinDebuggerScriptRepositoryPresenter >> applyFilter [ - |filtered| - filtered := StSindarinDebuggerScriptRepository scriptsNames select: [ :each | - each asLowercase includesSubstring: filter text asLowercase ]. - scriptList items: filtered -] - -{ #category : 'accessing' } -StSindarinDebuggerScriptRepositoryPresenter >> chooseElement [ - ^ chooseElement -] - -{ #category : 'initialization' } -StSindarinDebuggerScriptRepositoryPresenter >> connectPresenters [ - - scriptList transmitTo: self -] - -{ #category : 'layout' } -StSindarinDebuggerScriptRepositoryPresenter >> defaultLayout [ - |buttonRow| - - buttonRow := SpBoxLayout newLeftToRight - spacing: 6; - add: #loadButton; - add: #cancelButton; - yourself. - - ^ SpBoxLayout newTopToBottom - spacing: 5; - 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. - - filter := self newTextInput. - filter placeholder: 'Filter ...'. - filter whenTextChangedDo: [ self applyFilter ]. - - loadButton := self newButton. - loadButton label: 'Load'. - - cancelButton := self newButton. - cancelButton label: 'Cancel'. - - self applyFilter. - -] - -{ #category : 'transmission' } -StSindarinDebuggerScriptRepositoryPresenter >> setModel: aListElement [ - - chooseElement := aListElement -] - -{ #category : 'actions' } -StSindarinDebuggerScriptRepositoryPresenter >> whenCancelButtonDo: aBlock [ - cancelButton action: aBlock . -] - -{ #category : 'actions' } -StSindarinDebuggerScriptRepositoryPresenter >> whenLoadButtonDo: aBlock [ - loadButton action: aBlock . -] diff --git a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st index 5a2e4884..868adec8 100644 --- a/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st +++ b/src/NewTools-Sindarin-Tools/StSindarinDebuggerScriptingPresenter.class.st @@ -20,7 +20,9 @@ Class { 'resultLabel', 'hasUnsavedCodeChanges', 'scriptNameInput', - 'scriptRepository' + 'scriptRepositoryChooser', + 'scriptChooser', + 'commandCreater' ], #category : 'NewTools-Sindarin-Tools-Presenters', #package : 'NewTools-Sindarin-Tools', @@ -35,7 +37,15 @@ StSindarinDebuggerScriptingPresenter >> accept: aVisitor [ { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> createCommandFromScript [ - self flag: 'todo' + self layout: self createCommandLayout. +] + +{ #category : 'layout' } +StSindarinDebuggerScriptingPresenter >> createCommandLayout [ + ^ SpBoxLayout newTopToBottom + add: self toolbarLayout expand: false; + add: commandCreater ; + yourself ] { #category : 'accessing' } @@ -51,8 +61,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 +77,11 @@ StSindarinDebuggerScriptingPresenter >> defaultLayout [ yourself ] +{ #category : 'accessing' } +StSindarinDebuggerScriptingPresenter >> defaultScriptRepository [ + ^ SindarinDefaultScriptRepository +] + { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> executeScript [ @@ -92,10 +108,31 @@ StSindarinDebuggerScriptingPresenter >> hasUnsavedCodeChanges [ ^ hasUnsavedCodeChanges ifNil: [ hasUnsavedCodeChanges := false ] ] +{ #category : 'initialization' } +StSindarinDebuggerScriptingPresenter >> initializeCommandCreater [ + commandCreater := StSindarinDebuggerCommandPresenter newApplication: self application. + commandCreater + package: (self defaultScriptRepository package name); + projectName: (self defaultScriptRepository repositoryName); + whenCancelDo: [ self layout: self defaultLayout ]; + whenCreateDo: [ + commandCreater + commandName: scriptNameInput text; + code: code text. + commandCreater generateCommand. + self layout: self defaultLayout + ]. +] + { #category : 'initialization' } StSindarinDebuggerScriptingPresenter >> initializePresenters [ scriptNameInput := self newTextInput. resultLabel := self newLabel. + + self initializeScriptChooser. + self initializeScriptRepositoryChooser. + self initializeCommandCreater. + code := self newCode. self loadLastScript. code syntaxHighlight: true. @@ -107,15 +144,55 @@ StSindarinDebuggerScriptingPresenter >> initializePresenters [ resultInspection owner: self. self initializeToolbar. self updateLabel. +] + +{ #category : 'initialization' } +StSindarinDebuggerScriptingPresenter >> initializeScriptChooser [ + |scriptName| + + scriptChooser := StSindarinDebuggerScriptChooserPresenter newApplication: self application. + scriptChooser repository: self defaultScriptRepository. + + scriptChooser whenLoadDo: [ + scriptName := scriptChooser chooseElement. + scriptName ifNotNil: [ + scriptNameInput text: scriptName . + code text: (scriptRepositoryChooser loadScript: scriptName) . + hasUnsavedCodeChanges := false. - scriptRepository := StSindarinDebuggerScriptRepositoryPresenter newApplication: self application. + self updateLabel . + self updatePresenter . + ]. + self layout: self defaultLayout. + ]. + scriptChooser whenCancelDo: [ + self layout: self defaultLayout. + ] ] { #category : 'initialization' } -StSindarinDebuggerScriptingPresenter >> initializeToolbar [ +StSindarinDebuggerScriptingPresenter >> initializeScriptRepositoryChooser [ + + scriptRepositoryChooser := StSindarinDebuggerScriptRepositoryChooserPresenter newApplication: self application. + scriptRepositoryChooser + findRepositories; + whenSelectedItemChangedDo: [ :item | + commandCreater + package: (item package name); + projectName: (item repositoryName). + scriptChooser repository: item . + self loadLastScript. + self updateLabel. + ]. + + +] +{ #category : 'initialization' } +StSindarinDebuggerScriptingPresenter >> initializeToolbar [ + toolbar := self newToolbar addStyle: 'stToolbar'; beIcons; @@ -125,59 +202,54 @@ StSindarinDebuggerScriptingPresenter >> initializeToolbar [ { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> loadLastScript [ |script| - script := (StSindarinDebuggerScriptRepository loadScript: 'Last updated') ifNil: ['sindarin stepOver']. + + script := (scriptRepositoryChooser loadScript: 'Last updated') ifNil: ['sindarin stepOver']. 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: (StSindarinDebuggerScriptRepository loadScript: scriptName) . - hasUnsavedCodeChanges := false. - - self updateLabel . - self updatePresenter . - ]. + scriptChooser applyFilter. - self layout: self defaultLayout. - ]. - - scriptRepository whenCancelButtonDo: [ - self layout: self defaultLayout. - ] + "check self initializeScriptRepository for loading script logic" ] { #category : 'layout' } StSindarinDebuggerScriptingPresenter >> loadScriptLayout [ ^ SpBoxLayout newTopToBottom - add: #scriptRepository; + add: self toolbarLayout expand: false; + add: #scriptChooser + expand: true + fill: true + padding:2; yourself ] { #category : 'actions' } -StSindarinDebuggerScriptingPresenter >> removeScriptCommand [ - self flag: 'todo' +StSindarinDebuggerScriptingPresenter >> removeScriptCommand [ + commandCreater + commandName: scriptNameInput text; + deleteCommand. ] { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> saveLastScript [ - StSindarinDebuggerScriptRepository saveScript: 'Last updated' code: code text. + scriptRepositoryChooser saveScript: 'Last updated' code: code text. + + hasUnsavedCodeChanges := false. + self updateLabel ] { #category : 'actions' } StSindarinDebuggerScriptingPresenter >> saveScript [ - StSindarinDebuggerScriptRepository saveScript: (scriptNameInput text) code: (code text). + scriptRepositoryChooser saveScript: (scriptNameInput text) code: (code text). hasUnsavedCodeChanges := false. self updateLabel @@ -210,6 +282,14 @@ StSindarinDebuggerScriptingPresenter >> toolbarActions [ ^ group ] +{ #category : 'layout' } +StSindarinDebuggerScriptingPresenter >> toolbarLayout [ + ^ SpBoxLayout newLeftToRight + add: #toolbar expand: false; + add: #scriptRepositoryChooser; + yourself. +] + { #category : 'initialization' } StSindarinDebuggerScriptingPresenter >> updateCode [