Skip to content

Commit

Permalink
[FT] - better search engine for selection
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLeGoff committed Jul 7, 2023
1 parent 43b29e1 commit 281aa03
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 52 deletions.
84 changes: 61 additions & 23 deletions src/Pyramid-Bloc/PyramidSearchAndSelectModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ Class {
#superclass : #Object,
#instVars : [
'code',
'isTree',
'name'
'name',
'isRoots',
'isAll',
'isSelection'
],
#category : #'Pyramid-Bloc-plugin-hierarchy'
}
Expand All @@ -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';
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 [

Expand All @@ -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 }
Expand Down
76 changes: 47 additions & 29 deletions src/Pyramid-Bloc/PyramidSearchAndSelectPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ Class {
#superclass : #SpPresenter,
#instVars : [
'unselectButton',
'flatRadioButton',
'treeRadioButton',
'allRadioButton',
'rootsRadioButton',
'selectionRadioButton',
'codePresenter',
'selectButton',
'examplesDropList',
Expand All @@ -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
]
Expand Down Expand Up @@ -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:
Expand All @@ -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 [

Expand All @@ -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
Expand Down Expand Up @@ -134,12 +148,6 @@ PyramidSearchAndSelectPresenter >> examplesDropList [
^ examplesDropList
]

{ #category : #accessing }
PyramidSearchAndSelectPresenter >> flatRadioButton [

^ flatRadioButton
]

{ #category : #initialization }
PyramidSearchAndSelectPresenter >> initializeExamples [
self examplesDropList items: PyramidSearchAndSelectModel default
Expand All @@ -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 ];
Expand All @@ -177,16 +189,22 @@ PyramidSearchAndSelectPresenter >> initializePresenters [
self initializeExamples
]

{ #category : #accessing }
PyramidSearchAndSelectPresenter >> rootsRadioButton [

^ rootsRadioButton
]

{ #category : #accessing }
PyramidSearchAndSelectPresenter >> selectButton [

^ selectButton
]

{ #category : #accessing }
PyramidSearchAndSelectPresenter >> treeRadioButton [
PyramidSearchAndSelectPresenter >> selectionRadioButton [

^ treeRadioButton
^ selectionRadioButton
]

{ #category : #accessing }
Expand Down

0 comments on commit 281aa03

Please sign in to comment.