Tools__ViewTreeApplication.st
changeset 2455 93aaf62a6b95
parent 2454 4867f3e9dd43
child 2458 64d8f3c973b3
equal deleted inserted replaced
2454:4867f3e9dd43 2455:93aaf62a6b95
     2 
     2 
     3 "{ NameSpace: Tools }"
     3 "{ NameSpace: Tools }"
     4 
     4 
     5 ApplicationModel subclass:#ViewTreeApplication
     5 ApplicationModel subclass:#ViewTreeApplication
     6 	instanceVariableNames:'model treeView hasSingleSelectionHolder clickedItem clickedPoint
     6 	instanceVariableNames:'model treeView hasSingleSelectionHolder clickedItem clickedPoint
     7 		motionAction infoChannel testModeChannel process
     7 		motionAction infoChannel process followFocusChannel
     8 		followFocusChannel showNamesHolder'
     8 		showNamesHolder'
     9 	classVariableNames:''
     9 	classVariableNames:''
    10 	poolDictionaries:''
    10 	poolDictionaries:''
    11 	category:'A-Views-Support'
    11 	category:'A-Views-Support'
    12 !
    12 !
    13 
    13 
   156               menu: middleButtonMenu
   156               menu: middleButtonMenu
   157               hasHorizontalScrollBar: true
   157               hasHorizontalScrollBar: true
   158               hasVerticalScrollBar: true
   158               hasVerticalScrollBar: true
   159               miniScrollerHorizontal: true
   159               miniScrollerHorizontal: true
   160               miniScrollerVertical: false
   160               miniScrollerVertical: false
   161               backgroundColor: (Color 49.999237048905 49.999237048905 100.0)
       
   162               listModel: listOfItems
   161               listModel: listOfItems
   163               multipleSelectOk: true
   162               multipleSelectOk: true
   164               useIndex: false
   163               useIndex: false
   165               highlightMode: label
   164               highlightMode: label
   166               doubleClickSelector: doubleClicked:
   165               doubleClickSelector: doubleClicked:
   213                   label: 'Pick a View'
   212                   label: 'Pick a View'
   214                   itemValue: doPickViews
   213                   itemValue: doPickViews
   215                   translateLabel: true
   214                   translateLabel: true
   216                 )
   215                 )
   217                (MenuItem
   216                (MenuItem
   218                   enabled: hasPickedView
   217                   enabled: hasTargetWidgetChannel
   219                   label: 'Release Picked View'
   218                   label: 'Release Picked View'
   220                   itemValue: doUnpick
   219                   itemValue: doUnpick
   221                   translateLabel: true
   220                   translateLabel: true
   222                 )
   221                 )
   223                (MenuItem
   222                (MenuItem
   283             label: 'Menu'
   282             label: 'Menu'
   284             translateLabel: true
   283             translateLabel: true
   285             submenuChannel: middleButtonMenu
   284             submenuChannel: middleButtonMenu
   286           )
   285           )
   287          (MenuItem
   286          (MenuItem
       
   287             enabled: hasTargetWidgetChannel
   288             label: 'Components'
   288             label: 'Components'
   289             translateLabel: true
   289             translateLabel: true
   290             startGroup: right
   290             startGroup: right
   291             submenuChannel: submenuComponents:
   291             submenuChannel: submenuComponents:
   292           )
   292           )
   293          (MenuItem
   293          (MenuItem
       
   294             enabled: hasTargetWidgetChannel
   294             label: 'Applications'
   295             label: 'Applications'
   295             translateLabel: true
   296             translateLabel: true
   296             submenuChannel: submenuApplications:
   297             submenuChannel: submenuApplications:
   297           )
   298           )
   298          )
   299          )
   487             translateLabel: false
   488             translateLabel: false
   488             labelImage: (ResourceRetriever ToolbarIconLibrary inspect22x24Icon 'Application')
   489             labelImage: (ResourceRetriever ToolbarIconLibrary inspect22x24Icon 'Application')
   489             argument: application
   490             argument: application
   490           )
   491           )
   491          (MenuItem
   492          (MenuItem
   492             label: '-'
   493             label: ''
   493           )
   494           )
   494          (MenuItem
   495          (MenuItem
   495             enabled: hasSingleSelectionHolder
   496             enabled: hasSingleSelectionHolder
   496             label: 'Widget'
   497             label: 'Widget'
   497             itemValue: doBrowse:
   498             itemValue: doBrowse:
   536 ! !
   537 ! !
   537 
   538 
   538 !ViewTreeApplication methodsFor:'aspects'!
   539 !ViewTreeApplication methodsFor:'aspects'!
   539 
   540 
   540 followFocusChannel
   541 followFocusChannel
   541     "boolean holder, which indicates whether selection changed dependend on the focus view
   542     "boolean holder, which indicates whether selection changed dependend on the focus view"
   542     "
   543 
   543     ^ followFocusChannel
   544     ^ followFocusChannel
   544 !
   545 !
   545 
   546 
   546 hasSingleSelectionHolder
   547 hasSingleSelectionHolder
   547     "boolean holder, true if one item is selected
   548     "boolean holder, true if one item is selected"
   548     "
   549 
   549     ^ hasSingleSelectionHolder
   550     ^ hasSingleSelectionHolder
   550 !
   551 !
   551 
   552 
       
   553 hasTargetWidgetChannel
       
   554     "answer the channel which is set to true if a target widget exists"
       
   555 
       
   556     ^ model hasTargetWidgetChannel
       
   557 !
       
   558 
   552 infoChannel
   559 infoChannel
   553     "channel, which keeps a printable information
   560     "channel, which keeps a printable information"
   554     "
   561 
   555     ^ infoChannel
   562     ^ infoChannel
   556 !
   563 !
   557 
   564 
   558 listOfItems
   565 listOfItems
   559     "returns the hierarchical list of items
   566     "returns the hierarchical list of items"
   560     "
   567 
   561     ^ model listOfItems
   568     ^ model listOfItems
   562 !
   569 !
   563 
   570 
   564 model
   571 model
   565     "returns my selection model, a ViewTreeModel
   572     "returns my selection model, a ViewTreeModel"
   566     "
   573 
   567     ^ model
   574     ^ model
   568 !
   575 !
   569 
   576 
   570 selectOnClickHolder
   577 selectOnClickHolder
   571     "boolean holder, which indicates whether the selection will change on click
   578     "boolean holder, which indicates whether the selection will change on click"
   572     "
   579 
   573     ^ model selectOnClickHolder
   580     ^ model selectOnClickHolder
   574 !
   581 !
   575 
   582 
   576 showNamesHolder
   583 showNamesHolder
   577     "boolean holder, which indicates whether application names or widget names
   584     "boolean holder, which indicates whether application names or widget names
   578      as additional text are shown for the items
   585      as additional text are shown for the items"
   579     "
   586 
   580     ^ showNamesHolder
   587     ^ showNamesHolder
   581 !
   588 !
   582 
   589 
   583 testModeChannel
   590 testModeChannel
   584     "boolean holder, which indicates whether running in test or edit mode (eat input events)
   591     "answer a boolean channel which describes the behaviour how to process
   585     "
   592      events on the target view.
   586     ^ testModeChannel
   593 
       
   594      false: all input events are eaten and the selection is shown on the target view.
       
   595      true:  no  input events are eaten and no  selection is shown on the target view."
       
   596 
       
   597     ^ model testModeChannel
   587 ! !
   598 ! !
   588 
   599 
   589 !ViewTreeApplication methodsFor:'change & update'!
   600 !ViewTreeApplication methodsFor:'change & update'!
   590 
   601 
   591 selectionChanged
   602 selectionChanged
   592     "called if the selection changed
   603     "called if the selection changed"
   593     "
   604 
   594     |info view item|
   605     |info view item|
   595 
   606 
   596     item := model selectedItem.
   607     item := model selectedItem.
   597 
   608 
   598     item notNil ifTrue:[ |state|
   609     item notNil ifTrue:[ |state|
   618 !
   629 !
   619 
   630 
   620 update:something with:someArgument from:aModel
   631 update:something with:someArgument from:aModel
   621     |oldSelection|
   632     |oldSelection|
   622 
   633 
   623     oldSelection := model selectedItem.
       
   624 
       
   625     aModel == testModeChannel ifTrue:[
       
   626         model selectedItem:nil.
       
   627         model testMode:(testModeChannel value).
       
   628         model selectedItem:oldSelection.
       
   629         ^ self
       
   630     ].
       
   631 
       
   632     aModel == showNamesHolder ifTrue:[
   634     aModel == showNamesHolder ifTrue:[
       
   635         oldSelection := model selectedItem.
   633         model selectedItem:nil.
   636         model selectedItem:nil.
   634         self listOfItems showWidgetNames:(aModel value).
   637         self listOfItems showWidgetNames:(aModel value).
   635         model selectedItem:oldSelection.
   638         model selectedItem:oldSelection.
   636         ^ self
   639         ^ self
   637     ].
   640     ].
   639 ! !
   642 ! !
   640 
   643 
   641 !ViewTreeApplication methodsFor:'event processing'!
   644 !ViewTreeApplication methodsFor:'event processing'!
   642 
   645 
   643 processButtonMotionEvent:ev
   646 processButtonMotionEvent:ev
   644     "handle a button motion event
   647     "handle a button motion event"
   645     "
   648 
   646     |click|
   649     |click rootView|
   647 
   650 
   648     motionAction notNil ifTrue:[
   651     motionAction isNil ifTrue:[^ self].
   649         click := ev view sensor mousePoint.
   652 
   650 
   653     (rootView := model rootView) isNil ifTrue:[
   651         click = clickedPoint ifFalse:[
   654         clickedItem := motionAction := nil.
   652             (clickedItem isNil or:[(click dist:clickedPoint) > 5.0]) ifTrue:[
   655         ^ self
   653                 motionAction value:click
   656     ].
   654             ]
   657 
       
   658     click := rootView device
       
   659             translatePoint:((ev x)@ (ev y))
       
   660             fromView:(ev view)
       
   661             toView:rootView.
       
   662 
       
   663     click = clickedPoint ifFalse:[
       
   664         (clickedItem isNil or:[(click dist:clickedPoint) > 5.0]) ifTrue:[
       
   665             motionAction value:click
   655         ]
   666         ]
   656     ].
   667     ].
   657 !
   668 !
   658 
   669 
   659 processButtonPressEvent:ev
   670 processButtonPressEvent:ev
   660     "handle a buttopn press event
   671     "handle a buttopn press event"
   661     "
   672 
   662     |sensor lastRectangle|
   673     |rootView sensor lastRectangle|
   663 
   674 
       
   675     rootView    := model rootView.
   664     sensor      := model rootView sensor.
   676     sensor      := model rootView sensor.
   665     clickedItem := model listOfItems detectItemRespondsToView:(ev view).
   677     clickedItem := model listOfItems detectItemRespondsToView:(ev view).
   666 
   678 
   667     (sensor ctrlDown or:[sensor shiftDown]) ifTrue:[
   679     (sensor ctrlDown or:[sensor shiftDown]) ifTrue:[
   668         clickedItem notNil ifTrue:[
   680         clickedItem notNil ifTrue:[
   669             self selectOnClickHolder value ifTrue:[
   681             self selectOnClickHolder value ifTrue:[
   670                 model toggleSelectItem:clickedItem
   682                 model toggleSelectItem:clickedItem
   671             ].
   683             ].
   672         ].
   684         ].
   673         clickedItem := motionAction := nil.
   685         clickedItem := motionAction := nil.
   674     ] ifFalse:[
   686         ^ self
   675         clickedPoint  := ev view sensor mousePoint.
   687     ].
   676         lastRectangle := nil.
   688 
   677 
   689     clickedPoint := rootView device translatePoint:((ev x)@ (ev y))  fromView:(ev view) toView:rootView.
   678         motionAction :=[:p| |rootView|
   690     lastRectangle := nil.
   679             rootView    := model rootView device rootView.
   691 
   680             clickedItem := nil.
   692     motionAction :=[:p|
   681 
   693         rootView    := model rootView device rootView.
   682             rootView xoring:[
   694         rootView    := model rootView.
   683                 lastRectangle notNil ifTrue:[ rootView displayRectangle:lastRectangle ]
   695         clickedItem := nil.
   684                                     ifFalse:[ rootView clippedByChildren:false ].
   696 
   685 
   697         rootView xoring:[
   686                 p isNil ifTrue:[
   698             lastRectangle notNil ifTrue:[ rootView displayRectangle:lastRectangle ]
   687                     rootView clippedByChildren:true.
   699                                 ifFalse:[ rootView clippedByChildren:false ].
   688                     motionAction := nil.
   700 
   689                 ] ifFalse:[
   701             p isNil ifTrue:[
   690                     lastRectangle := Rectangle origin:(clickedPoint min:p) corner:(clickedPoint max:p).
   702                 rootView clippedByChildren:true.
   691                     rootView displayRectangle:lastRectangle.
   703                 motionAction := nil.
   692                 ].
   704             ] ifFalse:[
   693                 rootView flush.
   705                 lastRectangle := Rectangle origin:(clickedPoint min:p) corner:(clickedPoint max:p).
       
   706                 rootView displayRectangle:lastRectangle.
   694             ].
   707             ].
   695             lastRectangle
   708             rootView flush.
   696         ]
   709         ].
   697     ]
   710         lastRectangle
       
   711     ].
   698 !
   712 !
   699 
   713 
   700 processButtonReleaseEvent:anEvent
   714 processButtonReleaseEvent:anEvent
   701     "handle a button release event
   715     "handle a button release event"
   702     "
   716 
   703     |rootView rectangle newItems widget origin|
   717     |rootView rectangle newItems widget origin|
   704 
   718 
       
   719     (rootView := model rootView) isNil ifTrue:[
       
   720         clickedItem := motionAction := nil.
       
   721         ^ self
       
   722     ].
   705     motionAction isNil ifTrue:[ ^ self ].
   723     motionAction isNil ifTrue:[ ^ self ].
   706     clickedItem notNil ifTrue:[ ^ model selectItem:clickedItem ].
   724     clickedItem notNil ifTrue:[ ^ model selectItem:clickedItem ].
   707 
   725 
   708     (rectangle := motionAction value:nil) notNil ifTrue:[
   726     rectangle := motionAction value:nil.
   709         rootView  := model rootView device rootView.
   727     rectangle isNil ifTrue:[^ self].
   710         newItems := OrderedCollection new.
   728 
   711 
   729     newItems := OrderedCollection new.
   712         model rootItem recursiveDo:[:anItem|
   730 
   713             widget := anItem widget.
   731     model rootItem recursiveDo:[:anItem|
   714             origin := widget originRelativeTo:rootView.
   732         widget := anItem widget.
   715 
   733         origin := widget originRelativeTo:rootView.
   716             (rectangle containsRect:(Rectangle origin:origin extent:(widget extent))) ifTrue:[
   734 
   717                 newItems add:anItem.
   735         (rectangle containsRect:(Rectangle origin:origin extent:(widget extent))) ifTrue:[
   718             ]
   736             newItems add:anItem.
   719         ].
   737         ]
   720         model value:newItems.
   738     ].
   721     ].
   739     model value:newItems.
   722 !
   740 !
   723 
   741 
   724 processEvent:anEvent
   742 processEvent:anEvent
   725     "process an event
   743     "process an event"
   726     "
   744 
   727     |button menu|
   745     |button menu|
   728 
   746 
   729     anEvent isKeyPressEvent ifTrue:[ ^ self processKeyPressEvent:anEvent ].
   747     anEvent isKeyPressEvent ifTrue:[ ^ self processKeyPressEvent:anEvent ].
   730     anEvent isButtonEvent  ifFalse:[ ^ self ].
   748     anEvent isButtonEvent  ifFalse:[ ^ self ].
   731 
   749 
   764         ].
   782         ].
   765     ].
   783     ].
   766 !
   784 !
   767 
   785 
   768 processKeyPressEvent:anEvent
   786 processKeyPressEvent:anEvent
   769     "process an key press event
   787     "process an key press event"
   770     "
   788 
   771     |item prnt idx key max next|
   789     |item prnt idx key max next|
   772 
   790 
   773     key := anEvent key.
   791     key := anEvent key.
   774     key isSymbol ifFalse:[^ self].
   792     key isSymbol ifFalse:[^ self].
   775 
   793 
   821       ^ self.
   839       ^ self.
   822     ].
   840     ].
   823 !
   841 !
   824 
   842 
   825 processMappedView:aView
   843 processMappedView:aView
   826     "process a mapped event
   844     "process a mapped event"
   827     "
   845 
   828     |parent anchor|
   846     |parent anchor|
   829 
   847 
   830     parent := self listOfItems detectItemRespondsToView:aView.
   848     parent := self listOfItems detectItemRespondsToView:aView.
   831     parent isNil ifTrue:[ ^ self ].
   849     parent isNil ifTrue:[ ^ self ].
   832 
   850 
   844 ! !
   862 ! !
   845 
   863 
   846 !ViewTreeApplication methodsFor:'initialization & release'!
   864 !ViewTreeApplication methodsFor:'initialization & release'!
   847 
   865 
   848 closeDownViews
   866 closeDownViews
   849     "release the grapped application
   867     "release the grapped application"
   850     "
   868 
   851     process := nil.
   869     process := nil.
   852     super closeDownViews.
   870     super closeDownViews.
   853     self doUnpick.
   871     self doUnpick.
   854 !
   872 !
   855 
   873 
   856 initialize
   874 initialize
   857     "setup my model and channels
   875     "setup my model and channels"
   858     "
   876 
   859     super initialize.
   877     super initialize.
   860 
   878 
   861     infoChannel              := ''    asValue.
   879     infoChannel              := ''    asValue.
   862     hasSingleSelectionHolder := false asValue.
   880     hasSingleSelectionHolder := false asValue.
   863     followFocusChannel       := false asValue.
   881     followFocusChannel       := false asValue.
   865     model := ViewTreeModel new.
   883     model := ViewTreeModel new.
   866     model inputEventAction:[:ev| self processEvent:ev ].
   884     model inputEventAction:[:ev| self processEvent:ev ].
   867     model mappedViewAction:[:vw| self processMappedView:vw ].
   885     model mappedViewAction:[:vw| self processMappedView:vw ].
   868     model application:self.
   886     model application:self.
   869 
   887 
   870     testModeChannel := model testMode asValue.
       
   871     testModeChannel addDependent:self.
       
   872 
       
   873     showNamesHolder := false asValue.
   888     showNamesHolder := false asValue.
   874     showNamesHolder addDependent:self.
   889     showNamesHolder addDependent:self.
   875 !
   890 !
   876 
   891 
   877 postBuildTree:aTree
   892 postBuildTree:aTree
   878     treeView := aTree scrolledView.
   893     treeView := aTree scrolledView.
   879     treeView hasConstantHeight:true.
   894     treeView hasConstantHeight:true.
   880 ! !
   895 ! !
   881 
   896 
   882 !ViewTreeApplication methodsFor:'menu actions'!
       
   883 
       
   884 doShowNames
       
   885     "automatically generated by UIEditor ..."
       
   886 
       
   887     "*** the code below performs no action"
       
   888     "*** (except for some feedback on the Transcript)"
       
   889     "*** Please change as required and accept in the browser."
       
   890     "*** (and replace this comment by something more useful ;-)"
       
   891 
       
   892     "action to be added ..."
       
   893 
       
   894     Transcript showCR:self class name, ': action for #doShowNames ...'.
       
   895 ! !
       
   896 
       
   897 !ViewTreeApplication methodsFor:'menu queries'!
   897 !ViewTreeApplication methodsFor:'menu queries'!
   898 
   898 
   899 hasApplication
   899 hasApplication
   900     "returns true if the current selected view has an application
   900     "returns true if the current selected view has an application"
   901     "
   901 
   902     |view|
   902     |view|
   903 
   903 
   904     view := self selectedView.
   904     view := self selectedView.
   905   ^ (view notNil and:[view application notNil])
   905   ^ (view notNil and:[view application notNil])
   906 !
   906 !
   907 
   907 
   908 hasController
   908 hasController
   909     "returns true if the current selected item's view has a controller
   909     "returns true if the current selected item's view has a controller
   910      other than nil or the view itself
   910      other than nil or the view itself"
   911     "
   911 
   912     |view controller|
   912     |view controller|
   913 
   913 
   914     view := self selectedView.
   914     view := self selectedView.
   915 
   915 
   916     view notNil ifTrue:[
   916     view notNil ifTrue:[
   919     ].
   919     ].
   920     ^ false
   920     ^ false
   921 !
   921 !
   922 
   922 
   923 hasModel
   923 hasModel
   924     "returns true if the current selected view has a model
   924     "returns true if the current selected view has a model"
   925     "
   925 
   926     |view|
   926     |view|
   927 
   927 
   928     view := self selectedView.
   928     view := self selectedView.
   929   ^ (view notNil and:[view model notNil])
   929   ^ (view notNil and:[view model notNil])
   930 !
       
   931 
       
   932 hasPickedView
       
   933     "returns true if a view is picked
       
   934     "
       
   935     ^ model rootItem notNil
       
   936 ! !
   930 ! !
   937 
   931 
   938 !ViewTreeApplication methodsFor:'menu specs'!
   932 !ViewTreeApplication methodsFor:'menu specs'!
   939 
   933 
   940 middleButtonMenu
   934 middleButtonMenu
   941     "returns the middleButton menu for the single selected item or nil
   935     "returns the middleButton menu for the single selected item or nil"
   942     "
   936 
   943     ^ [ model selectedItem notNil ifTrue:[self class middleButtonMenu]
   937     ^ [ model selectedItem notNil ifTrue:[self class middleButtonMenu]
   944                                  ifFalse:[nil]
   938                                  ifFalse:[nil]
   945       ]
   939       ]
   946 !
   940 !
   947 
   941 
  1020     ].
  1014     ].
  1021     ^ menu
  1015     ^ menu
  1022 !
  1016 !
  1023 
  1017 
  1024 submenuGeometry:aMenu
  1018 submenuGeometry:aMenu
  1025     "builds and returns the geometry submenu
  1019     "builds and returns the geometry submenu"
  1026     "
  1020 
  1027     |view point inst list x y|
  1021     |view point inst list x y|
  1028 
  1022 
  1029     view := self selectedView.
  1023     view := self selectedView.
  1030     view isNil ifTrue:[^ nil].
  1024     view isNil ifTrue:[^ nil].
  1031 
  1025 
  1082 
  1076 
  1083   ^ MenuDesc buildFromList:list onGC:aMenu
  1077   ^ MenuDesc buildFromList:list onGC:aMenu
  1084 !
  1078 !
  1085 
  1079 
  1086 submenuInspector:aMenu
  1080 submenuInspector:aMenu
  1087     "builds and returns the inspector submenu
  1081     "builds and returns the inspector submenu"
  1088     "
  1082 
  1089     |view list n names label value|
  1083     |view list n names label value|
  1090 
  1084 
  1091     view := self selectedView.
  1085     view := self selectedView.
  1092     view isNil ifTrue:[^ nil].
  1086     view isNil ifTrue:[^ nil].
  1093 
  1087 
  1112 
  1106 
  1113     ^ MenuDesc buildFromList:list onGC:aMenu
  1107     ^ MenuDesc buildFromList:list onGC:aMenu
  1114 !
  1108 !
  1115 
  1109 
  1116 submenuInterface:aMenu
  1110 submenuInterface:aMenu
  1117     "builds and returns the interface submenu
  1111     "builds and returns the interface submenu"
  1118     "
  1112 
  1119     |view label inst value list|
  1113     |view label inst value list|
  1120 
  1114 
  1121     view := self selectedView.
  1115     view := self selectedView.
  1122     view isNil ifTrue:[^ nil].
  1116     view isNil ifTrue:[^ nil].
  1123 
  1117 
  1211     list last isSeparator ifTrue:[ list removeLast ].
  1205     list last isSeparator ifTrue:[ list removeLast ].
  1212   ^ MenuDesc buildFromList:list onGC:aMenu
  1206   ^ MenuDesc buildFromList:list onGC:aMenu
  1213 !
  1207 !
  1214 
  1208 
  1215 submenuVisibility:aMenu
  1209 submenuVisibility:aMenu
  1216     "builds and returns the geometry submenu
  1210     "builds and returns the geometry submenu"
  1217     "
  1211 
  1218     |view list value|
  1212     |view list value|
  1219 
  1213 
  1220     view := self selectedView.
  1214     view := self selectedView.
  1221     view isNil ifTrue:[^ nil].
  1215     view isNil ifTrue:[^ nil].
  1222 
  1216 
  1284         ].
  1278         ].
  1285         aRootItemOrNil expand.
  1279         aRootItemOrNil expand.
  1286 
  1280 
  1287         process isNil ifTrue:[
  1281         process isNil ifTrue:[
  1288             theProcess := process :=
  1282             theProcess := process :=
  1289                 Process for:[   |update|
  1283                 Process for:[   |update testModeChannel|
  1290 
  1284 
  1291                                 update := false.
  1285                                 update := false.
  1292 
  1286                                 testModeChannel := model testModeChannel.
  1293                                [process == theProcess] whileTrue:[
  1287 
       
  1288                                 [process == theProcess] whileTrue:[
  1294                                     Delay waitForSeconds:0.5.
  1289                                     Delay waitForSeconds:0.5.
  1295 
  1290 
  1296                                     (treeView notNil and:[process == theProcess and:[treeView shown]]) ifTrue:[
  1291                                     (treeView notNil and:[process == theProcess and:[treeView shown]]) ifTrue:[
  1297                                         (self isInTestmode and:[followFocusChannel value == true]) ifTrue:[
  1292                                         (testModeChannel value == true and:[followFocusChannel value == true]) ifTrue:[
  1298                                             self selectFocusView.
  1293                                             self selectFocusView.
  1299                                         ].
  1294                                         ].
  1300                                         update ifTrue:[
  1295                                         update ifTrue:[
  1301                                             self updateShownStatus.
  1296                                             self updateShownStatus.
  1302                                         ].
  1297                                         ].
  1347             treeView invalidateDeviceRectangle:damage repairNow:false.
  1342             treeView invalidateDeviceRectangle:damage repairNow:false.
  1348         ].
  1343         ].
  1349     ].
  1344     ].
  1350 ! !
  1345 ! !
  1351 
  1346 
  1352 !ViewTreeApplication methodsFor:'queries'!
       
  1353 
       
  1354 isInTestmode
       
  1355     "returns true if running in test mode - no events eaten
       
  1356     "
       
  1357     ^ testModeChannel value == true
       
  1358 ! !
       
  1359 
       
  1360 !ViewTreeApplication methodsFor:'selection'!
  1347 !ViewTreeApplication methodsFor:'selection'!
  1361 
  1348 
  1362 selectedView
  1349 selectedView
  1363     "returns the selected view or nil
  1350     "answer the selected view or nil"
  1364     "
  1351 
  1365     |item|
  1352     |item|
  1366 
  1353 
  1367     item := model selectedItem.
  1354     item := model selectedItem.
  1368     item notNil ifTrue:[ ^ item widget ].
  1355     item notNil ifTrue:[ ^ item widget ].
  1369   ^ nil
  1356   ^ nil
  1411         inst class browserClass openInClass:(inst class) selector:nil
  1398         inst class browserClass openInClass:(inst class) selector:nil
  1412     ].
  1399     ].
  1413 !
  1400 !
  1414 
  1401 
  1415 doDestroy
  1402 doDestroy
  1416     "destroy the current selected view
  1403     "destroy the current selected view"
  1417     "
  1404 
  1418     |item parent|
  1405     |item parent|
  1419 
  1406 
  1420     item := model selectedItem.
  1407     item := model selectedItem.
  1421     item isNil ifTrue:[ ^ self].
  1408     item isNil ifTrue:[ ^ self].
  1422 
  1409 
  1447         model value:nsel.
  1434         model value:nsel.
  1448     ].
  1435     ].
  1449 !
  1436 !
  1450 
  1437 
  1451 doFlash
  1438 doFlash
  1452     "flash the selected view
  1439     "flash the selected view"
  1453     "
  1440 
  1454     |view|
  1441     |view|
  1455 
  1442 
  1456     view := self selectedView.
  1443     view := self selectedView.
  1457     view isNil ifTrue:[ ^ self].
  1444     view isNil ifTrue:[ ^ self].
  1458 
  1445 
  1483 
  1470 
  1484     inst notNil ifTrue:[ inst inspect ].
  1471     inst notNil ifTrue:[ inst inspect ].
  1485 !
  1472 !
  1486 
  1473 
  1487 doPickViews
  1474 doPickViews
  1488     "pick a window's topView
  1475     "pick a window's topView"
  1489     "
  1476 
  1490     |window|
  1477     |window|
  1491 
  1478 
  1492     self doUnpick.
  1479     self doUnpick.
  1493 
  1480 
  1494     window := Screen current viewFromUser.
  1481     window := Screen current viewFromUser.
  1555         model selectItem:firstFound
  1542         model selectItem:firstFound
  1556     ].
  1543     ].
  1557 !
  1544 !
  1558 
  1545 
  1559 doUnpick
  1546 doUnpick
  1560     "release current picked window and contained subwindows
  1547     "release current picked window and contained subwindows"
  1561     "
  1548 
  1562     self setRootItem:nil.
  1549     self setRootItem:nil.
  1563 ! !
  1550 ! !
  1564 
  1551 
  1565 !ViewTreeApplication::MenuDesc class methodsFor:'building'!
  1552 !ViewTreeApplication::MenuDesc class methodsFor:'building'!
  1566 
  1553