Skip to content

Commit

Permalink
better tree columns plus tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyan11 committed Dec 24, 2023
1 parent 14b3663 commit 8a9f9eb
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 110 deletions.
34 changes: 34 additions & 0 deletions src/Pyramid-Bloc/PyramidAbstractColumnsBuilder.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Class {
#name : #PyramidAbstractColumnsBuilder,
#superclass : #Object,
#instVars : [
'editor'
],
#category : #'Pyramid-Bloc-plugin-tree-library'
}

{ #category : #testing }
PyramidAbstractColumnsBuilder class >> isAbstract [

^ self == PyramidAbstractColumnsBuilder
]

{ #category : #'as yet unclassified' }
PyramidAbstractColumnsBuilder >> buildOn: aPyramidTreePlugin [
"aPyramidTreePlugin addColumns: { }"
self shouldBeImplemented

]

{ #category : #accessing }
PyramidAbstractColumnsBuilder >> editor [

editor ifNil: [ Error signal: 'Editor should not be nil.' ].
^ editor
]

{ #category : #accessing }
PyramidAbstractColumnsBuilder >> editor: anObject [

editor := anObject
]
13 changes: 2 additions & 11 deletions src/Pyramid-Bloc/PyramidLibraryPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ Class {
#category : #'Pyramid-Bloc-plugin-tree-library'
}

{ #category : #accessing }
PyramidLibraryPresenter class >> idGenerator [

IdGenerator ifNil: [ IdGenerator := self makeIdGenerator ].
^ IdGenerator

]

{ #category : #accessing }
PyramidLibraryPresenter class >> makeIdGenerator [
^ Generator on: [ :generator |
Expand Down Expand Up @@ -103,7 +95,7 @@ PyramidLibraryPresenter >> defaultLayout [
expand: false;
yourself)
width: 300;
yourself)
yourself); yourself
]

{ #category : #accessing }
Expand All @@ -120,6 +112,7 @@ PyramidLibraryPresenter >> editor: aPyramidEditor [
{ #category : #accessing }
PyramidLibraryPresenter >> idGenerator [

idGenerator ifNil: [ idGenerator := self class makeIdGenerator ].
^ idGenerator
]

Expand All @@ -132,8 +125,6 @@ PyramidLibraryPresenter >> idGenerator: anObject [
{ #category : #initialization }
PyramidLibraryPresenter >> initializePresenters [

idGenerator := self class idGenerator.

addButton := SpButtonPresenter new
label: self buttonLabel;
action: [ self buttonAction ];
Expand Down
94 changes: 94 additions & 0 deletions src/Pyramid-Bloc/PyramidTreeBaseColumnsBuilder.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Class {
#name : #PyramidTreeBaseColumnsBuilder,
#superclass : #PyramidAbstractColumnsBuilder,
#category : #'Pyramid-Bloc-plugin-tree-library'
}

{ #category : #'as yet unclassified' }
PyramidTreeBaseColumnsBuilder >> buildOn: aPyramidTreePlugin [

aPyramidTreePlugin addColumns: { self nameAndTypeColumn . self hashColumn . self zIndexColumn . self visibilityColumn }
]

{ #category : #accessing }
PyramidTreeBaseColumnsBuilder >> hashColumn [

^ SpStringTableColumn new
title: 'Hash';
evaluated: [ :aBlElement |
aBlElement identityHash printString ];
displayColor: [ :aBlElement | Color gray ];
width: 60;
yourself
]

{ #category : #accessing }
PyramidTreeBaseColumnsBuilder >> nameAndTypeColumn [

^ SpCompositeTableColumn new
title: 'Elements';
addColumn:
(SpImageTableColumn evaluated: [ :aBlElement | aBlElement asIcon ]);
addColumn: (SpStringTableColumn new
title: 'Identifier';
evaluated: [ :aBlElement |
aBlElement elementId isNoId
ifTrue: [ '@\no name\' ]
ifFalse: [ aBlElement id asSymbol ] ];
yourself);
addColumn: (SpStringTableColumn new
title: 'Class';
evaluated: [ :aBlElement | aBlElement class name ];
displayColor: [ :aBlElement | Color gray ];
displayItalic: [ :aBlElement | true ];
yourself);
yourself
]

{ #category : #initialization }
PyramidTreeBaseColumnsBuilder >> setVisibility: aBlVisibility of: aBlElement onEditor: aPyramidEditor [

aPyramidEditor propertiesManager commandExecutor
use: PyramidVisibilityCommand new
on: { aBlElement }
with: aBlVisibility
]

{ #category : #accessing }
PyramidTreeBaseColumnsBuilder >> visibilityColumn [

^ SpCompositeTableColumn new
title: 'Visibility';
width: 80;
addColumn: (SpImageTableColumn evaluated: [ :aBlElement |
aBlElement
allParentsDetect: [ :parent | parent isVisible not ]
ifFound: [ :parent | self iconNamed: #uncommentedClass ]
ifNone: [ self iconNamed: #blank16 ] ]);
addColumn: (SpImageTableColumn evaluated: [ :aBlElement |
aBlElement visibility asIcon ]);
addColumn: (SpLinkTableColumn new
title: 'Visible';
url: [ :aBlElement | '' ];
action: [ :aBlElement |
self
setVisibility: aBlElement visibility nextVisibilityForTree
of: aBlElement
onEditor: self editor ];
evaluated: [ :aBlElement | aBlElement visibility asString ];
yourself);
yourself
]

{ #category : #accessing }
PyramidTreeBaseColumnsBuilder >> zIndexColumn [

^ SpStringTableColumn new
title: 'z';
evaluated: [ :aBlElement |
aBlElement elevation elevation = 0
ifTrue: [ '' ]
ifFalse: [ aBlElement elevation elevation printString ] ];
width: 16;
yourself
]
133 changes: 38 additions & 95 deletions src/Pyramid-Bloc/PyramidTreePlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,89 +9,33 @@ Class {
'libraryPresenterForElement',
'libraryPresenterForRoot'
],
#classVars : [
'ColumnsBuildersClasses'
],
#category : #'Pyramid-Bloc-plugin-tree-library'
}

{ #category : #'as yet unclassified' }
PyramidTreePlugin class >> columnHashValue: aPyramidTreePlugin [

^ SpStringTableColumn new
title: 'Hash';
evaluated: [ :aBlElement | aBlElement identityHash printString ];
displayColor: [ :aBlElement | Color gray ];
width: 60;
yourself
]
{ #category : #accessing }
PyramidTreePlugin class >> columnsBuildersClasses [

{ #category : #'as yet unclassified' }
PyramidTreePlugin class >> columnNameAndType: aPyramidTreePlugin [

^ SpCompositeTableColumn new
title: 'Elements';
addColumn:
(SpImageTableColumn evaluated: [ :aBlElement | aBlElement asIcon ]);
addColumn: (SpStringTableColumn new
title: 'Identifier';
evaluated: [ :aBlElement |
aBlElement elementId isNoId
ifTrue: [ '@\no name\' ]
ifFalse: [ aBlElement id asSymbol ] ];
yourself);
addColumn: (SpStringTableColumn new
title: 'Class';
evaluated: [ :aBlElement | aBlElement class name ];
displayColor: [ :aBlElement | Color gray ];
displayItalic: [ :aBlElement | true ];
yourself);
yourself
ColumnsBuildersClasses ifNil: [
ColumnsBuildersClasses := Set new ].
^ ColumnsBuildersClasses
]

{ #category : #'as yet unclassified' }
PyramidTreePlugin class >> columnVisibility: aPyramidTreePlugin [

^ SpCompositeTableColumn new
title: 'Visibility';
width: 80;
addColumn: (SpImageTableColumn evaluated: [ :aBlElement |
aBlElement
allParentsDetect: [ :parent | parent isVisible not ]
ifFound: [ :parent | self iconNamed: #uncommentedClass ]
ifNone: [ self iconNamed: #blank16 ] ]);
addColumn: (SpImageTableColumn evaluated: [ :aBlElement |
aBlElement visibility asIcon ]);
addColumn: (SpLinkTableColumn new
title: 'Visible';
url: [ :aBlElement | '' ];
action: [ :aBlElement |
self
setVisibility: aBlElement visibility nextVisibilityForTree
of: aBlElement
onEditor: aPyramidTreePlugin editor ];
evaluated: [ :aBlElement | aBlElement visibility asString ];
yourself);
yourself
]
{ #category : #initialization }
PyramidTreePlugin class >> install [
"Do some stuff here when the plugin used class oriented behavior"

{ #category : #'as yet unclassified' }
PyramidTreePlugin class >> columnZIndex: aPyramidTreePlugin [

^ SpStringTableColumn new
title: 'z';
evaluated: [ :aBlElement |
aBlElement elevation elevation = 0
ifTrue: [ '' ]
ifFalse: [ aBlElement elevation elevation printString ] ];
width: 16;
yourself
self columnsBuildersClasses add: PyramidTreeBaseColumnsBuilder
]

{ #category : #initialization }
PyramidTreePlugin class >> setVisibility: aBlVisibility of: aBlElement onEditor: aPyramidEditor [
PyramidTreePlugin >> addColumns: aCollection [
aCollection do: [ :each | self treePresenter columns add: each ].
self treePresenter updateTree

aPyramidEditor propertiesManager commandExecutor
use: PyramidVisibilityCommand new
on: { aBlElement }
with: aBlVisibility

]

{ #category : #adding }
Expand All @@ -109,13 +53,19 @@ PyramidTreePlugin >> addPanelsOn: aPyramidSimpleWindow [
addItem: [ :builder | self menuAddAndDeleteOn: builder ]
]

{ #category : #actions }
PyramidTreePlugin >> configureBuilder: aPyramidEditorBuilder [

self class columnsBuildersClasses do: [ :each |
each new
editor: aPyramidEditorBuilder editor;
buildOn: self ]
]

{ #category : #connecting }
PyramidTreePlugin >> connectOn: aPyramidEditor [

self editor: aPyramidEditor.
self treePresenter projectModel: aPyramidEditor projectModel.
self treePresenter editorMenuBuilder:
(self editor window services at: #selectionMenu) builder
]

{ #category : #accessing }
Expand All @@ -125,11 +75,14 @@ PyramidTreePlugin >> editor [
]

{ #category : #accessing }
PyramidTreePlugin >> editor: anObject [
PyramidTreePlugin >> editor: aPyramidEditor [

editor := anObject.
self libraryPresenterForElement editor: anObject.
self libraryPresenterForRoot editor: anObject.
editor := aPyramidEditor.
self libraryPresenterForElement editor: aPyramidEditor.
self libraryPresenterForRoot editor: aPyramidEditor.
self treePresenter projectModel: aPyramidEditor projectModel.
self treePresenter editorMenuBuilder:
(self editor window services at: #selectionMenu) builder
]

{ #category : #initialization }
Expand All @@ -139,35 +92,25 @@ PyramidTreePlugin >> initialize [
treePresenter := PyramidTreePresenter new
libraryPresenterForRoot:
self libraryPresenterForRoot;
yourself.
self initializeTreeColumns.
yourself
]

{ #category : #initialization }
PyramidTreePlugin >> initializeLibraryPresenters [

| idGenerator |
idGenerator := PyramidLibraryPresenter idGenerator.
idGenerator := PyramidLibraryPresenter makeIdGenerator.
libraryPresenterForElement := PyramidLibraryPresenterForElement new
editor: self editor;
idGenerator: idGenerator;
idGenerator: idGenerator;
yourself.
libraryPresenterForRoot := PyramidLibraryPresenterForFirstLevelElement new
libraryPresenterForRoot := PyramidLibraryPresenterForFirstLevelElement
new
editor: self editor;
idGenerator: idGenerator;
idGenerator: idGenerator;
yourself
]

{ #category : #initialization }
PyramidTreePlugin >> initializeTreeColumns [

self treePresenter columns add: (self class columnNameAndType: self).
self treePresenter columns add: (self class columnHashValue: self).
self treePresenter columns add: (self class columnZIndex: self).
self treePresenter columns add: (self class columnVisibility: self).
self treePresenter updateTree
]

{ #category : #'as yet unclassified' }
PyramidTreePlugin >> libraryPresenterForElement [

Expand Down
8 changes: 4 additions & 4 deletions src/Pyramid-Tests/PyramidLibraryPresenterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Class {
PyramidLibraryPresenterTest >> testIdGenerator [
"We generate a bunch of id and we verify that none are the same"

| libraryPresForElements libraryPresForFirstLevel elements |
libraryPresForElements := PyramidLibraryPresenterForElement new.
libraryPresForFirstLevel := PyramidLibraryPresenterForFirstLevelElement
new.
| treePlugin libraryPresForElements libraryPresForFirstLevel elements |
treePlugin := PyramidTreePlugin new.
libraryPresForElements := treePlugin libraryPresenterForElement.
libraryPresForFirstLevel := treePlugin libraryPresenterForRoot.
elements := Bag new.
1 to: 100 do: [ :i |
elements add:
Expand Down
Loading

0 comments on commit 8a9f9eb

Please sign in to comment.