Skip to content

Commit

Permalink
Remove the need to dowload the ressources a second time
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyan11 committed Oct 26, 2023
1 parent b30e89e commit 5a788fe
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ BaselineOfMoleculeGeographicalPositionExample >> loadPyramid: spec [
{ #category : #'load scripts' }
BaselineOfMoleculeGeographicalPositionExample >> postload: loader package: packageSpec [

| molGeoDownloadedRessource molGeoPosHelper |
"Download ressources."
molGeoDownloadedRessource := #MolGeoDownloadedRessource
asClassInEnvironment:
self class environment.
molGeoDownloadedRessource ensureAllDownloaded.

| molGeoPosHelper |
"Open helper."
molGeoPosHelper := #MolGeoPosHelper asClassInEnvironment:
self class environment.
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ MolGeoPosApplication >> makeGPSButton [

^ MolGeoSwitchElement new
label: 'GPS';
icon: (MolGeoGPSDownloaded asForm: self iconSize);
icon: (MolGeoRessource gps asForm: self iconSize);
whenActivatedDo: [
self stopGeoPosEquipement.
MolGNSSGPS start ];
Expand All @@ -83,8 +83,10 @@ MolGeoPosApplication >> makeGPSInaccurateButton [

^ MolGeoSwitchElement new
label: 'GPSInaccurate';
icon: (MolGeoGPSInaccurateDownloaded asForm: self iconSize);
whenActivatedDo: [ self stopGeoPosEquipement.MolGNSSGPSInaccurate start ];
icon: (MolGeoRessource gpsInacurrate asForm: self iconSize);
whenActivatedDo: [
self stopGeoPosEquipement.
MolGNSSGPSInaccurate start ];
yourself
]

Expand All @@ -93,7 +95,7 @@ MolGeoPosApplication >> makeGSMButton [

^ MolGeoSwitchElement new
label: 'GSM';
icon: (MolGeoGSMDownloaded asForm: self iconSize);
icon: (MolGeoRessource gsm asForm: self iconSize);
whenActivatedDo: [
self stopGeoPosEquipement.
MolGSM start ];
Expand All @@ -105,8 +107,10 @@ MolGeoPosApplication >> makeGalileoButton [

^ MolGeoSwitchElement new
label: 'Galileo';
icon: (MolGeoGalileoDownloaded asForm: self iconSize);
whenActivatedDo: [ self stopGeoPosEquipement. MolGNSSGalileo start ];
icon: (MolGeoRessource galileo asForm: self iconSize);
whenActivatedDo: [
self stopGeoPosEquipement.
MolGNSSGalileo start ];
yourself
]

Expand All @@ -115,15 +119,17 @@ MolGeoPosApplication >> makeWiFiButton [

^ MolGeoSwitchElement new
label: 'WiFi';
icon: (MolGeoWiFiDownloaded asForm: self iconSize);
whenActivatedDo: [ self stopGeoPosEquipement. MolWiFi start ];
icon: (MolGeoRessource wiFi asForm: self iconSize);
whenActivatedDo: [
self stopGeoPosEquipement.
MolWiFi start ];
yourself
]

{ #category : #'as yet unclassified' }
MolGeoPosApplication >> mapForm [

^ (MolGeoMapDownloaded asForm: self maximumMapSize)
^ MolGeoRessource map asForm: self maximumMapSize
]

{ #category : #'as yet unclassified' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ MolGeoPosHelper >> openTheExample [
^ Lesson
title: 'Molecule Geographical Position - help'
lesson:
'"To launch the applicaiton you can copy/paste the following line in a playground and clic on <Do it>."
'"To launch the application you can copy/paste the following line in a playground and clic on <Do it>."
MolGeoPosApplication open.
"You can also select the previous line with your mouse and press (ctrl + D or cmd + D) to reopen it at any moment."
Expand Down
125 changes: 125 additions & 0 deletions src/Molecule-Geographical-Position-Example/MolGeoRessource.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
Class {
#name : #MolGeoRessource,
#superclass : #Object,
#instVars : [
'fileName'
],
#category : #'Molecule-Geographical-Position-Example-ressources'
}

{ #category : #'as yet unclassified' }
MolGeoRessource class >> galileo [

^ self new
fileName: 'favorite.png';
yourself
]

{ #category : #'as yet unclassified' }
MolGeoRessource class >> gps [

^ self new
fileName: 'link.png';
yourself
]

{ #category : #'as yet unclassified' }
MolGeoRessource class >> gpsInacurrate [

^ self new
fileName: 'chains.png';
yourself
]

{ #category : #'as yet unclassified' }
MolGeoRessource class >> gsm [

^ self new
fileName: 'antenna.png';
yourself
]

{ #category : #'as yet unclassified' }
MolGeoRessource class >> map [

^ self new
fileName: 'map.png';
yourself
]

{ #category : #'as yet unclassified' }
MolGeoRessource class >> wiFi [

^ self new
fileName: 'wifi.png';
yourself
]

{ #category : #converting }
MolGeoRessource >> asForm [

^ (Form fromFileNamed: self fileReference)
mapColor: Color white
to: Color transparent
]

{ #category : #converting }
MolGeoRessource >> asForm: anExtent [

^ self asForm scaledToSize: anExtent
]

{ #category : #default }
MolGeoRessource >> baseIcebergDirectory [

| expectedName myRepository |
expectedName := 'molecule-geographical-position-example'.

myRepository := IceRepository registry
detect: [ :each |
each name asLowercase = expectedName ]
ifNone: [
self error:
('Did not find any repository named ''{1}'' in Iceberg (case insensitive). Alexandrie tests require it to access resources.'
format: { expectedName }) ].

^ myRepository location
]

{ #category : #default }
MolGeoRessource >> baseRessourceDirectory [

^ self baseIcebergDirectory / 'ressources'
]

{ #category : #accessing }
MolGeoRessource >> fileName [

^ fileName
]

{ #category : #accessing }
MolGeoRessource >> fileName: aString [

fileName := aString
]

{ #category : #accessing }
MolGeoRessource >> fileReference [

^ self baseRessourceDirectory / self fileName
]

{ #category : #initialization }
MolGeoRessource >> initialize [

super initialize.

fileName := 'doesnotexist.png'
]

{ #category : #testing }
MolGeoRessource >> isDownloaded [

^ self fileReference exists
]

This file was deleted.

0 comments on commit 5a788fe

Please sign in to comment.