Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/Pyramid-Bloc/PyramidNavigationPlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ PyramidNavigationPlugin >> connectOn: aPyramidEditor [
editor := aPyramidEditor.
self navigation editor: aPyramidEditor.
self libraryController popoverOrigin:
(aPyramidEditor window services at: #tabLeft) presenter.

aPyramidEditor
addShortcutSpecInCollection: KeyboardKey delete
action: [ self removeSelectedElements ]
name: 'Shortcut Spec removeSelectedElement'.
(aPyramidEditor window services at: #tabLeft) presenter
]

{ #category : #initialization }
Expand Down
22 changes: 18 additions & 4 deletions src/Pyramid-Bloc/PyramidNavigationTreePresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Class {
#category : #'Pyramid-Bloc-plugin-navigation'
}

{ #category : #'as yet unclassified' }
{ #category : #actions }
PyramidNavigationTreePresenter >> actionEditorMenu [

| builder |
Expand All @@ -20,7 +20,7 @@ PyramidNavigationTreePresenter >> actionEditorMenu [
^ builder menuFor: self editor projectModel selection
]

{ #category : #'as yet unclassified' }
{ #category : #actions }
PyramidNavigationTreePresenter >> actionSelectionChanged: aSelection [

self editor ifNil: [ ^ self ].
Expand Down Expand Up @@ -106,7 +106,9 @@ PyramidNavigationTreePresenter >> initializePresenters [
whenSelectionChangedDo: [ :aSelection |
self actionSelectionChanged: aSelection ];
expandAll.
self allTreeColumns do: [ :each | treeTable addColumn: each ]
self allTreeColumns do: [ :each | treeTable addColumn: each ].

treeTable eventHandler whenKeyUpDo:[ :event | (event key = KeyboardKey delete) ifTrue:[ self removeSelectedElements] ]
]

{ #category : #accessing }
Expand Down Expand Up @@ -140,6 +142,18 @@ PyramidNavigationTreePresenter >> previousNumberOfElement: anObject [
previousNumberOfElement := anObject
]

{ #category : #actions }
PyramidNavigationTreePresenter >> removeSelectedElements [

self editor commandExecutor

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It confirm that it was a good idea to rename SmockCommandExecutor to SmockCommandRunner! The mistake was not away.

use: PyramidRemoveSelectedElementsCommand new
on: self editor projectModel selection
with: self editor projectModel firstLevelElements.

"Update the selection after remove"
self editor projectModel updateSelection
]

{ #category : #api }
PyramidNavigationTreePresenter >> roots: aCollection [

Expand All @@ -164,7 +178,7 @@ PyramidNavigationTreePresenter >> treeTable [
^ treeTable
]

{ #category : #'as yet unclassified' }
{ #category : #updating }
PyramidNavigationTreePresenter >> updateRoots [

| currentTreeRoots roots parent shouldOrder calculatedNumberOfElement |
Expand Down
12 changes: 11 additions & 1 deletion src/Pyramid-Bloc/PyramidSaveModelVerifier.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,18 @@ PyramidSaveModelVerifier class >> classPackageIsEqual [
{ #category : #constructor }
PyramidSaveModelVerifier class >> methodIsValid [

(SystemVersion current major <= 12) ifTrue: [ ^self methodIsValidP12 ].

^ self new verifyBlock: [ :model | OCScanner isSelector: model savingMethodName ];
showBlock: [ :view | view showMethodIsNotValidError ];
yourself
]

{ #category : #constructor }
PyramidSaveModelVerifier class >> methodIsValidP12 [

^ self new

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interresting. Should be better to use a dedicated object for that the next time.

verifyBlock: [ :model |model savingMethodName isValidSelector];
verifyBlock: [ :model | model savingMethodName isValidSelector ];
showBlock: [ :view | view showMethodIsNotValidError ];
yourself
]
Expand Down
58 changes: 26 additions & 32 deletions src/Pyramid-Bloc/PyramidSavingService.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -118,40 +118,34 @@ PyramidSavingService class >> ston [
{ #category : #private }
PyramidSavingService >> buildMetaDataMethod [

| methodName windowSize gridVisibility gridSpacing gridColor icons dictContent nl tab header existingIds |
| methodName windowSize gridVisibility gridSpacing gridColor icons dictContent nl tab header rootElements|
methodName := self saveModel savingMethodName , 'MetaData'.
windowSize := PyramidMainExtension currentGridWindowSize ifNil: [
800 @ 600 ].
gridVisibility := PyramidMainExtension currentGridVisibility ifNil: [
false ].
windowSize := PyramidMainExtension currentGridWindowSize ifNil: [ 800 @ 600 ].
gridVisibility := PyramidMainExtension currentGridVisibility ifNil: [ false ].
gridSpacing := PyramidMainExtension currentGridSpacing ifNil: [ 10 ].
gridColor := PyramidMainExtension currentGridColor ifNil: [
Color black ].
existingIds := Set new.
[
self saveModel projectModel firstLevelElements do: [ :e |
(e respondsTo: #id) ifTrue: [
e id ifNotNil: [ :anId | existingIds add: anId asString ] ] ] ]
on: Error
do: [ :err | existingIds := Set new ].
gridColor := PyramidMainExtension currentGridColor ifNil: [ Color black ].

rootElements := self saveModel projectModel firstLevelElements.
icons := Dictionary new.
PyramidMainExtension currentProjectIcons keysAndValuesDo: [
:key
:value |
| keyString suffix baseId |
keyString := key asString.
suffix := #( '_icon' '_endIcon' '_innerImage' )
detect: [ :s | keyString endsWith: s ]
ifNone: [ nil ].
suffix ifNotNil: [
baseId := keyString copyFrom: 1 to: keyString size - suffix size.
(existingIds includes: baseId) ifTrue: [
icons at: key put: value ] ] ] .
PyramidMainExtension currentProjectIcons keysAndValuesDo: [:key :value |
| keyString suffix baseId |
keyString := key asString.
suffix := #( '_icon' '_endIcon' '_innerImage' )
detect: [ :s | keyString endsWith: s ]
ifNone: [ nil ].
suffix ifNotNil: [
baseId := keyString copyFrom: 1 to: keyString size - suffix size.
(rootElements anySatisfy:[:e | (e id = baseId) or:[ e allChildrenBreadthFirstDetect: [:c |c id = baseId ] ifFound:[:c | true] ifNone:[false] ]]) ifTrue:[
icons at: key put: value
]
]
].
(windowSize = (800 @ 600) and: [
gridVisibility not and: [
gridSpacing = 10 and: [
gridColor = Color black and: [ icons isEmpty ] ] ] ]) ifTrue: [
^ nil ].
gridVisibility not and: [
gridSpacing = 10 and: [
gridColor = Color black and: [ icons isEmpty ] ] ] ]) ifTrue: [
^ nil
].
nl := String with: Character cr.
tab := String with: Character tab.
dictContent := ''.
Expand Down Expand Up @@ -195,7 +189,7 @@ PyramidSavingService >> canSave [
^ self verifier verify: self saveModel
]

{ #category : #'as yet unclassified' }
{ #category : #private }
PyramidSavingService >> errorCannotSave [

PyramidSaveError signal: 'Cannot save with given model. Check canSave method to more explenation.'
Expand All @@ -207,7 +201,7 @@ PyramidSavingService >> methodBuilder [
^ self class currentMethodBuilder
]

{ #category : #'as yet unclassified' }
{ #category : #API }
PyramidSavingService >> save [
| class |
self canSave ifFalse: [ self errorCannotSave ].
Expand Down
8 changes: 6 additions & 2 deletions src/Pyramid-Bloc/PyramidToImageInnerImageCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ PyramidToImageInnerImageCommand >> getValueFor: aToImage [
{ #category : #setter }
PyramidToImageInnerImageCommand >> setValueFor: aToImage with: aSymbol [

aToImage innerImage:
(PyramidIconInputPresenter innerElementFromName: aSymbol).
| innerImage |
innerImage := PyramidIconInputPresenter toImageFromName: aSymbol.
innerImage constraints horizontal matchParent.
innerImage constraints vertical matchParent.
aToImage innerImage: innerImage.

PyramidMainExtension
addIconName: aSymbol
forElementId: aToImage id asString, '_innerImage'
Expand Down
2 changes: 2 additions & 0 deletions src/Pyramid-Toplo/PyramidToploThemePlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ PyramidToploThemePlugin class >> toploLibraryCategory [
ToLabel.
ToImage.
ToAlbum.
ToPane.
ToCheckbox.
ToTextField}.
knownNotUsable := #( #ToCircularMenuInnerElement
#ToCircularMenuList #ToExPicsumNode
Expand Down
2 changes: 1 addition & 1 deletion src/Pyramid/PyramidEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ PyramidEditor >> commandExecutor: anObject [
commandExecutor := anObject
]

{ #category : #'as yet unclassified' }
{ #category : #'private - default' }
PyramidEditor >> defaultSpecShortcuts [

"Shortcut using only projectModel"
Expand Down
57 changes: 9 additions & 48 deletions src/Pyramid/PyramidIconInputPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,41 +37,17 @@ PyramidIconInputPresenter class >> findToploIconNamed: aSymbol [
ifNone: [ nil ] ] ]
]

{ #category : #private }
PyramidIconInputPresenter class >> innerElementFromName: aSymbol [

(self findToploIconNamed: aSymbol) ifNotNil: [ :element |
| proxy |
proxy := self toploSvgProxyFor: element.

proxy pyramidExternalRessourceSource postConstructionBlock: [ :obj |
obj constraints horizontal matchParent.
obj constraints vertical matchParent ].

^ proxy ].

^ self buildProxy: Object selector: #iconNamed: args: { aSymbol }
]

{ #category : #private }
PyramidIconInputPresenter class >> toImageFromName: aSymbol [

(self findToploIconNamed: aSymbol) ifNotNil: [ :element |
| proxy |
proxy := self toploSvgProxyFor: element.

proxy pyramidExternalRessourceSource postConstructionBlock: [ :obj |
obj constraints horizontal exact: 16.
obj constraints vertical exact: 16 ].
| proxy |
proxy := (self findToploIconNamed: aSymbol) ifNotNil: [ :element |
self buildProxy: element provider selector: element name asSymbol args: #( )
] ifNil:[
self buildProxy: Object selector: #iconNamed: args: { aSymbol }
].

^ ToImage new
innerImage: proxy;
yourself ].

^ ToImage new
innerImage:
(self buildProxy: Object selector: #iconNamed: args: { aSymbol });
yourself
^ ToImage new innerImage: proxy;yourself
]

{ #category : #adding }
Expand All @@ -96,6 +72,8 @@ PyramidIconInputPresenter class >> toploIconThemeCategoryFromClass: aClass withC

elementSelectors := (aClass perform: method selector) collect: [
:suffix | prefix , '_' , suffix ].

elementSelectors := elementSelectors asSortedCollection.

elements := elementSelectors collect: [ :selector |
PyramidLibraryElement new
Expand Down Expand Up @@ -150,23 +128,6 @@ PyramidIconInputPresenter class >> toploMaterialIconCategory [
withCategoryPrefix: 'Material Design - '
]

{ #category : #private }
PyramidIconInputPresenter class >> toploSvgProxyFor: element [

| stringProxy svgProxy |
stringProxy := self
buildProxy: element provider
selector: element name asSymbol
args: #( ).

svgProxy := self
buildProxy: BlSvgConverter
selector: #convertFromString:
args: { stringProxy }.

^ svgProxy
]

{ #category : #private }
PyramidIconInputPresenter >> buildIconPickerPresenter [

Expand Down
2 changes: 1 addition & 1 deletion src/Pyramid/TPyramidFindPlugin.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Trait {
#category : #'Pyramid-core'
}

{ #category : #'as yet unclassified' }
{ #category : #accessing }
TPyramidFindPlugin >> findPlugin: aSymbolOrAClass [

| allPlugins |
Expand Down
Loading