VDBStackApplication.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 19 Sep 2014 10:05:54 +0100
changeset 16 fc1898815ab6
parent 15 7cddd476fb00
child 17 c5ee4ea44165
permissions -rw-r--r--
Temporary commit: some more work on displaying source code.

"{ Package: 'jv:vdb' }"

VDBAbstractApplication subclass:#VDBStackApplication
	instanceVariableNames:'selectionHolder listHolder'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-UI-Others'
!


!VDBStackApplication 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:VDBStackApplication andSelector:#windowSpec
     VDBStackApplication new openInterface:#windowSpec
     VDBStackApplication open
    "

    <resource: #canvas>

    ^ 
    #(FullSpec
       name: windowSpec
       window: 
      (WindowSpec
         label: 'Execution Stack'
         name: 'Execution Stack'
         min: (Point 10 10)
         bounds: (Rectangle 0 0 300 300)
       )
       component: 
      (SpecCollection
         collection: (
          (HierarchicalListViewSpec
             name: 'Stack'
             layout: (LayoutFrame 0 0 0 0 0 1 0 1)
             model: selectionHolder
             hasHorizontalScrollBar: true
             hasVerticalScrollBar: true
             listModel: listHolder
             useIndex: false
             highlightMode: line
           )
          )
        
       )
     )

    "Modified: / 18-09-2014 / 00:16:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStackApplication 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
      ).

! !

!VDBStackApplication methodsFor:'aspects'!

listHolder
    "return/create the 'listHolder' value holder (automatically generated)"

    listHolder isNil ifTrue:[
        listHolder := HierarchicalList new.
        listHolder showRoot: false.
        listHolder root: HierarchicalItem new.
    ].
    ^ listHolder

    "Modified: / 17-09-2014 / 23:03:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

selectionHolder
    "return/create the 'selectionHolder' value holder (automatically generated)"

    selectionHolder isNil ifTrue:[
        selectionHolder := ValueHolder new.
    ].
    ^ selectionHolder
! !

!VDBStackApplication methodsFor:'change & update'!

updateList
    | inferior thread root list |

    debugger isNil ifTrue:[  
        self listHolder root children:#().
        ^ self.
    ].
    debugger inferiors isEmptyOrNil ifTrue:[ 
        self listHolder root children:#().
        ^ self.
    ].
    debugger inferiors size > 1 ifTrue:[ 
        self error: 'Only one inferior supported'.
        ^ self.
    ].
    inferior := debugger inferiors anElement.
    inferior threads isEmptyOrNil ifTrue:[ 
        self listHolder root children:#().
        ^ self.
    ].
    debugger inferiors size > 1 ifTrue:[ 
        self error: 'Only one thread supported (yet)'.
        ^ self.
    ].          
    thread := inferior threads anElement.
    thread isTerminated ifTrue:[ 
        self listHolder root children:#().
        ^ self.
    ].
    root := self listHolder root.
    list := thread stack collect:[ :frame | 
        HierarchicalItemWithLabelAndIconAndValue new
            label: frame printString;
            value: frame;
            parent: root.
    ].
    root children: list.
    root expand.

    "Created: / 17-09-2014 / 23:04:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 18-09-2014 / 23:27:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStackApplication methodsFor:'change & update-dekayed'!

delayedUpdateList
    self window sensor pushUserEvent: #updateList for: self

    "Created: / 18-09-2014 / 00:25:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStackApplication methodsFor:'event handling'!

onStoppedEvent: event
    self delayedUpdateList.

    "Created: / 17-09-2014 / 23:04:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 18-09-2014 / 23:30:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

onThreadExitedEvent: event
    self delayedUpdateList.

    "Created: / 18-09-2014 / 23:30:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

onThreadGroupExitedEvent: event
    self delayedUpdateList.

    "Created: / 18-09-2014 / 23:30:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStackApplication methodsFor:'hooks'!

commonPostOpen
    "a common hook for postOpenWith:, postOpenAsSubcanvasWith: and postOpenAsDialogWith:."

    self delayedUpdateList

    "Created: / 18-09-2014 / 00:29:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStackApplication methodsFor:'initialization & release'!

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

    debugger announcer
        when: GDBStoppedEvent           send: #onStoppedEvent: to: self;
        when: GDBThreadExitedEvent      send: #onThreadExitedEvent: to: self;
        when: GDBThreadGroupExitedEvent send: #onThreadGroupExitedEvent: to: self

    "Created: / 07-06-2014 / 14:33:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 18-09-2014 / 23:30:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBStackApplication class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !