Skip to content

Commit

Permalink
Merge pull request #35 from adri09070/33-Chests-clipboard-has-a-buffe…
Browse files Browse the repository at this point in the history
…r-of-one-which-is-not-enough

implementing a clipboard chest with a maximum size
  • Loading branch information
StevenCostiou authored May 3, 2024
2 parents fb88f9f + 60f1aa8 commit 029ce79
Show file tree
Hide file tree
Showing 56 changed files with 1,071 additions and 614 deletions.
15 changes: 8 additions & 7 deletions src/Chest-Commands/ChestAddNewChestCommand.class.st
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
Class {
#name : #ChestAddNewChestCommand,
#superclass : #ChestCommand,
#category : #'Chest-Commands'
#name : 'ChestAddNewChestCommand',
#superclass : 'ChestCommand',
#category : 'Chest-Commands',
#package : 'Chest-Commands'
}

{ #category : #default }
{ #category : 'default' }
ChestAddNewChestCommand class >> defaultDescription [

^ 'Request the naming of a new chest and create it'
]

{ #category : #default }
{ #category : 'default' }
ChestAddNewChestCommand class >> defaultIconName [

^ #add
]

{ #category : #default }
{ #category : 'default' }
ChestAddNewChestCommand class >> defaultName [

^ 'Add chest'
]

{ #category : #executing }
{ #category : 'executing' }
ChestAddNewChestCommand >> execute [

^ context requestNameNewChest
Expand Down
17 changes: 9 additions & 8 deletions src/Chest-Commands/ChestAddNewItemCommand.class.st
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
Class {
#name : #ChestAddNewItemCommand,
#superclass : #ChestCommand,
#category : #'Chest-Commands'
#name : 'ChestAddNewItemCommand',
#superclass : 'ChestCommand',
#category : 'Chest-Commands',
#package : 'Chest-Commands'
}

{ #category : #default }
{ #category : 'default' }
ChestAddNewItemCommand class >> defaultDescription [

^ 'Request an expression whose result will be stored inside the selected chest'
]

{ #category : #default }
{ #category : 'default' }
ChestAddNewItemCommand class >> defaultIconName [

^ #add
]

{ #category : #default }
{ #category : 'default' }
ChestAddNewItemCommand class >> defaultName [

^ 'Add item'
]

{ #category : #testing }
{ #category : 'testing' }
ChestAddNewItemCommand >> canBeExecuted [

^ context selectedChest isNotNil
]

{ #category : #executing }
{ #category : 'executing' }
ChestAddNewItemCommand >> execute [

^ context requestExpressionToStoreInChest
Expand Down
31 changes: 16 additions & 15 deletions src/Chest-Commands/ChestCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@
Abstract class whose subclasses are all commands for `Chest`. It is also an utility class that provides on class side groups of commands that can be used to create Commander command groups.
"
Class {
#name : #ChestCommand,
#superclass : #CmCommand,
#category : #'Chest-Commands'
#name : 'ChestCommand',
#superclass : 'CmCommand',
#category : 'Chest-Commands',
#package : 'Chest-Commands'
}

{ #category : #'accessing - commands classes' }
{ #category : 'accessing - commands classes' }
ChestCommand class >> chestCodePresenterCommandClasses [

^ { ChestLoadObjectIntoCodeCommand }
]

{ #category : #'accessing - commands classes' }
{ #category : 'accessing - commands classes' }
ChestCommand class >> chestLoadChestCommandClasses [

^ {
ChestLoadBindingsInPlaygroundCommand.
ChestLoadBindingsFromAllChestsInPlaygroundCommand }
]

{ #category : #'accessing - commands classes' }
{ #category : 'accessing - commands classes' }
ChestCommand class >> chestLoadItemCommandClasses [

^ { ChestLoadSingleBindingInPlaygroundCommand }
]

{ #category : #'accessing - commands classes' }
{ #category : 'accessing - commands classes' }
ChestCommand class >> chestTableContentMenuCommandClasses [

^ {
Expand All @@ -38,15 +39,15 @@ ChestCommand class >> chestTableContentMenuCommandClasses [
ChestRemoveAllItemsInChestCommand }
]

{ #category : #'accessing - commands classes' }
{ #category : 'accessing - commands classes' }
ChestCommand class >> chestTableContentToolbarCommandClasses [

^ {
ChestAddNewItemCommand.
ChestRemoveItemCommand }
]

{ #category : #'accessing - commands classes' }
{ #category : 'accessing - commands classes' }
ChestCommand class >> chestTableMenuCommandClasses [

^ {
Expand All @@ -57,42 +58,42 @@ ChestCommand class >> chestTableMenuCommandClasses [
ChestRemoveAllChestsCommand }
]

{ #category : #'accessing - commands classes' }
{ #category : 'accessing - commands classes' }
ChestCommand class >> chestTableToolbarCommandClasses [

^ {
ChestAddNewChestCommand.
ChestRemoveChestCommand }
]

{ #category : #'accessing - commands classes' }
{ #category : 'accessing - commands classes' }
ChestCommand class >> chestTreeTableMenuCommandClasses [

^ self chestTableMenuCommandClasses
, self chestTableContentMenuCommandClasses
]

{ #category : #'accessing - commands classes' }
{ #category : 'accessing - commands classes' }
ChestCommand class >> chestTreeTableToolbarCommandClasses [

^ {
ChestAddNewChestCommand.
ChestRemoveAllChestsCommand }
]

{ #category : #default }
{ #category : 'default' }
ChestCommand class >> defaultIconName [

^ nil
]

{ #category : #default }
{ #category : 'default' }
ChestCommand class >> defaultShortcutKey [

^ nil
]

{ #category : #default }
{ #category : 'default' }
ChestCommand class >> isVisibleForContext: aSpecContext [

^ true
Expand Down
35 changes: 18 additions & 17 deletions src/Chest-Commands/ChestCommandTreeBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,43 @@
Class that builds the group of Chest commands for the `SpCodePresenter` context menu.
"
Class {
#name : #ChestCommandTreeBuilder,
#superclass : #Object,
#name : 'ChestCommandTreeBuilder',
#superclass : 'Object',
#instVars : [
'rootCommandGroup',
'codePresenter'
],
#category : #'Chest-Commands'
#category : 'Chest-Commands',
#package : 'Chest-Commands'
}

{ #category : #accessing }
{ #category : 'accessing' }
ChestCommandTreeBuilder class >> buildCommandsGroupWith: aCodePresenter forRoot: aRootCommandGroup [

self new
buildCommandsGroupWith: aCodePresenter
forRoot: aRootCommandGroup
]

{ #category : #accessing }
{ #category : 'accessing' }
ChestCommandTreeBuilder class >> displayStrategy [

^ CmUIDisplayAsSubMenu
]

{ #category : #accessing }
{ #category : 'accessing' }
ChestCommandTreeBuilder class >> groupDescription [

^ 'Actions interacting with Chest'
]

{ #category : #accessing }
{ #category : 'accessing' }
ChestCommandTreeBuilder class >> groupName [

^ 'Chest'
]

{ #category : #building }
{ #category : 'building' }
ChestCommandTreeBuilder >> buildAndRegisterGroup [

"builds the group that will register under the provided root command group"
Expand All @@ -50,7 +51,7 @@ ChestCommandTreeBuilder >> buildAndRegisterGroup [
^ group
]

{ #category : #building }
{ #category : 'building' }
ChestCommandTreeBuilder >> buildChestCommandGroup [

self chestCommandClasses do: [ :commandClass |
Expand All @@ -60,15 +61,15 @@ ChestCommandTreeBuilder >> buildChestCommandGroup [
self group beDisplayedAsGroup
]

{ #category : #building }
{ #category : 'building' }
ChestCommandTreeBuilder >> buildCommandsGroupWith: aCodePresenter forRoot: aRootCommandGroup [

codePresenter := aCodePresenter.
rootCommandGroup := aRootCommandGroup.
self buildChestCommandGroup
]

{ #category : #building }
{ #category : 'building' }
ChestCommandTreeBuilder >> buildPasteLoadCodeGroup [

| specGroup allChests subSpecGroup |
Expand All @@ -89,13 +90,13 @@ ChestCommandTreeBuilder >> buildPasteLoadCodeGroup [
^ specGroup
]

{ #category : #building }
{ #category : 'building' }
ChestCommandTreeBuilder >> buildSpecCommand: commandClass forContext: aContext [

^ commandClass forSpecContext: aContext
]

{ #category : #building }
{ #category : 'building' }
ChestCommandTreeBuilder >> chestCommandClasses [

^ {
Expand All @@ -104,27 +105,27 @@ ChestCommandTreeBuilder >> chestCommandClasses [
each isVisibleForContext: codePresenter ]
]

{ #category : #accessing }
{ #category : 'accessing' }
ChestCommandTreeBuilder >> displayStrategy [

^ self class displayStrategy new
]

{ #category : #accessing }
{ #category : 'accessing' }
ChestCommandTreeBuilder >> group [

^ rootCommandGroup
commandOrGroupNamed: self groupName
ifNone: [ self buildAndRegisterGroup ]
]

{ #category : #accessing }
{ #category : 'accessing' }
ChestCommandTreeBuilder >> groupDescription [

^ self class groupDescription
]

{ #category : #accessing }
{ #category : 'accessing' }
ChestCommandTreeBuilder >> groupName [

^ self class groupName
Expand Down
23 changes: 9 additions & 14 deletions src/Chest-Commands/ChestCopyObjectCommand.class.st
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
Class {
#name : #ChestCopyObjectCommand,
#superclass : #SpCodeSelectionCommand,
#category : #'Chest-Commands'
#name : 'ChestCopyObjectCommand',
#superclass : 'SpCodeSelectionCommand',
#category : 'Chest-Commands',
#package : 'Chest-Commands'
}

{ #category : #default }
{ #category : 'default' }
ChestCopyObjectCommand class >> defaultDescription [

^ 'Store the result of the selected expression in a clipboard chest to paste it later'
]

{ #category : #defaults }
{ #category : 'defaults' }
ChestCopyObjectCommand class >> defaultIconName [

^ #smallCopy
]

{ #category : #default }
{ #category : 'default' }
ChestCopyObjectCommand class >> defaultName [

^ 'Copy object in a clipboard chest'
]

{ #category : #executing }
{ #category : 'executing' }
ChestCopyObjectCommand >> execute [

self evaluateSelectionAndDo: [ :result |
[ ClipboardChest at: ClipboardChest clipboardEntryName put: result ]
on: ChestKeyAlreadyInUseError
do: [
ClipboardChest removeObjectNamed:
ClipboardChest clipboardEntryName.
ClipboardChest at: ClipboardChest clipboardEntryName put: result ] ]
self evaluateSelectionAndDo: [ :result | ClipboardChest add: result ]
]
Loading

0 comments on commit 029ce79

Please sign in to comment.