From 27c4493feab722048b9dcb5109237368ab61489f Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Sat, 31 Jan 2026 13:53:35 +0100 Subject: [PATCH] Playground: Add delete page feature This change adds a remove page icon. When we share the play-cache between multiple images it's common to have pages we do not want to keep. Instead of going to the folder to remove the files I propose to have an icon to do it from the playground directly --- .../StPlaygroundPage.class.st | 8 +++++ .../StPlaygroundPageSummaryPresenter.class.st | 35 +++++++++++++++---- .../StPlaygroundPagesPresenter.class.st | 13 ++++--- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/NewTools-Playground/StPlaygroundPage.class.st b/src/NewTools-Playground/StPlaygroundPage.class.st index 6f531e644..033a796e7 100644 --- a/src/NewTools-Playground/StPlaygroundPage.class.st +++ b/src/NewTools-Playground/StPlaygroundPage.class.st @@ -119,6 +119,14 @@ StPlaygroundPage >> defaultObjectInspectorClass [ ^ StPlaygroundPagePresenter ] +{ #category : 'submorphs - add/remove' } +StPlaygroundPage >> delete [ + "Delete the corresponding page" + + self fileReference ensureDelete. + (self fileReference withExtension: 'ombu') ensureDelete +] + { #category : 'accessing' } StPlaygroundPage >> ensureContentsFlushed [ diff --git a/src/NewTools-Playground/StPlaygroundPageSummaryPresenter.class.st b/src/NewTools-Playground/StPlaygroundPageSummaryPresenter.class.st index 5a634732c..8e3f15a04 100644 --- a/src/NewTools-Playground/StPlaygroundPageSummaryPresenter.class.st +++ b/src/NewTools-Playground/StPlaygroundPageSummaryPresenter.class.st @@ -10,7 +10,9 @@ Class { #classTraits : 'SpTModel classTrait', #instVars : [ 'firstLineLabel', - 'timeLabel' + 'timeLabel', + 'deleteIcon', + 'deleteBlock' ], #category : 'NewTools-Playground-View', #package : 'NewTools-Playground', @@ -27,13 +29,26 @@ StPlaygroundPageSummaryPresenter >> contents [ StPlaygroundPageSummaryPresenter >> initializePresenters [ layout := SpBoxLayout newTopToBottom - borderWidth: 1; - spacing: 2; - add: (firstLineLabel := self newLabel) expand: false; - add: (timeLabel := self newLabel) expand: false; - yourself. + borderWidth: 1; + spacing: 2; + add: (firstLineLabel := self newLabel) expand: false; + add: (SpBoxLayout newLeftToRight + spacing: 5; + borderWidth: 1; + add: (timeLabel := self newLabel); + add: (deleteIcon := self newButton) width: 25; + yourself) + expand: false; + yourself. - timeLabel addStyle: 'dim' + timeLabel addStyle: 'dim'. + + deleteIcon + icon: (self iconNamed: #remove); + help: 'This action will remove the page from the playground and remove the persisted page.'; + action: [ + self model delete. + deleteBlock ifNotNil: [ deleteBlock value ] ] ] { #category : 'accessing' } @@ -55,3 +70,9 @@ StPlaygroundPageSummaryPresenter >> updatePresenter [ firstLineLabel label: self pageTitle. timeLabel label: self model modificationTime epiceaBrowsersAsString ] + +{ #category : 'events' } +StPlaygroundPageSummaryPresenter >> whenDeleteButtonPressed: aBlock [ + + deleteBlock := aBlock +] diff --git a/src/NewTools-Playground/StPlaygroundPagesPresenter.class.st b/src/NewTools-Playground/StPlaygroundPagesPresenter.class.st index e5ffaad39..1d1934bac 100644 --- a/src/NewTools-Playground/StPlaygroundPagesPresenter.class.st +++ b/src/NewTools-Playground/StPlaygroundPagesPresenter.class.st @@ -174,10 +174,15 @@ StPlaygroundPagesPresenter >> pagesActions [ { #category : 'initialization' } StPlaygroundPagesPresenter >> pagesAsPresenters [ - ^ self pages collect: [ :each | - self - instantiate: StPlaygroundPageSummaryPresenter - on: each ] + ^ self pages collect: [ :each | + (self instantiate: StPlaygroundPageSummaryPresenter on: each) + whenDeleteButtonPressed: [ + | oldIndex | + "Refresh the list but keep the selected index to not jump in the list." + oldIndex := pageList selectedIndex. + pageList presenters: self pagesAsPresenters. + pageList selectIndex: oldIndex ]; + yourself ] ] { #category : 'private' }