FlyByWindowInformation.st
author Claus Gittinger <cg@exept.de>
Mon, 16 Dec 2013 14:42:41 +0100
changeset 3065 311d632319d9
parent 3058 d7792b7a50b7
child 3212 c973eab410cb
permissions -rw-r--r--
class: FlyByWindowInformation
added: #documentation
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@2699
    15
	instanceVariableNames:'lastApplication lastView cleanupAction finishSemaphore finished'
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@3065
    37
documentation
cg@3065
    38
"
cg@3065
    39
    I implement a tooltip, which presents a number of interesting facts
cg@3065
    40
    about the window under the mouse pointer, and also offer keyboard
cg@3065
    41
    shortcuts to quickly open browsers and/or inspectors on the view under the
cg@3065
    42
    pointer.
cg@3065
    43
    Enabled via the Launcher's 'FlyBy Window Information' menu item.
cg@3065
    44
"
cg@3065
    45
!
cg@3065
    46
cg@2300
    47
examples
cg@2300
    48
"
cg@2300
    49
    self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
    50
"
cg@2300
    51
!
cg@2300
    52
cg@2300
    53
shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
    54
    self start waitUntilFinished
cg@2300
    55
cg@2300
    56
    "
cg@2300
    57
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
    58
    "
cg@2300
    59
! !
cg@2300
    60
cg@2300
    61
!FlyByWindowInformation methodsFor:'accessing'!
cg@2300
    62
cg@2699
    63
cleanupAction:something 
cg@2300
    64
    cleanupAction := something.
cg@2300
    65
!
cg@2300
    66
cg@2300
    67
lastApplication
cg@2300
    68
    ^ lastApplication
cg@2300
    69
!
cg@2300
    70
cg@2300
    71
lastView
cg@2300
    72
    ^ lastView
cg@2300
    73
! !
cg@2300
    74
cg@2543
    75
!FlyByWindowInformation methodsFor:'defaults'!
cg@2543
    76
cg@2543
    77
flyByHelpTimeoutMillis
cg@2543
    78
    ^ 1000
cg@2543
    79
! !
cg@2543
    80
cg@2300
    81
!FlyByWindowInformation methodsFor:'event handling'!
cg@2300
    82
cg@2340
    83
buttonMotion:buttonAndModifierState x:x y:y view:aView
cg@2702
    84
    finished == true ifTrue:[^ self].
cg@2702
    85
cg@2340
    86
    super buttonMotion:buttonAndModifierState x:x y:y view:aView.
cg@2300
    87
    ^ true
cg@2300
    88
!
cg@2300
    89
cg@2300
    90
buttonPress:button x:x y:y view:aView
cg@2300
    91
    self stop.
cg@2300
    92
    ^ true
cg@2300
    93
!
cg@2300
    94
cg@2300
    95
keyPress:key x:x y:y view:aView
cg@2943
    96
    <resource: #keyboard (#Escape #Return)>
cg@2943
    97
cg@2823
    98
    |obj objToInspect objToBrowse lcKey|
cg@2300
    99
cg@2300
   100
    key == #Escape ifTrue:[
cg@2300
   101
        self stop.
cg@2300
   102
        ^ true
cg@2300
   103
    ].
cg@2300
   104
cg@2435
   105
    key == $? ifTrue:[
cg@2435
   106
        [
sv@2836
   107
            WindowTreeView notNil ifTrue:[
sv@2836
   108
                WindowTreeView openOn:(lastView topView) initialSelection:lastView.
sv@2836
   109
            ] ifFalse:[
sv@2836
   110
                self warn:'WindowTreeView class is not present!!'.
sv@2836
   111
            ].
cg@2435
   112
        ] fork.
cg@2435
   113
        self stop.
cg@2435
   114
        ^ true.
cg@2300
   115
    ].
cg@2435
   116
cg@2823
   117
    key == #Return ifTrue:[
cg@2823
   118
        objToBrowse := lastApplication ? lastView
cg@2823
   119
    ].
cg@2823
   120
cg@2435
   121
    key isCharacter ifTrue:[
cg@2435
   122
        lcKey := key asLowercase.
cg@2435
   123
cg@2435
   124
        lcKey == $a ifTrue:[
cg@2435
   125
            obj := lastApplication
cg@2300
   126
        ].
cg@2435
   127
        lcKey == $o ifTrue:[
cg@2824
   128
            lastView notNil ifTrue:[
cg@2824
   129
                obj := lastView model
cg@2824
   130
            ].
cg@2435
   131
        ].
cg@2435
   132
        lcKey == $m ifTrue:[
cg@2824
   133
            lastApplication notNil ifTrue:[
cg@2824
   134
                obj := lastApplication masterApplication
cg@2824
   135
            ]
cg@2824
   136
        ].
cg@2824
   137
        lcKey == $t ifTrue:[
cg@2824
   138
            lastApplication notNil ifTrue:[
cg@2824
   139
                obj := lastApplication topApplication
cg@2824
   140
            ].
cg@2435
   141
        ].
cg@2435
   142
        lcKey == $v ifTrue:[
cg@2435
   143
            obj := lastView
cg@2435
   144
        ].
cg@2939
   145
        lcKey == $g ifTrue:[
cg@2939
   146
            obj := lastView windowGroup
cg@2939
   147
        ].
cg@2824
   148
        lcKey == $w ifTrue:[
cg@2824
   149
            lastView notNil ifTrue:[
cg@2824
   150
                obj := lastView topView
cg@2824
   151
            ]
cg@2435
   152
        ].
cg@2435
   153
        obj notNil ifTrue:[
cg@2435
   154
            key isLowercase ifTrue:[
cg@2823
   155
                objToInspect := obj
cg@2435
   156
            ] ifFalse:[
cg@2823
   157
                objToBrowse := obj
cg@2435
   158
            ].
cg@2435
   159
        ].
cg@2300
   160
    ].
cg@2300
   161
cg@2823
   162
    objToInspect notNil ifTrue:[
cg@2823
   163
        [ objToInspect inspect ] forkAt:(Processor userSchedulingPriority).
cg@2823
   164
    ].
cg@2823
   165
    objToBrowse notNil ifTrue:[
cg@2823
   166
        [ objToBrowse browse ] forkAt:(Processor userSchedulingPriority).
cg@2823
   167
    ].
cg@2823
   168
cg@2300
   169
    ^ true
cg@2823
   170
cg@2824
   171
    "Modified: / 12-11-2010 / 11:51:04 / cg"
cg@2300
   172
! !
cg@2300
   173
cg@2300
   174
!FlyByWindowInformation methodsFor:'help texts'!
cg@2300
   175
cg@2300
   176
helpTextFor:aView at:aPointOrNil
cg@2699
   177
    "generate the text to be shown as popup-flyby info"
cg@2699
   178
cg@2824
   179
    |resources|
cg@2824
   180
cg@2300
   181
    lastView := aView.
cg@2300
   182
    lastApplication := aView application.
cg@2300
   183
cg@2824
   184
    resources := self class classResources.
cg@2824
   185
cg@2824
   186
    ^ Text streamContents:[:s |
cg@2824
   187
        |topViewToInspect applicationToInspect 
cg@2824
   188
         masterApplicationToInspect topApplicationToInspect modelToInspect
cg@2939
   189
         genComponentNameForApplication windowGroupToInspect|
cg@2700
   190
cg@2824
   191
        genComponentNameForApplication := 
cg@2824
   192
            [:app :s |
cg@2700
   193
                (app notNil 
cg@2700
   194
                and:[ app builder notNil ]) ifTrue:[
cg@2700
   195
                    |components v|
cg@2700
   196
cg@2700
   197
                    components := app builder namedComponents.
cg@2700
   198
cg@2700
   199
                    v := aView.
cg@2700
   200
                    [   (components includes:v) not
cg@2700
   201
                        and:[v container notNil]
cg@2700
   202
                    ] whileTrue:[
cg@2700
   203
                        v := v container.
cg@2700
   204
                    ].
cg@2700
   205
                    (components includes:v) ifTrue:[
cg@2700
   206
                        |k|
cg@2700
   207
cg@2700
   208
                        k := components keyAtValue:v.
cg@2700
   209
                        v == aView ifTrue:[
cg@2824
   210
                            s nextPutLine:('       component: ' , k).
cg@2700
   211
                        ] ifFalse:[
cg@2824
   212
                            s nextPutLine:('       subview of component: ' , k).
cg@2700
   213
                        ].
cg@2700
   214
                    ].
cg@2700
   215
                ].
cg@2700
   216
            ].
cg@2314
   217
cg@2300
   218
        aView topView ~~ aView ifTrue:[
cg@2314
   219
            topViewToInspect := aView topView.
cg@2300
   220
        ].
cg@2300
   221
        lastApplication notNil ifTrue:[
cg@2314
   222
            applicationToInspect := lastApplication.
cg@2314
   223
            masterApplicationToInspect := lastApplication masterApplication.
cg@2824
   224
            masterApplicationToInspect notNil ifTrue:[
cg@2824
   225
                masterApplicationToInspect == applicationToInspect ifTrue:[
cg@2824
   226
                    masterApplicationToInspect := nil
cg@2824
   227
                ] ifFalse:[
cg@2824
   228
                    topApplicationToInspect := masterApplicationToInspect topApplication.
cg@2824
   229
                    topApplicationToInspect == masterApplicationToInspect ifTrue:[
cg@2824
   230
                        topApplicationToInspect := nil
cg@2824
   231
                    ]
cg@2824
   232
                ].
cg@2824
   233
            ]
cg@2314
   234
        ].
cg@2314
   235
        aView model notNil ifTrue:[
cg@2314
   236
            modelToInspect := aView model.
cg@2314
   237
            ((modelToInspect == applicationToInspect)
cg@2314
   238
            or:[ modelToInspect == masterApplicationToInspect ]) ifTrue:[
cg@2314
   239
                modelToInspect := nil.
cg@2300
   240
            ].
cg@2300
   241
        ].
cg@2314
   242
cg@2824
   243
        applicationToInspect notNil ifTrue:[
cg@2824
   244
            s nextPutLine:(resources string:'Application: %1' with:applicationToInspect class name allBold).
cg@2824
   245
            genComponentNameForApplication value:applicationToInspect value:s.
cg@2314
   246
        ].
cg@2700
   247
        masterApplicationToInspect notNil ifTrue:[
cg@2824
   248
            s nextPutLine:(resources string:'Master-Application: %1' with:masterApplicationToInspect class name allBold).
cg@2824
   249
            "/ genComponentNameForApplication value:masterApplicationToInspect value:s.
cg@2700
   250
        ].
cg@2824
   251
        topApplicationToInspect notNil ifTrue:[
cg@2824
   252
            s nextPutLine:(resources string:'Top-Application: %1' with:topApplicationToInspect class name allBold).
cg@2824
   253
            "/ genComponentNameForApplication value:topApplicationToInspect value:s.
cg@2314
   254
        ].
cg@2824
   255
        s nextPutLine:(resources string:'View: %1 "%2"' with:aView class name allBold with:aView name).
cg@2824
   256
        topViewToInspect notNil ifTrue:[
cg@2824
   257
            s nextPutLine:(resources string:'Topview: %1' with:topViewToInspect class name allBold).
cg@2824
   258
        ].
cg@2824
   259
        modelToInspect notNil ifTrue:[
cg@2824
   260
            s nextPutLine:(resources string:'Model: %1' with:modelToInspect class name allBold).
cg@2824
   261
        ].
cg@2699
   262
cg@2300
   263
        s cr.
cg@2300
   264
        s nextPutLine:'Press:'.
cg@2435
   265
        s nextPutLine:'    ? to show the viewtree'.
cg@2314
   266
        applicationToInspect notNil ifTrue:[
cg@2300
   267
            s nextPutLine:'    a to inspect application (A to browse)'.
cg@2314
   268
            masterApplicationToInspect notNil ifTrue:[
cg@2300
   269
                s nextPutLine:'    m to inspect masterApplication (M to browse)'.
cg@2824
   270
                topApplicationToInspect notNil ifTrue:[
cg@2824
   271
                    s nextPutLine:'    t to inspect masterApplication (T to browse)'.
cg@2824
   272
                ]
cg@2300
   273
            ].
cg@2300
   274
        ].
cg@2823
   275
        s nextPutLine:'    v to inspect view (V to browse)'.
cg@2823
   276
        topViewToInspect notNil ifTrue:[
cg@2824
   277
            s nextPutLine:'    w to inspect topWindow (W to browse)'.
cg@2823
   278
        ].
cg@2939
   279
        aView windowGroup notNil ifTrue:[
cg@2939
   280
            s nextPutLine:'    g to inspect windowGroup'.
cg@2939
   281
        ].
cg@2823
   282
        modelToInspect notNil ifTrue:[
cg@2823
   283
            s nextPutLine:'    o to inspect model (O to browse)'.
cg@2823
   284
        ].
cg@2823
   285
        s cr.
cg@2823
   286
        s nextPutLine:'RETURN to browse application.'.
cg@2823
   287
        s nextPutAll:'ESC or click to leave flyBy-info mode.'.
cg@2300
   288
    ]
cg@2300
   289
cg@2300
   290
    "
cg@2300
   291
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
   292
    "
cg@2823
   293
cg@2824
   294
    "Modified: / 12-11-2010 / 11:54:59 / cg"
cg@2300
   295
! !
cg@2300
   296
cg@2710
   297
!FlyByWindowInformation methodsFor:'private'!
cg@2710
   298
cg@3058
   299
activeHelpViewForApplication:applicationOrNil text:helpText onDevice:aDevice
cg@3058
   300
    ^ (ActiveHelpView for:helpText onDevice:aDevice) shapeStyle:nil.
cg@3058
   301
!
cg@3058
   302
cg@2847
   303
handleMouseIn:aView x:x y:y
cg@2847
   304
    finished == true ifTrue:[^ self].
cg@2847
   305
    super handleMouseIn:aView x:x y:y
cg@2847
   306
!
cg@2847
   307
cg@2710
   308
targetViewInitiatesHelpViaSensor
cg@2710
   309
    ^ false
cg@2710
   310
! !
cg@2710
   311
cg@2300
   312
!FlyByWindowInformation methodsFor:'queries'!
cg@2300
   313
cg@2300
   314
toolTipFollowsMouse
cg@2300
   315
    ^ true
cg@2300
   316
! !
cg@2300
   317
cg@2300
   318
!FlyByWindowInformation methodsFor:'start & stop'!
cg@2300
   319
cg@2699
   320
initiateHelpFor:aView at:aPointOrNil
cg@2710
   321
    self initiateHelpFor:aView at:aPointOrNil now:true
cg@2699
   322
!
cg@2699
   323
cg@2699
   324
initiateHelpFor:aView at:aPointOrNil now:showItNow
cg@2702
   325
    finished == true ifTrue:[^ self].
cg@2699
   326
    super initiateHelpFor:aView at:aPointOrNil now:showItNow
cg@2699
   327
!
cg@2699
   328
cg@2300
   329
start
cg@2300
   330
    |l|
cg@2300
   331
cg@2702
   332
    finished == true ifTrue:[^ self].
cg@2702
   333
cg@2300
   334
    l := FlyByHelp currentHelpListener.
cg@2300
   335
    l notNil ifTrue:[
cg@2300
   336
        FlyByHelp stop.
cg@2300
   337
        cleanupAction := [ FlyByHelp start ].
cg@2300
   338
    ].
cg@2300
   339
    finishSemaphore := Semaphore new.
cg@2699
   340
    finished := false.
cg@2300
   341
    super start.
cg@2300
   342
!
cg@2300
   343
cg@2300
   344
stop
cg@2699
   345
    finished := true.
cg@2300
   346
    super stop.
cg@2300
   347
    cleanupAction value.
cg@2300
   348
    finishSemaphore notNil ifTrue:[
cg@2300
   349
        finishSemaphore signalIf.
cg@2300
   350
    ].
cg@2300
   351
!
cg@2300
   352
cg@2300
   353
waitUntilFinished
cg@2300
   354
    finishSemaphore wait.
cg@2300
   355
! !
cg@2300
   356
cg@2300
   357
!FlyByWindowInformation class methodsFor:'documentation'!
cg@2300
   358
cg@2587
   359
version_CVS
cg@2587
   360
    ^ '$Header$'
cg@2300
   361
! !
cg@2943
   362