--- a/SettingsDialog.st Thu Nov 24 22:03:16 2016 +0000
+++ b/SettingsDialog.st Thu Nov 24 22:14:31 2016 +0000
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 2002 by eXept Software AG
All Rights Reserved
@@ -342,7 +344,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]")'
)
@@ -431,7 +433,7 @@
)
)
- extent: (Point 280 30)
+ extent: (Point 249 30)
)
(HierarchicalListViewSpec
name: 'HierarchicalListView1'
@@ -443,7 +445,7 @@
highlightMode: label
showLeftIndicators: false
indicatorSelector: doIndicatorClick:
- extent: (Point 280 589)
+ extent: (Point 249 589)
)
)
@@ -467,7 +469,7 @@
translateLabel: true
tabable: true
model: saveSettingsWithoutAskingForFile
- extent: (Point 135 22)
+ extent: (Point 118 28)
)
(ActionButtonSpec
label: 'Load From...'
@@ -476,7 +478,7 @@
translateLabel: true
tabable: true
model: loadSettingsFromFile
- extent: (Point 136 22)
+ extent: (Point 119 28)
)
)
@@ -540,7 +542,7 @@
tabable: true
model: help
enableChannel: enableHelp
- extent: (Point 131 22)
+ extent: (Point 138 28)
)
(ActionButtonSpec
label: 'Close'
@@ -549,7 +551,7 @@
visibilityChannel: closeButtonVisibleHolder
translateLabel: true
model: closeRequest
- extent: (Point 132 22)
+ extent: (Point 138 28)
)
(ActionButtonSpec
label: 'Discard'
@@ -559,7 +561,7 @@
tabable: true
model: doReload
enableChannel: enableReload
- extent: (Point 132 22)
+ extent: (Point 138 28)
)
(ActionButtonSpec
label: 'Apply'
@@ -569,7 +571,7 @@
tabable: true
model: doSave
enableChannel: enableOK
- extent: (Point 132 22)
+ extent: (Point 139 28)
)
)
@@ -583,7 +585,7 @@
)
)
- handles: (Any 0.34000000000000002 1.0)
+ handles: (Any 0.29999999999999999 1.0)
)
)
@@ -714,18 +716,27 @@
(MenuItem
label: 'Expand All'
itemValue: menuExpandAll
+ hideMenuOnActivated: false
)
(MenuItem
label: 'Collapse All'
itemValue: menuCollapseAll
+ hideMenuOnActivated: false
)
(MenuItem
label: '-'
)
(MenuItem
label: 'Show Search Field'
+ hideMenuOnActivated: false
indication: quickSearchFieldShownHolder
)
+ (MenuItem
+ label: 'Show Non-Default Settings'
+ isVisible: showNonDefaultSettingsMenuItemVisibleHolder
+ hideMenuOnActivated: false
+ indication: showNonDefaultSettingsHolder
+ )
)
nil
nil
@@ -1522,7 +1533,7 @@
quickSearchStringHolder isNil ifTrue:[
quickSearchStringHolder := ValueHolder new.
- quickSearchStringHolder onChangeSend:#quickSearchStringHolderChanged to:self.
+ quickSearchStringHolder onChangeSend:#quickSearchStringHolderChanged to:self.
].
^ quickSearchStringHolder.
!
@@ -1535,6 +1546,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.
@@ -1637,18 +1660,22 @@
app settingsDialog:self.
app basicInitialize.
app createBuilder.
+ app initialize.
].
self withWaitCursorDo:[
app settingsDialog:self.
- app initialize.
app readSettings.
].
app modifiedChannel addDependent:self.
self subCanvasApplicationHolder value:app.
self modifiedChanged.
- self highlightWidgetsWithMatchingSearchString
-
+ self highlightWidgetsWithMatchingSearchString.
+ "/ does not yet work fully
+ false ifTrue:[
+ self highlightWidgetsWithChangedSettings.
+ ].
+
"Modified: / 29-10-2010 / 11:51:13 / cg"
"Modified: / 17-02-2012 / 10:24:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
@@ -1669,6 +1696,69 @@
super update:something with:aParameter from:changedObject
! !
+!SettingsDialog methodsFor:'changed settings highlighting'!
+
+highlightWidgetsWithChangedSettings
+ "whenever an app is selected AND a quick search string is present,
+ 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 widgetsToHighlight|
+
+ highlightedWidgetsOriginalAttributes notNil ifTrue:[
+ self unhighlightWidgets.
+ ].
+
+ (app := subCanvasApplicationHolder value) isNil ifTrue:[^ self].
+
+ widgetsToHighlight := self widgetsWithChangedSettingsIn:app.
+ self highlightWidgets:widgetsToHighlight.
+!
+
+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 highlightWidgetsWithChangedSettings
+ ].
+!
+
+widgetsWithChangedSettingsIn:anApplication
+ "helper:
+ go through the widgets and find those which have a value different
+ from the default settings.
+ This is done by looking at model value (hope they have)"
+
+ | widgetsToHighlight |
+
+ widgetsToHighlight := Set new.
+
+ anApplication widgetsWithChangedSettingsDo:[:eachView |
+ |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:'initialization & release'!
closeRequest
@@ -1851,6 +1941,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"
@@ -1862,7 +1986,7 @@
perWidget at:#borderWidth: put:w borderWidth.
perWidget at:#borderColor: put:w borderColor.
- w borderWidth:2.
+ w borderWidth:1.
w borderColor:Color red.
].
!
@@ -1887,12 +2011,51 @@
!
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 |
+ |ok words widgetsToHighlight|
+
+ words := app quickSearchStrings.
+ ok := false.
+ (words contains:[:word | pattern match:word caseSensitive:false ])
+ ifTrue:[
+ app window isNil ifTrue:[
+ ok := true
+ ] ifFalse:[
+ widgetsToHighlight := self widgetsWithMatchingSearchStringIn:app.
+ ok := widgetsToHighlight notEmptyOrNil.
+ ]
+ ].
+ ok
+ ].
+
+ 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 +2065,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 +2086,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 +2113,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 ].
@@ -2007,8 +2137,24 @@
"/ 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 ].
- ].
+ alreadyIn ifFalse:[
+ ((eachView superView isKindOf:HorizontalPanelView)
+ or:[eachView superView class == View]) ifTrue:[
+ (widgetsToHighlight includes:eachView superView) ifFalse:[
+ eachView superView subViews size > 1 ifTrue:[
+ (eachView superView subViews contains:[:some | widgetsToHighlight includes:some])
+ ifTrue:[
+ "/ multiple in a panel; highlight the panel, not the children.
+ widgetsToHighlight add:eachView superView.
+ widgetsToHighlight removeAllFoundIn:eachView superView subViews.
+ alreadyIn := true.
+ ].
+ ].
+ ].
+ ].
+ alreadyIn ifFalse:[ widgetsToHighlight add:eachView ].
+ ]
+ ].
].
].
^ widgetsToHighlight.