FlyByWindowInformation.st
author Claus Gittinger <cg@exept.de>
Fri, 12 Nov 2010 11:39:53 +0100
changeset 2823 cd54d69eec13
parent 2710 0ce76feb3f91
child 2824 34ec9ea82209
permissions -rw-r--r--
changed:
#helpTextFor:at:
#keyPress:x:y:view:

return key and better flybyhelp
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
        [
cg@2435
   100
            WindowTreeView openOn:(lastView topView) initialSelection:lastView.
cg@2435
   101
        ] fork.
cg@2435
   102
        self stop.
cg@2435
   103
        ^ true.
cg@2300
   104
    ].
cg@2435
   105
cg@2823
   106
    key == #Return ifTrue:[
cg@2823
   107
        objToBrowse := lastApplication ? lastView
cg@2823
   108
    ].
cg@2823
   109
cg@2435
   110
    key isCharacter ifTrue:[
cg@2435
   111
        lcKey := key asLowercase.
cg@2435
   112
cg@2435
   113
        lcKey == $a ifTrue:[
cg@2435
   114
            obj := lastApplication
cg@2300
   115
        ].
cg@2435
   116
        lcKey == $o ifTrue:[
cg@2435
   117
            obj := lastView model
cg@2435
   118
        ].
cg@2435
   119
        lcKey == $m ifTrue:[
cg@2435
   120
            obj := lastApplication masterApplication
cg@2435
   121
        ].
cg@2435
   122
        lcKey == $v ifTrue:[
cg@2435
   123
            obj := lastView
cg@2435
   124
        ].
cg@2435
   125
        lcKey == $t ifTrue:[
cg@2435
   126
            obj := lastView topView
cg@2435
   127
        ].
cg@2435
   128
        obj notNil ifTrue:[
cg@2435
   129
            key isLowercase ifTrue:[
cg@2823
   130
                objToInspect := obj
cg@2435
   131
            ] ifFalse:[
cg@2823
   132
                objToBrowse := obj
cg@2435
   133
            ].
cg@2435
   134
        ].
cg@2300
   135
    ].
cg@2300
   136
cg@2823
   137
    objToInspect notNil ifTrue:[
cg@2823
   138
        [ objToInspect inspect ] forkAt:(Processor userSchedulingPriority).
cg@2823
   139
    ].
cg@2823
   140
    objToBrowse notNil ifTrue:[
cg@2823
   141
        [ objToBrowse browse ] forkAt:(Processor userSchedulingPriority).
cg@2823
   142
    ].
cg@2823
   143
cg@2300
   144
    ^ true
cg@2823
   145
cg@2823
   146
    "Modified: / 12-11-2010 / 11:38:23 / cg"
cg@2300
   147
! !
cg@2300
   148
cg@2300
   149
!FlyByWindowInformation methodsFor:'help texts'!
cg@2300
   150
cg@2300
   151
helpTextFor:aView at:aPointOrNil
cg@2699
   152
    "generate the text to be shown as popup-flyby info"
cg@2699
   153
cg@2300
   154
    lastView := aView.
cg@2300
   155
    lastApplication := aView application.
cg@2300
   156
cg@2300
   157
    ^ String streamContents:[:s |
cg@2700
   158
        |topViewToInspect applicationToInspect masterApplicationToInspect modelToInspect
cg@2700
   159
         genComponentNameForApplication|
cg@2700
   160
cg@2700
   161
        genComponentNameForApplication := [:app :s |
cg@2700
   162
                (app notNil 
cg@2700
   163
                and:[ app builder notNil ]) ifTrue:[
cg@2700
   164
                    |components v|
cg@2700
   165
cg@2700
   166
                    components := app builder namedComponents.
cg@2700
   167
cg@2700
   168
                    v := aView.
cg@2700
   169
                    [   (components includes:v) not
cg@2700
   170
                        and:[v container notNil]
cg@2700
   171
                    ] whileTrue:[
cg@2700
   172
                        v := v container.
cg@2700
   173
                    ].
cg@2700
   174
                    (components includes:v) ifTrue:[
cg@2700
   175
                        |k|
cg@2700
   176
cg@2700
   177
                        k := components keyAtValue:v.
cg@2700
   178
                        v == aView ifTrue:[
cg@2700
   179
                            s nextPutLine:('   Component: ' , k).
cg@2700
   180
                        ] ifFalse:[
cg@2700
   181
                            s nextPutLine:('   Subview of Component: ' , k).
cg@2700
   182
                        ].
cg@2700
   183
                    ].
cg@2700
   184
                ].
cg@2700
   185
            ].
cg@2314
   186
cg@2300
   187
        aView topView ~~ aView ifTrue:[
cg@2314
   188
            topViewToInspect := aView topView.
cg@2300
   189
        ].
cg@2300
   190
        lastApplication notNil ifTrue:[
cg@2314
   191
            applicationToInspect := lastApplication.
cg@2314
   192
            masterApplicationToInspect := lastApplication masterApplication.
cg@2700
   193
            masterApplicationToInspect == applicationToInspect ifTrue:[
cg@2700
   194
                masterApplicationToInspect := nil
cg@2700
   195
            ].
cg@2314
   196
        ].
cg@2314
   197
        aView model notNil ifTrue:[
cg@2314
   198
            modelToInspect := aView model.
cg@2314
   199
            ((modelToInspect == applicationToInspect)
cg@2314
   200
            or:[ modelToInspect == masterApplicationToInspect ]) ifTrue:[
cg@2314
   201
                modelToInspect := nil.
cg@2300
   202
            ].
cg@2300
   203
        ].
cg@2314
   204
cg@2352
   205
        s nextPutLine:('View: ' , aView class name, ' "',aView name printString,'"').
cg@2314
   206
        modelToInspect notNil ifTrue:[
cg@2314
   207
            s nextPutLine:('Model: ' , modelToInspect class name).
cg@2314
   208
        ].
cg@2314
   209
        topViewToInspect notNil ifTrue:[
cg@2314
   210
            s nextPutLine:('Topview: ' , topViewToInspect class name).
cg@2314
   211
        ].
cg@2700
   212
        masterApplicationToInspect notNil ifTrue:[
cg@2700
   213
            s nextPutLine:('Masterapplication: ' , masterApplicationToInspect class name).
cg@2700
   214
            genComponentNameForApplication value:masterApplicationToInspect value:s.
cg@2700
   215
        ].
cg@2314
   216
        applicationToInspect notNil ifTrue:[
cg@2314
   217
            s nextPutLine:('Application: ' , applicationToInspect class name).
cg@2700
   218
            genComponentNameForApplication value:applicationToInspect value:s.
cg@2314
   219
        ].
cg@2314
   220
cg@2699
   221
        "/ identity it as component
cg@2699
   222
cg@2300
   223
        s cr.
cg@2300
   224
        s nextPutLine:'Press:'.
cg@2435
   225
        s nextPutLine:'    ? to show the viewtree'.
cg@2314
   226
        applicationToInspect notNil ifTrue:[
cg@2300
   227
            s nextPutLine:'    a to inspect application (A to browse)'.
cg@2314
   228
            masterApplicationToInspect notNil ifTrue:[
cg@2300
   229
                s nextPutLine:'    m to inspect masterApplication (M to browse)'.
cg@2300
   230
            ].
cg@2300
   231
        ].
cg@2823
   232
        s nextPutLine:'    v to inspect view (V to browse)'.
cg@2823
   233
        topViewToInspect notNil ifTrue:[
cg@2823
   234
            s nextPutLine:'    t to inspect topView (T to browse)'.
cg@2823
   235
        ].
cg@2823
   236
        modelToInspect notNil ifTrue:[
cg@2823
   237
            s nextPutLine:'    o to inspect model (O to browse)'.
cg@2823
   238
        ].
cg@2823
   239
        s cr.
cg@2823
   240
        s nextPutLine:'RETURN to browse application.'.
cg@2823
   241
        s nextPutAll:'ESC or click to leave flyBy-info mode.'.
cg@2300
   242
    ]
cg@2300
   243
cg@2300
   244
    "
cg@2300
   245
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
   246
    "
cg@2823
   247
cg@2823
   248
    "Modified: / 12-11-2010 / 11:39:34 / cg"
cg@2300
   249
! !
cg@2300
   250
cg@2710
   251
!FlyByWindowInformation methodsFor:'private'!
cg@2710
   252
cg@2710
   253
targetViewInitiatesHelpViaSensor
cg@2710
   254
    ^ false
cg@2710
   255
! !
cg@2710
   256
cg@2300
   257
!FlyByWindowInformation methodsFor:'queries'!
cg@2300
   258
cg@2300
   259
toolTipFollowsMouse
cg@2300
   260
    ^ true
cg@2300
   261
! !
cg@2300
   262
cg@2300
   263
!FlyByWindowInformation methodsFor:'start & stop'!
cg@2300
   264
cg@2699
   265
initiateHelpFor:aView at:aPointOrNil
cg@2710
   266
    self initiateHelpFor:aView at:aPointOrNil now:true
cg@2699
   267
!
cg@2699
   268
cg@2699
   269
initiateHelpFor:aView at:aPointOrNil now:showItNow
cg@2702
   270
    finished == true ifTrue:[^ self].
cg@2699
   271
    super initiateHelpFor:aView at:aPointOrNil now:showItNow
cg@2699
   272
!
cg@2699
   273
cg@2300
   274
start
cg@2300
   275
    |l|
cg@2300
   276
cg@2702
   277
    finished == true ifTrue:[^ self].
cg@2702
   278
cg@2300
   279
    l := FlyByHelp currentHelpListener.
cg@2300
   280
    l notNil ifTrue:[
cg@2300
   281
        FlyByHelp stop.
cg@2300
   282
        cleanupAction := [ FlyByHelp start ].
cg@2300
   283
    ].
cg@2300
   284
    finishSemaphore := Semaphore new.
cg@2699
   285
    finished := false.
cg@2300
   286
    super start.
cg@2300
   287
!
cg@2300
   288
cg@2300
   289
stop
cg@2699
   290
    finished := true.
cg@2300
   291
    super stop.
cg@2300
   292
    cleanupAction value.
cg@2300
   293
    finishSemaphore notNil ifTrue:[
cg@2300
   294
        finishSemaphore signalIf.
cg@2300
   295
    ].
cg@2300
   296
!
cg@2300
   297
cg@2300
   298
waitUntilFinished
cg@2300
   299
    finishSemaphore wait.
cg@2300
   300
! !
cg@2300
   301
cg@2300
   302
!FlyByWindowInformation class methodsFor:'documentation'!
cg@2300
   303
cg@2300
   304
version
cg@2300
   305
    ^ '$Header$'
cg@2587
   306
!
cg@2587
   307
cg@2587
   308
version_CVS
cg@2587
   309
    ^ '$Header$'
cg@2300
   310
! !