Skip to content

Commit

Permalink
added last selection index
Browse files Browse the repository at this point in the history
  • Loading branch information
akevalion committed Oct 5, 2023
1 parent dc0724d commit 8f1df77
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/PharoLauncher-Spec2/PhLImageCreationPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Class {
'imageNameCheck',
'isNameValid'
],
#classVars : [
'LAST_SELECTED_INDEX'
],
#category : #'PharoLauncher-Spec2'
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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';
Expand All @@ -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
Expand Down

0 comments on commit 8f1df77

Please sign in to comment.