From 8f1df77618fdeb65085bf527aaf57274b70c6f3a Mon Sep 17 00:00:00 2001 From: Milton Mamani Torres Date: Thu, 5 Oct 2023 17:42:47 +0200 Subject: [PATCH 1/2] added last selection index --- .../PhLImageCreationPresenter.class.st | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st b/src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st index 6e7c4449..f150fee9 100644 --- a/src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st +++ b/src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st @@ -22,6 +22,9 @@ Class { 'imageNameCheck', 'isNameValid' ], + #classVars : [ + 'LAST_SELECTED_INDEX' + ], #category : #'PharoLauncher-Spec2' } @@ -59,6 +62,16 @@ PhLImageCreationPresenter class >> example [ model: {PhLRemoteTemplate example}) open ] +{ #category : #accessing } +PhLImageCreationPresenter class >> lastSelectedIndex [ + ^ LAST_SELECTED_INDEX +] + +{ #category : #accessing } +PhLImageCreationPresenter class >> lastSelectedIndex: aNumber [ + LAST_SELECTED_INDEX := 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 From 803604a18cb0db8512f8a3e015a777b6a2f9a6e3 Mon Sep 17 00:00:00 2001 From: Milton Mamani Torres Date: Fri, 6 Oct 2023 11:33:23 +0200 Subject: [PATCH 2/2] Update PhLImageCreationPresenter.class.st --- src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st b/src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st index f150fee9..35336420 100644 --- a/src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st +++ b/src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st @@ -23,7 +23,7 @@ Class { 'isNameValid' ], #classVars : [ - 'LAST_SELECTED_INDEX' + 'LastSelectedIndex' ], #category : #'PharoLauncher-Spec2' } @@ -64,12 +64,12 @@ PhLImageCreationPresenter class >> example [ { #category : #accessing } PhLImageCreationPresenter class >> lastSelectedIndex [ - ^ LAST_SELECTED_INDEX + ^ LastSelectedIndex ] { #category : #accessing } PhLImageCreationPresenter class >> lastSelectedIndex: aNumber [ - LAST_SELECTED_INDEX := aNumber + LastSelectedIndex := aNumber ] { #category : #initialization }