Skip to content

Commit

Permalink
add filter text widget [feenkcom/gtoolkit#3983]
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajKubelka committed Sep 23, 2024
1 parent 4009594 commit fa1adbd
Show file tree
Hide file tree
Showing 16 changed files with 221 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,13 @@ GtFilterElementByScripterExamples >> textElement [
scripterWithModel: [ GtFilterModelExamples new textModel ]
element: [ :aModel | GtFilterNameElement new filterViewModel: aModel asFilterViewModel ].

aScripter editor
click;
selectAll;
typeText: 'Class';
assertTextEqualsTo: 'Class';
// GtFilterSettingsId;
play.

^ aScripter
]
6 changes: 0 additions & 6 deletions src/GToolkit-Coder-UI/GtFilterBooleanViewModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,3 @@ GtFilterBooleanViewModel >> subscribeToFilterModel [
send: #onSwitchChanged:
to: self
]

{ #category : #'api - filter model' }
GtFilterBooleanViewModel >> unsubscribeFromFilterModel [
super unsubscribeFromFilterModel.
self filterModel unsubscribe: self
]
19 changes: 19 additions & 0 deletions src/GToolkit-Coder-UI/GtFilterItemsElement.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Class {
#name : #GtFilterItemsElement,
#superclass : #BlElement,
#traits : 'TBrLayoutResizable',
#classTraits : 'TBrLayoutResizable classTrait',
#category : #'GToolkit-Coder-UI-Filters - Widgets'
}

{ #category : #initialization }
GtFilterItemsElement >> defaultLayout [
^ BlFlowLayout horizontal
]

{ #category : #initialization }
GtFilterItemsElement >> initialize [
super initialize.
self hFitContentLimited.
self vFitContent
]
33 changes: 33 additions & 0 deletions src/GToolkit-Coder-UI/GtFilterItemsModel.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Class {
#name : #GtFilterItemsModel,
#superclass : #GtFiltersModel,
#instVars : [
'items'
],
#category : #'GToolkit-Coder-UI-Filters - Models'
}

{ #category : #initialization }
GtFilterItemsModel >> initialize [
super initialize.
items := Array empty
]

{ #category : #accessing }
GtFilterItemsModel >> items [
<return: #Collection of: #GtFilterModel>
^ items
]

{ #category : #accessing }
GtFilterItemsModel >> items: aCollection [
self items = aCollection ifTrue: [ ^ self ].

items := aCollection.
self notifyItemsChanged.
]

{ #category : #'private - notifying' }
GtFilterItemsModel >> notifyItemsChanged [
self announce: (GtFiltersModelItemsChanged new model: self)
]
2 changes: 1 addition & 1 deletion src/GToolkit-Coder-UI/GtFilterNameElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Class {

{ #category : #'private - updating' }
GtFilterNameElement >> addSettingsElement: anElement [
settingsContainer addChild: anElement as: #settings
settingsContainer addChild: anElement as: GtFilterSettingsId
]

{ #category : #initialization }
Expand Down
10 changes: 10 additions & 0 deletions src/GToolkit-Coder-UI/GtFilterSettingsId.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Class {
#name : #GtFilterSettingsId,
#superclass : #BlElementUniqueId,
#category : #'GToolkit-Coder-UI-Filters - Widgets'
}

{ #category : #converting }
GtFilterSettingsId >> asSymbol [
^ #'filter--settings'
]
6 changes: 0 additions & 6 deletions src/GToolkit-Coder-UI/GtFilterShortListViewModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,3 @@ GtFilterShortListViewModel >> subscribeToFilterModel [
send: #onSelectedItemChanged:
to: self
]

{ #category : #'api - filter model' }
GtFilterShortListViewModel >> unsubscribeFromFilterModel [
super unsubscribeFromFilterModel.
self filterModel unsubscribe: self
]
28 changes: 26 additions & 2 deletions src/GToolkit-Coder-UI/GtFilterTextModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Class {
#name : #GtFilterTextModel,
#superclass : #GtFilterModel,
#instVars : [
'text'
'text',
'inputFilter'
],
#category : #'GToolkit-Coder-UI-Filters - Models'
}
Expand All @@ -15,10 +16,33 @@ GtFilterTextModel >> filterViewModelClass [
{ #category : #initialization }
GtFilterTextModel >> initialize [
super initialize.
text := BlText empty
text := BlText empty.
inputFilter := BrTextEditorNoLineBreakInputFilter new.
]

{ #category : #accessing }
GtFilterTextModel >> inputFilter [
<return: #BrTextEditorInputFilter>
^ inputFilter
]

{ #category : #accessing }
GtFilterTextModel >> inputFilter: anInputFilter [
inputFilter = anInputFilter ifTrue: [ ^ self ].

inputFilter := anInputFilter.
self notifyInputFilterChanged.
]

{ #category : #'private - notifying' }
GtFilterTextModel >> notifyInputFilterChanged [
self
announce: (GtFilterTextModelInputFilterChanged new
model: self;
inputFilter: self inputFilter)
]

{ #category : #'private - notifying' }
GtFilterTextModel >> notifyTextChanged [
self
announce: (GtFilterTextModelTextChanged new
Expand Down
18 changes: 18 additions & 0 deletions src/GToolkit-Coder-UI/GtFilterTextModelInputFilterChanged.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Class {
#name : #GtFilterTextModelInputFilterChanged,
#superclass : #GtFilterModelAnnouncement,
#instVars : [
'inputFilter'
],
#category : #'GToolkit-Coder-UI-Filters - Events'
}

{ #category : #accessing }
GtFilterTextModelInputFilterChanged >> inputFilter [
^ inputFilter
]

{ #category : #accessing }
GtFilterTextModelInputFilterChanged >> inputFilter: anObject [
inputFilter := anObject
]
40 changes: 34 additions & 6 deletions src/GToolkit-Coder-UI/GtFilterTextSettingsElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,62 @@ GtFilterTextSettingsElement >> initializeEditorElement [
background: self theme default contentBackgroundColor;
aptitude: BrGlamorousRegularEditorAptitude new
glamorousRegularSmallSize;
text: ''
text: '';
padding: (BlInsets top: 1 right: 2 bottom: 1 left: 2)
]

{ #category : #'as yet unclassified' }
{ #category : #'api - filter view model' }
GtFilterTextSettingsElement >> onFilterViewModelChanged [
super onFilterViewModelChanged.

self updateEditorElement
]

{ #category : #'event handling' }
GtFilterTextSettingsElement >> onInputFilterChanged: anAnnouncement [
BlTaskAction
enqueueElement: self
action: [ self updateEditorElementInputFilter ]
]

{ #category : #'event handling' }
GtFilterTextSettingsElement >> onTextChanged: anAnnouncement [
BlTaskAction
enqueueElement: self
action: [ self updateEditorElement ]
action: [ self updateEditorElementText ]
]

{ #category : #'api - filter view model' }
GtFilterTextSettingsElement >> subscribeToFilterViewModel [
super subscribeToFilterViewModel.

self filterViewModel weak
when: GtFilterTextModelTextChanged
send: #onTextChanged:
to: self
when: GtFilterTextViewModelTextChanged
send: #onTextChanged:
to: self;
when: GtFilterTextViewModelInputFilterChanged
send: #onInputFilterChanged:
to: self
]

{ #category : #'private - updating' }
GtFilterTextSettingsElement >> updateEditorElement [
self updateEditorElementInputFilter.
self updateEditorElementText.
]

{ #category : #'private - updating' }
GtFilterTextSettingsElement >> updateEditorElementInputFilter [
(editorElement editor inputFilter = self filterViewModel inputFilter)
ifTrue: [ ^ self ].

editorElement inputFilter: self filterViewModel inputFilter
]

{ #category : #'private - updating' }
GtFilterTextSettingsElement >> updateEditorElementText [
(editorElement text equals: self filterViewModel text)
ifTrue: [ ^ self ].

editorElement text: self filterViewModel text copy
]
27 changes: 19 additions & 8 deletions src/GToolkit-Coder-UI/GtFilterTextViewModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ GtFilterTextViewModel >> filterElementClass [
^ GtFilterTextSettingsElement
]

{ #category : #testing }
GtFilterTextViewModel >> inputFilter [
<return: #BrTextEditorInputFilter>
^ self filterModel inputFilter
]

{ #category : #'event handling' }
GtFilterTextViewModel >> onInputFilterChanged: anAnnouncement [
self
announce: (GtFilterTextViewModelInputFilterChanged new
viewModel: self;
inputFilter: anAnnouncement inputFilter)
]

{ #category : #'event handling' }
GtFilterTextViewModel >> onTextChanged: anAnnouncement [
self
Expand All @@ -22,17 +36,14 @@ GtFilterTextViewModel >> subscribeToFilterModel [
super subscribeToFilterModel.
self filterModel weak
when: GtFilterTextModelTextChanged
send: #onTextChanged:
to: self
send: #onTextChanged:
to: self;
when: GtFilterTextModelInputFilterChanged
send: #onInputFilterChanged:
to: self
]

{ #category : #testing }
GtFilterTextViewModel >> text [
^ self filterModel text
]

{ #category : #'api - filter model' }
GtFilterTextViewModel >> unsubscribeFromFilterModel [
super unsubscribeFromFilterModel.
self filterModel unsubscribe: self
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Class {
#name : #GtFilterTextViewModelInputFilterChanged,
#superclass : #GtFilterViewModelAnnouncement,
#instVars : [
'inputFilter'
],
#category : #'GToolkit-Coder-UI-Filters - Events'
}

{ #category : #accessing }
GtFilterTextViewModelInputFilterChanged >> inputFilter [
^ inputFilter
]

{ #category : #accessing }
GtFilterTextViewModelInputFilterChanged >> inputFilter: anObject [
inputFilter := anObject
]
5 changes: 5 additions & 0 deletions src/GToolkit-Coder-UI/GtFilterViewModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ GtFilterViewModel >> filterElementClass [
<return: #'GtFilterSettingsElement class'>
^ self subclassResponsibility
]

{ #category : #'api - filter model' }
GtFilterViewModel >> unsubscribeFromFilterModel [
self filterModel unsubscribe: self
]
18 changes: 18 additions & 0 deletions src/GToolkit-Coder-UI/GtFiltersAnnouncement.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Class {
#name : #GtFiltersAnnouncement,
#superclass : #Announcement,
#instVars : [
'model'
],
#category : #'GToolkit-Coder-UI-Filters - Events'
}

{ #category : #accessing }
GtFiltersAnnouncement >> model [
^ model
]

{ #category : #accessing }
GtFiltersAnnouncement >> model: anObject [
model := anObject
]
7 changes: 7 additions & 0 deletions src/GToolkit-Coder-UI/GtFiltersModel.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Class {
#name : #GtFiltersModel,
#superclass : #Object,
#traits : 'TGtAnnouncer',
#classTraits : 'TGtAnnouncer classTrait',
#category : #'GToolkit-Coder-UI-Filters - Models'
}
5 changes: 5 additions & 0 deletions src/GToolkit-Coder-UI/GtFiltersModelItemsChanged.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #GtFiltersModelItemsChanged,
#superclass : #GtFiltersAnnouncement,
#category : #'GToolkit-Coder-UI-Filters - Events'
}

0 comments on commit fa1adbd

Please sign in to comment.