plugins/bee: add symbol filter
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 10 Jun 2019 15:22:49 +0100
changeset 166 d55f55ac977b
parent 165 1e2a4cb4afdd
child 167 16cd2d937309
plugins/bee: add symbol filter to quickly search through (possibly long) list of symbols.
plugins/bee/BeeSymbolListApplication.st
--- a/plugins/bee/BeeSymbolListApplication.st	Mon Jun 10 14:59:26 2019 +0100
+++ b/plugins/bee/BeeSymbolListApplication.st	Mon Jun 10 15:22:49 2019 +0100
@@ -3,7 +3,7 @@
 "{ NameSpace: Smalltalk }"
 
 VDBAbstractListApplication subclass:#BeeSymbolListApplication
-	instanceVariableNames:'symbolListHolder selectedSymbolHolder'
+	instanceVariableNames:'symbolListHolder selectedSymbolHolder filterHolder'
 	classVariableNames:''
 	poolDictionaries:'GDBStopReasons'
 	category:'VDB-Plugin-Bee-UI'
@@ -18,8 +18,126 @@
     "Modified: / 07-06-2019 / 15:00:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!BeeSymbolListApplication class methodsFor:'interface specs'!
+
+windowSpec
+    "This resource specification was automatically generated
+     by the UIPainter of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the UIPainter may not be able to read the specification."
+
+    "
+     UIPainter new openOnClass:BeeSymbolListApplication andSelector:#windowSpec
+     BeeSymbolListApplication new openInterface:#windowSpec
+     BeeSymbolListApplication open
+    "
+
+    <resource: #canvas>
+
+    ^ 
+    #(FullSpec
+       name: windowSpec
+       uuid: '10cae1b0-8b8a-11e9-8967-606720e43e2c'
+       window: 
+      (WindowSpec
+         label: 'VDBAbstractListApplication'
+         name: 'VDBAbstractListApplication'
+         uuid: '7601bfb1-8b88-11e9-8967-606720e43e2c'
+         min: (Point 10 10)
+         bounds: (Rectangle 0 0 300 300)
+       )
+       component: 
+      (SpecCollection
+         collection: (
+          (InputFieldSpec
+             name: 'EntryField1'
+             layout: (LayoutFrame 0 0 0 0 0 1 25 0)
+             uuid: '7601bfb2-8b88-11e9-8967-606720e43e2c'
+             model: filterHolder
+             immediateAccept: true
+             acceptOnReturn: true
+             acceptOnTab: true
+             acceptOnPointerLeave: true
+             emptyFieldReplacementText: 'Enter search pattern...'
+             translateEmptyFieldReplacementText: true
+             postBuildCallback: postBuildFilterView:
+           )
+          (SelectionInListModelViewSpec
+             name: 'SelectionInListModelView1'
+             layout: (LayoutFrame 0 0 25 0 0 1 0 1)
+             uuid: '7601bfb3-8b88-11e9-8967-606720e43e2c'
+             model: internalSelectionHolder
+             menu: contextMenu
+             hasHorizontalScrollBar: true
+             hasVerticalScrollBar: true
+             listModel: internalListHolder
+             useIndex: false
+             highlightMode: line
+             doubleClickSelector: doDoubleClick
+             selectConditionSelector: internalCanSelect:
+             postBuildCallback: postBuildInternalListView:
+           )
+          )
+        
+       )
+     )
+
+    "Modified: / 10-06-2019 / 15:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!BeeSymbolListApplication class methodsFor:'plugIn spec'!
+
+aspectSelectors
+    "This resource specification was automatically generated
+     by the UIPainter of ST/X."
+
+    "Do not manually edit this. If it is corrupted,
+     the UIPainter may not be able to read the specification."
+
+    "Return a description of exported aspects;
+     these can be connected to aspects of an embedding application
+     (if this app is embedded in a subCanvas)."
+
+    ^ #(
+        #debuggerHolder
+      ).
+
+! !
+
 !BeeSymbolListApplication methodsFor:'aspects'!
 
+filterHolder
+    "return/create the 'filterHolder' value holder (automatically generated)"
+
+    filterHolder isNil ifTrue:[
+        filterHolder := ValueHolder new.
+        filterHolder addDependent:self.
+    ].
+    ^ filterHolder
+
+    "Modified (format): / 10-06-2019 / 15:03:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+filterHolder:aValueHolder
+    "set the 'filterHolder' value holder (automatically generated)"
+
+    |oldValue newValue|
+
+    filterHolder notNil ifTrue:[
+        oldValue := filterHolder value.
+        filterHolder removeDependent:self.
+    ].
+    filterHolder := aValueHolder.
+    filterHolder notNil ifTrue:[
+        filterHolder addDependent:self.
+    ].
+    newValue := filterHolder value.
+    oldValue ~~ newValue ifTrue:[
+        self update:#value with:newValue from:filterHolder.
+    ].
+!
+
 selectedSymbolHolder
     "return/create the 'selectedSymbolHolder' value holder (automatically generated)"
 
@@ -87,9 +205,14 @@
         self enqueueDelayedUpdateInternalList.
         ^ self.
     ].
+    sender == filterHolder ifTrue:[ 
+        self enqueueDelayedUpdateInternalList.
+        ^ self.
+    ].
     super update:aspect with:param from:sender
 
     "Created: / 07-06-2019 / 15:05:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 10-06-2019 / 15:05:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !BeeSymbolListApplication methodsFor:'change & update-delayed'!
@@ -118,10 +241,24 @@
     | symbols symbolPs |
 
     symbols := self symbolListHolder value ? #().
+    self filterHolder value notEmptyOrNil ifTrue:[
+        | filter |
+
+        filter := StringPattern fromString: filterHolder value.
+        symbols := symbols select: [:symbol | filter match: symbol name relax: 1].
+        symbols isEmpty ifTrue:[ 
+            symbols := self symbolListHolder value ? #().    
+            symbols := symbols select: [:symbol | filter match: symbol name relax: 2].
+        ].
+        symbols isEmpty ifTrue:[ 
+            symbols := self symbolListHolder value ? #().    
+            symbols := symbols select: [:symbol | filter match: symbol name relax: 3].
+        ].
+    ].
     symbolPs := symbols collect:[ :reg | BeeSymbolPresenter new setSymbol: reg ].
     self internalListHolder value: symbolPs
 
-    "Modified: / 07-06-2019 / 14:53:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 10-06-2019 / 15:18:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 delayedUpdateSelection
@@ -144,6 +281,14 @@
     "Created: / 10-06-2019 / 14:12:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!BeeSymbolListApplication methodsFor:'hooks'!
+
+postBuildFilterView: aView
+    aView font: self textFont
+
+    "Modified: / 10-06-2019 / 15:14:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !BeeSymbolListApplication methodsFor:'initialization & release'!
 
 subscribe