Skip to content

Commit

Permalink
Merge pull request #1204 from moosetechnology/dsm-interactions
Browse files Browse the repository at this point in the history
DSM interactions
  • Loading branch information
NicolasAnquetil authored Oct 19, 2024
2 parents 19e9f2b + 966042f commit 5b6b858
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ MiDependencyStructuralMatrixBrowserModel >> entities [
^ graph nodes collect: #model
]

{ #category : #testing }
MiDependencyStructuralMatrixBrowserModel >> entity: aCandidate belongsTo: anEntity [
"test whether aDependentEntity can be scoped up to anEntity"

^(aCandidate atScope: anEntity class) includes: anEntity
]

{ #category : #actions }
MiDependencyStructuralMatrixBrowserModel >> followEntity: aCollection [

Expand All @@ -110,28 +117,31 @@ MiDependencyStructuralMatrixBrowserModel >> followEntity: aCollection [

{ #category : #api }
MiDependencyStructuralMatrixBrowserModel >> getTupleDependencyWeight: tuple [

^(tuple key = tuple value)
ifTrue: [ ^0 ]
ifFalse: [
tuple key model queryAllOutgoingForDSM count: [ :dependency || opposites |
dependency isAssociation ifTrue: [
"Association so need to get the target because DSM is done between entities"
opposites := dependency target.
opposites isCollection
ifTrue: [ opposites anySatisfy: [ :each | (each atScope: tuple value model class) includes: tuple value model] ]
"The ifNotNil is to avoid the null dependency problem coming from the model due to generic types"
ifFalse: [ opposites
ifNotNil: [ (opposites atScope: tuple value model class) includes: tuple value model ]
ifNil: [false]]
]
ifFalse: [
"Case of declaredType"
dependency isStub ifTrue: [ false ] ifFalse: [ (dependency atScope: tuple value model class) includes: tuple value model ]
]
"generic algorithm is to take all dependencies of the `tuple key` (row of the DSM) and count
those that can be scoped up to the `tuple value` (column of the DSM)"

^tuple key model queryAllOutgoingForDSM count: [ :dependency || opposites |
dependency isAssociation ifTrue: [
"Association so need to get the target because DSM is done between entities"
opposites := dependency target.
opposites isCollection
ifTrue: [ opposites anySatisfy: [ :each |
self entity: each belongsTo: tuple value model ]
]

]
ifFalse: [
self flag: 'can be nil because of a bug in the model with generic types'.
opposites
ifNotNil: [ self entity: opposites belongsTo: tuple value model ]
ifNil: [false]
]
]
ifFalse: [
"case of declaredType"
dependency isStub
ifTrue: [ false ]
ifFalse: [ self entity: dependency belongsTo: tuple value model ]
]
]
]

{ #category : #initialization }
Expand Down
17 changes: 16 additions & 1 deletion src/MooseIDE-Dependency/MiRSDSMShape.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ This is a modified version of the `RSComposite` to accomodate our new DSM
Class {
#name : #MiRSDSMShape,
#superclass : #RSComposite,
#instVars : [
'weight'
],
#category : #'MooseIDE-Dependency-DSM'
}

Expand All @@ -24,5 +27,17 @@ MiRSDSMShape >> initialize [

{ #category : #accessing }
MiRSDSMShape >> text: aString [
self children second text: aString
self children second text: aString
]

{ #category : #accessing }
MiRSDSMShape >> weight [

^ weight
]

{ #category : #accessing }
MiRSDSMShape >> weight: anObject [

weight := anObject
]
24 changes: 23 additions & 1 deletion src/MooseIDE-Dependency/MiRSDependencyStructuralMatrix.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ Class {
#category : #'MooseIDE-Dependency-DSM'
}

{ #category : #'hooks - labels' }
MiRSDependencyStructuralMatrix >> createLabelShapeX: aRSBox [

^(super createLabelShapeX: aRSBox)
popupText: [ :graphNode | graphNode model mooseName ] ;
yourself
]

{ #category : #'hooks - labels' }
MiRSDependencyStructuralMatrix >> createLabelShapeY: aRSBox [

^(super createLabelShapeY: aRSBox)
popupText: [ :graphNode | graphNode model mooseName ] ;
yourself
]

{ #category : #hooks }
MiRSDependencyStructuralMatrix >> createShape: tuple [
"1halt."
Expand All @@ -15,6 +31,7 @@ MiRSDependencyStructuralMatrix >> createShape: tuple [

^ MiRSDSMShape new
text: (weight = 0 ifTrue: [''] ifFalse: [ weight asString]);
weight: weight ;
model: tuple;
color: (self color cull: tuple);
yourself
Expand All @@ -27,8 +44,12 @@ MiRSDependencyStructuralMatrix >> getTupleDependencyWeight: tuple [

{ #category : #highlighting }
MiRSDependencyStructuralMatrix >> highlight: evt [
"Probable bug in RSDSM: `super highlight: evt` draws the row and column with bold border
But the borders are shape that should not receive announcement (like mouseEnter/Leave for highlight/unhighlight"
super highlight: evt.
shape := nil.
(self canvas canvas propertyAt: #columnRect) announcer: nil.
(self canvas canvas propertyAt: #rowRect) announcer: nil.

(owner sccShapesIncluding: evt shape) do: [ :aShape |
aShape color: (owner cellShowSCCColor: aShape model)
]
Expand All @@ -42,6 +63,7 @@ MiRSDependencyStructuralMatrix >> owner: anObject [

{ #category : #highlighting }
MiRSDependencyStructuralMatrix >> unhighlight: evt [

super unhighlight: evt.

(owner sccShapesIncluding: evt shape) do: [ :aShape |
Expand Down
5 changes: 5 additions & 0 deletions src/MooseIDE-Dependency/MooseEntity.extension.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Extension { #name : #MooseEntity }

{ #category : #'*MooseIDE-Dependency' }
MooseEntity >> addDeclaredTypesIn: dependencies [
"default is to do nothing (no declaredType to add)"
]

{ #category : #'*MooseIDE-Dependency' }
MooseEntity >> rootsForTreeMap [

Expand Down

0 comments on commit 5b6b858

Please sign in to comment.