Skip to content

Commit

Permalink
Merge pull request #194 from OpenSmock/190-MolWorld--UndeclaredVariab…
Browse files Browse the repository at this point in the history
…leRead-Attempt-to-read-undeclared-variable-MCSearchFacade

Write test for #190
  • Loading branch information
labordep authored Oct 1, 2024
2 parents ef06f85 + 32f8fd8 commit fb486a3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 13 deletions.
8 changes: 8 additions & 0 deletions src/Molecule-IDE-Tests/MolWorldTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Class {
#category : #'Molecule-IDE-Tests-Cases'
}

{ #category : #tests }
MolWorldTest >> testOpenDefineComponentDialog [

| dialog |
dialog := MolWorld openDefineComponentDialog.
self assert: dialog notNil.
]

{ #category : #tests }
MolWorldTest >> testWorldMenu [
| menuElements moleculeMenuEntry libraryMenu |
Expand Down
10 changes: 7 additions & 3 deletions src/Molecule-IDE/MolDefineComponentCmdCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ MolDefineComponentCmdCommand >> description [
^'Define this component: force to generate methods from contract definition'
]

{ #category : #accessing }
{ #category : #execution }
MolDefineComponentCmdCommand >> execute [
| componentsToDefine nbOfDefinedComponents |
| componentsToDefine nbOfDefinedComponents text |

componentsToDefine := self selectedComponentClasses.
componentsToDefine do:[ :c | MolComponentFactory defineComponent: c ].

nbOfDefinedComponents := componentsToDefine size.
self executionResult: nbOfDefinedComponents.

self inform: nbOfDefinedComponents asString, ' component', (nbOfDefinedComponents > 1 ifTrue:['s'] ifFalse:['']) ,' defined'.
text := nbOfDefinedComponents = 1
ifTrue:[ 'Define component: ', componentsToDefine first printString ]
ifFalse:[ nbOfDefinedComponents asString, ' component', (nbOfDefinedComponents > 1 ifTrue:['s'] ifFalse:['']) ,' defined' ].

MolUtils showInformation: text.
]
44 changes: 34 additions & 10 deletions src/Molecule-IDE/MolWorld.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,38 @@ Class {
#category : #'Molecule-IDE-Menus'
}

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

<script>
| retValue dialogWindow |
dialogWindow := self openDefineComponentDialog ifNil:[ ^ self ].
retValue := dialogWindow openModal.
^ retValue answer
]

{ #category : #'private - pharo11 remove' }
MolWorld class >> classSearchIn: classes [

self flag:'labordep: #190 this method come from MCSearchFacade. Need to replace it by a Spec2 utils'.

^ ListDialogWindow new
getList: [ :r | classes select: [ :e | r search: e name ] ];
displayBlock: [ :e | e name ];
title: 'Class search' translated;
yourself
]

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

<script>
| component |
component := self openDefineComponentDialog.
component ifNotNil: [ :e | MolComponentFactory defineComponent: e ]
component := self answerComponentToDefine.
component ifNotNil: [ :e |
MolComponentFactory defineComponent: e.
MolUtils showInformation: ('Define component: ', component printString).
]
]

{ #category : #actions }
Expand Down Expand Up @@ -171,18 +196,17 @@ MolWorld class >> menu60ReportBugOn: aBuilder [
action: [WebBrowser openOn: 'https://github.com/OpenSmock/Molecule/issues/new']
]

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

<script>
| searchClass list retValue |
| dialogWindow list |

list := SystemNavigation default allClasses select: [ :c |
c isTrait not and: [
(c allSuperclasses includes: Object) and: [ c isComponentClass ] ] ].
searchClass := MCSearchFacade classSearchIn: list.
searchClass title: 'Select the Molecule Component to define'.
retValue := searchClass openModal.
^ retValue answer

dialogWindow := self classSearchIn: list.
dialogWindow title: 'Select the Molecule Component to define'.
^ dialogWindow
]

{ #category : #'menu - tools' }
Expand Down

0 comments on commit fb486a3

Please sign in to comment.