FlyByWindowInformation.st
author Stefan Vogel <sv@exept.de>
Mon, 28 Feb 2011 19:08:00 +0100
changeset 2836 a2e82ebd3bc3
parent 2824 34ec9ea82209
child 2847 65280fe44707
permissions -rw-r--r--
changed: #keyPress:x:y:view: check if WindowTreeView class is present
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@2699
    85
handleMouseIn:aView x:x y:y
cg@2702
    86
    finished == true ifTrue:[^ self].
cg@2699
    87
    super handleMouseIn:aView x:x y:y
cg@2699
    88
!
cg@2699
    89
cg@2300
    90
keyPress:key x:x y:y view:aView
cg@2823
    91
    |obj objToInspect objToBrowse lcKey|
cg@2300
    92
cg@2300
    93
    key == #Escape ifTrue:[
cg@2300
    94
        self stop.
cg@2300
    95
        ^ true
cg@2300
    96
    ].
cg@2300
    97
cg@2435
    98
    key == $? ifTrue:[
cg@2435
    99
        [
sv@2836
   100
            WindowTreeView notNil ifTrue:[
sv@2836
   101
                WindowTreeView openOn:(lastView topView) initialSelection:lastView.
sv@2836
   102
            ] ifFalse:[
sv@2836
   103
                self warn:'WindowTreeView class is not present!!'.
sv@2836
   104
            ].
cg@2435
   105
        ] fork.
cg@2435
   106
        self stop.
cg@2435
   107
        ^ true.
cg@2300
   108
    ].
cg@2435
   109
cg@2823
   110
    key == #Return ifTrue:[
cg@2823
   111
        objToBrowse := lastApplication ? lastView
cg@2823
   112
    ].
cg@2823
   113
cg@2435
   114
    key isCharacter ifTrue:[
cg@2435
   115
        lcKey := key asLowercase.
cg@2435
   116
cg@2435
   117
        lcKey == $a ifTrue:[
cg@2435
   118
            obj := lastApplication
cg@2300
   119
        ].
cg@2435
   120
        lcKey == $o ifTrue:[
cg@2824
   121
            lastView notNil ifTrue:[
cg@2824
   122
                obj := lastView model
cg@2824
   123
            ].
cg@2435
   124
        ].
cg@2435
   125
        lcKey == $m ifTrue:[
cg@2824
   126
            lastApplication notNil ifTrue:[
cg@2824
   127
                obj := lastApplication masterApplication
cg@2824
   128
            ]
cg@2824
   129
        ].
cg@2824
   130
        lcKey == $t ifTrue:[
cg@2824
   131
            lastApplication notNil ifTrue:[
cg@2824
   132
                obj := lastApplication topApplication
cg@2824
   133
            ].
cg@2435
   134
        ].
cg@2435
   135
        lcKey == $v ifTrue:[
cg@2435
   136
            obj := lastView
cg@2435
   137
        ].
cg@2824
   138
        lcKey == $w ifTrue:[
cg@2824
   139
            lastView notNil ifTrue:[
cg@2824
   140
                obj := lastView topView
cg@2824
   141
            ]
cg@2435
   142
        ].
cg@2435
   143
        obj notNil ifTrue:[
cg@2435
   144
            key isLowercase ifTrue:[
cg@2823
   145
                objToInspect := obj
cg@2435
   146
            ] ifFalse:[
cg@2823
   147
                objToBrowse := obj
cg@2435
   148
            ].
cg@2435
   149
        ].
cg@2300
   150
    ].
cg@2300
   151
cg@2823
   152
    objToInspect notNil ifTrue:[
cg@2823
   153
        [ objToInspect inspect ] forkAt:(Processor userSchedulingPriority).
cg@2823
   154
    ].
cg@2823
   155
    objToBrowse notNil ifTrue:[
cg@2823
   156
        [ objToBrowse browse ] forkAt:(Processor userSchedulingPriority).
cg@2823
   157
    ].
cg@2823
   158
cg@2300
   159
    ^ true
cg@2823
   160
cg@2824
   161
    "Modified: / 12-11-2010 / 11:51:04 / cg"
cg@2300
   162
! !
cg@2300
   163
cg@2300
   164
!FlyByWindowInformation methodsFor:'help texts'!
cg@2300
   165
cg@2300
   166
helpTextFor:aView at:aPointOrNil
cg@2699
   167
    "generate the text to be shown as popup-flyby info"
cg@2699
   168
cg@2824
   169
    |resources|
cg@2824
   170
cg@2300
   171
    lastView := aView.
cg@2300
   172
    lastApplication := aView application.
cg@2300
   173
cg@2824
   174
    resources := self class classResources.
cg@2824
   175
cg@2824
   176
    ^ Text streamContents:[:s |
cg@2824
   177
        |topViewToInspect applicationToInspect 
cg@2824
   178
         masterApplicationToInspect topApplicationToInspect modelToInspect
cg@2700
   179
         genComponentNameForApplication|
cg@2700
   180
cg@2824
   181
        genComponentNameForApplication := 
cg@2824
   182
            [:app :s |
cg@2700
   183
                (app notNil 
cg@2700
   184
                and:[ app builder notNil ]) ifTrue:[
cg@2700
   185
                    |components v|
cg@2700
   186
cg@2700
   187
                    components := app builder namedComponents.
cg@2700
   188
cg@2700
   189
                    v := aView.
cg@2700
   190
                    [   (components includes:v) not
cg@2700
   191
                        and:[v container notNil]
cg@2700
   192
                    ] whileTrue:[
cg@2700
   193
                        v := v container.
cg@2700
   194
                    ].
cg@2700
   195
                    (components includes:v) ifTrue:[
cg@2700
   196
                        |k|
cg@2700
   197
cg@2700
   198
                        k := components keyAtValue:v.
cg@2700
   199
                        v == aView ifTrue:[
cg@2824
   200
                            s nextPutLine:('       component: ' , k).
cg@2700
   201
                        ] ifFalse:[
cg@2824
   202
                            s nextPutLine:('       subview of component: ' , k).
cg@2700
   203
                        ].
cg@2700
   204
                    ].
cg@2700
   205
                ].
cg@2700
   206
            ].
cg@2314
   207
cg@2300
   208
        aView topView ~~ aView ifTrue:[
cg@2314
   209
            topViewToInspect := aView topView.
cg@2300
   210
        ].
cg@2300
   211
        lastApplication notNil ifTrue:[
cg@2314
   212
            applicationToInspect := lastApplication.
cg@2314
   213
            masterApplicationToInspect := lastApplication masterApplication.
cg@2824
   214
            masterApplicationToInspect notNil ifTrue:[
cg@2824
   215
                masterApplicationToInspect == applicationToInspect ifTrue:[
cg@2824
   216
                    masterApplicationToInspect := nil
cg@2824
   217
                ] ifFalse:[
cg@2824
   218
                    topApplicationToInspect := masterApplicationToInspect topApplication.
cg@2824
   219
                    topApplicationToInspect == masterApplicationToInspect ifTrue:[
cg@2824
   220
                        topApplicationToInspect := nil
cg@2824
   221
                    ]
cg@2824
   222
                ].
cg@2824
   223
            ]
cg@2314
   224
        ].
cg@2314
   225
        aView model notNil ifTrue:[
cg@2314
   226
            modelToInspect := aView model.
cg@2314
   227
            ((modelToInspect == applicationToInspect)
cg@2314
   228
            or:[ modelToInspect == masterApplicationToInspect ]) ifTrue:[
cg@2314
   229
                modelToInspect := nil.
cg@2300
   230
            ].
cg@2300
   231
        ].
cg@2314
   232
cg@2824
   233
        applicationToInspect notNil ifTrue:[
cg@2824
   234
            s nextPutLine:(resources string:'Application: %1' with:applicationToInspect class name allBold).
cg@2824
   235
            genComponentNameForApplication value:applicationToInspect value:s.
cg@2314
   236
        ].
cg@2700
   237
        masterApplicationToInspect notNil ifTrue:[
cg@2824
   238
            s nextPutLine:(resources string:'Master-Application: %1' with:masterApplicationToInspect class name allBold).
cg@2824
   239
            "/ genComponentNameForApplication value:masterApplicationToInspect value:s.
cg@2700
   240
        ].
cg@2824
   241
        topApplicationToInspect notNil ifTrue:[
cg@2824
   242
            s nextPutLine:(resources string:'Top-Application: %1' with:topApplicationToInspect class name allBold).
cg@2824
   243
            "/ genComponentNameForApplication value:topApplicationToInspect value:s.
cg@2314
   244
        ].
cg@2824
   245
        s nextPutLine:(resources string:'View: %1 "%2"' with:aView class name allBold with:aView name).
cg@2824
   246
        topViewToInspect notNil ifTrue:[
cg@2824
   247
            s nextPutLine:(resources string:'Topview: %1' with:topViewToInspect class name allBold).
cg@2824
   248
        ].
cg@2824
   249
        modelToInspect notNil ifTrue:[
cg@2824
   250
            s nextPutLine:(resources string:'Model: %1' with:modelToInspect class name allBold).
cg@2824
   251
        ].
cg@2699
   252
cg@2300
   253
        s cr.
cg@2300
   254
        s nextPutLine:'Press:'.
cg@2435
   255
        s nextPutLine:'    ? to show the viewtree'.
cg@2314
   256
        applicationToInspect notNil ifTrue:[
cg@2300
   257
            s nextPutLine:'    a to inspect application (A to browse)'.
cg@2314
   258
            masterApplicationToInspect notNil ifTrue:[
cg@2300
   259
                s nextPutLine:'    m to inspect masterApplication (M to browse)'.
cg@2824
   260
                topApplicationToInspect notNil ifTrue:[
cg@2824
   261
                    s nextPutLine:'    t to inspect masterApplication (T to browse)'.
cg@2824
   262
                ]
cg@2300
   263
            ].
cg@2300
   264
        ].
cg@2823
   265
        s nextPutLine:'    v to inspect view (V to browse)'.
cg@2823
   266
        topViewToInspect notNil ifTrue:[
cg@2824
   267
            s nextPutLine:'    w to inspect topWindow (W to browse)'.
cg@2823
   268
        ].
cg@2823
   269
        modelToInspect notNil ifTrue:[
cg@2823
   270
            s nextPutLine:'    o to inspect model (O to browse)'.
cg@2823
   271
        ].
cg@2823
   272
        s cr.
cg@2823
   273
        s nextPutLine:'RETURN to browse application.'.
cg@2823
   274
        s nextPutAll:'ESC or click to leave flyBy-info mode.'.
cg@2300
   275
    ]
cg@2300
   276
cg@2300
   277
    "
cg@2300
   278
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
   279
    "
cg@2823
   280
cg@2824
   281
    "Modified: / 12-11-2010 / 11:54:59 / cg"
cg@2300
   282
! !
cg@2300
   283
cg@2710
   284
!FlyByWindowInformation methodsFor:'private'!
cg@2710
   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@2300
   337
version
cg@2300
   338
    ^ '$Header$'
cg@2587
   339
!
cg@2587
   340
cg@2587
   341
version_CVS
cg@2587
   342
    ^ '$Header$'
cg@2300
   343
! !