FlyByWindowInformation.st
author Claus Gittinger <cg@exept.de>
Wed, 29 Jun 2011 19:14:46 +0200
changeset 2847 65280fe44707
parent 2836 a2e82ebd3bc3
child 2939 5e2872ba0b95
permissions -rw-r--r--
category of: #handleMouseIn:x:y:
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@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@2699
    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@2702
    74
    finished == true ifTrue:[^ self].
cg@2702
    75
cg@2340
    76
    super buttonMotion:buttonAndModifierState x:x y:y view:aView.
cg@2300
    77
    ^ true
cg@2300
    78
!
cg@2300
    79
cg@2300
    80
buttonPress:button x:x y:y view:aView
cg@2300
    81
    self stop.
cg@2300
    82
    ^ true
cg@2300
    83
!
cg@2300
    84
cg@2300
    85
keyPress:key x:x y:y view:aView
cg@2823
    86
    |obj objToInspect objToBrowse lcKey|
cg@2300
    87
cg@2300
    88
    key == #Escape ifTrue:[
cg@2300
    89
        self stop.
cg@2300
    90
        ^ true
cg@2300
    91
    ].
cg@2300
    92
cg@2435
    93
    key == $? ifTrue:[
cg@2435
    94
        [
sv@2836
    95
            WindowTreeView notNil ifTrue:[
sv@2836
    96
                WindowTreeView openOn:(lastView topView) initialSelection:lastView.
sv@2836
    97
            ] ifFalse:[
sv@2836
    98
                self warn:'WindowTreeView class is not present!!'.
sv@2836
    99
            ].
cg@2435
   100
        ] fork.
cg@2435
   101
        self stop.
cg@2435
   102
        ^ true.
cg@2300
   103
    ].
cg@2435
   104
cg@2823
   105
    key == #Return ifTrue:[
cg@2823
   106
        objToBrowse := lastApplication ? lastView
cg@2823
   107
    ].
cg@2823
   108
cg@2435
   109
    key isCharacter ifTrue:[
cg@2435
   110
        lcKey := key asLowercase.
cg@2435
   111
cg@2435
   112
        lcKey == $a ifTrue:[
cg@2435
   113
            obj := lastApplication
cg@2300
   114
        ].
cg@2435
   115
        lcKey == $o ifTrue:[
cg@2824
   116
            lastView notNil ifTrue:[
cg@2824
   117
                obj := lastView model
cg@2824
   118
            ].
cg@2435
   119
        ].
cg@2435
   120
        lcKey == $m ifTrue:[
cg@2824
   121
            lastApplication notNil ifTrue:[
cg@2824
   122
                obj := lastApplication masterApplication
cg@2824
   123
            ]
cg@2824
   124
        ].
cg@2824
   125
        lcKey == $t ifTrue:[
cg@2824
   126
            lastApplication notNil ifTrue:[
cg@2824
   127
                obj := lastApplication topApplication
cg@2824
   128
            ].
cg@2435
   129
        ].
cg@2435
   130
        lcKey == $v ifTrue:[
cg@2435
   131
            obj := lastView
cg@2435
   132
        ].
cg@2824
   133
        lcKey == $w ifTrue:[
cg@2824
   134
            lastView notNil ifTrue:[
cg@2824
   135
                obj := lastView topView
cg@2824
   136
            ]
cg@2435
   137
        ].
cg@2435
   138
        obj notNil ifTrue:[
cg@2435
   139
            key isLowercase ifTrue:[
cg@2823
   140
                objToInspect := obj
cg@2435
   141
            ] ifFalse:[
cg@2823
   142
                objToBrowse := obj
cg@2435
   143
            ].
cg@2435
   144
        ].
cg@2300
   145
    ].
cg@2300
   146
cg@2823
   147
    objToInspect notNil ifTrue:[
cg@2823
   148
        [ objToInspect inspect ] forkAt:(Processor userSchedulingPriority).
cg@2823
   149
    ].
cg@2823
   150
    objToBrowse notNil ifTrue:[
cg@2823
   151
        [ objToBrowse browse ] forkAt:(Processor userSchedulingPriority).
cg@2823
   152
    ].
cg@2823
   153
cg@2300
   154
    ^ true
cg@2823
   155
cg@2824
   156
    "Modified: / 12-11-2010 / 11:51:04 / cg"
cg@2300
   157
! !
cg@2300
   158
cg@2300
   159
!FlyByWindowInformation methodsFor:'help texts'!
cg@2300
   160
cg@2300
   161
helpTextFor:aView at:aPointOrNil
cg@2699
   162
    "generate the text to be shown as popup-flyby info"
cg@2699
   163
cg@2824
   164
    |resources|
cg@2824
   165
cg@2300
   166
    lastView := aView.
cg@2300
   167
    lastApplication := aView application.
cg@2300
   168
cg@2824
   169
    resources := self class classResources.
cg@2824
   170
cg@2824
   171
    ^ Text streamContents:[:s |
cg@2824
   172
        |topViewToInspect applicationToInspect 
cg@2824
   173
         masterApplicationToInspect topApplicationToInspect modelToInspect
cg@2700
   174
         genComponentNameForApplication|
cg@2700
   175
cg@2824
   176
        genComponentNameForApplication := 
cg@2824
   177
            [:app :s |
cg@2700
   178
                (app notNil 
cg@2700
   179
                and:[ app builder notNil ]) ifTrue:[
cg@2700
   180
                    |components v|
cg@2700
   181
cg@2700
   182
                    components := app builder namedComponents.
cg@2700
   183
cg@2700
   184
                    v := aView.
cg@2700
   185
                    [   (components includes:v) not
cg@2700
   186
                        and:[v container notNil]
cg@2700
   187
                    ] whileTrue:[
cg@2700
   188
                        v := v container.
cg@2700
   189
                    ].
cg@2700
   190
                    (components includes:v) ifTrue:[
cg@2700
   191
                        |k|
cg@2700
   192
cg@2700
   193
                        k := components keyAtValue:v.
cg@2700
   194
                        v == aView ifTrue:[
cg@2824
   195
                            s nextPutLine:('       component: ' , k).
cg@2700
   196
                        ] ifFalse:[
cg@2824
   197
                            s nextPutLine:('       subview of component: ' , k).
cg@2700
   198
                        ].
cg@2700
   199
                    ].
cg@2700
   200
                ].
cg@2700
   201
            ].
cg@2314
   202
cg@2300
   203
        aView topView ~~ aView ifTrue:[
cg@2314
   204
            topViewToInspect := aView topView.
cg@2300
   205
        ].
cg@2300
   206
        lastApplication notNil ifTrue:[
cg@2314
   207
            applicationToInspect := lastApplication.
cg@2314
   208
            masterApplicationToInspect := lastApplication masterApplication.
cg@2824
   209
            masterApplicationToInspect notNil ifTrue:[
cg@2824
   210
                masterApplicationToInspect == applicationToInspect ifTrue:[
cg@2824
   211
                    masterApplicationToInspect := nil
cg@2824
   212
                ] ifFalse:[
cg@2824
   213
                    topApplicationToInspect := masterApplicationToInspect topApplication.
cg@2824
   214
                    topApplicationToInspect == masterApplicationToInspect ifTrue:[
cg@2824
   215
                        topApplicationToInspect := nil
cg@2824
   216
                    ]
cg@2824
   217
                ].
cg@2824
   218
            ]
cg@2314
   219
        ].
cg@2314
   220
        aView model notNil ifTrue:[
cg@2314
   221
            modelToInspect := aView model.
cg@2314
   222
            ((modelToInspect == applicationToInspect)
cg@2314
   223
            or:[ modelToInspect == masterApplicationToInspect ]) ifTrue:[
cg@2314
   224
                modelToInspect := nil.
cg@2300
   225
            ].
cg@2300
   226
        ].
cg@2314
   227
cg@2824
   228
        applicationToInspect notNil ifTrue:[
cg@2824
   229
            s nextPutLine:(resources string:'Application: %1' with:applicationToInspect class name allBold).
cg@2824
   230
            genComponentNameForApplication value:applicationToInspect value:s.
cg@2314
   231
        ].
cg@2700
   232
        masterApplicationToInspect notNil ifTrue:[
cg@2824
   233
            s nextPutLine:(resources string:'Master-Application: %1' with:masterApplicationToInspect class name allBold).
cg@2824
   234
            "/ genComponentNameForApplication value:masterApplicationToInspect value:s.
cg@2700
   235
        ].
cg@2824
   236
        topApplicationToInspect notNil ifTrue:[
cg@2824
   237
            s nextPutLine:(resources string:'Top-Application: %1' with:topApplicationToInspect class name allBold).
cg@2824
   238
            "/ genComponentNameForApplication value:topApplicationToInspect value:s.
cg@2314
   239
        ].
cg@2824
   240
        s nextPutLine:(resources string:'View: %1 "%2"' with:aView class name allBold with:aView name).
cg@2824
   241
        topViewToInspect notNil ifTrue:[
cg@2824
   242
            s nextPutLine:(resources string:'Topview: %1' with:topViewToInspect class name allBold).
cg@2824
   243
        ].
cg@2824
   244
        modelToInspect notNil ifTrue:[
cg@2824
   245
            s nextPutLine:(resources string:'Model: %1' with:modelToInspect class name allBold).
cg@2824
   246
        ].
cg@2699
   247
cg@2300
   248
        s cr.
cg@2300
   249
        s nextPutLine:'Press:'.
cg@2435
   250
        s nextPutLine:'    ? to show the viewtree'.
cg@2314
   251
        applicationToInspect notNil ifTrue:[
cg@2300
   252
            s nextPutLine:'    a to inspect application (A to browse)'.
cg@2314
   253
            masterApplicationToInspect notNil ifTrue:[
cg@2300
   254
                s nextPutLine:'    m to inspect masterApplication (M to browse)'.
cg@2824
   255
                topApplicationToInspect notNil ifTrue:[
cg@2824
   256
                    s nextPutLine:'    t to inspect masterApplication (T to browse)'.
cg@2824
   257
                ]
cg@2300
   258
            ].
cg@2300
   259
        ].
cg@2823
   260
        s nextPutLine:'    v to inspect view (V to browse)'.
cg@2823
   261
        topViewToInspect notNil ifTrue:[
cg@2824
   262
            s nextPutLine:'    w to inspect topWindow (W to browse)'.
cg@2823
   263
        ].
cg@2823
   264
        modelToInspect notNil ifTrue:[
cg@2823
   265
            s nextPutLine:'    o to inspect model (O to browse)'.
cg@2823
   266
        ].
cg@2823
   267
        s cr.
cg@2823
   268
        s nextPutLine:'RETURN to browse application.'.
cg@2823
   269
        s nextPutAll:'ESC or click to leave flyBy-info mode.'.
cg@2300
   270
    ]
cg@2300
   271
cg@2300
   272
    "
cg@2300
   273
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
   274
    "
cg@2823
   275
cg@2824
   276
    "Modified: / 12-11-2010 / 11:54:59 / cg"
cg@2300
   277
! !
cg@2300
   278
cg@2710
   279
!FlyByWindowInformation methodsFor:'private'!
cg@2710
   280
cg@2847
   281
handleMouseIn:aView x:x y:y
cg@2847
   282
    finished == true ifTrue:[^ self].
cg@2847
   283
    super handleMouseIn:aView x:x y:y
cg@2847
   284
!
cg@2847
   285
cg@2710
   286
targetViewInitiatesHelpViaSensor
cg@2710
   287
    ^ false
cg@2710
   288
! !
cg@2710
   289
cg@2300
   290
!FlyByWindowInformation methodsFor:'queries'!
cg@2300
   291
cg@2300
   292
toolTipFollowsMouse
cg@2300
   293
    ^ true
cg@2300
   294
! !
cg@2300
   295
cg@2300
   296
!FlyByWindowInformation methodsFor:'start & stop'!
cg@2300
   297
cg@2699
   298
initiateHelpFor:aView at:aPointOrNil
cg@2710
   299
    self initiateHelpFor:aView at:aPointOrNil now:true
cg@2699
   300
!
cg@2699
   301
cg@2699
   302
initiateHelpFor:aView at:aPointOrNil now:showItNow
cg@2702
   303
    finished == true ifTrue:[^ self].
cg@2699
   304
    super initiateHelpFor:aView at:aPointOrNil now:showItNow
cg@2699
   305
!
cg@2699
   306
cg@2300
   307
start
cg@2300
   308
    |l|
cg@2300
   309
cg@2702
   310
    finished == true ifTrue:[^ self].
cg@2702
   311
cg@2300
   312
    l := FlyByHelp currentHelpListener.
cg@2300
   313
    l notNil ifTrue:[
cg@2300
   314
        FlyByHelp stop.
cg@2300
   315
        cleanupAction := [ FlyByHelp start ].
cg@2300
   316
    ].
cg@2300
   317
    finishSemaphore := Semaphore new.
cg@2699
   318
    finished := false.
cg@2300
   319
    super start.
cg@2300
   320
!
cg@2300
   321
cg@2300
   322
stop
cg@2699
   323
    finished := true.
cg@2300
   324
    super stop.
cg@2300
   325
    cleanupAction value.
cg@2300
   326
    finishSemaphore notNil ifTrue:[
cg@2300
   327
        finishSemaphore signalIf.
cg@2300
   328
    ].
cg@2300
   329
!
cg@2300
   330
cg@2300
   331
waitUntilFinished
cg@2300
   332
    finishSemaphore wait.
cg@2300
   333
! !
cg@2300
   334
cg@2300
   335
!FlyByWindowInformation class methodsFor:'documentation'!
cg@2300
   336
cg@2587
   337
version_CVS
cg@2587
   338
    ^ '$Header$'
cg@2300
   339
! !