866 node children isEmpty ifTrue:[ |
866 node children isEmpty ifTrue:[ |
867 "/ no children; redraw selected line (image might change) |
867 "/ no children; redraw selected line (image might change) |
868 self redrawLine:lineNr. |
868 self redrawLine:lineNr. |
869 ] ifFalse:[ |
869 ] ifFalse:[ |
870 "/ with children; update list and redraw to end. |
870 "/ with children; update list and redraw to end. |
871 oldSize := list size. |
871 self recomputeListFromNodeAt:lineNr |
872 model removeDependent:self. |
|
873 model recomputeList. |
|
874 model addDependent:self. |
|
875 list := self listFromModel. |
|
876 |
|
877 oldSize ~~ list size ifTrue:[ |
|
878 self redrawFromLine:lineNr. |
|
879 self contentsChanged. |
|
880 ] |
|
881 ] |
872 ] |
882 |
873 |
883 |
874 |
884 ! |
875 ! |
885 |
876 |
1250 |
1241 |
1251 listFromModel |
1242 listFromModel |
1252 "get list from model and return the new list. |
1243 "get list from model and return the new list. |
1253 If listMessage is nil, try aspectMessage for backward compatibilty. |
1244 If listMessage is nil, try aspectMessage for backward compatibilty. |
1254 " |
1245 " |
1255 |msg| |
1246 |msg list |
1256 |
1247 runs "{ Class: SmallInteger }" |
|
1248 idx "{ Class: SmallInteger }" |
|
1249 | |
1257 widthOfWidestLine := nil. |
1250 widthOfWidestLine := nil. |
1258 |
1251 |
1259 (msg := listMsg ? aspectMsg) notNil ifTrue:[ |
1252 (msg := listMsg ? aspectMsg) notNil ifTrue:[ |
1260 listOfNodes := model perform:msg. |
1253 listOfNodes := model perform:msg. |
1261 listOfNodes size ~~ 0 ifTrue:[ |
1254 |
|
1255 (runs := listOfNodes size) ~~ 0 ifTrue:[ |
1262 self refetchDeviceResources. |
1256 self refetchDeviceResources. |
1263 ^ listOfNodes collect:[:n|n name] |
1257 idx := 1. |
|
1258 list := OrderedCollection new:runs. |
|
1259 |
|
1260 runs timesRepeat:[ |
|
1261 list add:(listOfNodes at:idx) name. |
|
1262 idx := idx + 1. |
|
1263 ]. |
|
1264 ^ list |
1264 ] |
1265 ] |
1265 ]. |
1266 ]. |
1266 listOfNodes := #(). |
1267 listOfNodes := #(). |
1267 ^ #() |
1268 ^ #() |
|
1269 |
1268 ! |
1270 ! |
1269 |
1271 |
1270 model:aModel |
1272 model:aModel |
1271 "check whether model is nil; than a default model is created |
1273 "check whether model is nil; than a default model is created |
1272 " |
1274 " |
1397 node children isEmpty ifTrue:[ |
1399 node children isEmpty ifTrue:[ |
1398 "/ no children; redraw selected line (image might change) |
1400 "/ no children; redraw selected line (image might change) |
1399 self redrawLine:anIndex. |
1401 self redrawLine:anIndex. |
1400 ] ifFalse:[ |
1402 ] ifFalse:[ |
1401 "/ with children; update list and redraw to end. |
1403 "/ with children; update list and redraw to end. |
1402 model removeDependent:self. |
1404 self recomputeListFromNodeAt:anIndex |
1403 model recomputeList. |
|
1404 model addDependent:self. |
|
1405 list := self listFromModel. |
|
1406 self redrawFromLine:anIndex. |
|
1407 self contentsChanged. |
|
1408 ] |
1405 ] |
1409 |
1406 |
1410 |
1407 |
|
1408 ! |
|
1409 |
|
1410 recomputeListFromNodeAt:anIndex |
|
1411 |
|
1412 model removeDependent:self. |
|
1413 model recomputeList. |
|
1414 model addDependent:self. |
|
1415 |
|
1416 list := self listFromModel. |
|
1417 self redrawFromLine:anIndex. |
|
1418 self contentsChanged. |
1411 ! ! |
1419 ! ! |
1412 |
1420 |
1413 !SelectionInTreeView methodsFor:'private - drag and drop'! |
1421 !SelectionInTreeView methodsFor:'private - drag and drop'! |
1414 |
1422 |
1415 collectionOfDragObjects |
1423 collectionOfDragObjects |
1493 ! |
1501 ! |
1494 |
1502 |
1495 widthOfContents:firstLine and:lastLine |
1503 widthOfContents:firstLine and:lastLine |
1496 "return the length (in pixels) of the longest line in a line-range |
1504 "return the length (in pixels) of the longest line in a line-range |
1497 " |
1505 " |
1498 |max "{ Class: SmallInteger }" |
1506 |parent name item tmpValue |
1499 thisLen "{ Class: SmallInteger }" |
1507 max "{ Class: SmallInteger }" |
1500 first "{ Class: SmallInteger }" |
1508 index "{ Class: SmallInteger }" |
1501 last "{ Class: SmallInteger }" | |
1509 runs "{ Class: SmallInteger }" |
1502 |
1510 level "{ Class: SmallInteger }" |
1503 listOfNodes size == 0 ifTrue:[^ 0]. |
1511 xOfStr "{ Class: SmallInteger }" |
1504 |
1512 dltX "{ Class: SmallInteger }" |
1505 last := listOfNodes size. |
1513 width "{ Class: SmallInteger }" |
1506 first := firstLine. |
1514 newSz "{ Class: SmallInteger }" |
1507 |
1515 maxSz "{ Class: SmallInteger }"| |
1508 (first > last) ifTrue:[^ 0]. |
1516 |
1509 |
1517 ( (listOfNodes size == 0) |
1510 (lastLine < last) ifTrue:[ |
1518 or:[(runs := lastLine min:(listOfNodes size)) < firstLine] |
1511 last := lastLine |
1519 ) ifTrue:[ |
1512 ]. |
1520 ^ 0 |
1513 max := 0. |
1521 ]. |
1514 |
1522 |
1515 listOfNodes from:first to:last do:[:anItem||name| |
1523 level := 1. |
1516 thisLen := self xOfStringNode:anItem. |
1524 xOfStr := self xOfStringLevel:level. |
1517 |
1525 max := xOfStr. |
1518 (name := anItem name) notNil ifTrue:[ |
1526 dltX := imageInset + imageWidth. |
1519 thisLen := thisLen + (name widthOn:self). |
1527 width := '1' widthOn:self. |
1520 ]. |
1528 parent := 4711. "/ to force a computation |
1521 (thisLen > max) ifTrue:[ |
1529 index := firstLine. |
1522 max := thisLen. |
1530 runs := runs - index + 1. |
1523 ] |
1531 |
1524 ]. |
1532 runs timesRepeat:[ |
1525 ^ max + leftOffset. |
1533 item := listOfNodes at:index. |
|
1534 name := item name. |
|
1535 index := index + 1. |
|
1536 |
|
1537 (newSz := name size) ~~ 0 ifTrue:[ |
|
1538 item parent ~~ parent ifTrue:[ |
|
1539 parent := item parent. |
|
1540 tmpValue := item level. |
|
1541 xOfStr := xOfStr + ((tmpValue - level) * dltX). |
|
1542 level := tmpValue. |
|
1543 maxSz := 0. |
|
1544 ]. |
|
1545 maxSz < newSz ifTrue:[ |
|
1546 maxSz := newSz. |
|
1547 max := max max:(xOfStr + (maxSz * width)). |
|
1548 ] |
|
1549 ] |
|
1550 ]. |
|
1551 ^ max + leftOffset. |
|
1552 |
|
1553 |
1526 ! |
1554 ! |
1527 |
1555 |
1528 withoutRedrawAt:anIndex put:aString |
1556 withoutRedrawAt:anIndex put:aString |
1529 "change a line without redisplay" |
1557 "change a line without redisplay" |
1530 |
1558 |
1535 |
1563 |
1536 super withoutRedrawAt:anIndex put:aString. |
1564 super withoutRedrawAt:anIndex put:aString. |
1537 |
1565 |
1538 (widthOfWidestLine := width) notNil ifTrue:[ |
1566 (widthOfWidestLine := width) notNil ifTrue:[ |
1539 width := self widthOfContents:anIndex and:anIndex. |
1567 width := self widthOfContents:anIndex and:anIndex. |
1540 |
1568 widthOfWidestLine := widthOfWidestLine max:width. |
1541 width > widthOfWidestLine ifTrue:[ |
|
1542 widthOfWidestLine := width |
|
1543 ] ifFalse:[ |
|
1544 widthOfWidestLine := nil "/ means: unknown |
|
1545 ] |
|
1546 ]. |
1569 ]. |
1547 |
1570 |
1548 |
1571 |
1549 ! ! |
1572 ! ! |
1550 |
1573 |