Skip to content

Commit

Permalink
Merge pull request #200 from OpenSmock/dev-pla
Browse files Browse the repository at this point in the history
Fix #198 and #199
  • Loading branch information
labordep authored Oct 4, 2024
2 parents 08e965b + 2d1e294 commit 1057cb9
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/Molecule-IDE/MolImplementationsPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ MolImplementationsPresenter >> initializePresenters [
self iconNamed: elem systemIconName ]
]

{ #category : #initialization }
MolImplementationsPresenter >> listImplementations: aComponentType [
"necessary to use a Collection or one of its subclasses (Array in this case) to retrieve implementations of the selected Type Trait"

(aComponentType = '' or: aComponentType = OrderedCollection new)
ifFalse: [
^ (MolUtils allComponentImplementationClassesOfType: aComponentType) asArray ]
]

{ #category : #initialization }
MolImplementationsPresenter >> title [

Expand Down
5 changes: 5 additions & 0 deletions src/Molecule-Tests/MolCompleteComponentChild2Impl.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #MolCompleteComponentChild2Impl,
#superclass : #MolCompleteComponentImpl,
#category : #'Molecule-Tests-Resources - Components'
}
24 changes: 24 additions & 0 deletions src/Molecule-Tests/MolUtilsTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ MolUtilsTest >> testActivateComponents [
self assert: (homeServices isWaitingForActivation: MolCompleteComponentImpl) equals: false.
]

{ #category : #tests }
MolUtilsTest >> testAllComponentImplementationClassesOfType [

self assert: (MolUtils allComponentImplementationClassesOfType: MolCompleteComponent) size equals: 5.
]

{ #category : #tests }
MolUtilsTest >> testAllComponentInstancesOfType [

Expand All @@ -71,6 +77,24 @@ MolUtilsTest >> testAllComponentInstancesOfType [
self assert: (MolUtils allComponentInstancesOfType: MolCompleteComponent) size = 4.


]

{ #category : #tests }
MolUtilsTest >> testAllComponentInstancesOfType2 [

self assert: (MolUtils allComponentInstancesOfType: MolCompleteComponent) isEmpty.

MolUtils startComponent: MolCompleteComponentChild2Impl named: #compA.
MolUtils startComponent: MolCompleteComponentChild2Impl named: #compB.
MolUtils startComponent: MolCompleteComponentChild2Impl named: #compC.

self assert: (MolUtils allComponentInstancesOfType: MolCompleteComponent) size = 3.

MolUtils startComponent: MolCompleteComponentChild2Impl named: #compD.

self assert: (MolUtils allComponentInstancesOfType: MolCompleteComponent) size = 4.


]

{ #category : #tests }
Expand Down
30 changes: 25 additions & 5 deletions src/Molecule/MolUtils.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,41 @@ MolUtils class >> activateComponents: aComponentClassList [
].
]

{ #category : #accessing }
MolUtils class >> allComponentImplementationClassesOfType: aComponentType [
"Return a list of component Class which are implemented a component Type"

| list |
list := Set new.
aComponentType users do:[ :class |
"class should be another trait or a component impl class"
class isTrait
ifFalse:[
list add: class.
list addAll: (class allSubclasses) ]
ifTrue:[ list addAll: (self allComponentImplementationClassesOfType: class) ].
].

^ list asOrderedCollection
]

{ #category : #accessing }
MolUtils class >> allComponentInstancesOfType: aComponentType [

| oc homeServices |
| oc homeServices classes |
(aComponentType notNil and:[aComponentType isTrait and:[aComponentType isComponentType]]) ifFalse:[^OrderedCollection new].

oc := OrderedCollection new.
homeServices := MolComponentManager default homeServices.
aComponentType users do:[ :class |
(homeServices isDeployedComponent: class) ifTrue:[
oc addAll: (homeServices deployedComponents at: class) values.

classes := self allComponentImplementationClassesOfType: aComponentType.
classes do:[ :c |
(homeServices isDeployedComponent: c) ifTrue:[
oc addAll: (homeServices deployedComponents at: c) values.
]
].

^oc
^ oc
]

{ #category : #private }
Expand Down

0 comments on commit 1057cb9

Please sign in to comment.