FlyByWindowInformation.st
author Claus Gittinger <cg@exept.de>
Wed, 29 Jul 2009 20:02:02 +0200
changeset 2570 4e663bc64364
parent 2543 7ad308542625
child 2587 81f38cd168a7
permissions -rw-r--r--
changed #requestPackage
     1 "{ Package: 'stx:libtool2' }"
     2 
     3 FlyByHelp subclass:#FlyByWindowInformation
     4 	instanceVariableNames:'lastApplication lastView cleanupAction finishSemaphore'
     5 	classVariableNames:''
     6 	poolDictionaries:''
     7 	category:'Interface-Help'
     8 !
     9 
    10 !FlyByWindowInformation class methodsFor:'documentation'!
    11 
    12 examples
    13 "
    14     self shownInformationOfViewUnderMouseUntilButtonIsPressed
    15 "
    16 !
    17 
    18 shownInformationOfViewUnderMouseUntilButtonIsPressed
    19     self start waitUntilFinished
    20 
    21     "
    22      self shownInformationOfViewUnderMouseUntilButtonIsPressed
    23     "
    24 ! !
    25 
    26 !FlyByWindowInformation methodsFor:'accessing'!
    27 
    28 cleanupAction:something
    29     cleanupAction := something.
    30 !
    31 
    32 lastApplication
    33     ^ lastApplication
    34 !
    35 
    36 lastView
    37     ^ lastView
    38 ! !
    39 
    40 !FlyByWindowInformation methodsFor:'defaults'!
    41 
    42 flyByHelpTimeoutMillis
    43     ^ 1000
    44 ! !
    45 
    46 !FlyByWindowInformation methodsFor:'event handling'!
    47 
    48 buttonMotion:buttonAndModifierState x:x y:y view:aView
    49     super buttonMotion:buttonAndModifierState x:x y:y view:aView.
    50     ^ true
    51 !
    52 
    53 buttonPress:button x:x y:y view:aView
    54     self stop.
    55     ^ true
    56 !
    57 
    58 keyPress:key x:x y:y view:aView
    59     |obj action lcKey|
    60 
    61     key == #Escape ifTrue:[
    62         self stop.
    63         ^ true
    64     ].
    65 
    66     key == $? ifTrue:[
    67         [
    68             WindowTreeView openOn:(lastView topView) initialSelection:lastView.
    69         ] fork.
    70         self stop.
    71         ^ true.
    72     ].
    73 
    74     key isCharacter ifTrue:[
    75         lcKey := key asLowercase.
    76 
    77         lcKey == $a ifTrue:[
    78             obj := lastApplication
    79         ].
    80         lcKey == $o ifTrue:[
    81             obj := lastView model
    82         ].
    83         lcKey == $m ifTrue:[
    84             obj := lastApplication masterApplication
    85         ].
    86         lcKey == $v ifTrue:[
    87             obj := lastView
    88         ].
    89         lcKey == $t ifTrue:[
    90             obj := lastView topView
    91         ].
    92         obj notNil ifTrue:[
    93             key isLowercase ifTrue:[
    94                 action := [ obj inspect ].
    95             ] ifFalse:[
    96                 action := [ obj browse ].
    97             ].
    98             action forkAt:8.
    99         ].
   100     ].
   101 
   102     ^ true
   103 ! !
   104 
   105 !FlyByWindowInformation methodsFor:'help texts'!
   106 
   107 helpTextFor:aView at:aPointOrNil
   108     lastView := aView.
   109     lastApplication := aView application.
   110 
   111     ^ String streamContents:[:s |
   112         |topViewToInspect applicationToInspect masterApplicationToInspect modelToInspect|
   113 
   114         aView topView ~~ aView ifTrue:[
   115             topViewToInspect := aView topView.
   116         ].
   117         lastApplication notNil ifTrue:[
   118             applicationToInspect := lastApplication.
   119             masterApplicationToInspect := lastApplication masterApplication.
   120         ].
   121         aView model notNil ifTrue:[
   122             modelToInspect := aView model.
   123             ((modelToInspect == applicationToInspect)
   124             or:[ modelToInspect == masterApplicationToInspect ]) ifTrue:[
   125                 modelToInspect := nil.
   126             ].
   127         ].
   128 
   129         s nextPutLine:('View: ' , aView class name, ' "',aView name printString,'"').
   130         modelToInspect notNil ifTrue:[
   131             s nextPutLine:('Model: ' , modelToInspect class name).
   132         ].
   133         topViewToInspect notNil ifTrue:[
   134             s nextPutLine:('Topview: ' , topViewToInspect class name).
   135         ].
   136         applicationToInspect notNil ifTrue:[
   137             s nextPutLine:('Application: ' , applicationToInspect class name).
   138         ].
   139         masterApplicationToInspect notNil ifTrue:[
   140             s nextPutLine:('Masterapplication: ' , masterApplicationToInspect class name).
   141         ].
   142 
   143         s cr.
   144         s nextPutLine:'Press:'.
   145         s nextPutLine:'    ? to show the viewtree'.
   146         s nextPutLine:'    v to inspect view (V to browse)'.
   147         modelToInspect notNil ifTrue:[
   148             s nextPutLine:'    o to inspect model (O to browse)'.
   149         ].
   150         topViewToInspect notNil ifTrue:[
   151             s nextPutLine:'    t to inspect topView (T to browse)'.
   152         ].
   153         applicationToInspect notNil ifTrue:[
   154             s nextPutLine:'    a to inspect application (A to browse)'.
   155             masterApplicationToInspect notNil ifTrue:[
   156                 s nextPutLine:'    m to inspect masterApplication (M to browse)'.
   157             ].
   158         ].
   159         s nextPutAll:'ESC or button to leave flyBy-info mode.'.
   160     ]
   161 
   162     "
   163      self shownInformationOfViewUnderMouseUntilButtonIsPressed
   164     "
   165 ! !
   166 
   167 !FlyByWindowInformation methodsFor:'queries'!
   168 
   169 toolTipFollowsMouse
   170     ^ true
   171 ! !
   172 
   173 !FlyByWindowInformation methodsFor:'start & stop'!
   174 
   175 start
   176     |l|
   177 
   178     l := FlyByHelp currentHelpListener.
   179     l notNil ifTrue:[
   180         FlyByHelp stop.
   181         cleanupAction := [ FlyByHelp start ].
   182     ].
   183     finishSemaphore := Semaphore new.
   184     super start.
   185 !
   186 
   187 stop
   188     super stop.
   189     cleanupAction value.
   190     finishSemaphore notNil ifTrue:[
   191         finishSemaphore signalIf.
   192     ].
   193 !
   194 
   195 waitUntilFinished
   196     finishSemaphore wait.
   197 ! !
   198 
   199 !FlyByWindowInformation class methodsFor:'documentation'!
   200 
   201 version
   202     ^ '$Header$'
   203 ! !