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

Fix #198 and #199 #200

Merged
merged 1 commit into from
Oct 4, 2024
Merged
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
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
Loading