diff --git a/src/MooseIDE-Core/Collection.extension.st b/src/MooseIDE-Core/Collection.extension.st index 23ba96a76..9c292310d 100644 --- a/src/MooseIDE-Core/Collection.extension.st +++ b/src/MooseIDE-Core/Collection.extension.st @@ -1,5 +1,11 @@ Extension { #name : #Collection } +{ #category : #'*MooseIDE-Core' } +Collection >> miInspect [ + + self asMooseGroup miInspect +] + { #category : #'*MooseIDE-Core' } Collection >> miPropagate [ diff --git a/src/MooseIDE-Core/ManifestMooseIDECore.class.st b/src/MooseIDE-Core/ManifestMooseIDECore.class.st new file mode 100644 index 000000000..2c85ed93c --- /dev/null +++ b/src/MooseIDE-Core/ManifestMooseIDECore.class.st @@ -0,0 +1,8 @@ +" +Please describe the package using the class comment of the included manifest class. The manifest class also includes other additional metadata for the package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser +" +Class { + #name : #ManifestMooseIDECore, + #superclass : #PackageManifest, + #category : #'MooseIDE-Core-Manifest' +} diff --git a/src/MooseIDE-Core/MiMooseGroupsTreeTablePresenter.class.st b/src/MooseIDE-Core/MiMooseGroupsTreeTablePresenter.class.st new file mode 100644 index 000000000..3416030d5 --- /dev/null +++ b/src/MooseIDE-Core/MiMooseGroupsTreeTablePresenter.class.st @@ -0,0 +1,192 @@ +" +I am a presenter thas shows the result of the current selected query in a tree presenter. +" +Class { + #name : #MiMooseGroupsTreeTablePresenter, + #superclass : #SpTreeTablePresenter, + #instVars : [ + 'sortedEntitiesCache', + 'headerTitle', + 'childrenSortingBlock', + 'extensionMenuItems', + 'manageNodesFromMenu' + ], + #category : #'MooseIDE-Core-Widgets' +} + +{ #category : #commands } +MiMooseGroupsTreeTablePresenter class >> buildCommandsGroupWith: presenterInstance forRoot: aCmCommandsGroup [ + + aCmCommandsGroup register: + (MiInspectCommand forSpecContext: presenterInstance) +] + +{ #category : #menu } +MiMooseGroupsTreeTablePresenter >> addExtensionMenugroupIn: aContextMenu [ + + extensionMenuItems ifEmpty: [ ^ self ]. + + aContextMenu addGroup: [ :group | + extensionMenuItems do: [ :item | group addItem: item ] ] +] + +{ #category : #api } +MiMooseGroupsTreeTablePresenter >> addMenuItem: aBlockOrMenuItem [ + + extensionMenuItems add: aBlockOrMenuItem +] + +{ #category : #menu } +MiMooseGroupsTreeTablePresenter >> addNodesManagementMenuGroupIn: aContextMenu [ + + manageNodesFromMenu ifFalse: [ ^ self ]. + + aContextMenu addGroup: [ :group | + group + addItem: [ :item | + item + name: 'Collapse all'; + icon: self theme treeUnexpandedForm; + action: [ self collapseAll ] ]; + addItem: [ :item | + item + name: 'Expand all'; + icon: self theme treeExpandedForm; + action: [ self expandAll ] ] ] +] + +{ #category : #testing } +MiMooseGroupsTreeTablePresenter >> canPropagate [ + + ^ true +] + +{ #category : #accessing } +MiMooseGroupsTreeTablePresenter >> childrenSortingBlock [ + + ^ childrenSortingBlock ifNil: [ #displayString ascending ] +] + +{ #category : #accessing } +MiMooseGroupsTreeTablePresenter >> childrenSortingBlock: aBlock [ + + childrenSortingBlock := aBlock +] + +{ #category : #api } +MiMooseGroupsTreeTablePresenter >> displayIcon: aValuable [ + + columns := columns copyWithFirst: (SpImageTableColumn new + evaluated: aValuable; + width: 35; + yourself) +] + +{ #category : #initialization } +MiMooseGroupsTreeTablePresenter >> initialize [ + + super initialize. + + self addColumn: + (SpStringTableColumn evaluated: [ :item | self stringForItem: item ]). + + self initializeChildrenBlock. + self beMultipleSelection. + self initializeContextMenu. + self setDoubleClickInspect. + self hideColumnHeaders. + + self whenRootsChangedDo: [ self resetEntitiesCache ]. + + manageNodesFromMenu := false +] + +{ #category : #initialization } +MiMooseGroupsTreeTablePresenter >> initializeChildrenBlock [ + + self children: [ :item | + (self roots includes: item) + ifTrue: [ + sortedEntitiesCache + at: item + ifAbsentPut: [ item entities sort: self childrenSortingBlock ] ] + ifFalse: [ { } ] ] +] + +{ #category : #initialization } +MiMooseGroupsTreeTablePresenter >> initializeContextMenu [ + + self contextMenu: [ + | menu | + menu := self rootCommandsGroup asMenuPresenter. + self addNodesManagementMenuGroupIn: menu. + self addExtensionMenugroupIn: menu. + menu ]. + + extensionMenuItems := OrderedCollection new +] + +{ #category : #menu } +MiMooseGroupsTreeTablePresenter >> manageNodesFromMenu [ + + manageNodesFromMenu := true +] + +{ #category : #'as yet unclassified' } +MiMooseGroupsTreeTablePresenter >> miInspect [ + + self selectedItem miInspect +] + +{ #category : #'as yet unclassified' } +MiMooseGroupsTreeTablePresenter >> miPropagate [ + + self selectedItem miPropagate +] + +{ #category : #accessing } +MiMooseGroupsTreeTablePresenter >> miSelectedItem [ + + ^ self selectedItem ifNil: [ { } ] +] + +{ #category : #update } +MiMooseGroupsTreeTablePresenter >> resetEntitiesCache [ + + ^ sortedEntitiesCache := IdentityDictionary new +] + +{ #category : #accessing } +MiMooseGroupsTreeTablePresenter >> rootBrowser [ + + ^ owner rootBrowser +] + +{ #category : #initialization } +MiMooseGroupsTreeTablePresenter >> setDoubleClickInspect [ + + self + activateOnDoubleClick; + whenActivatedDo: [ :each | each selectedItem miInspect ] +] + +{ #category : #naming } +MiMooseGroupsTreeTablePresenter >> stringForItem: item [ + + (self roots includes: item) ifTrue: [ ^ item description ]. + + ^ item displayString +] + +{ #category : #update } +MiMooseGroupsTreeTablePresenter >> updateForEntities: entities [ + + | groups | + groups := (entities allEntityTypes collect: [ :type | + entities allWithType: type ]) asOrderedCollection. + + groups do: [ :group | group description: group details ]. + + self roots: + (groups sort: [ :group | group description onlyLetters ] ascending) +] diff --git a/src/MooseIDE-Core/MiPresenter.class.st b/src/MooseIDE-Core/MiPresenter.class.st index f649907aa..5e949ef2c 100644 --- a/src/MooseIDE-Core/MiPresenter.class.st +++ b/src/MooseIDE-Core/MiPresenter.class.st @@ -32,6 +32,12 @@ MiPresenter >> isMiBrowser [ ^ false ] +{ #category : #'scripting - widgets' } +MiPresenter >> newMooseGroupsTreeTable [ + + ^ self instantiate: MiMooseGroupsTreeTablePresenter +] + { #category : #'scripting - widgets' } MiPresenter >> newSelectableListForPopoverExtent: aPoint [ @@ -45,3 +51,11 @@ MiPresenter >> newSelectableListForPopoverExtent: aPoint [ yourself); yourself ] + +{ #category : #accessing } +MiPresenter >> rootBrowser [ + + ^ self isMiBrowser + ifTrue: [ self ] + ifFalse: [ self owner rootBrowser ] +] diff --git a/src/MooseIDE-Core/MooseObject.extension.st b/src/MooseIDE-Core/MooseObject.extension.st index dc4d47f49..41a88659b 100644 --- a/src/MooseIDE-Core/MooseObject.extension.st +++ b/src/MooseIDE-Core/MooseObject.extension.st @@ -12,6 +12,12 @@ MooseObject >> miDescription [ ^ self description ] +{ #category : #'*MooseIDE-Core' } +MooseObject >> miInspect [ + + MiInspectorBrowser inspect: self +] + { #category : #'*MooseIDE-Core' } MooseObject >> miPropagate [ diff --git a/src/MooseIDE-CriticBrowser/FamixCBViolation.extension.st b/src/MooseIDE-CriticBrowser/FamixCBViolation.extension.st new file mode 100644 index 000000000..dab995b9e --- /dev/null +++ b/src/MooseIDE-CriticBrowser/FamixCBViolation.extension.st @@ -0,0 +1,13 @@ +Extension { #name : #FamixCBViolation } + +{ #category : #'*MooseIDE-CriticBrowser' } +FamixCBViolation >> mooseIcon [ + + ^ self iconNamed: self violatedCondition severity iconName +] + +{ #category : #'*MooseIDE-CriticBrowser' } +FamixCBViolation >> severityLevel [ + + ^ self violatedCondition severity level +] diff --git a/src/MooseIDE-CriticBrowser/MiCBExportRulesCommand.class.st b/src/MooseIDE-CriticBrowser/MiCBExportRulesCommand.class.st new file mode 100644 index 000000000..a8a3ae202 --- /dev/null +++ b/src/MooseIDE-CriticBrowser/MiCBExportRulesCommand.class.st @@ -0,0 +1,23 @@ +Class { + #name : #MiCBExportRulesCommand, + #superclass : #MiCommand, + #category : #'MooseIDE-CriticBrowser-Commands' +} + +{ #category : #default } +MiCBExportRulesCommand class >> defaultIconName [ + + ^ #smallSave +] + +{ #category : #default } +MiCBExportRulesCommand class >> defaultName [ + + ^ 'Export rules' +] + +{ #category : #executing } +MiCBExportRulesCommand >> execute [ + + self context exportRules +] diff --git a/src/MooseIDE-CriticBrowser/MiCBImportRulesCommand.class.st b/src/MooseIDE-CriticBrowser/MiCBImportRulesCommand.class.st new file mode 100644 index 000000000..0c5b89b99 --- /dev/null +++ b/src/MooseIDE-CriticBrowser/MiCBImportRulesCommand.class.st @@ -0,0 +1,23 @@ +Class { + #name : #MiCBImportRulesCommand, + #superclass : #MiCommand, + #category : #'MooseIDE-CriticBrowser-Commands' +} + +{ #category : #default } +MiCBImportRulesCommand class >> defaultIconName [ + + ^ #smallOpen +] + +{ #category : #default } +MiCBImportRulesCommand class >> defaultName [ + + ^ 'Import rules' +] + +{ #category : #executing } +MiCBImportRulesCommand >> execute [ + + self context importRules +] diff --git a/src/MooseIDE-CriticBrowser/MiCBRunAllRulesCommand.class.st b/src/MooseIDE-CriticBrowser/MiCBRunAllRulesCommand.class.st new file mode 100644 index 000000000..edd1d1b59 --- /dev/null +++ b/src/MooseIDE-CriticBrowser/MiCBRunAllRulesCommand.class.st @@ -0,0 +1,23 @@ +Class { + #name : #MiCBRunAllRulesCommand, + #superclass : #MiCommand, + #category : #'MooseIDE-CriticBrowser-Commands' +} + +{ #category : #default } +MiCBRunAllRulesCommand class >> defaultIconName [ + + ^ #glamorousPlay +] + +{ #category : #default } +MiCBRunAllRulesCommand class >> defaultName [ + + ^ 'Run' +] + +{ #category : #executing } +MiCBRunAllRulesCommand >> execute [ + + self context runAllRules +] diff --git a/src/MooseIDE-CriticBrowser/MiCriticBrowser.class.st b/src/MooseIDE-CriticBrowser/MiCriticBrowser.class.st index 63158bf2c..22d012426 100644 --- a/src/MooseIDE-CriticBrowser/MiCriticBrowser.class.st +++ b/src/MooseIDE-CriticBrowser/MiCriticBrowser.class.st @@ -15,8 +15,6 @@ Class { 'entitiesList', 'runButton', 'rulesResult', - 'importButton', - 'exportButton', 'addRulesPresenter', 'rulesEditorPresenter', 'rules', @@ -28,8 +26,23 @@ Class { #category : #'MooseIDE-CriticBrowser-Browser' } +{ #category : #keymaps } +MiCriticBrowser class >> browserKey [ + + ^ $c +] + { #category : #commands } -MiCriticBrowser class >> buildRulesCommandsGroupWith: presenterInstance [ +MiCriticBrowser class >> buildActionCommandsGroupWith: presenterInstance [ + + ^ { + (MiCBImportRulesCommand forSpecContext: presenterInstance). + (MiCBExportRulesCommand forSpecContext: presenterInstance). + (MiCBRunAllRulesCommand forSpecContext: presenterInstance) } +] + +{ #category : #commands } +MiCriticBrowser class >> buildRuleCommandsGroupWith: presenterInstance [ ^ MiAbstractCriticBrowserCommand asCommandGroupWith: presenterInstance @@ -77,6 +90,20 @@ MiCriticBrowser class >> windowSize [ ^ 1280 @ 560 ] +{ #category : #layout } +MiCriticBrowser >> actionButtonsLayout [ + + layout := SpBoxLayout newLeftToRight + hAlignEnd; + spacing: 5; + yourself. + + (self class buildActionCommandsGroupWith: self) do: [ :cmd | + layout add: cmd asButtonPresenter ]. + + ^ layout +] + { #category : #'accessing - testing' } MiCriticBrowser >> addContextsPresenter [ "used for testing purposes, do not access outside of tests" @@ -140,36 +167,32 @@ MiCriticBrowser >> contextEditorPresenter [ ] { #category : #layout } -MiCriticBrowser >> defaultLayout [ +MiCriticBrowser >> defaultLayout [ + ^ SpBoxLayout newTopToBottom - add: (SpPanedLayout newLeftToRight - add: (SpBoxLayout new - add: 'Entities' expand: false; - add: entitiesList; - yourself); - add: (SpPanedLayout newLeftToRight - add: (SpBoxLayout new - add: 'Rules' expand: false; - add: rules; - yourself); - add: (SpBoxLayout new - add: ('Entities requested' asPresenter) expand: false; - add: rulesResult; - yourself); - yourself); - yourself); - add: (SpBoxLayout newLeftToRight - add: statusLabel; - add: (SpBoxLayout newLeftToRight - addLast: importButton; - addLast: exportButton; - addLast: runButton; - hAlignEnd; - spacing: 5; - yourself); - vAlignCenter; - yourself) expand: false; - yourself + add: (SpPanedLayout newLeftToRight + add: (SpBoxLayout new + add: 'Entities' expand: false; + add: entitiesList; + yourself); + add: (SpPanedLayout newLeftToRight + add: (SpBoxLayout new + add: 'Rules' expand: false; + add: rules; + yourself); + add: (SpBoxLayout new + add: 'Entities requested' asPresenter expand: false; + add: rulesResult; + yourself); + yourself); + yourself); + add: (SpBoxLayout newLeftToRight + add: statusLabel; + add: self actionButtonsLayout; + vAlignCenter; + yourself) + expand: false; + yourself ] { #category : #accessing } @@ -291,97 +314,48 @@ MiCriticBrowser >> importRulesFromStream: aStream [ { #category : #initialization } MiCriticBrowser >> initialize [ + super initialize. application registerConsumer: addRulesPresenter for: FQAbstractQuery. - application registerConsumer: rulesEditorPresenter for: FQAbstractQuery -] - -{ #category : #initialization } -MiCriticBrowser >> initializeButtons [ - runButton := self newButton. - importButton := self newButton. - exportButton := self newButton. - - runButton - label: 'Run'; - icon: (self iconNamed: #glamorousPlay); - action: [ self runButtonAction ]. - - importButton - label: 'Import rules'; - icon: (self iconNamed: #smallOpen); - action: [ self importRules ]. - - exportButton - label: 'Export rules'; - icon: (self iconNamed: #smallSave); - action: [ self exportRules ] + application + registerConsumer: rulesEditorPresenter + for: FQAbstractQuery ] { #category : #initialization } MiCriticBrowser >> initializeLists [ - entitiesList := self newTree. - rules := self newTree. - rulesResult := self newTree. - - entitiesList - display: [ :each | self stringForItem: each ]; - children: [ :each | self children: each for: entitiesList ]; - activateOnDoubleClick; - whenActivatedDo: [ :each | each selectedItem inspect ]. + entitiesList := self newMooseGroupsTreeTable. + rules := self newTree. rules items: { self model rootContext }; display: [ :each | self displayRule: each ]; - displayIcon: [ :each | + displayIcon: [ :each | each class = FamixCBCondition ifTrue: [ self iconNamed: #radioButtonOn ] ifFalse: [ self iconNamed: #radioButtonSelected ] ]; children: [ :each | self childrenForContext: each ]; - contextMenu: [ - (self class buildRulesCommandsGroupWith: self) asMenuPresenter ]; + contextMenu: [ + (self class buildRuleCommandsGroupWith: self) asMenuPresenter ]; beSingleSelection; - whenSelectionChangedDo: [ + whenSelectionChangedDo: [ specModel violations ifNotEmpty: [ self selectedRules ] ]. - rulesResult - display: [ :each | self stringForItem: each ]; - displayIcon: [ :each | - each class = FamixCBViolation - ifTrue: [ - self iconNamed: each violatedCondition severity iconName ] - ifFalse: [ self iconNamed: 'blank' ] ]; - children: [ :each | self sortedChildren: each for: rulesResult ]; - contextMenu: expandMenu; - activateOnDoubleClick; - whenActivatedDo: [ :each | each selectedItem inspect ] -] - -{ #category : #initialization } -MiCriticBrowser >> initializeMenu [ - - expandMenu := self newMenu. - expandMenu - addItem: [ :item | - item - name: 'Collapse all'; - icon: ((self iconNamed: #windowMenuInactive) rotateBy: -90); - action: [ rulesResult collapseAll ] ]; - addItem: [ :item | - item - name: 'Expand all'; - icon: ((self iconNamed: #windowMenuInactive) rotateBy: 360); - action: [ rulesResult expandAll ] ] + rulesResult := self newMooseGroupsTreeTable + displayIcon: #mooseIcon; + childrenSortingBlock: + #severityLevel descending , #displayString ascending; + manageNodesFromMenu; + yourself ] { #category : #initialization } MiCriticBrowser >> initializePresenters [ super initializePresenters. - self initializeMenu. + self initializeLists. - self initializeButtons. self initializeStatusLabel. addRulesPresenter := MiCBAddRulesPresenter on: self. @@ -403,10 +377,11 @@ MiCriticBrowser >> initializeStatusLabel [ ] { #category : #accessing } -MiCriticBrowser >> miSelectedItem [ - ^ self rules selectedItem - ifNil: [ specModel getAllViolations ] - ifNotNil: [ specModel violationsOf: (self rules selectedItem) ] +MiCriticBrowser >> miSelectedItem [ + + ^ self rules selectedItem + ifNil: [ specModel getAllViolations ] + ifNotNil: [ specModel violationsOf: self rules selectedItem ] ] { #category : #'buttons actions' } @@ -451,7 +426,7 @@ MiCriticBrowser >> openEditRuleDialog [ { #category : #'accessing - testing' } MiCriticBrowser >> rules [ -"used for testing purposes, do not access outside of tests" + ^ rules ] @@ -468,11 +443,13 @@ MiCriticBrowser >> rulesResult [ ] { #category : #'buttons actions' } -MiCriticBrowser >> runButtonAction [ - "executes the queries on the entities stored in the model, then prints the results" +MiCriticBrowser >> runAllRules [ + "Executes the queries on the entities stored in the model, then prints the results" + self model run. - [ self model run. + [ + self model run. self updateStatusLabel: 'Updating display...'. self updateResultList: specModel getAllViolations. self updateRulesList. @@ -510,9 +487,10 @@ MiCriticBrowser >> sortedChildren: each for: aTreePresenter [ { #category : #naming } MiCriticBrowser >> stringForItem: item [ -"returns string to describe an item or a root regrouping entities of the same type" + "returns string to describe an item or a root regrouping entities of the same type" + (rulesResult roots includes: item) ifTrue: [ ^ item description ]. - ^ String streamContents: [ :s | item displayStringOn: s ] + ^ item displayString ] { #category : #initialization } @@ -524,32 +502,36 @@ MiCriticBrowser >> tagRuleResult [ { #category : #'updating screen' } MiCriticBrowser >> updateEntitiesList: aCollection [ + | roots | - roots := (aCollection allEntityTypes collect: [ :type | - aCollection allWithType: type ]) asOrderedCollection. + roots := (aCollection allEntityTypes collect: [ :type | + aCollection allWithType: type ]) asOrderedCollection. roots do: [ :group | group description: group details ]. entitiesList roots: (roots sort: [ :group | group description onlyLetters ] ascending). - + entitiesList roots: roots. - entitiesList refresh. - + entitiesList refresh ] { #category : #'updating screen' } MiCriticBrowser >> updateResultList: aCollection [ + | roots | - aCollection ifNotEmpty: [ - roots := (aCollection allViolatingEntitiesType collect: [ :type | - aCollection allWithViolatingEntitiesType: type ]) asOrderedCollection. - roots do: [ :group | group description: group stringForCBDescription ]. - rulesResult roots: - (roots sort: [ :group | group description onlyLetters ] ascending). - rulesResult refresh. - ] ifEmpty: [ - roots := aCollection. - rulesResult roots: roots - ]. + aCollection + ifNotEmpty: [ + roots := (aCollection allViolatingEntitiesType collect: [ :type | + aCollection allWithViolatingEntitiesType: type ]) + asOrderedCollection. + roots do: [ :group | + group description: group stringForCBDescription ]. + rulesResult roots: + (roots sort: [ :group | group description onlyLetters ] ascending). + rulesResult refresh ] + ifEmpty: [ + roots := aCollection. + rulesResult roots: roots ]. + self updateToolbar. rulesResult expandAll ] diff --git a/src/MooseIDE-CriticBrowser/MiCriticBrowserModel.class.st b/src/MooseIDE-CriticBrowser/MiCriticBrowserModel.class.st index 507d61b89..841dbe5ed 100644 --- a/src/MooseIDE-CriticBrowser/MiCriticBrowserModel.class.st +++ b/src/MooseIDE-CriticBrowser/MiCriticBrowserModel.class.st @@ -131,7 +131,8 @@ MiCriticBrowserModel >> ruleComponents [ { #category : #running } MiCriticBrowserModel >> run [ - rootContext runDownTree: entities withCallback: [ :aName | + + rootContext runDownTree: entities withCallback: [ :aName | self browser updateStatusLabel: 'Running critic ' , aName , '.' ]. violations := rootContext getAllViolations ] diff --git a/src/MooseIDE-Meta/MiShortcutsCategory.extension.st b/src/MooseIDE-Meta/MiShortcutsCategory.extension.st index eb53a8a81..5e9de9fe2 100644 --- a/src/MooseIDE-Meta/MiShortcutsCategory.extension.st +++ b/src/MooseIDE-Meta/MiShortcutsCategory.extension.st @@ -1,5 +1,12 @@ Extension { #name : #MiShortcutsCategory } +{ #category : #'*MooseIDE-Meta' } +MiShortcutsCategory >> openCriticBrowser [ + + + ^ MiCriticBrowser openKeyMap +] + { #category : #'*MooseIDE-Meta' } MiShortcutsCategory >> openModelRootBrowser [ diff --git a/src/MooseIDE-QueriesBrowser-Tests/MiQueriesBrowserTest.class.st b/src/MooseIDE-QueriesBrowser-Tests/MiQueriesBrowserTest.class.st index 2392f1d25..2eeb4a7d2 100644 --- a/src/MooseIDE-QueriesBrowser-Tests/MiQueriesBrowserTest.class.st +++ b/src/MooseIDE-QueriesBrowser-Tests/MiQueriesBrowserTest.class.st @@ -16,6 +16,15 @@ MiQueriesBrowserTest >> browserClass [ ^ MiQueriesBrowser ] +{ #category : #tests } +MiQueriesBrowserTest >> queryResultTreeItems [ + + | resultTree | + resultTree := browser queryResultTreePresenter. + ^ resultTree roots flatCollect: [ :root | + resultTree childrenFor: root ] +] + { #category : #running } MiQueriesBrowserTest >> setUp [ @@ -35,7 +44,7 @@ MiQueriesBrowserTest >> testAddNewNAryQuery [ self assert: (browser rootQuery children includes: unionQuery). self assert: browser selectedQuery equals: unionQuery. self - assertCollection: browser queryResultTreePresenter items + assertCollection: self queryResultTreeItems hasSameElements: unionQuery result ] @@ -93,7 +102,7 @@ MiQueriesBrowserTest >> testInitializePresenters [ self assert: browser queryCodePresenter text isNotEmpty. self assert: browser queryResultTreePresenter class - equals: QueryResultTreePresenter. + equals: MiMooseGroupsTreeTablePresenter. self assertCollection: browser queryResultEntities hasSameElements: helper classesAndMethods @@ -129,7 +138,7 @@ MiQueriesBrowserTest >> testRemoveQuery [ self deny: (browser rootQuery children includes: query). self deny: (browser rootQuery children includes: query2). self - assertCollection: browser queryResultTreePresenter items + assertCollection: self queryResultTreeItems hasSameElements: browser queryResultEntities ] @@ -137,7 +146,6 @@ MiQueriesBrowserTest >> testRemoveQuery [ MiQueriesBrowserTest >> testSelectQuery [ | query previousCurrentQuery newQuery | - query := (FQBooleanQuery property: #isDead) beChildOf: browser rootQuery. previousCurrentQuery := browser selectedQuery. @@ -145,7 +153,7 @@ MiQueriesBrowserTest >> testSelectQuery [ self deny: previousCurrentQuery equals: browser selectedQuery. self assert: browser selectedQuery equals: query. self - assertCollection: browser queryResultTreePresenter items + assertCollection: self queryResultTreeItems hasSameElements: query result. "Check if the code presenter changed its text to the new query" diff --git a/src/MooseIDE-QueriesBrowser/MiQueriesBrowser.class.st b/src/MooseIDE-QueriesBrowser/MiQueriesBrowser.class.st index 3f7257471..cc3275105 100644 --- a/src/MooseIDE-QueriesBrowser/MiQueriesBrowser.class.st +++ b/src/MooseIDE-QueriesBrowser/MiQueriesBrowser.class.st @@ -187,8 +187,8 @@ MiQueriesBrowser >> initializeQueryCodePresenter [ { #category : #initialization } MiQueriesBrowser >> initializeResultTreePresenter [ - queryResultTreePresenter := self instantiate: - QueryResultTreePresenter. + queryResultTreePresenter := self newMooseGroupsTreeTable. + queryResultTreePresenter updateForEntities: self queryResultEntities ] @@ -271,10 +271,7 @@ MiQueriesBrowser >> showResultOfQuery: aQuery [ result := aQuery result. - queryResultTreePresenter := self instantiate: - QueryResultTreePresenter. - queryResultTreePresenter updateForEntities: result. - + self initializeResultTreePresenter. "This will sho the correct queryResultTreePresenter:" queryNotebookPresenter resetAllPageContents ] diff --git a/src/MooseIDE-QueriesBrowser/QueryResultTreePresenter.class.st b/src/MooseIDE-QueriesBrowser/QueryResultTreePresenter.class.st deleted file mode 100644 index d480dbdf1..000000000 --- a/src/MooseIDE-QueriesBrowser/QueryResultTreePresenter.class.st +++ /dev/null @@ -1,108 +0,0 @@ -" -I am a presenter thas shows the result of the current selected query in a tree presenter. -" -Class { - #name : #QueryResultTreePresenter, - #superclass : #SpTreeTablePresenter, - #instVars : [ - 'sortedEntitiesCache' - ], - #category : #'MooseIDE-QueriesBrowser-Widgets' -} - -{ #category : #commands } -QueryResultTreePresenter class >> buildCommandsGroupWith: presenter forRoot: aCmCommandsGroup [ - - aCmCommandsGroup - register: - ((MiInspectCommand forSpecWithIconNamed: #glamorousInspect) - context: presenter owner); - register: (MiPropagateCommand new asSpecCommand - iconName: #moosePropagate; - context: presenter owner); - register: (MiPropagateCommand new doNotFreezeBrowser asSpecCommand - iconName: #glamorousRestart; - name: 'Use as root for queries'; - context: presenter owner) -] - -{ #category : #commands } -QueryResultTreePresenter class >> buildModelCommandsGroupWith: presenterInstance [ - - ^ CmCommandGroup forSpec beRoot - register: (MiInspectCommand forSpecContext: presenterInstance); - register: (MiPropagateCommand forSpecContext: presenterInstance) -] - -{ #category : #accessing } -QueryResultTreePresenter class >> headerTitle [ - ^ 'Result of current query' -] - -{ #category : #initialization } -QueryResultTreePresenter >> childrenOf: item [ - - ^ (self roots includes: item) - ifTrue: [ - sortedEntitiesCache - at: item - ifAbsentPut: [ item entities sort: #name ascending ] ] - ifFalse: { } -] - -{ #category : #initialization } -QueryResultTreePresenter >> initialize [ - - super initialize. - - self - whenRootsChangedDo: [ sortedEntitiesCache := IdentityDictionary new ]; - addColumn: (SpStringTableColumn - title: self class headerTitle - evaluated: [ :item | self stringForItem: item ]); - children: [ :item | self childrenOf: item ]; - beMultipleSelection; - contextMenu: [ - (self class buildModelCommandsGroupWith: self queriesBrowser) - asMenuPresenter ] -] - -{ #category : #'private - for tests' } -QueryResultTreePresenter >> items [ - - ^ self roots flatCollect: [ :root | self childrenOf: root ] -] - -{ #category : #accessing } -QueryResultTreePresenter >> miSelectedItem [ - - ^ (self selectedItems collect: [ :item | - item isCollection - ifTrue: [ item entities ] - ifFalse: [ item ] ]) flattened copyWithoutDuplicates - asMooseGroup -] - -{ #category : #accessing } -QueryResultTreePresenter >> queriesBrowser [ - - ^ owner owner -] - -{ #category : #naming } -QueryResultTreePresenter >> stringForItem: item [ - - (self roots includes: item) ifTrue: [ ^ item description ]. - ^ item name -] - -{ #category : #update } -QueryResultTreePresenter >> updateForEntities: entities [ - - | groups | - groups := (entities allEntityTypes collect: [ :type | - entities allWithType: type ]) asOrderedCollection. - groups do: [ :group | group description: group details ]. - self roots: - (groups sort: [ :group | group description onlyLetters ] ascending) -] diff --git a/src/MooseIDE-Tests/MiAbstractBrowserTest.class.st b/src/MooseIDE-Tests/MiAbstractBrowserTest.class.st index 7901614e9..afe6ec134 100644 --- a/src/MooseIDE-Tests/MiAbstractBrowserTest.class.st +++ b/src/MooseIDE-Tests/MiAbstractBrowserTest.class.st @@ -78,7 +78,7 @@ MiAbstractBrowserTest >> setUp [ { #category : #running } MiAbstractBrowserTest >> tearDown [ - browser window ifNotNil: [ :window | window close ]. + browser ifNotNil: [ browser withWindowDo: [ :window | window close ] ]. self application deleteBus: self bus. super tearDown