FlyByWindowInformation.st
author Claus Gittinger <cg@exept.de>
Sun, 04 Nov 2012 15:09:40 +0100
changeset 2939 5e2872ba0b95
parent 2847 65280fe44707
child 2943 e7d181ac8f06
permissions -rw-r--r--
changed:
#helpTextFor:at:
#keyPress:x:y:view:
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@2939
   133
        lcKey == $g ifTrue:[
cg@2939
   134
            obj := lastView windowGroup
cg@2939
   135
        ].
cg@2824
   136
        lcKey == $w ifTrue:[
cg@2824
   137
            lastView notNil ifTrue:[
cg@2824
   138
                obj := lastView topView
cg@2824
   139
            ]
cg@2435
   140
        ].
cg@2435
   141
        obj notNil ifTrue:[
cg@2435
   142
            key isLowercase ifTrue:[
cg@2823
   143
                objToInspect := obj
cg@2435
   144
            ] ifFalse:[
cg@2823
   145
                objToBrowse := obj
cg@2435
   146
            ].
cg@2435
   147
        ].
cg@2300
   148
    ].
cg@2300
   149
cg@2823
   150
    objToInspect notNil ifTrue:[
cg@2823
   151
        [ objToInspect inspect ] forkAt:(Processor userSchedulingPriority).
cg@2823
   152
    ].
cg@2823
   153
    objToBrowse notNil ifTrue:[
cg@2823
   154
        [ objToBrowse browse ] forkAt:(Processor userSchedulingPriority).
cg@2823
   155
    ].
cg@2823
   156
cg@2300
   157
    ^ true
cg@2823
   158
cg@2824
   159
    "Modified: / 12-11-2010 / 11:51:04 / cg"
cg@2300
   160
! !
cg@2300
   161
cg@2300
   162
!FlyByWindowInformation methodsFor:'help texts'!
cg@2300
   163
cg@2300
   164
helpTextFor:aView at:aPointOrNil
cg@2699
   165
    "generate the text to be shown as popup-flyby info"
cg@2699
   166
cg@2824
   167
    |resources|
cg@2824
   168
cg@2300
   169
    lastView := aView.
cg@2300
   170
    lastApplication := aView application.
cg@2300
   171
cg@2824
   172
    resources := self class classResources.
cg@2824
   173
cg@2824
   174
    ^ Text streamContents:[:s |
cg@2824
   175
        |topViewToInspect applicationToInspect 
cg@2824
   176
         masterApplicationToInspect topApplicationToInspect modelToInspect
cg@2939
   177
         genComponentNameForApplication windowGroupToInspect|
cg@2700
   178
cg@2824
   179
        genComponentNameForApplication := 
cg@2824
   180
            [:app :s |
cg@2700
   181
                (app notNil 
cg@2700
   182
                and:[ app builder notNil ]) ifTrue:[
cg@2700
   183
                    |components v|
cg@2700
   184
cg@2700
   185
                    components := app builder namedComponents.
cg@2700
   186
cg@2700
   187
                    v := aView.
cg@2700
   188
                    [   (components includes:v) not
cg@2700
   189
                        and:[v container notNil]
cg@2700
   190
                    ] whileTrue:[
cg@2700
   191
                        v := v container.
cg@2700
   192
                    ].
cg@2700
   193
                    (components includes:v) ifTrue:[
cg@2700
   194
                        |k|
cg@2700
   195
cg@2700
   196
                        k := components keyAtValue:v.
cg@2700
   197
                        v == aView ifTrue:[
cg@2824
   198
                            s nextPutLine:('       component: ' , k).
cg@2700
   199
                        ] ifFalse:[
cg@2824
   200
                            s nextPutLine:('       subview of component: ' , k).
cg@2700
   201
                        ].
cg@2700
   202
                    ].
cg@2700
   203
                ].
cg@2700
   204
            ].
cg@2314
   205
cg@2300
   206
        aView topView ~~ aView ifTrue:[
cg@2314
   207
            topViewToInspect := aView topView.
cg@2300
   208
        ].
cg@2300
   209
        lastApplication notNil ifTrue:[
cg@2314
   210
            applicationToInspect := lastApplication.
cg@2314
   211
            masterApplicationToInspect := lastApplication masterApplication.
cg@2824
   212
            masterApplicationToInspect notNil ifTrue:[
cg@2824
   213
                masterApplicationToInspect == applicationToInspect ifTrue:[
cg@2824
   214
                    masterApplicationToInspect := nil
cg@2824
   215
                ] ifFalse:[
cg@2824
   216
                    topApplicationToInspect := masterApplicationToInspect topApplication.
cg@2824
   217
                    topApplicationToInspect == masterApplicationToInspect ifTrue:[
cg@2824
   218
                        topApplicationToInspect := nil
cg@2824
   219
                    ]
cg@2824
   220
                ].
cg@2824
   221
            ]
cg@2314
   222
        ].
cg@2314
   223
        aView model notNil ifTrue:[
cg@2314
   224
            modelToInspect := aView model.
cg@2314
   225
            ((modelToInspect == applicationToInspect)
cg@2314
   226
            or:[ modelToInspect == masterApplicationToInspect ]) ifTrue:[
cg@2314
   227
                modelToInspect := nil.
cg@2300
   228
            ].
cg@2300
   229
        ].
cg@2314
   230
cg@2824
   231
        applicationToInspect notNil ifTrue:[
cg@2824
   232
            s nextPutLine:(resources string:'Application: %1' with:applicationToInspect class name allBold).
cg@2824
   233
            genComponentNameForApplication value:applicationToInspect value:s.
cg@2314
   234
        ].
cg@2700
   235
        masterApplicationToInspect notNil ifTrue:[
cg@2824
   236
            s nextPutLine:(resources string:'Master-Application: %1' with:masterApplicationToInspect class name allBold).
cg@2824
   237
            "/ genComponentNameForApplication value:masterApplicationToInspect value:s.
cg@2700
   238
        ].
cg@2824
   239
        topApplicationToInspect notNil ifTrue:[
cg@2824
   240
            s nextPutLine:(resources string:'Top-Application: %1' with:topApplicationToInspect class name allBold).
cg@2824
   241
            "/ genComponentNameForApplication value:topApplicationToInspect value:s.
cg@2314
   242
        ].
cg@2824
   243
        s nextPutLine:(resources string:'View: %1 "%2"' with:aView class name allBold with:aView name).
cg@2824
   244
        topViewToInspect notNil ifTrue:[
cg@2824
   245
            s nextPutLine:(resources string:'Topview: %1' with:topViewToInspect class name allBold).
cg@2824
   246
        ].
cg@2824
   247
        modelToInspect notNil ifTrue:[
cg@2824
   248
            s nextPutLine:(resources string:'Model: %1' with:modelToInspect class name allBold).
cg@2824
   249
        ].
cg@2699
   250
cg@2300
   251
        s cr.
cg@2300
   252
        s nextPutLine:'Press:'.
cg@2435
   253
        s nextPutLine:'    ? to show the viewtree'.
cg@2314
   254
        applicationToInspect notNil ifTrue:[
cg@2300
   255
            s nextPutLine:'    a to inspect application (A to browse)'.
cg@2314
   256
            masterApplicationToInspect notNil ifTrue:[
cg@2300
   257
                s nextPutLine:'    m to inspect masterApplication (M to browse)'.
cg@2824
   258
                topApplicationToInspect notNil ifTrue:[
cg@2824
   259
                    s nextPutLine:'    t to inspect masterApplication (T to browse)'.
cg@2824
   260
                ]
cg@2300
   261
            ].
cg@2300
   262
        ].
cg@2823
   263
        s nextPutLine:'    v to inspect view (V to browse)'.
cg@2823
   264
        topViewToInspect notNil ifTrue:[
cg@2824
   265
            s nextPutLine:'    w to inspect topWindow (W to browse)'.
cg@2823
   266
        ].
cg@2939
   267
        aView windowGroup notNil ifTrue:[
cg@2939
   268
            s nextPutLine:'    g to inspect windowGroup'.
cg@2939
   269
        ].
cg@2823
   270
        modelToInspect notNil ifTrue:[
cg@2823
   271
            s nextPutLine:'    o to inspect model (O to browse)'.
cg@2823
   272
        ].
cg@2823
   273
        s cr.
cg@2823
   274
        s nextPutLine:'RETURN to browse application.'.
cg@2823
   275
        s nextPutAll:'ESC or click to leave flyBy-info mode.'.
cg@2300
   276
    ]
cg@2300
   277
cg@2300
   278
    "
cg@2300
   279
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
   280
    "
cg@2823
   281
cg@2824
   282
    "Modified: / 12-11-2010 / 11:54:59 / cg"
cg@2300
   283
! !
cg@2300
   284
cg@2710
   285
!FlyByWindowInformation methodsFor:'private'!
cg@2710
   286
cg@2847
   287
handleMouseIn:aView x:x y:y
cg@2847
   288
    finished == true ifTrue:[^ self].
cg@2847
   289
    super handleMouseIn:aView x:x y:y
cg@2847
   290
!
cg@2847
   291
cg@2710
   292
targetViewInitiatesHelpViaSensor
cg@2710
   293
    ^ false
cg@2710
   294
! !
cg@2710
   295
cg@2300
   296
!FlyByWindowInformation methodsFor:'queries'!
cg@2300
   297
cg@2300
   298
toolTipFollowsMouse
cg@2300
   299
    ^ true
cg@2300
   300
! !
cg@2300
   301
cg@2300
   302
!FlyByWindowInformation methodsFor:'start & stop'!
cg@2300
   303
cg@2699
   304
initiateHelpFor:aView at:aPointOrNil
cg@2710
   305
    self initiateHelpFor:aView at:aPointOrNil now:true
cg@2699
   306
!
cg@2699
   307
cg@2699
   308
initiateHelpFor:aView at:aPointOrNil now:showItNow
cg@2702
   309
    finished == true ifTrue:[^ self].
cg@2699
   310
    super initiateHelpFor:aView at:aPointOrNil now:showItNow
cg@2699
   311
!
cg@2699
   312
cg@2300
   313
start
cg@2300
   314
    |l|
cg@2300
   315
cg@2702
   316
    finished == true ifTrue:[^ self].
cg@2702
   317
cg@2300
   318
    l := FlyByHelp currentHelpListener.
cg@2300
   319
    l notNil ifTrue:[
cg@2300
   320
        FlyByHelp stop.
cg@2300
   321
        cleanupAction := [ FlyByHelp start ].
cg@2300
   322
    ].
cg@2300
   323
    finishSemaphore := Semaphore new.
cg@2699
   324
    finished := false.
cg@2300
   325
    super start.
cg@2300
   326
!
cg@2300
   327
cg@2300
   328
stop
cg@2699
   329
    finished := true.
cg@2300
   330
    super stop.
cg@2300
   331
    cleanupAction value.
cg@2300
   332
    finishSemaphore notNil ifTrue:[
cg@2300
   333
        finishSemaphore signalIf.
cg@2300
   334
    ].
cg@2300
   335
!
cg@2300
   336
cg@2300
   337
waitUntilFinished
cg@2300
   338
    finishSemaphore wait.
cg@2300
   339
! !
cg@2300
   340
cg@2300
   341
!FlyByWindowInformation class methodsFor:'documentation'!
cg@2300
   342
cg@2587
   343
version_CVS
cg@2587
   344
    ^ '$Header$'
cg@2300
   345
! !