Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to a new version #155

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions src/BaselineOfMolecule/BaselineOfMolecule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Class {
#name : #BaselineOfMolecule,
#superclass : #BaselineOf,
#instVars : [
'previousDynamicContractUpdateActivated'
'isPreviouslyAutoComponentTypeUpdateActivated'
],
#category : #BaselineOfMolecule
}
Expand Down Expand Up @@ -31,12 +31,17 @@ BaselineOfMolecule >> baseline: spec [
BaselineOfMolecule >> postload: loader package: packageSpec [
"Reload new Molecule tools"

(Smalltalk globals includesKey: #MolComponentManager) ifFalse:[ ^self ].
(Smalltalk globals classNamed: #MolComponentManager) cleanUp.
"Rebuild all components"
| componentManagerClass |
componentManagerClass := RGClassDefinition named: #MolComponentManager.
componentManagerClass isDefined ifFalse:[ ^ self ].
componentManagerClass realClass cleanUp.

"Define all components after loading"
MolComponentFactory defineAllComponents.
"Reactive dynamic contract update if necessary"
(previousDynamicContractUpdateActivated ifNil:[false]) ifFalse:[
MolSystemObserver active.

"Active auto ComponentType update if necessary"
(isPreviouslyAutoComponentTypeUpdateActivated ifNil:[ false ]) ifFalse:[
MolComponentFactory default activateDynamicContractUpdate.
].
]
Expand All @@ -45,9 +50,12 @@ BaselineOfMolecule >> postload: loader package: packageSpec [
BaselineOfMolecule >> preload: loader package: packageSpec [
"If a Molecule component system is running, confirm loading and cleanUp before installation of the new version"

(Smalltalk globals includesKey: #MolComponentManager) ifFalse:[ ^self ].
previousDynamicContractUpdateActivated := false.
(Smalltalk globals classNamed: #MolComponentManager) isRunningComponents ifTrue:[
| componentManagerClass |
componentManagerClass := RGClassDefinition named: #MolComponentManager.
componentManagerClass isDefined ifFalse:[ ^ self ].

isPreviouslyAutoComponentTypeUpdateActivated := false.
componentManagerClass realClass isRunningComponents ifTrue:[
(Smalltalk ui theme
proceedIn: Morph new
text: 'Warning, you are going to modify Molecule then components are started, do you want to continue ?'
Expand All @@ -57,7 +65,8 @@ BaselineOfMolecule >> preload: loader package: packageSpec [
].
].

(Smalltalk globals classNamed: #MolComponentManager) cleanUp.
previousDynamicContractUpdateActivated := MolComponentFactory default isDynamicContractUpdateActivated.
componentManagerClass realClass cleanUp.
isPreviouslyAutoComponentTypeUpdateActivated := MolComponentFactory default isDynamicContractUpdateActivated.
MolComponentFactory default deactivateDynamicContractUpdate.
MolSystemObserver deactive.
]
32 changes: 30 additions & 2 deletions src/Molecule-IDE/MolWorld.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ Class {
#category : #'Molecule-IDE-Menus'
}

{ #category : #accessing }
MolWorld class >> componentFactoryClass [

| class |
class := RGClassDefinition named: #MolComponentFactory.

class isDefined
ifTrue: [ ^ class realClass ]
ifFalse: [ ^ nil ]
]

{ #category : #scripts }
MolWorld class >> defineAComponent [

Expand Down Expand Up @@ -171,6 +182,17 @@ MolWorld class >> menu60ReportBugOn: aBuilder [
action: [WebBrowser openOn: 'https://github.com/OpenSmock/Molecule/issues/new']
]

{ #category : #accessing }
MolWorld class >> molUtilsClass [

| class |
class := RGClassDefinition named: #MolUtils.

class isDefined
ifTrue: [ ^ class realClass ]
ifFalse: [ ^ nil ]
]

{ #category : #scripts }
MolWorld class >> openDefineComponentDialog [

Expand Down Expand Up @@ -234,7 +256,10 @@ This action may be necessary if your system is broken.'
{ #category : #'menu - tools' }
MolWorld class >> toolsMenu20ToggleLogsOn: aBuilder [
<worldMenu>
MolUtils isLogActive

| utilsClass |
utilsClass := self molUtilsClass ifNil:[ ^ self ].
utilsClass isLogActive
ifFalse: [
(aBuilder item: #TurnOffMolLogs)
parent: #MoleculeDebug;
Expand All @@ -256,7 +281,10 @@ MolWorld class >> toolsMenu20ToggleLogsOn: aBuilder [
{ #category : #'menu - tools' }
MolWorld class >> toolsMenu30ToggleDynamicContractUpdate: aBuilder [
<worldMenu>
MolComponentFactory default isDynamicContractUpdateActivated

| factoryClass |
factoryClass := self componentFactoryClass ifNil:[ ^ self ].
factoryClass default isDynamicContractUpdateActivated
ifFalse: [
(aBuilder item: #TurnOffMolLogs)
parent: #MoleculeDebug;
Expand Down
18 changes: 10 additions & 8 deletions src/Molecule-Tests/MolComponentFactoryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -798,17 +798,19 @@ MolComponentFactoryTest >> testDefineComponentTypeImplementors [

{ #category : #tests }
MolComponentFactoryTest >> testDefineDirtyComponents [
self assert: MolComponentFactory default dirtyComponentTypes isEmpty.

self assert: MolComponentFactory dirtyComponentTypeList isEmpty.

"Add a dirty component type manually"
MolComponentFactory default dirtyComponentTypes add: MolMyClientComponent.
MolComponentFactory default dirtyComponents add: MolMyClientComponentImpl.
self assert: MolComponentFactory default dirtyComponentTypes notEmpty.
self assert: MolComponentFactory default dirtyComponents notEmpty.

MolComponentFactory dirtyComponentTypeList add: MolMyClientComponent.
MolComponentFactory dirtyComponentImplList add:
MolMyClientComponentImpl.
self assert: MolComponentFactory dirtyComponentTypeList notEmpty.
self assert: MolComponentFactory dirtyComponentImplList notEmpty.

MolComponentFactory defineDirtyComponents.
self assert: MolComponentFactory default dirtyComponentTypes isEmpty.
self assert: MolComponentFactory default dirtyComponents isEmpty.
self assert: MolComponentFactory dirtyComponentTypeList isEmpty.
self assert: MolComponentFactory dirtyComponentImplList isEmpty
]

{ #category : #tests }
Expand Down
40 changes: 40 additions & 0 deletions src/Molecule/MCPackageLoader.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Extension { #name : #MCPackageLoader }

{ #category : #'*Molecule' }
MCPackageLoader >> announceLoad: aString do: aBlock [
| returnValue |
returnValue := nil.
[ self announceLoadStart: aString ] ensure: [
[ returnValue := aBlock value ] ensure: [
self announceLoadStop: aString ] ].
^ returnValue
]

{ #category : #'*Molecule' }
MCPackageLoader >> announceLoadStart: aString [
SystemAnnouncer uniqueInstance announce: (MCPackageLoaderStarted new
packageLoader: self;
label: aString;
yourself)
]

{ #category : #'*Molecule' }
MCPackageLoader >> announceLoadStop: aString [
SystemAnnouncer uniqueInstance announce: (MCPackageLoaderStarted new
packageLoader: self;
label: aString;
yourself)
]

{ #category : #'*Molecule' }
MCPackageLoader >> basicLoadWithNameLike: baseName [

self validate.
self useNewChangeSetNamedLike: baseName during: [self basicLoad].
]

{ #category : #'*Molecule' }
MCPackageLoader >> loadWithNameLike: aString [

^ self announceLoad: aString do: [ self basicLoadWithNameLike: aString ]
]
33 changes: 33 additions & 0 deletions src/Molecule/MCPackageLoaderStarted.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Class {
#name : #MCPackageLoaderStarted,
#superclass : #Announcement,
#instVars : [
'packageLoader',
'label'
],
#category : #'Molecule-Announcers'
}

{ #category : #accessing }
MCPackageLoaderStarted >> label [

^ label
]

{ #category : #accessing }
MCPackageLoaderStarted >> label: anObject [

label := anObject
]

{ #category : #accessing }
MCPackageLoaderStarted >> packageLoader [

^ packageLoader
]

{ #category : #accessing }
MCPackageLoaderStarted >> packageLoader: anObject [

packageLoader := anObject
]
31 changes: 31 additions & 0 deletions src/Molecule/MCPackageLoaderStopped.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Class {
#name : #MCPackageLoaderStopped,
#superclass : #Announcement,
#instVars : [
'packageLoader',
'label'
],
#category : #'Molecule-Announcers'
}

{ #category : #accessing }
MCPackageLoaderStopped >> label [
^ label
]

{ #category : #accessing }
MCPackageLoaderStopped >> label: anObject [
label := anObject
]

{ #category : #accessing }
MCPackageLoaderStopped >> packageLoader [

^ packageLoader
]

{ #category : #accessing }
MCPackageLoaderStopped >> packageLoader: anObject [

packageLoader := anObject
]
Loading