From 794b005a05407306ec5778851c68cbefdb3aed2d Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Tue, 1 Aug 2023 10:27:33 +0200 Subject: [PATCH 01/16] making custom layouts possible for the main Chest window --- src/Chest/ChestPresenter.class.st | 128 +++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 3 deletions(-) diff --git a/src/Chest/ChestPresenter.class.st b/src/Chest/ChestPresenter.class.st index 0670ed1..671f509 100644 --- a/src/Chest/ChestPresenter.class.st +++ b/src/Chest/ChestPresenter.class.st @@ -11,7 +11,15 @@ Class { 'chestsTable', 'chestContentsTable', 'inspector', - 'chestTableWithContent' + 'chestTableWithContent', + 'showPlaygroundButton', + 'showInspectorButton', + 'showPlaygroundContainer', + 'showInspectorContainer' + ], + #classVars : [ + 'ShowInspector', + 'ShowPlayground' ], #category : #Chest } @@ -58,6 +66,28 @@ ChestPresenter class >> buildLoadItemCommandGroup: aChestWithContentPresenter fo aRoot register: group ] +{ #category : #settings } +ChestPresenter class >> chestSettingsOn: aBuilder [ + + + (aBuilder group: #ChestTool) + label: 'Chest'; + parent: #tools; + description: 'Settings related to the Chest tool'; + with: [ + (aBuilder setting: #showPlayground) + label: 'Shows playground in Chest'; + target: self; + default: self showPlayground; + description: 'Shows a playground below chests and their contents.'. + (aBuilder setting: #showInspector) + label: 'Shows inspector in Chest'; + target: self; + default: self showInspector; + description: + 'Shows an inspector on the right to chests and their contents, on the selected chest item' ] +] + { #category : #'menu-entry' } ChestPresenter class >> debugWorldMenuOn: aBuilder [ @@ -109,6 +139,30 @@ ChestPresenter class >> registerClasses: commandClasses toGroup: aGroup withCont beHiddenWhenCantBeRun) ] ] +{ #category : #accessing } +ChestPresenter class >> showInspector [ + + ^ ShowInspector ifNil: [ ShowInspector := false ] +] + +{ #category : #accessing } +ChestPresenter class >> showInspector: anObject [ + + ^ ShowInspector := anObject +] + +{ #category : #accessing } +ChestPresenter class >> showPlayground [ + + ^ ShowPlayground ifNil: [ ShowPlayground := false ] +] + +{ #category : #accessing } +ChestPresenter class >> showPlayground: anObject [ + + ^ ShowPlayground := anObject +] + { #category : #visiting } ChestPresenter >> accept: aVisitor [ @@ -202,12 +256,28 @@ ChestPresenter >> defaultLayout [ ^ SpPanedLayout newHorizontal add: (SpPanedLayout newVertical add: #chestTableWithContent; - add: #playground; + add: showPlaygroundContainer; yourself); - add: #inspector; + add: showInspectorContainer; yourself ] +{ #category : #layout } +ChestPresenter >> displayInspector [ + + self class showInspector: true. + showInspectorContainer add: inspector. + showInspectorButton icon: (self application iconNamed: #enable) +] + +{ #category : #layout } +ChestPresenter >> displayPlayground [ + + self class showPlayground: true. + showPlaygroundContainer add: playground. + showPlaygroundButton icon: (self application iconNamed: #enable) +] + { #category : #layout } ChestPresenter >> headerLayoutWithTitle: aString withToolbar: aToolbar [ @@ -217,6 +287,22 @@ ChestPresenter >> headerLayoutWithTitle: aString withToolbar: aToolbar [ yourself ] +{ #category : #layout } +ChestPresenter >> hideInspector [ + + self class showInspector: false. + showInspectorContainer remove: inspector. + showInspectorButton icon: (self application iconNamed: #disable) +] + +{ #category : #layout } +ChestPresenter >> hidePlayground [ + + self class showPlayground: false. + showPlaygroundContainer remove: playground. + showPlaygroundButton icon: (self application iconNamed: #disable ) +] + { #category : #helper } ChestPresenter >> iconManager [ @@ -248,6 +334,8 @@ ChestPresenter >> initializePresenters [ chestsTable selectIndex: 1. self makeChestTreeTableContextMenu. + + self makeExpandableLayouts. self layout: self defaultLayout ] @@ -356,6 +444,40 @@ ChestPresenter >> makeChestsTable [ yourself ] +{ #category : #'presenter building' } +ChestPresenter >> makeExpandableLayouts [ + + showPlaygroundContainer := SpBoxLayout newVertical. + showPlaygroundButton := self newToggleButton + state: self class showPlayground; + icon: (self application iconNamed: #disable); + yourself. + + showPlaygroundContainer add: showPlaygroundButton expand: false. + self class showPlayground ifTrue: [ + showPlaygroundContainer add: playground. + showPlaygroundButton icon: (self application iconNamed: #enable) ]. + + showInspectorContainer := SpBoxLayout newHorizontal. + showInspectorButton := self newToggleButton + state: self class showInspector; + icon: (self application iconNamed: #disable); + yourself. + + showInspectorContainer add: showInspectorButton expand: false. + self class showInspector ifTrue: [ + showInspectorContainer add: inspector. + showInspectorButton icon: (self application iconNamed: #enable) ]. + + showPlaygroundButton + whenActivatedDo: [ self displayPlayground ]; + whenDeactivatedDo: [ self hidePlayground ]. + + showInspectorButton + whenActivatedDo: [ self displayInspector ]; + whenDeactivatedDo: [ self hideInspector ] +] + { #category : #'presenter building' } ChestPresenter >> makePlayground [ From 574bd15eb8c048a2a4ccdf88588b6d2793cc6c58 Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Tue, 1 Aug 2023 13:39:10 +0200 Subject: [PATCH 02/16] making cleaner expandable layouts --- src/Chest/ChestPresenter.class.st | 65 ++++++++++++++++++------------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/src/Chest/ChestPresenter.class.st b/src/Chest/ChestPresenter.class.st index 671f509..02f8ba0 100644 --- a/src/Chest/ChestPresenter.class.st +++ b/src/Chest/ChestPresenter.class.st @@ -15,7 +15,8 @@ Class { 'showPlaygroundButton', 'showInspectorButton', 'showPlaygroundContainer', - 'showInspectorContainer' + 'showInspectorContainer', + 'globalContainer' ], #classVars : [ 'ShowInspector', @@ -253,20 +254,20 @@ ChestPresenter >> defaultLayout [ makeChestsTable; makeChestContentsTable. - ^ SpPanedLayout newHorizontal - add: (SpPanedLayout newVertical - add: #chestTableWithContent; - add: showPlaygroundContainer; - yourself); - add: showInspectorContainer; - yourself + ^ globalContainer ] { #category : #layout } ChestPresenter >> displayInspector [ - self class showInspector: true. - showInspectorContainer add: inspector. + showInspectorContainer := SpBoxLayout newHorizontal + add: showInspectorButton expand: false; + add: inspector; + yourself. + globalContainer := SpPanedLayout newHorizontal + add: showPlaygroundContainer; + add: showInspectorContainer; + yourself. showInspectorButton icon: (self application iconNamed: #enable) ] @@ -290,8 +291,12 @@ ChestPresenter >> headerLayoutWithTitle: aString withToolbar: aToolbar [ { #category : #layout } ChestPresenter >> hideInspector [ - self class showInspector: false. - showInspectorContainer remove: inspector. + showInspectorContainer := showInspectorButton. + globalContainer := SpBoxLayout newHorizontal + add: showPlaygroundContainer; + add: showInspectorContainer expand: false; + yourself. + "showInspectorContainer remove: inspector." showInspectorButton icon: (self application iconNamed: #disable) ] @@ -447,35 +452,43 @@ ChestPresenter >> makeChestsTable [ { #category : #'presenter building' } ChestPresenter >> makeExpandableLayouts [ - showPlaygroundContainer := SpBoxLayout newVertical. showPlaygroundButton := self newToggleButton state: self class showPlayground; icon: (self application iconNamed: #disable); yourself. + showPlaygroundContainer := SpBoxLayout newVertical + add: #chestTableWithContent; + add: showPlaygroundButton expand: false; + yourself. - showPlaygroundContainer add: showPlaygroundButton expand: false. - self class showPlayground ifTrue: [ - showPlaygroundContainer add: playground. - showPlaygroundButton icon: (self application iconNamed: #enable) ]. + self class showPlayground ifTrue: [ self displayPlayground ]. - showInspectorContainer := SpBoxLayout newHorizontal. showInspectorButton := self newToggleButton state: self class showInspector; icon: (self application iconNamed: #disable); yourself. - showInspectorContainer add: showInspectorButton expand: false. - self class showInspector ifTrue: [ - showInspectorContainer add: inspector. - showInspectorButton icon: (self application iconNamed: #enable) ]. + self class showInspector + ifTrue: [ self displayInspector ] + ifFalse: [ self hideInspector ]. showPlaygroundButton - whenActivatedDo: [ self displayPlayground ]; - whenDeactivatedDo: [ self hidePlayground ]. + whenActivatedDo: [ + self class showPlayground: true. + self displayPlayground ]; + whenDeactivatedDo: [ + self class showPlayground: false. + self hidePlayground ]. showInspectorButton - whenActivatedDo: [ self displayInspector ]; - whenDeactivatedDo: [ self hideInspector ] + whenActivatedDo: [ + self class showInspector: true. + self displayInspector. + self layout: globalContainer ]; + whenDeactivatedDo: [ + self class showInspector: false. + self hideInspector. + self layout: globalContainer ] ] { #category : #'presenter building' } From 1a8e653d8c9ea9185cfccdb24595e1efbc02ce05 Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Tue, 1 Aug 2023 14:32:42 +0200 Subject: [PATCH 03/16] turning the chest list to a table --- src/Chest/ChestTableWithContentPresenter.class.st | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Chest/ChestTableWithContentPresenter.class.st b/src/Chest/ChestTableWithContentPresenter.class.st index e5d5749..da5e26a 100644 --- a/src/Chest/ChestTableWithContentPresenter.class.st +++ b/src/Chest/ChestTableWithContentPresenter.class.st @@ -566,11 +566,19 @@ ChestTableWithContentPresenter >> makeChestWithContentTreeTable [ { #category : #'presenter building' } ChestTableWithContentPresenter >> makeChestsTable [ - chestsTable := self newList + chestsTable := self newTable items: Chest allChests; - display: [ :chest | chest name ]; - sortingBlock: [ :chest1 :chest2 | + addColumn: + (SpStringTableColumn + title: 'Name' + evaluated: [ :chest | chest name ]) beExpandable; + addColumn: ((SpStringTableColumn + title: 'Size' + evaluated: [ :chest | + chest contents size asString ]) width: 40); + sortingBlock: [ :chest1 :chest2 | chest1 name < chest2 name ]; + beResizable; yourself. self makeChestTableContextMenu ] From a0120f59f4ba4ef8d9d3bc6c4615e928b4aa79c2 Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Tue, 1 Aug 2023 14:39:24 +0200 Subject: [PATCH 04/16] cleaner layout for "store" and "load" commands pop-ups --- src/Chest/ChestTableWithContentPresenter.class.st | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Chest/ChestTableWithContentPresenter.class.st b/src/Chest/ChestTableWithContentPresenter.class.st index da5e26a..2b0541e 100644 --- a/src/Chest/ChestTableWithContentPresenter.class.st +++ b/src/Chest/ChestTableWithContentPresenter.class.st @@ -427,7 +427,7 @@ ChestTableWithContentPresenter >> loadCommandLayout [ title: 'Variable Name' evaluated: #variableName) beEditable; - onAcceptEdition: [ :assoc :newVarName | + onAcceptEdition: [ :assoc :newVarName | assoc variableName: newVarName ]; yourself. self makeChestContentsTable. @@ -447,8 +447,9 @@ ChestTableWithContentPresenter >> loadCommandLayout [ add: (SpBoxLayout newHorizontal add: chestsTableToolbar; add: chestContentsTableToolbar; - yourself); - add: confirmActionBar; + yourself) + expand: false; + add: confirmActionBar expand: false; yourself ] @@ -861,7 +862,7 @@ ChestTableWithContentPresenter >> storeCommandLayout [ self chestTableContainer removeAll; - add: inputField; + add: inputField expand: false; add: chestsTable. self chestContentTableContainer removeAll; @@ -872,8 +873,8 @@ ChestTableWithContentPresenter >> storeCommandLayout [ add: (SpBoxLayout newHorizontal add: chestsTableToolbar; add: chestContentsTableToolbar; - yourself); - add: confirmActionBar; + yourself) expand: false; + add: confirmActionBar expand: false; yourself ] From 48e631756174e6a8cd820439dc6a877b34cb91bd Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Tue, 1 Aug 2023 14:46:59 +0200 Subject: [PATCH 05/16] making chest content's table resizable and all its columns expandable --- .../ChestTableWithContentPresenter.class.st | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Chest/ChestTableWithContentPresenter.class.st b/src/Chest/ChestTableWithContentPresenter.class.st index 2b0541e..f771fcc 100644 --- a/src/Chest/ChestTableWithContentPresenter.class.st +++ b/src/Chest/ChestTableWithContentPresenter.class.st @@ -468,15 +468,17 @@ ChestTableWithContentPresenter >> makeChestContentTableContextMenu [ ChestTableWithContentPresenter >> makeChestContentsTable [ chestContentsTable := self newTable - addColumn: ((SpStringTableColumn - title: 'Name' - evaluated: [ :association | - association key ]) width: 40); + addColumn: (SpStringTableColumn + title: 'Name' + evaluated: [ :association | + association key ]) beExpandable; addColumn: (SpStringTableColumn title: 'Object' - evaluated: [ :association | - association value asString ]); - items: #( ) asOrderedCollection. + evaluated: [ :association | + association value asString ]) beExpandable; + items: #( ) asOrderedCollection; + beResizable; + yourself. self makeChestContentTableContextMenu ] From d296afab7ef49d1cffeec32c3cf089112b45f67e Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Tue, 1 Aug 2023 15:48:19 +0200 Subject: [PATCH 06/16] adding the class of each object to the chest content's table --- src/Chest/ChestTableWithContentPresenter.class.st | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Chest/ChestTableWithContentPresenter.class.st b/src/Chest/ChestTableWithContentPresenter.class.st index f771fcc..8f5c7ed 100644 --- a/src/Chest/ChestTableWithContentPresenter.class.st +++ b/src/Chest/ChestTableWithContentPresenter.class.st @@ -473,9 +473,15 @@ ChestTableWithContentPresenter >> makeChestContentsTable [ evaluated: [ :association | association key ]) beExpandable; addColumn: (SpStringTableColumn - title: 'Object' + title: 'Value' evaluated: [ :association | - association value asString ]) beExpandable; + association value printString ]) + beExpandable; + addColumn: (SpStringTableColumn + title: 'Class' + evaluated: [ :association | + association value class printString ]) + beExpandable; items: #( ) asOrderedCollection; beResizable; yourself. From 5ee9dedfe4da8ba2df99f638d9d023438f472e28 Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Tue, 1 Aug 2023 16:04:00 +0200 Subject: [PATCH 07/16] fixing a weird bug that could cause to display several playgrounds after clicking the show/hide inspector button --- src/Chest/ChestPresenter.class.st | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Chest/ChestPresenter.class.st b/src/Chest/ChestPresenter.class.st index 02f8ba0..b877823 100644 --- a/src/Chest/ChestPresenter.class.st +++ b/src/Chest/ChestPresenter.class.st @@ -274,7 +274,6 @@ ChestPresenter >> displayInspector [ { #category : #layout } ChestPresenter >> displayPlayground [ - self class showPlayground: true. showPlaygroundContainer add: playground. showPlaygroundButton icon: (self application iconNamed: #enable) ] @@ -303,9 +302,8 @@ ChestPresenter >> hideInspector [ { #category : #layout } ChestPresenter >> hidePlayground [ - self class showPlayground: false. showPlaygroundContainer remove: playground. - showPlaygroundButton icon: (self application iconNamed: #disable ) + showPlaygroundButton icon: (self application iconNamed: #disable) ] { #category : #helper } @@ -449,7 +447,7 @@ ChestPresenter >> makeChestsTable [ yourself ] -{ #category : #'presenter building' } +{ #category : #layout } ChestPresenter >> makeExpandableLayouts [ showPlaygroundButton := self newToggleButton @@ -478,7 +476,9 @@ ChestPresenter >> makeExpandableLayouts [ self displayPlayground ]; whenDeactivatedDo: [ self class showPlayground: false. - self hidePlayground ]. + self hidePlayground. + "not satisfied with this but, for obscure reasons, the layout won't update automatically if wer hide the playground after displaying or hiding the inspector. It still displays automatically the playground though, leading to having several playgrounds. I need to force the layout update to prevent that, though I don't really understand why I need to do that. Probably a Spec bug" + self layout: globalContainer ]. showInspectorButton whenActivatedDo: [ From 4af2aaf4c79ac84b02dd7e4d41abab4135961b83 Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Wed, 2 Aug 2023 09:28:41 +0200 Subject: [PATCH 08/16] removing "not so important buttons" from toolbars + adding all actions to context menus --- src/Chest-Commands/ChestCommand.class.st | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Chest-Commands/ChestCommand.class.st b/src/Chest-Commands/ChestCommand.class.st index 3978460..7e9ea33 100644 --- a/src/Chest-Commands/ChestCommand.class.st +++ b/src/Chest-Commands/ChestCommand.class.st @@ -40,9 +40,7 @@ ChestCommand class >> chestTableContentMenuCommandClasses [ { #category : #'accessing - commands classes' } ChestCommand class >> chestTableContentToolbarCommandClasses [ - ^ { - ChestRemoveItemCommand. - ChestRemoveAllItemsInChestCommand } + ^ { ChestRemoveItemCommand } ] { #category : #'accessing - commands classes' } @@ -50,6 +48,7 @@ ChestCommand class >> chestTableMenuCommandClasses [ ^ { ChestRenameChestCommand. + ChestAddNewChestCommand. ChestRemoveChestCommand. ChestRemoveAllChestsCommand } ] @@ -57,10 +56,9 @@ ChestCommand class >> chestTableMenuCommandClasses [ { #category : #'accessing - commands classes' } ChestCommand class >> chestTableToolbarCommandClasses [ - ^ { + ^ { ChestAddNewChestCommand. - ChestRemoveChestCommand. - ChestRemoveAllChestsCommand } + ChestRemoveChestCommand } ] { #category : #'accessing - commands classes' } From 5df60e396ff17f6c68b7d38344e878c142ca3d05 Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:06:20 +0200 Subject: [PATCH 09/16] Adding a command to add a new item to a chest, based on an expression. And adding this command to the chest content's toolbar and context menu --- .../ChestAddNewItemCommand.class.st | 35 +++++++++++++++++++ src/Chest-Commands/ChestCommand.class.st | 7 ++-- src/Chest/ChestPresenter.class.st | 6 ++++ .../ChestTableWithContentPresenter.class.st | 28 +++++++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 src/Chest-Commands/ChestAddNewItemCommand.class.st diff --git a/src/Chest-Commands/ChestAddNewItemCommand.class.st b/src/Chest-Commands/ChestAddNewItemCommand.class.st new file mode 100644 index 0000000..9461235 --- /dev/null +++ b/src/Chest-Commands/ChestAddNewItemCommand.class.st @@ -0,0 +1,35 @@ +Class { + #name : #ChestAddNewItemCommand, + #superclass : #ChestCommand, + #category : #'Chest-Commands' +} + +{ #category : #default } +ChestAddNewItemCommand class >> defaultDescription [ + + ^ 'Request an expression whose result will be stored inside the selected chest' +] + +{ #category : #default } +ChestAddNewItemCommand class >> defaultIconName [ + + ^ #add +] + +{ #category : #default } +ChestAddNewItemCommand class >> defaultName [ + + ^ 'Add item' +] + +{ #category : #testing } +ChestAddNewItemCommand >> canBeExecuted [ + + ^ context selectedChest isNotNil +] + +{ #category : #executing } +ChestAddNewItemCommand >> execute [ + + ^ context requestExpressionToStoreInChest +] diff --git a/src/Chest-Commands/ChestCommand.class.st b/src/Chest-Commands/ChestCommand.class.st index 7e9ea33..d5be2a6 100644 --- a/src/Chest-Commands/ChestCommand.class.st +++ b/src/Chest-Commands/ChestCommand.class.st @@ -30,9 +30,10 @@ ChestCommand class >> chestLoadItemCommandClasses [ { #category : #'accessing - commands classes' } ChestCommand class >> chestTableContentMenuCommandClasses [ - ^ { + ^ { ChestRenameItemCommand. ChestInspectItemCommand. + ChestAddNewItemCommand. ChestRemoveItemCommand. ChestRemoveAllItemsInChestCommand } ] @@ -40,7 +41,9 @@ ChestCommand class >> chestTableContentMenuCommandClasses [ { #category : #'accessing - commands classes' } ChestCommand class >> chestTableContentToolbarCommandClasses [ - ^ { ChestRemoveItemCommand } + ^ { + ChestAddNewItemCommand. + ChestRemoveItemCommand } ] { #category : #'accessing - commands classes' } diff --git a/src/Chest/ChestPresenter.class.st b/src/Chest/ChestPresenter.class.st index b877823..8ce2fa2 100644 --- a/src/Chest/ChestPresenter.class.st +++ b/src/Chest/ChestPresenter.class.st @@ -540,6 +540,12 @@ ChestPresenter >> renameSelectedItem [ ^ chestTableWithContent renameSelectedItem ] +{ #category : #'ui - dialogs' } +ChestPresenter >> requestExpressionToStoreInChest [ + + chestTableWithContent requestExpressionToStoreInChest +] + { #category : #'ui - dialogs' } ChestPresenter >> requestNameNewChest [ diff --git a/src/Chest/ChestTableWithContentPresenter.class.st b/src/Chest/ChestTableWithContentPresenter.class.st index 8f5c7ed..67e0c8e 100644 --- a/src/Chest/ChestTableWithContentPresenter.class.st +++ b/src/Chest/ChestTableWithContentPresenter.class.st @@ -804,6 +804,24 @@ ChestTableWithContentPresenter >> renameSelectedItem [ ifFalse: [ chestContentsTable ]) ] +{ #category : #'ui - dialogs' } +ChestTableWithContentPresenter >> requestExpressionToStoreInChest [ + + | expression selectedChest expressionName | + selectedChest := self selectedChest. + expression := (UIManager default request: + ('Enter expression to be stored into ''{1}''' + format: { selectedChest name })) ifNil: [ ^ self ]. + expression trim ifEmpty: [ ^ self ]. + expressionName := self + storeExpression: expression + inChest: selectedChest. + UIManager default inform: + ('Object stored into''{1}'' as ''{2}'' successfully' format: { + selectedChest name. + expressionName }) +] + { #category : #'ui - dialogs' } ChestTableWithContentPresenter >> requestNameNewChest [ @@ -886,6 +904,16 @@ ChestTableWithContentPresenter >> storeCommandLayout [ yourself ] +{ #category : #'ui - dialogs' } +ChestTableWithContentPresenter >> storeExpression: expression inChest: aChest [ + + | result | + result := Smalltalk compiler + source: expression; + evaluate. + ^ aChest add: result +] + { #category : #updating } ChestTableWithContentPresenter >> subscribeToChestAnnouncer [ From f8a5404bddf7c73cd732cc9cc8c8634c4b4b415d Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:25:45 +0200 Subject: [PATCH 10/16] adding a command to inspect chests --- src/Chest-Commands/ChestCommand.class.st | 3 +- .../ChestInspectChestCommand.class.st | 41 +++++++++++++++++++ .../ChestInspectItemCommand.class.st | 6 +++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/Chest-Commands/ChestInspectChestCommand.class.st diff --git a/src/Chest-Commands/ChestCommand.class.st b/src/Chest-Commands/ChestCommand.class.st index d5be2a6..8543b37 100644 --- a/src/Chest-Commands/ChestCommand.class.st +++ b/src/Chest-Commands/ChestCommand.class.st @@ -49,8 +49,9 @@ ChestCommand class >> chestTableContentToolbarCommandClasses [ { #category : #'accessing - commands classes' } ChestCommand class >> chestTableMenuCommandClasses [ - ^ { + ^ { ChestRenameChestCommand. + ChestInspectChestCommand. ChestAddNewChestCommand. ChestRemoveChestCommand. ChestRemoveAllChestsCommand } diff --git a/src/Chest-Commands/ChestInspectChestCommand.class.st b/src/Chest-Commands/ChestInspectChestCommand.class.st new file mode 100644 index 0000000..294df81 --- /dev/null +++ b/src/Chest-Commands/ChestInspectChestCommand.class.st @@ -0,0 +1,41 @@ +Class { + #name : #ChestInspectChestCommand, + #superclass : #ChestCommand, + #category : #'Chest-Commands' +} + +{ #category : #default } +ChestInspectChestCommand class >> defaultDescription [ + + ^ 'Inspect the chest' +] + +{ #category : #default } +ChestInspectChestCommand class >> defaultIconName [ + + ^ #glamorousInspect +] + +{ #category : #default } +ChestInspectChestCommand class >> defaultName [ + + ^ 'Inspect chest' +] + +{ #category : #default } +ChestInspectChestCommand class >> defaultShortcutKey [ + + ^ $i meta +] + +{ #category : #testing } +ChestInspectChestCommand >> canBeExecuted [ + + ^ context selectedChest isNotNil +] + +{ #category : #executing } +ChestInspectChestCommand >> execute [ + + context selectedChest inspect +] diff --git a/src/Chest-Commands/ChestInspectItemCommand.class.st b/src/Chest-Commands/ChestInspectItemCommand.class.st index e5ea2dc..89d655f 100644 --- a/src/Chest-Commands/ChestInspectItemCommand.class.st +++ b/src/Chest-Commands/ChestInspectItemCommand.class.st @@ -10,6 +10,12 @@ ChestInspectItemCommand class >> defaultDescription [ ^ 'Inspect the object' ] +{ #category : #default } +ChestInspectItemCommand class >> defaultIconName [ + + ^ #glamorousInspect +] + { #category : #default } ChestInspectItemCommand class >> defaultName [ From 8074593ddb9c4a5a3a456ef01f0e66bfadf067ae Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:41:22 +0200 Subject: [PATCH 11/16] making chest toolbars update automatically --- src/Chest/ChestPresenter.class.st | 6 +- .../ChestTableWithContentPresenter.class.st | 55 ++++++++++++++++--- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/Chest/ChestPresenter.class.st b/src/Chest/ChestPresenter.class.st index 8ce2fa2..6f64123 100644 --- a/src/Chest/ChestPresenter.class.st +++ b/src/Chest/ChestPresenter.class.st @@ -392,9 +392,11 @@ ChestPresenter >> makeChestContentsTable [ self makeChestContentTableContextMenu. ^ chestContentsTable - whenSelectionChangedDo: [ :selection | + whenSelectionChangedDo: [ :selection | + chestTableWithContent chestContentsTableTransmitBlock cull: + selection. inspector model inspectedObject: - (selection selectedItem ifNotNil: [ :association | + (selection selectedItem ifNotNil: [ :association | association value ]). inspector updateList ]; applyKeyBindingsFromMenu: chestContentsTable contextMenu value; diff --git a/src/Chest/ChestTableWithContentPresenter.class.st b/src/Chest/ChestTableWithContentPresenter.class.st index 67e0c8e..b846300 100644 --- a/src/Chest/ChestTableWithContentPresenter.class.st +++ b/src/Chest/ChestTableWithContentPresenter.class.st @@ -18,7 +18,9 @@ Class { 'chestWithContentTreeTable', 'chestTableWithContentContainer', 'activePresenter', - 'chestWithContentTreeTableToolbar' + 'chestWithContentTreeTableToolbar', + 'chestTableToolbarCommandGroup', + 'chestContentsTableToolbarCommandGroup' ], #category : #Chest } @@ -212,6 +214,12 @@ ChestTableWithContentPresenter >> chestContentsTableToolbar [ ^ chestContentsTableToolbar ] +{ #category : #initialization } +ChestTableWithContentPresenter >> chestContentsTableTransmitBlock [ + + ^ [ :selection | self updateChestContentToolbar ] +] + { #category : #accessing } ChestTableWithContentPresenter >> chestTableContainer [ @@ -221,16 +229,18 @@ ChestTableWithContentPresenter >> chestTableContainer [ { #category : #accessing } ChestTableWithContentPresenter >> chestTableTransmitBlock [ - ^ [ :aChest | + ^ [ :aChest | aChest - ifNotNil: [ + ifNotNil: [ self updateChestContentTableForChest: aChest. - chestContentsTable items ifNotEmpty: [ + chestContentsTable items ifNotEmpty: [ chestContentsTable selectIndex: 1 ]. inputField text: aChest nextDefaultNameForObject ] - ifNil: [ + ifNil: [ chestContentsTable items: { } asOrderedCollection. - inputField text: '' ] ] + inputField text: '' ]. + + self updateChestToolbar ] ] { #category : #accessing } @@ -284,7 +294,9 @@ ChestTableWithContentPresenter >> connectPresenters [ chestsTable transmitDo: self chestTableTransmitBlock; - selectFirst + selectFirst. + + chestContentsTable transmitDo: self chestContentsTableTransmitBlock ] { #category : #layout } @@ -497,7 +509,10 @@ ChestTableWithContentPresenter >> makeChestContentsTableToolbar [ displayMode: StPharoSettings toolbarDisplayMode; addStyle: 'stToolbar'; fillWith: - self rootCommandsGroup / self class chestContentToolbarGroupName; + (chestContentsTableToolbarCommandGroup := self rootCommandsGroup + / + self class + chestContentToolbarGroupName); yourself ] @@ -601,7 +616,10 @@ ChestTableWithContentPresenter >> makeChestsTableToolbar [ displayMode: StPharoSettings toolbarDisplayMode; addStyle: 'stToolbar'; fillWith: - self rootCommandsGroup / self class chestToolbarGroupName; + (chestTableToolbarCommandGroup := self rootCommandsGroup + / + self class + chestToolbarGroupName); yourself ] @@ -974,6 +992,18 @@ ChestTableWithContentPresenter >> updateChestContentTableForChest: aChest [ lst items: aChest contents associations asOrderedCollection ] ] +{ #category : #updating } +ChestTableWithContentPresenter >> updateChestContentToolbar [ + + self updateToolbar: chestContentsTableToolbarCommandGroup +] + +{ #category : #updating } +ChestTableWithContentPresenter >> updateChestToolbar [ + + self updateToolbar: chestTableToolbarCommandGroup +] + { #category : #updating } ChestTableWithContentPresenter >> updateChestsTable [ @@ -985,6 +1015,13 @@ ChestTableWithContentPresenter >> updateChestsTable [ chestsTable ifNotNil: [ :lst | lst items: Chest allChests ] ] +{ #category : #accessing } +ChestTableWithContentPresenter >> updateToolbar: aCmCommandGroup [ + + aCmCommandGroup allCommands do: [ :spCommand | + spCommand updateEnableStatus ] +] + { #category : #'ui - dialogs' } ChestTableWithContentPresenter >> warningNamingChest: newChestName [ From e3d0aeeca9fb819144b2397087c04a1d023b0f5b Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:01:59 +0200 Subject: [PATCH 12/16] adding examples of chests and objects inside + filling playground with code to illustrate Chest's API usage --- src/Chest/Chest.class.st | 6 +++++- src/Chest/ChestPresenter.class.st | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Chest/Chest.class.st b/src/Chest/Chest.class.st index 32b8dd8..4c6f012 100644 --- a/src/Chest/Chest.class.st +++ b/src/Chest/Chest.class.st @@ -244,7 +244,11 @@ Chest class >> initialize [ ChestDictionary := Dictionary new. nextAvailableID := 1. - defaultInstance := nil + defaultInstance := nil. + self at: 'fortyTwo' put: 42. + (self newNamed: 'ExampleChest') + at: 'tata' + put: 'someExampleStringCalledTata' ] { #category : #'class initialization' } diff --git a/src/Chest/ChestPresenter.class.st b/src/Chest/ChestPresenter.class.st index 6f64123..d2479bc 100644 --- a/src/Chest/ChestPresenter.class.st +++ b/src/Chest/ChestPresenter.class.st @@ -497,11 +497,16 @@ ChestPresenter >> makeExpandableLayouts [ ChestPresenter >> makePlayground [ | newPlayground | - newPlayground := StPlayground new. + newPlayground := StPlaygroundPresenter new. - debugger ifNotNil: [ "newPlayground firstPage text interactionModel" + debugger ifNotNil: [ newPlayground firstPage text interactionModel: (ChestCodeScriptingInteractionModel debugger: debugger) ]. + newPlayground firstPage text text: + 'tata := Chest at: ''fortyTwo'' "access an object from the default chest". +(Chest named: ''ExampleChest'') at: ''tata'' put: #tata "error: an object is already named ''tata'' in this chest". +Chest inChest: ''ExampleChest'' at: ''tata'' put: #tata "error: an object is already named ''tata'' in this chest. If ''ExampleChest'' didn''t exist, it would create it". +Chest weak newNamed: ''WeakChestExample'' "creates a new chest that holds weak references to its stored objects"'. ^ newPlayground ] From 94b3564a8157ebf656959ba92e8b80e95d612314 Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:37:04 +0200 Subject: [PATCH 13/16] moving the creation of chest examples outside of the class initialization because that sends messages to unitialized objects --- src/BaselineOfChest/BaselineOfChest.class.st | 12 +++++++++++- src/Chest/Chest.class.st | 6 +----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/BaselineOfChest/BaselineOfChest.class.st b/src/BaselineOfChest/BaselineOfChest.class.st index b36b1fd..32a554d 100644 --- a/src/BaselineOfChest/BaselineOfChest.class.st +++ b/src/BaselineOfChest/BaselineOfChest.class.st @@ -12,9 +12,19 @@ BaselineOfChest >> baseline: spec [ spec package: 'Chest'; package: 'Chest-Tests'; - package: 'Chest-Commands' ]. + package: 'Chest-Commands'. + self createChestExamples ]. spec group: 'default' with: #( 'Chest' 'Chest-Commands' 'Chest-Tests' ) ] + +{ #category : #baselines } +BaselineOfChest >> createChestExamples [ + + Chest at: 'fortyTwo' put: 42. + (Chest newNamed: 'ExampleChest') + at: 'tata' + put: 'someExampleStringCalledTata' +] diff --git a/src/Chest/Chest.class.st b/src/Chest/Chest.class.st index 4c6f012..32b8dd8 100644 --- a/src/Chest/Chest.class.st +++ b/src/Chest/Chest.class.st @@ -244,11 +244,7 @@ Chest class >> initialize [ ChestDictionary := Dictionary new. nextAvailableID := 1. - defaultInstance := nil. - self at: 'fortyTwo' put: 42. - (self newNamed: 'ExampleChest') - at: 'tata' - put: 'someExampleStringCalledTata' + defaultInstance := nil ] { #category : #'class initialization' } From 6621c127d9b31174de089be263901a5a5ecfa8fb Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:40:10 +0200 Subject: [PATCH 14/16] resolving conflict --- src/BaselineOfChest/BaselineOfChest.class.st | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/BaselineOfChest/BaselineOfChest.class.st b/src/BaselineOfChest/BaselineOfChest.class.st index 32a554d..c5b41ed 100644 --- a/src/BaselineOfChest/BaselineOfChest.class.st +++ b/src/BaselineOfChest/BaselineOfChest.class.st @@ -12,12 +12,14 @@ BaselineOfChest >> baseline: spec [ spec package: 'Chest'; package: 'Chest-Tests'; - package: 'Chest-Commands'. + package: 'Chest-Commands'; + package: 'Chest-Commands-Tests'. self createChestExamples ]. spec group: 'default' - with: #( 'Chest' 'Chest-Commands' 'Chest-Tests' ) + with: + #( 'Chest' 'Chest-Commands' 'Chest-Tests' 'Chest-Commands-Tests' ) ] { #category : #baselines } From 4e1ddb4a02d0e64498194f7f782cafb4e0921ee4 Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:45:44 +0200 Subject: [PATCH 15/16] fixing creation of chest examples post load --- src/BaselineOfChest/BaselineOfChest.class.st | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/BaselineOfChest/BaselineOfChest.class.st b/src/BaselineOfChest/BaselineOfChest.class.st index c5b41ed..0ae597c 100644 --- a/src/BaselineOfChest/BaselineOfChest.class.st +++ b/src/BaselineOfChest/BaselineOfChest.class.st @@ -9,12 +9,13 @@ BaselineOfChest >> baseline: spec [ spec for: #common do: [ + spec postLoadDoIt: #postload:package:. + spec package: 'Chest'; package: 'Chest-Tests'; package: 'Chest-Commands'; - package: 'Chest-Commands-Tests'. - self createChestExamples ]. + package: 'Chest-Commands-Tests' ]. spec group: 'default' @@ -30,3 +31,9 @@ BaselineOfChest >> createChestExamples [ at: 'tata' put: 'someExampleStringCalledTata' ] + +{ #category : #baselines } +BaselineOfChest >> postload: loader package: packageSpec [ + + self createChestExamples +] From d676a3451cbcc754573cab0033244ba703eda723 Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Thu, 3 Aug 2023 10:45:02 +0200 Subject: [PATCH 16/16] cleaning comments and code --- src/Chest/ChestPresenter.class.st | 5 ++--- src/Chest/ChestTableWithContentPresenter.class.st | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Chest/ChestPresenter.class.st b/src/Chest/ChestPresenter.class.st index d2479bc..6f3684c 100644 --- a/src/Chest/ChestPresenter.class.st +++ b/src/Chest/ChestPresenter.class.st @@ -149,7 +149,7 @@ ChestPresenter class >> showInspector [ { #category : #accessing } ChestPresenter class >> showInspector: anObject [ - ^ ShowInspector := anObject + ShowInspector := anObject ] { #category : #accessing } @@ -161,7 +161,7 @@ ChestPresenter class >> showPlayground [ { #category : #accessing } ChestPresenter class >> showPlayground: anObject [ - ^ ShowPlayground := anObject + ShowPlayground := anObject ] { #category : #visiting } @@ -295,7 +295,6 @@ ChestPresenter >> hideInspector [ add: showPlaygroundContainer; add: showInspectorContainer expand: false; yourself. - "showInspectorContainer remove: inspector." showInspectorButton icon: (self application iconNamed: #disable) ] diff --git a/src/Chest/ChestTableWithContentPresenter.class.st b/src/Chest/ChestTableWithContentPresenter.class.st index 9977d81..ffe0037 100644 --- a/src/Chest/ChestTableWithContentPresenter.class.st +++ b/src/Chest/ChestTableWithContentPresenter.class.st @@ -513,7 +513,7 @@ ChestTableWithContentPresenter >> makeChestContentsTable [ addColumn: (SpStringTableColumn title: 'Class' evaluated: [ :association | - association value class printString ]) + association value class name ]) beExpandable; items: #( ) asOrderedCollection; beResizable;