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

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