VDBEventLogApplication.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 07 Jun 2014 14:42:45 +0100
changeset 1 09b3ef5606e7
child 2 9741a7683808
permissions -rw-r--r--
Added simple event log application. Initial stub for application containers (docking panels)

"{ Package: 'jv:vdb' }"

VDBAbstractApplication subclass:#VDBEventLogApplication
	instanceVariableNames:'eventList eventSelectionHolder'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-UI-Events'
!

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

    <resource: #canvas>

    ^ 
    #(FullSpec
       name: windowSpec
       window: 
      (WindowSpec
         label: 'Event Log'
         name: 'Event Log'
         min: (Point 10 10)
         bounds: (Rectangle 0 0 300 300)
       )
       component: 
      (SpecCollection
         collection: (
          (SelectionInListModelViewSpec
             name: 'EventList'
             layout: (LayoutFrame 0 0 0 0 0 1 0 1)
             model: eventSelectionHolder
             menu: eventMenu
             hasHorizontalScrollBar: true
             hasVerticalScrollBar: true
             listModel: eventList
             useIndex: false
             highlightMode: line
             doubleClickSelector: eventMenuInspect
           )
          )
        
       )
     )
! !

!VDBEventLogApplication class methodsFor:'menu specs'!

eventMenu
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

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


    "
     MenuEditor new openOnClass:VDBEventLogApplication andSelector:#eventMenu
     (Menu new fromLiteralArrayEncoding:(VDBEventLogApplication eventMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(Menu
        (
         (MenuItem
            enabled: hasEventSelectedHolder
            label: 'Inspect'
            itemValue: eventMenuInspect
          )
         )
        nil
        nil
      )
! !

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

! !

!VDBEventLogApplication methodsFor:'aspects'!

eventList
    <resource: #uiAspect>

    "automatically generated by UIPainter ..."

    "*** the code below creates a default model when invoked."
    "*** (which may not be the one you wanted)"
    "*** Please change as required and accept it in the browser."
    "*** (and replace this comment by something more useful ;-)"

    eventList isNil ifTrue:[
        eventList := List new.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/       eventList addDependent:self.
"/       eventList onChangeSend:#eventListChanged to:self.
    ].
    ^ eventList.
!

eventSelectionHolder
    <resource: #uiAspect>

    "automatically generated by UIPainter ..."

    "*** the code below creates a default model when invoked."
    "*** (which may not be the one you wanted)"
    "*** Please change as required and accept it in the browser."
    "*** (and replace this comment by something more useful ;-)"

    eventSelectionHolder isNil ifTrue:[
        eventSelectionHolder := ValueHolder new.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/       eventSelectionHolder addDependent:self.
"/       eventSelectionHolder onChangeSend:#eventSelectionHolderChanged to:self.
    ].
    ^ eventSelectionHolder.
! !

!VDBEventLogApplication methodsFor:'event handling'!

onEvent: aGDBEvent
    self eventList add: aGDBEvent

    "Created: / 07-06-2014 / 14:33:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBEventLogApplication methodsFor:'initialization & release'!

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

    debugger announcer
        when: GDBEvent send: #onEvent: to: self

    "Created: / 07-06-2014 / 14:33:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBEventLogApplication methodsFor:'menu actions'!

eventMenuInspect
    | event |

    event := self eventSelectionHolder value.
    event notNil ifTrue:[event inspect].

    "Modified: / 07-06-2014 / 14:36:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBEventLogApplication methodsFor:'menu queries'!

hasEventSelectedHolder
    ^ (AspectAdaptor forAspect:#notEmptyNil) subjectChannel: self eventSelectionHolder

    "Created: / 07-06-2014 / 14:37:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !