Skip to content

Commit

Permalink
Fix pharo image version when absent
Browse files Browse the repository at this point in the history
  • Loading branch information
demarey committed Jan 5, 2024
1 parent 2b1d650 commit 6dae2ca
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/PharoLauncher-Spec2/PhLImagesPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ PhLImagesPresenter >> connectPresenters [

imageTable transmitDo: [ :image |
self
ensurePharoVersion;
refreshLaunchConfigurationList;
updateToolbarCommandsAvailability ].

Expand Down Expand Up @@ -233,6 +234,19 @@ PhLImagesPresenter >> ensure: aBoolean [
ifFalse: [ PhLCommandError signal ]
]

{ #category : #computing }
PhLImagesPresenter >> ensurePharoVersion [
| image |
image := self selectedImages first.
[ image ensurePharoVersion ]
on: PhLImageVersionFileNotFound
do: [ | presenter |
presenter := PhLPharoVersionChooserPresenter new.
presenter openModal.
image versionFile
writeStreamDo: [ :stream | stream nextPutAll: presenter version ] ]
]

{ #category : #private }
PhLImagesPresenter >> filter: regexMatcher [

Expand Down
63 changes: 63 additions & 0 deletions src/PharoLauncher-Spec2/PhLPharoVersionChooserPresenter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"
I'm a simple presenter to fix the version of a Pharo image when no version file exists.
"
Class {
#name : #PhLPharoVersionChooserPresenter,
#superclass : #SpPresenterWithModel,
#traits : 'TPhLInteractionTrait',
#classTraits : 'TPhLInteractionTrait classTrait',
#instVars : [
'versionTable'
],
#category : #'PharoLauncher-Spec2'
}

{ #category : #examples }
PhLPharoVersionChooserPresenter class >> example [

^ self new
openDialog;
yourself
]

{ #category : #layout }
PhLPharoVersionChooserPresenter >> defaultLayout [
^ SpBoxLayout newHorizontal
add: versionTable;
yourself
]

{ #category : #initialization }
PhLPharoVersionChooserPresenter >> initializePresenters [
versionTable := self newTable
addColumn: ((SpStringTableColumn title: 'Pharo version' evaluated: #key) width: 100; yourself);
addColumn: ((SpStringTableColumn
title: 'version string'
evaluated: #value) width: 60; yourself);
showColumnHeaders;
items: self pharoVersions;
yourself
]

{ #category : #initialization }
PhLPharoVersionChooserPresenter >> initializeWindow: aWindowPresenter [

aWindowPresenter
title: 'Choose the Pharo version of the image:';
initialExtent: 300@300;
centered
]

{ #category : #accessing }
PhLPharoVersionChooserPresenter >> pharoVersions [
| maxPharoVersion versions |
maxPharoVersion := 12.
versions := (#(1.2 1.3 1.4) copyWithAll: (2 to: maxPharoVersion)) reversed.

^ versions collect: [ :v | 'Pharo ', v asString -> (v * 10) asInteger asString]
]

{ #category : #versions }
PhLPharoVersionChooserPresenter >> version [
^ versionTable selectedItem value
]

0 comments on commit 6dae2ca

Please sign in to comment.