diff --git a/.smalltalk.ston b/.smalltalk.ston index b061e401..69bf48aa 100644 --- a/.smalltalk.ston +++ b/.smalltalk.ston @@ -6,6 +6,9 @@ SmalltalkCISpec { SCIMetacelloLoadSpec { #baseline : 'Pyramid', #directory : 'src', + #onConflict : #useLoaded, + #onUpgrade : #useLoaded, + #onWarningLog : true, #platforms : [ #pharo ] } ], diff --git a/README.md b/README.md index 1c605b3f..13d3fa87 100644 --- a/README.md +++ b/README.md @@ -36,20 +36,32 @@ To install a version of Pyramid, use one of the following scripts inside a playg ### Latest development version ```st -Metacello new +[[ + Metacello new baseline: 'Pyramid'; - repository: 'github://OpenSmock/Pyramid:main/src'; - load + repository: 'github://OpenSmock/Pyramid:stage-dev-shortcuts/src'; + onConflict: [ :ex :loaded :incoming | ex useLoaded ]; + onUpgrade: [ :ex :loaded :incoming | ex useLoaded ]; + ignoreImage; + load. + ] on: MCMergeOrLoadWarning do: [ :warning | warning load ] +] on: Warning do: [ :w | w resume ]. ``` Only with Bloc (without Toplo features): ```st -Metacello new +[[ + Metacello new baseline: 'Pyramid'; - repository: 'github://OpenSmock/Pyramid:main/src'; - load: 'BlocUI'; - load + repository: 'github://OpenSmock/Pyramid:stage-dev-shortcuts/src'; + onConflict: [ :ex :loaded :incoming | ex useLoaded ]; + onUpgrade: [ :ex :loaded :incoming | ex useLoaded ]; + ignoreImage; + load: 'BlocUI'; + load. + ] on: MCMergeOrLoadWarning do: [ :warning | warning load ] +] on: Warning do: [ :w | w resume ]. ``` ### Release version diff --git a/src/Pyramid-Bloc/PyramidSpacePlugin.class.st b/src/Pyramid-Bloc/PyramidSpacePlugin.class.st index e9459d12..df836934 100644 --- a/src/Pyramid-Bloc/PyramidSpacePlugin.class.st +++ b/src/Pyramid-Bloc/PyramidSpacePlugin.class.st @@ -6,7 +6,8 @@ Class { #instVars : [ 'builder', 'morphicPresenter', - 'resetSpaceButton' + 'resetSpaceButton', + 'resetShortcutBlock' ], #category : #'Pyramid-Bloc-plugin-space' } @@ -37,6 +38,7 @@ PyramidSpacePlugin >> connectOn: aPyramidEditor [ { #category : #initialization } PyramidSpacePlugin >> initialize [ + resetShortcutBlock := [ :aSpace | ]. builder := PyramidSpaceBuilder defaultEditorBuilder. morphicPresenter := SpMorphPresenter new. resetSpaceButton := SpButtonPresenter new @@ -74,12 +76,25 @@ PyramidSpacePlugin >> morphicPresenter [ ^ morphicPresenter ] +{ #category : #accessing } +PyramidSpacePlugin >> resetShortcutBlock [ + + ^ resetShortcutBlock +] + +{ #category : #accessing } +PyramidSpacePlugin >> resetShortcutBlock: aBlock [ + + resetShortcutBlock := aBlock +] + { #category : #initialization } PyramidSpacePlugin >> resetSpace [ | space | space := self builder build. self makePresenterWithBlSpace: space. + resetShortcutBlock value: space. space show ] diff --git a/src/Pyramid-Bloc/PyramidSpaceShortcutCopyPasteCut.class.st b/src/Pyramid-Bloc/PyramidSpaceShortcutCopyPasteCut.class.st new file mode 100644 index 00000000..5ecf5122 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidSpaceShortcutCopyPasteCut.class.st @@ -0,0 +1,147 @@ +" +This class is used to create the shortcut for copy and paste -> use the plugin-copy-paste from this package. + +It use the editor to get the collection of selected object from project model in Pyramid space. +" +Class { + #name : #PyramidSpaceShortcutCopyPasteCut, + #superclass : #PyramidSpaceShortcutManagerPlugin, + #instVars : [ + 'copyPastePlugin', + 'navigationPlugin', + 'shortcutCopy', + 'shortcutPaste', + 'keyCombinationCopy', + 'keyCombinationPaste', + 'elementCollectionSelected', + 'keyCombinationCut', + 'shortcutCut' + ], + #category : #'Pyramid-Bloc-plugin-shortcut-manager' +} + +{ #category : #'accessing - classes' } +PyramidSpaceShortcutCopyPasteCut >> copyPasteCutPluginFromPyramid: aPyramidEditor [ + + "Connect selection array" + self elementCollectionSelected: aPyramidEditor. + "get copyPastePlugin" + copyPastePlugin := aPyramidEditor findPlugin: PyramidCopyPastePlugin. + "Get navigationPlugin" + navigationPlugin := aPyramidEditor findPlugin: PyramidNavigationPlugin. +] + +{ #category : #accessing } +PyramidSpaceShortcutCopyPasteCut >> copyPastePlugin: aPlugin [ + + copyPastePlugin := aPlugin +] + +{ #category : #action } +PyramidSpaceShortcutCopyPasteCut >> copySelectedElementInSpace [ + + elementCollectionSelected isEmpty + ifTrue: [ ^ self ]. + elementCollectionSelected size = 1 + ifTrue: [ copyPastePlugin copyAsStonInClipboard: (elementCollectionSelected first). ^ 1 ] + ifFalse: [ self inform: 'Can not copy multiple element' ] + + + +] + +{ #category : #accessing } +PyramidSpaceShortcutCopyPasteCut >> defaultKeyCombinationCopy [ + "CTRL + C to activate this shortcut" + keyCombinationCopy := ((BlKeyCombination builder primary key: KeyboardKey C) build) +] + +{ #category : #accessing } +PyramidSpaceShortcutCopyPasteCut >> defaultKeyCombinationCut [ + "CTRL + X to activate this shortcut" + keyCombinationCut := ((BlKeyCombination builder primary key: KeyboardKey X) build) +] + +{ #category : #accessing } +PyramidSpaceShortcutCopyPasteCut >> defaultKeyCombinationPaste [ + "CTRL + V to activate this shortcut" + keyCombinationPaste := ((BlKeyCombination builder primary key: KeyboardKey V) build) +] + +{ #category : #accessing } +PyramidSpaceShortcutCopyPasteCut >> elementCollectionSelected: aPyramidEditor [ + + elementCollectionSelected := (aPyramidEditor projectModel selection) collection. +] + +{ #category : #initialization } +PyramidSpaceShortcutCopyPasteCut >> initialize [ + + self defaultKeyCombinationCopy. + self defaultKeyCombinationPaste. + self defaultKeyCombinationCut. +] + +{ #category : #accessing } +PyramidSpaceShortcutCopyPasteCut >> keyCombinationCopy: aKeyCombination [ + + ^ keyCombinationCopy := aKeyCombination +] + +{ #category : #accessing } +PyramidSpaceShortcutCopyPasteCut >> keyCombinationCut: aKeyCombination [ + + ^ keyCombinationCut := aKeyCombination +] + +{ #category : #accessing } +PyramidSpaceShortcutCopyPasteCut >> keyCombinationPaste: aKeyCombination [ + + ^ keyCombinationPaste := aKeyCombination +] + +{ #category : #action } +PyramidSpaceShortcutCopyPasteCut >> pasteElement [ + + elementCollectionSelected isEmpty + ifTrue: [ copyPastePlugin pasteFromClipboardOnFirstLevelElements ]. + elementCollectionSelected size = 1 + ifTrue: [ copyPastePlugin pasteFromClipboardOnSelection: (elementCollectionSelected first) ] + + + +] + +{ #category : #accessing } +PyramidSpaceShortcutCopyPasteCut >> shortcutActionCopy [ + + ^ shortcutCopy := BlShortcutWithAction new + name: 'Pyramid edition shortcut copy'; + combination: keyCombinationCopy; + action: [ :event | copyPastePlugin + ifNil: [ self inform: 'Plugin Copy/Paste is not installed' ] + ifNotNil: [ self copySelectedElementInSpace ] ] +] + +{ #category : #accessing } +PyramidSpaceShortcutCopyPasteCut >> shortcutActionCut [ + + ^ shortcutCut := BlShortcutWithAction new + name: 'Pyramid edition shortcut cut'; + combination: keyCombinationCut; + action: [ :event | copyPastePlugin + ifNil: [ self inform: 'Plugin Copy/Paste is not installed' ] + ifNotNil: [ self copySelectedElementInSpace = 1 + ifTrue: [ navigationPlugin removeSelectedElements ] ] ] +] + +{ #category : #accessing } +PyramidSpaceShortcutCopyPasteCut >> shortcutActionPaste [ + + ^ shortcutPaste := BlShortcutWithAction new + name: 'Pyramid edition shortcut paste'; + combination: keyCombinationPaste; + action: [ :event | copyPastePlugin + ifNil: [ self inform: 'Plugin Copy/Paste is not installed' ] + ifNotNil: [ self pasteElement ] ] +] diff --git a/src/Pyramid-Bloc/PyramidSpaceShortcutGrid.class.st b/src/Pyramid-Bloc/PyramidSpaceShortcutGrid.class.st new file mode 100644 index 00000000..8acf0ca1 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidSpaceShortcutGrid.class.st @@ -0,0 +1,60 @@ +" +This class define the shortcut to show or hide the grid on the space. + +the grid is define in the plugin-space-extension -> PyramidMainExtension +" +Class { + #name : #PyramidSpaceShortcutGrid, + #superclass : #PyramidSpaceShortcutManagerPlugin, + #instVars : [ + 'gridFeature', + 'shortcutGridVisibility', + 'keyCombinationGridVisibility', + 'keyCombinationTest', + 'shortcutTest' + ], + #category : #'Pyramid-Bloc-plugin-shortcut-manager' +} + +{ #category : #accessing } +PyramidSpaceShortcutGrid >> defaultKeyCombinationGridVisibility [ + "CTRL + G to activate this shortcut" + keyCombinationGridVisibility := ((BlKeyCombination builder primary key: KeyboardKey G) build) +] + +{ #category : #'accessing - classes' } +PyramidSpaceShortcutGrid >> gridFeatureFromSpacePlugin: aPyramidEditor [ + + | spacePlugin listOfSpaceExtension pyramidMainExtensionSet | + + spacePlugin := aPyramidEditor findPlugin: PyramidSpacePlugin. + + listOfSpaceExtension := spacePlugin builder extensions. + + pyramidMainExtensionSet := listOfSpaceExtension select: [ :extensions | extensions isKindOf: PyramidMainExtension ]. + pyramidMainExtensionSet size = 1 + ifFalse: [^ self]. + gridFeature := pyramidMainExtensionSet asArray first + +] + +{ #category : #initialization } +PyramidSpaceShortcutGrid >> initialize [ + + self defaultKeyCombinationGridVisibility. +] + +{ #category : #accessing } +PyramidSpaceShortcutGrid >> keyCombinationGridVisibility: aKeyCombination [ + + keyCombinationGridVisibility := aKeyCombination +] + +{ #category : #accessing } +PyramidSpaceShortcutGrid >> shortcutActionGridVisibility [ + + ^ shortcutGridVisibility := BlShortcutWithAction new + name: 'Pyramid edition shortcut grid visibility'; + combination: keyCombinationGridVisibility; + action: [ :event | gridFeature workplacePropertiesView visibilityButton toggleState ]. +] diff --git a/src/Pyramid-Bloc/PyramidSpaceShortcutInspectSelectedElement.class.st b/src/Pyramid-Bloc/PyramidSpaceShortcutInspectSelectedElement.class.st new file mode 100644 index 00000000..5a317ecf --- /dev/null +++ b/src/Pyramid-Bloc/PyramidSpaceShortcutInspectSelectedElement.class.st @@ -0,0 +1,45 @@ +Class { + #name : #PyramidSpaceShortcutInspectSelectedElement, + #superclass : #PyramidSpaceShortcutManagerPlugin, + #instVars : [ + 'projectModel', + 'keyCombinationInspect', + 'shortcutInspect' + ], + #category : #'Pyramid-Bloc-plugin-shortcut-manager' +} + +{ #category : #accessing } +PyramidSpaceShortcutInspectSelectedElement >> defaultKeyCombinationInspect [ + "CTRL + S to activate this shortcut" + keyCombinationInspect := ((BlKeyCombination builder primary key: KeyboardKey I) build) +] + +{ #category : #initialization } +PyramidSpaceShortcutInspectSelectedElement >> initialize [ + + self defaultKeyCombinationInspect. +] + +{ #category : #accessing } +PyramidSpaceShortcutInspectSelectedElement >> keyCombinationInspect: aKeyCombination [ + + ^ keyCombinationInspect := aKeyCombination +] + +{ #category : #'accessing - classes' } +PyramidSpaceShortcutInspectSelectedElement >> projectModelFromPyramid: aPyramidEditor [ + + projectModel := aPyramidEditor projectModel +] + +{ #category : #accessing } +PyramidSpaceShortcutInspectSelectedElement >> shortcutActionInspect [ + + ^ shortcutInspect := BlShortcutWithAction new + name: 'Pyramid edition shortcut save'; + combination: keyCombinationInspect; + action: [ :event | projectModel selection size = 1 + ifTrue: [ (projectModel selection first) inspect ] + ifFalse: [ self inform: 'Cannot inspect zero or multiple selected element' ] ] +] diff --git a/src/Pyramid-Bloc/PyramidSpaceShortcutManagerPlugin.class.st b/src/Pyramid-Bloc/PyramidSpaceShortcutManagerPlugin.class.st new file mode 100644 index 00000000..b4c5abbe --- /dev/null +++ b/src/Pyramid-Bloc/PyramidSpaceShortcutManagerPlugin.class.st @@ -0,0 +1,143 @@ +" +This class is use to add shortcut to the space in pyramid to use feature, you can check the PyramidShortcutUndoRedo as exemple. + +Shortcut only works when the space of Pyramid have the focus. + +List of current active shortcut (default value) : +- Save -> ctrl + S +- Undo -> ctrl + Z +- Redo -> ctrl + Y +- Copy -> ctrl + C +- Paste -> ctrl + V +- Cut -> ctrl + X +- Grid visibility switch -> ctrl + G +- Select all element -> ctrl + A +- Delete selected element -> delete or suppr +- Inspect one selected element -> ctrl + I +" +Class { + #name : #PyramidSpaceShortcutManagerPlugin, + #superclass : #Object, + #traits : 'TPyramidPlugin', + #classTraits : 'TPyramidPlugin classTrait', + #instVars : [ + 'shortcutCollection', + 'shortcutUndoRedo', + 'shortcutCopyPaste', + 'shortcutSaveAction', + 'shortcutGrid', + 'shortcutRemoveElement', + 'shortcutSelectAllElement', + 'shortcutInspectSelectedElement' + ], + #category : #'Pyramid-Bloc-plugin-shortcut-manager' +} + +{ #category : #adding } +PyramidSpaceShortcutManagerPlugin >> addAllShortcutInCollection [ + "Default values of the different shortcut" + + "Shortcut Undo (ctrl + Z) / Redo (ctrl + Y) " + shortcutCollection add: shortcutUndoRedo shortcutActionUndo. + shortcutCollection add: shortcutUndoRedo shortcutActionRedo. + + "Shortcut Copy (ctrl + C) / Paste (ctrl + V)" + shortcutCollection add: shortcutCopyPaste shortcutActionCopy. + shortcutCollection add: shortcutCopyPaste shortcutActionPaste. + shortcutCollection add: shortcutCopyPaste shortcutActionCut. + + "Shortcut Save (ctrl + S)" + shortcutCollection add: shortcutSaveAction shortcutActionSave. + + "Shortcut grid" + "Grid visibility (ctrl + G)" + shortcutCollection add: shortcutGrid shortcutActionGridVisibility. + + "Shortcut Remove Element (suppr / del)" + shortcutCollection add: shortcutRemoveElement shortcutActionRemoveElement. + + "Shortcut Select all element in space (ctrl + A)" + shortcutCollection add: shortcutSelectAllElement shortcutActionSelectAll. + + "Shortcut inspect selected element (ctrl + I)" + shortcutCollection add: shortcutInspectSelectedElement shortcutActionInspect. + + "New shortcut to add under this comment, keep the same patern as before" + +] + +{ #category : #accessing } +PyramidSpaceShortcutManagerPlugin >> addAllShortcutInSpace: aSpace [ + + self addAllShortcutInCollection. + shortcutCollection do: [ :shortcut | aSpace root addShortcut: shortcut ]. + + +] + +{ #category : #connecting } +PyramidSpaceShortcutManagerPlugin >> connectOn: aPyramidEditor [ + + | spacePlugin spacePluginSet | + + "Get the space plugin to adding shortcut" + spacePluginSet := aPyramidEditor plugins select: [ :plugin | plugin isKindOf: PyramidSpacePlugin ]. + spacePluginSet size = 1 + ifFalse: [self inform: 'Space plugin is not installed -> impossible to install shortcut to the space'. + ^ self]. + spacePlugin := spacePluginSet asArray first. + + "Get History plugin for Undo / Redo shortcut" + shortcutUndoRedo historyPluginFromPyramid: aPyramidEditor. + + "Get Copy Paste plugin" + shortcutCopyPaste copyPasteCutPluginFromPyramid: aPyramidEditor. + + "Get Save plugin" + shortcutSaveAction savePluginFromPyramid: aPyramidEditor. + + "Get space MainExtension" + shortcutGrid gridFeatureFromSpacePlugin: aPyramidEditor. + + "Get Navigation Plugin for shortcut remove element" + shortcutRemoveElement navigationPluginFromPyramid: aPyramidEditor. + + shortcutSelectAllElement projectModelFromPyramid: aPyramidEditor. + + "Get projectModelFromPyramid for Inspect selected element" + shortcutInspectSelectedElement projectModelFromPyramid: aPyramidEditor. + + "Adding shortcut to Pyramid" + spacePlugin resetShortcutBlock: [ :aSpace | self refreshAllShortcutInSpace: aSpace ]. + spacePlugin resetSpace. +] + +{ #category : #initialization } +PyramidSpaceShortcutManagerPlugin >> initialize [ + + shortcutCollection := OrderedCollection new. + + shortcutUndoRedo := PyramidSpaceShortcutUndoRedo new. + shortcutCopyPaste := PyramidSpaceShortcutCopyPasteCut new. + shortcutSaveAction := PyramidSpaceShortcutSave new. + shortcutGrid := PyramidSpaceShortcutGrid new. + shortcutRemoveElement := PyramidSpaceShortcutRemoveElement new. + shortcutSelectAllElement := PyramidSpaceShortcutSelectAllElement new. + shortcutInspectSelectedElement := PyramidSpaceShortcutInspectSelectedElement new. +] + +{ #category : #action } +PyramidSpaceShortcutManagerPlugin >> refreshAllShortcutInSpace: aSpace [ + + self removeAllShortcutInSpace: aSpace. + self addAllShortcutInSpace: aSpace. + + +] + +{ #category : #removing } +PyramidSpaceShortcutManagerPlugin >> removeAllShortcutInSpace: aSpace [ + + shortcutCollection do: [ :shortcut | aSpace root removeShortcut: shortcut ]. + shortcutCollection removeAll. +] diff --git a/src/Pyramid-Bloc/PyramidSpaceShortcutRemoveElement.class.st b/src/Pyramid-Bloc/PyramidSpaceShortcutRemoveElement.class.st new file mode 100644 index 00000000..e90b4a44 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidSpaceShortcutRemoveElement.class.st @@ -0,0 +1,49 @@ +" +This class define the shortcut to delete a selected element in the space. + +it use the plugin-navigation in this package. +" +Class { + #name : #PyramidSpaceShortcutRemoveElement, + #superclass : #PyramidSpaceShortcutManagerPlugin, + #instVars : [ + 'navigationPlugin', + 'shortcutActionRemoveElement', + 'keyCombinationRemoveElement' + ], + #category : #'Pyramid-Bloc-plugin-shortcut-manager' +} + +{ #category : #accessing } +PyramidSpaceShortcutRemoveElement >> defaultKeyCombinationRemoveElement [ + "suppr / del to activate this shortcut" + keyCombinationRemoveElement := ((BlKeyCombination builder key: KeyboardKey delete) build) +] + +{ #category : #initialization } +PyramidSpaceShortcutRemoveElement >> initialize [ + + self defaultKeyCombinationRemoveElement +] + +{ #category : #accessing } +PyramidSpaceShortcutRemoveElement >> keyCombinationRemoveElement: aKeyCombination [ + + keyCombinationRemoveElement := aKeyCombination +] + +{ #category : #'accessing - classes' } +PyramidSpaceShortcutRemoveElement >> navigationPluginFromPyramid: aPyramidEditor [ + + navigationPlugin := aPyramidEditor findPlugin: PyramidNavigationPlugin. +] + +{ #category : #accessing } +PyramidSpaceShortcutRemoveElement >> shortcutActionRemoveElement [ + + ^ shortcutActionRemoveElement := BlShortcutWithAction new + name: 'Pyramid edition shortcut remove selected element'; + combination: keyCombinationRemoveElement; + action: [ :event | navigationPlugin ifNil: [ self inform: 'Plugin navigation is not installed' ] + ifNotNil: [ navigationPlugin removeSelectedElements ] ] +] diff --git a/src/Pyramid-Bloc/PyramidSpaceShortcutSave.class.st b/src/Pyramid-Bloc/PyramidSpaceShortcutSave.class.st new file mode 100644 index 00000000..5ab40a75 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidSpaceShortcutSave.class.st @@ -0,0 +1,50 @@ +" +This class used to create shortcut for saving in Pyramid space. + +Used the plugin-save in this package. +" +Class { + #name : #PyramidSpaceShortcutSave, + #superclass : #PyramidSpaceShortcutManagerPlugin, + #instVars : [ + 'savePlugin', + 'shortcutSave', + 'keyCombinationSave' + ], + #category : #'Pyramid-Bloc-plugin-shortcut-manager' +} + +{ #category : #accessing } +PyramidSpaceShortcutSave >> defaultKeyCombinationSave [ + "CTRL + S to activate this shortcut" + keyCombinationSave := ((BlKeyCombination builder primary key: KeyboardKey S) build) +] + +{ #category : #initialization } +PyramidSpaceShortcutSave >> initialize [ + + self defaultKeyCombinationSave +] + +{ #category : #accessing } +PyramidSpaceShortcutSave >> keyCombinationSave: aKeyCombination [ + + ^ keyCombinationSave := aKeyCombination +] + +{ #category : #'accessing - classes' } +PyramidSpaceShortcutSave >> savePluginFromPyramid: aPyramidEditor [ + + savePlugin := aPyramidEditor findPlugin: PyramidSavePlugin. +] + +{ #category : #accessing } +PyramidSpaceShortcutSave >> shortcutActionSave [ + + ^ shortcutSave := BlShortcutWithAction new + name: 'Pyramid edition shortcut save'; + combination: keyCombinationSave; + action: [ :event | savePlugin + ifNil: [ self inform: 'Plugin save is not installed' ] + ifNotNil: [ savePlugin saveAction ] ] +] diff --git a/src/Pyramid-Bloc/PyramidSpaceShortcutSelectAllElement.class.st b/src/Pyramid-Bloc/PyramidSpaceShortcutSelectAllElement.class.st new file mode 100644 index 00000000..359da9c2 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidSpaceShortcutSelectAllElement.class.st @@ -0,0 +1,65 @@ +" +This class used to create shortcut for select all element or all children from one selected element in Pyramid space. +" +Class { + #name : #PyramidSpaceShortcutSelectAllElement, + #superclass : #PyramidSpaceShortcutManagerPlugin, + #instVars : [ + 'keyCombinationSelectAll', + 'shortcutSelectAll', + 'projectModel' + ], + #category : #'Pyramid-Bloc-plugin-shortcut-manager' +} + +{ #category : #accessing } +PyramidSpaceShortcutSelectAllElement >> defaultKeyCombinationSelectAll [ + "CTRL + A to activate this shortcut" + keyCombinationSelectAll := ((BlKeyCombination builder primary key: KeyboardKey A) build) +] + +{ #category : #initialization } +PyramidSpaceShortcutSelectAllElement >> initialize [ + + self defaultKeyCombinationSelectAll +] + +{ #category : #'accessing - classes' } +PyramidSpaceShortcutSelectAllElement >> projectModelFromPyramid: aPyramidEditor [ + + projectModel := aPyramidEditor projectModel. +] + +{ #category : #action } +PyramidSpaceShortcutSelectAllElement >> selectAll [ + + projectModel selection asArray isEmpty + ifTrue: [ self selectAllElementInSpace ]. + projectModel selection asArray size = 1 + ifTrue: [ self selectAllChildrenOfSelectedElement ]. +] + +{ #category : #action } +PyramidSpaceShortcutSelectAllElement >> selectAllChildrenOfSelectedElement [ + + (projectModel selection collection asArray first) children isEmpty + ifTrue: [ self inform: 'No children to select in the selected element' ] + ifFalse: [ projectModel setSelection: (projectModel selection collection asArray first) children ] + +] + +{ #category : #action } +PyramidSpaceShortcutSelectAllElement >> selectAllElementInSpace [ + + projectModel setSelection: projectModel firstLevelElements collection +] + +{ #category : #accessing } +PyramidSpaceShortcutSelectAllElement >> shortcutActionSelectAll [ + + ^ shortcutSelectAll := BlShortcutWithAction new + name: 'Pyramid edition shortcut to select all element in space'; + combination: keyCombinationSelectAll; + action: [ :event | projectModel ifNil: [ self inform: 'problem with the project model' ] + ifNotNil: [ self selectAll ] ] +] diff --git a/src/Pyramid-Bloc/PyramidSpaceShortcutUndoRedo.class.st b/src/Pyramid-Bloc/PyramidSpaceShortcutUndoRedo.class.st new file mode 100644 index 00000000..bd6c39e3 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidSpaceShortcutUndoRedo.class.st @@ -0,0 +1,78 @@ +" +Class use to create the shortcut undo / redo. + +Use the history feature from the package Pyramid. +" +Class { + #name : #PyramidSpaceShortcutUndoRedo, + #superclass : #PyramidSpaceShortcutManagerPlugin, + #instVars : [ + 'historyPlugin', + 'shortcutUndo', + 'keyCombinationUndo', + 'shortcutRedo', + 'keyCombinationRedo' + ], + #category : #'Pyramid-Bloc-plugin-shortcut-manager' +} + +{ #category : #accessing } +PyramidSpaceShortcutUndoRedo >> defaultKeyCombinationRedo [ + "CTRL + Y to activate this shortcut" + keyCombinationRedo := ((BlKeyCombination builder primary key: KeyboardKey Y) build) +] + +{ #category : #accessing } +PyramidSpaceShortcutUndoRedo >> defaultKeyCombinationUndo [ + "CTRL + Z to activate this shortcut" + keyCombinationUndo := ((BlKeyCombination builder primary key: KeyboardKey Z) build) +] + +{ #category : #'accessing - classes' } +PyramidSpaceShortcutUndoRedo >> historyPluginFromPyramid: aPyramidEditor [ + + historyPlugin := aPyramidEditor findPlugin: PyramidHistoryPlugin. +] + +{ #category : #initialization } +PyramidSpaceShortcutUndoRedo >> initialize [ + + self defaultKeyCombinationRedo. + self defaultKeyCombinationUndo. +] + +{ #category : #accessing } +PyramidSpaceShortcutUndoRedo >> keyCombinationRedo: aNewKeyCombination [ + + ^ keyCombinationRedo := aNewKeyCombination +] + +{ #category : #accessing } +PyramidSpaceShortcutUndoRedo >> keyCombinationUndo: aNewKeyCombination [ + + ^ keyCombinationUndo := aNewKeyCombination +] + +{ #category : #accessing } +PyramidSpaceShortcutUndoRedo >> shortcutActionRedo [ + + ^ shortcutRedo := BlShortcutWithAction new + name: 'Pyramid edition shortcut redo'; + combination: keyCombinationRedo; + action: [ :event | historyPlugin + ifNil: [ self inform: 'Plugin undo/redo is not installed' ] + ifNotNil: [ historyPlugin history redo. + historyPlugin projectModel informElementsChanged ] ] +] + +{ #category : #accessing } +PyramidSpaceShortcutUndoRedo >> shortcutActionUndo [ + + ^ shortcutUndo := BlShortcutWithAction new + name: 'Pyramid edition shortcut undo'; + combination: keyCombinationUndo; + action: [ :event | historyPlugin + ifNil: [ self inform: 'Plugin undo/redo is not installed' ] + ifNotNil: [ historyPlugin history undo. + historyPlugin projectModel informElementsChanged ] ] +]