From c640869e86edcdf6feea03585afea9c2ac74fd8f Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Fri, 21 Aug 2020 18:04:35 +0200 Subject: [PATCH 001/372] Midas-Meta: removed deprecated SpDynamicPresenter. Update layout dynamically instead. --- .../MiModelImporterFromPharo.class.st | 194 ++++++++++-------- 1 file changed, 104 insertions(+), 90 deletions(-) diff --git a/src/Midas-Meta/MiModelImporterFromPharo.class.st b/src/Midas-Meta/MiModelImporterFromPharo.class.st index 81a72aa31..7e5172c11 100644 --- a/src/Midas-Meta/MiModelImporterFromPharo.class.st +++ b/src/Midas-Meta/MiModelImporterFromPharo.class.st @@ -21,61 +21,8 @@ Class { { #category : #specs } MiModelImporterFromPharo class >> defaultSpec [ - ^ SpBoxLayout newVertical - spacing: 8; - add: self modelNameLayout; - add: self packageButtonLayout height: self buttonHeight; - add: self metamodelFactoryLayout height: self buttonHeight; - add: #mergeCheckBox height: self labelHeight; - add: #subclassesCheckBox height: self labelHeight; - add: #typeOfAttributesCheckBox height: self labelHeight; - add: self importerClassLayout height: self buttonHeight; - add: #contextCheckBoxes; - add: self invocationStrategyLayout height: self buttonHeight; - yourself -] - -{ #category : #specs } -MiModelImporterFromPharo class >> importerClassLayout [ - ^ SpPanedLayout newHorizontal - add: 'Importer: '; - position: 1.5 / 5; - add: #importerDroplist; - yourself -] - -{ #category : #specs } -MiModelImporterFromPharo class >> invocationStrategyLayout [ - ^ SpBoxLayout newHorizontal - add: 'Invocation candidates computation:'; - add: #invocationStrategyDroplist; - yourself -] - -{ #category : #specs } -MiModelImporterFromPharo class >> metamodelFactoryLayout [ - ^ SpPanedLayout newHorizontal - add: 'Metamodel factory: '; - position: 1.5 / 5; - add: #factoryDroplist; - yourself -] - -{ #category : #specs } -MiModelImporterFromPharo class >> modelNameLayout [ - ^ SpBoxLayout newHorizontal - add: 'Model name: '; - add: #modelNameField; - yourself -] -{ #category : #specs } -MiModelImporterFromPharo class >> packageButtonLayout [ - ^ SpBoxLayout newHorizontal - add: SpNullPresenter new; - add: #packagesButton width: self buttonWidth * 2; - add: SpNullPresenter new; - yourself + ^ SpBoxLayout newVertical ] { #category : #specs } @@ -85,18 +32,61 @@ MiModelImporterFromPharo class >> title [ { #category : #updating } MiModelImporterFromPharo >> addContext: context [ + entitiesToImport add: context. - (MooseImportingContext entityDependencies at: context) - do: [ :dependency | - (self contextCheckBoxes - detect: [ :checkBox | checkBox label = dependency asString ]) - state: true ] + (MooseImportingContext entityDependencies at: context) do: [ + :dependency | + (self contextCheckBoxes detect: [ :checkBox | + checkBox label = dependency asString ]) state: true ] ] { #category : #accessing } MiModelImporterFromPharo >> contextCheckBoxes [ - ^ contextCheckBoxes presenters - reject: [ :pres | pres class == SpNullPresenter ] + + ^ contextCheckBoxes +] + +{ #category : #layout } +MiModelImporterFromPharo >> contextLayout [ + + | contextLayout context | + contextLayout := SpBoxLayout newHorizontal. + + context := MooseImportingContext entityDependencies keys sort: + #yourself ascending. + (context groupsOf: context size // 3 + 1) do: [ :group | + | subLayout | + subLayout := SpBoxLayout newVertical. + group do: [ :c | + | checkBox | + checkBox := SpCheckBoxPresenter new + label: c; + state: true; + whenActivatedDo: [ self addContext: c ]; + whenDeactivatedDo: [ self removeContext: c ]; + yourself. + subLayout add: checkBox. + contextCheckBoxes add: checkBox ]. + contextLayout add: subLayout ]. + ^ contextLayout +] + +{ #category : #layout } +MiModelImporterFromPharo >> defaultLayout [ + + ^ SpBoxLayout newVertical + spacing: 8; + add: self modelNameLayout height: self class buttonHeight; + add: self packageButtonLayout height: self class buttonHeight; + add: self metamodelFactoryLayout height: self class buttonHeight; + add: #mergeCheckBox height: self class labelHeight; + add: #subclassesCheckBox height: self class labelHeight; + add: #typeOfAttributesCheckBox height: self class labelHeight; + add: self importerClassLayout height: self class buttonHeight; + add: self contextLayout; + add: self invocationStrategyLayout + height: self class buttonHeight; + yourself ] { #category : #accessing } @@ -109,12 +99,23 @@ MiModelImporterFromPharo >> importerClass [ ^ importerDroplist selectedItem ] +{ #category : #layout } +MiModelImporterFromPharo >> importerClassLayout [ + ^ SpPanedLayout newHorizontal + add: 'Importer: '; + position: 1.5 / 5; + add: #importerDroplist; + yourself +] + { #category : #initialization } MiModelImporterFromPharo >> initialize [ + packageNames := OrderedCollection new. importingContext := MooseImportingContext new. entitiesToImport := MooseImportingContext entityDependencies keys - asOrderedCollection. + asOrderedCollection. + contextCheckBoxes := OrderedCollection new. super initialize ] @@ -139,27 +140,6 @@ MiModelImporterFromPharo >> initializeConfigurationCheckBoxes [ yourself ] -{ #category : #'initialization - widgets' } -MiModelImporterFromPharo >> initializeContextCheckBoxes [ - contextCheckBoxes := SpDynamicPresentersListBuilder new - modelObjects: - (MooseImportingContext entityDependencies keys - sort: #yourself ascending); - presenter: SpCheckBoxPresenter - configuredAs: [ :checkBox :context | - checkBox - label: context; - state: true ]; - "9 is a magic number so we have 3 columns" - layoutBuilder: (SpDynamicTopToBottomColumnsLayout columns: 9); - build. - self contextCheckBoxes - do: [ :checkBox | - checkBox - whenActivatedDo: [ self addContext: checkBox label asSymbol ]; - whenDeactivatedDo: [ self removeContext: checkBox label asSymbol ] ] -] - { #category : #initialization } MiModelImporterFromPharo >> initializeDialogWindow: aDialog [ aDialog @@ -211,20 +191,55 @@ MiModelImporterFromPharo >> initializePackagesButton [ { #category : #initialization } MiModelImporterFromPharo >> initializePresenters [ + super initializePresenters. + self layout: self defaultLayout. self initializeModelNameField. self initializePackagesButton. self initializeDroplists. self initializeConfigurationCheckBoxes. - self initializeContextCheckBoxes. self initializeInvocationStrategyDroplist ] +{ #category : #layout } +MiModelImporterFromPharo >> invocationStrategyLayout [ + ^ SpBoxLayout newHorizontal + add: 'Invocation candidates computation:'; + add: #invocationStrategyDroplist; + yourself +] + +{ #category : #layout } +MiModelImporterFromPharo >> metamodelFactoryLayout [ + ^ SpPanedLayout newHorizontal + add: 'Metamodel factory: '; + position: 1.5 / 5; + add: #factoryDroplist; + yourself +] + { #category : #accessing } MiModelImporterFromPharo >> modelName [ ^ modelNameField text ] +{ #category : #layout } +MiModelImporterFromPharo >> modelNameLayout [ + ^ SpBoxLayout newHorizontal + add: 'Model name: '; + add: #modelNameField; + yourself +] + +{ #category : #layout } +MiModelImporterFromPharo >> packageButtonLayout [ + ^ SpBoxLayout newHorizontal + add: SpNullPresenter new; + add: #packagesButton width: self class buttonWidth * 2; + add: SpNullPresenter new; + yourself +] + { #category : #accessing } MiModelImporterFromPharo >> packages [ ^ packageNames @@ -237,13 +252,12 @@ MiModelImporterFromPharo >> packages: anObject [ { #category : #updating } MiModelImporterFromPharo >> removeContext: context [ + entitiesToImport remove: context. - (MooseImportingContext entityDependencies - select: [ :values | values includes: context ]) - keysDo: [ :dependency | - (self contextCheckBoxes - detect: [ :checkBox | checkBox label = dependency asString ]) - state: false ] + (MooseImportingContext entityDependencies select: [ :values | + values includes: context ]) keysDo: [ :dependency | + (self contextCheckBoxes detect: [ :checkBox | + checkBox label = dependency asString ]) state: false ] ] { #category : #action } From 81bf6c19360726dd1b5e3bb404a940a3824b9d2c Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Fri, 21 Aug 2020 18:06:09 +0200 Subject: [PATCH 002/372] Midas-Core: Remove references to deprecated SpDynamicPresenter. and changed #toolBar to #toolbar --- src/Midas-Core/MiBusLogsList.class.st | 5 +- src/Midas-Core/MiBusesPopup.class.st | 15 +++-- src/Midas-Core/MiLogBrowser.class.st | 59 +++++++------------- src/Midas-Core/MiMidasItemPresenter.class.st | 23 +++++--- 4 files changed, 44 insertions(+), 58 deletions(-) diff --git a/src/Midas-Core/MiBusLogsList.class.st b/src/Midas-Core/MiBusLogsList.class.st index 527d667ea..4b347d661 100644 --- a/src/Midas-Core/MiBusLogsList.class.st +++ b/src/Midas-Core/MiBusLogsList.class.st @@ -52,7 +52,7 @@ MiBusLogsList >> forBus: aBus [ ] { #category : #initialization } -MiBusLogsList >> initializeClearButtin [ +MiBusLogsList >> initializeClearButton [ clearButton := self newButton label: 'Clear'; iconName: #smallDelete; @@ -74,9 +74,10 @@ MiBusLogsList >> initializeLogsList [ { #category : #initialization } MiBusLogsList >> initializePresenters [ + super initializePresenters. busName := self newLabel. - self initializeClearButtin. + self initializeClearButton. self initializeLogsList ] diff --git a/src/Midas-Core/MiBusesPopup.class.st b/src/Midas-Core/MiBusesPopup.class.st index b0ed30f99..bd304edda 100644 --- a/src/Midas-Core/MiBusesPopup.class.st +++ b/src/Midas-Core/MiBusesPopup.class.st @@ -56,15 +56,14 @@ MiBusesPopup >> followNewBus [ { #category : #initialization } MiBusesPopup >> initializeBusesList [ + busesList := self newTable. - browser isMiBrowser - ifTrue: [ busesList - addColumn: - ((SpCheckBoxTableColumn - evaluated: [ :bus | browser buses includes: bus ]) - onActivation: [ :bus | browser followBus: bus ]; - onDesactivation: [ :bus | browser unfollowBus: bus ]; - width: 20) ]. + browser isMiBrowser ifTrue: [ + busesList addColumn: ((SpCheckBoxTableColumn evaluated: [ :bus | + browser buses includes: bus ]) + onActivation: [ :bus | browser followBus: bus ]; + onDeactivation: [ :bus | browser unfollowBus: bus ]; + width: 20) ]. busesList addColumn: (SpStringTableColumn evaluated: #name); items: self application buses diff --git a/src/Midas-Core/MiLogBrowser.class.st b/src/Midas-Core/MiLogBrowser.class.st index 9cef8ed0d..962a29723 100644 --- a/src/Midas-Core/MiLogBrowser.class.st +++ b/src/Midas-Core/MiLogBrowser.class.st @@ -23,15 +23,6 @@ Class { #category : #'Midas-Core-Logger' } -{ #category : #'world menu' } -MiLogBrowser class >> defaultSpec [ - ^ super defaultSpec - "add: #toolbar - withConstraints: [ :constraints | constraints height: self toolbarHeight ];" - add: #logsLists; - yourself -] - { #category : #'world menu' } MiLogBrowser class >> menuCommandOn: aBuilder [ @@ -111,28 +102,16 @@ MiLogBrowser >> initializeBuses: someBuses [ ] { #category : #initialization } -MiLogBrowser >> initializeLogsList [ - logsLists := self newNullPresenter -] +MiLogBrowser >> initializeToolbar [ -{ #category : #initialization } -MiLogBrowser >> initializePresenters [ - super initializePresenters. - "self initializeToolBar." - self initializeLogsList -] - -{ #category : #initialization } -MiLogBrowser >> initializeToolBar [ - toolbar := self newToolBar - addItem: - (SpToolBarButtonPresenter new - label: 'Clear all'; - icon: (self theme iconNamed: #smallDelete); - help: 'Remove all loggers entries'; - action: [ self cleanAllLoggers ]; - yourself); - yourself + toolbar := self newToolbar + addItem: (SpToolbarButtonPresenter new + label: 'Clear all'; + icon: (self theme iconNamed: #smallDelete); + help: 'Remove all loggers entries'; + action: [ self cleanAllLoggers ]; + yourself); + yourself ] { #category : #accessing } @@ -159,13 +138,15 @@ MiLogBrowser >> update [ { #category : #initialization } MiLogBrowser >> updateLogsList [ - logsLists := SpDynamicPresentersListBuilder new - modelObjects: self buses asOrderedCollection; - presenter: MiBusLogsList - configuredAs: [ :presenter :bus | - presenter - owner: self; - forBus: bus ]; - layoutBuilder: (SpDynamicTopToBottomRowsLayout rows: 1); - build + + logsLists := SpBoxLayout newVertical. + + self buses do: [ :bus | + logsLists add: (MiBusLogsList new + owner: self; + forBus: bus) ]. + + self layout: (self class defaultSpec + add: logsLists; + yourself) ] diff --git a/src/Midas-Core/MiMidasItemPresenter.class.st b/src/Midas-Core/MiMidasItemPresenter.class.st index b4ddd049e..2ab52ce02 100644 --- a/src/Midas-Core/MiMidasItemPresenter.class.st +++ b/src/Midas-Core/MiMidasItemPresenter.class.st @@ -46,16 +46,21 @@ MiMidasItemPresenter >> initializePresenters [ { #category : #initialization } MiMidasItemPresenter >> initializeTable [ + table := self newTable - addColumn: - ((SpCheckBoxTableColumn evaluated: self tableCheckBoxEvaluation) - onActivation: [ :aBusOrBrowser | self activateItem: aBusOrBrowser ]; - onDesactivation: [ :aBusOrBrowser | self deactivateItem: aBusOrBrowser ]; - width: 20; - yourself); - addColumn: (SpStringTableColumn evaluated: self tableStringEvaluation); - items: self tableItems; - yourself + addColumn: + ((SpCheckBoxTableColumn evaluated: + self tableCheckBoxEvaluation) + onActivation: [ :aBusOrBrowser | + self activateItem: aBusOrBrowser ]; + onDeactivation: [ :aBusOrBrowser | + self deactivateItem: aBusOrBrowser ]; + width: 20; + yourself); + addColumn: + (SpStringTableColumn evaluated: self tableStringEvaluation); + items: self tableItems; + yourself ] { #category : #'accessing model' } From a267a22dc0925b931f292a162ebbfdd3b63041c3 Mon Sep 17 00:00:00 2001 From: ClotildeToullec Date: Fri, 21 Aug 2020 18:07:21 +0200 Subject: [PATCH 003/372] FamixQueries: Removed references to deprecated SpDynamixPresenter. Had to change tests accordingly. --- .../MiComparativeQueryPresenterTest.class.st | 62 +++++-- .../MiNavigationQueriesPresenterTest.class.st | 159 ++++++++--------- .../MiNavigationQueryPresenter.extension.st | 11 ++ .../MiPropertyQueryPresenter.extension.st | 12 +- .../MiPropertyQueryPresenterTest.class.st | 67 +++---- ...MiQueriesCombinationPresenter.extension.st | 4 +- ...MiQueriesCombinationPresenterTest.class.st | 19 +- ...MiQueryConfigurationPresenter.extension.st | 11 -- ...MiQueryConfigurationPresenterTest.class.st | 43 +++-- .../MiQueryCreationPresenter.extension.st | 4 +- .../MiQueryCreationPresenterTest.class.st | 17 +- .../MiScopeQueriesPresenterTest.class.st | 165 +++++++++--------- .../MiScopeQueryPresenter.extension.st | 13 ++ .../MiTypeQueriesPresenterTest.class.st | 135 +++++++------- .../MiTypeQueryPresenter.extension.st | 6 + .../MiBooleanQueryPresenter.class.st | 11 +- .../MiNavigationQueryPresenter.class.st | 153 +++++++++------- .../MiNumericQueryPresenter.class.st | 53 +++--- .../MiPropertyQueryPresenter.class.st | 29 ++- .../MiQueriesBrowser.class.st | 19 +- .../MiQueriesCombinationPresenter.class.st | 14 +- .../MiQueryConfigurationPresenter.class.st | 30 ++-- .../MiQueryCreationPresenter.class.st | 17 +- .../MiScopeQueryPresenter.class.st | 110 +++++++----- .../MiStringQueryPresenter.class.st | 53 +++--- .../MiTypeQueryPresenter.class.st | 121 +++++++------ 26 files changed, 722 insertions(+), 616 deletions(-) create mode 100644 src/Midas-FamixQueries-Tests/MiNavigationQueryPresenter.extension.st delete mode 100644 src/Midas-FamixQueries-Tests/MiQueryConfigurationPresenter.extension.st create mode 100644 src/Midas-FamixQueries-Tests/MiScopeQueryPresenter.extension.st create mode 100644 src/Midas-FamixQueries-Tests/MiTypeQueryPresenter.extension.st diff --git a/src/Midas-FamixQueries-Tests/MiComparativeQueryPresenterTest.class.st b/src/Midas-FamixQueries-Tests/MiComparativeQueryPresenterTest.class.st index 0f65510df..08ae855bd 100644 --- a/src/Midas-FamixQueries-Tests/MiComparativeQueryPresenterTest.class.st +++ b/src/Midas-FamixQueries-Tests/MiComparativeQueryPresenterTest.class.st @@ -11,57 +11,81 @@ MiComparativeQueryPresenterTest class >> isAbstract [ { #category : #tests } MiComparativeQueryPresenterTest >> assertComparatorsDropList [ + self - assert: presenter comparators class + assert: presenter comparatorDropList class identicalTo: SpDropListPresenter. self - assertCollection: presenter comparators listItems + assertCollection: presenter comparatorDropList listItems hasSameElements: presenter query class comparators ] { #category : #tests } -MiComparativeQueryPresenterTest >> assertValueInput [ +MiComparativeQueryPresenterTest >> assertValueInputField [ + self - assert: presenter valueInput class + assert: presenter valueInputField class identicalTo: self valueInputClass ] { #category : #tests } MiComparativeQueryPresenterTest >> testMatchesQuery [ + super testMatchesQuery. - presenter comparators selectIndex: 2. + presenter comparatorDropList selectIndex: 2. self assert: presenter query comparator - equals: presenter comparators selectedItem. - presenter valueInput text: self valueInput. + equals: presenter comparatorDropList selectedItem. + presenter valueInputField text: self valueInput. self assert: presenter query valueToCompare asString - equals: presenter valueInput text + equals: presenter valueInputField text +] + +{ #category : #tests } +MiComparativeQueryPresenterTest >> testPresenters [ + + super testPresenters. + self + assertComparatorsDropList; + assertValueInputField +] + +{ #category : #tests } +MiComparativeQueryPresenterTest >> testPresentersOnImpossibleQuery [ + + super testPresentersOnImpossibleQuery. + + self + assert: presenter comparatorDropList class + identicalTo: SpNullPresenter. + + self + assert: presenter valueInputField class + identicalTo: SpNullPresenter ] { #category : #tests } MiComparativeQueryPresenterTest >> testQueryValidity [ + super testQueryValidity. + self resetPresenterWithEntities: helper classesAndMethods. - presenter comparators selectIndex: 2. + + presenter comparatorDropList selectIndex: 2. self assert: presenter query isValid. - presenter valueInput text: self valueInput. - self assert: presenter query isValid -] -{ #category : #tests } -MiComparativeQueryPresenterTest >> testSecondParameter [ - super testSecondParameter. - self assertComparatorsDropList. - self assertValueInput + presenter valueInputField text: self valueInput. + self assert: presenter query isValid ] { #category : #tests } MiComparativeQueryPresenterTest >> testUpdateCreationBrowser [ + super testUpdateCreationBrowser. - presenter comparators selectIndex: 2. + presenter comparatorDropList selectIndex: 2. self assertCreationPresenterWasUpdated. - presenter valueInput text: self valueInput. + presenter valueInputField text: self valueInput. self assertCreationPresenterWasUpdated ] diff --git a/src/Midas-FamixQueries-Tests/MiNavigationQueriesPresenterTest.class.st b/src/Midas-FamixQueries-Tests/MiNavigationQueriesPresenterTest.class.st index 17de71a13..7980ea273 100644 --- a/src/Midas-FamixQueries-Tests/MiNavigationQueriesPresenterTest.class.st +++ b/src/Midas-FamixQueries-Tests/MiNavigationQueriesPresenterTest.class.st @@ -6,40 +6,39 @@ Class { { #category : #running } MiNavigationQueriesPresenterTest >> assertCheckBoxesMatchAvailableAssociations [ + | availableAssociations | availableAssociations := presenter query availableAssociations. - self assert: self checkBoxes size equals: availableAssociations size. self - assert: (self checkBoxes select: #state) size + assert: presenter associationCheckBoxes size + equals: availableAssociations size. + self + assert: (presenter associationCheckBoxes select: #state) size equals: availableAssociations size. self - assertCollection: - (availableAssociations - collect: [ :assoc | assoc mooseDescription name asString ]) - hasSameElements: (self checkBoxes select: #state thenCollect: #label) + assertCollection: (availableAssociations collect: [ :assoc | + assoc mooseDescription name asString ]) + hasSameElements: + (presenter associationCheckBoxes select: #state thenCollect: #label) ] { #category : #running } MiNavigationQueriesPresenterTest >> assertCheckBoxesMatchQuery [ + self - assertCollection: - (presenter query associations - collect: [ :type | type mooseDescription name asString ]) - hasSameElements: (self checkBoxes select: #state thenCollect: #label). - - (self radioButtons detect: [ :rb | rb state not ]) click. - - self - assertCollection: - (presenter query associations - collect: [ :type | type mooseDescription name asString ]) - hasSameElements: (self checkBoxes select: #state thenCollect: #label) -] + assertCollection: (presenter query associations collect: [ :type | + type mooseDescription name asString ]) + hasSameElements: + (presenter associationCheckBoxes select: #state thenCollect: #label). -{ #category : #accessing } -MiNavigationQueriesPresenterTest >> checkBoxes [ - ^ presenter secondParameter presenters - reject: [ :pres | pres class = SpNullPresenter ] + (presenter directionRadioButtons detect: [ :rb | rb state not ]) + click. + + self + assertCollection: (presenter query associations collect: [ :type | + type mooseDescription name asString ]) + hasSameElements: + (presenter associationCheckBoxes select: #state thenCollect: #label) ] { #category : #running } @@ -52,111 +51,115 @@ MiNavigationQueriesPresenterTest >> queryClass [ ^ FQNavigationQuery ] -{ #category : #accessing } -MiNavigationQueriesPresenterTest >> radioButtons [ - ^ presenter firstParameter presenters - reject: [ :pres | pres class = SpNullPresenter ] -] - { #category : #tests } MiNavigationQueriesPresenterTest >> testCheckBoxesDisabledWhenOnlyOneChecked [ + self resetPresenterWithEntities: helper methods. - (self radioButtons - detect: [ :radioButton | radioButton label = 'Local Incoming' ]) - click. + (presenter directionRadioButtons detect: [ :radioButton | + radioButton label = 'Local Incoming' ]) click. "Only 1 association in the query, cannot be removed, so all checkBoxes are disabled" - self checkBoxes do: [ :cb | self deny: cb isEnabled ]. - self assert: (self checkBoxes select: #state) size equals: 1 + presenter associationCheckBoxes do: [ :cb | self deny: cb isEnabled ]. + self + assert: (presenter associationCheckBoxes select: #state) size + equals: 1 ] { #category : #tests } MiNavigationQueriesPresenterTest >> testCheckBoxesMatchAssociations [ + self assertCheckBoxesMatchAvailableAssociations. self assertCheckBoxesMatchQuery. - (self radioButtons detect: [ :rb | rb state not ]) click. + (presenter directionRadioButtons detect: [ :rb | rb state not ]) + click. self assertCheckBoxesMatchAvailableAssociations. self assertCheckBoxesMatchQuery ] { #category : #tests } -MiNavigationQueriesPresenterTest >> testFirstParameter [ - self assert: - (presenter firstParameter presenters - allSatisfy: [ :pres | pres class == SpRadioButtonPresenter ]). +MiNavigationQueriesPresenterTest >> testPresenters [ + + self assert: (presenter directionRadioButtons allSatisfy: [ :pres | + pres class == SpRadioButtonPresenter ]). + + self assert: (presenter associationCheckBoxes allSatisfy: [ :pres | + pres class == SpCheckBoxPresenter ]) +] + +{ #category : #tests } +MiNavigationQueriesPresenterTest >> testPresentersOnImpossibleQuery [ self resetPresenterWithEntities: helper noEntities. - self assert: - (presenter firstParameter presenters - allSatisfy: [ :pres | pres class == SpRadioButtonPresenter ]) + + self assert: (presenter directionRadioButtons allSatisfy: [ :pres | + pres class == SpRadioButtonPresenter ]). + + self + assert: presenter associationCheckBoxes class + identicalTo: MiNoPossibleQueryPresenter ] { #category : #tests } MiNavigationQueriesPresenterTest >> testQueryValidity [ + self assert: presenter query isValid. - - (self radioButtons detect: [ :rb | rb state not ]) click. + + (presenter directionRadioButtons detect: [ :rb | rb state not ]) + click. self assert: presenter query isValid. - - self checkBoxes first click. + + presenter associationCheckBoxes first click. self assert: presenter query isValid. - self checkBoxes first click. + presenter associationCheckBoxes first click. self assert: presenter query isValid. - - self resetPresenterWithEntities: helper entitiesWithNoIncomingAssociations. + + self resetPresenterWithEntities: + helper entitiesWithNoIncomingAssociations. self deny: presenter query isValid. - + self resetPresenterWithEntities: helper noEntities. - self deny: presenter query isValid. + self deny: presenter query isValid ] { #category : #tests } MiNavigationQueriesPresenterTest >> testRadioButtonsMatchAvailableDirections [ + | directions | directions := presenter query class directionStrategies. - - self assert: self radioButtons size equals: directions size. - + + self + assert: presenter directionRadioButtons size + equals: directions size. + self - assertCollection: (self radioButtons collect: #label) + assertCollection: (presenter directionRadioButtons collect: #label) hasSameElements: (directions collect: #label) ] { #category : #tests } MiNavigationQueriesPresenterTest >> testRadioButtonsMatchQuery [ - self - assert: (self radioButtons detect: #state) label - equals: self currentQuery directionStrategy label. - - (self radioButtons detect: [ :rb | rb state not ]) click. - self - assert: (self radioButtons detect: #state) label - equals: self currentQuery directionStrategy label -] -{ #category : #tests } -MiNavigationQueriesPresenterTest >> testSecondParameter [ - self assert: - (presenter secondParameter presenters - allSatisfy: [ :pres | - pres class == SpCheckBoxPresenter - "Could be some SpNullPresenter depending on the dynamic layout - but it is not the case here" ]). + self + assert: (presenter directionRadioButtons detect: #state) label + equals: presenter query directionStrategy label. - self resetPresenterWithEntities: helper noEntities. + (presenter directionRadioButtons detect: [ :rb | rb state not ]) + click. self - assert: presenter secondParameter class - identicalTo: MiNoPossibleQueryPresenter + assert: (presenter directionRadioButtons detect: #state) label + equals: presenter query directionStrategy label ] { #category : #tests } MiNavigationQueriesPresenterTest >> testUpdateCreationBrowser [ + self assertCreationPresenterWasUpdated. - - (self radioButtons detect: [ :rb | rb state not ]) click. + + (presenter directionRadioButtons detect: [ :rb | rb state not ]) + click. self assertCreationPresenterWasUpdated. - self checkBoxes first click. + presenter associationCheckBoxes first click. self assertCreationPresenterWasUpdated ] diff --git a/src/Midas-FamixQueries-Tests/MiNavigationQueryPresenter.extension.st b/src/Midas-FamixQueries-Tests/MiNavigationQueryPresenter.extension.st new file mode 100644 index 000000000..cc268d51d --- /dev/null +++ b/src/Midas-FamixQueries-Tests/MiNavigationQueryPresenter.extension.st @@ -0,0 +1,11 @@ +Extension { #name : #MiNavigationQueryPresenter } + +{ #category : #'*Midas-FamixQueries-Tests' } +MiNavigationQueryPresenter >> associationCheckBoxes [ + ^ associationCheckBoxes +] + +{ #category : #'*Midas-FamixQueries-Tests' } +MiNavigationQueryPresenter >> directionRadioButtons [ + ^ directionRadioButtons +] diff --git a/src/Midas-FamixQueries-Tests/MiPropertyQueryPresenter.extension.st b/src/Midas-FamixQueries-Tests/MiPropertyQueryPresenter.extension.st index 41cd02354..59db8df24 100644 --- a/src/Midas-FamixQueries-Tests/MiPropertyQueryPresenter.extension.st +++ b/src/Midas-FamixQueries-Tests/MiPropertyQueryPresenter.extension.st @@ -1,16 +1,16 @@ Extension { #name : #MiPropertyQueryPresenter } { #category : #'*Midas-FamixQueries-Tests' } -MiPropertyQueryPresenter >> comparators [ - ^ secondParameter presenterAt: #comparators +MiPropertyQueryPresenter >> comparatorDropList [ + ^ comparatorDropList ] { #category : #'*Midas-FamixQueries-Tests' } -MiPropertyQueryPresenter >> properties [ - ^ secondParameter presenterAt: #properties +MiPropertyQueryPresenter >> propertyDropList [ + ^ propertyDropList ] { #category : #'*Midas-FamixQueries-Tests' } -MiPropertyQueryPresenter >> valueInput [ - ^ secondParameter presenterAt: #valueInput +MiPropertyQueryPresenter >> valueInputField [ + ^ valueInputField ] diff --git a/src/Midas-FamixQueries-Tests/MiPropertyQueryPresenterTest.class.st b/src/Midas-FamixQueries-Tests/MiPropertyQueryPresenterTest.class.st index cd9c760f3..dba149236 100644 --- a/src/Midas-FamixQueries-Tests/MiPropertyQueryPresenterTest.class.st +++ b/src/Midas-FamixQueries-Tests/MiPropertyQueryPresenterTest.class.st @@ -11,15 +11,16 @@ MiPropertyQueryPresenterTest class >> isAbstract [ { #category : #tests } MiPropertyQueryPresenterTest >> assertPropertiesDropList [ + self - assert: presenter properties class + assert: presenter propertyDropList class identicalTo: SpDropListPresenter. self - assertCollection: presenter properties listItems + assertCollection: presenter propertyDropList listItems hasSameElements: presenter query availableProperties. self assert: presenter query property - equals: presenter properties selectedItem + equals: presenter propertyDropList selectedItem ] { #category : #running } @@ -27,69 +28,75 @@ MiPropertyQueryPresenterTest >> queryClass [ ^ self subclassResponsibility ] -{ #category : #tests } -MiPropertyQueryPresenterTest >> testFirstParameter [ - self - assert: presenter firstParameter class - identicalTo: SpNullPresenter. - - self resetPresenterWithEntities: helper noEntities. - self - assert: presenter firstParameter class - identicalTo: SpNullPresenter. -] - { #category : #tests } MiPropertyQueryPresenterTest >> testMatchesQuery [ + self assert: presenter query property - equals: presenter properties selectedItem. - presenter properties selectIndex: 2. + equals: presenter propertyDropList selectedItem. + presenter propertyDropList selectIndex: 2. self assert: presenter query property - equals: presenter properties selectedItem + equals: presenter propertyDropList selectedItem ] { #category : #tests } MiPropertyQueryPresenterTest >> testNoAvailableProperties [ + self resetPresenterWithEntities: helper noEntities. self - assert: presenter secondParameter class + assert: presenter propertyDropList class + identicalTo: MiNoPossibleQueryPresenter +] + +{ #category : #tests } +MiPropertyQueryPresenterTest >> testPresenters [ + + self assertPropertiesDropList +] + +{ #category : #tests } +MiPropertyQueryPresenterTest >> testPresentersOnImpossibleQuery [ + + self resetPresenterWithEntities: helper noEntities. + + self + assert: presenter propertyDropList class identicalTo: MiNoPossibleQueryPresenter ] { #category : #tests } MiPropertyQueryPresenterTest >> testQueryMatchesOwnerQuery [ + self assert: presenter query equals: presenter owner query. - presenter properties selectIndex: 2. + presenter propertyDropList selectIndex: 2. self assert: presenter query equals: presenter owner query ] { #category : #tests } MiPropertyQueryPresenterTest >> testQueryValidity [ - self assert: self currentQuery isValid. - presenter properties selectIndex: 2. - self assert: self currentQuery isValid. + + self assert: presenter query isValid. + + presenter propertyDropList selectIndex: 2. + self assert: presenter query isValid. self resetPresenterWithEntities: helper noEntities. self deny: presenter query isValid ] -{ #category : #tests } -MiPropertyQueryPresenterTest >> testSecondParameter [ - self assertPropertiesDropList. -] - { #category : #tests } MiPropertyQueryPresenterTest >> testUpdateCreationBrowser [ + self assertCreationPresenterWasUpdated. - presenter properties selectIndex: 2. + presenter propertyDropList selectIndex: 2. self assertCreationPresenterWasUpdated ] { #category : #tests } MiPropertyQueryPresenterTest >> testUpdateDoesNotChangeOwnerPresenter [ - presenter properties selectIndex: 2. + + presenter propertyDropList selectIndex: 2. self assert: presenter owner queryConfigurationPresenter identicalTo: presenter diff --git a/src/Midas-FamixQueries-Tests/MiQueriesCombinationPresenter.extension.st b/src/Midas-FamixQueries-Tests/MiQueriesCombinationPresenter.extension.st index 9d69047cf..b71004ad0 100644 --- a/src/Midas-FamixQueries-Tests/MiQueriesCombinationPresenter.extension.st +++ b/src/Midas-FamixQueries-Tests/MiQueriesCombinationPresenter.extension.st @@ -26,6 +26,6 @@ MiQueriesCombinationPresenter >> resultList [ ] { #category : #'*Midas-FamixQueries-Tests' } -MiQueriesCombinationPresenter >> toolBar [ - ^ toolBar +MiQueriesCombinationPresenter >> toolbar [ + ^ toolbar ] diff --git a/src/Midas-FamixQueries-Tests/MiQueriesCombinationPresenterTest.class.st b/src/Midas-FamixQueries-Tests/MiQueriesCombinationPresenterTest.class.st index d5fca5008..32f4c6dcc 100644 --- a/src/Midas-FamixQueries-Tests/MiQueriesCombinationPresenterTest.class.st +++ b/src/Midas-FamixQueries-Tests/MiQueriesCombinationPresenterTest.class.st @@ -51,19 +51,20 @@ MiQueriesCombinationPresenterTest >> tearDown [ { #category : #tests } MiQueriesCombinationPresenterTest >> testBasicInitialization [ + self assertCollection: presenter combinationsDroplist listItems - hasSameElements: - {FQUnionQuery. - FQIntersectionQuery. - FQSubstractionQuery}. + hasSameElements: { + FQUnionQuery. + FQIntersectionQuery. + FQSubstractionQuery }. self assertCollection: presenter resultList items - hasSameElements: #(). - self assert: presenter toolBar class identicalTo: SpToolBarPresenter. + hasSameElements: #( ). + self assert: presenter toolbar class identicalTo: SpToolbarPresenter. self - assert: presenter toolBar presenters first class - identicalTo: SpToolBarButtonPresenter + assert: presenter toolbar presenters first class + identicalTo: SpToolbarButtonPresenter ] { #category : #tests } @@ -144,7 +145,7 @@ MiQueriesCombinationPresenterTest >> testToolBarAction [ | initialQueriesSize | self openInstance. initialQueriesSize := presenter browser queries size. - presenter toolBar presenters first click. + presenter toolbar presenters first click. self assert: presenter browser queries size equals: initialQueriesSize + 1. diff --git a/src/Midas-FamixQueries-Tests/MiQueryConfigurationPresenter.extension.st b/src/Midas-FamixQueries-Tests/MiQueryConfigurationPresenter.extension.st deleted file mode 100644 index 4e9cc1c91..000000000 --- a/src/Midas-FamixQueries-Tests/MiQueryConfigurationPresenter.extension.st +++ /dev/null @@ -1,11 +0,0 @@ -Extension { #name : #MiQueryConfigurationPresenter } - -{ #category : #'*Midas-FamixQueries-Tests' } -MiQueryConfigurationPresenter >> firstParameter [ - ^ firstParameter -] - -{ #category : #'*Midas-FamixQueries-Tests' } -MiQueryConfigurationPresenter >> secondParameter [ - ^ secondParameter -] diff --git a/src/Midas-FamixQueries-Tests/MiQueryConfigurationPresenterTest.class.st b/src/Midas-FamixQueries-Tests/MiQueryConfigurationPresenterTest.class.st index 5c3bdb216..a24c5464b 100644 --- a/src/Midas-FamixQueries-Tests/MiQueryConfigurationPresenterTest.class.st +++ b/src/Midas-FamixQueries-Tests/MiQueryConfigurationPresenterTest.class.st @@ -29,11 +29,6 @@ MiQueryConfigurationPresenterTest >> classToTest [ ^ self subclassResponsibility ] -{ #category : #accessing } -MiQueryConfigurationPresenterTest >> currentQuery [ - ^ presenter query -] - { #category : #running } MiQueryConfigurationPresenterTest >> queryClass [ ^ self subclassResponsibility @@ -41,33 +36,29 @@ MiQueryConfigurationPresenterTest >> queryClass [ { #category : #running } MiQueryConfigurationPresenterTest >> resetPresenterWithEntities: aMooseGroup [ + | superPresenter | - superPresenter := MiQueryCreationPresenter - on: - (MiQueriesBrowser - on: - (FQRootQuery new - result: aMooseGroup; - yourself)). + superPresenter := MiQueryCreationPresenter on: + (MiQueriesBrowser on: (FQRootQuery new + result: aMooseGroup; + yourself)). + superPresenter queryTypesDropList selectItem: self queryClass. - presenter := superPresenter presenters - detect: [ :pres | pres class == self classToTest ] + presenter := superPresenter presenters detect: [ :pres | + pres class == self classToTest ] ] { #category : #running } MiQueryConfigurationPresenterTest >> setUp [ + super setUp. helper := FQTestsHelper current. self resetPresenterWithEntities: helper classesAndMethods ] -{ #category : #tests } -MiQueryConfigurationPresenterTest >> testFirstParameter [ - ^ self subclassResponsibility -] - { #category : #tests } MiQueryConfigurationPresenterTest >> testImpossibleQueryInitialization [ + self resetPresenterWithEntities: helper noEntities. self assert: presenter query class identicalTo: self queryClass. self deny: presenter query isValid @@ -80,12 +71,20 @@ MiQueryConfigurationPresenterTest >> testNormalQueryInitialization [ ] { #category : #tests } -MiQueryConfigurationPresenterTest >> testQueryValidity [ - ^ self subclassResponsibility +MiQueryConfigurationPresenterTest >> testPresenters [ + + self subclassResponsibility ] { #category : #tests } -MiQueryConfigurationPresenterTest >> testSecondParameter [ +MiQueryConfigurationPresenterTest >> testPresentersOnImpossibleQuery [ + + self subclassResponsibility +] + +{ #category : #tests } +MiQueryConfigurationPresenterTest >> testQueryValidity [ + ^ self subclassResponsibility ] diff --git a/src/Midas-FamixQueries-Tests/MiQueryCreationPresenter.extension.st b/src/Midas-FamixQueries-Tests/MiQueryCreationPresenter.extension.st index df369d912..a3de79903 100644 --- a/src/Midas-FamixQueries-Tests/MiQueryCreationPresenter.extension.st +++ b/src/Midas-FamixQueries-Tests/MiQueryCreationPresenter.extension.st @@ -31,6 +31,6 @@ MiQueryCreationPresenter >> resultList [ ] { #category : #'*Midas-FamixQueries-Tests' } -MiQueryCreationPresenter >> toolBar [ - ^ toolBar +MiQueryCreationPresenter >> toolbar [ + ^ toolbar ] diff --git a/src/Midas-FamixQueries-Tests/MiQueryCreationPresenterTest.class.st b/src/Midas-FamixQueries-Tests/MiQueryCreationPresenterTest.class.st index ce3578e72..b37459592 100644 --- a/src/Midas-FamixQueries-Tests/MiQueryCreationPresenterTest.class.st +++ b/src/Midas-FamixQueries-Tests/MiQueryCreationPresenterTest.class.st @@ -64,7 +64,7 @@ MiQueryCreationPresenterTest >> testCreateOnlyOneChild [ self changeQueryType. self assert: presenter browser initialQuery children isEmpty. - presenter toolBar presenters first click. + presenter toolbar presenters first click. self assert: presenter browser initialQuery children size equals: 1. self @@ -82,7 +82,7 @@ MiQueryCreationPresenterTest >> testDisabledToolBarButton [ result: helper noEntities; yourself)). self openInstance. - self deny: presenter toolBar presenters first isEnabled + self deny: presenter toolbar presenters first isEnabled ] { #category : #tests } @@ -141,16 +141,17 @@ MiQueryCreationPresenterTest >> testResultList [ { #category : #tests } MiQueryCreationPresenterTest >> testToolBar [ + | initialQueriesSize | self openInstance. - self assert: presenter toolBar class identicalTo: SpToolBarPresenter. + self assert: presenter toolbar class identicalTo: SpToolbarPresenter. self - assert: presenter toolBar presenters first class - identicalTo: SpToolBarButtonPresenter. - self assert: presenter toolBar presenters first isEnabled. + assert: presenter toolbar presenters first class + identicalTo: SpToolbarButtonPresenter. + self assert: presenter toolbar presenters first isEnabled. initialQueriesSize := presenter browser queries size. - - presenter toolBar presenters first click. + + presenter toolbar presenters first click. self assert: presenter browser queries size equals: initialQueriesSize + 1. diff --git a/src/Midas-FamixQueries-Tests/MiScopeQueriesPresenterTest.class.st b/src/Midas-FamixQueries-Tests/MiScopeQueriesPresenterTest.class.st index 8e75c77bb..10d86ed4f 100644 --- a/src/Midas-FamixQueries-Tests/MiScopeQueriesPresenterTest.class.st +++ b/src/Midas-FamixQueries-Tests/MiScopeQueriesPresenterTest.class.st @@ -9,30 +9,20 @@ MiScopeQueriesPresenterTest >> classToTest [ ^ MiScopeQueryPresenter ] -{ #category : #running } -MiScopeQueriesPresenterTest >> dropList [ - ^ presenter secondParameter -] - { #category : #running } MiScopeQueriesPresenterTest >> queryClass [ ^ FQScopeQuery ] -{ #category : #accessing } -MiScopeQueriesPresenterTest >> radioButtons [ - ^ presenter firstParameter presenters - reject: [ :pres | pres class = SpNullPresenter ] -] - { #category : #tests } MiScopeQueriesPresenterTest >> testChangingDirectionChangesAvailableScopes [ + | initialScopes | initialScopes := presenter query availableScopes copy. - - (self radioButtons - detect: [ :radioButton | radioButton state not ]) click. - + + (presenter directionRadioButtons detect: [ :radioButton | + radioButton state not ]) click. + self denyCollection: initialScopes hasSameElements: presenter query availableScopes @@ -40,19 +30,24 @@ MiScopeQueriesPresenterTest >> testChangingDirectionChangesAvailableScopes [ { #category : #tests } MiScopeQueriesPresenterTest >> testDropListMatchesAvailableScopes [ + | scopes | scopes := presenter query availableScopes. - - self assert: self dropList listItems size equals: scopes size. - - self assertCollection: scopes hasSameElements: self dropList listItems . + + self + assert: presenter scopesDropList listItems size + equals: scopes size. + + self + assertCollection: scopes + hasSameElements: presenter scopesDropList listItems ] { #category : #tests } MiScopeQueriesPresenterTest >> testDropListMatchesForOtherDirection [ - (self radioButtons - detect: [ :radioButton | radioButton state not ]) click. + (presenter directionRadioButtons detect: [ :radioButton | + radioButton state not ]) click. self testDropListMatchesAvailableScopes. self testDropListMatchesQuery @@ -60,107 +55,119 @@ MiScopeQueriesPresenterTest >> testDropListMatchesForOtherDirection [ { #category : #tests } MiScopeQueriesPresenterTest >> testDropListMatchesQuery [ + self - assert: self dropList selectedItem - equals: self currentQuery scope. - - self dropList selectItem: - (presenter query availableScopes - detect: [ :scope | self currentQuery scope ~~ scope ]). + assert: presenter scopesDropList selectedItem + equals: presenter query scope. + + presenter scopesDropList selectItem: + (presenter query availableScopes detect: [ :scope | + presenter query scope ~~ scope ]). self - assert: self dropList selectedItem - equals: self currentQuery scope + assert: presenter scopesDropList selectedItem + equals: presenter query scope ] { #category : #tests } -MiScopeQueriesPresenterTest >> testFirstParameter [ - self assert: - (presenter firstParameter presenters - allSatisfy: [ :pres | pres class == SpRadioButtonPresenter ]). +MiScopeQueriesPresenterTest >> testNoScopesForADirection [ - self resetPresenterWithEntities: helper noEntities. - self assert: - (presenter firstParameter presenters - allSatisfy: [ :pres | pres class == SpRadioButtonPresenter ]) + self resetPresenterWithEntities: helper entitiesWithNoDownScope. + + (presenter directionRadioButtons detect: [ :radioButton | + radioButton label = 'Down' ]) click. + + self + assert: presenter scopesDropList class + identicalTo: MiNoPossibleQueryPresenter ] { #category : #tests } -MiScopeQueriesPresenterTest >> testNoScopesForADirection [ - self resetPresenterWithEntities: helper entitiesWithNoDownScope. - - (presenter firstParameter presenters - detect: [ :radioButton | radioButton label = 'Down' ]) click. - +MiScopeQueriesPresenterTest >> testPresenters [ + + self assert: (presenter directionRadioButtons allSatisfy: [ :pres | + pres class == SpRadioButtonPresenter ]). + self - assert: presenter secondParameter class + assert: presenter scopesDropList class + identicalTo: SpDropListPresenter +] + +{ #category : #tests } +MiScopeQueriesPresenterTest >> testPresentersOnImpossibleQuery [ + + self resetPresenterWithEntities: helper noEntities. + + self assert: (presenter directionRadioButtons allSatisfy: [ :pres | + pres class == SpRadioButtonPresenter ]). + + self + assert: presenter scopesDropList class identicalTo: MiNoPossibleQueryPresenter ] { #category : #tests } MiScopeQueriesPresenterTest >> testQueryValidity [ + self assert: presenter query isValid. - - (self radioButtons detect: [ :rb | rb state not ]) click. + + (presenter directionRadioButtons detect: [ :rb | rb state not ]) + click. self assert: presenter query isValid. - - self dropList selectItem: (self dropList listItems copyWithout: self dropList selectedItem) anyOne. + + presenter scopesDropList selectItem: + (presenter scopesDropList listItems copyWithout: + presenter scopesDropList selectedItem) anyOne. self assert: presenter query isValid. - + self resetPresenterWithEntities: helper entitiesWithNoDownScope. - (presenter firstParameter presenters - detect: [ :radioButton | radioButton label = 'Down' ]) click. + (presenter directionRadioButtons detect: [ :radioButton | + radioButton label = 'Down' ]) click. self deny: presenter query isValid. - + self resetPresenterWithEntities: helper noEntities. self deny: presenter query isValid ] { #category : #tests } MiScopeQueriesPresenterTest >> testRadioButtonsMatchAvailableDirections [ + | directions | directions := presenter query directionStrategies. - self assert: self radioButtons size equals: directions size. - + self + assert: presenter directionRadioButtons size + equals: directions size. + self assertCollection: (directions collect: #label) - hasSameElements: (self radioButtons collect: #label) + hasSameElements: (presenter directionRadioButtons collect: #label) ] { #category : #tests } MiScopeQueriesPresenterTest >> testRadioButtonsMatchQuery [ - self - assert: (self radioButtons detect: #state) label - equals: self currentQuery directionStrategy label. - - (self radioButtons detect: [ :rb | rb state not ]) click. - self - assert: (self radioButtons detect: #state) label - equals: self currentQuery directionStrategy label -] -{ #category : #tests } -MiScopeQueriesPresenterTest >> testSecondParameter [ self - assert: presenter secondParameter class - identicalTo: SpDropListPresenter. - - self resetPresenterWithEntities: helper noEntities. + assert: (presenter directionRadioButtons detect: #state) label + equals: presenter query directionStrategy label. + + (presenter directionRadioButtons detect: [ :rb | rb state not ]) + click. self - assert: presenter secondParameter class - identicalTo: MiNoPossibleQueryPresenter + assert: (presenter directionRadioButtons detect: #state) label + equals: presenter query directionStrategy label ] { #category : #tests } MiScopeQueriesPresenterTest >> testUpdateCreationBrowser [ + self assertCreationPresenterWasUpdated. - - (self radioButtons detect: [ :rb | rb state not ]) click. + + (presenter directionRadioButtons detect: [ :rb | rb state not ]) + click. self assertCreationPresenterWasUpdated. - - self dropList - selectItem: - (presenter query availableScopes - detect: [ :scope | self currentQuery scope ~~ scope ]). + + presenter scopesDropList selectItem: + (presenter query availableScopes detect: [ :scope | + presenter query scope ~~ scope ]). self assertCreationPresenterWasUpdated ] diff --git a/src/Midas-FamixQueries-Tests/MiScopeQueryPresenter.extension.st b/src/Midas-FamixQueries-Tests/MiScopeQueryPresenter.extension.st new file mode 100644 index 000000000..43d0a3bb5 --- /dev/null +++ b/src/Midas-FamixQueries-Tests/MiScopeQueryPresenter.extension.st @@ -0,0 +1,13 @@ +Extension { #name : #MiScopeQueryPresenter } + +{ #category : #'*Midas-FamixQueries-Tests' } +MiScopeQueryPresenter >> directionRadioButtons [ + + ^ directionRadioButtons +] + +{ #category : #'*Midas-FamixQueries-Tests' } +MiScopeQueryPresenter >> scopesDropList [ + + ^ scopesDropList +] diff --git a/src/Midas-FamixQueries-Tests/MiTypeQueriesPresenterTest.class.st b/src/Midas-FamixQueries-Tests/MiTypeQueriesPresenterTest.class.st index 35f79e3de..bc9945ae9 100644 --- a/src/Midas-FamixQueries-Tests/MiTypeQueriesPresenterTest.class.st +++ b/src/Midas-FamixQueries-Tests/MiTypeQueriesPresenterTest.class.st @@ -4,12 +4,6 @@ Class { #category : #'Midas-FamixQueries-Tests-QueriesConfiguration' } -{ #category : #accessing } -MiTypeQueriesPresenterTest >> checkBoxes [ - ^ presenter secondParameter presenters - reject: [ :pres | pres class = SpNullPresenter ] -] - { #category : #running } MiTypeQueriesPresenterTest >> classToTest [ ^ MiTypeQueryPresenter @@ -22,118 +16,115 @@ MiTypeQueriesPresenterTest >> queryClass [ { #category : #tests } MiTypeQueriesPresenterTest >> testCheckBoxesChangeQueryTypes [ + | initialSize | - initialSize := self currentQuery types size. - - self checkBoxes first click. - self assert: self currentQuery types size equals: initialSize - 1. - - self checkBoxes first click. - self assert: self currentQuery types size equals: initialSize + initialSize := presenter query types size. + + presenter typeCheckBoxes first click. + self assert: presenter query types size equals: initialSize - 1. + + presenter typeCheckBoxes first click. + self assert: presenter query types size equals: initialSize ] { #category : #tests } MiTypeQueriesPresenterTest >> testCheckBoxesDisabledWhenOnlyOneChecked [ + self resetPresenterWithEntities: helper modelExample allModelClasses. "Only 1 type in the query, cannot be removed, so the checkBox is disabled" - self deny: self checkBoxes first isEnabled. - self assert: self checkBoxes first state + self deny: presenter typeCheckBoxes first isEnabled. + self assert: presenter typeCheckBoxes first state ] { #category : #tests } MiTypeQueriesPresenterTest >> testCheckBoxesMatchAvailableTypes [ + | types | types := presenter query availableTypes. - self assert: self checkBoxes size equals: types size. + self assert: presenter typeCheckBoxes size equals: types size. self - assertCollection: - (types - collect: [ :type | type name asEnglishPlural withoutPrefix: 'FamixSt' ]) - hasSameElements: (self checkBoxes collect: #label) + assertCollection: (types collect: [ :type | + type name asEnglishPlural withoutPrefix: 'FamixSt' ]) + hasSameElements: (presenter typeCheckBoxes collect: #label) ] { #category : #tests } MiTypeQueriesPresenterTest >> testCheckBoxesMatchQuery [ + | currentQueryTypes | - - self checkBoxes first click. - - currentQueryTypes := self currentQuery types - collect: [ :type | type name asEnglishPlural withoutPrefix: 'FamixSt' ]. - + presenter typeCheckBoxes first click. + + currentQueryTypes := presenter query types collect: [ :type | + type name asEnglishPlural withoutPrefix: + 'FamixSt' ]. + self assertCollection: currentQueryTypes - hasSameElements: (self checkBoxes select: #state thenCollect: #label). - + hasSameElements: + (presenter typeCheckBoxes select: #state thenCollect: #label). + self denyCollection: currentQueryTypes - hasSameElements: (self checkBoxes reject: #state thenCollect: #label) + hasSameElements: + (presenter typeCheckBoxes reject: #state thenCollect: #label) ] { #category : #tests } -MiTypeQueriesPresenterTest >> testFirstParameter [ - self - assert: presenter firstParameter class - identicalTo: SpNullPresenter. - - self resetPresenterWithEntities: helper noEntities. - self - assert: presenter firstParameter class - identicalTo: SpNullPresenter. -] +MiTypeQueriesPresenterTest >> testLastCheckBoxeDisabled [ + + presenter typeCheckBoxes first click. + self assert: presenter typeCheckBoxes first isEnabled. + self deny: presenter typeCheckBoxes first state. -{ #category : #tests } -MiTypeQueriesPresenterTest >> testLastCheckBoxeDisabled [ - self checkBoxes first click. - self assert: self checkBoxes first isEnabled. - self deny: self checkBoxes first state. - "Only 1 type in the query, cannot be removed, so the checkBox is disabled" - self deny: self checkBoxes second isEnabled. - self assert: self checkBoxes second state. - - self checkBoxes first click. + self deny: presenter typeCheckBoxes second isEnabled. + self assert: presenter typeCheckBoxes second state. + + presenter typeCheckBoxes first click. "Two types in the query, so one of them can be removed. All checkboxes are enabled" - self assert: self checkBoxes first isEnabled. - self assert: self checkBoxes first state. - self assert: self checkBoxes second isEnabled. - self assert: self checkBoxes second state. + self assert: presenter typeCheckBoxes first isEnabled. + self assert: presenter typeCheckBoxes first state. + self assert: presenter typeCheckBoxes second isEnabled. + self assert: presenter typeCheckBoxes second state +] + +{ #category : #tests } +MiTypeQueriesPresenterTest >> testPresenters [ + + self assert: (presenter typeCheckBoxes allSatisfy: [ :pres | + pres class == SpCheckBoxPresenter and: [ pres state ] ]) +] + +{ #category : #tests } +MiTypeQueriesPresenterTest >> testPresentersOnImpossibleQuery [ + + self resetPresenterWithEntities: helper noEntities. + + self + assert: presenter typeCheckBoxes class + identicalTo: MiNoPossibleQueryPresenter ] { #category : #tests } MiTypeQueriesPresenterTest >> testQueryValidity [ + self assert: presenter query isValid. - self checkBoxes first click. + presenter typeCheckBoxes first click. self assert: presenter query isValid. - self checkBoxes first click. + presenter typeCheckBoxes first click. self assert: presenter query isValid. self resetPresenterWithEntities: helper noEntities. self deny: presenter query isValid ] -{ #category : #tests } -MiTypeQueriesPresenterTest >> testSecondParameter [ - self assert: - (presenter secondParameter presenters - allSatisfy: - [ :pres | pres class == SpCheckBoxPresenter - "Could be some SpNullPresenter depending on the dynamic layout - but it is not the case here, since there is only 2 types" - and: [ pres state ] ]). - - self resetPresenterWithEntities: helper noEntities. - self - assert: presenter secondParameter class - identicalTo: MiNoPossibleQueryPresenter -] - { #category : #tests } MiTypeQueriesPresenterTest >> testUpdateCreationBrowser [ + self assertCreationPresenterWasUpdated. - self checkBoxes first click. + presenter typeCheckBoxes first click. self assertCreationPresenterWasUpdated ] diff --git a/src/Midas-FamixQueries-Tests/MiTypeQueryPresenter.extension.st b/src/Midas-FamixQueries-Tests/MiTypeQueryPresenter.extension.st new file mode 100644 index 000000000..b10ef1019 --- /dev/null +++ b/src/Midas-FamixQueries-Tests/MiTypeQueryPresenter.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #MiTypeQueryPresenter } + +{ #category : #'*Midas-FamixQueries-Tests' } +MiTypeQueryPresenter >> typeCheckBoxes [ + ^ typeCheckBoxes +] diff --git a/src/Midas-FamixQueries/MiBooleanQueryPresenter.class.st b/src/Midas-FamixQueries/MiBooleanQueryPresenter.class.st index 47dd274dc..73ac9bff3 100644 --- a/src/Midas-FamixQueries/MiBooleanQueryPresenter.class.st +++ b/src/Midas-FamixQueries/MiBooleanQueryPresenter.class.st @@ -6,10 +6,11 @@ Class { { #category : #specs } MiBooleanQueryPresenter class >> layout [ + ^ SpBoxLayout newVertical - add: #properties - expand: true - fill: true - padding: 50; - yourself + add: #propertyDropList + expand: true + fill: true + padding: 50; + yourself ] diff --git a/src/Midas-FamixQueries/MiNavigationQueryPresenter.class.st b/src/Midas-FamixQueries/MiNavigationQueryPresenter.class.st index 5703cfc35..9f48cef4f 100644 --- a/src/Midas-FamixQueries/MiNavigationQueryPresenter.class.st +++ b/src/Midas-FamixQueries/MiNavigationQueryPresenter.class.st @@ -1,6 +1,10 @@ Class { #name : #MiNavigationQueryPresenter, #superclass : #MiQueryConfigurationPresenter, + #instVars : [ + 'directionRadioButtons', + 'associationCheckBoxes' + ], #category : #'Midas-FamixQueries-QueriesConfiguration' } @@ -9,49 +13,84 @@ MiNavigationQueryPresenter class >> title [ ^ 'Navigation Query' ] +{ #category : #layout } +MiNavigationQueryPresenter >> associationCheckBoxesLayout [ + + | subLayout | + associationCheckBoxes isCollection ifFalse: [ + ^ associationCheckBoxes ]. + + subLayout := SpBoxLayout newVertical. + + associationCheckBoxes do: [ :checkBox | + subLayout add: checkBox height: self class buttonHeight ]. + + ^ subLayout +] + +{ #category : #layout } +MiNavigationQueryPresenter >> buildLayout [ + + self layout: (SpBoxLayout newHorizontal + add: self directionRadioButtonsLayout; + add: self associationCheckBoxesLayout; + yourself) +] + { #category : #'widgets configuration' } -MiNavigationQueryPresenter >> configureCheckBox: checkBox forNavigationAssociation: associationClass [ - self setStateOfCheckBox: checkBox association: associationClass. +MiNavigationQueryPresenter >> checkBoxForNavigationAssociation: associationClass [ + + | checkBox | + checkBox := self newCheckBox. checkBox + state: (self query associations includes: associationClass); + enabled: self query associations size > 1; label: associationClass mooseDescription name asString; whenActivatedDo: [ self query addAssociation: associationClass ]; - whenDeactivatedDo: [ [ self query removeAssociation: associationClass ] + whenDeactivatedDo: [ + [ self query removeAssociation: associationClass ] on: FQCannotRemoveLastNavigationAssociation - do: [ checkBox state: true - "Spec does not allow this to work" ] ]. - checkBox - whenChangedDo: [ self update. - self notifyQueryChanged ] + do: [ + checkBox state: true + "Spec does not allow this to work" ] ]; + whenChangedDo: [ + self update. + self notifyQueryChanged. + self query associations size == 1 + ifTrue: [ associationCheckBoxes select: #state thenDo: #disable ] + ifFalse: [ associationCheckBoxes select: #state thenDo: #enable ] ]. + ^ checkBox ] -{ #category : #'widgets configuration' } -MiNavigationQueryPresenter >> configureRadioButton: radioButton forNavigationDirection: direction [ - radioButton - state: self query directionStrategy == direction; - label: direction label; - whenActivatedDo: [ self query resetAndChangeDirection: direction. - self updateAccordingToDirection. - self notifyQueryChanged ] +{ #category : #layout } +MiNavigationQueryPresenter >> directionRadioButtonsLayout [ + + | subLayout | + subLayout := SpBoxLayout newVertical. + + directionRadioButtons do: [ :radioButton | + subLayout add: radioButton height: self class buttonHeight ]. + + ^ subLayout ] { #category : #initialization } MiNavigationQueryPresenter >> initializeAssociationsCheckBoxes [ - self updateAccordingToDirection + + self setAssociationCheckBoxes ] { #category : #initialization } MiNavigationQueryPresenter >> initializeDirectionRadioButtons [ - firstParameter := SpDynamicPresentersListBuilder new - modelObjects: self query class directionStrategies; - presenter: SpRadioButtonPresenter - configuredAs: [ :radioButton :direction | - self - configureRadioButton: radioButton - forNavigationDirection: direction ]; - layoutBuilder: (SpDynamicTopToBottomRowsLayout rows: 1); - build. - (firstParameter presenters detect: #state) - associatedRadioButtons: firstParameter presenters allButFirst + + | selectedButton | + directionRadioButtons := self query class directionStrategies + collect: [ :direction | + self radioButtonForNavigationDirection: + direction ]. + selectedButton := directionRadioButtons detect: #state. + selectedButton associatedRadioButtons: + (directionRadioButtons copyWithout: selectedButton) ] { #category : #initialization } @@ -61,53 +100,33 @@ MiNavigationQueryPresenter >> initializePresenters [ ] { #category : #'widgets configuration' } -MiNavigationQueryPresenter >> selectCurrentQueryDirection [ - (firstParameter presenters - detect: - [ :radioButton | radioButton label = self query directionStrategy label ]) - state: true -] +MiNavigationQueryPresenter >> radioButtonForNavigationDirection: direction [ -{ #category : #initialization } -MiNavigationQueryPresenter >> setAssociationsCheckBoxesConstraints [ - | checkBoxes | - "Dynamic layout involves NullPresenters, they will not answer to #enable, #disable" - checkBoxes := secondParameter presenters - reject: [ :pres | pres class == SpNullPresenter ]. - - "Disable active checkBoxes when the query has only one association, to forbid removing it." - checkBoxes - do: [ :association | - association - whenChangedDo: [ self query associations size == 1 - ifTrue: [ checkBoxes select: #state thenDo: #disable ] - ifFalse: [ checkBoxes select: #state thenDo: #enable ] ] ] + ^ self newRadioButton + state: self query directionStrategy == direction; + label: direction label; + whenActivatedDo: [ + self query resetAndChangeDirection: direction. + self updateAccordingToDirection. + self notifyQueryChanged ] ] { #category : #'widgets configuration' } -MiNavigationQueryPresenter >> setStateOfCheckBox: checkBox association: associationClass [ - checkBox state: (self query associations includes: associationClass). - checkBox enabled: self query associations size > 1 -] +MiNavigationQueryPresenter >> setAssociationCheckBoxes [ -{ #category : #update } -MiNavigationQueryPresenter >> showAssociationsCheckBoxes [ - secondParameter := SpDynamicPresentersListBuilder new - modelObjects: self query availableAssociations; - presenter: SpCheckBoxPresenter - configuredAs: [ :checkBox :associationTrait | - self - configureCheckBox: checkBox - forNavigationAssociation: associationTrait ]; - layoutBuilder: (SpDynamicLeftToRightRowsLayout rows: 1); - build. - self setAssociationsCheckBoxesConstraints + associationCheckBoxes := self query availableAssociations + ifEmpty: [ + self noParameterMessage: 'association' ] + ifNotEmpty: [ :associations | + associations collect: [ :associationTrait | + self checkBoxForNavigationAssociation: + associationTrait ] ] ] { #category : #update } MiNavigationQueryPresenter >> updateAccordingToDirection [ - self query availableAssociations - ifEmpty: [ secondParameter := self noParameterMessage: 'association' ] - ifNotEmpty: [ self showAssociationsCheckBoxes ]. + + self setAssociationCheckBoxes. + self buildLayout. self update ] diff --git a/src/Midas-FamixQueries/MiNumericQueryPresenter.class.st b/src/Midas-FamixQueries/MiNumericQueryPresenter.class.st index 66d21daf9..396d22df1 100644 --- a/src/Midas-FamixQueries/MiNumericQueryPresenter.class.st +++ b/src/Midas-FamixQueries/MiNumericQueryPresenter.class.st @@ -6,26 +6,40 @@ Class { { #category : #specs } MiNumericQueryPresenter class >> layout [ + | padding | padding := 8. ^ SpBoxLayout newVertical - add: #properties - expand: true - fill: true - padding: padding; - add: #comparators - expand: false - fill: false - padding: padding; - add: #valueInput - expand: true - fill: true - padding: padding; - yourself + add: #propertyDropList + expand: true + fill: true + padding: padding; + add: #comparatorDropList + expand: false + fill: false + padding: padding; + add: #valueInputField + expand: true + fill: true + padding: padding; + yourself ] { #category : #initialization } -MiNumericQueryPresenter >> comparatorsDropList [ +MiNumericQueryPresenter >> initializePresenters [ + + super initializePresenters. + query availableProperties + ifNotEmpty: [ + comparatorDropList := self newComparatorDropList. + valueInputField := self newValueInputField ] + ifEmpty: [ + comparatorDropList := self newNullPresenter. + valueInputField := self newNullPresenter ] +] + +{ #category : #initialization } +MiNumericQueryPresenter >> newComparatorDropList [ ^ self newDropList items: self query class comparators; display: [ :prop | prop asString ]; @@ -36,16 +50,7 @@ MiNumericQueryPresenter >> comparatorsDropList [ ] { #category : #initialization } -MiNumericQueryPresenter >> initializeSecondParameter [ - super initializeSecondParameter. - query availableProperties - ifNotEmpty: [ secondParameter - presenterAt: #comparators put: self comparatorsDropList; - presenterAt: #valueInput put: self valueInputField ] -] - -{ #category : #initialization } -MiNumericQueryPresenter >> valueInputField [ +MiNumericQueryPresenter >> newValueInputField [ ^ self newNumberInput placeholder: 'Your numeric value'; climbRate: 1; diff --git a/src/Midas-FamixQueries/MiPropertyQueryPresenter.class.st b/src/Midas-FamixQueries/MiPropertyQueryPresenter.class.st index b7b579960..ee8828f28 100644 --- a/src/Midas-FamixQueries/MiPropertyQueryPresenter.class.st +++ b/src/Midas-FamixQueries/MiPropertyQueryPresenter.class.st @@ -2,36 +2,29 @@ Class { #name : #MiPropertyQueryPresenter, #superclass : #MiQueryConfigurationPresenter, #instVars : [ - 'properties', - 'comparators', - 'valueInput' + 'propertyDropList', + 'valueInputField', + 'comparatorDropList' ], #category : #'Midas-FamixQueries-QueriesConfiguration' } -{ #category : #specs } -MiPropertyQueryPresenter class >> addFirstParameterToLayout: defaultLayout [ - defaultLayout add: #firstParameter width: 0 +{ #category : #layout } +MiPropertyQueryPresenter >> buildLayout [ + + self layout: self class layout ] { #category : #initialization } MiPropertyQueryPresenter >> initializePresenters [ - firstParameter := self newNullPresenter hide. - self initializeSecondParameter -] -{ #category : #initialization } -MiPropertyQueryPresenter >> initializeSecondParameter [ - secondParameter := query availableProperties - ifEmpty: [ self noParameterMessage: 'property' ] - ifNotEmpty: [ (self instantiate: SpDynamicPresenter) - layout: self class layout; - presenterAt: #properties put: self propertiesDropList; - yourself ] + propertyDropList := query availableProperties + ifEmpty: [ self noParameterMessage: 'property' ] + ifNotEmpty: [ self newPropertyDropList ] ] { #category : #initialization } -MiPropertyQueryPresenter >> propertiesDropList [ +MiPropertyQueryPresenter >> newPropertyDropList [ ^ self newDropList items: self query availableProperties; display: [ :prop | prop asString ]; diff --git a/src/Midas-FamixQueries/MiQueriesBrowser.class.st b/src/Midas-FamixQueries/MiQueriesBrowser.class.st index 64234443e..ca13f3321 100644 --- a/src/Midas-FamixQueries/MiQueriesBrowser.class.st +++ b/src/Midas-FamixQueries/MiQueriesBrowser.class.st @@ -74,18 +74,15 @@ MiQueriesBrowser class >> newModel [ { #category : #'instance creation' } MiQueriesBrowser class >> open [ +