VDBStatusApplication.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 24 Sep 2019 00:43:53 +0100
changeset 186 8110a5e2c704
parent 154 26937faa5a97
child 241 9996050286c5
permissions -rw-r--r--
Always inspect varobj when double-clicking on a variable in variable inspector...

"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
"{ Package: 'jv:vdb' }"

"{ NameSpace: Smalltalk }"

VDBAbstractApplication subclass:#VDBStatusApplication
	instanceVariableNames:'statusTextHolder running commands'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-UI-Others'
!

!VDBStatusApplication class methodsFor:'documentation'!

copyright
"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
! !

!VDBStatusApplication class methodsFor:'interface specs'!

windowSpec
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:VDBStatusApplication andSelector:#windowSpec
     VDBStatusApplication new openInterface:#windowSpec
     VDBStatusApplication open
    "

    <resource: #canvas>

    ^ 
    #(FullSpec
       name: windowSpec
       uuid: 'd148ed70-316b-11e9-8b55-606720e43e2c'
       window: 
      (WindowSpec
         label: 'Debugger Status'
         name: 'Debugger Status'
         uuid: '7f956341-3167-11e9-8b55-606720e43e2c'
         min: (Point 10 10)
         bounds: (Rectangle 0 0 300 30)
       )
       component: 
      (SpecCollection
         collection: (
          (LabelSpec
             label: 'Label'
             name: 'StatusText'
             layout: (LayoutFrame 0 0 0 0 0 1 30 0)
             uuid: '7f956342-3167-11e9-8b55-606720e43e2c'
             translateLabel: true
             labelChannel: statusTextHolder
             adjust: left
             postBuildCallback: postBuildStatusText:
             usePreferredHeight: true
           )
          )
        
       )
     )
! !

!VDBStatusApplication class methodsFor:'plugIn spec'!

aspectSelectors
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this. If it is corrupted,
     the UIPainter may not be able to read the specification."

    "Return a description of exported aspects;
     these can be connected to aspects of an embedding application
     (if this app is embedded in a subCanvas)."

    ^ #(
        #debuggerHolder
      ).

! !

!VDBStatusApplication methodsFor:'aspects'!

statusTextHolder
    <resource: #uiAspect>

    statusTextHolder isNil ifTrue:[
        statusTextHolder := ValueHolder new.
        self enqueueDelayedUpdateStatusText.
    ].
    ^ statusTextHolder.

    "Modified: / 18-02-2019 / 08:39:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStatusApplication methodsFor:'change & update'!

enqueueDelayedUpdateStatusText
    self enqueueMessage: #delayedUpdateStatusText

    "Created: / 16-02-2019 / 08:20:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 18-02-2019 / 10:23:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStatusApplication methodsFor:'change & update-delayed'!

delayedUpdateStatusText
    | status |

    debugger notNil ifTrue:[
        running ifTrue:[ 
            status := resources string: 'RUN'
        ] ifFalse:[ 
            debugger hasPendingCommands ifTrue:[ 
                status := resources string: 'BSY'
            ] ifFalse:[ 
                status := resources string: 'RDY'
            ].
        ].
    ] ifFalse:[ 
        status := resources string: 'DIS'
    ].
    self statusTextHolder value:
        ('[%1] C: %2' bindWith: status with: commands)

    "Created: / 16-02-2019 / 08:19:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStatusApplication methodsFor:'event handling'!

onCommandEvent: event
    commands := commands + 1.
    self enqueueDelayedUpdateStatusText

    "Created: / 15-02-2019 / 21:41:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 16-02-2019 / 08:21:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

onCommandResultEvent: event
    self enqueueDelayedUpdateStatusText

    "Created: / 15-02-2019 / 21:41:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 16-02-2019 / 08:21:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

onRunningEvent: event
    running := true.
    commands := 0.
    self enqueueDelayedUpdateStatusText

    "Created: / 19-01-2019 / 23:46:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 16-02-2019 / 08:21:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

onStoppedEvent: event
    running := false.
    commands := 0.
    self enqueueDelayedUpdateStatusText

    "Created: / 19-01-2019 / 23:46:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 16-02-2019 / 08:21:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStatusApplication methodsFor:'hooks'!

postBuildStatusText: aLabel
    <resource: #uiCallback>

    aLabel font: self textFont

    "Modified: / 15-02-2019 / 21:50:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStatusApplication methodsFor:'initialization & release'!

initialize
    super initialize.
    running := false.
    commands := 0

    "Created: / 15-02-2019 / 21:47:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

subscribe   
    "Register for debugger events. To be overrided by subclasses"

    debugger announcer
        when: GDBRunningEvent       send: #onRunningEvent:      to: self;
        when: GDBStoppedEvent       send: #onStoppedEvent:      to: self;

        when: GDBCommandEvent       send: #onCommandEvent:      to: self;
        when: GDBCommandResultEvent send: #onCommandResultEvent: to: self. 

    running := debugger inferiors anySatisfy:[ :tg | tg isRunning and:[ tg isStopped not ] ].
    self enqueueDelayedUpdateStatusText

    "Created: / 15-02-2019 / 21:34:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 18-02-2019 / 08:39:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !