14 SelectionInListView subclass:#SelectionInTreeView |
14 SelectionInListView subclass:#SelectionInTreeView |
15 instanceVariableNames:'validateDoubleClickBlock selectionHolder rootHolder imageWidth |
15 instanceVariableNames:'validateDoubleClickBlock selectionHolder rootHolder imageWidth |
16 showLines listOfNodes imageInset textInset labelOffsetY |
16 showLines listOfNodes imageInset textInset labelOffsetY |
17 openIndicator computeResources closeIndicator showRoot |
17 openIndicator computeResources closeIndicator showRoot |
18 extentOpenIndicator extentCloseIndicator showDirectoryIndicator |
18 extentOpenIndicator extentCloseIndicator showDirectoryIndicator |
19 indicatorExtentDiv2 imageOpened imageClosed imageItem' |
19 indicatorExtentDiv2 imageOpened imageClosed imageItem |
|
20 discardMotionEvents' |
20 classVariableNames:'ImageOpened ImageClosed ImageItem OpenIndicator CloseIndicator' |
21 classVariableNames:'ImageOpened ImageClosed ImageItem OpenIndicator CloseIndicator' |
21 poolDictionaries:'' |
22 poolDictionaries:'' |
22 category:'Views-Text' |
23 category:'Views-Text' |
23 ! |
24 ! |
24 |
25 |
566 self selectionDo:[:i| aOneArgBlock value:(listOfNodes at:i) ] |
567 self selectionDo:[:i| aOneArgBlock value:(listOfNodes at:i) ] |
567 ! ! |
568 ! ! |
568 |
569 |
569 !SelectionInTreeView methodsFor:'event handling'! |
570 !SelectionInTreeView methodsFor:'event handling'! |
570 |
571 |
|
572 buttonMotion:buttonMask x:x y:y |
|
573 "mouse-move while button was pressed - handle selection changes" |
|
574 |
|
575 discardMotionEvents ifFalse:[ |
|
576 super buttonMotion:buttonMask x:x y:y |
|
577 ] |
|
578 |
|
579 |
|
580 ! |
|
581 |
571 buttonMultiPress:button x:x y:y |
582 buttonMultiPress:button x:x y:y |
572 |
583 |
573 (self indicatiorLineForButton:button atX:x y:y) == 0 ifTrue:[ |
584 (self indicatiorLineForButton:button atX:x y:y) == 0 ifTrue:[ |
574 ^ super buttonMultiPress:button x:x y:y |
585 ^ super buttonMultiPress:button x:x y:y |
575 ]. |
586 ]. |
591 ( validateDoubleClickBlock isNil |
602 ( validateDoubleClickBlock isNil |
592 or:[(validateDoubleClickBlock value:node) ~~ false] |
603 or:[(validateDoubleClickBlock value:node) ~~ false] |
593 ) ifFalse:[ |
604 ) ifFalse:[ |
594 ^ super buttonPress:button x:x y:y |
605 ^ super buttonPress:button x:x y:y |
595 ]. |
606 ]. |
596 |
607 discardMotionEvents := true. |
597 dragIsActive := false. |
608 dragIsActive := false. |
598 clickPosition := nil. |
609 clickPosition := nil. |
599 expand := node isExpandable. |
610 |
600 |
611 self hasSelection ifTrue:[ |
601 (size := self numberOfSelections) == 0 ifTrue:[ "/ nothing selected |
612 (selectConditionBlock isNil or:[selectConditionBlock value:lineNr]) ifTrue:[ |
602 ^ self nodeAt:lineNr expand:expand. |
613 self selection:lineNr |
603 ]. |
614 ] ifFalse:[ |
604 oldSelection := selection. |
615 self selection:nil |
605 |
616 ] |
606 size == 1 ifTrue:[ "/ single selection |
617 ]. |
607 selNode := self selectedNode. |
618 self nodeAt:lineNr expand:(node isExpandable). |
608 |
619 |
609 lineNr >= self selectedIndex ifTrue:[ "/ operation will not changed |
620 ! |
610 ^ self nodeAt:lineNr expand:expand. "/ current selected index |
621 |
611 ]. |
622 buttonRelease:button x:x y:y |
612 model setSelectionIndex:0. "/ selected index will change |
623 "stop any autoscroll" |
613 self selectWithoutScroll:nil. |
624 |
614 |
625 discardMotionEvents ifTrue:[ |
615 self nodeAt:lineNr expand:expand. |
626 clickPosition := nil. |
616 size := self indexOfNode:selNode. |
627 discardMotionEvents := false. |
617 |
628 ]. |
618 size == 0 ifTrue:[ "/ old selection no longer visible |
629 super buttonRelease:button x:x y:y |
619 ^ self selection:lineNr "/ change selection; raise notify |
630 |
620 ]. |
|
621 self selectWithoutScroll:size. "/ can keep old selection |
|
622 model setSelectionIndex:selection. "/ but has to change index |
|
623 ^ self selectionChangedFrom:oldSelection |
|
624 ]. |
|
625 selNode := OrderedCollection new:size. |
|
626 newSel := OrderedCollection new:size. |
|
627 |
|
628 self selectionDo:[:i| |
|
629 selNode add:(listOfNodes at:i) "/ change selection to nodes |
|
630 ]. |
|
631 model setSelectionIndex:0. "/ redraw current selection unselected |
|
632 self selectWithoutScroll:nil. |
|
633 self nodeAt:lineNr expand:expand. "/ perform expand/collapse operation |
|
634 |
|
635 selNode do:[:n||i| "/ convert old selection to new selection |
|
636 (i := self indexOfNode:n) ~~ 0 ifTrue:[ |
|
637 newSel add:i "/ can take over into new selection |
|
638 ] |
|
639 ]. |
|
640 |
|
641 newSel isEmpty ifTrue:[ "/ old selection no longer visible |
|
642 ^ self selection:lineNr "/ change selection; raise notify |
|
643 ]. |
|
644 |
|
645 newSel size == size ifTrue:[ |
|
646 self selectWithoutScroll:newSel. "/ can keep old selection |
|
647 model setSelectionIndex:selection. "/ but has to change indeces |
|
648 self selectionChangedFrom:oldSelection. |
|
649 ] ifFalse:[ |
|
650 self selection:newSel "/ can keep part of old selection |
|
651 ] |
|
652 ! |
631 ! |
653 |
632 |
654 doubleClicked |
633 doubleClicked |
655 "handle a double click; collapse or expand selected entry |
634 "handle a double click; collapse or expand selected entry |
656 in case of having children |
635 in case of having children |
762 self bitGravity:#NorthWest. |
741 self bitGravity:#NorthWest. |
763 showLines := true. |
742 showLines := true. |
764 showRoot := true. |
743 showRoot := true. |
765 computeResources := true. |
744 computeResources := true. |
766 showDirectoryIndicator := false. |
745 showDirectoryIndicator := false. |
|
746 discardMotionEvents := false. |
|
747 |
767 textInset := 2. |
748 textInset := 2. |
768 imageInset := 0. "/ set during indication enabled |
749 imageInset := 0. "/ set during indication enabled |
769 imageWidth := 8. "/ default: will change during startup |
750 imageWidth := 8. "/ default: will change during startup |
770 self model:nil. "/ creates a default model. |
751 self model:nil. "/ creates a default model. |
771 ! |
752 ! |