157 addCategory:category |
157 addCategory:category |
158 |item path parentPath parentCategory parentItem| |
158 |item path parentPath parentCategory parentItem| |
159 |
159 |
160 item:= categoryToItemDictionary at:category ifAbsent:nil. |
160 item:= categoryToItemDictionary at:category ifAbsent:nil. |
161 item isNil ifTrue:[ |
161 item isNil ifTrue:[ |
162 path := category asCollectionOfSubstringsSeparatedBy:$-. |
162 path := category asCollectionOfSubstringsSeparatedBy:$-. |
163 |
163 |
164 item := ClassCategoryItem new. |
164 item := ClassCategoryItem new. |
165 item category:category. |
165 item category:category. |
166 item label:(path last). |
166 item label:(path last). |
167 categoryToItemDictionary at:category put:item. |
167 categoryToItemDictionary at:category put:item. |
168 |
168 |
169 category size > 0 ifTrue:[ |
169 category size > 0 ifTrue:[ |
170 "/ find the parent ... |
170 "/ find the parent ... |
171 parentPath := path copyWithoutLast:1. |
171 parentPath := path copyButLast:1. |
172 parentCategory := parentPath asStringWith:$-. |
172 parentCategory := parentPath asStringWith:$-. |
173 |
173 |
174 parentItem := self addCategory:parentCategory . |
174 parentItem := self addCategory:parentCategory . |
175 |
175 |
176 parentItem add:item sortBlock:[:i1 :i2 | i1 category asLowercase < i2 category asLowercase]. |
176 parentItem add:item sortBlock:[:i1 :i2 | i1 category asLowercase < i2 category asLowercase]. |
177 ] |
177 ] |
178 ]. |
178 ]. |
179 ^ item |
179 ^ item |
180 ! |
180 ! |
181 |
181 |
182 generateHierarchicalCategoryTree |
182 generateHierarchicalCategoryTree |