From dcdad06eb8d9855804b2234cea4aaa3abaa1a777 Mon Sep 17 00:00:00 2001 From: Juraj Kubelka Date: Thu, 26 Sep 2024 11:36:02 -0300 Subject: [PATCH] add editor completion [feenkcom/gtoolkit#3983] --- src/GToolkit-Coder-UI/GtFilterTextModel.class.st | 12 +++++++++--- .../GtFilterTextSettingsElement.class.st | 15 ++++++++++++++- .../GtFilterTextViewModel.class.st | 6 ++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/GToolkit-Coder-UI/GtFilterTextModel.class.st b/src/GToolkit-Coder-UI/GtFilterTextModel.class.st index 12f37775..4d8acb6c 100644 --- a/src/GToolkit-Coder-UI/GtFilterTextModel.class.st +++ b/src/GToolkit-Coder-UI/GtFilterTextModel.class.st @@ -4,19 +4,25 @@ Class { #instVars : [ 'text', 'inputFilter', - 'completion' + 'completionBuilder' ], #category : #'GToolkit-Coder-UI-Filters - Models' } { #category : #accessing } GtFilterTextModel >> completion [ - ^ completion + + ^ completionBuilder value ] { #category : #accessing } GtFilterTextModel >> completion: aCompletionBuilder [ - completion := aCompletionBuilder + completionBuilder := aCompletionBuilder +] + +{ #category : #accessing } +GtFilterTextModel >> completionDo: aBlock [ + self completion ifNotNil: aBlock ] { #category : #accessing } diff --git a/src/GToolkit-Coder-UI/GtFilterTextSettingsElement.class.st b/src/GToolkit-Coder-UI/GtFilterTextSettingsElement.class.st index 2896f923..12ff115d 100644 --- a/src/GToolkit-Coder-UI/GtFilterTextSettingsElement.class.st +++ b/src/GToolkit-Coder-UI/GtFilterTextSettingsElement.class.st @@ -2,7 +2,8 @@ Class { #name : #GtFilterTextSettingsElement, #superclass : #GtFilterSettingsElement, #instVars : [ - 'editorElement' + 'editorElement', + 'completionController' ], #category : #'GToolkit-Coder-UI-Filters - Widgets' } @@ -83,10 +84,22 @@ GtFilterTextSettingsElement >> subscribeToFilterViewModel [ to: self ] +{ #category : #'private - updating' } +GtFilterTextSettingsElement >> updateEditorCompletionController [ + completionController ifNotNil: [ :aController | + completionController := nil. + aController uninstall ]. + + self filterViewModel completionDo: [ :aStrategy | + completionController := GtCompletionController on: editorElement strategy: aStrategy. + completionController install ] +] + { #category : #'private - updating' } GtFilterTextSettingsElement >> updateEditorElement [ self updateEditorElementInputFilter. self updateEditorElementText. + self updateEditorCompletionController. ] { #category : #'private - updating' } diff --git a/src/GToolkit-Coder-UI/GtFilterTextViewModel.class.st b/src/GToolkit-Coder-UI/GtFilterTextViewModel.class.st index 79948ec9..49b3f001 100644 --- a/src/GToolkit-Coder-UI/GtFilterTextViewModel.class.st +++ b/src/GToolkit-Coder-UI/GtFilterTextViewModel.class.st @@ -4,6 +4,12 @@ Class { #category : #'GToolkit-Coder-UI-Filters - View Models' } +{ #category : #accessing } +GtFilterTextViewModel >> completionDo: aBlock [ + self hasFilterModel ifFalse: [ ^ self ]. + self filterModel completionDo: aBlock +] + { #category : #accessing } GtFilterTextViewModel >> filterElementClass [ ^ GtFilterTextSettingsElement