From 6dfca543fcdf5d6ca42b2b3ec6e189d1548e8fc6 Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Tue, 3 Dec 2024 18:05:23 +0100 Subject: [PATCH 1/7] Add a new inspector for the component. Need Roassal --- .../MolComponentToRoassal.class.st | 242 ++++++++++++++++++ src/Molecule/MolComponentImpl.trait.st | 6 + src/Molecule/MolHomeServices.class.st | 13 + 3 files changed, 261 insertions(+) create mode 100644 src/Molecule-IDE/MolComponentToRoassal.class.st diff --git a/src/Molecule-IDE/MolComponentToRoassal.class.st b/src/Molecule-IDE/MolComponentToRoassal.class.st new file mode 100644 index 0000000..b1617ea --- /dev/null +++ b/src/Molecule-IDE/MolComponentToRoassal.class.st @@ -0,0 +1,242 @@ +" +I am a utility class to transform a Molecule component into a Roassal graph. + +Use #graphFromSingleComponent: aMolComponent to have a RSShape of the Molecule component. +Use #canvasFromMultipleComponents: aCollection to have a RSCanvas of multiple Molecule components. + +" +Class { + #name : #MolComponentToRoassal, + #superclass : #Object, + #category : #'Molecule-IDE-Inspectors' +} + +{ #category : #'as yet unclassified' } +MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfComponents [ + + | canvas dictionaryEvents lineBuilder | + canvas := RSCanvas new. + canvas addAll: + (aCollectionOfComponents collect: [ :comp | comp asRSMoleculeShape ]). + + dictionaryEvents := Dictionary new. + aCollectionOfComponents collect: [ :comp | + comp servicesProviders keys , comp parametersProviders keys + , comp eventsSubscribers keys do: [ :event | + dictionaryEvents + at: event + ifPresent: [ :l | l add: comp ] + ifAbsentPut: [ OrderedCollection with: comp ] ] ]. + + lineBuilder := RSLineBuilder arrowedLine + canvas: canvas; + withBorderAttachPoint. + + aCollectionOfComponents do: [ :compSource | + compSource eventsNotifiers keys do: [ :event | + dictionaryEvents + at: event + ifPresent: [ :allComponentsForEvent | + lineBuilder useAssociations: + (allComponentsForEvent collect: [ :compTarget | + compSource -> compTarget ]) ] + ifAbsent: [ + self flag: #TODO "No components has been found for this contract ..." ] ] ]. + + RSForceBasedLayout new + doNotUseProgressBar; + length: 400; + charge: -2000; + on: canvas nodes. + + canvas @ RSCanvasController. + canvas zoomToFit. + ^ canvas +] + +{ #category : #'instance creation' } +MolComponentToRoassal class >> connectorsFromEventCollection: aCollection andColor: aColor andCornerRadius: aCornerRadius [ + + ^ aCollection collect: [ :each | + | eventBox eventName | + eventName := RSLabel new + text: each printString; + color: Color black; + yourself. + eventBox := RSBox new + withBorder; + color: aColor; + extent: eventName extent + 10; + cornerRadius: aCornerRadius; + yourself. + RSComposite new + shapes: { + eventBox. + eventName }; + adjustToChildren; + model: each; + yourself ] +] + +{ #category : #'instance creation' } +MolComponentToRoassal class >> connectorsInOn: aMolComponent [ + + | connectors services events parameters | + services := self + connectorsFromEventCollection: + aMolComponent servicesProviders keys + andColor: Color green muchLighter + andCornerRadius: (RSCornerRadius new right: 10). + events := self + connectorsFromEventCollection: + aMolComponent eventsSubscribers keys + andColor: Color blue muchLighter + andCornerRadius: (RSCornerRadius new right: 10). + parameters := self + connectorsFromEventCollection: + aMolComponent parametersProviders keys + andColor: Color red muchLighter + andCornerRadius: (RSCornerRadius new right: 10). + connectors := RSComposite new + shapes: services , events , parameters; + yourself. + connectors model: (connectors shapes collect: #model). + + RSVerticalLineLayout new + alignLeft; + on: connectors shapes. + + connectors adjustToChildren. + ^ connectors +] + +{ #category : #'instance creation' } +MolComponentToRoassal class >> connectorsOn: aMolComponent [ + + | connectors connectorsIn connectorsOut model | + connectorsIn := self connectorsInOn: aMolComponent. + connectorsOut := self connectorsOutOn: aMolComponent. + + model := connectorsIn model asOrderedCollection + , connectorsOut model asOrderedCollection. + + (connectorsIn children isEmpty and: [ + connectorsOut children isNotEmpty ]) ifTrue: [ + connectorsIn + add: (RSBox new + extent: connectorsOut extent; + color: Color transparent; + model: aMolComponent; + yourself); + adjustToChildren ]. + (connectorsOut children isEmpty and: [ + connectorsIn children isNotEmpty ]) ifTrue: [ + connectorsOut + add: (RSBox new + extent: connectorsIn extent; + color: Color transparent; + model: aMolComponent; + yourself); + adjustToChildren ]. + + connectors := RSComposite new + shapes: { + connectorsIn. + connectorsOut }; + yourself. + connectors model: model. + + RSHorizontalLineLayout new + alignTop; + on: connectors shapes. + connectors adjustToChildren. + ^ connectors +] + +{ #category : #'instance creation' } +MolComponentToRoassal class >> connectorsOutOn: aMolComponent [ + + | eventsOut connectors services events parameters | + eventsOut := aMolComponent eventsNotifiers keys. + services := self + connectorsFromEventCollection: + (eventsOut select: [ :each | + each usesTrait: MolComponentServices ]) + andColor: Color green muchLighter + andCornerRadius: (RSCornerRadius new left: 10). + events := self + connectorsFromEventCollection: + (eventsOut select: [ :each | + each usesTrait: MolComponentEvents ]) + andColor: Color blue muchLighter + andCornerRadius: (RSCornerRadius new left: 10). + parameters := self + connectorsFromEventCollection: + (eventsOut select: [ :each | + each usesTrait: MolComponentParameters ]) + andColor: Color red muchLighter + andCornerRadius: (RSCornerRadius new left: 10). + connectors := RSComposite new + shapes: services , events , parameters; + yourself. + connectors model: (connectors shapes collect: #model). + + RSVerticalLineLayout new + alignRight; + on: connectors shapes. + + connectors adjustToChildren. + ^ connectors +] + +{ #category : #'instance creation' } +MolComponentToRoassal class >> graphFromSingleComponent: aMolComponent [ + + | classNameLabel componentNameLabel connectors composite | + classNameLabel := RSLabel new + text: aMolComponent className; + color: Color black lighter lighter; + italic; + fontSize: 14; + yourself. + componentNameLabel := RSLabel new + text: aMolComponent componentName; + color: Color black; + fontSize: 18; + yourself. + + connectors := self connectorsOn: aMolComponent. + + RSVerticalLineLayout new + alignCenter; + on: { + componentNameLabel. + classNameLabel. + connectors }. + + composite := RSComposite new + draggable; + popupText: [ :comp | comp componentName ]; + model: aMolComponent; + withBorder; + color: Color gray muchLighter; + shapes: { + componentNameLabel. + classNameLabel. + connectors }; + yourself. + composite adjustToChildren. + composite extent: composite extent + (0 @ 20). + composite @ (RSMenuActivable new menuDo: [ :aMenuMorph :anRSBox | + aMenuMorph + add: 'Inspect' + target: aMolComponent + selector: #inspect + argument: #( ) ]). + + ^ composite +] + +{ #category : #'see class side' } +MolComponentToRoassal >> seeClassSide [ +] diff --git a/src/Molecule/MolComponentImpl.trait.st b/src/Molecule/MolComponentImpl.trait.st index fcde883..61f9bc4 100644 --- a/src/Molecule/MolComponentImpl.trait.st +++ b/src/Molecule/MolComponentImpl.trait.st @@ -202,6 +202,12 @@ MolComponentImpl classSide >> undeploy [ ^ MolComponentManager default deploymentServices undeployComponentImplementation: self ] +{ #category : #converting } +MolComponentImpl >> asRSMoleculeShape [ + + ^ MolComponentToRoassal graphFromSingleComponent: self +] + { #category : #'life cycle' } MolComponentImpl >> componentActivate [ "here write the code corresponding to component activation phase" diff --git a/src/Molecule/MolHomeServices.class.st b/src/Molecule/MolHomeServices.class.st index 979198f..c244932 100644 --- a/src/Molecule/MolHomeServices.class.st +++ b/src/Molecule/MolHomeServices.class.st @@ -148,6 +148,19 @@ MolHomeServices >> initialize [ waitingForActivation := Set new ] +{ #category : #'as yet unclassified' } +MolHomeServices >> inspectionDeployedComponentsGraph [ + + + | canvas components | + components := self deployedComponents flatCollect: #values. + canvas := MolComponentToRoassal canvasFromMultipleComponents: components. + + ^ SpRoassalInspectorPresenter new + canvas: canvas; + yourself +] + { #category : #accessing } MolHomeServices >> instanceOf: aClass named: aName [ ^(self deployedComponents at: aClass ifAbsent: [^nil]) at: aName ifAbsent: [^nil] From ad5cb16bae96afdbb08d937f510cdab3309794d2 Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Thu, 5 Dec 2024 08:19:45 +0100 Subject: [PATCH 2/7] Fix the link. The link where only checking if the component had the same interfaces, now it also check for the component name --- .../MolComponentToRoassal.class.st | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Molecule-IDE/MolComponentToRoassal.class.st b/src/Molecule-IDE/MolComponentToRoassal.class.st index b1617ea..f5eaddb 100644 --- a/src/Molecule-IDE/MolComponentToRoassal.class.st +++ b/src/Molecule-IDE/MolComponentToRoassal.class.st @@ -21,12 +21,13 @@ MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfCompon dictionaryEvents := Dictionary new. aCollectionOfComponents collect: [ :comp | - comp servicesProviders keys , comp parametersProviders keys - , comp eventsSubscribers keys do: [ :event | + comp servicesProviders associations + , comp parametersProviders associations + , comp eventsSubscribers associations do: [ :eventAndName | dictionaryEvents - at: event - ifPresent: [ :l | l add: comp ] - ifAbsentPut: [ OrderedCollection with: comp ] ] ]. + at: eventAndName key + ifPresent: [ :l | l add: eventAndName value -> comp ] + ifAbsentPut: [ OrderedCollection with: eventAndName value -> comp ] ] ]. lineBuilder := RSLineBuilder arrowedLine canvas: canvas; @@ -37,16 +38,22 @@ MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfCompon dictionaryEvents at: event ifPresent: [ :allComponentsForEvent | - lineBuilder useAssociations: - (allComponentsForEvent collect: [ :compTarget | - compSource -> compTarget ]) ] + | matchingComponents | + matchingComponents := allComponentsForEvent select: [ :compTarget | + compSource componentName = compTarget key ]. + matchingComponents + ifNotEmpty: [ :val | + lineBuilder useAssociations: + (val collect: [ :each | compSource -> each value ]) ] + ifEmpty: [ + self flag: #TODO "No components habs the correct componentName for this contract ..." ] ] ifAbsent: [ - self flag: #TODO "No components has been found for this contract ..." ] ] ]. + self flag: #TODO "No components has the event for this contract ..." ] ] ]. RSForceBasedLayout new doNotUseProgressBar; - length: 400; - charge: -2000; + length: 3000; + charge: 1; on: canvas nodes. canvas @ RSCanvasController. From d97889466a793dca932ec65ade56030908c9b2ca Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Thu, 5 Dec 2024 17:09:29 +0100 Subject: [PATCH 3/7] Link on contracts --- .../MolComponentToRoassal.class.st | 244 +++++++++++++----- src/Molecule-IDE/MolRSContractModel.class.st | 71 +++++ .../MolRSContractModelSource.class.st | 24 ++ .../MolRSContractModelTarget.class.st | 10 + src/Molecule/MolComponentImpl.trait.st | 10 + 5 files changed, 289 insertions(+), 70 deletions(-) create mode 100644 src/Molecule-IDE/MolRSContractModel.class.st create mode 100644 src/Molecule-IDE/MolRSContractModelSource.class.st create mode 100644 src/Molecule-IDE/MolRSContractModelTarget.class.st diff --git a/src/Molecule-IDE/MolComponentToRoassal.class.st b/src/Molecule-IDE/MolComponentToRoassal.class.st index f5eaddb..3d96538 100644 --- a/src/Molecule-IDE/MolComponentToRoassal.class.st +++ b/src/Molecule-IDE/MolComponentToRoassal.class.st @@ -11,49 +11,122 @@ Class { #category : #'Molecule-IDE-Inspectors' } -{ #category : #'as yet unclassified' } +{ #category : #'instance creation' } +MolComponentToRoassal class >> associationsAllConsumedEventsAndTargetsFor: aMolComponent [ + + ^ aMolComponent componentConnector eventsSubscribers associations + collect: [ :asso | + MolRSContractModelTarget new + eventClass: asso key; + name: asso value; + component: aMolComponent; + color: self eventColor; + yourself ] +] + +{ #category : #'instance creation' } +MolComponentToRoassal class >> associationsAllProducedEventsAndTargetsFor: aMolComponent [ + + ^ aMolComponent class allProducedEvents collect: [ :event | + MolRSContractModelSource new + eventClass: event; + name: aMolComponent componentName; + component: aMolComponent; + color: self eventColor; + yourself ]. + + +] + +{ #category : #'instance creation' } +MolComponentToRoassal class >> associationsAllProvidedParametersAndTargetsFor: aMolComponent [ + + ^ aMolComponent class allProvidedParameters collect: [ :event | + MolRSContractModelSource new + eventClass: event; + name: aMolComponent componentName; + component: aMolComponent; + color: self parameterColor; + yourself ]. +] + +{ #category : #'instance creation' } +MolComponentToRoassal class >> associationsAllProvidedServicesAndTargetsFor: aMolComponent [ + + ^ aMolComponent class allProvidedServices collect: [ :event | + MolRSContractModelSource new + eventClass: event; + name: aMolComponent componentName; + component: aMolComponent; + color: self serviceColor; + yourself ]. +] + +{ #category : #'instance creation' } +MolComponentToRoassal class >> associationsAllUsedParametersAndTargetsFor: aMolComponent [ + + ^ aMolComponent componentConnector parametersProviders associations collect: [ :asso | + MolRSContractModelTarget new + eventClass: asso key; + name: asso value; + component: aMolComponent; + color: self parameterColor; + yourself ] +] + +{ #category : #'instance creation' } +MolComponentToRoassal class >> associationsAllUsedServicesAndTargetsFor: aMolComponent [ + + ^ aMolComponent componentConnector servicesProviders associations collect: [ :asso | + MolRSContractModelTarget new + eventClass: asso key; + name: asso value; + component: aMolComponent; + color: self serviceColor; + yourself ] +] + +{ #category : #'instance creation' } MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfComponents [ - | canvas dictionaryEvents lineBuilder | + | canvas componentShapes allEventShapes allContracts allContractSources allContractTargets lineBuilder | canvas := RSCanvas new. - canvas addAll: - (aCollectionOfComponents collect: [ :comp | comp asRSMoleculeShape ]). - - dictionaryEvents := Dictionary new. - aCollectionOfComponents collect: [ :comp | - comp servicesProviders associations - , comp parametersProviders associations - , comp eventsSubscribers associations do: [ :eventAndName | - dictionaryEvents - at: eventAndName key - ifPresent: [ :l | l add: eventAndName value -> comp ] - ifAbsentPut: [ OrderedCollection with: eventAndName value -> comp ] ] ]. + componentShapes := aCollectionOfComponents collect: [ :comp | + comp asRSMoleculeShape ]. + canvas addAll: componentShapes. + + allEventShapes := componentShapes flatCollect: [ :a | + | tempCollection | + tempCollection := a children select: [ :b | + b model isCollection ]. + ((((tempCollection flatCollect: #children) + flatCollect: #children) reject: [ :each | + each model isComponent ]) flatCollect: + #children) select: [ :c | c model isNotNil ] ]. + + allContracts := allEventShapes collect: #model. + allContractSources := allContracts select: [ :each | + each isContractSource ]. + allContractTargets := allContracts reject: [ :each | + each isContractSource ]. lineBuilder := RSLineBuilder arrowedLine canvas: canvas; + shapes: allEventShapes; withBorderAttachPoint. - aCollectionOfComponents do: [ :compSource | - compSource eventsNotifiers keys do: [ :event | - dictionaryEvents - at: event - ifPresent: [ :allComponentsForEvent | - | matchingComponents | - matchingComponents := allComponentsForEvent select: [ :compTarget | - compSource componentName = compTarget key ]. - matchingComponents - ifNotEmpty: [ :val | - lineBuilder useAssociations: - (val collect: [ :each | compSource -> each value ]) ] - ifEmpty: [ - self flag: #TODO "No components habs the correct componentName for this contract ..." ] ] - ifAbsent: [ - self flag: #TODO "No components has the event for this contract ..." ] ] ]. + allContractSources do: [ :source | + | allAssociatedTargets | + allAssociatedTargets := allContractTargets select: [ :target | + target eventClass = source eventClass and: [ + target name = source name ] ]. + allAssociatedTargets do: [ :target | + lineBuilder useAssociation: source -> target ] ]. RSForceBasedLayout new doNotUseProgressBar; length: 3000; - charge: 1; + charge: -1000; on: canvas nodes. canvas @ RSCanvasController. @@ -62,26 +135,49 @@ MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfCompon ] { #category : #'instance creation' } -MolComponentToRoassal class >> connectorsFromEventCollection: aCollection andColor: aColor andCornerRadius: aCornerRadius [ +MolComponentToRoassal class >> canvasFromSingleComponent: aMolComponent [ - ^ aCollection collect: [ :each | - | eventBox eventName | + | canvas | + canvas := RSCanvas new. + canvas add: aMolComponent asRSMoleculeShape. + canvas @ RSCanvasController. + canvas zoomToFit. + ^ canvas +] + +{ #category : #'instance creation' } +MolComponentToRoassal class >> connectorsFromMolRSContracts: aCollectionOfMolRSContractModel [ + + ^ aCollectionOfMolRSContractModel collect: [ :rsContractModel | + | linkBox eventBox eventName | eventName := RSLabel new - text: each printString; + text: rsContractModel eventClass printString; color: Color black; yourself. + eventBox := RSBox new withBorder; - color: aColor; + color: rsContractModel color; extent: eventName extent + 10; - cornerRadius: aCornerRadius; + cornerRadius: rsContractModel rsCornerRadius; yourself. + + linkBox := RSBox new + extent: 1 asPoint; + color: Color transparent; + model: rsContractModel; + yourself. + rsContractModel isContractSource + ifTrue: [ linkBox position: eventBox extent x / 2 @ 0 ] + ifFalse: [ linkBox position: eventBox extent x / -2 @ 0 ]. + RSComposite new shapes: { + linkBox. eventBox. eventName }; adjustToChildren; - model: each; + model: rsContractModel eventClass; yourself ] ] @@ -90,20 +186,18 @@ MolComponentToRoassal class >> connectorsInOn: aMolComponent [ | connectors services events parameters | services := self - connectorsFromEventCollection: - aMolComponent servicesProviders keys - andColor: Color green muchLighter - andCornerRadius: (RSCornerRadius new right: 10). + connectorsFromMolRSContracts: + (self associationsAllUsedServicesAndTargetsFor: + aMolComponent). events := self - connectorsFromEventCollection: - aMolComponent eventsSubscribers keys - andColor: Color blue muchLighter - andCornerRadius: (RSCornerRadius new right: 10). + connectorsFromMolRSContracts: + (self associationsAllConsumedEventsAndTargetsFor: + aMolComponent). parameters := self - connectorsFromEventCollection: - aMolComponent parametersProviders keys - andColor: Color red muchLighter - andCornerRadius: (RSCornerRadius new right: 10). + connectorsFromMolRSContracts: + (self associationsAllUsedParametersAndTargetsFor: + aMolComponent). + connectors := RSComposite new shapes: services , events , parameters; yourself. @@ -163,26 +257,18 @@ MolComponentToRoassal class >> connectorsOn: aMolComponent [ { #category : #'instance creation' } MolComponentToRoassal class >> connectorsOutOn: aMolComponent [ - | eventsOut connectors services events parameters | - eventsOut := aMolComponent eventsNotifiers keys. - services := self - connectorsFromEventCollection: - (eventsOut select: [ :each | - each usesTrait: MolComponentServices ]) - andColor: Color green muchLighter - andCornerRadius: (RSCornerRadius new left: 10). - events := self - connectorsFromEventCollection: - (eventsOut select: [ :each | - each usesTrait: MolComponentEvents ]) - andColor: Color blue muchLighter - andCornerRadius: (RSCornerRadius new left: 10). - parameters := self - connectorsFromEventCollection: - (eventsOut select: [ :each | - each usesTrait: MolComponentParameters ]) - andColor: Color red muchLighter - andCornerRadius: (RSCornerRadius new left: 10). + | connectors services events parameters | + + services := self connectorsFromMolRSContracts: + (self associationsAllProvidedServicesAndTargetsFor: + aMolComponent). + events := self connectorsFromMolRSContracts: + (self associationsAllProducedEventsAndTargetsFor: + aMolComponent). + parameters := self connectorsFromMolRSContracts: + (self associationsAllProvidedParametersAndTargetsFor: + aMolComponent). + connectors := RSComposite new shapes: services , events , parameters; yourself. @@ -196,6 +282,12 @@ MolComponentToRoassal class >> connectorsOutOn: aMolComponent [ ^ connectors ] +{ #category : #color } +MolComponentToRoassal class >> eventColor [ + + ^ Color blue muchLighter +] + { #category : #'instance creation' } MolComponentToRoassal class >> graphFromSingleComponent: aMolComponent [ @@ -244,6 +336,18 @@ MolComponentToRoassal class >> graphFromSingleComponent: aMolComponent [ ^ composite ] +{ #category : #color } +MolComponentToRoassal class >> parameterColor [ + + ^ Color red muchLighter +] + +{ #category : #color } +MolComponentToRoassal class >> serviceColor [ + + ^ Color green muchLighter +] + { #category : #'see class side' } MolComponentToRoassal >> seeClassSide [ ] diff --git a/src/Molecule-IDE/MolRSContractModel.class.st b/src/Molecule-IDE/MolRSContractModel.class.st new file mode 100644 index 0000000..8a0becb --- /dev/null +++ b/src/Molecule-IDE/MolRSContractModel.class.st @@ -0,0 +1,71 @@ +Class { + #name : #MolRSContractModel, + #superclass : #Object, + #instVars : [ + 'component', + 'name', + 'eventClass', + 'color' + ], + #category : #'Molecule-IDE-Inspectors' +} + +{ #category : #accessing } +MolRSContractModel >> color [ + + ^ color +] + +{ #category : #accessing } +MolRSContractModel >> color: anObject [ + + color := anObject +] + +{ #category : #accessing } +MolRSContractModel >> component [ + + ^ component +] + +{ #category : #accessing } +MolRSContractModel >> component: anObject [ + + component := anObject +] + +{ #category : #accessing } +MolRSContractModel >> eventClass [ + + ^ eventClass +] + +{ #category : #accessing } +MolRSContractModel >> eventClass: anObject [ + + eventClass := anObject +] + +{ #category : #testing } +MolRSContractModel >> isContractSource [ + + ^ false +] + +{ #category : #accessing } +MolRSContractModel >> name [ + + ^ name +] + +{ #category : #accessing } +MolRSContractModel >> name: anObject [ + + name := anObject +] + +{ #category : #'as yet unclassified' } +MolRSContractModel >> rsCornerRadius [ + + ^ self shouldBeImplemented +] diff --git a/src/Molecule-IDE/MolRSContractModelSource.class.st b/src/Molecule-IDE/MolRSContractModelSource.class.st new file mode 100644 index 0000000..d7bfaff --- /dev/null +++ b/src/Molecule-IDE/MolRSContractModelSource.class.st @@ -0,0 +1,24 @@ +Class { + #name : #MolRSContractModelSource, + #superclass : #MolRSContractModel, + #category : #'Molecule-IDE-Inspectors' +} + +{ #category : #'as yet unclassified' } +MolRSContractModelSource >> findTarget [ + + self halt. + ^ nil +] + +{ #category : #testing } +MolRSContractModelSource >> isContractSource [ + + ^ true +] + +{ #category : #'as yet unclassified' } +MolRSContractModelSource >> rsCornerRadius [ + + ^ RSCornerRadius new left: 10 +] diff --git a/src/Molecule-IDE/MolRSContractModelTarget.class.st b/src/Molecule-IDE/MolRSContractModelTarget.class.st new file mode 100644 index 0000000..d5b1c0b --- /dev/null +++ b/src/Molecule-IDE/MolRSContractModelTarget.class.st @@ -0,0 +1,10 @@ +Class { + #name : #MolRSContractModelTarget, + #superclass : #MolRSContractModel, + #category : #'Molecule-IDE-Inspectors' +} + +{ #category : #'as yet unclassified' } +MolRSContractModelTarget >> rsCornerRadius [ + ^ RSCornerRadius new right: 10 +] diff --git a/src/Molecule/MolComponentImpl.trait.st b/src/Molecule/MolComponentImpl.trait.st index 61f9bc4..7f8f04b 100644 --- a/src/Molecule/MolComponentImpl.trait.st +++ b/src/Molecule/MolComponentImpl.trait.st @@ -424,6 +424,16 @@ MolComponentImpl >> forServices: aServicesTrait useProvider: aComponentName [ ifFalse: [ MolUtils log: self printString, '>forServices:useProvider: try to link a non services trait for services ' ] ] +{ #category : #'as yet unclassified' } +MolComponentImpl >> inspectionComponent [ + + + + ^ SpRoassalInspectorPresenter new + canvas: (MolComponentToRoassal canvasFromSingleComponent: self); + yourself +] + { #category : #testing } MolComponentImpl >> isComponent [ From a7e23e8b89af2dd69d9af486aede7e01cb7cadad Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Thu, 5 Dec 2024 18:38:27 +0100 Subject: [PATCH 4/7] Add a better layout for the nodes --- .../MolComponentToRoassal.class.st | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/Molecule-IDE/MolComponentToRoassal.class.st b/src/Molecule-IDE/MolComponentToRoassal.class.st index 3d96538..38f5849 100644 --- a/src/Molecule-IDE/MolComponentToRoassal.class.st +++ b/src/Molecule-IDE/MolComponentToRoassal.class.st @@ -89,7 +89,7 @@ MolComponentToRoassal class >> associationsAllUsedServicesAndTargetsFor: aMolCom { #category : #'instance creation' } MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfComponents [ - | canvas componentShapes allEventShapes allContracts allContractSources allContractTargets lineBuilder | + | canvas componentShapes allEventShapes allContracts allContractSources allContractTargets lineBuilder ghostLineBuilder | canvas := RSCanvas new. componentShapes := aCollectionOfComponents collect: [ :comp | comp asRSMoleculeShape ]. @@ -114,6 +114,11 @@ MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfCompon canvas: canvas; shapes: allEventShapes; withBorderAttachPoint. + ghostLineBuilder := RSLineBuilder line + canvas: canvas; + shapes: componentShapes; + color: Color transparent; + withBorderAttachPoint. allContractSources do: [ :source | | allAssociatedTargets | @@ -121,14 +126,34 @@ MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfCompon target eventClass = source eventClass and: [ target name = source name ] ]. allAssociatedTargets do: [ :target | - lineBuilder useAssociation: source -> target ] ]. + lineBuilder useAssociation: source -> target. + ghostLineBuilder useAssociation: source component -> target component ] ]. - RSForceBasedLayout new + "RSForceBasedLayout new doNotUseProgressBar; length: 3000; charge: -1000; + on: canvas nodes." + + "RSGridLayout new + lineItemsCount: 10; + gapSize: 1; + on: canvas nodes." + "RSHorizontalTreeLayout new + horizontalGap: 500; + on: canvas nodes; + yourself." + + RSConditionalLayout new + ifNotConnectedThen: RSVerticalLineLayout new; + else: (RSClusteringLayout new + clustersLayout: RSGridLayout new; + forEachLayout: (RSHorizontalTreeLayout new horizontalGap: 500; yourself)); on: canvas nodes. + "RSHorizontalTreeLayout new on: canvas nodes." + "RSClusterRadialTreeLayout new on: canvas nodes." + canvas @ RSCanvasController. canvas zoomToFit. ^ canvas From f8614083f5b32930309d8f4a31c7450bb7c5b9e4 Mon Sep 17 00:00:00 2001 From: Nyan11 Date: Fri, 6 Dec 2024 11:22:58 +0100 Subject: [PATCH 5/7] sort the events by name --- src/Molecule-IDE/MolComponentToRoassal.class.st | 12 ++++++------ src/Molecule-IDE/MolRSContractModel.class.st | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Molecule-IDE/MolComponentToRoassal.class.st b/src/Molecule-IDE/MolComponentToRoassal.class.st index 38f5849..0ac0918 100644 --- a/src/Molecule-IDE/MolComponentToRoassal.class.st +++ b/src/Molecule-IDE/MolComponentToRoassal.class.st @@ -213,15 +213,15 @@ MolComponentToRoassal class >> connectorsInOn: aMolComponent [ services := self connectorsFromMolRSContracts: (self associationsAllUsedServicesAndTargetsFor: - aMolComponent). + aMolComponent) sorted. events := self connectorsFromMolRSContracts: (self associationsAllConsumedEventsAndTargetsFor: - aMolComponent). + aMolComponent) sorted. parameters := self connectorsFromMolRSContracts: (self associationsAllUsedParametersAndTargetsFor: - aMolComponent). + aMolComponent) sorted. connectors := RSComposite new shapes: services , events , parameters; @@ -286,13 +286,13 @@ MolComponentToRoassal class >> connectorsOutOn: aMolComponent [ services := self connectorsFromMolRSContracts: (self associationsAllProvidedServicesAndTargetsFor: - aMolComponent). + aMolComponent) sorted. events := self connectorsFromMolRSContracts: (self associationsAllProducedEventsAndTargetsFor: - aMolComponent). + aMolComponent) sorted. parameters := self connectorsFromMolRSContracts: (self associationsAllProvidedParametersAndTargetsFor: - aMolComponent). + aMolComponent) sorted. connectors := RSComposite new shapes: services , events , parameters; diff --git a/src/Molecule-IDE/MolRSContractModel.class.st b/src/Molecule-IDE/MolRSContractModel.class.st index 8a0becb..bc07a90 100644 --- a/src/Molecule-IDE/MolRSContractModel.class.st +++ b/src/Molecule-IDE/MolRSContractModel.class.st @@ -10,6 +10,12 @@ Class { #category : #'Molecule-IDE-Inspectors' } +{ #category : #comparing } +MolRSContractModel >> <= aMolRSContractModel [ + + ^ self eventClass name < aMolRSContractModel eventClass name +] + { #category : #accessing } MolRSContractModel >> color [ From dfc22f650d37ec9169d4e10cec6e93b9d813e7cb Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Tue, 10 Dec 2024 09:26:08 +0100 Subject: [PATCH 6/7] Move method into correct package --- src/Molecule-IDE/MolComponentImpl.extension.st | 17 +++++++++++++++++ src/Molecule-IDE/MolHomeServices.extension.st | 14 ++++++++++++++ src/Molecule/MolComponentImpl.trait.st | 16 ---------------- src/Molecule/MolHomeServices.class.st | 13 ------------- 4 files changed, 31 insertions(+), 29 deletions(-) create mode 100644 src/Molecule-IDE/MolComponentImpl.extension.st create mode 100644 src/Molecule-IDE/MolHomeServices.extension.st diff --git a/src/Molecule-IDE/MolComponentImpl.extension.st b/src/Molecule-IDE/MolComponentImpl.extension.st new file mode 100644 index 0000000..df719d3 --- /dev/null +++ b/src/Molecule-IDE/MolComponentImpl.extension.st @@ -0,0 +1,17 @@ +Extension { #name : #MolComponentImpl } + +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> asRSMoleculeShape [ + + ^ MolComponentToRoassal graphFromSingleComponent: self +] + +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> inspectionComponent [ + + + + ^ SpRoassalInspectorPresenter new + canvas: (MolComponentToRoassal canvasFromSingleComponent: self); + yourself +] diff --git a/src/Molecule-IDE/MolHomeServices.extension.st b/src/Molecule-IDE/MolHomeServices.extension.st new file mode 100644 index 0000000..3091140 --- /dev/null +++ b/src/Molecule-IDE/MolHomeServices.extension.st @@ -0,0 +1,14 @@ +Extension { #name : #MolHomeServices } + +{ #category : #'*Molecule-IDE' } +MolHomeServices >> inspectionDeployedComponentsGraph [ + + + | canvas components | + components := self deployedComponents flatCollect: #values. + canvas := MolComponentToRoassal canvasFromMultipleComponents: components. + + ^ SpRoassalInspectorPresenter new + canvas: canvas; + yourself +] diff --git a/src/Molecule/MolComponentImpl.trait.st b/src/Molecule/MolComponentImpl.trait.st index 7f8f04b..fcde883 100644 --- a/src/Molecule/MolComponentImpl.trait.st +++ b/src/Molecule/MolComponentImpl.trait.st @@ -202,12 +202,6 @@ MolComponentImpl classSide >> undeploy [ ^ MolComponentManager default deploymentServices undeployComponentImplementation: self ] -{ #category : #converting } -MolComponentImpl >> asRSMoleculeShape [ - - ^ MolComponentToRoassal graphFromSingleComponent: self -] - { #category : #'life cycle' } MolComponentImpl >> componentActivate [ "here write the code corresponding to component activation phase" @@ -424,16 +418,6 @@ MolComponentImpl >> forServices: aServicesTrait useProvider: aComponentName [ ifFalse: [ MolUtils log: self printString, '>forServices:useProvider: try to link a non services trait for services ' ] ] -{ #category : #'as yet unclassified' } -MolComponentImpl >> inspectionComponent [ - - - - ^ SpRoassalInspectorPresenter new - canvas: (MolComponentToRoassal canvasFromSingleComponent: self); - yourself -] - { #category : #testing } MolComponentImpl >> isComponent [ diff --git a/src/Molecule/MolHomeServices.class.st b/src/Molecule/MolHomeServices.class.st index c244932..979198f 100644 --- a/src/Molecule/MolHomeServices.class.st +++ b/src/Molecule/MolHomeServices.class.st @@ -148,19 +148,6 @@ MolHomeServices >> initialize [ waitingForActivation := Set new ] -{ #category : #'as yet unclassified' } -MolHomeServices >> inspectionDeployedComponentsGraph [ - - - | canvas components | - components := self deployedComponents flatCollect: #values. - canvas := MolComponentToRoassal canvasFromMultipleComponents: components. - - ^ SpRoassalInspectorPresenter new - canvas: canvas; - yourself -] - { #category : #accessing } MolHomeServices >> instanceOf: aClass named: aName [ ^(self deployedComponents at: aClass ifAbsent: [^nil]) at: aName ifAbsent: [^nil] From 40433df04007a7b74c943442877d3715764ab562 Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Tue, 10 Dec 2024 10:25:42 +0100 Subject: [PATCH 7/7] Small improvments, comments, rename some methods --- .../MolComponentImpl.extension.st | 44 +++- .../MolComponentToRoassal.class.st | 228 +++++++----------- src/Molecule-IDE/MolRSContractModel.class.st | 11 + .../MolRSContractModelSource.class.st | 10 +- .../MolRSContractModelTarget.class.st | 3 + 5 files changed, 145 insertions(+), 151 deletions(-) diff --git a/src/Molecule-IDE/MolComponentImpl.extension.st b/src/Molecule-IDE/MolComponentImpl.extension.st index df719d3..6685d2f 100644 --- a/src/Molecule-IDE/MolComponentImpl.extension.st +++ b/src/Molecule-IDE/MolComponentImpl.extension.st @@ -3,7 +3,49 @@ Extension { #name : #MolComponentImpl } { #category : #'*Molecule-IDE' } MolComponentImpl >> asRSMoleculeShape [ - ^ MolComponentToRoassal graphFromSingleComponent: self + | classNameLabel componentNameLabel contracts composite | + classNameLabel := RSLabel new + text: self className; + color: Color black lighter lighter; + italic; + fontSize: 14; + yourself. + componentNameLabel := RSLabel new + text: self componentName; + color: Color black; + fontSize: 18; + yourself. + + contracts := MolComponentToRoassal contractFromMolComponentImpl: self. + + RSVerticalLineLayout new + alignCenter; + on: { + componentNameLabel. + classNameLabel. + contracts }. + + composite := RSComposite new + draggable; + popupText: [ :comp | comp componentName ]; + model: self; + withBorder; + color: Color gray muchLighter; + shapes: { + componentNameLabel. + classNameLabel. + contracts }; + yourself. + composite adjustToChildren. + composite extent: composite extent + (0 @ 20). + composite @ (RSMenuActivable new menuDo: [ :aMenuMorph :anRSBox | + aMenuMorph + add: 'Inspect' + target: self + selector: #inspect + argument: #( ) ]). + + ^ composite ] { #category : #'*Molecule-IDE' } diff --git a/src/Molecule-IDE/MolComponentToRoassal.class.st b/src/Molecule-IDE/MolComponentToRoassal.class.st index 0ac0918..e1e8146 100644 --- a/src/Molecule-IDE/MolComponentToRoassal.class.st +++ b/src/Molecule-IDE/MolComponentToRoassal.class.st @@ -1,8 +1,8 @@ " I am a utility class to transform a Molecule component into a Roassal graph. -Use #graphFromSingleComponent: aMolComponent to have a RSShape of the Molecule component. -Use #canvasFromMultipleComponents: aCollection to have a RSCanvas of multiple Molecule components. +Use `#canvasFromSingleComponent: aMolComponent` to have a `RSCanvas` of a single `MolComponentImpl`. +Use `#canvasFromMultipleComponents: aCollection` to have a `RSCanvas` of multiple `MolComponentImpl`. " Class { @@ -11,7 +11,7 @@ Class { #category : #'Molecule-IDE-Inspectors' } -{ #category : #'instance creation' } +{ #category : #model } MolComponentToRoassal class >> associationsAllConsumedEventsAndTargetsFor: aMolComponent [ ^ aMolComponent componentConnector eventsSubscribers associations @@ -24,7 +24,7 @@ MolComponentToRoassal class >> associationsAllConsumedEventsAndTargetsFor: aMolC yourself ] ] -{ #category : #'instance creation' } +{ #category : #model } MolComponentToRoassal class >> associationsAllProducedEventsAndTargetsFor: aMolComponent [ ^ aMolComponent class allProducedEvents collect: [ :event | @@ -38,7 +38,7 @@ MolComponentToRoassal class >> associationsAllProducedEventsAndTargetsFor: aMolC ] -{ #category : #'instance creation' } +{ #category : #model } MolComponentToRoassal class >> associationsAllProvidedParametersAndTargetsFor: aMolComponent [ ^ aMolComponent class allProvidedParameters collect: [ :event | @@ -50,7 +50,7 @@ MolComponentToRoassal class >> associationsAllProvidedParametersAndTargetsFor: a yourself ]. ] -{ #category : #'instance creation' } +{ #category : #model } MolComponentToRoassal class >> associationsAllProvidedServicesAndTargetsFor: aMolComponent [ ^ aMolComponent class allProvidedServices collect: [ :event | @@ -62,7 +62,7 @@ MolComponentToRoassal class >> associationsAllProvidedServicesAndTargetsFor: aMo yourself ]. ] -{ #category : #'instance creation' } +{ #category : #model } MolComponentToRoassal class >> associationsAllUsedParametersAndTargetsFor: aMolComponent [ ^ aMolComponent componentConnector parametersProviders associations collect: [ :asso | @@ -74,7 +74,7 @@ MolComponentToRoassal class >> associationsAllUsedParametersAndTargetsFor: aMolC yourself ] ] -{ #category : #'instance creation' } +{ #category : #model } MolComponentToRoassal class >> associationsAllUsedServicesAndTargetsFor: aMolComponent [ ^ aMolComponent componentConnector servicesProviders associations collect: [ :asso | @@ -95,6 +95,8 @@ MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfCompon comp asRSMoleculeShape ]. canvas addAll: componentShapes. + "We need tor recover all the contract shape in the roassal elements tree. + The code is a bit spaghetti ..." allEventShapes := componentShapes flatCollect: [ :a | | tempCollection | tempCollection := a children select: [ :b | @@ -104,12 +106,10 @@ MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfCompon each model isComponent ]) flatCollect: #children) select: [ :c | c model isNotNil ] ]. - allContracts := allEventShapes collect: #model. - allContractSources := allContracts select: [ :each | - each isContractSource ]. - allContractTargets := allContracts reject: [ :each | - each isContractSource ]. - + "We create the link between the element. + We need to types of links: + - the displayed arrow that will be created by the `lineBuilder`. + - an invisible link that will be used for the layout that will be created by the `ghostLineBuilder`." lineBuilder := RSLineBuilder arrowedLine canvas: canvas; shapes: allEventShapes; @@ -120,6 +120,11 @@ MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfCompon color: Color transparent; withBorderAttachPoint. + allContracts := allEventShapes collect: #model. + allContractSources := allContracts select: [ :each | + each isContractSource ]. + allContractTargets := allContracts reject: [ :each | + each isContractSource ]. allContractSources do: [ :source | | allAssociatedTargets | allAssociatedTargets := allContractTargets select: [ :target | @@ -127,33 +132,22 @@ MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfCompon target name = source name ] ]. allAssociatedTargets do: [ :target | lineBuilder useAssociation: source -> target. - ghostLineBuilder useAssociation: source component -> target component ] ]. - - "RSForceBasedLayout new - doNotUseProgressBar; - length: 3000; - charge: -1000; - on: canvas nodes." - - "RSGridLayout new - lineItemsCount: 10; - gapSize: 1; - on: canvas nodes." - "RSHorizontalTreeLayout new - horizontalGap: 500; - on: canvas nodes; - yourself." - + ghostLineBuilder useAssociation: + source component -> target component ] ]. + + "We create a layout for the components: + - if they are not connected: they will be aligned on the top-left corner. + - if they are connected: they will be displayed as a RSHorizontalTreeLayout, all trees will be ina a RSGridLayout." RSConditionalLayout new - ifNotConnectedThen: RSVerticalLineLayout new; + ifNotConnectedThen: (RSVerticalLineLayout new gapSize: 20; yourself); else: (RSClusteringLayout new - clustersLayout: RSGridLayout new; - forEachLayout: (RSHorizontalTreeLayout new horizontalGap: 500; yourself)); + clustersLayout: (RSGridLayout new gapSize: 20; yourself); + forEachLayout: (RSHorizontalTreeLayout new + horizontalGap: 500; + verticalGap: 20; + yourself)); on: canvas nodes. - "RSHorizontalTreeLayout new on: canvas nodes." - "RSClusterRadialTreeLayout new on: canvas nodes." - canvas @ RSCanvasController. canvas zoomToFit. ^ canvas @@ -171,7 +165,50 @@ MolComponentToRoassal class >> canvasFromSingleComponent: aMolComponent [ ] { #category : #'instance creation' } -MolComponentToRoassal class >> connectorsFromMolRSContracts: aCollectionOfMolRSContractModel [ +MolComponentToRoassal class >> contractFromMolComponentImpl: aMolComponent [ + + | contractsAll contractsIn contractsOut model | + contractsIn := self contractsInFor: aMolComponent. + contractsOut := self contractsOutFor: aMolComponent. + + model := contractsIn model asOrderedCollection + , contractsOut model asOrderedCollection. + + (contractsIn children isEmpty and: [ + contractsOut children isNotEmpty ]) ifTrue: [ + contractsIn + add: (RSBox new + extent: contractsOut extent; + color: Color transparent; + model: aMolComponent; + yourself); + adjustToChildren ]. + (contractsOut children isEmpty and: [ + contractsIn children isNotEmpty ]) ifTrue: [ + contractsOut + add: (RSBox new + extent: contractsIn extent; + color: Color transparent; + model: aMolComponent; + yourself); + adjustToChildren ]. + + contractsAll := RSComposite new + shapes: { + contractsIn. + contractsOut }; + yourself. + contractsAll model: model. + + RSHorizontalLineLayout new + alignTop; + on: contractsAll shapes. + contractsAll adjustToChildren. + ^ contractsAll +] + +{ #category : #'instance creation' } +MolComponentToRoassal class >> contractsFromMolRSContracts: aCollectionOfMolRSContractModel [ ^ aCollectionOfMolRSContractModel collect: [ :rsContractModel | | linkBox eventBox eventName | @@ -207,24 +244,21 @@ MolComponentToRoassal class >> connectorsFromMolRSContracts: aCollectionOfMolRSC ] { #category : #'instance creation' } -MolComponentToRoassal class >> connectorsInOn: aMolComponent [ +MolComponentToRoassal class >> contractsInFor: aMolComponent [ | connectors services events parameters | - services := self - connectorsFromMolRSContracts: + services := self contractsFromMolRSContracts: (self associationsAllUsedServicesAndTargetsFor: aMolComponent) sorted. - events := self - connectorsFromMolRSContracts: + events := self contractsFromMolRSContracts: (self associationsAllConsumedEventsAndTargetsFor: aMolComponent) sorted. - parameters := self - connectorsFromMolRSContracts: + parameters := self contractsFromMolRSContracts: (self associationsAllUsedParametersAndTargetsFor: aMolComponent) sorted. connectors := RSComposite new - shapes: services , events , parameters; + shapes: events , services , parameters; yourself. connectors model: (connectors shapes collect: #model). @@ -237,65 +271,21 @@ MolComponentToRoassal class >> connectorsInOn: aMolComponent [ ] { #category : #'instance creation' } -MolComponentToRoassal class >> connectorsOn: aMolComponent [ - - | connectors connectorsIn connectorsOut model | - connectorsIn := self connectorsInOn: aMolComponent. - connectorsOut := self connectorsOutOn: aMolComponent. - - model := connectorsIn model asOrderedCollection - , connectorsOut model asOrderedCollection. - - (connectorsIn children isEmpty and: [ - connectorsOut children isNotEmpty ]) ifTrue: [ - connectorsIn - add: (RSBox new - extent: connectorsOut extent; - color: Color transparent; - model: aMolComponent; - yourself); - adjustToChildren ]. - (connectorsOut children isEmpty and: [ - connectorsIn children isNotEmpty ]) ifTrue: [ - connectorsOut - add: (RSBox new - extent: connectorsIn extent; - color: Color transparent; - model: aMolComponent; - yourself); - adjustToChildren ]. - - connectors := RSComposite new - shapes: { - connectorsIn. - connectorsOut }; - yourself. - connectors model: model. - - RSHorizontalLineLayout new - alignTop; - on: connectors shapes. - connectors adjustToChildren. - ^ connectors -] - -{ #category : #'instance creation' } -MolComponentToRoassal class >> connectorsOutOn: aMolComponent [ +MolComponentToRoassal class >> contractsOutFor: aMolComponent [ | connectors services events parameters | - - services := self connectorsFromMolRSContracts: + services := self contractsFromMolRSContracts: (self associationsAllProvidedServicesAndTargetsFor: aMolComponent) sorted. - events := self connectorsFromMolRSContracts: + events := self contractsFromMolRSContracts: (self associationsAllProducedEventsAndTargetsFor: aMolComponent) sorted. - parameters := self connectorsFromMolRSContracts: + parameters := self contractsFromMolRSContracts: (self associationsAllProvidedParametersAndTargetsFor: aMolComponent) sorted. connectors := RSComposite new - shapes: services , events , parameters; + shapes: events , services , parameters; yourself. connectors model: (connectors shapes collect: #model). @@ -313,54 +303,6 @@ MolComponentToRoassal class >> eventColor [ ^ Color blue muchLighter ] -{ #category : #'instance creation' } -MolComponentToRoassal class >> graphFromSingleComponent: aMolComponent [ - - | classNameLabel componentNameLabel connectors composite | - classNameLabel := RSLabel new - text: aMolComponent className; - color: Color black lighter lighter; - italic; - fontSize: 14; - yourself. - componentNameLabel := RSLabel new - text: aMolComponent componentName; - color: Color black; - fontSize: 18; - yourself. - - connectors := self connectorsOn: aMolComponent. - - RSVerticalLineLayout new - alignCenter; - on: { - componentNameLabel. - classNameLabel. - connectors }. - - composite := RSComposite new - draggable; - popupText: [ :comp | comp componentName ]; - model: aMolComponent; - withBorder; - color: Color gray muchLighter; - shapes: { - componentNameLabel. - classNameLabel. - connectors }; - yourself. - composite adjustToChildren. - composite extent: composite extent + (0 @ 20). - composite @ (RSMenuActivable new menuDo: [ :aMenuMorph :anRSBox | - aMenuMorph - add: 'Inspect' - target: aMolComponent - selector: #inspect - argument: #( ) ]). - - ^ composite -] - { #category : #color } MolComponentToRoassal class >> parameterColor [ diff --git a/src/Molecule-IDE/MolRSContractModel.class.st b/src/Molecule-IDE/MolRSContractModel.class.st index bc07a90..0265422 100644 --- a/src/Molecule-IDE/MolRSContractModel.class.st +++ b/src/Molecule-IDE/MolRSContractModel.class.st @@ -1,3 +1,14 @@ +" +I am used as a model for the Roassal3 inspection add-on (see: `MolComponentToRoassal`). + +I sort the different contracts (services, events, parameters). +I contain: +- the `#component`: the `MolComponentImpl` of the modelized component. +- the `#eventClass`: the class of the modelized event. +- the `#name`: the name of the component if the model is source, or the name of the targeted component if the model is target. +- the `#color`: the `Color` of the event on the Roassal canvas (the colors are defined in `MolComponentToRoassal`). +- the `#rsCornerRadius`: the `RSCornerRadius` object to shape the Roassal element (right for source, left for target). +" Class { #name : #MolRSContractModel, #superclass : #Object, diff --git a/src/Molecule-IDE/MolRSContractModelSource.class.st b/src/Molecule-IDE/MolRSContractModelSource.class.st index d7bfaff..f3097df 100644 --- a/src/Molecule-IDE/MolRSContractModelSource.class.st +++ b/src/Molecule-IDE/MolRSContractModelSource.class.st @@ -1,16 +1,12 @@ +" +I represent a Molecule contract on a component that provide this contract. +" Class { #name : #MolRSContractModelSource, #superclass : #MolRSContractModel, #category : #'Molecule-IDE-Inspectors' } -{ #category : #'as yet unclassified' } -MolRSContractModelSource >> findTarget [ - - self halt. - ^ nil -] - { #category : #testing } MolRSContractModelSource >> isContractSource [ diff --git a/src/Molecule-IDE/MolRSContractModelTarget.class.st b/src/Molecule-IDE/MolRSContractModelTarget.class.st index d5b1c0b..6c82102 100644 --- a/src/Molecule-IDE/MolRSContractModelTarget.class.st +++ b/src/Molecule-IDE/MolRSContractModelTarget.class.st @@ -1,3 +1,6 @@ +" +I represent a Molecule contract on a component that consume this contract. +" Class { #name : #MolRSContractModelTarget, #superclass : #MolRSContractModel,