diff --git a/src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st b/src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st index 6e7c4449..35336420 100644 --- a/src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st +++ b/src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st @@ -22,6 +22,9 @@ Class { 'imageNameCheck', 'isNameValid' ], + #classVars : [ + 'LastSelectedIndex' + ], #category : #'PharoLauncher-Spec2' } @@ -59,6 +62,16 @@ PhLImageCreationPresenter class >> example [ model: {PhLRemoteTemplate example}) open ] +{ #category : #accessing } +PhLImageCreationPresenter class >> lastSelectedIndex [ + ^ LastSelectedIndex +] + +{ #category : #accessing } +PhLImageCreationPresenter class >> lastSelectedIndex: aNumber [ + LastSelectedIndex := aNumber +] + { #category : #initialization } PhLImageCreationPresenter >> checkNewName: name [ "If the image name is taken we display a red cross. Else we display a validation sign. @@ -161,8 +174,12 @@ PhLImageCreationPresenter >> initializePresenters [ display: [ :file | file basename ]; whenSelectionChangedDo: [ :selection | selection selectedItem ifNotNil: [ :item | + self class lastSelectedIndex: selection selectedIndex. initScriptText text: item model contents ] ]; yourself. + + self initializeSelectedItem. + descriptionText := self newText. editInitScriptButton := self newButton addStyle: 'small'; @@ -176,6 +193,16 @@ PhLImageCreationPresenter >> initializePresenters [ createButton disable ] +{ #category : #initialization } +PhLImageCreationPresenter >> initializeSelectedItem [ + | index | + index := self class lastSelectedIndex. + index ifNil: [ ^ self ]. + (index between: 1 and: initScript items size) + ifTrue: [ ^ self class lastSelectedIndex: 1 ]. + initScript selectIndex: index +] + { #category : #testing } PhLImageCreationPresenter >> isNameValid [ ^ isNameValid