VDBAbstractListApplication.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 17 Jan 2018 07:03:58 +0000
changeset 55 fd2637e6d153
parent 54 d974a70c70ad
child 57 8cd259e11b9e
permissions -rw-r--r--
UI: refactored updates in thread / stack view * Do not reload tree on thread exit event. This slows down things a lot on Windows when debugging Smalltalk/X as threads are created and terminated every now and again. Only do that on stopped event. * Do not reload three on running event - thre tree would be not up to date anyways, no need to bother.

"
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:#VDBAbstractListApplication
	instanceVariableNames:'internalListHolder internalListView internalSelectionHolder'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-UI-Abstract'
!

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

!VDBAbstractListApplication class methodsFor:'interface specs'!

columnsSpec
    ^ #()

    "Created: / 02-06-2017 / 07:26:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

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

    <resource: #canvas>

    ^ 
    #(FullSpec
       name: windowSpec
       window: 
      (WindowSpec
         label: 'VDBAbstractListApplication'
         name: 'VDBAbstractListApplication'
         min: (Point 10 10)
         bounds: (Rectangle 0 0 300 300)
       )
       component: 
      (SpecCollection
         collection: (
          (SelectionInListModelViewSpec
             name: 'SelectionInListModelView1'
             layout: (LayoutFrame 0 0 0 0 0 1 0 1)
             model: internalSelectionHolder
             menu: contextMenu
             hasHorizontalScrollBar: true
             hasVerticalScrollBar: true
             listModel: internalListHolder
             useIndex: false
             highlightMode: line
             doubleClickSelector: doDoubleClick
             postBuildCallback: postBuildInternalListView:
           )
          )
        
       )
     )

    "Modified: / 11-07-2017 / 15:19:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBAbstractListApplication class methodsFor:'menu specs'!

contextMenu
    "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:VDBAbstractListApplication andSelector:#contextMenu
     (Menu new fromLiteralArrayEncoding:(VDBAbstractListApplication contextMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(Menu
        (
         (MenuItem
            label: 'Item Menu Slice'
            submenuChannel: contextMenuItemSlice
            isMenuSlice: true
          )
         (MenuItem
            label: 'Inspect Menu Slice'
            submenuChannel: contextMenuInspectSlice
            isMenuSlice: true
          )
         )
        nil
        nil
      )
!

contextMenuInspectSlice
    "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:VDBAbstractListApplication andSelector:#contextMenuInspectSlice
     (Menu new fromLiteralArrayEncoding:(VDBAbstractListApplication contextMenuInspectSlice)) startUp
    "

    <resource: #menu>

    ^ 
     #(Menu
        (
         (MenuItem
            enabled: hasSelection
            label: 'Inspect Model'
            itemValue: doInspectModel
          )
         (MenuItem
            label: 'Inspect Presenter'
            itemValue: doInspectPresenter
          )
         (MenuItem
            label: '-'
          )
         (MenuItem
            label: 'Update'
            itemValue: duUpdateList
          )
         )
        nil
        nil
      )
! !

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

! !

!VDBAbstractListApplication class methodsFor:'queries'!

isAbstract
    "Return if this class is an abstract class.
     True is returned here for myself only; false for subclasses.
     Abstract subclasses must redefine again."

    ^ self == VDBAbstractListApplication.
! !

!VDBAbstractListApplication methodsFor:'actions'!

postBuildInternalListView: aView
    <resource: #uiCallback>

    | columns |

    internalListView := aView.
    internalListView font: CodeView defaultFont.

    columns := self class columnsSpec.
    columns notEmptyOrNil ifTrue:[
        | renderer |

        renderer := aView setupTableRenderer.
        renderer columnDescriptors: columns
    ].

    "Modified: / 11-06-2017 / 22:16:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBAbstractListApplication methodsFor:'aspects-private'!

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

    internalListHolder isNil ifTrue:[
        internalListHolder := ValueHolder new.
    ].
    ^ internalListHolder

    "Created: / 27-02-2015 / 15:55:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

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

    internalSelectionHolder isNil ifTrue:[
        internalSelectionHolder := ValueHolder new.
        internalSelectionHolder addDependent:self.
    ].
    ^ internalSelectionHolder
! !

!VDBAbstractListApplication methodsFor:'change & update'!

enqueueDelayedUpdate: selector
    self window sensor pushUserEvent: selector for:self

    "Created: / 17-01-2018 / 06:50:29 / jv"
!

enqueueDelayedUpdate: selector with: argument
    self window sensor pushUserEvent: selector for:self  withArgument: argument

    "Created: / 17-01-2018 / 06:50:39 / jv"
!

enqueueDelayedUpdateInternalList
   self enqueueDelayedUpdate: #delayedUpdateInternalList

    "Created: / 20-09-2014 / 23:05:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 17-01-2018 / 06:51:55 / jv"
!

enqueueDelayedUpdateSelection
    self enqueueDelayedUpdate: #delayedUpdateSelection

    "Created: / 27-02-2015 / 15:35:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 17-01-2018 / 06:52:09 / jv"
!

update:aspect with:param from:sender
    "Invoked when an object that I depend upon sends a change notification."
    sender == internalSelectionHolder ifTrue:[ 
        self enqueueDelayedUpdateSelection.
        ^ self
    ].

    super update:aspect with:param from:sender

    "Created: / 27-02-2015 / 15:44:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

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

delayedUpdateInternalList
    "raise an error: must be redefined in concrete subclass(es)"

    ^ self subclassResponsibility
!

delayedUpdateSelection
    "raise an error: must be redefined in concrete subclass(es)"

    ^ self subclassResponsibility
! !

!VDBAbstractListApplication methodsFor:'hooks'!

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

    self enqueueDelayedUpdateInternalList

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

!VDBAbstractListApplication methodsFor:'menu'!

contextMenu
    ^ [
        (Menu decodeFromLiteralArray: self class contextMenu)
            receiver:self;
            findGuiResourcesIn:self;
            yourself
    ]

    "Created: / 16-01-2018 / 14:29:05 / jv"
    "Modified: / 16-01-2018 / 22:02:37 / jv"
    "Modified (comment): / 16-01-2018 / 23:26:46 / jv"
!

contextMenuItemSlice
    | item menu |

    item := self internalSelectionHolder value.
    item isNil ifTrue:[ 
        menu := Menu new.
    ] ifFalse:[ 
        menu := item contextMenu.
    ].
    ^ menu.

    "Created: / 16-01-2018 / 13:37:08 / jv"
    "Modified: / 16-01-2018 / 22:03:45 / jv"
! !

!VDBAbstractListApplication methodsFor:'menu actions'!

doInspectModel
    | selection |

    selection := self internalSelectionHolder value.
    selection notEmptyOrNil ifTrue:[ 
        selection isThreadGroupPresenter ifTrue: [ selection threadGroup inspect ].
        selection isThreadPresenter ifTrue: [ selection thread inspect ].
        selection isFramePresenter ifTrue: [ selection frame inspect ].    
        selection isVariablePresenter ifTrue: [ selection variable inspect ].    
        selection isBreakpointPresenter ifTrue: [ selection breakpoint inspect ].    
    ].

    "Modified: / 11-07-2017 / 11:49:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

doInspectPresenter
    self internalSelectionHolder value inspect

    "Modified: / 22-09-2014 / 01:17:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

duUpdateList
    <resource: #uiCallback>

    self enqueueDelayedUpdateInternalList

    "Modified: / 12-06-2017 / 12:00:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBAbstractListApplication methodsFor:'queries'!

hasSelection
    ^ self internalSelectionHolder value notEmptyOrNil

    "Modified: / 22-09-2014 / 01:13:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !