VDBRegisterListApplication.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 20 Jun 2019 16:11:12 +0100
changeset 174 3f6f51330641
parent 151 bc7626f46210
child 211 2bf7c99e6efa
permissions -rw-r--r--
UI: add "Edit" button to settings application to edit GDB and VDB init scripts

"
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 }"

VDBAbstractTreeApplication subclass:#VDBRegisterListApplication
	instanceVariableNames:'registerListHolder selectedRegisterHolder'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-UI-Others'
!

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

!VDBRegisterListApplication class methodsFor:'accessing'!

defaultWindowTitle
    ^ self resources string:'Registers'

    "Created: / 11-07-2017 / 16:37:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 01-10-2018 / 12:08:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBRegisterListApplication class methodsFor:'interface specs'!

columnsSpec
    "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:VDBFrameApplication andSelector:#columnsSpec
    "

    <resource: #tableColumns>

    ^#(
      (DataSetColumnSpec
         label: 'Value'
         labelAlignment: left
         labelButtonType: Button
         width: 1.0
         height: heightOfFirstRow
         menuFromApplication: false
         printSelector: value
         backgroundSelector: backgroundColor
         showRowSeparator: false
         showColSeparator: false
       )
      )
    
! !

!VDBRegisterListApplication 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
        #registerListHolder
        #selectedRegisterHolder
      ).

    "Modified: / 27-09-2018 / 20:32:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBRegisterListApplication class methodsFor:'startup-web applications'!

initialPageSpec
    "this is only required for web-applications"

    ^ self shouldImplement
!

pageSpecs
    "this is only required for web-applications"

    ^ self shouldImplement
! !

!VDBRegisterListApplication methodsFor:'aspects'!

backgroundColorFor: aVDBRegisterPresenter
    ^ aVDBRegisterPresenter register hasChanged
        ifTrue:[ Color yellow lighter lighter ]
        ifFalse:[ nil ]

    "Created: / 01-02-2018 / 09:08:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 27-09-2018 / 20:41:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

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

    registerListHolder isNil ifTrue:[
        registerListHolder := ValueHolder with: #().
        registerListHolder addDependent:self.
    ].
    ^ registerListHolder

    "Created: / 27-09-2018 / 20:31:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

registerListHolder:something
    "set the 'variableObjectListHolder' value holder (automatically generated)"

    |oldValue newValue|

    registerListHolder notNil ifTrue:[
        oldValue := registerListHolder value.
        registerListHolder removeDependent:self.
    ].
    registerListHolder := something.
    registerListHolder notNil ifTrue:[
        registerListHolder addDependent:self.
    ].
    newValue := registerListHolder value.
    oldValue ~~ newValue ifTrue:[
        self update:#value with:newValue from:registerListHolder.
    ].

    "Created: / 27-09-2018 / 20:31:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

selectedRegisterHolder
    "return/create the 'selectedVariableHolder' value holder (automatically generated)"
    
    selectedRegisterHolder isNil ifTrue:[
        selectedRegisterHolder := ValueHolder new.
        selectedRegisterHolder addDependent:self.
    ].
    ^ selectedRegisterHolder

    "Created: / 27-09-2018 / 20:31:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

selectedRegisterHolder:something 
    "set the 'selectedVariableHolder' value holder (automatically generated)"
    
    | oldValue  newValue |

    selectedRegisterHolder notNil ifTrue:[
        oldValue := selectedRegisterHolder value.
        selectedRegisterHolder removeDependent:self.
    ].
    selectedRegisterHolder := something.
    selectedRegisterHolder notNil ifTrue:[
        selectedRegisterHolder addDependent:self.
    ].
    newValue := selectedRegisterHolder value.
    oldValue ~~ newValue ifTrue:[
        self 
            update:#value
            with:newValue
            from:selectedRegisterHolder.
    ].

    "Created: / 27-09-2018 / 20:31:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBRegisterListApplication methodsFor:'change & update'!

update:aspect with:param from:sender
    "Invoked when an object that I depend upon sends a change notification."

    sender == registerListHolder ifTrue:[ 
         self enqueueDelayedUpdateContents.
         ^ self.
    ].
    super update:aspect with:param from:sender

    "Modified: / 14-02-2019 / 16:31:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

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

delayedUpdateInternalList
    | registers registerPs |

    registers := self registerListHolder value ? #().
    registerPs := registers collect:[ :reg | VDBRegisterPresenter new setRegister: reg ].
    self internalListHolder root 
        children: registerPs;
        expand.

    "Modified: / 28-09-2018 / 06:50:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

delayedUpdateSelection
    | internalSelection |

    internalSelection := self internalSelectionHolder value.
    internalSelection notNil ifTrue:[
        self selectedRegisterHolder value: internalSelection register
    ] ifFalse:[ 
        self selectedRegisterHolder value: nil
    ].

    "Modified: / 27-09-2018 / 21:08:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBRegisterListApplication methodsFor:'drag & drop'!

dropObjects:aCollectionOfDropObjects
    "drop manager wants to drop.
     This is ony sent, if #canDrop: returned true.
     Must be redefined in order for drop to work."

    ^ self shouldImplement
! !

!VDBRegisterListApplication methodsFor:'event handling'!

onStoppedEvent: aGDBStoppedEvent
    self enqueueDelayedInvalidateInternalList

    "Created: / 01-02-2018 / 23:14:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBRegisterListApplication methodsFor:'initialization & release'!

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

    debugger announcer
        when: GDBStoppedEvent               send: #onStoppedEvent: to: self

    "Created: / 01-02-2018 / 23:07:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBRegisterListApplication class methodsFor:'documentation'!

version_HG

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