From 00c992cc41ac05ddbe0919ab7a08af846d4ac5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Blizni=C4=8Denko?= Date: Sat, 2 Nov 2024 23:21:24 +0100 Subject: [PATCH] Remove depedent elements even when not shown --- .../OPDiagramRemoveFigureCommand.class.st | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/repository/OpenPonk-Spec/OPDiagramRemoveFigureCommand.class.st b/repository/OpenPonk-Spec/OPDiagramRemoveFigureCommand.class.st index e9308b1d..4c908869 100644 --- a/repository/OpenPonk-Spec/OPDiagramRemoveFigureCommand.class.st +++ b/repository/OpenPonk-Spec/OPDiagramRemoveFigureCommand.class.st @@ -103,9 +103,40 @@ OPDiagramRemoveFigureCommand >> executeWithConfirmation [ { #category : 'execution' } OPDiagramRemoveFigureCommand >> executeWithoutConfirmation [ + | allShown | diagramController deselectAll. + + allShown := self showDependentAndReturnOriginallyShown. + figures do: [ :each | (diagramController hasControllerForFigure: each) ifTrue: [ diagramController removeModelOfRoassalShape: each ] ]. + + self removeAllNotOriginallyShown: allShown. + canvas signalUpdate ] + +{ #category : 'execution' } +OPDiagramRemoveFigureCommand >> removeAllNotOriginallyShown: allShown [ + + diagramController allVisibleShowableElements + reject: [ :any | allShown includes: any ] + thenDo: [ :each | + diagramController + controllerForModel: each + ifFound: [ :controller | + controller removeControllerAndDiagramElement ] ] +] + +{ #category : 'execution' } +OPDiagramRemoveFigureCommand >> showDependentAndReturnOriginallyShown [ + + | executor allShown dependent | + executor := OPDiagramExplorer on: diagramController. + allShown := diagramController allVisibleShowableElements asSet. + dependent := models flatCollect: [ :each | + executor dependentFor: each ]. + executor showElements: dependent. + ^ allShown +]