#UI_ENHANCEMENT by cg
class: SettingsDialog
added:5 methods
comment/format in: #quickSearchStringHolder
changed:5 methods
fixed quick search widget highlighting;
preps for "highlight changed settings"
--- a/SettingsDialog.st Sun Oct 30 16:26:00 2016 +0100
+++ b/SettingsDialog.st Sun Oct 30 16:26:57 2016 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 2002 by eXept Software AG
All Rights Reserved
@@ -344,7 +342,7 @@
'Save the current settings into a file.\The "settings.stx" file is automatically read upon every fresh start of ST/X.'
#quickSearchString
-'Quick search pattern. Highlights settings which contain the entered string (in the label or its tooltip).\Searches both in the presented text AND in the english original version.\\Prefix with a space to search for words starting with it;\append a space, to search for words ending with it.\Notice, that without a separator, it will often find strange partial strings (such as "update", when searching for "date")'
+'Quick search pattern.\Highlights settings which contain the entered string (in the label or its tooltip).\Searches both in the presented text AND in the english original version.\\Prefix with a space to search for words starting with it;\append a space, to search for words ending with it.\(i.e. surround with spaces to search for free standing words only.)\Notice, that without a separator, it will often find strange partial strings\(such as "update", when searching for "date", or "amount" when searching for "mou[se]")'
)
@@ -585,7 +583,7 @@
)
)
- handles: (Any 0.34000000000000002 1.0)
+ handles: (Any 0.3 1.0)
)
)
@@ -728,6 +726,11 @@
label: 'Show Search Field'
indication: quickSearchFieldShownHolder
)
+ (MenuItem
+ label: 'Show Non-Default Settings'
+ isVisible: showNonDefaultSettingsMenuItemVisibleHolder
+ indication: showNonDefaultSettingsHolder
+ )
)
nil
nil
@@ -1524,7 +1527,7 @@
quickSearchStringHolder isNil ifTrue:[
quickSearchStringHolder := ValueHolder new.
- quickSearchStringHolder onChangeSend:#quickSearchStringHolderChanged to:self.
+ quickSearchStringHolder onChangeSend:#quickSearchStringHolderChanged to:self.
].
^ quickSearchStringHolder.
!
@@ -1537,6 +1540,18 @@
^ selectedItem.
!
+showNonDefaultSettingsHolder
+ |holder|
+
+ holder := builder valueAspectFor:#'showNonDefaultSettingsHolder' initialValue:false.
+ holder onChangeSend:#showNonDefaultSettingsHolderChanged to:self.
+ ^ holder
+!
+
+showNonDefaultSettingsMenuItemVisibleHolder
+ ^ builder valueAspectFor:#'showNonDefaultSettingsMenuItemVisibleHolder' initialValue:false
+!
+
subCanvasApplicationHolder
subCanvasApplicationHolder isNil ifTrue:[
subCanvasApplicationHolder := ValueHolder new.
@@ -1851,6 +1866,40 @@
^ pattern.
!
+highlightApplicationsForWhich:aBlock
+ "common code for string search and changed-settings search.
+ Enumerates all applications with aBlock;
+ if it return true, it will be collectet and highlighted."
+
+ |oldSelection pattern showNonDefault matchingTreeItems|
+
+ applicationList root recursiveExpand.
+
+ matchingTreeItems := OrderedCollection new.
+ "/ now search all specs for this word
+ applicationList root recursiveDo:[:eachSettingsAppItem |
+ |appClass app words|
+
+ (appClass := eachSettingsAppItem applicationClass) notNil ifTrue:[
+ (app := eachSettingsAppItem application) isNil ifTrue:[
+ eachSettingsAppItem application:(app := appClass new).
+ ].
+
+ (aBlock value:app) ifTrue:[
+ matchingTreeItems add:eachSettingsAppItem.
+ ].
+ ].
+ ].
+
+ applicationList root children do:[:c | c recursiveCollapse].
+ "/ now expand all matches
+ matchingTreeItems do:[:eachMatchingItem |
+ eachMatchingItem label:(eachMatchingItem label string allBold withColor:Color red).
+ applicationList itemChanged:#redraw with:nil from:eachMatchingItem.
+ eachMatchingItem makeVisible
+ ].
+!
+
highlightWidgets:aSetOfWidget
"highlight a matching widget"
@@ -1887,12 +1936,74 @@
!
quickSearchStringHolderChanged
+ "the text in the quick search entry field has changed.
+ remember the current selection,
+ update the highlighting of matching fields (and expand corresponding tree nodes),
+ then reselect (because the treeView is too stupid in loosing the selection,
+ when expanding/hiding)"
+
|oldSelection pattern matchingTreeItems|
+ oldSelection := self selectedItem value.
+ self unhighlightFoundItemsFromSearch.
+
+ (pattern := self getWordMatchPattern) isNil ifTrue:[^ self].
+
+ self
+ highlightApplicationsForWhich:[:app |
+ |words|
+
+ words := app quickSearchStrings.
+ (words contains:[:word | pattern match:word caseSensitive:false ])
+ and:[
+ |widgetsToHighlight|
+
+ app window isNil ifTrue:[
+ true
+ ] ifFalse:[
+ widgetsToHighlight := self widgetsWithMatchingSearchStringIn:app.
+ widgetsToHighlight notEmptyOrNil.
+ ]
+ ]
+ ].
+
+ oldSelection notNil ifTrue:[
+ oldSelection makeVisible.
+ self selectedItem value:oldSelection.
+ self highlightWidgetsWithMatchingSearchString.
+ ].
+!
+
+showNonDefaultSettingsHolderChanged
+ "the show-non-default settings check box has changed.
+ remember the current selection,
+ update the highlighting of matching fields (and expand corresponding tree nodes),
+ then reselect (because the treeView is too stupid in loosing the selection,
+ when expanding/hiding)"
+
+ |oldSelection pattern showNonDefault matchingTreeItems|
+
+ oldSelection := self selectedItem value.
+ self unhighlightFoundItemsFromSearch.
+
+ (showNonDefault := self showNonDefaultSettingsHolder value) ifFalse:[^ self].
+
+ self highlightApplicationsForWhich:[:app | app hasValuesDifferentFromDefault].
+
+ oldSelection notNil ifTrue:[
+ oldSelection makeVisible.
+ self selectedItem value:oldSelection.
+ self highlightWidgetsWithMatchingSearchString.
+ ].
+!
+
+unhighlightFoundItemsFromSearch
+ "undo any highlighting of matching fields (from the previous show matching items)"
+
+ |oldSelection pattern showNonDefault matchingTreeItems|
+
self unhighlightWidgets.
- oldSelection := self selectedItem value.
-
"/ make all labels normal
applicationList root recursiveDo:[:eachSettingsAppItem |
|lbl|
@@ -1902,46 +2013,6 @@
applicationList itemChanged:#redraw with:nil from:eachSettingsAppItem.
].
].
-
- (pattern := self getWordMatchPattern) isNil ifTrue:[^ self].
-
- applicationList root recursiveExpand.
-"/ applicationList root recursiveDo:[:eachSettingsAppItem |
-"/ eachSettingsAppItem expand.
-"/ ].
- matchingTreeItems := OrderedCollection new.
- "/ now search all specs for this word
- applicationList root recursiveDo:[:eachSettingsAppItem |
- |appClass app words|
-
- (appClass := eachSettingsAppItem applicationClass) notNil ifTrue:[
- (app := eachSettingsAppItem application) isNil ifTrue:[
- eachSettingsAppItem application:(app := appClass new).
- ].
- words := app quickSearchStrings.
- (words contains:[:word | pattern match:word caseSensitive:false ]) ifTrue:[
- (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
- matchingTreeItems do:[:eachMatchingItem |
- eachMatchingItem label:(eachMatchingItem label string allBold withColor:Color red).
- applicationList itemChanged:#redraw with:nil from:eachMatchingItem.
- eachMatchingItem makeVisible
- ].
-
- oldSelection notNil ifTrue:[
- oldSelection makeVisible.
- self selectedItem value:oldSelection.
- self highlightWidgetsWithMatchingSearchString.
- ].
!
unhighlightWidgets
@@ -1963,10 +2034,25 @@
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 words widgetsToHighlight allWords|
(pattern := self getWordMatchPattern) isNil ifTrue:[^ self].
+ allWords :=
+ [:text |
+
+ |words xLatedText|
+ words := Set new.
+ text notNil ifTrue:[
+ text asCollectionOfWordsDo:[:w | words add:w asLowercase].
+ xLatedText := anApplication resources string:text.
+ (xLatedText notNil and:[xLatedText ~= text]) ifTrue:[
+ xLatedText asCollectionOfWordsDo:[:w | words add:w asLowercase].
+ ].
+ ].
+ words
+ ].
+
widgetsToHighlight := Set new.
words := anApplication quickSearchStrings.
@@ -1975,29 +2061,21 @@
"/ look which widget matches it in its helpKey or label
anApplication window withAllSubViewsDo:[:eachView |
- |wordsInWidget widgetHasIt label helpKey xLatedText helpText|
+ |wordsInWidget widgetHasIt label helpKey xLatedText helpText tooltip|
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].
- ].
- ].
+ wordsInWidget addAll:(allWords value:helpText).
+ tooltip := anApplication flyByHelpTextForKey:helpKey.
+ wordsInWidget addAll:(allWords value:tooltip).
].
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].
- ].
+ wordsInWidget addAll:(allWords value:label)
].
widgetHasIt := wordsInWidget contains:[:w | pattern match:w caseSensitive:false ].
@@ -2008,7 +2086,8 @@
alreadyIn := false.
eachView allSuperViewsDo:[:sv | (widgetsToHighlight includes:sv) ifTrue:[ alreadyIn := true]].
alreadyIn ifFalse:[ widgetsToHighlight add:eachView ].
- ].
+ ] ifFalse:[
+ ].
].
].
^ widgetsToHighlight.