Skip to content

Commit

Permalink
Merge pull request #1143 from moosetechnology/critic-browser
Browse files Browse the repository at this point in the history
Make query result tree an independant widget
  • Loading branch information
ClotildeToullec authored Aug 2, 2024
2 parents a3c33aa + 61672ad commit 26b217a
Show file tree
Hide file tree
Showing 16 changed files with 440 additions and 245 deletions.
6 changes: 6 additions & 0 deletions src/MooseIDE-Core/Collection.extension.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Extension { #name : #Collection }

{ #category : #'*MooseIDE-Core' }
Collection >> miInspect [

self asMooseGroup miInspect
]

{ #category : #'*MooseIDE-Core' }
Collection >> miPropagate [

Expand Down
8 changes: 8 additions & 0 deletions src/MooseIDE-Core/ManifestMooseIDECore.class.st
Original file line number Diff line number Diff line change
@@ -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'
}
192 changes: 192 additions & 0 deletions src/MooseIDE-Core/MiMooseGroupsTreeTablePresenter.class.st
Original file line number Diff line number Diff line change
@@ -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)
]
14 changes: 14 additions & 0 deletions src/MooseIDE-Core/MiPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ MiPresenter >> isMiBrowser [
^ false
]

{ #category : #'scripting - widgets' }
MiPresenter >> newMooseGroupsTreeTable [

^ self instantiate: MiMooseGroupsTreeTablePresenter
]

{ #category : #'scripting - widgets' }
MiPresenter >> newSelectableListForPopoverExtent: aPoint [

Expand All @@ -45,3 +51,11 @@ MiPresenter >> newSelectableListForPopoverExtent: aPoint [
yourself);
yourself
]

{ #category : #accessing }
MiPresenter >> rootBrowser [

^ self isMiBrowser
ifTrue: [ self ]
ifFalse: [ self owner rootBrowser ]
]
6 changes: 6 additions & 0 deletions src/MooseIDE-Core/MooseObject.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ MooseObject >> miDescription [
^ self description
]

{ #category : #'*MooseIDE-Core' }
MooseObject >> miInspect [

MiInspectorBrowser inspect: self
]

{ #category : #'*MooseIDE-Core' }
MooseObject >> miPropagate [

Expand Down
13 changes: 13 additions & 0 deletions src/MooseIDE-CriticBrowser/FamixCBViolation.extension.st
Original file line number Diff line number Diff line change
@@ -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
]
23 changes: 23 additions & 0 deletions src/MooseIDE-CriticBrowser/MiCBExportRulesCommand.class.st
Original file line number Diff line number Diff line change
@@ -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
]
23 changes: 23 additions & 0 deletions src/MooseIDE-CriticBrowser/MiCBImportRulesCommand.class.st
Original file line number Diff line number Diff line change
@@ -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
]
23 changes: 23 additions & 0 deletions src/MooseIDE-CriticBrowser/MiCBRunAllRulesCommand.class.st
Original file line number Diff line number Diff line change
@@ -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
]
Loading

0 comments on commit 26b217a

Please sign in to comment.