VDBEventLogApplication.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 14 Mar 2018 10:07:45 +0000
changeset 66 a6439bb6d8bc
parent 49 2ec7f7ed9242
child 106 2a95c11eb590
permissions -rw-r--r--
UI: add support to "pin" menus, i.e., turn them into a floating toolboxes This spares us the need of explicit toolbar in the UI and gives the user the freedom of turning every menu into always-visible toolbar is it suits her (actual) need. This idea is taken from good old NeXTstep UI. For now, this is only supported for "Exec" menu, but the support is generic so it would work any menu.

"
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:#VDBEventLogApplication
	instanceVariableNames:'eventList eventSelectionHolder'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-UI-Events'
!

!VDBEventLogApplication 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/
"
! !

!VDBEventLogApplication class methodsFor:'columns specs'!

listColumnSpec
    "This resource specification was automatically generated
     by the DataSetBuilder of ST/X."

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

    "
     DataSetBuilder new openOnClass:VDBEventLogApplication andSelector:#listColumnSpec
    "

    <resource: #tableColumns>

    ^#(
      (DataSetColumnSpec
         label: 'Class Name'
         labelButtonType: Button
         usePreferredWidth: true
         minWidth: 150
         height: heightOfFirstRow
         menuFromApplication: false
         printSelector: className
         canSelect: false
       )
      (DataSetColumnSpec
         label: 'Value'
         labelButtonType: Button
         width: 1.0
         height: heightOfFirstRow
         menuFromApplication: false
         printSelector: displayString
         canSelect: false
       )
      )
    
! !

!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: (
          (DataSetSpec
             name: 'EventList'
             layout: (LayoutFrame 0 0 0 0 0 1 0 1)
             model: eventSelectionHolder
             menu: eventMenu
             hasHorizontalScrollBar: true
             hasVerticalScrollBar: true
             dataList: eventList
             useIndex: false
             columnHolder: listColumnSpec
           )
          )
        
       )
     )
! !

!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 Event'
            itemValue: doInspect
          )
         (MenuItem
            label: 'Clear Events'
            itemValue: doClear
          )
         )
        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:'hooks'!

postBuildListView:aView
    <resource: #uiCallback>

    aView setupTableRenderer
        columnDescriptors:self class listColumnSpec;
        showHorizontalSeparators:false;
        showItemInAdditionToColumns: false.

    "Modified: / 10-06-2014 / 21:21:06 / 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'!

doClear
    <resource: #uiCallback>

    eventList removeAll

    "Modified: / 11-06-2017 / 20:18:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

doInspect
    | 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:#notEmptyOrNil) subjectChannel: self eventSelectionHolder

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

!VDBEventLogApplication class methodsFor:'documentation'!

version_HG

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