#UI_ENHANCEMENT by cg
class: AbstractLauncherApplication
refactored the packagedialog
avoid useless redraws.
--- a/AbstractLauncherApplication.st Sun Oct 16 13:55:19 2016 +0200
+++ b/AbstractLauncherApplication.st Sun Oct 16 14:30:20 2016 +0200
@@ -36,12 +36,19 @@
itemsByPath getItemByPath myHierarchicalItemWithLabelAndIcon
filterHolder masterRoot infoTextHolder loadButton
loadAndBrowseButton selectedPackageHolder monticelloRoot
- backgroundPackageFindProcess'
+ backgroundPackageFindProcess itemsMatchingFilter'
classVariableNames:'PreviousPackageDialogItems PreviousPackageDialogExtent'
poolDictionaries:''
privateIn:AbstractLauncherApplication
!
+HierarchicalItemWithLabelAndIcon subclass:#MyHierarchicalItem
+ instanceVariableNames:'type info'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:AbstractLauncherApplication::PackageLoadDialog
+!
+
!AbstractLauncherApplication class methodsFor:'documentation'!
copyright
@@ -7244,35 +7251,20 @@
packageIdByItem := IdentityDictionary new.
pathByItem := IdentityDictionary new.
- Class withoutUpdatingChangesDo:[
- myHierarchicalItemWithLabelAndIcon :=
- HierarchicalItemWithLabelAndIcon
- subclass:#myHierarchicalItemWithLabelAndIcon
- instanceVariableNames:'type info'
- classVariableNames:''
- poolDictionaries:''
- category:nil
- inEnvironment:nil.
- myHierarchicalItemWithLabelAndIcon compile:'type ^ type'.
- myHierarchicalItemWithLabelAndIcon compile:'type:aSymbol type := aSymbol'.
- myHierarchicalItemWithLabelAndIcon compile:'info ^ info'.
- myHierarchicalItemWithLabelAndIcon compile:'info:anObject info := anObject'.
- ].
-
list := HierarchicalList new.
- masterRoot := myHierarchicalItemWithLabelAndIcon new.
+ masterRoot := MyHierarchicalItem new.
masterRoot icon:(ToolbarIconLibrary stxHomeIcon).
masterRoot label:(resources string:'local ').
masterRoot type:#localRoot.
- root := myHierarchicalItemWithLabelAndIcon new.
+ root := MyHierarchicalItem new.
root icon:folderIcon.
root label:((resources string:'[Compiled Packages]') asText allItalic withColor:Color grey).
root type:#compiledPackagesRoot.
masterRoot add:root.
- monticelloRoot := myHierarchicalItemWithLabelAndIcon new.
+ monticelloRoot := MyHierarchicalItem new.
monticelloLabel := ((resources string:'[Monticello Packages]') asText allItalic withColor:Color grey).
monticelloRoot type:#monticelloRoot.
@@ -7419,54 +7411,63 @@
!
filterChangedAction
- |matchingItems filterPattern isMatch firstMatchingItem|
+ |newMatchingItems filterPattern isMatch firstMatchingItem|
filterPattern := filterHolder value.
filterPattern isEmptyOrNil ifTrue:[
- "/ nothing
+ itemsMatchingFilter notEmptyOrNil ifTrue:[
+ "/ nothing
+ root recursiveDo:[:item |
+ item label:(item label copy asText allNonBold withoutAnyColorEmphasis).
+ ].
+ ].
+ itemsMatchingFilter := #().
+ ^ self.
+ ].
+
+ filterPattern := filterPattern asLowercase.
+ isMatch := filterPattern includesMatchCharacters.
+
+ newMatchingItems := OrderedCollection new.
+ masterRoot recursiveDo:[:item |
+ |itemLabel itemPackage|
+
+ itemLabel := item label.
+ itemPackage := packageIdByItem at:item ifAbsent:''.
+
+ ((isMatch and:[itemLabel matches:filterPattern caseSensitive:false])
+ or:[ (isMatch not and:[ itemLabel asLowercase includesString:filterPattern ])
+ or:[ (isMatch and:[itemPackage matches:filterPattern caseSensitive:false])
+ or:[ isMatch not and:[ itemPackage asLowercase includesString:filterPattern ]]]])
+ ifTrue:[
+ newMatchingItems add:item.
+ ]
+ ].
+ (newMatchingItems sameContentsAs:itemsMatchingFilter) ifTrue:[
+ ^ self
+ ].
+
+ newMatchingItems isEmpty ifTrue:[
+ "/ nothing found
root recursiveDo:[:item |
item label:(item label copy asText allNonBold withoutAnyColorEmphasis).
].
+ Screen current beep.
] ifFalse:[
- filterPattern := filterPattern asLowercase.
- isMatch := filterPattern includesMatchCharacters.
-
- matchingItems := OrderedCollection new.
+ "/ collapse all and fully expand all matching items
masterRoot recursiveDo:[:item |
- |itemLabel itemPackage|
-
- itemLabel := item label.
- itemPackage := packageIdByItem at:item ifAbsent:''.
-
- ((isMatch and:[itemLabel matches:filterPattern caseSensitive:false])
- or:[ (isMatch not and:[ itemLabel asLowercase includesString:filterPattern ])
- or:[ (isMatch and:[itemPackage matches:filterPattern caseSensitive:false])
- or:[ isMatch not and:[ itemPackage asLowercase includesString:filterPattern ]]]])
- ifTrue:[
- matchingItems add:item.
- ]
+ item collapse.
+ item label:(item label copy asText allNonBold withColor:Color grey).
].
- matchingItems isEmpty ifTrue:[
- "/ nothing found
- root recursiveDo:[:item |
- item label:(item label copy asText allNonBold withoutAnyColorEmphasis).
- ].
- Screen current beep.
- ] ifFalse:[
- "/ collapse all and fully expand all matching items
- masterRoot recursiveDo:[:item |
- item collapse.
- item label:(item label copy asText allNonBold withColor:Color grey).
- ].
- firstMatchingItem := nil.
- matchingItems do:[:item |
- item label:(item label copy asText allBold withoutAnyColorEmphasis).
- item makeVisible.
- firstMatchingItem := firstMatchingItem ? item.
- ].
- hierarchicalListView makeLineVisible:firstMatchingItem listIndex.
+ firstMatchingItem := nil.
+ newMatchingItems do:[:item |
+ item label:(item label copy asText allBold withoutAnyColorEmphasis).
+ item makeVisible.
+ firstMatchingItem := firstMatchingItem ? item.
].
- ].
+ hierarchicalListView makeLineVisible:firstMatchingItem listIndex.
+ ].
+ itemsMatchingFilter := newMatchingItems.
!
getItemByPath:path packageID:packageID under:aRoot
@@ -7480,7 +7481,7 @@
ifFalse:[ itemsByPath at:( {aRoot label},path) ifAbsent:nil ].
item isNil ifTrue:[
parent := self getItemByPath:(path copyButLast) packageID:packageID under:aRoot.
- item := myHierarchicalItemWithLabelAndIcon new
+ item := MyHierarchicalItem new
children:#();
icon:greyFolderIcon;
label:path last.
@@ -7500,7 +7501,7 @@
do:[:each |
|reposItem|
- reposItem := myHierarchicalItemWithLabelAndIcon new.
+ reposItem := MyHierarchicalItem new.
reposItem icon:folderIcon.
reposItem label:each displayString , ((resources string:' [MC Repository]') asText allItalic withColor:Color grey).
reposItem type:#monticelloRepository.
@@ -7510,7 +7511,7 @@
each allPackageNames asSortedCollection do:[:eachPackage |
|packageItem|
- packageItem := myHierarchicalItemWithLabelAndIcon new.
+ packageItem := MyHierarchicalItem new.
packageItem icon:packageIcon.
packageItem label:eachPackage.
packageItem type:#monticelloPackage.
@@ -7728,7 +7729,7 @@
path := subDir asFilename components.
(itemsByPath at:( {root label},path) ifAbsent:nil) isNil ifTrue:[
folderRoot isNil ifTrue:[
- folderRoot := myHierarchicalItemWithLabelAndIcon new.
+ folderRoot := MyHierarchicalItem new.
folderRoot icon:folderIcon.
folderRoot label:((resources string:'[%1]' with:eachDirName) asText allItalic withColor:Color grey).
folderRoot type:#compiledPackagesRoot.
@@ -8065,6 +8066,24 @@
].
! !
+!AbstractLauncherApplication::PackageLoadDialog::MyHierarchicalItem methodsFor:'accessing'!
+
+info
+ ^ info
+!
+
+info:something
+ info := something.
+!
+
+type
+ ^ type
+!
+
+type:something
+ type := something.
+! !
+
!AbstractLauncherApplication class methodsFor:'documentation'!
version