FlyByWindowInformation.st
author Claus Gittinger <cg@exept.de>
Tue, 29 Sep 2009 21:32:51 +0200
changeset 2587 81f38cd168a7
parent 2543 7ad308542625
child 2699 22dd96b4e37f
permissions -rw-r--r--
added: #copyright
cg@2587
     1
"
cg@2587
     2
 COPYRIGHT (c) 2008 by eXept Software AG
cg@2587
     3
              All Rights Reserved
cg@2587
     4
cg@2587
     5
 This software is furnished under a license and may be used
cg@2587
     6
 only in accordance with the terms of that license and with the
cg@2587
     7
 inclusion of the above copyright notice.   This software may not
cg@2587
     8
 be provided or otherwise made available to, or used by, any
cg@2587
     9
 other person.  No title to or ownership of the software is
cg@2587
    10
 hereby transferred.
cg@2587
    11
"
cg@2300
    12
"{ Package: 'stx:libtool2' }"
cg@2300
    13
cg@2300
    14
FlyByHelp subclass:#FlyByWindowInformation
cg@2300
    15
	instanceVariableNames:'lastApplication lastView cleanupAction finishSemaphore'
cg@2300
    16
	classVariableNames:''
cg@2300
    17
	poolDictionaries:''
cg@2300
    18
	category:'Interface-Help'
cg@2300
    19
!
cg@2300
    20
cg@2300
    21
!FlyByWindowInformation class methodsFor:'documentation'!
cg@2300
    22
cg@2587
    23
copyright
cg@2587
    24
"
cg@2587
    25
 COPYRIGHT (c) 2008 by eXept Software AG
cg@2587
    26
              All Rights Reserved
cg@2587
    27
cg@2587
    28
 This software is furnished under a license and may be used
cg@2587
    29
 only in accordance with the terms of that license and with the
cg@2587
    30
 inclusion of the above copyright notice.   This software may not
cg@2587
    31
 be provided or otherwise made available to, or used by, any
cg@2587
    32
 other person.  No title to or ownership of the software is
cg@2587
    33
 hereby transferred.
cg@2587
    34
"
cg@2587
    35
!
cg@2587
    36
cg@2300
    37
examples
cg@2300
    38
"
cg@2300
    39
    self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
    40
"
cg@2300
    41
!
cg@2300
    42
cg@2300
    43
shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
    44
    self start waitUntilFinished
cg@2300
    45
cg@2300
    46
    "
cg@2300
    47
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
    48
    "
cg@2300
    49
! !
cg@2300
    50
cg@2300
    51
!FlyByWindowInformation methodsFor:'accessing'!
cg@2300
    52
cg@2300
    53
cleanupAction:something
cg@2300
    54
    cleanupAction := something.
cg@2300
    55
!
cg@2300
    56
cg@2300
    57
lastApplication
cg@2300
    58
    ^ lastApplication
cg@2300
    59
!
cg@2300
    60
cg@2300
    61
lastView
cg@2300
    62
    ^ lastView
cg@2300
    63
! !
cg@2300
    64
cg@2543
    65
!FlyByWindowInformation methodsFor:'defaults'!
cg@2543
    66
cg@2543
    67
flyByHelpTimeoutMillis
cg@2543
    68
    ^ 1000
cg@2543
    69
! !
cg@2543
    70
cg@2300
    71
!FlyByWindowInformation methodsFor:'event handling'!
cg@2300
    72
cg@2340
    73
buttonMotion:buttonAndModifierState x:x y:y view:aView
cg@2340
    74
    super buttonMotion:buttonAndModifierState x:x y:y view:aView.
cg@2300
    75
    ^ true
cg@2300
    76
!
cg@2300
    77
cg@2300
    78
buttonPress:button x:x y:y view:aView
cg@2300
    79
    self stop.
cg@2300
    80
    ^ true
cg@2300
    81
!
cg@2300
    82
cg@2300
    83
keyPress:key x:x y:y view:aView
cg@2435
    84
    |obj action lcKey|
cg@2300
    85
cg@2300
    86
    key == #Escape ifTrue:[
cg@2300
    87
        self stop.
cg@2300
    88
        ^ true
cg@2300
    89
    ].
cg@2300
    90
cg@2435
    91
    key == $? ifTrue:[
cg@2435
    92
        [
cg@2435
    93
            WindowTreeView openOn:(lastView topView) initialSelection:lastView.
cg@2435
    94
        ] fork.
cg@2435
    95
        self stop.
cg@2435
    96
        ^ true.
cg@2300
    97
    ].
cg@2435
    98
cg@2435
    99
    key isCharacter ifTrue:[
cg@2435
   100
        lcKey := key asLowercase.
cg@2435
   101
cg@2435
   102
        lcKey == $a ifTrue:[
cg@2435
   103
            obj := lastApplication
cg@2300
   104
        ].
cg@2435
   105
        lcKey == $o ifTrue:[
cg@2435
   106
            obj := lastView model
cg@2435
   107
        ].
cg@2435
   108
        lcKey == $m ifTrue:[
cg@2435
   109
            obj := lastApplication masterApplication
cg@2435
   110
        ].
cg@2435
   111
        lcKey == $v ifTrue:[
cg@2435
   112
            obj := lastView
cg@2435
   113
        ].
cg@2435
   114
        lcKey == $t ifTrue:[
cg@2435
   115
            obj := lastView topView
cg@2435
   116
        ].
cg@2435
   117
        obj notNil ifTrue:[
cg@2435
   118
            key isLowercase ifTrue:[
cg@2435
   119
                action := [ obj inspect ].
cg@2435
   120
            ] ifFalse:[
cg@2435
   121
                action := [ obj browse ].
cg@2435
   122
            ].
cg@2435
   123
            action forkAt:8.
cg@2435
   124
        ].
cg@2300
   125
    ].
cg@2300
   126
cg@2300
   127
    ^ true
cg@2300
   128
! !
cg@2300
   129
cg@2300
   130
!FlyByWindowInformation methodsFor:'help texts'!
cg@2300
   131
cg@2300
   132
helpTextFor:aView at:aPointOrNil
cg@2300
   133
    lastView := aView.
cg@2300
   134
    lastApplication := aView application.
cg@2300
   135
cg@2300
   136
    ^ String streamContents:[:s |
cg@2314
   137
        |topViewToInspect applicationToInspect masterApplicationToInspect modelToInspect|
cg@2314
   138
cg@2300
   139
        aView topView ~~ aView ifTrue:[
cg@2314
   140
            topViewToInspect := aView topView.
cg@2300
   141
        ].
cg@2300
   142
        lastApplication notNil ifTrue:[
cg@2314
   143
            applicationToInspect := lastApplication.
cg@2314
   144
            masterApplicationToInspect := lastApplication masterApplication.
cg@2314
   145
        ].
cg@2314
   146
        aView model notNil ifTrue:[
cg@2314
   147
            modelToInspect := aView model.
cg@2314
   148
            ((modelToInspect == applicationToInspect)
cg@2314
   149
            or:[ modelToInspect == masterApplicationToInspect ]) ifTrue:[
cg@2314
   150
                modelToInspect := nil.
cg@2300
   151
            ].
cg@2300
   152
        ].
cg@2314
   153
cg@2352
   154
        s nextPutLine:('View: ' , aView class name, ' "',aView name printString,'"').
cg@2314
   155
        modelToInspect notNil ifTrue:[
cg@2314
   156
            s nextPutLine:('Model: ' , modelToInspect class name).
cg@2314
   157
        ].
cg@2314
   158
        topViewToInspect notNil ifTrue:[
cg@2314
   159
            s nextPutLine:('Topview: ' , topViewToInspect class name).
cg@2314
   160
        ].
cg@2314
   161
        applicationToInspect notNil ifTrue:[
cg@2314
   162
            s nextPutLine:('Application: ' , applicationToInspect class name).
cg@2314
   163
        ].
cg@2314
   164
        masterApplicationToInspect notNil ifTrue:[
cg@2314
   165
            s nextPutLine:('Masterapplication: ' , masterApplicationToInspect class name).
cg@2314
   166
        ].
cg@2314
   167
cg@2300
   168
        s cr.
cg@2300
   169
        s nextPutLine:'Press:'.
cg@2435
   170
        s nextPutLine:'    ? to show the viewtree'.
cg@2300
   171
        s nextPutLine:'    v to inspect view (V to browse)'.
cg@2314
   172
        modelToInspect notNil ifTrue:[
cg@2314
   173
            s nextPutLine:'    o to inspect model (O to browse)'.
cg@2314
   174
        ].
cg@2314
   175
        topViewToInspect notNil ifTrue:[
cg@2300
   176
            s nextPutLine:'    t to inspect topView (T to browse)'.
cg@2300
   177
        ].
cg@2314
   178
        applicationToInspect notNil ifTrue:[
cg@2300
   179
            s nextPutLine:'    a to inspect application (A to browse)'.
cg@2314
   180
            masterApplicationToInspect notNil ifTrue:[
cg@2300
   181
                s nextPutLine:'    m to inspect masterApplication (M to browse)'.
cg@2300
   182
            ].
cg@2300
   183
        ].
cg@2493
   184
        s nextPutAll:'ESC or button to leave flyBy-info mode.'.
cg@2300
   185
    ]
cg@2300
   186
cg@2300
   187
    "
cg@2300
   188
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
   189
    "
cg@2300
   190
! !
cg@2300
   191
cg@2300
   192
!FlyByWindowInformation methodsFor:'queries'!
cg@2300
   193
cg@2300
   194
toolTipFollowsMouse
cg@2300
   195
    ^ true
cg@2300
   196
! !
cg@2300
   197
cg@2300
   198
!FlyByWindowInformation methodsFor:'start & stop'!
cg@2300
   199
cg@2300
   200
start
cg@2300
   201
    |l|
cg@2300
   202
cg@2300
   203
    l := FlyByHelp currentHelpListener.
cg@2300
   204
    l notNil ifTrue:[
cg@2300
   205
        FlyByHelp stop.
cg@2300
   206
        cleanupAction := [ FlyByHelp start ].
cg@2300
   207
    ].
cg@2300
   208
    finishSemaphore := Semaphore new.
cg@2300
   209
    super start.
cg@2300
   210
!
cg@2300
   211
cg@2300
   212
stop
cg@2300
   213
    super stop.
cg@2300
   214
    cleanupAction value.
cg@2300
   215
    finishSemaphore notNil ifTrue:[
cg@2300
   216
        finishSemaphore signalIf.
cg@2300
   217
    ].
cg@2300
   218
!
cg@2300
   219
cg@2300
   220
waitUntilFinished
cg@2300
   221
    finishSemaphore wait.
cg@2300
   222
! !
cg@2300
   223
cg@2300
   224
!FlyByWindowInformation class methodsFor:'documentation'!
cg@2300
   225
cg@2300
   226
version
cg@2300
   227
    ^ '$Header$'
cg@2587
   228
!
cg@2587
   229
cg@2587
   230
version_CVS
cg@2587
   231
    ^ '$Header$'
cg@2300
   232
! !