92 |
92 |
93 getChildren |
93 getChildren |
94 "returns the children as they are present (or not); not going to the model..." |
94 "returns the children as they are present (or not); not going to the model..." |
95 |
95 |
96 ^ children |
96 ^ children |
97 |
|
98 "Modified: / 09-07-2010 / 08:43:29 / cg" |
|
99 ! |
97 ! |
100 |
98 |
101 level |
99 level |
102 "returns the level starting with 1" |
100 "returns the level starting with 0 for the root" |
103 |
101 |
104 |item level| |
102 |item level| |
105 |
103 |
106 "/ for optimization we try to suppress a block |
104 item := self. |
107 |
105 level := 0. |
108 item := self. |
106 |
109 |
107 [ (item := item parentOrModel) notNil] whileTrue:[ |
110 (item := item parentOrModel) isNil ifTrue:[^ 0]. |
|
111 (item := item parentOrModel) isNil ifTrue:[^ 1]. |
|
112 (item := item parentOrModel) isNil ifTrue:[^ 2]. |
|
113 (item := item parentOrModel) isNil ifTrue:[^ 3]. |
|
114 (item := item parentOrModel) isNil ifTrue:[^ 4]. |
|
115 (item := item parentOrModel) isNil ifTrue:[^ 5]. |
|
116 (item := item parentOrModel) isNil ifTrue:[^ 6]. |
|
117 |
|
118 level := 7. |
|
119 |
|
120 [(item := item parentOrModel) notNil] whileTrue:[ |
|
121 level := level + 1. |
108 level := level + 1. |
122 level > 100000 ifTrue:[ |
109 level > 100000 ifTrue:[ |
123 self halt:'possibly recursive item hierarchy' |
110 self halt:'possibly recursive item hierarchy' |
124 ]. |
111 ]. |
125 ]. |
112 ]. |
126 ^ level |
113 ^ level |
127 |
114 |
128 "Modified: / 09-07-2010 / 08:40:56 / cg" |
115 "Modified: / 09-07-2010 / 08:56:27 / cg" |
129 ! |
116 ! |
130 |
117 |
131 parent |
118 parent |
132 "returns the parent or nil" |
119 "returns the parent or nil" |
133 |
120 |
134 ^ (parent notNil and:[parent isHierarchicalItem]) |
121 ^ (parent notNil and:[parent isHierarchicalItem]) |
135 ifTrue:[parent] |
122 ifTrue:[parent] |
136 ifFalse:[nil] |
123 ifFalse:[nil] |
137 |
|
138 "Modified: / 09-07-2010 / 08:36:07 / cg" |
|
139 ! |
124 ! |
140 |
125 |
141 parent:aParent |
126 parent:aParent |
142 "set the parent (or the model if the item is the root item)" |
127 "set the parent (or the model if the item is the root item)" |
143 |
128 |
144 parent := aParent |
129 parent := aParent |
145 |
|
146 "Modified: / 09-07-2010 / 08:35:52 / cg" |
|
147 ! |
130 ! |
148 |
131 |
149 rootItem |
132 rootItem |
150 "returns the root item" |
133 "returns the root item" |
151 |
134 |
152 parent isHierarchicalItem ifTrue:[ |
135 parent isHierarchicalItem ifTrue:[ |
153 ^ parent rootItem |
136 ^ parent rootItem |
154 ]. |
137 ]. |
155 ^ self |
138 ^ self |
156 |
|
157 "Modified: / 09-07-2010 / 08:32:41 / cg" |
|
158 ! ! |
139 ! ! |
159 |
140 |
160 !HierarchicalItem methodsFor:'accessing-children'! |
141 !HierarchicalItem methodsFor:'accessing-children'! |
161 |
142 |
162 at:anIndex |
143 at:anIndex |
595 parent notNil ifTrue:[ "check whether parent exists" |
564 parent notNil ifTrue:[ "check whether parent exists" |
596 parent isHierarchicalItem ifTrue:[parent remove:self] "parent is HierarchicalItem" |
565 parent isHierarchicalItem ifTrue:[parent remove:self] "parent is HierarchicalItem" |
597 ifFalse:[parent root:nil] "parent is HierarchicalList" |
566 ifFalse:[parent root:nil] "parent is HierarchicalList" |
598 ]. |
567 ]. |
599 ^ self |
568 ^ self |
600 |
|
601 "Modified: / 09-07-2010 / 08:33:24 / cg" |
|
602 ! |
569 ! |
603 |
570 |
604 remove:aChild |
571 remove:aChild |
605 "remove a child" |
572 "remove a child" |
606 |
573 |
607 self removeIndex:(self identityIndexOf:aChild) |
574 self removeIndex:(self identityIndexOf:aChild) |
608 |
|
609 "Modified: / 09-07-2010 / 08:33:19 / cg" |
|
610 ! |
575 ! |
611 |
576 |
612 removeAll |
577 removeAll |
613 "remove all children" |
578 "remove all children" |
614 |
579 |
615 |size| |
580 |size| |
616 |
581 |
617 (size := children size) ~~ 0 ifTrue:[ |
582 (size := children size) ~~ 0 ifTrue:[ |
618 self removeFromIndex:1 toIndex:size |
583 self removeFromIndex:1 toIndex:size |
619 ] |
584 ] |
620 |
|
621 "Modified: / 09-07-2010 / 08:33:12 / cg" |
|
622 ! |
585 ! |
623 |
586 |
624 removeAll:aList |
587 removeAll:aList |
625 "remove all children in the collection" |
588 "remove all children in the collection" |
626 |
589 |
634 ] |
597 ] |
635 ] |
598 ] |
636 ] |
599 ] |
637 ]. |
600 ]. |
638 ^ aList |
601 ^ aList |
639 |
|
640 "Modified: / 09-07-2010 / 08:33:08 / cg" |
|
641 ! |
602 ! |
642 |
603 |
643 removeFromIndex:startIndex |
604 removeFromIndex:startIndex |
644 "remove the children from startIndex up to end of children" |
605 "remove the children from startIndex up to end of children" |
645 |
606 |
646 ^ self removeFromIndex:startIndex toIndex:(children size) |
607 ^ self removeFromIndex:startIndex toIndex:(children size) |
647 |
|
648 "Modified: / 09-07-2010 / 08:33:03 / cg" |
|
649 ! |
608 ! |
650 |
609 |
651 removeFromIndex:startIndex toIndex:stopIndex |
610 removeFromIndex:startIndex toIndex:stopIndex |
652 "remove the children from startIndex up to and including |
611 "remove the children from startIndex up to and including |
653 the child under stopIndex." |
612 the child under stopIndex." |
667 children size == 0 ifTrue:[ |
626 children size == 0 ifTrue:[ |
668 self clearExpandedWhenLastChildWasRemoved ifTrue:[ |
627 self clearExpandedWhenLastChildWasRemoved ifTrue:[ |
669 isExpanded := false. |
628 isExpanded := false. |
670 ] |
629 ] |
671 ]. |
630 ]. |
672 |
|
673 "Modified: / 09-07-2010 / 08:32:57 / cg" |
|
674 ! |
631 ! |
675 |
632 |
676 removeIndex:anIndex |
633 removeIndex:anIndex |
677 "remove the child at an index" |
634 "remove the child at an index" |
678 |
635 |
679 anIndex > 0 ifTrue:[ |
636 anIndex > 0 ifTrue:[ |
680 self removeFromIndex:anIndex toIndex:anIndex |
637 self removeFromIndex:anIndex toIndex:anIndex |
681 ] |
638 ] |
682 |
|
683 "Modified: / 09-07-2010 / 08:32:53 / cg" |
|
684 ! ! |
639 ! ! |
685 |
640 |
686 !HierarchicalItem methodsFor:'basic adding & removing'! |
641 !HierarchicalItem methodsFor:'basic adding & removing'! |
687 |
642 |
688 basicAdd:aChild sortBlock:aBlock |
643 basicAdd:aChild sortBlock:aBlock |
1016 |coll| |
961 |coll| |
1017 |
962 |
1018 coll := OrderedCollection new. |
963 coll := OrderedCollection new. |
1019 self recursiveDo:[:el| coll add:(aBlock value:el) ]. |
964 self recursiveDo:[:el| coll add:(aBlock value:el) ]. |
1020 ^ coll |
965 ^ coll |
1021 |
|
1022 "Modified: / 09-07-2010 / 08:34:24 / cg" |
|
1023 ! |
966 ! |
1024 |
967 |
1025 recursiveDo:aOneArgBlock |
968 recursiveDo:aOneArgBlock |
1026 "evaluate a block on each item and all the sub-items" |
969 "evaluate a block on each item and all the sub-items" |
1027 |
970 |
1028 self do:[:aChild| |
971 self do:[:aChild| |
1029 aOneArgBlock value:aChild. |
972 aOneArgBlock value:aChild. |
1030 aChild nonCriticalRecursiveDo:aOneArgBlock |
973 aChild nonCriticalRecursiveDo:aOneArgBlock |
1031 ]. |
974 ]. |
1032 |
|
1033 "Modified: / 09-07-2010 / 08:34:05 / cg" |
|
1034 ! |
975 ! |
1035 |
976 |
1036 recursiveReverseDo:aOneArgBlock |
977 recursiveReverseDo:aOneArgBlock |
1037 "evaluate a block on each item and all the sub-items; |
978 "evaluate a block on each item and all the sub-items; |
1038 proccesing children in reverse direction" |
979 proccesing children in reverse direction" |
1039 |
980 |
1040 self reverseDo:[:aChild| |
981 self reverseDo:[:aChild| |
1041 aChild nonCriticalRecursiveReverseDo:aOneArgBlock. |
982 aChild nonCriticalRecursiveReverseDo:aOneArgBlock. |
1042 aOneArgBlock value:aChild. |
983 aOneArgBlock value:aChild. |
1043 ]. |
984 ]. |
1044 |
|
1045 "Modified: / 09-07-2010 / 08:33:52 / cg" |
|
1046 ! |
985 ! |
1047 |
986 |
1048 recursiveSelect:aBlock |
987 recursiveSelect:aBlock |
1049 "return a new collection with all children and subChildren from the receiver, for which |
988 "return a new collection with all children and subChildren from the receiver, for which |
1050 the argument aBlock evaluates to true." |
989 the argument aBlock evaluates to true." |
1052 |coll| |
991 |coll| |
1053 |
992 |
1054 coll := OrderedCollection new. |
993 coll := OrderedCollection new. |
1055 self recursiveDo:[:el| (aBlock value:el) ifTrue:[coll add:el] ]. |
994 self recursiveDo:[:el| (aBlock value:el) ifTrue:[coll add:el] ]. |
1056 ^ coll |
995 ^ coll |
1057 |
|
1058 "Modified: / 09-07-2010 / 08:33:47 / cg" |
|
1059 ! |
996 ! |
1060 |
997 |
1061 reverseDo:aOneArgBlock |
998 reverseDo:aOneArgBlock |
1062 "evaluate a block on each child in reverse direction" |
999 "evaluate a block on each child in reverse direction" |
1063 |
1000 |
1064 ^ self from:1 reverseDo:aOneArgBlock |
1001 ^ self from:1 reverseDo:aOneArgBlock |
1065 |
|
1066 "Modified: / 09-07-2010 / 08:32:48 / cg" |
|
1067 ! |
1002 ! |
1068 |
1003 |
1069 select:aBlock |
1004 select:aBlock |
1070 "return a new collection with all items from the receiver, for which |
1005 "return a new collection with all items from the receiver, for which |
1071 the argument aBlock evaluates to true." |
1006 the argument aBlock evaluates to true." |
1086 |
1019 |
1087 self do:[:el| |
1020 self do:[:el| |
1088 aOneArgBlock value:el. |
1021 aOneArgBlock value:el. |
1089 el nonCriticalRecursiveDo:aOneArgBlock. |
1022 el nonCriticalRecursiveDo:aOneArgBlock. |
1090 ]. |
1023 ]. |
1091 |
|
1092 "Modified: / 09-07-2010 / 08:31:43 / cg" |
|
1093 ! ! |
1024 ! ! |
1094 |
1025 |
1095 !HierarchicalItem methodsFor:'enumerating parents'! |
1026 !HierarchicalItem methodsFor:'enumerating parents'! |
1096 |
1027 |
1097 parentsDetect:aBlock |
1028 parentsDetect:aBlock |
1098 "find the first parent, for which evaluation of the block returns |
1029 "find the first parent, for which evaluation of the block returns |
1099 true; if none does so, report an error" |
1030 true; if none does so, report an error" |
1100 |
1031 |
1101 ^ self parentsDetect:aBlock ifNone:[self errorNotFound] |
1032 ^ self parentsDetect:aBlock ifNone:[self errorNotFound] |
1102 |
|
1103 "Modified: / 09-07-2010 / 08:35:43 / cg" |
|
1104 ! |
1033 ! |
1105 |
1034 |
1106 parentsDetect:aBlock ifNone:anExceptionBlock |
1035 parentsDetect:aBlock ifNone:anExceptionBlock |
1107 "find the first parent, for which evaluation of the block returns |
1036 "find the first parent, for which evaluation of the block returns |
1108 true; if none does so, return the evaluation of anExceptionBlock" |
1037 true; if none does so, return the evaluation of anExceptionBlock" |
1279 ]. |
1198 ]. |
1280 |
1199 |
1281 w := 0. |
1200 w := 0. |
1282 aLabel asCollectionOfLines do:[:el|w := w max:(el widthOn:aGC)]. |
1201 aLabel asCollectionOfLines do:[:el|w := w max:(el widthOn:aGC)]. |
1283 ^ w |
1202 ^ w |
1284 |
|
1285 "Modified: / 09-07-2010 / 08:32:03 / cg" |
|
1286 ! ! |
1203 ! ! |
1287 |
1204 |
1288 !HierarchicalItem methodsFor:'private-enumerating'! |
1205 !HierarchicalItem methodsFor:'private-enumerating'! |
1289 |
1206 |
1290 nonCriticalDo:aOneArgBlock |
1207 nonCriticalDo:aOneArgBlock |
1291 "evaluate a block noncritical for each child." |
1208 "evaluate a block noncritical for each child." |
1292 |
1209 |
1293 ^ self nonCriticalFrom:1 to:nil do:aOneArgBlock |
1210 ^ self nonCriticalFrom:1 to:nil do:aOneArgBlock |
1294 |
|
1295 "Modified: / 09-07-2010 / 08:37:57 / cg" |
|
1296 ! |
1211 ! |
1297 |
1212 |
1298 nonCriticalFrom:startIndex to:endIndex do:aOneArgBlock |
1213 nonCriticalFrom:startIndex to:endIndex do:aOneArgBlock |
1299 "evaluate a block noncritical for each child starting with the |
1214 "evaluate a block noncritical for each child starting with the |
1300 child at startIndex to the endIndex (if nil to end of list)." |
1215 child at startIndex to the endIndex (if nil to end of list)." |
1308 resp := nil. |
1223 resp := nil. |
1309 |
1224 |
1310 endIndex notNil ifTrue:[ |
1225 endIndex notNil ifTrue:[ |
1311 size := size min:endIndex |
1226 size := size min:endIndex |
1312 ]. |
1227 ]. |
1313 startIndex to:size do:[:i| |item| |
1228 startIndex to:size do:[:i| |
|
1229 |item| |
|
1230 |
1314 item := list at:i ifAbsent:nil. |
1231 item := list at:i ifAbsent:nil. |
1315 item isNil ifTrue:[^ resp]. |
1232 item isNil ifTrue:[^ resp]. |
1316 resp := aOneArgBlock value:item. |
1233 resp := aOneArgBlock value:item. |
1317 ]. |
1234 ]. |
1318 ^ resp |
1235 ^ resp |
1319 |
|
1320 "Modified: / 09-07-2010 / 08:37:50 / cg" |
|
1321 ! |
1236 ! |
1322 |
1237 |
1323 nonCriticalFrom:startIndex to:endIndex reverseDo:aOneArgBlock |
1238 nonCriticalFrom:startIndex to:endIndex reverseDo:aOneArgBlock |
1324 "evaluate a block non critical for each child starting with the |
1239 "evaluate a block non critical for each child starting with the |
1325 child at endIndex (if nil to end of list) to startIndex." |
1240 child at endIndex (if nil to end of list) to startIndex." |
1339 item := list at:i ifAbsent:nil. |
1254 item := list at:i ifAbsent:nil. |
1340 item isNil ifTrue:[^ resp]. |
1255 item isNil ifTrue:[^ resp]. |
1341 resp := aOneArgBlock value:item. |
1256 resp := aOneArgBlock value:item. |
1342 ]. |
1257 ]. |
1343 ^ resp |
1258 ^ resp |
1344 |
|
1345 "Modified: / 09-07-2010 / 08:37:43 / cg" |
|
1346 ! |
1259 ! |
1347 |
1260 |
1348 nonCriticalKeysAndValuesReverseDo:aOneArgBlock |
1261 nonCriticalKeysAndValuesReverseDo:aOneArgBlock |
1349 "evaluate the argument, aBlock in reverse order for every |
1262 "evaluate the argument, aBlock in reverse order for every |
1350 child, passing both index and element as arguments." |
1263 child, passing both index and element as arguments." |
1361 item := list at:i ifAbsent:nil. |
1274 item := list at:i ifAbsent:nil. |
1362 item isNil ifTrue:[^ resp]. |
1275 item isNil ifTrue:[^ resp]. |
1363 resp := aOneArgBlock value:i value:item. |
1276 resp := aOneArgBlock value:i value:item. |
1364 ]. |
1277 ]. |
1365 ^ resp |
1278 ^ resp |
1366 |
|
1367 "Modified: / 09-07-2010 / 08:37:23 / cg" |
|
1368 ! |
1279 ! |
1369 |
1280 |
1370 nonCriticalRecursiveDo:aOneArgBlock |
1281 nonCriticalRecursiveDo:aOneArgBlock |
1371 "evaluate the block non critical for each item and all the sub-items" |
1282 "evaluate the block non critical for each item and all the sub-items" |
1372 |
1283 |
1373 self nonCriticalFrom:1 to:nil do:[:aChild| |
1284 self nonCriticalFrom:1 to:nil do:[:eachChild| |
1374 aOneArgBlock value:aChild. |
1285 aOneArgBlock value:eachChild. |
1375 aChild nonCriticalRecursiveDo:aOneArgBlock |
1286 eachChild nonCriticalRecursiveDo:aOneArgBlock |
1376 ]. |
1287 ]. |
1377 |
|
1378 "Modified: / 09-07-2010 / 08:36:58 / cg" |
|
1379 ! |
1288 ! |
1380 |
1289 |
1381 nonCriticalRecursiveReverseDo:aOneArgBlock |
1290 nonCriticalRecursiveReverseDo:aOneArgBlock |
1382 "evaluate the block non critical for each item and all the sub-items; |
1291 "evaluate the block non critical for each item and all the sub-items; |
1383 proccesing children in reverse direction" |
1292 proccesing children in reverse direction" |
1384 |
1293 |
1385 self nonCriticalFrom:1 to:nil reverseDo:[:aChild| |
1294 self nonCriticalFrom:1 to:nil reverseDo:[:eachChild| |
1386 aChild nonCriticalRecursiveReverseDo:aOneArgBlock. |
1295 eachChild nonCriticalRecursiveReverseDo:aOneArgBlock. |
1387 aOneArgBlock value:aChild. |
1296 aOneArgBlock value:eachChild. |
1388 ]. |
1297 ]. |
1389 |
|
1390 "Modified: / 09-07-2010 / 08:36:49 / cg" |
|
1391 ! |
1298 ! |
1392 |
1299 |
1393 nonCriticalRecursiveSort:aSortBlock |
1300 nonCriticalRecursiveSort:aSortBlock |
1394 "evaluate a block noncritical for each child." |
1301 "evaluate a block noncritical for each child." |
1395 |
1302 |
1571 |
1470 |
1572 height isNil ifTrue:[ |
1471 height isNil ifTrue:[ |
1573 height := self heightOf:(self label) on:aGC |
1472 height := self heightOf:(self label) on:aGC |
1574 ]. |
1473 ]. |
1575 ^ height |
1474 ^ height |
1576 |
|
1577 "Modified: / 09-07-2010 / 08:42:35 / cg" |
|
1578 ! |
1475 ! |
1579 |
1476 |
1580 widthOn:aGC |
1477 widthOn:aGC |
1581 "return the width of the receiver, if it is to be displayed on aGC" |
1478 "return the width of the receiver, if it is to be displayed on aGC" |
1582 |
1479 |
1583 width isNil ifTrue:[ |
1480 width isNil ifTrue:[ |
1584 width := self widthOf:(self label) on:aGC |
1481 width := self widthOf:(self label) on:aGC |
1585 ]. |
1482 ]. |
1586 ^ width |
1483 ^ width |
1587 |
|
1588 "Modified: / 09-07-2010 / 08:31:53 / cg" |
|
1589 ! ! |
1484 ! ! |
1590 |
1485 |
1591 !HierarchicalItem methodsFor:'protocol-event processing'! |
1486 !HierarchicalItem methodsFor:'protocol-event processing'! |
1592 |
1487 |
1593 processButtonPress:button x:x y:y |
1488 processButtonPress:button x:x y:y |
1594 "a mouse button was pressed in my label. |
1489 "a mouse button was pressed in my label. |
1595 Return true, if the event is eaten (ignored by the gc). |
1490 Return true, if the event is eaten (ignored by the gc). |
1596 By default, false is returned (should be handled by the gc)." |
1491 By default, false is returned (should be handled by the gc)." |
1597 |
1492 |
1598 ^ false |
1493 ^ false |
1599 |
|
1600 "Modified: / 09-07-2010 / 08:35:22 / cg" |
|
1601 ! |
1494 ! |
1602 |
1495 |
1603 processButtonPress:button x:x y:y on:aGC |
1496 processButtonPress:button x:x y:y on:aGC |
1604 "a mouse button was pressed in my label. |
1497 "a mouse button was pressed in my label. |
1605 Return true, if the event is eaten (ignored by the gc). |
1498 Return true, if the event is eaten (ignored by the gc). |
1606 By default, false is returned (should be handled by the gc)." |
1499 By default, false is returned (should be handled by the gc)." |
1607 |
1500 |
1608 ^ self processButtonPress:button x:x y:y |
1501 ^ self processButtonPress:button x:x y:y |
1609 |
|
1610 "Modified: / 09-07-2010 / 08:35:10 / cg" |
|
1611 ! |
1502 ! |
1612 |
1503 |
1613 processButtonPressOnIcon:button on:aGC |
1504 processButtonPressOnIcon:button on:aGC |
1614 "a mouse button was pressed in my icon. |
1505 "a mouse button was pressed in my icon. |
1615 Return true, if the event is eaten (ignored by the gc). |
1506 Return true, if the event is eaten (ignored by the gc). |
1616 By default, false is returned (should be handled by the gc)." |
1507 By default, false is returned (should be handled by the gc)." |
1617 |
1508 |
1618 ^ false |
1509 ^ false |
1619 |
|
1620 "Modified: / 09-07-2010 / 08:35:00 / cg" |
|
1621 ! ! |
1510 ! ! |
1622 |
1511 |
1623 !HierarchicalItem methodsFor:'protocol-monitoring'! |
1512 !HierarchicalItem methodsFor:'protocol-monitoring'! |
1624 |
1513 |
1625 monitoringCycle |
1514 monitoringCycle |
1626 "called every 'n' seconds by the model, if the monitoring |
1515 "called every 'n' seconds by the model, if the monitoring |
1627 cycle is enabled. The item can perform some checks, .. |
1516 cycle is enabled. The item can perform some checks, .. |
1628 **** can be redefined by subclass to perform some actions |
1517 **** can be redefined by subclass to perform some actions |
1629 " |
1518 " |
1630 |
|
1631 "Modified: / 09-07-2010 / 08:38:06 / cg" |
|
1632 ! ! |
1519 ! ! |
1633 |
1520 |
1634 !HierarchicalItem methodsFor:'protocol-queries'! |
1521 !HierarchicalItem methodsFor:'protocol-queries'! |
1635 |
1522 |
1636 canCollapse |
1523 canCollapse |
1673 "checks whether the item has children; |
1560 "checks whether the item has children; |
1674 the list needs not to be loaded yet( example. FileDirectory ). |
1561 the list needs not to be loaded yet( example. FileDirectory ). |
1675 *** to optimize: redefine in subClass" |
1562 *** to optimize: redefine in subClass" |
1676 |
1563 |
1677 ^ self children size ~~ 0 |
1564 ^ self children size ~~ 0 |
1678 |
|
1679 "Modified: / 09-07-2010 / 08:42:50 / cg" |
|
1680 ! |
1565 ! |
1681 |
1566 |
1682 hasIndicator |
1567 hasIndicator |
1683 "on default the indicator is drawn if the item has children" |
1568 "on default the indicator is drawn if the item has children" |
1684 |
1569 |
1685 ^ self hasChildren |
1570 ^ self hasChildren |
1686 |
|
1687 "Modified: / 09-07-2010 / 08:42:46 / cg" |
|
1688 ! |
1571 ! |
1689 |
1572 |
1690 isSelectable |
1573 isSelectable |
1691 "returns true if the item is selectable" |
1574 "returns true if the item is selectable" |
1692 |
1575 |
1693 ^ true |
1576 ^ true |
1694 |
|
1695 "Modified: / 09-07-2010 / 08:41:30 / cg" |
|
1696 ! |
1577 ! |
1697 |
1578 |
1698 string |
1579 string |
1699 "access the printable string used for steping through a list |
1580 "access the printable string used for stepping through a list |
1700 searching for an entry starting with a character. |
1581 searching for an entry starting with a character. |
1701 *** to optimize:redefine by subClass" |
1582 *** to optimize:redefine by subClass" |
1702 |
1583 |
1703 |label| |
1584 |label| |
1704 |
1585 |
1777 [item notNil] whileTrue:[ |
1652 [item notNil] whileTrue:[ |
1778 item == anItem ifTrue:[^ true]. |
1653 item == anItem ifTrue:[^ true]. |
1779 item := item parent. |
1654 item := item parent. |
1780 ]. |
1655 ]. |
1781 ^ false |
1656 ^ false |
1782 |
|
1783 "Modified: / 09-07-2010 / 08:41:36 / cg" |
|
1784 ! |
1657 ! |
1785 |
1658 |
1786 isRootItem |
1659 isRootItem |
1787 "returns true if the item is the root item" |
1660 "returns true if the item is the root item" |
1788 |
1661 |
1789 ^ parent isHierarchicalItem not |
1662 ^ parent isHierarchicalItem not |
1790 |
|
1791 "Modified: / 09-07-2010 / 08:41:26 / cg" |
|
1792 ! |
1663 ! |
1793 |
1664 |
1794 size |
1665 size |
1795 "return the number of children" |
1666 "return the number of children" |
1796 |
1667 |
1797 ^ self children size |
1668 ^ self children size |
1798 |
|
1799 "Modified: / 09-07-2010 / 08:32:24 / cg" |
|
1800 ! ! |
1669 ! ! |
1801 |
1670 |
1802 !HierarchicalItem methodsFor:'searching'! |
1671 !HierarchicalItem methodsFor:'searching'! |
1803 |
1672 |
1804 detect:aOneArgBlock |
1673 detect:aOneArgBlock |
1854 |
1721 |
1855 identityIndexOf:aChild |
1722 identityIndexOf:aChild |
1856 "return the index of aChild or 0 if not found. Compare using ==" |
1723 "return the index of aChild or 0 if not found. Compare using ==" |
1857 |
1724 |
1858 ^ self identityIndexOf:aChild startingAt:1 |
1725 ^ self identityIndexOf:aChild startingAt:1 |
1859 |
|
1860 "Modified: / 09-07-2010 / 08:42:12 / cg" |
|
1861 ! |
1726 ! |
1862 |
1727 |
1863 identityIndexOf:aChild startingAt:startIndex |
1728 identityIndexOf:aChild startingAt:startIndex |
1864 "return the index of aChild, starting search at startIndex. |
1729 "return the index of aChild, starting search at startIndex. |
1865 Compare using ==; return 0 if not found" |
1730 Compare using ==; return 0 if not found" |
1871 self from:startIndex do:[:el| |
1736 self from:startIndex do:[:el| |
1872 el == aChild ifTrue:[^ index ]. |
1737 el == aChild ifTrue:[^ index ]. |
1873 index := index + 1. |
1738 index := index + 1. |
1874 ]. |
1739 ]. |
1875 ^ 0 |
1740 ^ 0 |
1876 |
|
1877 "Modified: / 09-07-2010 / 08:42:07 / cg" |
|
1878 ! |
1741 ! |
1879 |
1742 |
1880 recursiveDetect:aOneArgBlock |
1743 recursiveDetect:aOneArgBlock |
1881 "recursive find the first child, for which evaluation |
1744 "recursive find the first child, for which evaluation |
1882 of the block returns true; if none nil is returned" |
1745 of the block returns true; if none nil is returned" |
1883 |
1746 |
1884 self recursiveDo:[:aChild| |
1747 self recursiveDo:[:aChild| |
1885 (aOneArgBlock value:aChild) ifTrue:[^ aChild] |
1748 (aOneArgBlock value:aChild) ifTrue:[^ aChild] |
1886 ]. |
1749 ]. |
1887 ^ nil |
1750 ^ nil |
1888 |
|
1889 "Modified: / 09-07-2010 / 08:34:17 / cg" |
|
1890 ! |
1751 ! |
1891 |
1752 |
1892 recursiveDetectLast:aBlock |
1753 recursiveDetectLast:aBlock |
1893 "find the last child, for which evaluation of the block returns |
1754 "find the last child, for which evaluation of the block returns |
1894 true; if none does so, nil id returned" |
1755 true; if none does so, nil id returned" |
1895 |
1756 |
1896 self recursiveReverseDo:[:aChild| |
1757 self recursiveReverseDo:[:aChild| |
1897 (aBlock value:aChild) ifTrue:[^ aChild]. |
1758 (aBlock value:aChild) ifTrue:[^ aChild]. |
1898 ]. |
1759 ]. |
1899 ^ nil |
1760 ^ nil |
1900 |
|
1901 "Modified: / 09-07-2010 / 08:34:12 / cg" |
|
1902 ! |
1761 ! |
1903 |
1762 |
1904 withAllDetect:aOneArgBlock |
1763 withAllDetect:aOneArgBlock |
1905 "recursive find the first item including self, for which evaluation |
1764 "recursive find the first item including self, for which evaluation |
1906 of the block returns true; if none nil is returned" |
1765 of the block returns true; if none nil is returned" |
1907 |
1766 |
1908 (aOneArgBlock value:self) ifTrue:[^ self]. |
1767 (aOneArgBlock value:self) ifTrue:[^ self]. |
1909 |
1768 |
1910 ^ self recursiveDetect:aOneArgBlock |
1769 ^ self recursiveDetect:aOneArgBlock |
1911 |
|
1912 "Modified: / 09-07-2010 / 08:31:47 / cg" |
|
1913 ! ! |
1770 ! ! |
1914 |
1771 |
1915 !HierarchicalItem methodsFor:'sorting & reordering'! |
1772 !HierarchicalItem methodsFor:'sorting & reordering'! |
1916 |
1773 |
1917 recursiveSort:aSortBlock |
1774 recursiveSort:aSortBlock |