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

Write test for #190 #194

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
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
Loading