#FEATURE by cg
class: SettingsDialog
added: #widgetsWithMatchingSearchStringIn:
changed:
#highlightWidgetsWithMatchingSearchString
#quickSearchStringHolderChanged
--- a/SettingsDialog.st Mon May 02 17:37:02 2016 +0200
+++ b/SettingsDialog.st Tue May 03 13:18:35 2016 +0200
@@ -1848,7 +1848,7 @@
go through the widgets and highlight those which match.
This is done by looking at the helpkey and model aspects for a match"
- |app pattern words widgetsToHighlight|
+ |app pattern widgetsToHighlight|
highlightedWidgetsOriginalAttributes notNil ifTrue:[
self unhighlightWidgets.
@@ -1858,55 +1858,12 @@
(app := subCanvasApplicationHolder value) isNil ifTrue:[^ self].
- widgetsToHighlight := Set new.
- words := app quickSearchStrings.
-
- (words contains:[:word | pattern match:word caseSensitive:false]) ifTrue:[
- "/ ok - there is a match in this app;
- "/ look which widget matches it in its helpKey or label
-
- app window withAllSubViewsDo:[:eachView |
- |wordsInWidget widgetHasIt label helpKey xLatedText helpText|
-
- wordsInWidget := Set new.
-
- (helpKey := eachView helpKey) notNil ifTrue:[
- wordsInWidget add:helpKey.
- helpText := app helpTextForKey:helpKey.
- helpText notNil ifTrue:[
- helpText asCollectionOfWordsDo:[:w | wordsInWidget add:w asLowercase].
- xLatedText := app resources string:helpText.
- (xLatedText notNil and:[xLatedText ~= helpText]) ifTrue:[
- xLatedText asCollectionOfWordsDo:[:w | wordsInWidget add:w asLowercase].
- ].
- ].
- ].
- label := eachView perform:#label ifNotUnderstood:nil.
- (label notNil and:[label isString]) ifTrue:[
- label := label string.
- label asCollectionOfWordsDo:[:w | wordsInWidget add:w asLowercase].
- xLatedText := app resources string:label.
- (xLatedText notNil and:[xLatedText ~= label]) ifTrue:[
- xLatedText asCollectionOfWordsDo:[:w | wordsInWidget add:w asLowercase].
- ].
- ].
-
- widgetHasIt := wordsInWidget contains:[:w | pattern match:w caseSensitive:false ].
- widgetHasIt ifTrue:[
- |alreadyIn|
-
- "/ check if a superview also has it (frames/framedboxes, etc.)
- alreadyIn := false.
- eachView allSuperViewsDo:[:sv | (widgetsToHighlight includes:sv) ifTrue:[ alreadyIn := true]].
- alreadyIn ifFalse:[ widgetsToHighlight add:eachView ].
- ].
- ].
- ].
+ widgetsToHighlight := self widgetsWithMatchingSearchStringIn:app.
self highlightWidgets:widgetsToHighlight.
!
quickSearchStringHolderChanged
- |oldSelection pattern matches|
+ |oldSelection pattern matchingTreeItems|
self unhighlightWidgets.
@@ -1928,24 +1885,29 @@
"/ applicationList root recursiveDo:[:eachSettingsAppItem |
"/ eachSettingsAppItem expand.
"/ ].
- matches := OrderedCollection new.
+ matchingTreeItems := OrderedCollection new.
"/ now search all specs for this word
applicationList root recursiveDo:[:eachSettingsAppItem |
- |app words|
+ |appClass app words|
- eachSettingsAppItem applicationClass notNil ifTrue:[
+ (appClass := eachSettingsAppItem applicationClass) notNil ifTrue:[
(app := eachSettingsAppItem application) isNil ifTrue:[
- eachSettingsAppItem application:(app := eachSettingsAppItem applicationClass new).
+ eachSettingsAppItem application:(app := appClass new).
].
words := app quickSearchStrings.
(words contains:[:word | pattern match:word caseSensitive:false ]) ifTrue:[
- matches add:eachSettingsAppItem.
+ (app window notNil
+ and:[ (self widgetsWithMatchingSearchStringIn:app) isEmptyOrNil]) ifTrue:[
+ self breakPoint:#cg.
+ ] ifFalse:[
+ matchingTreeItems add:eachSettingsAppItem.
+ ].
].
].
].
applicationList root children do:[:c | c recursiveCollapse].
"/ now expand all matches
- matches do:[:eachMatchingItem |
+ matchingTreeItems do:[:eachMatchingItem |
eachMatchingItem label:(eachMatchingItem label string allBold colorizeAllWith:Color red).
applicationList itemChanged:#redraw with:nil from:eachMatchingItem.
eachMatchingItem makeVisible
@@ -1970,6 +1932,62 @@
].
highlightedWidgetsOriginalAttributes := nil.
].
+!
+
+widgetsWithMatchingSearchStringIn:anApplication
+ "helper:
+ go through the widgets and find those which match.
+ This is done by looking at the helpkey and model aspects for a match"
+
+ |pattern words widgetsToHighlight|
+
+ (pattern := self getWordMatchPattern) isNil ifTrue:[^ self].
+
+ widgetsToHighlight := Set new.
+ words := anApplication quickSearchStrings.
+
+ (words contains:[:word | pattern match:word caseSensitive:false]) ifTrue:[
+ "/ ok - there is a match in this app;
+ "/ look which widget matches it in its helpKey or label
+
+ anApplication window withAllSubViewsDo:[:eachView |
+ |wordsInWidget widgetHasIt label helpKey xLatedText helpText|
+
+ wordsInWidget := Set new.
+
+ (helpKey := eachView helpKey) notNil ifTrue:[
+ wordsInWidget add:helpKey.
+ helpText := anApplication helpTextForKey:helpKey.
+ helpText notNil ifTrue:[
+ helpText asCollectionOfWordsDo:[:w | wordsInWidget add:w asLowercase].
+ xLatedText := anApplication resources string:helpText.
+ (xLatedText notNil and:[xLatedText ~= helpText]) ifTrue:[
+ xLatedText asCollectionOfWordsDo:[:w | wordsInWidget add:w asLowercase].
+ ].
+ ].
+ ].
+ label := eachView perform:#label ifNotUnderstood:nil.
+ (label notNil and:[label isString]) ifTrue:[
+ label := label string.
+ label asCollectionOfWordsDo:[:w | wordsInWidget add:w asLowercase].
+ xLatedText := anApplication resources string:label.
+ (xLatedText notNil and:[xLatedText ~= label]) ifTrue:[
+ xLatedText asCollectionOfWordsDo:[:w | wordsInWidget add:w asLowercase].
+ ].
+ ].
+
+ widgetHasIt := wordsInWidget contains:[:w | pattern match:w caseSensitive:false ].
+ widgetHasIt ifTrue:[
+ |alreadyIn|
+
+ "/ check if a superview also has it (frames/framedboxes, etc.)
+ alreadyIn := false.
+ eachView allSuperViewsDo:[:sv | (widgetsToHighlight includes:sv) ifTrue:[ alreadyIn := true]].
+ alreadyIn ifFalse:[ widgetsToHighlight add:eachView ].
+ ].
+ ].
+ ].
+ ^ widgetsToHighlight.
! !
!SettingsDialog methodsFor:'selection'!