Add utility method `PluggableHierarchicalList >> roots:`
This allows one to set multiple objects as root without a need to manually
create synthetic root object. Useful to show a collection of hierachical object.
--- a/PluggableHierarchicalList.st Fri Sep 17 12:47:39 2021 +0100
+++ b/PluggableHierarchicalList.st Fri Jul 29 17:54:29 2022 +0100
@@ -1,5 +1,6 @@
"
COPYRIGHT (c) 2015 Jan Vrany
+ COPYRIGHT (c) 2022 LabWare
All Rights Reserved
This software is furnished under a license and may be used
@@ -25,6 +26,7 @@
copyright
"
COPYRIGHT (c) 2015 Jan Vrany
+ COPYRIGHT (c) 2022 LabWare
All Rights Reserved
This software is furnished under a license and may be used
@@ -114,6 +116,25 @@
super root: item.
"Created: / 21-05-2015 / 19:17:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+roots: aCollection
+ | rootItem |
+
+ rootItem := HierarchicalItemWithLabelAndIconAndValue new.
+ rootItem label: 'Root'.
+ rootItem children: (aCollection collect: [ :child |
+ | childItem |
+ childItem := HierarchicalItemWithLabelAndIconAndValue new.
+ childItem label: (labelBlock notNil ifTrue:[ labelBlock value: child ] ifFalse:[ child displayString ]).
+ childItem icon: (iconBlock notNil ifTrue:[ iconBlock value: child] ifFalse:[ nil ]).
+ childItem value: child.
+ childItem parent: rootItem
+ ]).
+ rootItem expand.
+ super root: rootItem.
+
+ "Created: / 29-07-2022 / 17:19:07 / Jan Vrany <jan.vrany@labware.com>"
! !
!PluggableHierarchicalList methodsFor:'protocol'!
@@ -135,3 +156,10 @@
"Created: / 21-05-2015 / 19:19:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!PluggableHierarchicalList class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+