From 281aa03bf2cd3c5671f3367569b6ae78afb92b95 Mon Sep 17 00:00:00 2001 From: YannLEGOFF Date: Fri, 7 Jul 2023 13:36:35 +0200 Subject: [PATCH] [FT] - better search engine for selection --- .../PyramidSearchAndSelectModel.class.st | 84 ++++++++++++++----- .../PyramidSearchAndSelectPresenter.class.st | 76 ++++++++++------- 2 files changed, 108 insertions(+), 52 deletions(-) diff --git a/src/Pyramid-Bloc/PyramidSearchAndSelectModel.class.st b/src/Pyramid-Bloc/PyramidSearchAndSelectModel.class.st index 52690118..26d06b90 100644 --- a/src/Pyramid-Bloc/PyramidSearchAndSelectModel.class.st +++ b/src/Pyramid-Bloc/PyramidSearchAndSelectModel.class.st @@ -3,8 +3,10 @@ Class { #superclass : #Object, #instVars : [ 'code', - 'isTree', - 'name' + 'name', + 'isRoots', + 'isAll', + 'isSelection' ], #category : #'Pyramid-Bloc-plugin-hierarchy' } @@ -13,17 +15,17 @@ Class { PyramidSearchAndSelectModel class >> all [ ^ self new - isTree: false; - code: 'self'; - name: 'Select all'; - yourself + beAll; + code: 'self'; + name: 'Select all'; + yourself ] { #category : #'as yet unclassified' } PyramidSearchAndSelectModel class >> allChildrenOf [ ^ self new - isTree: false; + beAll; code: '(self select: [ :e | e id asSymbol = #toto ]) flatCollect: [ :each | each children ]'; name: 'Select all children elements of all elements named #toto'; @@ -34,7 +36,7 @@ PyramidSearchAndSelectModel class >> allChildrenOf [ PyramidSearchAndSelectModel class >> blTextElement [ ^ self new - isTree: false; + beAll; code: 'self select: [ :e | e isKindOf: BlTextElement ]'; name: 'Select all text element'; yourself @@ -58,7 +60,7 @@ PyramidSearchAndSelectModel class >> default [ PyramidSearchAndSelectModel class >> named [ ^ self new - isTree: false; + beAll; code: 'self select: [ :e | e id asSymbol = #toto ]'; name: 'Select all elements named #toto'; yourself @@ -68,17 +70,17 @@ PyramidSearchAndSelectModel class >> named [ PyramidSearchAndSelectModel class >> noSelection [ ^ self new - isTree: true; - code: '{ }'; - name: 'Unselect all'; - yourself + beAll; + code: '{ }'; + name: 'Unselect all'; + yourself ] { #category : #'as yet unclassified' } PyramidSearchAndSelectModel class >> notVisible [ ^ self new - isTree: false; + beAll; code: 'self select: [ :e | e visibility isVisible not ]'; name: 'Select all non visible element'; yourself @@ -88,22 +90,46 @@ PyramidSearchAndSelectModel class >> notVisible [ PyramidSearchAndSelectModel class >> roots [ ^ self new - isTree: true; - code: 'self'; - name: 'Select all roots'; - yourself + beRoots; + code: 'self'; + name: 'Select all roots'; + yourself ] { #category : #'as yet unclassified' } PyramidSearchAndSelectModel class >> transparentBackground [ ^ self new - isTree: false; + beAll; code: 'self select: [ :e | e background isTransparent ]'; name: 'Select all elements with transparent background'; yourself ] +{ #category : #accessing } +PyramidSearchAndSelectModel >> beAll [ + + isAll := true. + isRoots := false. + isSelection := false +] + +{ #category : #accessing } +PyramidSearchAndSelectModel >> beRoots [ + + isAll := false. + isRoots := true. + isSelection := false +] + +{ #category : #accessing } +PyramidSearchAndSelectModel >> beSelection [ + + isAll := false. + isRoots := false. + isSelection := true +] + { #category : #accessing } PyramidSearchAndSelectModel >> code [ @@ -116,16 +142,28 @@ PyramidSearchAndSelectModel >> code: anObject [ code := anObject ] +{ #category : #initialization } +PyramidSearchAndSelectModel >> initialize [ + + self beAll +] + +{ #category : #accessing } +PyramidSearchAndSelectModel >> isAll [ + + ^ isAll +] + { #category : #accessing } -PyramidSearchAndSelectModel >> isTree [ +PyramidSearchAndSelectModel >> isRoots [ - ^ isTree + ^ isRoots ] { #category : #accessing } -PyramidSearchAndSelectModel >> isTree: anObject [ +PyramidSearchAndSelectModel >> isSelection [ - isTree := anObject + ^ isSelection ] { #category : #accessing } diff --git a/src/Pyramid-Bloc/PyramidSearchAndSelectPresenter.class.st b/src/Pyramid-Bloc/PyramidSearchAndSelectPresenter.class.st index c125909e..2d600049 100644 --- a/src/Pyramid-Bloc/PyramidSearchAndSelectPresenter.class.st +++ b/src/Pyramid-Bloc/PyramidSearchAndSelectPresenter.class.st @@ -3,8 +3,9 @@ Class { #superclass : #SpPresenter, #instVars : [ 'unselectButton', - 'flatRadioButton', - 'treeRadioButton', + 'allRadioButton', + 'rootsRadioButton', + 'selectionRadioButton', 'codePresenter', 'selectButton', 'examplesDropList', @@ -17,11 +18,9 @@ Class { { #category : #'as yet unclassified' } PyramidSearchAndSelectPresenter >> actionExample: aModel [ - aModel isTree - ifTrue: [ - self treeRadioButton click ] - ifFalse: [ - self flatRadioButton click ]. + aModel isRoots ifTrue: [ self rootsRadioButton click ]. + aModel isSelection ifTrue: [ self selectionRadioButton click ]. + aModel isAll ifTrue: [ self allRadioButton click ]. self codePresenter text: aModel code. self actionSelect ] @@ -64,11 +63,17 @@ PyramidSearchAndSelectPresenter >> activeProject [ PyramidSearchAndSelectPresenter >> activeProject: anObject [ activeProject := anObject. - flatRadioButton click. + allRadioButton click ] { #category : #accessing } -PyramidSearchAndSelectPresenter >> codeIsForFlat [ +PyramidSearchAndSelectPresenter >> allRadioButton [ + + ^ allRadioButton +] + +{ #category : #accessing } +PyramidSearchAndSelectPresenter >> codeIsForAll [ self activeProject ifNil: [ ^ self ]. self codePresenter interactionModel: @@ -78,13 +83,21 @@ PyramidSearchAndSelectPresenter >> codeIsForFlat [ ] { #category : #accessing } -PyramidSearchAndSelectPresenter >> codeIsForTree [ +PyramidSearchAndSelectPresenter >> codeIsForRoots [ self activeProject ifNil: [ ^ self ]. self codePresenter interactionModel: (SpCodeObjectInteractionModel on: self activeProject roots) ] +{ #category : #accessing } +PyramidSearchAndSelectPresenter >> codeIsForSelection [ + + self activeProject ifNil: [ ^ self ]. + self codePresenter interactionModel: + (SpCodeObjectInteractionModel on: self activeProject selection) +] + { #category : #accessing } PyramidSearchAndSelectPresenter >> codePresenter [ @@ -102,10 +115,11 @@ PyramidSearchAndSelectPresenter >> defaultLayout [ add: self selectButton; yourself) expand: false; - add: (SpBoxLayout newHorizontal + add: (SpBoxLayout newHorizontal spacing: 4; - add: self flatRadioButton; - add: self treeRadioButton; + add: self allRadioButton; + add: self rootsRadioButton; + add: self selectionRadioButton; yourself) expand: false; add: (SpBoxLayout newHorizontal @@ -134,12 +148,6 @@ PyramidSearchAndSelectPresenter >> examplesDropList [ ^ examplesDropList ] -{ #category : #accessing } -PyramidSearchAndSelectPresenter >> flatRadioButton [ - - ^ flatRadioButton -] - { #category : #initialization } PyramidSearchAndSelectPresenter >> initializeExamples [ self examplesDropList items: PyramidSearchAndSelectModel default @@ -151,16 +159,20 @@ PyramidSearchAndSelectPresenter >> initializePresenters [ codePresenter := SpCodePresenter new text: 'self'; yourself. - treeRadioButton := SpRadioButtonPresenter new - label: 'self = tree'; + rootsRadioButton := SpRadioButtonPresenter new + label: 'self = {roots}'; yourself. - flatRadioButton := SpRadioButtonPresenter new - label: 'self = flat'; + selectionRadioButton := SpRadioButtonPresenter new + label: 'self = {selection}'; yourself. - treeRadioButton associatedRadioButtons: { flatRadioButton }. - treeRadioButton whenActivatedDo: [ self codeIsForTree ]. - flatRadioButton whenActivatedDo: [ self codeIsForFlat ]. - + allRadioButton := SpRadioButtonPresenter new + label: 'self = {all}'; + yourself. + allRadioButton associatedRadioButtons: { selectionRadioButton . rootsRadioButton }. + allRadioButton whenActivatedDo: [ self codeIsForAll ]. + selectionRadioButton whenActivatedDo: [ self codeIsForSelection ]. + rootsRadioButton whenActivatedDo: [ self codeIsForRoots ]. + unselectButton := SpButtonPresenter new label: 'unselect'; action: [ self actionUnselect ]; @@ -177,6 +189,12 @@ PyramidSearchAndSelectPresenter >> initializePresenters [ self initializeExamples ] +{ #category : #accessing } +PyramidSearchAndSelectPresenter >> rootsRadioButton [ + + ^ rootsRadioButton +] + { #category : #accessing } PyramidSearchAndSelectPresenter >> selectButton [ @@ -184,9 +202,9 @@ PyramidSearchAndSelectPresenter >> selectButton [ ] { #category : #accessing } -PyramidSearchAndSelectPresenter >> treeRadioButton [ +PyramidSearchAndSelectPresenter >> selectionRadioButton [ - ^ treeRadioButton + ^ selectionRadioButton ] { #category : #accessing }