FlyByWindowInformation.st
author Claus Gittinger <cg@exept.de>
Mon, 02 Nov 2009 15:55:15 +0100
changeset 2702 96f1dbce3d00
parent 2700 bad11f9b735f
child 2710 0ce76feb3f91
permissions -rw-r--r--
changed:5 methods
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@2699
    86
cg@2702
    87
    finished == true ifTrue:[^ self].
cg@2699
    88
    super handleMouseIn:aView x:x y:y
cg@2699
    89
!
cg@2699
    90
cg@2300
    91
keyPress:key x:x y:y view:aView
cg@2435
    92
    |obj action lcKey|
cg@2300
    93
cg@2300
    94
    key == #Escape ifTrue:[
cg@2300
    95
        self stop.
cg@2300
    96
        ^ true
cg@2300
    97
    ].
cg@2300
    98
cg@2435
    99
    key == $? ifTrue:[
cg@2435
   100
        [
cg@2435
   101
            WindowTreeView openOn:(lastView topView) initialSelection:lastView.
cg@2435
   102
        ] fork.
cg@2435
   103
        self stop.
cg@2435
   104
        ^ true.
cg@2300
   105
    ].
cg@2435
   106
cg@2435
   107
    key isCharacter ifTrue:[
cg@2435
   108
        lcKey := key asLowercase.
cg@2435
   109
cg@2435
   110
        lcKey == $a ifTrue:[
cg@2435
   111
            obj := lastApplication
cg@2300
   112
        ].
cg@2435
   113
        lcKey == $o ifTrue:[
cg@2435
   114
            obj := lastView model
cg@2435
   115
        ].
cg@2435
   116
        lcKey == $m ifTrue:[
cg@2435
   117
            obj := lastApplication masterApplication
cg@2435
   118
        ].
cg@2435
   119
        lcKey == $v ifTrue:[
cg@2435
   120
            obj := lastView
cg@2435
   121
        ].
cg@2435
   122
        lcKey == $t ifTrue:[
cg@2435
   123
            obj := lastView topView
cg@2435
   124
        ].
cg@2435
   125
        obj notNil ifTrue:[
cg@2435
   126
            key isLowercase ifTrue:[
cg@2435
   127
                action := [ obj inspect ].
cg@2435
   128
            ] ifFalse:[
cg@2435
   129
                action := [ obj browse ].
cg@2435
   130
            ].
cg@2435
   131
            action forkAt:8.
cg@2435
   132
        ].
cg@2300
   133
    ].
cg@2300
   134
cg@2300
   135
    ^ true
cg@2300
   136
! !
cg@2300
   137
cg@2300
   138
!FlyByWindowInformation methodsFor:'help texts'!
cg@2300
   139
cg@2300
   140
helpTextFor:aView at:aPointOrNil
cg@2699
   141
    "generate the text to be shown as popup-flyby info"
cg@2699
   142
cg@2300
   143
    lastView := aView.
cg@2300
   144
    lastApplication := aView application.
cg@2300
   145
cg@2300
   146
    ^ String streamContents:[:s |
cg@2700
   147
        |topViewToInspect applicationToInspect masterApplicationToInspect modelToInspect
cg@2700
   148
         genComponentNameForApplication|
cg@2700
   149
cg@2700
   150
        genComponentNameForApplication := [:app :s |
cg@2700
   151
                (app notNil 
cg@2700
   152
                and:[ app builder notNil ]) ifTrue:[
cg@2700
   153
                    |components v|
cg@2700
   154
cg@2700
   155
                    components := app builder namedComponents.
cg@2700
   156
cg@2700
   157
                    v := aView.
cg@2700
   158
                    [   (components includes:v) not
cg@2700
   159
                        and:[v container notNil]
cg@2700
   160
                    ] whileTrue:[
cg@2700
   161
                        v := v container.
cg@2700
   162
                    ].
cg@2700
   163
                    (components includes:v) ifTrue:[
cg@2700
   164
                        |k|
cg@2700
   165
cg@2700
   166
                        k := components keyAtValue:v.
cg@2700
   167
                        v == aView ifTrue:[
cg@2700
   168
                            s nextPutLine:('   Component: ' , k).
cg@2700
   169
                        ] ifFalse:[
cg@2700
   170
                            s nextPutLine:('   Subview of Component: ' , k).
cg@2700
   171
                        ].
cg@2700
   172
                    ].
cg@2700
   173
                ].
cg@2700
   174
            ].
cg@2314
   175
cg@2300
   176
        aView topView ~~ aView ifTrue:[
cg@2314
   177
            topViewToInspect := aView topView.
cg@2300
   178
        ].
cg@2300
   179
        lastApplication notNil ifTrue:[
cg@2314
   180
            applicationToInspect := lastApplication.
cg@2314
   181
            masterApplicationToInspect := lastApplication masterApplication.
cg@2700
   182
            masterApplicationToInspect == applicationToInspect ifTrue:[
cg@2700
   183
                masterApplicationToInspect := nil
cg@2700
   184
            ].
cg@2314
   185
        ].
cg@2314
   186
        aView model notNil ifTrue:[
cg@2314
   187
            modelToInspect := aView model.
cg@2314
   188
            ((modelToInspect == applicationToInspect)
cg@2314
   189
            or:[ modelToInspect == masterApplicationToInspect ]) ifTrue:[
cg@2314
   190
                modelToInspect := nil.
cg@2300
   191
            ].
cg@2300
   192
        ].
cg@2314
   193
cg@2352
   194
        s nextPutLine:('View: ' , aView class name, ' "',aView name printString,'"').
cg@2314
   195
        modelToInspect notNil ifTrue:[
cg@2314
   196
            s nextPutLine:('Model: ' , modelToInspect class name).
cg@2314
   197
        ].
cg@2314
   198
        topViewToInspect notNil ifTrue:[
cg@2314
   199
            s nextPutLine:('Topview: ' , topViewToInspect class name).
cg@2314
   200
        ].
cg@2700
   201
        masterApplicationToInspect notNil ifTrue:[
cg@2700
   202
            s nextPutLine:('Masterapplication: ' , masterApplicationToInspect class name).
cg@2700
   203
            genComponentNameForApplication value:masterApplicationToInspect value:s.
cg@2700
   204
        ].
cg@2314
   205
        applicationToInspect notNil ifTrue:[
cg@2314
   206
            s nextPutLine:('Application: ' , applicationToInspect class name).
cg@2700
   207
            genComponentNameForApplication value:applicationToInspect value:s.
cg@2314
   208
        ].
cg@2314
   209
cg@2699
   210
        "/ identity it as component
cg@2699
   211
cg@2300
   212
        s cr.
cg@2300
   213
        s nextPutLine:'Press:'.
cg@2435
   214
        s nextPutLine:'    ? to show the viewtree'.
cg@2300
   215
        s nextPutLine:'    v to inspect view (V to browse)'.
cg@2314
   216
        modelToInspect notNil ifTrue:[
cg@2314
   217
            s nextPutLine:'    o to inspect model (O to browse)'.
cg@2314
   218
        ].
cg@2314
   219
        topViewToInspect notNil ifTrue:[
cg@2300
   220
            s nextPutLine:'    t to inspect topView (T to browse)'.
cg@2300
   221
        ].
cg@2314
   222
        applicationToInspect notNil ifTrue:[
cg@2300
   223
            s nextPutLine:'    a to inspect application (A to browse)'.
cg@2314
   224
            masterApplicationToInspect notNil ifTrue:[
cg@2300
   225
                s nextPutLine:'    m to inspect masterApplication (M to browse)'.
cg@2300
   226
            ].
cg@2300
   227
        ].
cg@2493
   228
        s nextPutAll:'ESC or button to leave flyBy-info mode.'.
cg@2300
   229
    ]
cg@2300
   230
cg@2300
   231
    "
cg@2300
   232
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
   233
    "
cg@2300
   234
! !
cg@2300
   235
cg@2300
   236
!FlyByWindowInformation methodsFor:'queries'!
cg@2300
   237
cg@2300
   238
toolTipFollowsMouse
cg@2300
   239
    ^ true
cg@2300
   240
! !
cg@2300
   241
cg@2300
   242
!FlyByWindowInformation methodsFor:'start & stop'!
cg@2300
   243
cg@2699
   244
initiateHelpFor:aView at:aPointOrNil
cg@2702
   245
    finished == true ifTrue:[^ self].
cg@2700
   246
    super initiateHelpFor:aView at:aPointOrNil 
cg@2699
   247
!
cg@2699
   248
cg@2699
   249
initiateHelpFor:aView at:aPointOrNil now:showItNow
cg@2702
   250
    finished == true ifTrue:[^ self].
cg@2699
   251
    super initiateHelpFor:aView at:aPointOrNil now:showItNow
cg@2699
   252
!
cg@2699
   253
cg@2300
   254
start
cg@2300
   255
    |l|
cg@2300
   256
cg@2702
   257
    finished == true ifTrue:[^ self].
cg@2702
   258
cg@2300
   259
    l := FlyByHelp currentHelpListener.
cg@2300
   260
    l notNil ifTrue:[
cg@2300
   261
        FlyByHelp stop.
cg@2300
   262
        cleanupAction := [ FlyByHelp start ].
cg@2300
   263
    ].
cg@2300
   264
    finishSemaphore := Semaphore new.
cg@2699
   265
    finished := false.
cg@2300
   266
    super start.
cg@2300
   267
!
cg@2300
   268
cg@2300
   269
stop
cg@2699
   270
    finished := true.
cg@2300
   271
    super stop.
cg@2300
   272
    cleanupAction value.
cg@2300
   273
    finishSemaphore notNil ifTrue:[
cg@2300
   274
        finishSemaphore signalIf.
cg@2300
   275
    ].
cg@2300
   276
!
cg@2300
   277
cg@2300
   278
waitUntilFinished
cg@2300
   279
    finishSemaphore wait.
cg@2300
   280
! !
cg@2300
   281
cg@2300
   282
!FlyByWindowInformation class methodsFor:'documentation'!
cg@2300
   283
cg@2300
   284
version
cg@2300
   285
    ^ '$Header$'
cg@2587
   286
!
cg@2587
   287
cg@2587
   288
version_CVS
cg@2587
   289
    ^ '$Header$'
cg@2300
   290
! !