--- a/SettingsDialog.st Fri Apr 22 16:02:24 2016 +0200
+++ b/SettingsDialog.st Fri Apr 22 16:02:56 2016 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 2002 by eXept Software AG
All Rights Reserved
@@ -18,7 +16,9 @@
ApplicationModel subclass:#SettingsDialog
instanceVariableNames:'requestor subCanvasApplicationHolder help doReload doSave
enableReload enableHelp enableOK selectedItem applicationList
- categoryIcons lastSelection whyDisabledInfoHolder'
+ categoryIcons lastSelection whyDisabledInfoHolder
+ quickSearchStringHolder quickSearchFieldShownHolder
+ highlightedWidgetsOriginalAttributes'
classVariableNames:'ApplicationList IconList'
poolDictionaries:''
category:'Interface-Smalltalk'
@@ -390,17 +390,58 @@
component:
(SpecCollection
collection: (
- (HierarchicalListViewSpec
- name: 'HierarchicalListView1'
- layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -34 1)
- model: selectedItem
- hasHorizontalScrollBar: true
- hasVerticalScrollBar: true
- listModel: applicationList
- useIndex: false
- highlightMode: label
- showLeftIndicators: false
- indicatorSelector: doIndicatorClick:
+ (VerticalPanelViewSpec
+ name: 'VerticalPanel1'
+ layout: (LayoutFrame 0 0 0 0 0 1 -34 1)
+ horizontalLayout: fit
+ verticalLayout: topFit
+ horizontalSpace: 3
+ verticalSpace: 3
+ component:
+ (SpecCollection
+ collection: (
+ (ViewSpec
+ name: 'QuickSearchBox'
+ visibilityChannel: quickSearchFieldShownHolder
+ component:
+ (SpecCollection
+ collection: (
+ (LabelSpec
+ label: 'Quick Search:'
+ name: 'Label1'
+ layout: (LayoutFrame 0 0 0 0 150 0 0 1)
+ translateLabel: true
+ adjust: left
+ )
+ (InputFieldSpec
+ name: 'QuickSeachEntryField'
+ layout: (LayoutFrame 150 0 0 0 0 1 0 1)
+ model: quickSearchStringHolder
+ immediateAccept: true
+ acceptOnReturn: true
+ acceptOnTab: true
+ acceptOnPointerLeave: true
+ )
+ )
+
+ )
+ extent: (Point 260 30)
+ )
+ (HierarchicalListViewSpec
+ name: 'HierarchicalListView1'
+ model: selectedItem
+ hasHorizontalScrollBar: true
+ hasVerticalScrollBar: true
+ listModel: applicationList
+ useIndex: false
+ highlightMode: label
+ showLeftIndicators: false
+ indicatorSelector: doIndicatorClick:
+ extent: (Point 260 575)
+ )
+ )
+
+ )
)
(HorizontalPanelViewSpec
name: 'HorizontalPanel2'
@@ -420,7 +461,7 @@
translateLabel: true
tabable: true
model: saveSettingsWithoutAskingForFile
- extent: (Point 126 22)
+ extent: (Point 124 22)
)
(ActionButtonSpec
label: 'Load From...'
@@ -429,7 +470,7 @@
translateLabel: true
tabable: true
model: loadSettingsFromFile
- extent: (Point 126 22)
+ extent: (Point 124 22)
)
)
@@ -493,7 +534,7 @@
tabable: true
model: help
enableChannel: enableHelp
- extent: (Point 163 22)
+ extent: (Point 161 22)
)
(ActionButtonSpec
label: 'Discard'
@@ -503,7 +544,7 @@
tabable: true
model: doReload
enableChannel: enableReload
- extent: (Point 163 22)
+ extent: (Point 162 22)
)
(ActionButtonSpec
label: 'Apply'
@@ -513,7 +554,7 @@
tabable: true
model: doSave
enableChannel: enableOK
- extent: (Point 164 22)
+ extent: (Point 162 22)
)
)
@@ -527,7 +568,7 @@
)
)
- handles: (Any 0.33750000000000002 1.0)
+ handles: (Any 0.33750000000000036 1.0)
)
)
@@ -663,6 +704,13 @@
label: 'Collapse All'
itemValue: menuCollapseAll
)
+ (MenuItem
+ label: '-'
+ )
+ (MenuItem
+ label: 'Show Search Field'
+ indication: quickSearchFieldShownHolder
+ )
)
nil
nil
@@ -1439,6 +1487,23 @@
^ requestor notNil "/ loadAndSaveSettingsItemVisible
!
+quickSearchFieldShownHolder
+ quickSearchFieldShownHolder isNil ifTrue:[
+ quickSearchFieldShownHolder := false asValue
+ ].
+ ^ quickSearchFieldShownHolder.
+!
+
+quickSearchStringHolder
+ <resource: #uiAspect>
+
+ quickSearchStringHolder isNil ifTrue:[
+ quickSearchStringHolder := ValueHolder new.
+ quickSearchStringHolder onChangeSend:#quickSearchStringHolderChanged to:self.
+ ].
+ ^ quickSearchStringHolder.
+!
+
selectedItem
selectedItem isNil ifTrue:[
selectedItem := ValueHolder new.
@@ -1490,6 +1555,7 @@
^ self
].
oldAppl modifiedChannel removeDependent:self.
+ self unhighlightWidgets.
].
item := self selectedItem value.
@@ -1555,6 +1621,8 @@
app modifiedChannel addDependent:self.
self subCanvasApplicationHolder value:app.
self modifiedChanged.
+
+ self highlightWidgetsWithMatchingSearchString
"Modified: / 29-10-2010 / 11:51:13 / cg"
"Modified: / 17-02-2012 / 10:24:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -1719,6 +1787,134 @@
self realApplicationsDo:[:app | app clearDidModifySettings].
! !
+!SettingsDialog methodsFor:'quick search support'!
+
+highlightWidgets:aSetOfWidget
+ "highlight a matching widget"
+
+ highlightedWidgetsOriginalAttributes := Dictionary new.
+ aSetOfWidget do:[:w |
+ |perWidget|
+
+ highlightedWidgetsOriginalAttributes at:w put:(perWidget := Dictionary new).
+ perWidget at:#borderWidth: put:w borderWidth.
+ perWidget at:#borderColor: put:w borderColor.
+
+ w borderWidth:2.
+ w borderColor:Color red.
+ ].
+!
+
+highlightWidgetsWithMatchingSearchString
+ "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 searchString pattern words widgetsToHighlight|
+
+ highlightedWidgetsOriginalAttributes notNil ifTrue:[
+ self unhighlightWidgets.
+ ].
+
+ searchString := self quickSearchStringHolder value.
+ searchString isEmptyOrNil ifTrue:[^ self].
+
+ pattern := '*',searchString,'*'.
+
+ (app := subCanvasApplicationHolder value) isNil ifTrue:[^ self].
+
+ widgetsToHighlight := Set new.
+ words := app quickSearchStrings.
+
+ (words contains:[:word | pattern match:word]) ifTrue:[
+ "/ ok - there is a match
+ app window withAllSubViewsDo:[:v |
+ v helpKey notNil ifTrue:[
+ (pattern match:v helpKey caseSensitive:false) ifTrue:[
+ |alreadyIn|
+
+ alreadyIn := false.
+ v allSuperViewsDo:[:sv | (widgetsToHighlight includes:sv) ifTrue:[ alreadyIn := true]].
+ alreadyIn ifFalse:[ widgetsToHighlight add:v ].
+ ].
+ ].
+ ].
+ ].
+ self highlightWidgets:widgetsToHighlight.
+!
+
+quickSearchStringHolderChanged
+ |oldSelection searchString pattern matches|
+
+ oldSelection := self selectedItem value.
+
+ "/ make all labels normal
+ applicationList root recursiveDo:[:eachSettingsAppItem |
+ eachSettingsAppItem label:(eachSettingsAppItem label string).
+ ].
+
+ searchString := self quickSearchStringHolder value.
+ searchString isEmptyOrNil ifTrue:[^ self].
+ pattern := '*',searchString,'*'.
+
+ applicationList root recursiveExpand.
+"/ applicationList root recursiveDo:[:eachSettingsAppItem |
+"/ eachSettingsAppItem expand.
+"/ ].
+ matches := OrderedCollection new.
+ "/ now search all specs for this word
+ applicationList root recursiveDo:[:eachSettingsAppItem |
+ |app words|
+
+ eachSettingsAppItem applicationClass notNil ifTrue:[
+ (app := eachSettingsAppItem application) isNil ifTrue:[
+ eachSettingsAppItem application:(app := eachSettingsAppItem applicationClass new).
+ ].
+ words := app quickSearchStrings.
+ (words contains:[:word | pattern match:word caseSensitive:false ]) ifTrue:[
+ matches add:eachSettingsAppItem.
+ ].
+ ].
+ ].
+ applicationList root children do:[:c | c recursiveCollapse].
+ "/ now expand all matches
+ matches do:[:eachMatchingItem |
+ eachMatchingItem label:(eachMatchingItem label string allBold).
+ eachMatchingItem makeVisible
+ ].
+
+ oldSelection notNil ifTrue:[
+ oldSelection makeVisible.
+ self selectedItem value:oldSelection.
+ ].
+!
+
+unhighlightWidget:aWidget
+ "unhighlight a matching widget"
+
+ highlightedWidgetsOriginalAttributes notNil ifTrue:[
+ highlightedWidgetsOriginalAttributes keysAndValuesDo:[:widget :oldValues |
+ oldValues keysAndValuesDo:[:sel :oldValue |
+ widget perform:sel with:oldValue
+ ].
+ ].
+ highlightedWidgetsOriginalAttributes := nil.
+ ].
+!
+
+unhighlightWidgets
+ "unhighlight a matching widget"
+
+ highlightedWidgetsOriginalAttributes notNil ifTrue:[
+ highlightedWidgetsOriginalAttributes keysAndValuesDo:[:widget :oldValues |
+ oldValues keysAndValuesDo:[:sel :oldValue |
+ widget perform:sel with:oldValue
+ ].
+ ].
+ highlightedWidgetsOriginalAttributes := nil.
+ ].
+! !
+
!SettingsDialog methodsFor:'selection'!
selectItemWithClass:aClass
@@ -1834,7 +2030,7 @@
!SettingsDialog::HierarchicalApplicationList::ApplicationItem methodsFor:'queries'!
canCollapse
- "the rootItem is cannot be collapsed"
+ "the rootItem cannot be collapsed"
"/ first check if we are expanded, if not answer false
^ (self isExpanded and:[self isRootItem not])