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